@te-river/opencode-team-mode 1.7.2 → 1.7.3

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 (165) hide show
  1. package/README.md +1009 -849
  2. package/README.zh-CN.md +906 -756
  3. package/dist/host/v2-browser-gate.d.ts +4 -1
  4. package/dist/host/v2-browser-gate.d.ts.map +1 -1
  5. package/dist/host/v2-browser-gate.js +1 -1
  6. package/dist/host/v2-browser-gate.js.map +1 -1
  7. package/dist/host/v2-capabilities.js +1 -1
  8. package/dist/host/v2-capabilities.js.map +1 -1
  9. package/dist/host/v2-guard.d.ts +3 -1
  10. package/dist/host/v2-guard.d.ts.map +1 -1
  11. package/dist/host/v2-guard.js +2 -2
  12. package/dist/host/v2-guard.js.map +1 -1
  13. package/dist/host/v2-offload.d.ts +12 -2
  14. package/dist/host/v2-offload.d.ts.map +1 -1
  15. package/dist/host/v2-offload.js +9 -9
  16. package/dist/host/v2-offload.js.map +1 -1
  17. package/dist/host/v2-probe-chain.d.ts +5 -1
  18. package/dist/host/v2-probe-chain.d.ts.map +1 -1
  19. package/dist/host/v2-probe-chain.js +4 -6
  20. package/dist/host/v2-probe-chain.js.map +1 -1
  21. package/dist/host/v2-probe.d.ts.map +1 -1
  22. package/dist/host/v2-probe.js +2 -1
  23. package/dist/host/v2-probe.js.map +1 -1
  24. package/dist/host/v2-prune.d.ts +5 -1
  25. package/dist/host/v2-prune.d.ts.map +1 -1
  26. package/dist/host/v2-prune.js +8 -14
  27. package/dist/host/v2-prune.js.map +1 -1
  28. package/dist/host/v2-retry.d.ts +9 -2
  29. package/dist/host/v2-retry.d.ts.map +1 -1
  30. package/dist/host/v2-retry.js +13 -15
  31. package/dist/host/v2-retry.js.map +1 -1
  32. package/dist/host/v2-session.d.ts +6 -2
  33. package/dist/host/v2-session.d.ts.map +1 -1
  34. package/dist/host/v2-session.js +7 -13
  35. package/dist/host/v2-session.js.map +1 -1
  36. package/dist/host/v2.d.ts +7 -2
  37. package/dist/host/v2.d.ts.map +1 -1
  38. package/dist/host/v2.js +38 -35
  39. package/dist/host/v2.js.map +1 -1
  40. package/dist/prompts/lead.d.ts +1 -1
  41. package/dist/prompts/lead.d.ts.map +1 -1
  42. package/dist/prompts/lead.js +23 -7
  43. package/dist/prompts/lead.js.map +1 -1
  44. package/dist/prompts/specialists.d.ts +1 -1
  45. package/dist/prompts/specialists.d.ts.map +1 -1
  46. package/dist/prompts/specialists.js +1 -1
  47. package/dist/tm/args-schema.d.ts +1 -1
  48. package/dist/tm/args-schema.js +6 -6
  49. package/dist/tm/args-schema.js.map +1 -1
  50. package/dist/tm/board.js +2 -2
  51. package/dist/tm/board.js.map +1 -1
  52. package/dist/tm/config-files.d.ts +41 -17
  53. package/dist/tm/config-files.d.ts.map +1 -1
  54. package/dist/tm/config-files.js +68 -73
  55. package/dist/tm/config-files.js.map +1 -1
  56. package/dist/tm/config-layers.d.ts +65 -33
  57. package/dist/tm/config-layers.d.ts.map +1 -1
  58. package/dist/tm/config-layers.js +165 -81
  59. package/dist/tm/config-layers.js.map +1 -1
  60. package/dist/tm/config-template.d.ts +32 -0
  61. package/dist/tm/config-template.d.ts.map +1 -0
  62. package/dist/tm/config-template.js +74 -0
  63. package/dist/tm/config-template.js.map +1 -0
  64. package/dist/tm/config.d.ts +115 -140
  65. package/dist/tm/config.d.ts.map +1 -1
  66. package/dist/tm/config.js +100 -200
  67. package/dist/tm/config.js.map +1 -1
  68. package/dist/tm/index.d.ts +11 -3
  69. package/dist/tm/index.d.ts.map +1 -1
  70. package/dist/tm/index.js +46 -16
  71. package/dist/tm/index.js.map +1 -1
  72. package/dist/tm/ledger.d.ts +7 -3
  73. package/dist/tm/ledger.d.ts.map +1 -1
  74. package/dist/tm/ledger.js +5 -4
  75. package/dist/tm/ledger.js.map +1 -1
  76. package/dist/tm/memory.js +3 -3
  77. package/dist/tm/pipelines.js +1 -1
  78. package/dist/tm/search.js +6 -6
  79. package/dist/tm/search.js.map +1 -1
  80. package/dist/tm/stats.js +2 -2
  81. package/dist/tm/stats.js.map +1 -1
  82. package/dist/tm/tools.js +2 -2
  83. package/dist/tm/webfetch.d.ts +5 -2
  84. package/dist/tm/webfetch.d.ts.map +1 -1
  85. package/dist/tm/webfetch.js +24 -18
  86. package/dist/tm/webfetch.js.map +1 -1
  87. package/docs/installation-v2.md +59 -38
  88. package/docs/installation.md +4 -4
  89. package/package.json +1 -1
  90. package/dist/approval-gate.d.ts +0 -205
  91. package/dist/approval-gate.d.ts.map +0 -1
  92. package/dist/approval-gate.js +0 -627
  93. package/dist/approval-gate.js.map +0 -1
  94. package/dist/host/v1.d.ts +0 -14
  95. package/dist/host/v1.d.ts.map +0 -1
  96. package/dist/host/v1.js +0 -340
  97. package/dist/host/v1.js.map +0 -1
  98. package/dist/host/v2-client.d.ts +0 -53
  99. package/dist/host/v2-client.d.ts.map +0 -1
  100. package/dist/host/v2-client.js +0 -193
  101. package/dist/host/v2-client.js.map +0 -1
  102. package/dist/host/v2-transcript.d.ts +0 -73
  103. package/dist/host/v2-transcript.d.ts.map +0 -1
  104. package/dist/host/v2-transcript.js +0 -151
  105. package/dist/host/v2-transcript.js.map +0 -1
  106. package/dist/host-hooks.d.ts +0 -126
  107. package/dist/host-hooks.d.ts.map +0 -1
  108. package/dist/host-hooks.js +0 -284
  109. package/dist/host-hooks.js.map +0 -1
  110. package/dist/tm/bash-timeout.d.ts +0 -72
  111. package/dist/tm/bash-timeout.d.ts.map +0 -1
  112. package/dist/tm/bash-timeout.js +0 -100
  113. package/dist/tm/bash-timeout.js.map +0 -1
  114. package/dist/tm/browser.d.ts +0 -642
  115. package/dist/tm/browser.d.ts.map +0 -1
  116. package/dist/tm/browser.js +0 -2836
  117. package/dist/tm/browser.js.map +0 -1
  118. package/dist/tm/ptc/budgets.d.ts +0 -59
  119. package/dist/tm/ptc/budgets.d.ts.map +0 -1
  120. package/dist/tm/ptc/budgets.js +0 -138
  121. package/dist/tm/ptc/budgets.js.map +0 -1
  122. package/dist/tm/ptc/contract.d.ts +0 -171
  123. package/dist/tm/ptc/contract.d.ts.map +0 -1
  124. package/dist/tm/ptc/contract.js +0 -85
  125. package/dist/tm/ptc/contract.js.map +0 -1
  126. package/dist/tm/ptc/driver.d.ts +0 -40
  127. package/dist/tm/ptc/driver.d.ts.map +0 -1
  128. package/dist/tm/ptc/driver.js +0 -213
  129. package/dist/tm/ptc/driver.js.map +0 -1
  130. package/dist/tm/ptc/engines.d.ts +0 -43
  131. package/dist/tm/ptc/engines.d.ts.map +0 -1
  132. package/dist/tm/ptc/engines.js +0 -454
  133. package/dist/tm/ptc/engines.js.map +0 -1
  134. package/dist/tm/ptc/gate.d.ts +0 -28
  135. package/dist/tm/ptc/gate.d.ts.map +0 -1
  136. package/dist/tm/ptc/gate.js +0 -130
  137. package/dist/tm/ptc/gate.js.map +0 -1
  138. package/dist/tm/ptc/index.d.ts +0 -19
  139. package/dist/tm/ptc/index.d.ts.map +0 -1
  140. package/dist/tm/ptc/index.js +0 -15
  141. package/dist/tm/ptc/index.js.map +0 -1
  142. package/dist/tm/ptc/pscan.d.ts +0 -30
  143. package/dist/tm/ptc/pscan.d.ts.map +0 -1
  144. package/dist/tm/ptc/pscan.js +0 -341
  145. package/dist/tm/ptc/pscan.js.map +0 -1
  146. package/dist/tm/ptc/summary.d.ts +0 -17
  147. package/dist/tm/ptc/summary.d.ts.map +0 -1
  148. package/dist/tm/ptc/summary.js +0 -134
  149. package/dist/tm/ptc/summary.js.map +0 -1
  150. package/dist/tm/ptc/tool.d.ts +0 -66
  151. package/dist/tm/ptc/tool.d.ts.map +0 -1
  152. package/dist/tm/ptc/tool.js +0 -231
  153. package/dist/tm/ptc/tool.js.map +0 -1
  154. package/dist/tm/ptc.d.ts +0 -298
  155. package/dist/tm/ptc.d.ts.map +0 -1
  156. package/dist/tm/ptc.js +0 -865
  157. package/dist/tm/ptc.js.map +0 -1
  158. package/dist/tm/pty.d.ts +0 -70
  159. package/dist/tm/pty.d.ts.map +0 -1
  160. package/dist/tm/pty.js +0 -245
  161. package/dist/tm/pty.js.map +0 -1
  162. package/dist/tool-coerce.d.ts +0 -24
  163. package/dist/tool-coerce.d.ts.map +0 -1
  164. package/dist/tool-coerce.js +0 -63
  165. package/dist/tool-coerce.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"v1.d.ts","sourceRoot":"","sources":["../../src/host/v1.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAA8C,WAAW,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAqCjG,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,WAAW,EAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,OAAO,CAAC,KAAK,CAAC,CA4UhB"}
