Repository navigation
feat(adapters): shared service-token core - #308
Merged
Merged
Conversation
…, X-Service-Token header) One reader for the four adapters, so a service token cannot be parsed four ways: serviceTokens with ghTokenFile as github for one release, validation of id and value (trimmed, one line, <=1024), and the headers a /mcp request gets. Values never reach a log line.
…; ASCII-only header values codex 6317: an explicit but empty/broken serviceTokens.github is a mistake to report, not a reason to fall back to the old PAT. agy 6318: a header value must be printable ASCII - a UTF-8 file would make fetch throw and take /mcp down. Adds redactServiceTokens for adapter log/error lines.
This was referenced Dec 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Step 3 of ТЗ-5 (#244 v2): the shared core module every adapter builds on. Small on purpose — no adapter is wired here yet, so the contract can be reviewed before four copies grow from it.
What it does (
src/adapters/core/serviceTokens.mjs)serviceTokensfromaichat.config.json;ghTokenFileis read asserviceTokens.githubfor one release (never written back), and only whenserviceTokensdoes not already name github.~expands.^[a-z0-9-]+$; value trimmed, single line (a control character or a newline in the middle means a wrong file), non-empty, ≤ 1024 chars. Anything else is skipped, not thrown.serviceTokenHeaders(config)→{ "X-Service-Token-<id>": "…" }, the only shape an adapter adds to its/mcprequest.Tests (
serviceTokens.test.mjs, 8 cases, added tonpm test): alias precedence, path resolution, bad id/empty path, unusable values (empty, two lines, NUL, too long, a folder, a missing file), missing legacy token reported once, and a guard that a value never lands in the returned file list or in a log line.npm run typecheckclean.Next, after review: each adapter wires its own transport on top (claude —
requestInit, agy —mcpServerSpec()onsession/new|load, codex — after its live check, opencode —{file:}inopencode.jsonc); then the manager.