opencode-acp-client 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +220 -2
  3. package/README.zh.md +199 -0
  4. package/dist/acp/capabilities.d.ts +168 -0
  5. package/dist/acp/capabilities.js +240 -0
  6. package/dist/acp/capabilities.js.map +1 -0
  7. package/dist/acp/client.d.ts +241 -0
  8. package/dist/acp/client.js +767 -0
  9. package/dist/acp/client.js.map +1 -0
  10. package/dist/acp/types.d.ts +228 -0
  11. package/dist/acp/types.js +23 -0
  12. package/dist/acp/types.js.map +1 -0
  13. package/dist/acp-replay.d.ts +60 -0
  14. package/dist/acp-replay.js +188 -0
  15. package/dist/acp-replay.js.map +1 -0
  16. package/dist/contract.d.ts +435 -0
  17. package/dist/contract.js +126 -0
  18. package/dist/contract.js.map +1 -0
  19. package/dist/daemons.d.ts +39 -0
  20. package/dist/daemons.js +112 -0
  21. package/dist/daemons.js.map +1 -0
  22. package/dist/index.d.ts +268 -0
  23. package/dist/index.js +1882 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/opencode-bin.d.ts +73 -0
  26. package/dist/opencode-bin.js +109 -0
  27. package/dist/opencode-bin.js.map +1 -0
  28. package/dist/project.d.ts +81 -0
  29. package/dist/project.js +230 -0
  30. package/dist/project.js.map +1 -0
  31. package/dist/server.d.ts +743 -0
  32. package/dist/server.js +5029 -0
  33. package/dist/server.js.map +1 -0
  34. package/dist/session-map.d.ts +89 -0
  35. package/dist/session-map.js +305 -0
  36. package/dist/session-map.js.map +1 -0
  37. package/dist/sessions-command.d.ts +70 -0
  38. package/dist/sessions-command.js +188 -0
  39. package/dist/sessions-command.js.map +1 -0
  40. package/dist/sse.d.ts +40 -0
  41. package/dist/sse.js +147 -0
  42. package/dist/sse.js.map +1 -0
  43. package/dist/state.d.ts +161 -0
  44. package/dist/state.js +135 -0
  45. package/dist/state.js.map +1 -0
  46. package/dist/subagent-sessions.d.ts +71 -0
  47. package/dist/subagent-sessions.js +107 -0
  48. package/dist/subagent-sessions.js.map +1 -0
  49. package/dist/translate/events.d.ts +231 -0
  50. package/dist/translate/events.js +1244 -0
  51. package/dist/translate/events.js.map +1 -0
  52. package/dist/upgrade.d.ts +56 -0
  53. package/dist/upgrade.js +162 -0
  54. package/dist/upgrade.js.map +1 -0
  55. package/package.json +66 -4
