@zergai/ztc 0.23.1-dev.202611152321 → 0.24.0-beta.1

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 (149) hide show
  1. package/README.md +299 -13
  2. package/bin/zmux-darwin-arm64 +0 -0
  3. package/bin/ztc-audio-darwin-arm64 +0 -0
  4. package/bin/ztc-capture-darwin-arm64 +0 -0
  5. package/bin/ztc-computer-darwin-arm64 +0 -0
  6. package/bin/ztc-llm-darwin-arm64 +0 -0
  7. package/bin/ztc-tts-darwin-arm64 +0 -0
  8. package/bin/ztc-tui-darwin-arm64 +0 -0
  9. package/bin/zterm-darwin-arm64 +2 -2
  10. package/dist/agent/agent.js +57 -14
  11. package/dist/agent/backends/http_error.d.ts +2 -0
  12. package/dist/agent/backends/http_error.js +2 -0
  13. package/dist/agent/backends/router_gate.d.ts +3 -2
  14. package/dist/agent/backends/router_gate.js +5 -4
  15. package/dist/agent/backends/router_keys.d.ts +14 -0
  16. package/dist/agent/backends/router_keys.js +19 -0
  17. package/dist/agent/backends/router_refusal.d.ts +5 -3
  18. package/dist/agent/backends/router_refusal.js +28 -6
  19. package/dist/agent/backends/types.d.ts +1 -1
  20. package/dist/agent/backends/zrouter_stream.js +10 -6
  21. package/dist/agent/commands/agent_cli.d.ts +11 -1
  22. package/dist/agent/commands/agent_cli.js +295 -38
  23. package/dist/agent/commands/diff.js +4 -1
  24. package/dist/agent/commands/help.js +4 -1
  25. package/dist/agent/commands/plan.js +3 -1
  26. package/dist/agent/commands/session_redaction.d.ts +16 -0
  27. package/dist/agent/commands/session_redaction.js +77 -0
  28. package/dist/agent/commands/settings.js +144 -0
  29. package/dist/agent/commands/types.d.ts +5 -0
  30. package/dist/agent/commands/usage_spec.d.ts +4 -0
  31. package/dist/agent/commands/usage_spec.js +10 -4
  32. package/dist/agent/runtime/policy.d.ts +25 -0
  33. package/dist/agent/runtime/policy.js +154 -26
  34. package/dist/agent/runtime/source_verification.js +6 -2
  35. package/dist/agent/runtime/tool_runtime.js +81 -3
  36. package/dist/agent/tools/apply_patch.js +678 -131
  37. package/dist/agent/tools/bus_message.d.ts +26 -1
  38. package/dist/agent/tools/bus_message.js +126 -10
  39. package/dist/agent/tools/file.d.ts +16 -1
  40. package/dist/agent/tools/file.js +43 -5
  41. package/dist/agent/tools/index.d.ts +1 -1
  42. package/dist/agent/tools/index.js +1 -1
  43. package/dist/agent/tools/pane.js +5 -0
  44. package/dist/agent/tools/search.js +5 -1
  45. package/dist/agent/tools/supervision.js +16 -2
  46. package/dist/agent/tools/types.d.ts +22 -0
  47. package/dist/app/mirror_startup.d.ts +7 -5
  48. package/dist/app/mirror_startup.js +7 -5
  49. package/dist/app/navigator_mirrors.d.ts +20 -0
  50. package/dist/app/navigator_mirrors.js +36 -0
  51. package/dist/app/workspace_layout_controller.d.ts +11 -2
  52. package/dist/app/workspace_layout_controller.js +13 -2
  53. package/dist/batch/worktree.js +9 -1
  54. package/dist/cli_ratatui.d.ts +264 -12
  55. package/dist/cli_ratatui.js +1198 -103
  56. package/dist/config/types.d.ts +29 -0
  57. package/dist/desktop/daily/source_baseline.js +3 -1
  58. package/dist/diagnostics/session_export.d.ts +1 -0
  59. package/dist/diagnostics/session_export.js +229 -26
  60. package/dist/emulation/tool_adapters.js +42 -5
  61. package/dist/headless.js +24 -5
  62. package/dist/instance_registry.d.ts +7 -0
  63. package/dist/mcp/workspace_server.d.ts +12 -1
  64. package/dist/mcp/workspace_server.js +75 -8
  65. package/dist/panes/agent_cli.d.ts +60 -3
  66. package/dist/panes/agent_cli.js +169 -16
  67. package/dist/panes/agent_pane_sessions.d.ts +22 -0
  68. package/dist/panes/agent_pane_sessions.js +111 -0
  69. package/dist/panes/agent_panes.d.ts +77 -3
  70. package/dist/panes/agent_panes.js +199 -10
  71. package/dist/panes/agent_profiles.d.ts +5 -0
  72. package/dist/panes/agent_profiles.js +7 -0
  73. package/dist/panes/agent_resume.d.ts +134 -0
  74. package/dist/panes/agent_resume.js +155 -0
  75. package/dist/panes/agent_sessions/claude_head.d.ts +32 -0
  76. package/dist/panes/agent_sessions/claude_head.js +122 -0
  77. package/dist/panes/agent_sessions/claude_store.d.ts +59 -0
  78. package/dist/panes/agent_sessions/claude_store.js +223 -0
  79. package/dist/panes/agent_sessions/codex_head.d.ts +55 -0
  80. package/dist/panes/agent_sessions/codex_head.js +161 -0
  81. package/dist/panes/agent_sessions/codex_store.d.ts +43 -0
  82. package/dist/panes/agent_sessions/codex_store.js +187 -0
  83. package/dist/panes/agent_sessions/controller.d.ts +74 -0
  84. package/dist/panes/agent_sessions/controller.js +110 -0
  85. package/dist/panes/agent_sessions/cut_json.d.ts +14 -0
  86. package/dist/panes/agent_sessions/cut_json.js +109 -0
  87. package/dist/panes/agent_sessions/limits.d.ts +48 -0
  88. package/dist/panes/agent_sessions/limits.js +48 -0
  89. package/dist/panes/agent_sessions/scan.d.ts +49 -0
  90. package/dist/panes/agent_sessions/scan.js +86 -0
  91. package/dist/panes/agent_sessions/store_fs.d.ts +51 -0
  92. package/dist/panes/agent_sessions/store_fs.js +128 -0
  93. package/dist/panes/agent_sessions/stores.d.ts +36 -0
  94. package/dist/panes/agent_sessions/stores.js +89 -0
  95. package/dist/panes/agent_sessions/title.d.ts +9 -0
  96. package/dist/panes/agent_sessions/title.js +51 -0
  97. package/dist/panes/agent_sessions/types.d.ts +48 -0
  98. package/dist/panes/agent_sessions/types.js +2 -0
  99. package/dist/panes/reply_arbitrator.d.ts +39 -0
  100. package/dist/panes/reply_arbitrator.js +185 -0
  101. package/dist/panes/reply_modes.d.ts +291 -0
  102. package/dist/panes/reply_modes.js +598 -0
  103. package/dist/runtime_info.js +11 -2
  104. package/dist/session.js +4 -2
  105. package/dist/simulation/living/context.d.ts +8 -8
  106. package/dist/simulation/living/types.d.ts +5 -5
  107. package/dist/simulation/toolkit/dynamic_state.d.ts +1 -1
  108. package/dist/ui/ratatui/ipc_path.d.ts +5 -0
  109. package/dist/ui/ratatui/ipc_path.js +23 -3
  110. package/dist/ui/ratatui/pane_credential_broker.d.ts +23 -8
  111. package/dist/ui/ratatui/pane_credential_broker.js +49 -14
  112. package/dist/ui/ratatui/pane_relay.d.ts +5 -2
  113. package/dist/ui/ratatui/pane_relay.js +86 -19
  114. package/dist/ui/ratatui/process.js +3 -0
  115. package/dist/ui/ratatui/protocol.d.ts +50 -1
  116. package/dist/ui/ratatui/protocol.js +56 -0
  117. package/dist/ui/ratatui/relay_policy.d.ts +39 -0
  118. package/dist/ui/ratatui/relay_policy.js +94 -0
  119. package/dist/ui/ratatui/screen_privacy.d.ts +15 -0
  120. package/dist/ui/ratatui/screen_privacy.js +24 -0
  121. package/dist/ui/scrollback.js +8 -0
  122. package/dist/ui/widgets/agent_sessions_panel.d.ts +139 -0
  123. package/dist/ui/widgets/agent_sessions_panel.js +542 -0
  124. package/dist/ui/widgets/log_view.d.ts +5 -1
  125. package/dist/ui/widgets/log_view.js +40 -4
  126. package/dist/utils/atomic_write.js +9 -11
  127. package/dist/utils/canonical_path.d.ts +19 -0
  128. package/dist/utils/canonical_path.js +44 -0
  129. package/dist/utils/compaction.d.ts +2 -1
  130. package/dist/utils/compaction.js +3 -1
  131. package/dist/utils/git_directory_names.d.ts +51 -0
  132. package/dist/utils/git_directory_names.js +429 -0
  133. package/dist/utils/temporary_write_root.d.ts +6 -1
  134. package/dist/utils/temporary_write_root.js +32 -2
  135. package/dist/utils/tool_result_message.d.ts +4 -1
  136. package/dist/utils/tool_result_message.js +6 -2
  137. package/dist/web/bus_hold.d.ts +70 -0
  138. package/dist/web/bus_hold.js +118 -0
  139. package/dist/web/mirror_client.d.ts +7 -3
  140. package/dist/web/mirror_client.js +61 -23
  141. package/dist/web/mirror_route_gate.d.ts +40 -0
  142. package/dist/web/mirror_route_gate.js +71 -0
  143. package/dist/web/mirror_stream.d.ts +147 -22
  144. package/dist/web/mirror_stream.js +350 -83
  145. package/dist/web/pane_credentials.d.ts +32 -1
  146. package/dist/web/pane_credentials.js +62 -2
  147. package/dist/workspace_collision.js +11 -2
  148. package/dist/zlm-embed.mjs +940 -273
  149. package/package.json +39 -7
