zcode-acp-server 0.21.4 → 0.23.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 (70) hide show
  1. package/README.md +6 -7
  2. package/dist/cli.d.ts +8 -5
  3. package/dist/cli.d.ts.map +1 -1
  4. package/dist/cli.js +22 -14
  5. package/dist/cli.js.map +1 -1
  6. package/dist/config/user-config.d.ts +48 -0
  7. package/dist/config/user-config.d.ts.map +1 -0
  8. package/dist/config/user-config.js +101 -0
  9. package/dist/config/user-config.js.map +1 -0
  10. package/dist/handlers/session.d.ts +33 -3
  11. package/dist/handlers/session.d.ts.map +1 -1
  12. package/dist/handlers/session.js +152 -9
  13. package/dist/handlers/session.js.map +1 -1
  14. package/dist/i18n.d.ts +2 -0
  15. package/dist/i18n.d.ts.map +1 -1
  16. package/dist/i18n.js +2 -0
  17. package/dist/i18n.js.map +1 -1
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +2 -2
  20. package/dist/index.js.map +1 -1
  21. package/dist/remote/config.d.ts +36 -24
  22. package/dist/remote/config.d.ts.map +1 -1
  23. package/dist/remote/config.js +70 -36
  24. package/dist/remote/config.js.map +1 -1
  25. package/dist/remote/hub-server.d.ts +24 -13
  26. package/dist/remote/hub-server.d.ts.map +1 -1
  27. package/dist/remote/hub-server.js +78 -63
  28. package/dist/remote/hub-server.js.map +1 -1
  29. package/dist/server.d.ts +22 -0
  30. package/dist/server.d.ts.map +1 -1
  31. package/dist/server.js +25 -0
  32. package/dist/server.js.map +1 -1
  33. package/dist/tui.d.ts +38 -0
  34. package/dist/tui.d.ts.map +1 -0
  35. package/dist/tui.js +96 -0
  36. package/dist/tui.js.map +1 -0
  37. package/dist/utils.d.ts +8 -0
  38. package/dist/utils.d.ts.map +1 -1
  39. package/dist/utils.js +10 -0
  40. package/dist/utils.js.map +1 -1
  41. package/docs/CLI.md +33 -76
  42. package/docs/REMOTE-CLIENTS.md +26 -20
  43. package/docs/REMOTE.md +62 -23
  44. package/docs/TROUBLESHOOTING.md +5 -1
  45. package/docs/adr/0007-unified-cli-entry-and-bin-pruning.md +2 -0
  46. package/package.json +3 -7
  47. package/dist/repl/App.d.ts +0 -108
  48. package/dist/repl/App.d.ts.map +0 -1
  49. package/dist/repl/App.js +0 -732
  50. package/dist/repl/App.js.map +0 -1
  51. package/dist/repl/history.d.ts +0 -25
  52. package/dist/repl/history.d.ts.map +0 -1
  53. package/dist/repl/history.js +0 -73
  54. package/dist/repl/history.js.map +0 -1
  55. package/dist/repl/hub.d.ts +0 -87
  56. package/dist/repl/hub.d.ts.map +0 -1
  57. package/dist/repl/hub.js +0 -188
  58. package/dist/repl/hub.js.map +0 -1
  59. package/dist/repl/input-buffer.d.ts +0 -77
  60. package/dist/repl/input-buffer.d.ts.map +0 -1
  61. package/dist/repl/input-buffer.js +0 -174
  62. package/dist/repl/input-buffer.js.map +0 -1
  63. package/dist/repl/model.d.ts +0 -312
  64. package/dist/repl/model.d.ts.map +0 -1
  65. package/dist/repl/model.js +0 -674
  66. package/dist/repl/model.js.map +0 -1
  67. package/dist/repl/run.d.ts +0 -12
  68. package/dist/repl/run.d.ts.map +0 -1
  69. package/dist/repl/run.js +0 -1245
  70. package/dist/repl/run.js.map +0 -1
