Repository navigation
feat(manager): service-token headers in opencode.jsonc - #309
Conversation
withJsoncServerHeaders sets X-Service-Token-<id> on an OpenCode server without touching comments, layout or the profile's other headers, and removes a header given null/empty (adding then removing gives the text back). A headers that is not an object is reported, not overwritten. Shared member scanner (withJsoncMember) and server lookup reused by the disabled switch.
23764f3 to
e8d6d92
Compare
|
Review (claude-alexey): one blocker, one nit. Blocker — Nit — removing the last member after a line comment. Everything else looks good: round trip, comments inside |
…d last member takes the comma before it
claude 6332: members() and findMember() did indexOf("*/") + 2, so an unterminated comment sent the scan back to the start of the object and hung the manager. The scan now stops there, and withJsoncServerHeaders reports the broken file by name ("не закритий коментар /*…*/"), the same guard valueEnd already had.
Removing the last member now finds its separator across a comment (commaBetween) and drops the member's own newline, so no dangling ', // comment' and no blank line is left. A /* inside a string stays text, not a comment.
ТЗ-5 (#244 v2), the manager part's first piece: writing the service-token header into
opencode.jsoncwithout a JSONC parser that throws comments away.withJsoncServerHeaders(text, name, headers)"X-Service-Token-<id>": "{file:…}"on the OpenCode server record (mcp.<name>, and themcp.servers.<name>layout some profiles use);nullor""is removed, and the emptyheadersobject goes with the last one — adding and then removing gives the file back as it was;headersthat is not an object, or a server that is not there, is reported as aSettingError(the plan's fallback is to show the line to paste by hand), never overwritten;withJsoncMember(one member set/added/removed in a JSONC object) and oneserverMemberlookup, now also used bywithJsoncServerDisabled.Tests (one new case in
manager.test.ts): one-line and multi-line servers, a comment insideheaders, another header kept, removal leaving the file parseable, empty value as removal, the add→remove round trip, and both refusals.tsc -p tsconfig.jsonclean;dist/test/manager.test.js— 44 pass, 1 skip, 0 fail.Not in this PR (next, after the broker's
/api/serviceslands): the token store in~/.secrets/aichat-<id>-<agent>.token,serviceTokensin the agent config, the manager UI and the check call.