@@ -0,0 +1,112 @@
1
+ /**
2
+ * A tiny registry of bridge processes, so a user can find and reap them.
3
+ *
4
+ * The bridge already spawns everything by explicit PID (never a name-based
5
+ * kill), but a bridge that is SIGKILLed — or a terminal that dies with it —
6
+ * takes its cleanup with it, and the agent it spawned can end up orphaned. We
7
+ * have paid for that in practice: orphaned agents hold a backend's session lock
8
+ * and the next restore fails with "Internal error" while our own log looks
9
+ * healthy. There is no way to list "the bridges I started" from the process
10
+ * table alone (a manually started `dsh --profile acp` looks identical), so each
11
+ * bridge records itself here and the `ps` command reports it.
12
+ *
13
+ * The file is per-process (`<pid>.json`) and removed on a clean shutdown, so a
14
+ * stale entry IS the signal: the process is gone without cleaning up. Nothing
15
+ * here is authoritative — `isAlive` is a `kill(pid, 0)` probe at read time, and
16
+ * a recycled pid is possible in theory; the metadata is for the human, the pid
17
+ * is only trusted together with it.
18
+ */
19
+ import { mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
20
+ import { homedir } from 'node:os';
21
+ import { join } from 'node:path';
22
+ /**
23
+ * Where the records live. `OPENCODE_ACP_CLIENT_DAEMONS` overrides it — the test
24
+ * suite points it at a scratch directory, exactly like the session map.
25
+ */
26
+ export function daemonsDir(env = process.env) {
27
+ const override = env['OPENCODE_ACP_CLIENT_DAEMONS'];
28
+ return override && override.trim() !== ''
29
+ ? override
30
+ : join(homedir(), '.opencode-acp-client', 'daemons');
31
+ }
32
+ /** Whether a pid exists. Signal 0 does the permission check and nothing else. */
33
+ export function isAlive(pid) {
34
+ if (!Number.isInteger(pid) || pid <= 0)
35
+ return false;
36
+ try {
37
+ process.kill(pid, 0);
38
+ return true;
39
+ }
40
+ catch (err) {
41
+ // EPERM means it exists but belongs to someone else — still alive.
42
+ return err.code === 'EPERM';
43
+ }
44
+ }
45
+ /** Record this process. Best effort: a failure here must not stop the bridge. */
46
+ export function registerDaemon(record, pid = process.pid) {
47
+ try {
48
+ const dir = daemonsDir();
49
+ mkdirSync(dir, { recursive: true });
50
+ const full = { ...record, pid, startedAt: Date.now() };
51
+ writeFileSync(join(dir, `${pid}.json`), `${JSON.stringify(full, undefined, 2)}\n`, 'utf8');
52
+ }
53
+ catch {
54
+ /* the bridge works without it; `ps` simply will not list this run */
55
+ }
56
+ }
57
+ /** Drop this process's record. Safe to call more than once. */
58
+ export function unregisterDaemon(pid = process.pid) {
59
+ try {
60
+ rmSync(join(daemonsDir(), `${pid}.json`), { force: true });
61
+ }
62
+ catch {
63
+ /* nothing to do */
64
+ }
65
+ }
66
+ /**
67
+ * Every recorded bridge, newest first, each checked for liveness at call time.
68
+ *
69
+ * A malformed file is skipped rather than thrown: a half-written record must not
70
+ * make `ps` unusable exactly when the user is trying to clean up.
71
+ */
72
+ export function listDaemons(env = process.env) {
73
+ const dir = daemonsDir(env);
74
+ let names;
75
+ try {
76
+ names = readdirSync(dir).filter((name) => name.endsWith('.json'));
77
+ }
78
+ catch {
79
+ return [];
80
+ }
81
+ const entries = [];
82
+ for (const name of names) {
83
+ const file = join(dir, name);
84
+ try {
85
+ const record = JSON.parse(readFileSync(file, 'utf8'));
86
+ if (typeof record.pid !== 'number')
87
+ continue;
88
+ entries.push({ record, alive: isAlive(record.pid), file });
89
+ }
90
+ catch {
91
+ /* skip a broken record */
92
+ }
93
+ }
94
+ return entries.sort((a, b) => (b.record.startedAt ?? 0) - (a.record.startedAt ?? 0));
95
+ }
96
+ /** Remove the records whose process is gone. Returns how many were dropped. */
97
+ export function pruneDaemons(env = process.env) {
98
+ let removed = 0;
99
+ for (const entry of listDaemons(env)) {
100
+ if (entry.alive)
101
+ continue;
102
+ try {
103
+ rmSync(entry.file, { force: true });
104
+ removed += 1;
105
+ }
106
+ catch {
107
+ /* leave it for next time */
108
+ }
109
+ }
110
+ return removed;
111
+ }
112
+ //# sourceMappingURL=daemons.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"daemons.js","sourceRoot":"","sources":["../src/daemons.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACtF,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAuBjC;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,MAAyB,OAAO,CAAC,GAAG;IAC7D,MAAM,QAAQ,GAAG,GAAG,CAAC,6BAA6B,CAAC,CAAC;IACpD,OAAO,QAAQ,IAAI,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE;QACvC,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,sBAAsB,EAAE,SAAS,CAAC,CAAC;AACzD,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,OAAO,CAAC,GAAW;IACjC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IACrD,IAAI,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,mEAAmE;QACnE,OAAQ,GAAyB,CAAC,IAAI,KAAK,OAAO,CAAC;IACrD,CAAC;AACH,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,cAAc,CAAC,MAA+C,EAAE,GAAG,GAAG,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ACP to the agent on
6
+ * stdio and serves the opencode v2 HTTP/SSE surface, so the opencode v2 TUI can
7
+ * be its interface. Any ACP agent works - the agent is whatever follows `--`.
8
+ *
9
+ * The agent command is everything after `--`, so we never have to understand
10
+ * another tool's flag syntax:
11
+ *
12
+ * oc-acp-client -- <agent command> [args...]
13
+ * oc-acp-client -- <agent command> [args...]
14
+ * oc-acp-client --port 4096 -- npx -y @agentclientprotocol/claude-agent-acp
15
+ *
16
+ * Prints the listening URL on stdout as a single JSON line so scripts (and the
17
+ * e2e harness) can read it without guessing a port.
18
+ *
19
+ * Starting the opencode v2 TUI against this server is the default, and the only
20
+ * path where a v2 client is *required*. `--no-tui` (or `--bridge-port`, which
21
+ * implies it) serves the same surface to any other v2 client, the test
22
+ * harness, or looking at the raw `/api/*` by hand. The TUI is the client verified
23
+ * end to end here; any client attaches to the same OpenAPI surface (with the caveat noted
24
+ * at `--bridge-port`: its state roots are its own, not ours).
25
+ *
26
+ * The client binary is selected by `OPENCODE_BIN` (or `opencode` on `PATH`);
27
+ * there is no flag for it.
28
+ */
29
+ interface ParsedArgs {
30
+ port: number;
31
+ host: string;
32
+ directory: string;
33
+ /** Undefined when the command is a native opencode subcommand. */
34
+ agentCommand: string | undefined;
35
+ agentArgs: string[];
36
+ /**
37
+ * Start the opencode v2 TUI against this server.
38
+ *
39
+ * **Default true** — that is what makes this one command from nothing to a
40
+ * working TUI, which is the product. `--no-tui` turns it off: the server-only
41
+ * mode any other v2 client attaches to (see `--bridge-port`), by the test
42
+ * harness, and for inspecting the raw surface.
43
+ */
44
+ launch: boolean;
45
+ logPath: string | undefined;
46
+ /** opencode flags and any unknown args, passed to the TUI verbatim. */
47
+ passThrough: string[];
48
+ session: string | undefined;
49
+ /** `--continue`: opencode's own semantic, forwarded as-is. */
50
+ continueSession: boolean;
51
+ /**
52
+ * True when the command is a NATIVE opencode subcommand invocation: run the
53
+ * binary with the argv as-is and do not start the bridge or the TUI.
54
+ */
55
+ nativeCommand: boolean;
56
+ /** The leading subcommand itself, when nativeCommand was set. */
57
+ nativeSubcommand: string | undefined;
58
+ /**
59
+ * A bridge-owned subcommand (`ps`): no agent, no TUI, no opencode binary.
60
+ * Handled in `main` before the agent preflight, like the native ones.
61
+ */
62
+ bridgeCommand?: 'ps' | 'sessions' | 'upgrade';
63
+ psJson: boolean;
64
+ sessionsJson: boolean;
65
+ /** 0 means every row (`--all`). */
66
+ sessionsLimit: number;
67
+ sessionsOffset: number;
68
+ sessionsDirectory?: string;
69
+ sessionsAgent?: string;
70
+ sessionsUnknown: string[];
71
+ refusedWord?: string;
72
+ replacedFlags: string[];
73
+ cliOnlyFlags: string[];
74
+ upgradeCheck: boolean;
75
+ upgradeTarget?: string;
76
+ unknownUpgrade: string[];
77
+ sessionsWidth?: number;
78
+ psPrune: boolean;
79
+ psKill: boolean;
80
+ }
81
+ /**
82
+ * `-c`/`--continue`: the newest remembered session for this directory, and the agent that
83
+ * owns it. The map is now the only source: without a session there is no way to know which
84
+ * agent to ask, so the CLI errors instead of falling back to a blank conversation.
85
+ */
86
+ export declare function newestContinueEntry(entries: Array<[
87
+ string,
88
+ {
89
+ directory?: string;
90
+ agent?: {
91
+ command: string;
92
+ args: string[];
93
+ };
94
+ updatedAt: number;
95
+ }
96
+ ]>, directory: string): {
97
+ visibleId: string;
98
+ agent: {
99
+ command: string;
100
+ args: string[];
101
+ };
102
+ } | undefined;
103
+ /**
104
+ * Translate a `--session <id>` value into the id the agent will answer to.
105
+ *
106
+ * Exported and pure so the startup contract is assertable at its own layer: the id
107
+ * the TUI shows (`ses_…`) is never the agent's own id (a UUID), and sending it raw
108
+ * to `session/load` is what made a resumed session silently restart empty — the
109
+ * agent answered "Internal error" and the bridge opened a brand-new session under
110
+ * the requested id. The session map holds the pairing; an unknown id passes through
111
+ * as given (the agent's load then answers for whether it exists), so agent-native
112
+ * ids learned elsewhere keep working.
113
+ */
114
+ export declare function resolveSessionId(requested: string | undefined, log?: (line: string) => void, launch?: {
115
+ command: string;
116
+ args?: readonly string[];
117
+ }): string | undefined;
118
+ export declare function parseArgs(argv: readonly string[]): ParsedArgs;
119
+ export declare function printHelp(): void;
120
+ /**
121
+ * Is the agent command runnable?
122
+ *
123
+ * The agent is spawned lazily — on the first prompt — so without this check a
124
+ * typo would be discovered only after the TUI had taken over the terminal, and
125
+ * it would look like a dead composer rather than a bad command. Checking first
126
+ * turns that into one readable line before anything starts.
127
+ *
128
+ * Deliberately does **not run** the command: an arbitrary ACP agent may not
129
+ * support any probe flag, and one that ignores argv simply waits on stdin
130
+ * (which is the trap that made `--dump-config` discovery unworkable).
131
+ */
132
+ export declare function findExecutable(command: string, env?: NodeJS.ProcessEnv, cwd?: string): string | undefined;
133
+ /**
134
+ * Arguments for the launched client.
135
+ *
136
+ * Pure and exported so the `--session` can be asserted: leaving it out looks
137
+ * fine — the TUI still renders — but the composer then sits on
138
+ * `session/undefined` and Enter does nothing at all.
139
+ */
140
+ export declare function clientArgs(args: ParsedArgs, url: string, session?: string): string[];
141
+ /**
142
+ * The environment our TUI runs under, so a native `opencode` install and this
143
+ * product never share state — and the TUI cannot disturb the native install.
144
+ *
145
+ * The seams, each measured against the shipped binary (`opencode debug paths`,
146
+ * v2.0.31) rather than assumed:
147
+ * XDG_STATE_HOME → `…/tui/tabs.json` (TAB LAYOUT) and locks. Shared, a
148
+ * native TUI listed our tabs and could not open them
149
+ * (their sessions exist only behind the bridge).
150
+ * XDG_DATA_HOME → `opencode.db`, log, snapshot, shell, repos. Shared,
151
+ * the two worlds' session dbs interleave.
152
+ * XDG_CONFIG_HOME → deliberately NOT redirected: TUI config (tui.json,
153
+ * plugins, themes) is shared with the user's install.
154
+ * OPENCODE_DB → the db file outright: a second belt even if an
155
+ * XDG root is ignored. (Measured: honoured.)
156
+ * OPENCODE_DISABLE_AUTOUPDATE → our TUI must not upgrade itself mid-run; a
157
+ * silent version bump is what produced the "Server at
158
+ * … has version X; this client is Y" warnings.
159
+ * OPENCODE_DISABLE_FILEWATCHER → two TUIs watching one worktree duplicate file
160
+ * events; ours need not watch at all.
161
+ * OPENCODE_CONFIG_DIR → ONLY when OPENCODE_ACP_CLIENT_ISOLATED_CONFIG=1: a
162
+ * private config root. Off by default on purpose —
163
+ * it would also hide the user's own providers/plugins
164
+ * from OUR TUI, which is not what "isolation" should
165
+ * cost. Measured nuance: `OPENCODE_CONFIG_DIR` adds a
166
+ * config root but does not stop the user-level one
167
+ * from loading, so this is a containment, not a wall.
168
+ * ★ The root is named after the agent command (see `agentStateSlug`): two agents
169
+ * never share a tabs.json, so a dsh launch cannot restore an opencode tab (reported
170
+ * 2026-10-19 — the mixed tabs also mixed model catalogs). One client = one agent;
171
+ * another agent is another launch, with its own tab set.
172
+ *
173
+ * `OPENCODE_ACP_CLIENT_SHARED_STATE=1` restores the old shared behaviour for anyone
174
+ * who wants one opencode world.
175
+ *
176
+ * Not used, each checked: `OPENCODE_TUI_CHANNEL` (the channel is a BUILD constant;
177
+ * setting it changed no path), `OPENCODE_TEST_HOME` (moves only `home`, not data or
178
+ * state), `OPENCODE_CONFIG`/`OPENCODE_CONFIG_CONTENT` (append/override, not a root).
179
+ */
180
+ export declare function agentStateSlug(command: string, args?: readonly string[]): string;
181
+ export declare function isolatedTuiRoots(binding?: {
182
+ command: string;
183
+ args?: readonly string[];
184
+ }): Record<string, string> | undefined;
185
+ /**
186
+ * The command the user ran, rebuilt for the TUI's exit epilogue.
187
+ *
188
+ * The owner's rule: the `Continue` line must read like the invocation that
189
+ * started THIS process — `oc-acp-client …` when installed as the bin,
190
+ * `node dist/index.js …` when run from a checkout (the actual entry file, not
191
+ * some invented wrapper). process.argv carries resolved paths; the shapes are:
192
+ * - bin: argv[1] = <prefix>/bin/oc-acp-client → basename
193
+ * - node: argv[1] = <...>/dist/index.js → `node <path>`
194
+ * (relative to cwd when the entry sits under it — how a checkout
195
+ * is normally launched — absolute otherwise)
196
+ * The remaining words are the user's own argv, verbatim.
197
+ */
198
+ export declare function invocationCommand(): string;
199
+ /**
200
+ * The user's typed command with the resume id in place: an existing
201
+ * `--session <id>` / `-s <id>` value is REPLACED (never appended — appending
202
+ * produced `… --session ses_x … --session ses_y`, the owner's report), and a
203
+ * `-c`/`--continue` becomes `--session <id>` too, because "continue" would
204
+ * reopen whatever is newest at copy-time, not necessarily THIS conversation.
205
+ * The id is the VISIBLE one (`ses_…`): the bridge translates it on the next
206
+ * run. The TUI's own epilogue id cannot be used — on a resumed session it is
207
+ * the AGENT's id (the bridge hands the TUI the translated UUID), which the
208
+ * user should not have to see or copy.
209
+ */
210
+ export declare function resumeCommand(sessionId: string): string;
211
+ /**
212
+ * Four rows: the native wordmark, a space, then `acp client`. 91 columns with
213
+ * the indent; a narrower terminal gets one plain line instead (the rows would
214
+ * wrap and the cursor arithmetic would land somewhere else).
215
+ */
216
+ export declare function epilogueWordmark(columns: number): string[];
217
+ /**
218
+ * The replacement `Continue` row, or undefined when even the shortest form would
219
+ * wrap.
220
+ *
221
+ * Exported and pure because the width rule has a measured history: an over-long
222
+ * line was once ABANDONED (leaving the TUI's native `opencode -s …` — read by the
223
+ * owner as "the rewrite is broken"), and the fix was to shorten it instead. A
224
+ * wrapped row also breaks the `ESC[2A` geometry, which is why the length check is
225
+ * a hard filter rather than best effort. ` Continue ` is the client's own
226
+ * prefix and is part of the measurement.
227
+ */
228
+ export declare function epilogueLine(sessionId: string, columns: number): string | undefined;
229
+ /**
230
+ * The id the exit epilogue's `Continue` line should name, in order of how sure
231
+ * we are about it. Pure and exported so the ordering itself can be tested; the
232
+ * three sources and why they rank this way:
233
+ *
234
+ * 1. `prompted` — the session the user actually TYPED into this run. The one
235
+ * signal the bridge owns outright (it is set at the top of the prompt
236
+ * handler), so nothing outranks it.
237
+ * 2. `intent` — the session the user ASKED to resume (`--session <id>`, or the
238
+ * id `-c` resolved to). This is intent, not inference. Measured: with
239
+ * several restored tabs the client hydrates each one in turn, and the
240
+ * last-read heuristic named a DIFFERENT tab than the one the user resumed.
241
+ * 3. `viewed` — the last session the client hydrated/read. A resume with no
242
+ * typing and no flag lands here; it beats leaving the TUI's native
243
+ * `opencode -s <id>` line in place (which names neither this product nor
244
+ * an id the native daemon knows), but a prefetch can end up last, so it
245
+ * never outranks intent.
246
+ */
247
+ export declare function epilogueSessionCandidates(sources: {
248
+ prompted?: string | undefined;
249
+ intent?: string | undefined;
250
+ viewed?: string | undefined;
251
+ }): string[];
252
+ export declare function epilogueSessionId(sources: {
253
+ prompted?: string | undefined;
254
+ intent?: string | undefined;
255
+ viewed?: string | undefined;
256
+ }): string | undefined;
257
+ /**
258
+ * The epilogue may only name an id the NEXT start can resolve.
259
+ *
260
+ * Measured by the owner (2026-10-18): after a real conversation the line said
261
+ * `-s ses_eb55…`, and the next start answered "unknown session id" — the session had a
262
+ * record, but its map pairing was filed under a different (pre-adoption) id. That
263
+ * particular bug is fixed at the source, but a session that never reached an agent (a
264
+ * POST with no prompt) still has no pairing, and the `viewed` tier can name it. So the
265
+ * candidate list is filtered by `resolveSessionId`: never print a line that cannot work.
266
+ */
267
+ export declare function firstResolvableSessionId(candidates: Array<string | undefined>, resolve?: (id: string) => string | undefined): string | undefined;
268
+ export {};