package/README.md CHANGED
@@ -13,7 +13,7 @@ The server launches the ZCode headless app-server (`zcode app-server --stdio`) a
13
13
 
14
14
  - **Native editor experience** — streaming diffs, permission prompts and plan mode in Zed / JetBrains' own agent panel. No side-by-side terminal.
15
15
  - **The official harness, not a reimplementation** — drives the real `zcode app-server`: native tools, skills, MCP and slash commands, auto-compaction, session resume/fork.
16
- - **Beyond the editor** — a full bilingual terminal REPL (`zcode-acp`, English/中文, works over SSH), phone/web access to the same sessions (`zcode-acp-remote`), opt-in writes-only sandbox. Credentials stay in `~/.zcode`.
16
+ - **Beyond the editor** — an interactive terminal chat (`zcode-acp`, a [Martty](https://github.com/openma-ai/Martty)-powered TUI, works over SSH), phone/web access to the same sessions (`zcode-acp-remote`), opt-in writes-only sandbox. Credentials stay in `~/.zcode`.
17
17
 
18
18
  Because it drives the real ZCode client, your GLM Coding Plan comes along untouched — current perks (the 150% quota bonus, priority routing over raw API) and the plan's flat-rate economics apply exactly as in the official app. No API keys in editor settings.
19
19
 
@@ -142,11 +142,10 @@ the primary client. Discovery API, tunnels, auth, and semantics:
142
142
 
143
143
  ## Unified CLI (`zcode-acp`)
144
144
 
145
- One command for every surface: an interactive terminal chat REPL with native
146
- scrollback (`zcode-acp`), plan quota cards (`zcode-acp quota`, GLM + Opencode
147
- Go), the remote hub daemon (`zcode-acp hub`), and the stdio server editors
148
- invoke (`zcode-acp server`). REPL keys, completion, history, and quota setup:
149
- [docs/CLI.md](docs/CLI.md).
145
+ One command for every surface: an interactive terminal chat TUI (`zcode-acp`,
146
+ powered by Martty), plan quota cards (`zcode-acp quota`, GLM + Opencode Go),
147
+ the remote hub daemon (`zcode-acp hub`), and the stdio server editors invoke
148
+ (`zcode-acp server`). TUI keys and quota setup: [docs/CLI.md](docs/CLI.md).
150
149
 
151
150
  ## ACP Registry
152
151
 
@@ -204,7 +203,7 @@ See [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) for the full architecture docum
204
203
  - [Protocol](docs/PROTOCOL.md) — ZCode JSON-RPC protocol details
205
204
  - [Sandbox](docs/SANDBOX.md) — full sandbox manual (switches, whitelist, popups, verification)
206
205
  - [Remote Access](docs/REMOTE.md) — hub, discovery API, tunnels, remote session-create
207
- - [Unified CLI](docs/CLI.md) — REPL, quota cards, hub/server subcommands
206
+ - [Unified CLI](docs/CLI.md) — interactive TUI, quota cards, hub/server subcommands
208
207
  - [Remote Clients](docs/REMOTE-CLIENTS.md) — remote access integration contract (discovery, transport, recovery)
209
208
  - [Replay Guide](docs/REPLAY-GUIDE.md) — building a client UI on tail replay
210
209
  - [Development](docs/DEVELOPMENT.md) — local development, debugging, adding extension methods
package/dist/cli.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
3
  * Unified CLI entry (`zcode-acp`). Every operational surface is a subcommand;
4
- * bare invocation opens the interactive REPL. See docs/adr/0007 for why the
5
- * old `zcode-acp-hub` / `zcode-quota` bins were folded in here and why
6
- * `zcode-acp-server` remains as a bin alias pointing at this same file.
4
+ * bare invocation opens the interactive Martty TUI (ADR-0020). See docs/adr
5
+ * 0007 for why the old `zcode-acp-hub` / `zcode-quota` bins were folded in
6
+ * here and why `zcode-acp-server` remains as a bin alias pointing at this
7
+ * same file.
7
8
  *
8
9
  * The legacy alias is detected via argv[0]: npm/pnpm install bin names as
9
10
  * symlinks, so both `zcode-acp` and `zcode-acp-server` resolve to dist/cli.js
@@ -14,8 +15,9 @@
14
15
  export type Invocation = {
15
16
  kind: "help";
16
17
  } | {
17
- kind: "repl";
18
+ kind: "tui";
18
19
  explicit: boolean;
20
+ check: boolean;
19
21
  } | {
20
22
  kind: "server";
21
23
  } | {
@@ -34,7 +36,8 @@ export type Invocation = {
34
36
  *
35
37
  * `invokedAs` is basename(argv[1]); `zcode-acp-server` means we were spawned
36
38
  * by an editor config that expects the bridge to speak ACP on stdio with no
37
- * subcommand prefix. Bare `zcode-acp` opens the interactive REPL.
39
+ * subcommand prefix. Bare `zcode-acp` opens the interactive Martty TUI;
40
+ * `repl` stays accepted as the old spelling of `tui`.
38
41
  */
39
42
  export declare function resolveInvocation(invokedAs: string, argv: readonly string[]): Invocation;
40
43
  //# sourceMappingURL=cli.d.ts.map
package/dist/cli.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;GAUG;AAWH,sFAAsF;AACtF,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GACjB;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,GACf;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAErC;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,UAAU,CAoBxF"}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;GAWG;AAWH,sFAAsF;AACtF,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAClD;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GACjB;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,GACf;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAErC;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,UAAU,CAsBxF"}
package/dist/cli.js CHANGED
@@ -1,9 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
3
  * Unified CLI entry (`zcode-acp`). Every operational surface is a subcommand;
4
- * bare invocation opens the interactive REPL. See docs/adr/0007 for why the
5
- * old `zcode-acp-hub` / `zcode-quota` bins were folded in here and why
6
- * `zcode-acp-server` remains as a bin alias pointing at this same file.
4
+ * bare invocation opens the interactive Martty TUI (ADR-0020). See docs/adr
5
+ * 0007 for why the old `zcode-acp-hub` / `zcode-quota` bins were folded in
6
+ * here and why `zcode-acp-server` remains as a bin alias pointing at this
7
+ * same file.
7
8
  *
8
9
  * The legacy alias is detected via argv[0]: npm/pnpm install bin names as
9
10
  * symlinks, so both `zcode-acp` and `zcode-acp-server` resolve to dist/cli.js
@@ -15,23 +16,25 @@ import process from "node:process";
15
16
  import { main as runHub } from "./bin/hub.js";
16
17
  import { main as runQuota } from "./bin/quota.js";
17
18
  import { main as runServer, runHeadless } from "./index.js";
18
- import { runRepl } from "./repl/run.js";
19
+ import { checkTuiRuntime, runTui } from "./tui.js";
19
20
  import { AGENT_INFO } from "./utils.js";
20
21
  /**
21
22
  * Map (invoked name, argv) to a subcommand. Pure — exported for unit tests.
22
23
  *
23
24
  * `invokedAs` is basename(argv[1]); `zcode-acp-server` means we were spawned
24
25
  * by an editor config that expects the bridge to speak ACP on stdio with no
25
- * subcommand prefix. Bare `zcode-acp` opens the interactive REPL.
26
+ * subcommand prefix. Bare `zcode-acp` opens the interactive Martty TUI;
27
+ * `repl` stays accepted as the old spelling of `tui`.
26
28
  */
27
29
  export function resolveInvocation(invokedAs, argv) {
28
30
  if (invokedAs === "zcode-acp-server")
29
31
  return { kind: "server" };
30
32
  const sub = argv[0];
31
33
  if (sub === undefined)
32
- return { kind: "repl", explicit: false };
33
- if (sub === "repl" || sub === "tui")
34
- return { kind: "repl", explicit: true };
34
+ return { kind: "tui", explicit: false, check: false };
35
+ if (sub === "repl" || sub === "tui") {
36
+ return { kind: "tui", explicit: true, check: argv.slice(1).includes("--check") };
37
+ }
35
38
  if (sub === "-h" || sub === "--help" || sub === "help") {
36
39
  return { kind: "help" };
37
40
  }
@@ -51,11 +54,12 @@ export function resolveInvocation(invokedAs, argv) {
51
54
  const HELP_TEXT = `Usage: zcode-acp [command] [options]
52
55
 
53
56
  The single entry point for every zcode-acp-server surface. Bare invocation
54
- opens the interactive REPL (agent chat in this terminal).
57
+ opens the interactive Martty TUI (agent chat in this terminal).
55
58
 
56
59
  Commands:
57
- (none) | repl Interactive agent chat (Ink UI): stream output, tool
58
- rows, arrow-key permission prompts. /exit quits.
60
+ (none) | tui Interactive agent chat (Martty TUI): stream output,
61
+ tool rows, model picker, session resume. /exit quits.
62
+ 'tui --check' runs a headless wiring check and exits.
59
63
  quota [args...] Plan usage cards (was the zcode-quota bin): -w watch,
60
64
  -i <sec>, -d detail, -p plain, provider glm|go.
61
65
  hub Run the remote-access hub daemon (was zcode-acp-hub;
@@ -84,13 +88,17 @@ async function main() {
84
88
  case "help":
85
89
  process.stdout.write(HELP_TEXT + "\n");
86
90
  return;
87
- case "repl":
91
+ case "tui":
92
+ if (invocation.check) {
93
+ process.exitCode = (await checkTuiRuntime()) ? 0 : 1;
94
+ return;
95
+ }
88
96
  if (process.stdin.isTTY && process.stdout.isTTY) {
89
- await runRepl();
97
+ await runTui();
90
98
  return;
91
99
  }
92
100
  if (invocation.explicit) {
93
- process.stderr.write("zcode-acp: interactive REPL needs a TTY — run it from a terminal.\n");
101
+ process.stderr.write("zcode-acp: interactive TUI needs a TTY — run it from a terminal.\n");
94
102
  process.exit(2);
95
103
  }
96
104
  // Bare invocation without a TTY falls back to the stdio server: on
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,WAAW,EAAE,MAAM,Y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,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CACzF,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Global user configuration (~/.config/zcode-acp/config.json).
3
+ *
4
+ * The file is the AUTHORITATIVE source for user preferences that must not
5
+ * depend on how a process was launched: the hub daemon is idle-exited and
6
+ * re-spawned by whichever bridge needs it next, so its birth env rotates
7
+ * between GUI-launched editors (no shell rc vars) and interactive shells.
8
+ * Every read is live (no cache) — editing the file takes effect on the next
9
+ * use (e.g. the next remote incubation) without restarting the hub.
10
+ *
11
+ * Precedence everywhere: config file > environment variable > built-in
12
+ * default. Env vars remain fully supported as a fallback for setups without
13
+ * a file and for one-off/test overrides of unspecified fields.
14
+ *
15
+ * Per-process plumbing (ZCODE_ACP_REMOTE_ORIGIN, _PIN_CWD,
16
+ * ZCODE_ACP_RESUME_SESSION) is deliberately NOT file-configurable — those
17
+ * carry per-request/per-role state, not user preference.
18
+ */
19
+ /** Terminal incubation preferences for remote session-create (ADR-0016). */
20
+ export interface TerminalPrefs {
21
+ /** false → remote session-create stays headless (no visible window). */
22
+ enabled?: boolean;
23
+ /** Terminal app name (Terminal, iTerm, wezterm, kitty, alacritty, ghostty, …). */
24
+ app?: string;
25
+ /** Shell command template; `{script}` is replaced with the quoted script path. */
26
+ command?: string;
27
+ }
28
+ /** The `remote` section of the user config file. */
29
+ export interface RemoteUserConfig {
30
+ enabled?: boolean;
31
+ token?: string;
32
+ hubPort?: number;
33
+ hubHost?: string;
34
+ bridgePort?: number;
35
+ terminal?: TerminalPrefs;
36
+ }
37
+ export interface UserConfig {
38
+ remote?: RemoteUserConfig;
39
+ }
40
+ /** Resolve the config file path: $XDG_CONFIG_HOME/zcode-acp or ~/.config/zcode-acp. */
41
+ export declare function userConfigPath(env?: NodeJS.ProcessEnv): string;
42
+ /**
43
+ * Read and validate the user config. Best-effort: a missing file is the
44
+ * normal no-file path ({}), anything unreadable/malformed warns once and
45
+ * reads as absent so the env fallback keeps the process working.
46
+ */
47
+ export declare function loadUserConfig(env?: NodeJS.ProcessEnv): UserConfig;
48
+ //# sourceMappingURL=user-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-config.d.ts","sourceRoot":"","sources":["../../src/config/user-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAQH,4EAA4E;AAC5E,MAAM,WAAW,aAAa;IAC5B,wEAAwE;IACxE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,kFAAkF;IAClF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,kFAAkF;IAClF,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,oDAAoD;AACpD,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,aAAa,CAAC;CAC1B;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,gBAAgB,CAAC;CAC3B;AAED,uFAAuF;AACvF,wBAAgB,cAAc,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAG3E;AAMD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,UAAU,CAqD/E"}
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Global user configuration (~/.config/zcode-acp/config.json).
3
+ *
4
+ * The file is the AUTHORITATIVE source for user preferences that must not
5
+ * depend on how a process was launched: the hub daemon is idle-exited and
6
+ * re-spawned by whichever bridge needs it next, so its birth env rotates
7
+ * between GUI-launched editors (no shell rc vars) and interactive shells.
8
+ * Every read is live (no cache) — editing the file takes effect on the next
9
+ * use (e.g. the next remote incubation) without restarting the hub.
10
+ *
11
+ * Precedence everywhere: config file > environment variable > built-in
12
+ * default. Env vars remain fully supported as a fallback for setups without
13
+ * a file and for one-off/test overrides of unspecified fields.
14
+ *
15
+ * Per-process plumbing (ZCODE_ACP_REMOTE_ORIGIN, _PIN_CWD,
16
+ * ZCODE_ACP_RESUME_SESSION) is deliberately NOT file-configurable — those
17
+ * carry per-request/per-role state, not user preference.
18
+ */
19
+ import { readFileSync } from "node:fs";
20
+ import { homedir } from "node:os";
21
+ import path from "node:path";
22
+ import { warn } from "../utils.js";
23
+ /** Resolve the config file path: $XDG_CONFIG_HOME/zcode-acp or ~/.config/zcode-acp. */
24
+ export function userConfigPath(env = process.env) {
25
+ const base = (env.XDG_CONFIG_HOME ?? "").trim() || path.join(homedir(), ".config");
26
+ return path.join(base, "zcode-acp", "config.json");
27
+ }
28
+ function isPlainObject(v) {
29
+ return typeof v === "object" && v !== null && !Array.isArray(v);
30
+ }
31
+ /**
32
+ * Read and validate the user config. Best-effort: a missing file is the
33
+ * normal no-file path ({}), anything unreadable/malformed warns once and
34
+ * reads as absent so the env fallback keeps the process working.
35
+ */
36
+ export function loadUserConfig(env = process.env) {
37
+ const file = userConfigPath(env);
38
+ let raw;
39
+ try {
40
+ raw = readFileSync(file, "utf8");
41
+ }
42
+ catch {
43
+ return {}; // missing (or unreadable) file — env fallback applies
44
+ }
45
+ let parsed;
46
+ try {
47
+ parsed = JSON.parse(raw);
48
+ }
49
+ catch (e) {
50
+ warn(`config: ${file} is not valid JSON — ignoring (${e instanceof Error ? e.message : String(e)})`);
51
+ return {};
52
+ }
53
+ if (!isPlainObject(parsed)) {
54
+ warn(`config: ${file} is not a JSON object — ignoring`);
55
+ return {};
56
+ }
57
+ const remote = parsed["remote"];
58
+ if (remote === undefined)
59
+ return {};
60
+ if (!isPlainObject(remote)) {
61
+ warn(`config: "remote" in ${file} is not an object — ignoring the section`);
62
+ return {};
63
+ }
64
+ const out = {};
65
+ if (typeof remote["enabled"] === "boolean")
66
+ out.enabled = remote["enabled"];
67
+ if (typeof remote["token"] === "string" && remote["token"].trim())
68
+ out.token = remote["token"].trim();
69
+ for (const key of ["hubPort", "bridgePort"]) {
70
+ const v = remote[key];
71
+ if (v === undefined)
72
+ continue;
73
+ if (typeof v !== "number" || !Number.isInteger(v) || v < 1 || v > 65535) {
74
+ warn(`config: remote.${key}=${JSON.stringify(v)} is not a valid port — ignoring`);
75
+ }
76
+ else {
77
+ out[key] = v;
78
+ }
79
+ }
80
+ if (typeof remote["hubHost"] === "string" && remote["hubHost"].trim()) {
81
+ out.hubHost = remote["hubHost"].trim();
82
+ }
83
+ const terminal = remote["terminal"];
84
+ if (isPlainObject(terminal)) {
85
+ const t = {};
86
+ if (typeof terminal["enabled"] === "boolean")
87
+ t.enabled = terminal["enabled"];
88
+ if (typeof terminal["app"] === "string" && terminal["app"].trim())
89
+ t.app = terminal["app"].trim();
90
+ if (typeof terminal["command"] === "string" && terminal["command"].trim()) {
91
+ t.command = terminal["command"].trim();
92
+ }
93
+ if (Object.keys(t).length > 0)
94
+ out.terminal = t;
95
+ }
96
+ else if (terminal !== undefined) {
97
+ warn(`config: remote.terminal in ${file} is not an object — ignoring`);
98
+ }
99
+ return { remote: out };
100
+ }
101
+ //# sourceMappingURL=user-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-config.js","sourceRoot":"","sources":["../../src/config/user-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AA0BnC,uFAAu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,MAAM,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,CAAC;IACzC,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;IACpC,IAAI,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,MAAM,CAAC,GAAkB,EAAE,CAAC;QAC5B,IAAI,OAAO,QAAQ,CAAC,SAAS,CAAC,KAAK,SAAS;YAAE,CAAC,CAAC,OAAO,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;QAC9E,IAAI,OAAO,QAAQ,CAAC,KAAK,CAAC,KAAK,QAAQ,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE;YAAE,CAAC,CAAC,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;QAClG,IAAI,OAAO,QAAQ,CAAC,SAAS,CAAC,KAAK,QAAQ,IAAI,QAAQ,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;YAC1E,CAAC,CAAC,OAAO,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,CAAC;QACzC,CAAC;QACD,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC;YAAE,GAAG,CAAC,QAAQ,GAAG,CAAC,CAAC;IAClD,CAAC;SAAM,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAClC,IAAI,CAAC,8BAA8B,IAAI,8BAA8B,CAAC,CAAC;IACzE,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;AACzB,CAAC"}
@@ -14,13 +14,41 @@ import type * as acp from "@agentclientprotocol/sdk";
14
14
  import { EventStreamListener, TurnMonitor } from "../backend/listener.js";
15
15
  import { ProjectionDiffer } from "../translators/index.js";
16
16
  import type { PendingTurn, ZcodeAcpServer } from "../server.js";
17
+ /**
18
+ * Read and consume the boot-resume session id: the first `session/new` after
19
+ * process start claims it, the env is deleted so later `session/new` calls
20
+ * (the TUI's /new) create fresh sessions. Whitespace-only counts as unset.
21
+ */
22
+ export declare function consumeBootResumeTarget(): string | null;
23
+ /**
24
+ * Banner-handshake trigger for a boot-resumed TUI (ADR-0017 follow-up).
25
+ * Martty's welcome banner paints INSTEAD of the transcript and only dives
26
+ * when text is submitted — so a boot-resumed TUI showed its replayed history
27
+ * only after the user's first message. The hub therefore also incubates the
28
+ * resume TUI with `DSH_TUI_AUTOPROMPT=<this string>`: martty auto-submits it
29
+ * at boot (banner dives immediately, the text queues until the boot bind),
30
+ * and the prompt path answers it with a one-line ack instead of a model
31
+ * turn — scoped to the booting connection (see bootResumeTriggerConnection).
32
+ * Plain text on purpose: a leading `/` would route through martty's
33
+ * slash dispatch (whose gates run before agent capabilities are known) and
34
+ * `!` would run a local shell command.
35
+ */
36
+ export declare const BOOT_RESUME_TRIGGER = "resume session";
17
37
  /**
18
38
  * `session/new` → local placeholder id. The real zcode `session/create` is
19
39
  * deferred to first use (`ensureRealSession`) so an editor startup that never
20
40
  * sends a message leaves no empty session in the backend or the App's task
21
41
  * index. The created session uses mode yolo (hardcoded).
42
+ *
43
+ * Exception — boot-resume interception (ADR-0017, amended by ADR-0020): when
44
+ * the hub incubated this bridge for a specific conversation
45
+ * (ZCODE_ACP_RESUME_SESSION), the TUI client's opening `session/new` is
46
+ * served as a `session/load` of that id instead. The client adopts the
47
+ * resumed conversation with zero client-side support. A failed load falls
48
+ * back to a fresh session so the window still lands on a usable prompt
49
+ * (the retired in-house REPL had the same fallback).
22
50
  */
23
- export declare function newSession(server: ZcodeAcpServer, params: acp.NewSessionRequest): Promise<acp.NewSessionResponse>;
51
+ export declare function newSession(server: ZcodeAcpServer, params: acp.NewSessionRequest, client?: acp.AgentContext): Promise<acp.NewSessionResponse>;
24
52
  /**
25
53
  * Materialize a lazy `session/new` placeholder into a real backend session on
26
54
  * first use (prompt / set_config_option / extension methods). Idempotent:
@@ -37,7 +65,9 @@ export declare function resumeSession(server: ZcodeAcpServer, params: acp.Resume
37
65
  * `session/load` → zcode `session/resume` + stream conversation history back as
38
66
  * `session/update` notifications (text/reasoning/简化 tool_call).
39
67
  */
40
- export declare function loadSession(server: ZcodeAcpServer, params: acp.LoadSessionRequest, cx: acp.AgentContext): Promise<acp.LoadSessionResponse>;
68
+ export declare function loadSession(server: ZcodeAcpServer, params: acp.LoadSessionRequest, cx: acp.AgentContext, opts?: {
69
+ replayHistory?: boolean;
70
+ }): Promise<acp.LoadSessionResponse>;
41
71
  /**
42
72
  * `session/prompt` → subscribe-before-send, run the event-driven turn loop.
43
73
  *
@@ -52,7 +82,7 @@ export declare function loadSession(server: ZcodeAcpServer, params: acp.LoadSess
52
82
  * the continuation for real, and only the session/load replay later surfaced
53
83
  * the orphaned continuation bubble.
54
84
  */
55
- export declare function prompt(server: ZcodeAcpServer, params: acp.PromptRequest, cx: acp.AgentContext, requestId: number | string): Promise<acp.PromptResponse>;
85
+ export declare function prompt(server: ZcodeAcpServer, params: acp.PromptRequest, cx: acp.AgentContext, requestId: number | string, client?: acp.AgentContext): Promise<acp.PromptResponse>;
56
86
  /**
57
87
  * `session/set_config_option` → dispatch model/mode/thought and emit the
58
88
  * resulting config_option_update (+ current_mode_update for mode).
@@ -1 +1 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/handlers/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,OAAO,KAAK,KAAK,GAAG,MAAM,0BAA0B,CAAC;AAGrD,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAuB1E,OAAO,EAML,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AA+GhE;;;;;GAKG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,GAAG,CAAC,iBAAiB,GAC5B,OAAO,CA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