package/dist/host/v1.js DELETED
@@ -1,340 +0,0 @@
1
- /**
2
- * The v1 personality: everything this plugin does through the OpenCode 1.18.x
3
- * `server(input, options)` hook object. Moved out of `src/index.ts` verbatim
4
- * for the v2 port (see docs plan) — no behaviour change is allowed here; a v1
5
- * host must observe byte-identical hooks, and the ~1700 assertions in
6
- * test-*.mjs are the oracle that keeps that promise.
7
- *
8
- * v1-only by construction: the single composed `tool.execute.before` slot, the
9
- * permission-event approval gate, the `{"*": "ask"}` bash escalation object,
10
- * and `tui.showToast` notification.
11
- */
12
- import { agents } from "../agents.js";
13
- import { commands } from "../commands.js";
14
- import { startBlackboardMaintenance, resolveTtlMs, DEFAULT_TTL_DAYS, } from "../blackboard.js";
15
- import { createEnvProtectHook, parseExtraDeny, resolveEnvProtectMode, bashAskPatterns, } from "../envprotect.js";
16
- import { createApprovalGate, resolveAskTimeoutMs, hasPermissionReplyCapability, } from "../approval-gate.js";
17
- import { createTmTools } from "../tm/index.js";
18
- import { createBashTimeoutHook } from "../tm/bash-timeout.js";
19
- import { createCapabilityProbe } from "../capabilities.js";
20
- import { createTaskOffload } from "../task-offload.js";
21
- import { coerceToolArgs } from "../tool-coerce.js";
22
- import { ASK_GRACE_MS, setAskBridgeObserver, setAskWaitMs } from "../tm/perm-ask.js";
23
- import { applyToolDefinition, applyChatParams, applySessionCompacting, applyCompactionAutoContinue, applyShellEnv, hookSwitches, TASK_HINT_BACKGROUND, } from "../host-hooks.js";
24
- import { hostBackgroundSubagentsEnabled } from "../tm/dispatch.js";
25
- import { blackboardNote } from "./note.js";
26
- export async function createV1Personality(input, options) {
27
- // ---------- blackboard maintenance (code-level TTL sweeper) ----------
28
- const directory = typeof input?.directory === "string" && input.directory.length > 0
29
- ? input.directory
30
- : process.cwd();
31
- const ttlMs = resolveTtlMs(options);
32
- const ttlDays = Math.round(ttlMs / (24 * 60 * 60 * 1000)) || DEFAULT_TTL_DAYS;
33
- const boardRoot = startBlackboardMaintenance(directory, ttlMs);
34
- const note = blackboardNote(boardRoot, ttlDays);
35
- // ---------- R6 env protection (code-level interception) ----------
36
- // Plugin option envProtect (default false): opt-in env protection.
37
- // When disabled, R6 hook is not installed at all — no interception,
38
- // no approval gate, no audit logging for env reads.
39
- // When enabled, TM_ENV_PROTECT / TM_ENV_PROTECT_EXTRA_DENY still apply.
40
- const envProtectMode = options?.envProtect
41
- ? resolveEnvProtectMode(process.env.TM_ENV_PROTECT)
42
- : "off";
43
- const envProtectExtra = parseExtraDeny(process.env.TM_ENV_PROTECT_EXTRA_DENY);
44
- // ---------- unified approval gate (R6 env face + R2 danger face) ----------
45
- // Layer 2: ONE timer that auto-REJECTS unanswered official-dialog requests
46
- // after TM_ASK_TIMEOUT_MIN and (Layer 3) fails closed if the SDK reply is
47
- // broken. Armed ONLY when R6 is not off AND the client exposes a
48
- // permission-reply path — otherwise there is no live auto-reject and the
49
- // R6 hook must keep hard-throwing every env read (fail-closed).
50
- // Attention hook for EVERY official dialog the plugin observes (bash R2/R6
51
- // asks AND the tm_* ctx.ask web dialogs): the host's `tui.showToast` RPC
52
- // (verified 1.18.30 route: payload { title?, message, variant, duration })
53
- // surfaces a toast so a user not staring at the screen still learns a
54
- // confirmation is waiting. Best-effort — never breaks the gate.
55
- const notifyAsk = (message) => {
56
- try {
57
- const tui = input?.client
58
- ?.tui;
59
- if (typeof tui?.showToast === "function") {
60
- const r = tui.showToast({
61
- title: "OpenCode TeamMode",
62
- message,
63
- variant: "warning",
64
- duration: 15_000,
65
- });
66
- if (r && typeof r.catch === "function") {
67
- ;
68
- r.catch(() => { });
69
- }
70
- }
71
- }
72
- catch {
73
- /* notification is best-effort */
74
- }
75
- };
76
- const approvalGate = envProtectMode !== "off" && hasPermissionReplyCapability(input?.client)
77
- ? createApprovalGate({
78
- client: input?.client,
79
- timeoutMs: resolveAskTimeoutMs(process.env),
80
- notify: notifyAsk,
81
- })
82
- : null;
83
- if (approvalGate)
84
- approvalGate.start();
85
- // Sessions are only allowed to DEFER expressible env reads to the dialog
86
- // once the gate registered them as carrying our injected bash ask set
87
- // (reviewer C1: a global isArmed() deferral let stock build/plan agents
88
- // run printenv silently). The authoritative source of that fact is the
89
- // config hook below: it records exactly which agents got the escalated
90
- // ask object, and a `message.updated`/`chat.message` user prompt routed
91
- // to one of those agents registers its session (live-proven ordering:
92
- // the user message event arrives before the session's first
93
- // tool.execute.before, while permission.asked arrives AFTER it).
94
- const injectedExecAgents = new Set();
95
- const envProtectHook = createEnvProtectHook(input?.client, envProtectMode, envProtectExtra, { deferToApproval: (sessionID) => approvalGate?.canDefer(sessionID) ?? false,
96
- envApproved: (sessionID) => approvalGate?.isEnvApproved(sessionID) ?? false });
97
- // ---------- JIT layer-2 tools (tm_read / tm_grep / tm_bash / tm_fetch) ----------
98
- // T0.4-verified static registration: server() hooks gain a `tool` segment.
99
- // The R6 mode/extra resolved above are passed in so the tm_* pipelines
100
- // share the SAME interception source as the built-in tools (anti-backdoor:
101
- // the global hook ALSO aliases tm_* onto read/grep/bash — see envprotect).
102
- // ---------- host-capability probe (see src/capabilities.ts) ----------
103
- // The plugin's features degrade quietly when a host surface disappears;
104
- // this records what is actually present and says so once, at startup,
105
- // instead of letting an OpenCode upgrade surface as an agent working
106
- // around something the user never agreed to lose.
107
- let capabilityProbe = null;
108
- const tmRuntime = await createTmTools(input, {
109
- mode: envProtectMode,
110
- extra: envProtectExtra,
111
- notify: notifyAsk,
112
- // The capability probe is built from the tm runtime (it needs the run
113
- // store to log into), and tm_stats needs the probe back — a declaration
114
- // before construction breaks the cycle without weakening either side.
115
- capabilities: () => capabilityProbe?.snapshot() ?? [],
116
- // A child session we take over (adopted from the host tree, or named to
117
- // tm_join) is registered the moment it is recognised (the message.updated
118
- // route below re-confirms it): an exec-role sub-agent whose session were
119
- // NOT registered would hard-throw its own protected reads instead of
120
- // opening the dialog.
121
- onChildSession: (sessionID, agent) => {
122
- if (approvalGate && injectedExecAgents.has(agent))
123
- approvalGate.registerExecSession(sessionID);
124
- },
125
- });
126
- // ---------- host-hook switches (TM_TOOL_HINTS / TM_COMPACTION_*) ------
127
- const hostSwitches = hookSwitches(process.env);
128
- capabilityProbe = createCapabilityProbe({
129
- client: input?.client,
130
- hasShellBridge: typeof input?.$ === "function",
131
- hasPermissionReply: hasPermissionReplyCapability(input?.client),
132
- trajectory: (event) => tmRuntime.pipelines.store.appendTrajectory(event),
133
- notify: notifyAsk,
134
- });
135
- // ctx.ask is only observable from inside a tool call — perm-ask reports
136
- // every lookup it makes, which is how this row ever reaches 已验证.
137
- // The tool-side backstop for a dialog nobody answers. It is deliberately
138
- // LONGER than the gate's own auto-reject so the gate stays authoritative when it
139
- // is armed; when it is not (R6 off, no reply capability) this is the only thing
140
- // that keeps a governed call from hanging until the user interrupts the turn.
141
- setAskWaitMs(resolveAskTimeoutMs(process.env) + ASK_GRACE_MS);
142
- setAskBridgeObserver((present) => capabilityProbe?.observeAskBridge(present));
143
- // Plan B's other half: keep the host's background-task result injection
144
- // inside the context budget. Built here because it needs the tm runtime's
145
- // thresholds and its trajectory writer.
146
- const taskOffloadHook = createTaskOffload({
147
- enabled: tmRuntime.config.taskOffload === "on",
148
- thresholdTokens: tmRuntime.config.offloadThresholdText,
149
- previewLines: tmRuntime.config.previewLines,
150
- previewMaxTokens: tmRuntime.config.previewMaxTokens,
151
- log: (event) => tmRuntime.pipelines.store.appendTrajectory(event),
152
- });
153
- // Startup report: one trajectory line always, one toast ONLY when a
154
- // required surface is gone (a missing 待观察 row is not an alarm).
155
- capabilityProbe.report();
156
- // ---------- bash timeout clamp (issue #6, see tm/bash-timeout.ts) ------
157
- const bashTimeoutHook = createBashTimeoutHook({
158
- probeMs: tmRuntime.config.bashTimeoutProbeMs,
159
- maxMs: tmRuntime.config.bashTimeoutMaxMs,
160
- readonlyAllowed: tmRuntime.config.bashReadonlyAllowed,
161
- onClamp: (info) => {
162
- try {
163
- tmRuntime.pipelines.store.appendTrajectory({
164
- tool: "bash",
165
- step_id: "timeout-clamp",
166
- event: info.via,
167
- from_ms: info.from,
168
- to_ms: info.to,
169
- });
170
- }
171
- catch {
172
- /* observability only */
173
- }
174
- },
175
- });
176
- return {
177
- // ---------- v1 config hook: inject agents & commands ----------
178
- config(cfg) {
179
- if (!cfg.agent)
180
- cfg.agent = {};
181
- // Execution roles carry permission.bash === "allow"; escalate it to a
182
- // pattern object so the host opens its official confirmation dialog
183
- // for the R6 env face + R2 danger face (default `*` stays allow). A
184
- // shallow copy keeps the module-level `agents` object pristine. The
185
- // R6 env face is only injected while the approval gate can arm: with
186
- // no arming client the R6 hook hard-throws env reads BEFORE any
187
- // dialog could be satisfied, so those patterns would be dead popups.
188
- const bashAsk = bashAskPatterns(envProtectMode, approvalGate !== null);
189
- for (const [name, def] of Object.entries(agents)) {
190
- // Respect user-defined overrides: never clobber an existing entry.
191
- if (cfg.agent[name])
192
- continue;
193
- const permission = def.permission
194
- ? {
195
- ...def.permission,
196
- ...(def.permission.bash === "allow" ? { bash: bashAsk } : null),
197
- }
198
- : def.permission;
199
- cfg.agent[name] = {
200
- ...def,
201
- permission,
202
- prompt: name === "team" ? (def.prompt ?? "") + note : def.prompt,
203
- };
204
- // deferral-registry seed: agents that ACTUALLY carry our escalated
205
- // bash ask object (user-overridden agents never get added)
206
- if (def.permission && def.permission.bash === "allow")
207
- injectedExecAgents.add(name);
208
- }
209
- if (!cfg.command)
210
- cfg.command = {};
211
- for (const [name, def] of Object.entries(commands)) {
212
- if (cfg.command[name])
213
- continue;
214
- cfg.command[name] = def;
215
- }
216
- // ---------- make Team the default agent (opt-out: defaultAgent:false)
217
- const promote = options?.defaultAgent !== false;
218
- if (promote && (!cfg.default_agent || cfg.default_agent === "build")) {
219
- cfg.default_agent = "team";
220
- }
221
- },
222
- // ---------- R6: block the model's env-var read paths in code ----------
223
- // ONE hook, two independent jobs (the host calls the single
224
- // `tool.execute.before` slot per plugin): first clamp a wasteful
225
- // model-set bash timeout, then run the R6 interception. The clamp
226
- // runs BEFORE R6 so a blocked call is never also a slow one.
227
- "tool.execute.before": async (input, output) => {
228
- capabilityProbe?.observeHook("tool.execute.before");
229
- // First, and narrowest: a built-in boolean the model sent as a string
230
- // (the host's schema rejects it — two dead `task {background}` calls
231
- // proved the trap). Then the timeout clamp, then R6.
232
- const coerced = coerceToolArgs(input, output);
233
- if (coerced.length) {
234
- tmRuntime.pipelines.store.appendTrajectory({
235
- tool: String(input?.tool ?? "task"),
236
- step_id: "args-coerce",
237
- event: "coerced",
238
- keys: coerced.join(","),
239
- });
240
- }
241
- bashTimeoutHook(input, output);
242
- await envProtectHook(input, output);
243
- },
244
- // ---------- host-hook leverage beyond the tool surface (audit #2) ----
245
- // Every one of these rides a published hook and mutates ONLY the
246
- // fields whose shape is verified; each is independently switchable,
247
- // because this host's d.ts has shipped surfaces the runtime never
248
- // fires (permission.ask), so adapters must fail soft, not assume.
249
- // The `observeHook` calls are that "not assume" made observable: a row
250
- // stays 待观察 until the host actually calls the hook, and tm_stats
251
- // reports it either way.
252
- "tool.definition": (input, output) => {
253
- capabilityProbe?.observeHook("tool.definition");
254
- applyToolDefinition(input, output, hostSwitches.toolHints, hostBackgroundSubagentsEnabled() ? TASK_HINT_BACKGROUND : undefined);
255
- },
256
- "chat.params": (input, output) => {
257
- capabilityProbe?.observeHook("chat.params");
258
- applyChatParams(input, output, process.env);
259
- },
260
- "experimental.session.compacting": (input, output) => {
261
- capabilityProbe?.observeHook("session.compacting");
262
- applySessionCompacting(output, hostSwitches.compactionContext);
263
- },
264
- "experimental.compaction.autocontinue": (input, output) => {
265
- capabilityProbe?.observeHook("compaction.autocontinue");
266
- applyCompactionAutoContinue(output, process.env);
267
- },
268
- "shell.env": (input, output) => {
269
- capabilityProbe?.observeHook("shell.env");
270
- applyShellEnv(output, process.env);
271
- },
272
- // ---------- unified approval gate: watch the host permission dialog ---
273
- event: ({ event }) => {
274
- capabilityProbe?.observeEvent(event?.type ?? "");
275
- // Async dispatch bookkeeping runs FIRST and independently of R6:
276
- // session.idle / .error are what tell the lead its children settled.
277
- tmRuntime.observeDispatchEvent(event);
278
- if (!approvalGate)
279
- return;
280
- // Pre-tool session registration: the live host emits message.updated
281
- // with the full UserMessage ({ sessionID, role:"user", agent }) when
282
- // a prompt enters a session — BEFORE any tool.execute.before of that
283
- // turn, which is exactly when the R6 hook needs to know the session
284
- // carries our injected ask set (permission.asked only fires AFTER
285
- // the hook, so it can never be the first-command registration).
286
- if (event?.type === "message.updated") {
287
- const info = event.properties?.info;
288
- if (info &&
289
- info.role === "user" &&
290
- typeof info.agent === "string" &&
291
- typeof info.sessionID === "string") {
292
- // UserMessage.agent is a REQUIRED string in the host schema
293
- // (verified in the desktop binary), so a user prompt always names
294
- // its agent. Deferral stays live only while the CURRENT prompt
295
- // runs an exec-role agent: a prompt routed to any other agent
296
- // revokes the registration (stock agents' sessions would never
297
- // open our dialogs, so a stale registration = silent env reads).
298
- if (injectedExecAgents.has(info.agent)) {
299
- approvalGate.registerExecSession(info.sessionID);
300
- }
301
- else {
302
- approvalGate.revokeExecSession(info.sessionID);
303
- }
304
- }
305
- return;
306
- }
307
- approvalGate.handleEvent(event);
308
- },
309
- // secondary registration channel (official 1.18.x contract; the event
310
- // route above is the one verified against the live 1.18.29 bus)
311
- "chat.message": (input, output) => {
312
- // Plan B: the host's background sub-agent injects the child's FULL
313
- // reply here. Governance first, and independent of the approval gate —
314
- // it only ever touches synthetic parts carrying the host's own
315
- // task envelope (see src/task-offload.ts).
316
- taskOffloadHook(input, output ?? { message: undefined, parts: undefined });
317
- if (!approvalGate)
318
- return;
319
- if (input &&
320
- typeof input.sessionID === "string" &&
321
- typeof input.agent === "string") {
322
- if (injectedExecAgents.has(input.agent)) {
323
- approvalGate.registerExecSession(input.sessionID);
324
- }
325
- else {
326
- approvalGate.revokeExecSession(input.sessionID);
327
- }
328
- }
329
- },
330
- dispose: async () => {
331
- approvalGate?.dispose();
332
- // tm_browser owns a browser child process — kill it on teardown and
333
- // WAIT, or the process can exit with the window still on screen.
334
- await tmRuntime.dispose();
335
- },
336
- // ---------- JIT layer-2: tm_read / tm_grep / tm_bash / tm_fetch ----------
337
- tool: tmRuntime.tools,
338
- };
339
- }
340
- //# sourceMappingURL=v1.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"v1.js","sourceRoot":"","sources":["../../src/host/v1.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EACL,0BAA0B,EAC1B,YAAY,EACZ,gBAAgB,GACjB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,qBAAqB,EACrB,eAAe,GAChB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,4BAA4B,GAC7B,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,EAAE,qBAAqB,EAAwB,MAAM,oBAAoB,CAAA;AAChF,OAAO,EAAE,iBA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,SAAS,CAAC,CAAA;oBAChD,CAAC;gBACH,CAAC;gBACD,OAAM;YACR,CAAC;YACD,YAAY,CAAC,WAAW,CAAC,KAAwB,CAAC,CAAA;QACpD,CAAC;QACD,sEAAsE;QACtE,gEAAgE;QAChE,cAAc,EAAE,CACd,KAA6C,EAC7C,MAAiF,EACjF,EAAE;YACF,mEAAmE;YACnE,uEAAuE;YACvE,+DAA+D;YAC/D,2CAA2C;YAC3C,eAAe,CAAC,KAAK,EAAE,MAAM,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAA;YAC1E,IAAI,CAAC,YAAY;gBAAE,OAAM;YACzB,IACE,KAAK;gBACL,OAAO,KAAK,CAAC,SAAS,KAAK,QAAQ;gBACnC,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,EAC/B,CAAC;gBACD,IAAI,kBAAkB,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;oBACxC,YAAY,CAAC,mBAAmB,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;gBACnD,CAAC;qBAAM,CAAC;oBACN,YAAY,CAAC,iBAAiB,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;gBACjD,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,YAAY,EAAE,OAAO,EAAE,CAAA;YACvB,oEAAoE;YACpE,iEAAiE;YACjE,MAAM,SAAS,CAAC,OAAO,EAAE,CAAA;QAC3B,CAAC;QAED,4EAA4E;QAC5E,IAAI,EAAE,SAAS,CAAC,KAAK;KACtB,CAAA;AACH,CAAC"}
@@ -1,53 +0,0 @@
1
- /**
2
- * The v2 client shim.
3
- *
4
- * v1 handed plugin tools an SDK client with `file.read` and `find.text`; the v2
5
- * plugin context has no `file` domain at all (verified against the live
6
- * `ctx` key list), and `tm_read`/`tm_grep` hard-fail without it
7
- * ("宿主 client 不可用"). Rather than fork those two pipelines per host
8
- * generation, this module satisfies the SAME two method contracts from Node fs,
9
- * returning the exact payload shapes the real host emits so
10
- * `unwrapClientResult`/`extractText` in `src/tm/client-unwrap.ts` keep working
11
- * untouched.
12
- *
13
- * The scan is bounded on purpose. An unbounded recursive grep over a real
14
- * workspace is the difference between a tool call and a hung turn, and the
15
- * bound is REPORTED rather than silently truncating — a truncated answer that
16
- * reads like a complete one is the defect this repo keeps getting paid for.
17
- */
18
- type ClientResult = {
19
- data: unknown;
20
- } | {
21
- data: {
22
- error: {
23
- name: string;
24
- data: {
25
- message: string;
26
- };
27
- };
28
- };
29
- };
30
- /**
31
- * `client.file.read({ query: { path, directory } })` →
32
- * `{ data: { type: "text", content } }` (the 1.18.x real-host shape).
33
- */
34
- declare function read(req: unknown): Promise<ClientResult>;
35
- /**
36
- * `client.find.text({ query: { pattern, directory } })` →
37
- * `{ data: FindMatch[] }`. `pattern` arrives as the raw model string, exactly
38
- * as in v1; an invalid regex is the CALLER's problem to report, so it throws
39
- * and pipelines.ts turns it into a structured error like every other host
40
- * client failure.
41
- */
42
- declare function findText(req: unknown): Promise<ClientResult>;
43
- /** The two methods `createTmTools` actually reaches for on this object. */
44
- export declare function createV2Client(): {
45
- file: {
46
- read: typeof read;
47
- };
48
- find: {
49
- text: typeof findText;
50
- };
51
- };
52
- export {};
53
- //# sourceMappingURL=v2-client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"v2-client.d.ts","sourceRoot":"","sources":["../../src/host/v2-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAgCH,KAAK,YAAY,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE;QAAE,KAAK,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE;gBAAE,OAAO,EAAE,MAAM,CAAA;aAAE,CAAA;SAAE,CAAA;KAAE,CAAA;CAAE,CAAA;AAkBxG;;;GAGG;AACH,iBAAe,IAAI,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC,CAkBvD;AA6BD;;;;;;GAMG;AACH,iBAAe,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC,CAqE3D;AAED,2EAA2E;AAC3E,wBAAgB,cAAc,IAAI;IAAE,IAAI,EAAE;QAAE,IAAI,EAAE,OAAO,IAAI,CAAA;KAAE,CAAC;IAAC,IAAI,EAAE;QAAE,IAAI,EAAE,OAAO,QAAQ,CAAA;KAAE,CAAA;CAAE,CAEjG"}
@@ -1,193 +0,0 @@
1
- /**
2
- * The v2 client shim.
3
- *
4
- * v1 handed plugin tools an SDK client with `file.read` and `find.text`; the v2
5
- * plugin context has no `file` domain at all (verified against the live
6
- * `ctx` key list), and `tm_read`/`tm_grep` hard-fail without it
7
- * ("宿主 client 不可用"). Rather than fork those two pipelines per host
8
- * generation, this module satisfies the SAME two method contracts from Node fs,
9
- * returning the exact payload shapes the real host emits so
10
- * `unwrapClientResult`/`extractText` in `src/tm/client-unwrap.ts` keep working
11
- * untouched.
12
- *
13
- * The scan is bounded on purpose. An unbounded recursive grep over a real
14
- * workspace is the difference between a tool call and a hung turn, and the
15
- * bound is REPORTED rather than silently truncating — a truncated answer that
16
- * reads like a complete one is the defect this repo keeps getting paid for.
17
- */
18
- import fs from "node:fs";
19
- import path from "node:path";
20
- /** Directories no read-only search should ever walk into. */
21
- const SKIP_DIRS = new Set([
22
- ".git",
23
- "node_modules",
24
- "dist",
25
- "build",
26
- "out",
27
- "target",
28
- ".next",
29
- ".nuxt",
30
- ".venv",
31
- "venv",
32
- "__pycache__",
33
- ".cache",
34
- ".turbo",
35
- ".gradle",
36
- "coverage",
37
- ".pytest_cache",
38
- ]);
39
- const MAX_VISITED_FILES = 20_000;
40
- const MAX_MATCHED_FILES = 200;
41
- const MAX_LINES_PER_FILE = 20;
42
- const MAX_TOTAL_LINES = 500;
43
- const MAX_SCAN_FILE_BYTES = 2 * 1024 * 1024;
44
- const MAX_READ_BYTES = 8 * 1024 * 1024;
45
- function clientError(name, message) {
46
- return { data: { error: { name, data: { message } } } };
47
- }
48
- function looksBinary(buffer) {
49
- const head = buffer.subarray(0, Math.min(buffer.length, 8_192));
50
- return head.includes(0);
51
- }
52
- /**
53
- * `client.file.read({ query: { path, directory } })` →
54
- * `{ data: { type: "text", content } }` (the 1.18.x real-host shape).
55
- */
56
- async function read(req) {
57
- const query = req?.query ?? {};
58
- const target = typeof query.path === "string" ? query.path : "";
59
- if (!target)
60
- return clientError("ReadError", "缺少 path 参数");
61
- try {
62
- const st = fs.statSync(target);
63
- if (st.isDirectory())
64
- return clientError("ReadError", `路径是目录: ${target}`);
65
- if (st.size > MAX_READ_BYTES) {
66
- return clientError("ReadError", `文件过大(${st.size} 字节 > ${MAX_READ_BYTES}),本工具不整读:改用 tm_grep 定位行号,或 tm_bash 的 head/tail 取样`);
67
- }
68
- return { data: { type: "text", content: fs.readFileSync(target, "utf8") } };
69
- }
70
- catch (err) {
71
- const code = err?.code ?? "ReadError";
72
- return clientError(String(code), `${code}: ${target}`);
73
- }
74
- }
75
- function walkFiles(root, out) {
76
- let truncated = false;
77
- const stack = [root];
78
- while (stack.length) {
79
- const dir = stack.pop();
80
- let entries;
81
- try {
82
- entries = fs.readdirSync(dir, { withFileTypes: true });
83
- }
84
- catch {
85
- continue; // unreadable directory: skip, it is not our workspace to force
86
- }
87
- for (const entry of entries) {
88
- const full = path.join(dir, entry.name);
89
- if (entry.isSymbolicLink())
90
- continue; // never follow links: cycles and escapes
91
- if (entry.isDirectory()) {
92
- if (SKIP_DIRS.has(entry.name))
93
- continue;
94
- stack.push(full);
95
- continue;
96
- }
97
- if (!entry.isFile())
98
- continue;
99
- if (out.length >= MAX_VISITED_FILES)
100
- return { truncated: true };
101
- out.push(full);
102
- }
103
- }
104
- return { truncated };
105
- }
106
- /**
107
- * `client.find.text({ query: { pattern, directory } })` →
108
- * `{ data: FindMatch[] }`. `pattern` arrives as the raw model string, exactly
109
- * as in v1; an invalid regex is the CALLER's problem to report, so it throws
110
- * and pipelines.ts turns it into a structured error like every other host
111
- * client failure.
112
- */
113
- async function findText(req) {
114
- const query = req?.query ?? {};
115
- const pattern = typeof query.pattern === "string" ? query.pattern : "";
116
- if (!pattern)
117
- return clientError("FindError", "缺少 pattern 参数");
118
- const root = typeof query.directory === "string" && query.directory ? query.directory : process.cwd();
119
- const re = new RegExp(pattern);
120
- const files = [];
121
- const walked = walkFiles(root, files);
122
- const matches = [];
123
- let totalLines = 0;
124
- // Every bound that actually BIT has to be named in the answer: a grep that
125
- // shows 20 of a file's 400 matching lines and stays silent reads as a
126
- // complete answer, which is the exact defect this repo keeps paying for.
127
- const trimmed = [];
128
- let truncated = walked.truncated;
129
- for (const file of files) {
130
- if (matches.length >= MAX_MATCHED_FILES || totalLines >= MAX_TOTAL_LINES) {
131
- truncated = true;
132
- trimmed.push(`范围在 ${matches.length} 个文件 / ${totalLines} 行处停止(${files.length} 个文件待扫)`);
133
- break;
134
- }
135
- let st;
136
- try {
137
- st = fs.statSync(file);
138
- }
139
- catch {
140
- continue;
141
- }
142
- if (st.size > MAX_SCAN_FILE_BYTES)
143
- continue;
144
- let buffer;
145
- try {
146
- buffer = fs.readFileSync(file);
147
- }
148
- catch {
149
- continue;
150
- }
151
- if (buffer.length === 0 || looksBinary(buffer))
152
- continue;
153
- const lines = buffer.toString("utf8").split(/\r?\n/);
154
- const hits = [];
155
- let firstLine = 0;
156
- let matchedInFile = 0;
157
- for (let i = 0; i < lines.length; i++) {
158
- if (!re.test(lines[i]))
159
- continue;
160
- matchedInFile++;
161
- if (!firstLine)
162
- firstLine = i + 1;
163
- if (hits.length < MAX_LINES_PER_FILE && totalLines + hits.length < MAX_TOTAL_LINES)
164
- hits.push(lines[i]);
165
- }
166
- if (!matchedInFile)
167
- continue;
168
- if (hits.length < matchedInFile) {
169
- truncated = true;
170
- trimmed.push(`${path.basename(file)} 命中 ${matchedInFile} 行,只带前 ${hits.length} 行`);
171
- }
172
- matches.push({ path: file, lines: hits, line: firstLine });
173
- totalLines += hits.length;
174
- }
175
- if (truncated) {
176
- const detail = trimmed.length
177
- ? trimmed.slice(0, 3).join(";") + (trimmed.length > 3 ? `;另有 ${trimmed.length - 3} 处` : "")
178
- : "达到扫描上限";
179
- matches.push({
180
- path: "(扫描被截断)",
181
- lines: [
182
- `这是部分结果:${detail}(上限 每文件 ${MAX_LINES_PER_FILE} 行 / ${MAX_MATCHED_FILES} 个文件 / ${MAX_TOTAL_LINES} 行)。缩小 directory 或收紧 pattern 再来一次,别把这份当成全量`,
183
- ],
184
- line: 0,
185
- });
186
- }
187
- return { data: matches };
188
- }
189
- /** The two methods `createTmTools` actually reaches for on this object. */
190
- export function createV2Client() {
191
- return { file: { read }, find: { text: findText } };
192
- }
193
- //# sourceMappingURL=v2-client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"v2-client.js","sourceRoot":"","sources":["../../src/host/v2-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,6DAA6D;AAC7D,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC;IACxB,MAAM;IACN,cAAc;IACd,MAAM;IACN,OAAO;IACP,KAAK;IACL,QAAQ;IACR,OAAO;IACP,OAAO;IACP,OAAO;IACP,MAAM;IACN,aAAa;IACb,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,UAAU;IACV,eAAe;CAChB,CAAC,CAAA;AAEF,MAAM,iBAAiB,GAAG,MAAM,CAAA;AAChC,MAAM,iBAAiB,GAAG,GAAG,CAAA;AAC7B,MAAM,kBAAkB,GAAG,EAAE,CAAA;AAC7B,MAAM,eAAe,GAAG,GAAG,CAAA;AAC3B,MAAM,mBAAmB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAA;AAC3C,MAAM,cAAc,GAAG,CAAC,GAAG,IAAI,GAAG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