@@ -71,8 +71,39 @@ export declare class PaneCredentialStore {
71
71
  /**
72
72
  * Mint a credential for a pane about to be created. It authenticates as nothing until bound, and is dropped if it
73
73
  * isn't bound within PENDING_TTL_MS. With `paneId`, a renderer that assigns ids before it spawns binds it at once.
74
+ * `openedBy` is the pane a pane asked for it from, through the pane relay (the pane its relay connection announced),
75
+ * which openerOf then names for as long as the credential stands for its pane. `joinsBus` says a ZTC that joins this
76
+ * port's mirror bus as it starts will hold it (joinsBus).
74
77
  */
75
- issue(scope?: PaneCredentialScope, paneId?: number): PaneCredential;
78
+ issue(scope?: PaneCredentialScope, paneId?: number, openedBy?: number | null, options?: {
79
+ joinsBus?: boolean;
80
+ }): PaneCredential;
81
+ /**
82
+ * The pane that opened pane PANE_ID through the pane relay, as the credential bound to it records (issue's
83
+ * `openedBy`). Null when its credential records none (ZTC itself or the person opened it, a relay connection that
84
+ * named no pane did, or its owner started it again in place), when no credential stands for it (it holds none, it
85
+ * closed, or the renderer relaunched it without one), or when its credentials disagree.
86
+ */
87
+ openerOf(paneId: number): number | null;
88
+ /**
89
+ * Whether pane PANE_ID runs a ZTC that joins this port's mirror bus as it starts, as a credential bound to it says
90
+ * (issue's `joinsBus`), whichever way the pane was opened. False once the pane closes, once its program has exited
91
+ * (programExited), or when it holds no such credential.
92
+ */
93
+ joinsBus(paneId: number): boolean;
94
+ /**
95
+ * The renderer says pane PANE_ID's program has exited (its pane list's is_alive): the ZTC that holds a credential bound
96
+ * to the pane that joins this port's mirror bus is gone, so the pane no longer joins (joinsBus) and its ZTC has exited
97
+ * (ztcExited). That lasts as long as the credential stands for the pane: a pane started again in place with a fresh
98
+ * credential, or opened anew, holds one that hasn't exited; one started again without a credential, or closed, holds
99
+ * none. Returns whether this is news: a credential that joins the bus, and hadn't exited, is now marked.
100
+ */
101
+ programExited(paneId: number): boolean;
102
+ /**
103
+ * Whether pane PANE_ID's ZTC, which joined or would have joined this port's mirror bus, has exited (programExited), and
104
+ * no credential of a ZTC that still joins it stands for the pane.
105
+ */
106
+ ztcExited(paneId: number): boolean;
76
107
  /** The pane a presented credential stands for; 'pending' while it waits for its pane; null for anything else. */
77
108
  resolve(token: string): PanePrincipal | 'pending' | null;
78
109
  /**
@@ -71,12 +71,16 @@ export class PaneCredentialStore {
71
71
  /**
72
72
  * Mint a credential for a pane about to be created. It authenticates as nothing until bound, and is dropped if it
73
73
  * isn't bound within PENDING_TTL_MS. With `paneId`, a renderer that assigns ids before it spawns binds it at once.
74
+ * `openedBy` is the pane a pane asked for it from, through the pane relay (the pane its relay connection announced),
75
+ * which openerOf then names for as long as the credential stands for its pane. `joinsBus` says a ZTC that joins this
76
+ * port's mirror bus as it starts will hold it (joinsBus).
74
77
  */
75
- issue(scope = 'pane', paneId) {
78
+ issue(scope = 'pane', paneId, openedBy = null, options = {}) {
76
79
  this.sweep();
77
80
  const token = randomBytes(32).toString('base64url');
78
81
  const key = digest(token);
79
- this.entries.set(key, { scope, paneId: null, pendingUntilMs: Date.now() + PENDING_TTL_MS, waiters: new Set() });
82
+ this.entries.set(key, { scope, paneId: null, openedBy, joinsBus: options.joinsBus === true, exited: false,
83
+ pendingUntilMs: Date.now() + PENDING_TTL_MS, waiters: new Set() });
80
84
  const credential = {
81
85
  token,
82
86
  scope,
@@ -98,6 +102,62 @@ export class PaneCredentialStore {
98
102
  credential.bind(paneId);
99
103
  return credential;
100
104
  }
105
+ /**
106
+ * The pane that opened pane PANE_ID through the pane relay, as the credential bound to it records (issue's
107
+ * `openedBy`). Null when its credential records none (ZTC itself or the person opened it, a relay connection that
108
+ * named no pane did, or its owner started it again in place), when no credential stands for it (it holds none, it
109
+ * closed, or the renderer relaunched it without one), or when its credentials disagree.
110
+ */
111
+ openerOf(paneId) {
112
+ const openers = new Set();
113
+ for (const entry of this.entries.values())
114
+ if (entry.paneId === paneId)
115
+ openers.add(entry.openedBy);
116
+ return openers.size === 1 ? [...openers][0] : null;
117
+ }
118
+ /**
119
+ * Whether pane PANE_ID runs a ZTC that joins this port's mirror bus as it starts, as a credential bound to it says
120
+ * (issue's `joinsBus`), whichever way the pane was opened. False once the pane closes, once its program has exited
121
+ * (programExited), or when it holds no such credential.
122
+ */
123
+ joinsBus(paneId) {
124
+ for (const entry of this.entries.values())
125
+ if (entry.paneId === paneId && entry.joinsBus && !entry.exited)
126
+ return true;
127
+ return false;
128
+ }
129
+ /**
130
+ * The renderer says pane PANE_ID's program has exited (its pane list's is_alive): the ZTC that holds a credential bound
131
+ * to the pane that joins this port's mirror bus is gone, so the pane no longer joins (joinsBus) and its ZTC has exited
132
+ * (ztcExited). That lasts as long as the credential stands for the pane: a pane started again in place with a fresh
133
+ * credential, or opened anew, holds one that hasn't exited; one started again without a credential, or closed, holds
134
+ * none. Returns whether this is news: a credential that joins the bus, and hadn't exited, is now marked.
135
+ */
136
+ programExited(paneId) {
137
+ let marked = false;
138
+ for (const entry of this.entries.values()) {
139
+ if (entry.paneId !== paneId || !entry.joinsBus || entry.exited)
140
+ continue;
141
+ entry.exited = true;
142
+ marked = true;
143
+ }
144
+ return marked;
145
+ }
146
+ /**
147
+ * Whether pane PANE_ID's ZTC, which joined or would have joined this port's mirror bus, has exited (programExited), and
148
+ * no credential of a ZTC that still joins it stands for the pane.
149
+ */
150
+ ztcExited(paneId) {
151
+ let exited = false;
152
+ for (const entry of this.entries.values()) {
153
+ if (entry.paneId !== paneId || !entry.joinsBus)
154
+ continue;
155
+ if (!entry.exited)
156
+ return false;
157
+ exited = true;
158
+ }
159
+ return exited;
160
+ }
101
161
  /** The pane a presented credential stands for; 'pending' while it waits for its pane; null for anything else. */
102
162
  resolve(token) {
103
163
  if (!token)
@@ -37,8 +37,17 @@ function gitEnvironment() {
37
37
  delete env[key];
38
38
  return { ...env, GIT_OPTIONAL_LOCKS: '0', GIT_TERMINAL_PROMPT: '0' };
39
39
  }
40
+ /**
41
+ * Options every git run here takes first, as runtime_info's probes do. Inspection and isolation run git in the work tree
42
+ * the agent writes to, in ZTC's own process and outside any sandbox the agent works under: core.fsmonitor=false keeps a
43
+ * core.fsmonitor command in the repository's config from running on a diff or an apply, and safe.bareRepository=explicit
44
+ * keeps git from taking a bare repository planted in the work tree for the session's repository and running its config.
45
+ * Both are honoured from the command line, which the agent cannot write, and leave normal work trees and linked
46
+ * worktrees working.
47
+ */
48
+ const GIT_OPTIONS = ['-c', 'core.fsmonitor=false', '-c', 'safe.bareRepository=explicit'];
40
49
  async function git(cwd, args, limit = 1024 * 1024, timeout = GIT_TIMEOUT_MS) {
41
- const result = await execFileAsync('git', ['-C', cwd, ...args], {
50
+ const result = await execFileAsync('git', [...GIT_OPTIONS, '-C', cwd, ...args], {
42
51
  env: gitEnvironment(), encoding: 'buffer', timeout, maxBuffer: limit,
43
52
  windowsHide: true,
44
53
  });
@@ -594,7 +603,7 @@ async function applyPatch(cwd, patch, staged) {
594
603
  if (!patch.length)
595
604
  return;
596
605
  await new Promise((resolvePromise, reject) => {
597
- const child = spawn('git', ['-C', cwd, 'apply', '--binary', ...(staged ? ['--index'] : []), '-'], {
606
+ const child = spawn('git', [...GIT_OPTIONS, '-C', cwd, 'apply', '--binary', ...(staged ? ['--index'] : []), '-'], {
598
607
  env: gitEnvironment(), stdio: ['pipe', 'ignore', 'pipe'], windowsHide: true,
599
608
  });
600
609
  let stderr = '';