@te-river/opencode-team-mode 1.6.0 → 1.6.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.
- package/README.md +80 -15
- package/README.zh-CN.md +67 -18
- package/dist/host/note.d.ts +7 -0
- package/dist/host/note.d.ts.map +1 -0
- package/dist/host/note.js +28 -0
- package/dist/host/note.js.map +1 -0
- package/dist/host/v1.d.ts +14 -0
- package/dist/host/v1.d.ts.map +1 -0
- package/dist/host/v1.js +340 -0
- package/dist/host/v1.js.map +1 -0
- package/dist/host/v2-browser-gate.d.ts +45 -0
- package/dist/host/v2-browser-gate.d.ts.map +1 -0
- package/dist/host/v2-browser-gate.js +319 -0
- package/dist/host/v2-browser-gate.js.map +1 -0
- package/dist/host/v2-capabilities.d.ts +68 -0
- package/dist/host/v2-capabilities.d.ts.map +1 -0
- package/dist/host/v2-capabilities.js +146 -0
- package/dist/host/v2-capabilities.js.map +1 -0
- package/dist/host/v2-client.d.ts +53 -0
- package/dist/host/v2-client.d.ts.map +1 -0
- package/dist/host/v2-client.js +193 -0
- package/dist/host/v2-client.js.map +1 -0
- package/dist/host/v2-events.d.ts +56 -0
- package/dist/host/v2-events.d.ts.map +1 -0
- package/dist/host/v2-events.js +158 -0
- package/dist/host/v2-events.js.map +1 -0
- package/dist/host/v2-guard.d.ts +101 -0
- package/dist/host/v2-guard.d.ts.map +1 -0
- package/dist/host/v2-guard.js +199 -0
- package/dist/host/v2-guard.js.map +1 -0
- package/dist/host/v2-offload.d.ts +148 -0
- package/dist/host/v2-offload.d.ts.map +1 -0
- package/dist/host/v2-offload.js +288 -0
- package/dist/host/v2-offload.js.map +1 -0
- package/dist/host/v2-permissions.d.ts +123 -0
- package/dist/host/v2-permissions.d.ts.map +1 -0
- package/dist/host/v2-permissions.js +190 -0
- package/dist/host/v2-permissions.js.map +1 -0
- package/dist/host/v2-probe.d.ts +85 -0
- package/dist/host/v2-probe.d.ts.map +1 -0
- package/dist/host/v2-probe.js +268 -0
- package/dist/host/v2-probe.js.map +1 -0
- package/dist/host/v2-scope.d.ts +51 -0
- package/dist/host/v2-scope.d.ts.map +1 -0
- package/dist/host/v2-scope.js +58 -0
- package/dist/host/v2-scope.js.map +1 -0
- package/dist/host/v2-session-client.d.ts +74 -0
- package/dist/host/v2-session-client.d.ts.map +1 -0
- package/dist/host/v2-session-client.js +171 -0
- package/dist/host/v2-session-client.js.map +1 -0
- package/dist/host/v2-session.d.ts +85 -0
- package/dist/host/v2-session.d.ts.map +1 -0
- package/dist/host/v2-session.js +171 -0
- package/dist/host/v2-session.js.map +1 -0
- package/dist/host/v2-subagent.d.ts +157 -0
- package/dist/host/v2-subagent.d.ts.map +1 -0
- package/dist/host/v2-subagent.js +286 -0
- package/dist/host/v2-subagent.js.map +1 -0
- package/dist/host/v2-tool.d.ts +67 -0
- package/dist/host/v2-tool.d.ts.map +1 -0
- package/dist/host/v2-tool.js +209 -0
- package/dist/host/v2-tool.js.map +1 -0
- package/dist/host/v2-transcript.d.ts +73 -0
- package/dist/host/v2-transcript.d.ts.map +1 -0
- package/dist/host/v2-transcript.js +151 -0
- package/dist/host/v2-transcript.js.map +1 -0
- package/dist/host/v2-types.d.ts +229 -0
- package/dist/host/v2-types.d.ts.map +1 -0
- package/dist/host/v2-types.js +17 -0
- package/dist/host/v2-types.js.map +1 -0
- package/dist/host/v2.d.ts +42 -0
- package/dist/host/v2.d.ts.map +1 -0
- package/dist/host/v2.js +706 -0
- package/dist/host/v2.js.map +1 -0
- package/dist/index.d.ts +23 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +29 -366
- package/dist/index.js.map +1 -1
- package/dist/prompts/lead.d.ts +1 -1
- package/dist/prompts/lead.d.ts.map +1 -1
- package/dist/prompts/lead.js +452 -426
- package/dist/prompts/lead.js.map +1 -1
- package/dist/prompts/shared.d.ts +2 -2
- package/dist/prompts/shared.d.ts.map +1 -1
- package/dist/prompts/shared.js +30 -10
- package/dist/prompts/shared.js.map +1 -1
- package/dist/prompts/specialists.d.ts +2 -2
- package/dist/prompts/specialists.d.ts.map +1 -1
- package/dist/prompts/specialists.js +7 -6
- package/dist/prompts/specialists.js.map +1 -1
- package/dist/task-offload.d.ts +16 -0
- package/dist/task-offload.d.ts.map +1 -1
- package/dist/task-offload.js +51 -0
- package/dist/task-offload.js.map +1 -1
- package/dist/tm/browser.d.ts.map +1 -1
- package/dist/tm/browser.js +41 -10
- package/dist/tm/browser.js.map +1 -1
- package/dist/tm/dispatch.d.ts +47 -0
- package/dist/tm/dispatch.d.ts.map +1 -1
- package/dist/tm/dispatch.js +230 -31
- package/dist/tm/dispatch.js.map +1 -1
- package/dist/tm/dupe-guard.d.ts +16 -3
- package/dist/tm/dupe-guard.d.ts.map +1 -1
- package/dist/tm/dupe-guard.js +27 -7
- package/dist/tm/dupe-guard.js.map +1 -1
- package/dist/tm/index.d.ts +40 -1
- package/dist/tm/index.d.ts.map +1 -1
- package/dist/tm/index.js +40 -11
- package/dist/tm/index.js.map +1 -1
- package/dist/tm/ledger.d.ts +114 -0
- package/dist/tm/ledger.d.ts.map +1 -0
- package/dist/tm/ledger.js +308 -0
- package/dist/tm/ledger.js.map +1 -0
- package/dist/tm/perm-ask.d.ts +1 -3
- package/dist/tm/perm-ask.d.ts.map +1 -1
- package/dist/tm/perm-ask.js +10 -1
- package/dist/tm/perm-ask.js.map +1 -1
- package/dist/tm/preview.d.ts +55 -0
- package/dist/tm/preview.d.ts.map +1 -1
- package/dist/tm/preview.js +225 -0
- package/dist/tm/preview.js.map +1 -1
- package/dist/tm/search.d.ts.map +1 -1
- package/dist/tm/search.js +40 -10
- package/dist/tm/search.js.map +1 -1
- package/dist/tm/serp-loop.d.ts +45 -0
- package/dist/tm/serp-loop.d.ts.map +1 -0
- package/dist/tm/serp-loop.js +80 -0
- package/dist/tm/serp-loop.js.map +1 -0
- package/dist/tm/stats.d.ts +10 -0
- package/dist/tm/stats.d.ts.map +1 -1
- package/dist/tm/stats.js +160 -0
- package/dist/tm/stats.js.map +1 -1
- package/dist/tm/webfetch.d.ts +4 -0
- package/dist/tm/webfetch.d.ts.map +1 -1
- package/dist/tm/webfetch.js +75 -8
- package/dist/tm/webfetch.js.map +1 -1
- package/docs/installation-v2.md +436 -0
- package/docs/installation.md +12 -0
- package/docs/research/agent-data-exchange.md +117 -0
- package/docs/research/browser-pane.md +89 -0
- package/docs/research/host-http-api.md +132 -0
- package/docs/research/host-subagent-injection.md +187 -0
- package/docs/research/plugin-loader-contract.md +261 -0
- package/docs/research/v2-builtin-tools.md +447 -0
- package/docs/v2-port-notes.md +315 -0
- package/index.js +7 -0
- package/package.json +64 -61
- package/scripts/gen-v2-config.mjs +304 -0
- package/scripts/lib/config-surgery.cjs +239 -0
- package/scripts/lib/fake-ctx.mjs +146 -0
package/dist/host/v1.js
ADDED
|
@@ -0,0 +1,340 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,YAA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ClB,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"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { V2Registration } from "./v2-types.js";
|
|
2
|
+
import type { TeamScope } from "./v2-scope.js";
|
|
3
|
+
/** The four host-vs-tm_browser differences that cost rounds in the user's real task log,
|
|
4
|
+
* said once per session at the result where each one bites. */
|
|
5
|
+
export declare const NATIVE_BROWSER_NOTE: string;
|
|
6
|
+
export interface BrowserGateReport {
|
|
7
|
+
/** browser_* execute.before events we looked at (Team sessions only) */
|
|
8
|
+
seen: number;
|
|
9
|
+
/** of those, how many carried a URL or local path we could classify */
|
|
10
|
+
classified: number;
|
|
11
|
+
/** refusals raised at the door */
|
|
12
|
+
refused: number;
|
|
13
|
+
/** of those refusals, how many the host walked past anyway (layer 2 fired) */
|
|
14
|
+
leaked: number;
|
|
15
|
+
/** sessions that got the one-time native browser_* reading note */
|
|
16
|
+
annotated: number;
|
|
17
|
+
/** refusals that produced no following result within the window — the door held */
|
|
18
|
+
held: number;
|
|
19
|
+
/** refusals raised against a Code Mode program (`execute`), which reaches the same
|
|
20
|
+
* browser through `tools.browser.*` and would otherwise bypass this file entirely */
|
|
21
|
+
codeModeRefused: number;
|
|
22
|
+
/** out-of-scope calls left completely alone, counted rather than invisible */
|
|
23
|
+
foreignSkipped: number;
|
|
24
|
+
/** per-tool refusal counts, so "which verb is the hole" is answerable */
|
|
25
|
+
byTool: Record<string, {
|
|
26
|
+
seen: number;
|
|
27
|
+
refused: number;
|
|
28
|
+
leaked: number;
|
|
29
|
+
}>;
|
|
30
|
+
}
|
|
31
|
+
export interface BrowserGate {
|
|
32
|
+
registrations: V2Registration[];
|
|
33
|
+
report: BrowserGateReport;
|
|
34
|
+
/** The hook bodies are exported through this seam so a test can drive both halves
|
|
35
|
+
* (a host that honours the throw, and one that does not) without a live desktop. */
|
|
36
|
+
fireBefore: (event: unknown) => void;
|
|
37
|
+
fireAfter: (event: unknown) => void;
|
|
38
|
+
}
|
|
39
|
+
export declare function applyV2BrowserGate(ctx: unknown, opts: {
|
|
40
|
+
allowlist: readonly string[];
|
|
41
|
+
scope?: TeamScope;
|
|
42
|
+
env?: Record<string, string | undefined>;
|
|
43
|
+
}): BrowserGate;
|
|
44
|
+
export declare function browserGateSummary(r: BrowserGateReport): string;
|
|
45
|
+
//# sourceMappingURL=v2-browser-gate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v2-browser-gate.d.ts","sourceRoot":"","sources":["../../src/host/v2-browser-gate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAyC9C;gEACgE;AAChE,eAAO,MAAM,mBAAmB,QAO8B,CAAA;AAE9D,MAAM,WAAW,iBAAiB;IAChC,wEAAwE;IACxE,IAAI,EAAE,MAAM,CAAA;IACZ,uEAAuE;IACvE,UAAU,EAAE,MAAM,CAAA;IAClB,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAA;IACf,8EAA8E;IAC9E,MAAM,EAAE,MAAM,CAAA;IACd,mEAAmE;IACnE,SAAS,EAAE,MAAM,CAAA;IACjB,mFAAmF;IACnF,IAAI,EAAE,MAAM,CAAA;IACZ;0FACsF;IACtF,eAAe,EAAE,MAAM,CAAA;IACvB,8EAA8E;IAC9E,cAAc,EAAE,MAAM,CAAA;IACtB,yEAAyE;IACzE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAC1E;AAED,MAAM,W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