@te-river/opencode-team-mode 1.5.12 → 1.5.14

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 (88) hide show
  1. package/README.md +30 -6
  2. package/README.zh-CN.md +28 -4
  3. package/dist/agents.d.ts +5 -1
  4. package/dist/agents.d.ts.map +1 -1
  5. package/dist/agents.js +24 -2
  6. package/dist/agents.js.map +1 -1
  7. package/dist/capabilities.d.ts +66 -0
  8. package/dist/capabilities.d.ts.map +1 -0
  9. package/dist/capabilities.js +165 -0
  10. package/dist/capabilities.js.map +1 -0
  11. package/dist/host-hooks.d.ts +115 -0
  12. package/dist/host-hooks.d.ts.map +1 -0
  13. package/dist/host-hooks.js +270 -0
  14. package/dist/host-hooks.js.map +1 -0
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +103 -4
  17. package/dist/index.js.map +1 -1
  18. package/dist/prompts/lead.d.ts +1 -1
  19. package/dist/prompts/lead.d.ts.map +1 -1
  20. package/dist/prompts/lead.js +71 -8
  21. package/dist/prompts/lead.js.map +1 -1
  22. package/dist/prompts/shared.d.ts +1 -1
  23. package/dist/prompts/shared.d.ts.map +1 -1
  24. package/dist/prompts/shared.js +51 -2
  25. package/dist/prompts/shared.js.map +1 -1
  26. package/dist/prompts/specialists.d.ts +1 -1
  27. package/dist/prompts/specialists.d.ts.map +1 -1
  28. package/dist/prompts/specialists.js +38 -17
  29. package/dist/prompts/specialists.js.map +1 -1
  30. package/dist/tm/args-schema.d.ts +7 -1
  31. package/dist/tm/args-schema.d.ts.map +1 -1
  32. package/dist/tm/args-schema.js +9 -3
  33. package/dist/tm/args-schema.js.map +1 -1
  34. package/dist/tm/bash-timeout.d.ts +72 -0
  35. package/dist/tm/bash-timeout.d.ts.map +1 -0
  36. package/dist/tm/bash-timeout.js +100 -0
  37. package/dist/tm/bash-timeout.js.map +1 -0
  38. package/dist/tm/browser.d.ts +91 -5
  39. package/dist/tm/browser.d.ts.map +1 -1
  40. package/dist/tm/browser.js +564 -89
  41. package/dist/tm/browser.js.map +1 -1
  42. package/dist/tm/cache.d.ts +68 -0
  43. package/dist/tm/cache.d.ts.map +1 -0
  44. package/dist/tm/cache.js +157 -0
  45. package/dist/tm/cache.js.map +1 -0
  46. package/dist/tm/config.d.ts +87 -0
  47. package/dist/tm/config.d.ts.map +1 -1
  48. package/dist/tm/config.js +66 -0
  49. package/dist/tm/config.js.map +1 -1
  50. package/dist/tm/dispatch.d.ts +123 -0
  51. package/dist/tm/dispatch.d.ts.map +1 -0
  52. package/dist/tm/dispatch.js +476 -0
  53. package/dist/tm/dispatch.js.map +1 -0
  54. package/dist/tm/dupe-guard.d.ts +58 -0
  55. package/dist/tm/dupe-guard.d.ts.map +1 -0
  56. package/dist/tm/dupe-guard.js +105 -0
  57. package/dist/tm/dupe-guard.js.map +1 -0
  58. package/dist/tm/index.d.ts +32 -4
  59. package/dist/tm/index.d.ts.map +1 -1
  60. package/dist/tm/index.js +58 -5
  61. package/dist/tm/index.js.map +1 -1
  62. package/dist/tm/perm-ask.d.ts +1 -0
  63. package/dist/tm/perm-ask.d.ts.map +1 -1
  64. package/dist/tm/perm-ask.js +15 -1
  65. package/dist/tm/perm-ask.js.map +1 -1
  66. package/dist/tm/pipelines.d.ts.map +1 -1
  67. package/dist/tm/pipelines.js +11 -0
  68. package/dist/tm/pipelines.js.map +1 -1
  69. package/dist/tm/pty.d.ts +70 -0
  70. package/dist/tm/pty.d.ts.map +1 -0
  71. package/dist/tm/pty.js +242 -0
  72. package/dist/tm/pty.js.map +1 -0
  73. package/dist/tm/search.d.ts +56 -7
  74. package/dist/tm/search.d.ts.map +1 -1
  75. package/dist/tm/search.js +195 -41
  76. package/dist/tm/search.js.map +1 -1
  77. package/dist/tm/stats.d.ts +117 -0
  78. package/dist/tm/stats.d.ts.map +1 -0
  79. package/dist/tm/stats.js +296 -0
  80. package/dist/tm/stats.js.map +1 -0
  81. package/dist/tm/webfetch.d.ts +23 -0
  82. package/dist/tm/webfetch.d.ts.map +1 -1
  83. package/dist/tm/webfetch.js +97 -8
  84. package/dist/tm/webfetch.js.map +1 -1
  85. package/dist/types.d.ts +16 -0
  86. package/dist/types.d.ts.map +1 -1
  87. package/docs/installation.md +216 -17
  88. package/package.json +2 -2
@@ -0,0 +1,117 @@
1
+ /**
2
+ * tm_stats — read the plugin's own trajectory back (2026-09-19).
3
+ *
4
+ * Why: the project's whole justification is throughput ("if Team isn't
5
+ * faster, Team has no point"), and until now every claim about it was
6
+ * unfalsifiable — the run store and `steps.jsonl` were append-only outputs
7
+ * nothing read back. This module turns that log into the two numbers that
8
+ * actually decide the argument:
9
+ *
10
+ * 1. TOKENS kept out of the context window (offload events, measured by
11
+ * the same CJK-aware estimator the offload decision used, net of the
12
+ * preview that DID come back);
13
+ * 2. SECONDS saved by overlap (dispatch children's own
14
+ * durations summed against the wall-clock window they actually
15
+ * occupied — serial cost minus parallel cost).
16
+ *
17
+ * Plus the governance and degrade counts a user needs to see whether the
18
+ * guardrails are biting (blocked subresources, refused tm_pty starts,
19
+ * clamped bash timeouts, engine fallbacks).
20
+ *
21
+ * Honesty rules baked in: the numbers are an ESTIMATE over the retained
22
+ * trajectory (TTL-swept, run-per-process), the window is stated alongside
23
+ * them, and the host-capability matrix rides the same reply so "what broke
24
+ * after the upgrade" is answerable in one call. Read-only, no network, no
25
+ * new surface: it reads files this plugin wrote.
26
+ */
27
+ import type { ToolDefinition } from "../types.js";
28
+ import { type CapabilityRow } from "../capabilities.js";
29
+ import type { RunStore } from "./store.js";
30
+ /** One `steps.jsonl` line; unknown fields stay reachable. */
31
+ export interface TrajEvent {
32
+ ts?: string;
33
+ run_id?: string;
34
+ tool?: string;
35
+ step_id?: string;
36
+ event?: string;
37
+ [k: string]: unknown;
38
+ }
39
+ /** Torn/crashed tail lines are normal in an append-only log — skip, never throw. */
40
+ export declare function parseTrajectoryJsonl(text: string): TrajEvent[];
41
+ export interface RunFile {
42
+ runId: string;
43
+ file: string;
44
+ mtimeMs: number;
45
+ bytes: number;
46
+ }
47
+ /** Newest-first trajectory runs (one dir per plugin process). */
48
+ export declare function listTrajectoryRuns(trajectoryRoot: string, limit?: number): RunFile[];
49
+ export interface ToolStat {
50
+ tool: string;
51
+ calls: number;
52
+ results: number;
53
+ offloaded: number;
54
+ tokens: number;
55
+ savedTokens: number;
56
+ }
57
+ export interface TmStats {
58
+ window: {
59
+ runs: number;
60
+ events: number;
61
+ from?: number;
62
+ to?: number;
63
+ wallMs: number;
64
+ };
65
+ tools: ToolStat[];
66
+ dispatch: {
67
+ starts: number;
68
+ settled: number;
69
+ failed: number;
70
+ adopted: number;
71
+ cancelled: number;
72
+ sumMs: number;
73
+ maxMs: number;
74
+ /** serial cost minus the wall-clock window the children really used. */
75
+ overlapSavedMs: number;
76
+ };
77
+ ptc: {
78
+ runs: number;
79
+ calls: number;
80
+ errors: number;
81
+ retries: number;
82
+ sumMs: number;
83
+ };
84
+ governance: {
85
+ blockedSubresources: number;
86
+ blockedHosts: string[];
87
+ ptyRefused: number;
88
+ clampedTimeouts: number;
89
+ clampSavedMs: number;
90
+ offloadDegraded: number;
91
+ /** URL-cache hits — every one is a fetch this round did NOT pay for. */
92
+ webCacheHits: number;
93
+ /** evaluate_script results that had a secret shape masked out. */
94
+ evalMasks: number;
95
+ };
96
+ degrades: Array<{
97
+ seam: string;
98
+ reason: string;
99
+ }>;
100
+ }
101
+ export declare function summarizeEvents(events: readonly TrajEvent[]): TmStats;
102
+ /** Markdown, in the shapes the host renders fastest (tables, not prose). */
103
+ export declare function renderStats(stats: TmStats, opts: {
104
+ runDirs: number;
105
+ roots: string[];
106
+ matrix?: CapabilityRow[];
107
+ now?: number;
108
+ }): string;
109
+ export interface StatsDeps {
110
+ store: RunStore;
111
+ /** Live host-capability matrix (index.ts owns the probe). */
112
+ capabilities?: () => CapabilityRow[];
113
+ /** Injected for tests; defaults to reading the real trajectory store. */
114
+ readEvents?: (runs: readonly RunFile[]) => TrajEvent[];
115
+ }
116
+ export declare function buildStatsTool(deps: StatsDeps): ToolDefinition;
117
+ //# sourceMappingURL=stats.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../src/tm/stats.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,aAAa,CAAA;AAC7D,OAAO,EAA0B,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAE/E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE1C,6DAA6D;AAC7D,MAAM,WAAW,SAAS;IACxB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CACrB;AAED,oFAAoF;AACpF,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,CAY9D;AAED,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;CACd;AAED,iEAAiE;AACjE,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,MAAM,EAAE,KAAK,SAAK,GAAG,OAAO,EAAE,CAoBhF;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,OAAO;IACtB,MAAM,EAAE;QAAE,IAAI,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;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,CAAC,EAAE,aAAa,EAAE,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GACjF,MAAM,CAsER;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,QAAQ,CAAA;IACf,6DAA6D;IAC7D,YAAY,CAAC,EAAE,MAAM,aAAa,EAAE,CAAA;IACpC,yEAAyE;IACzE,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,OAAO,EAAE,KAAK,SAAS,EAAE,CAAA;CACvD;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,GAAG,cAAc,CAsD9D"}
@@ -0,0 +1,296 @@
1
+ /**
2
+ * tm_stats — read the plugin's own trajectory back (2026-09-19).
3
+ *
4
+ * Why: the project's whole justification is throughput ("if Team isn't
5
+ * faster, Team has no point"), and until now every claim about it was
6
+ * unfalsifiable — the run store and `steps.jsonl` were append-only outputs
7
+ * nothing read back. This module turns that log into the two numbers that
8
+ * actually decide the argument:
9
+ *
10
+ * 1. TOKENS kept out of the context window (offload events, measured by
11
+ * the same CJK-aware estimator the offload decision used, net of the
12
+ * preview that DID come back);
13
+ * 2. SECONDS saved by overlap (dispatch children's own
14
+ * durations summed against the wall-clock window they actually
15
+ * occupied — serial cost minus parallel cost).
16
+ *
17
+ * Plus the governance and degrade counts a user needs to see whether the
18
+ * guardrails are biting (blocked subresources, refused tm_pty starts,
19
+ * clamped bash timeouts, engine fallbacks).
20
+ *
21
+ * Honesty rules baked in: the numbers are an ESTIMATE over the retained
22
+ * trajectory (TTL-swept, run-per-process), the window is stated alongside
23
+ * them, and the host-capability matrix rides the same reply so "what broke
24
+ * after the upgrade" is answerable in one call. Read-only, no network, no
25
+ * new surface: it reads files this plugin wrote.
26
+ */
27
+ import * as fs from "node:fs";
28
+ import * as path from "node:path";
29
+ import { renderCapabilityMatrix } from "../capabilities.js";
30
+ import { tmError, toToolResult } from "./result.js";
31
+ /** Torn/crashed tail lines are normal in an append-only log — skip, never throw. */
32
+ export function parseTrajectoryJsonl(text) {
33
+ const out = [];
34
+ for (const line of text.split(/\r?\n/)) {
35
+ if (!line.trim())
36
+ continue;
37
+ try {
38
+ const e = JSON.parse(line);
39
+ if (e && typeof e === "object")
40
+ out.push(e);
41
+ }
42
+ catch {
43
+ /* skip */
44
+ }
45
+ }
46
+ return out;
47
+ }
48
+ /** Newest-first trajectory runs (one dir per plugin process). */
49
+ export function listTrajectoryRuns(trajectoryRoot, limit = 10) {
50
+ const runsRoot = path.join(trajectoryRoot, "runs");
51
+ let names = [];
52
+ try {
53
+ names = fs.readdirSync(runsRoot);
54
+ }
55
+ catch {
56
+ return [];
57
+ }
58
+ const files = [];
59
+ for (const name of names) {
60
+ const file = path.join(runsRoot, name, "steps.jsonl");
61
+ try {
62
+ const st = fs.statSync(file);
63
+ if (st.isFile())
64
+ files.push({ runId: name, file, mtimeMs: st.mtimeMs, bytes: st.size });
65
+ }
66
+ catch {
67
+ /* run without a trajectory file — nothing to read */
68
+ }
69
+ }
70
+ files.sort((a, b) => b.mtimeMs - a.mtimeMs);
71
+ return files.slice(0, Math.max(1, Math.min(50, Math.round(limit) || 1)));
72
+ }
73
+ function num(v) {
74
+ const n = typeof v === "number" ? v : Number(v);
75
+ return Number.isFinite(n) ? n : 0;
76
+ }
77
+ function tsMs(e) {
78
+ const t = Date.parse(String(e.ts ?? ""));
79
+ return Number.isFinite(t) ? t : 0;
80
+ }
81
+ /** The preview that DID reach the context — fall back to the 80-token cap. */
82
+ const PREVIEW_FALLBACK_TOKENS = 80;
83
+ export function summarizeEvents(events) {
84
+ const stats = {
85
+ window: { runs: 0, events: events.length, wallMs: 0 },
86
+ tools: [],
87
+ dispatch: { starts: 0, settled: 0, failed: 0, adopted: 0, cancelled: 0, sumMs: 0, maxMs: 0, overlapSavedMs: 0 },
88
+ ptc: { runs: 0, calls: 0, errors: 0, retries: 0, sumMs: 0 },
89
+ governance: { blockedSubresources: 0, blockedHosts: [], ptyRefused: 0, clampedTimeouts: 0, clampSavedMs: 0, offloadDegraded: 0, webCacheHits: 0, evalMasks: 0 },
90
+ degrades: [],
91
+ };
92
+ const byTool = new Map();
93
+ const hosts = new Set();
94
+ const runs = new Set();
95
+ let first = 0;
96
+ let last = 0;
97
+ // dispatch overlap window: from the first start to the last settle
98
+ let dFirstAt = 0;
99
+ let dLastAt = 0;
100
+ /** child session id -> its first observed start, to derive a duration the
101
+ * event itself may not carry. */
102
+ const startAt = new Map();
103
+ const row = (tool) => {
104
+ let r = byTool.get(tool);
105
+ if (!r) {
106
+ r = { tool, calls: 0, results: 0, offloaded: 0, tokens: 0, savedTokens: 0 };
107
+ byTool.set(tool, r);
108
+ }
109
+ return r;
110
+ };
111
+ for (const e of events) {
112
+ const tool = String(e.tool ?? "?");
113
+ const ev = String(e.event ?? "");
114
+ if (e.run_id)
115
+ runs.add(String(e.run_id));
116
+ const at = tsMs(e);
117
+ if (at) {
118
+ if (!first || at < first)
119
+ first = at;
120
+ if (at > last)
121
+ last = at;
122
+ }
123
+ if (ev === "call")
124
+ row(tool).calls++;
125
+ if (ev === "result") {
126
+ const r = row(tool);
127
+ r.results++;
128
+ const tokens = num(e.tokens);
129
+ r.tokens += tokens;
130
+ if (e.offloaded === true) {
131
+ r.offloaded++;
132
+ // what actually entered the window is the preview, not the payload
133
+ r.savedTokens += Math.max(0, tokens - (num(e.preview_tokens) || PREVIEW_FALLBACK_TOKENS));
134
+ }
135
+ }
136
+ if (tool === "tm_dispatch" && ev === "start") {
137
+ stats.dispatch.starts++;
138
+ const cid = String(e.child ?? "");
139
+ if (at && cid && !startAt.has(cid))
140
+ startAt.set(cid, at);
141
+ if (at) {
142
+ if (!dFirstAt || at < dFirstAt)
143
+ dFirstAt = at;
144
+ dLastAt = Math.max(dLastAt, at);
145
+ }
146
+ }
147
+ if (tool === "tm_dispatch" && (ev === "idle" || ev === "error")) {
148
+ if (ev === "idle")
149
+ stats.dispatch.settled++;
150
+ else
151
+ stats.dispatch.failed++;
152
+ // The child's OWN duration: the live path writes `ms`, but an event that
153
+ // only says "this child stopped" still pins it from the timestamps — and
154
+ // a failed child that worked for 12 s must not count as free.
155
+ const started = startAt.get(String(e.child ?? ""));
156
+ const dur = num(e.ms) || (at && started && at > started ? at - started : 0);
157
+ stats.dispatch.sumMs += dur;
158
+ stats.dispatch.maxMs = Math.max(stats.dispatch.maxMs, dur);
159
+ if (at)
160
+ dLastAt = Math.max(dLastAt, at);
161
+ }
162
+ if (tool === "tm_dispatch" && ev === "adopt")
163
+ stats.dispatch.adopted++;
164
+ if (tool === "tm_dispatch" && ev === "cancel")
165
+ stats.dispatch.cancelled++;
166
+ if (tool === "tm_ptc_run" && ev === "finish") {
167
+ stats.ptc.runs++;
168
+ stats.ptc.calls += num(e.calls);
169
+ stats.ptc.errors += num(e.errors);
170
+ stats.ptc.retries += num(e.retries);
171
+ stats.ptc.sumMs += num(e.ms);
172
+ }
173
+ if (ev === "blocked") {
174
+ stats.governance.blockedSubresources += num(e.count);
175
+ for (const h of String(e.hosts ?? "").split(","))
176
+ if (h.trim())
177
+ hosts.add(h.trim());
178
+ }
179
+ if (tool === "tm_pty" && ev === "refused")
180
+ stats.governance.ptyRefused++;
181
+ if (ev === "cache_hit")
182
+ stats.governance.webCacheHits++;
183
+ if (ev === "eval_redacted")
184
+ stats.governance.evalMasks++;
185
+ if (tool === "bash" && e.step_id === "timeout-clamp") {
186
+ stats.governance.clampedTimeouts++;
187
+ stats.governance.clampSavedMs += Math.max(0, num(e.from_ms) - num(e.to_ms));
188
+ }
189
+ if (ev === "engine" && tool === "tm_browser" && String(e.kind ?? "") === "cdp-legacy") {
190
+ stats.degrades.push({ seam: "tm_browser/playwright-core", reason: String(e.reason ?? "").slice(0, 160) });
191
+ }
192
+ if (e.degraded === true)
193
+ stats.governance.offloadDegraded++;
194
+ }
195
+ const dispatchWindow = dFirstAt && dLastAt > dFirstAt ? dLastAt - dFirstAt : 0;
196
+ stats.dispatch.overlapSavedMs =
197
+ stats.dispatch.settled + stats.dispatch.failed > 1
198
+ ? Math.max(0, stats.dispatch.sumMs - dispatchWindow)
199
+ : 0;
200
+ stats.window.runs = runs.size;
201
+ stats.window.from = first || undefined;
202
+ stats.window.to = last || undefined;
203
+ stats.window.wallMs = last > first ? last - first : 0;
204
+ stats.governance.blockedHosts = [...hosts].slice(0, 12);
205
+ stats.tools = [...byTool.values()].sort((a, b) => b.savedTokens - a.savedTokens || b.calls - a.calls || a.tool.localeCompare(b.tool));
206
+ return stats;
207
+ }
208
+ function secs(ms) {
209
+ return `${(ms / 1000).toFixed(ms >= 10_000 ? 0 : 1)}s`;
210
+ }
211
+ /** Markdown, in the shapes the host renders fastest (tables, not prose). */
212
+ export function renderStats(stats, opts) {
213
+ const now = opts.now ?? Date.now();
214
+ const head = [];
215
+ head.push(`**口径**:统计自本插件保留的 trajectory(每次插件进程一个 run 目录,TTL 到期即清),` +
216
+ `token 为 CJK 感知估算值,时间来自事件时间戳——是量级,不是账单。`);
217
+ head.push(`窗口:${stats.window.runs} 个 run(本次读取 ${opts.runDirs} 个)· ${stats.window.events} 条事件 · ` +
218
+ `墙钟 ${stats.window.wallMs ? secs(stats.window.wallMs) : "—"}(末次事件距今 ${stats.window.to ? secs(Math.max(0, now - stats.window.to)) : "—"})`);
219
+ const out = [head.join("\n")];
220
+ out.push("", "### 令牌经济(卸载 = 没进上下文的部分)", "", "| 工具 | 调用 | 结果 | 卸载 | 原始 token | 省下 token(估算) |", "|---|---:|---:|---:|---:|---:|");
221
+ let savedTotal = 0;
222
+ for (const t of stats.tools) {
223
+ savedTotal += t.savedTokens;
224
+ out.push(`| \`${t.tool}\` | ${t.calls} | ${t.results} | ${t.offloaded} | ${t.tokens.toLocaleString("en-US")} | ${t.savedTokens ? t.savedTokens.toLocaleString("en-US") : "—"} |`);
225
+ }
226
+ out.push(`| **合计** | | | | | **${savedTotal.toLocaleString("en-US")}** |`);
227
+ const d = stats.dispatch;
228
+ out.push("", "### 并行度(Team 的存在理由)", "", "| 指标 | 值 |", "|---|---|", `| 派发 / 完成 / 失败 / 取消 | ${d.starts} / ${d.settled} / ${d.failed} / ${d.cancelled} |`, `| 单个子代理耗时(最长 / 合计=串行代价) | ${d.maxMs ? secs(d.maxMs) : "—"} / ${d.sumMs ? secs(d.sumMs) : "—"} |`, `| **重叠省下**(串行 − 实际墙钟) | ${d.overlapSavedMs ? `**${secs(d.overlapSavedMs)}**` : "—(不足两个已结算的派发,或它们本就串行)"} |`, `| 重启后由宿主会话树接管 | ${d.adopted} |`);
229
+ const p = stats.ptc;
230
+ const g = stats.governance;
231
+ out.push("", "### 一次程序 N 次调用(tm_ptc_run)与治理面", "", "| 指标 | 值 |", "|---|---|", `| PTC 程序 / 内部调用 / 重试 / 错误 | ${p.runs} / ${p.calls} / ${p.retries} / ${p.errors}(合计 ${p.sumMs ? secs(p.sumMs) : "—"}) |`, `| 被拦子资源请求(浏览器) | ${g.blockedSubresources}${g.blockedHosts.length ? ` · 域名:${g.blockedHosts.join(", ")}` : ""} |`, `| tm_pty 治理面拒绝 | ${g.ptyRefused} |`, `| web URL 缓存命中(省下的抓取) | ${g.webCacheHits} |`, `| evaluate_script 结果脱敏次数 | ${g.evalMasks} |`, `| bash 超时夹顶 | ${g.clampedTimeouts} 次 · 省 ${g.clampSavedMs ? secs(g.clampSavedMs) : "—"} |`, `| 卸载降级(存储写失败→截断) | ${g.offloadDegraded} |`);
232
+ if (stats.degrades.length) {
233
+ out.push("", "### 引擎降级", "", "| 接口 | 原因 |", "|---|---|");
234
+ for (const x of stats.degrades)
235
+ out.push(`| ${x.seam} | ${x.reason || "—"} |`);
236
+ }
237
+ if (opts.matrix?.length) {
238
+ out.push("", "### 宿主能力矩阵(升级后先看这张表)", "", renderCapabilityMatrix(opts.matrix));
239
+ }
240
+ if (opts.roots.length) {
241
+ out.push("", `数据目录:${opts.roots.map((r) => `\`${r}\``).join(" · ")}`);
242
+ }
243
+ return out.join("\n");
244
+ }
245
+ export function buildStatsTool(deps) {
246
+ const tool = "tm_stats";
247
+ const readDefault = (runs) => {
248
+ const all = [];
249
+ for (const r of runs) {
250
+ try {
251
+ all.push(...parseTrajectoryJsonl(fs.readFileSync(r.file, "utf8")));
252
+ }
253
+ catch {
254
+ /* one unreadable run must not blank the whole report */
255
+ }
256
+ }
257
+ return all;
258
+ };
259
+ return {
260
+ description: `Read the plugin's OWN trajectory back as numbers: what it saved and where it broke.
261
+ - The throughput argument in one call — tokens kept out of the context window by offloading, and seconds saved by dispatch overlap (serial cost minus the wall-clock the children actually used), plus governance counts (blocked subresources, refused tm_pty starts, clamped bash timeouts, engine fallbacks).
262
+ - It also renders the HOST CAPABILITY MATRIX: every OpenCode surface this plugin leans on, marked 已验证 / 存在未用 / 待观察 / 缺失. After an OpenCode upgrade, call this FIRST — a missing row names the feature that silently went away.
263
+ - { runs: 10 } recent run dirs (default 10, max 50); { capabilities: false } to skip the matrix. Read-only over files this plugin wrote: no network, no shell, no secrets (the trajectory never records command text or values).`,
264
+ args: {
265
+ runs: { descriptor: "runs: number (optional, how many recent run dirs to read; default 10, max 50)" },
266
+ capabilities: { descriptor: "capabilities: false to omit the host-capability matrix" },
267
+ },
268
+ execute: async (rawArgs) => {
269
+ try {
270
+ const args = (rawArgs ?? {});
271
+ const limit = Math.max(1, Math.min(50, Math.round(num(args.runs)) || 10));
272
+ const runs = listTrajectoryRuns(deps.store.trajectoryRoot, limit);
273
+ if (!runs.length) {
274
+ return toToolResult(tmError(tool, "execute", `trajectory 目录为空(${deps.store.trajectoryRoot})——本插件还没跑过任何受治理工具,没有可统计的东西。`));
275
+ }
276
+ const events = (deps.readEvents ?? readDefault)(runs);
277
+ const stats = summarizeEvents(events);
278
+ const wantMatrix = !(args.capabilities === false || args.capabilities === "false");
279
+ const body = renderStats(stats, {
280
+ runDirs: runs.length,
281
+ roots: [deps.store.trajectoryRoot],
282
+ matrix: wantMatrix ? (deps.capabilities?.() ?? []) : [],
283
+ });
284
+ // Deliberately NOT offloaded: the point of this tool is the table the
285
+ // user (or the lead) reads whole; it is bounded by construction (one
286
+ // row per tool, per degraded seam, per capability).
287
+ return toToolResult(body);
288
+ }
289
+ catch (err) {
290
+ const e = err;
291
+ return toToolResult(tmError(tool, "execute", `tm_stats 失败:${String(e?.message ?? err).slice(0, 160)}`));
292
+ }
293
+ },
294
+ };
295
+ }
296
+ //# sourceMappingURL=stats.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stats.js","sourceRoot":"","sources":["../../src/tm/stats.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAEjC,OAAO,EAAE,sBAAsB,EAAsB,MAAM,oBAAoB,CAAA;AAC/E,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAanD,oFAAoF;AACpF,MAAM,UAAU,oBAAoB,CAAC,IAAY;IAC/C,MAAM,GAAG,GAAgB,EAAE,CAAA;IAC3B,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QACvC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YAAE,SAAQ;QAC1B,IAAI,CAAC;YACH,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAc,CAAA;YACvC,IAAI,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ;gBAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QAC7C,CAAC;QAAC,MAAM,CAAC;YACP,UAAU;QACZ,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AASD,iEAAiE;AACjE,MAAM,UAAU,kBAAkB,CAAC,cAAsB,EAAE,KAAK,GAAG,EAAE;IACnE,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CA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sE;gBACtE,qEAAqE;gBACrE,oDAAoD;gBACpD,OAAO,YAAY,CAAC,IAAI,CAAC,CAAA;YAC3B,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,MAAM,CAAC,GAAG,GAA4B,CAAA;gBACtC,OAAO,YAAY,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,EAAE,eAAe,MAAM,CAAC,CAAC,EAAE,OAAO,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAA;YACzG,CAAC;QACH,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -34,6 +34,7 @@ import { type TmConfig } from "./config.js";
34
34
  export declare const T4_SEEDED_DOMAINS: readonly string[];
35
35
  export declare function seedWebfetchDomains(allowlist: readonly string[]): string[];
36
36
  import { type TmPipelines } from "./pipelines.js";
37
+ import type { WebCache } from "./cache.js";
37
38
  /** True when `hostname` is the domain itself or a subdomain of it. */
38
39
  export declare function hostAllowed(hostname: string, allowlist: readonly string[]): boolean;
39
40
  export type UrlVerdict = {
@@ -60,6 +61,14 @@ export declare function htmlToText(html: string): string;
60
61
  /** Search-engine result pages whose raw HTML is worth collapsing into a
61
62
  * clean hit list (title + URL) instead of a wall of stripped page text. */
62
63
  export declare const SEARCH_PAGE_RE: RegExp;
64
+ /** BING WRAPS EVERY RESULT of its international layout (`…&ensearch=1`) in
65
+ * `https://www.bing.com/ck/a?...&u=a1<base64(destination)>`. Dropping those
66
+ * anchors (what ENGINE_TRACKER_RE does) is why the 2026-09-14 benchmark
67
+ * recorded "bing-int serves an anti-bot shell / 100% empty" — the shell was
68
+ * fine, our extractor threw every hit away (re-probed 2026-09-19: 10 real
69
+ * `b_algo` results, 0 extracted). Decode the wrapper so the hit survives;
70
+ * anything unrecognised still falls through to the skip. */
71
+ export declare function decodeEngineWrapperUrl(href: string): string | null;
63
72
  /** Domains that collide with common search terms (e.g. maimai.cn is the
64
73
  * Chinese professional-networking site 脉脉, NOT the SEGA maimai DX rhythm
65
74
  * game — a real session showed bing returning 10/10 maimai.cn hits for
@@ -77,6 +86,10 @@ export interface SearchHit {
77
86
  source?: string;
78
87
  /** 1-based fused rank (auto-fusion only). */
79
88
  rank?: number;
89
+ /** False when the host is outside the fetch allowlist (auto-fusion only) —
90
+ * following it will open an approval dialog, so the agent should prefer a
91
+ * hit it can actually read. Undefined = not evaluated. */
92
+ fetchable?: boolean;
80
93
  }
81
94
  /**
82
95
  * Pull external result hits (title + URL [+ engine snippet when present])
@@ -95,6 +108,9 @@ export interface WebFetchResult {
95
108
  text: string;
96
109
  contentType: string;
97
110
  finalUrl: string;
111
+ /** Set when the body came from the URL cache instead of the network — the
112
+ * reply says so, because a re-served page is not a freshly-verified one. */
113
+ cachedAt?: number;
98
114
  }
99
115
  export type FetchImpl = (input: string, init?: Record<string, unknown>) => Promise<{
100
116
  ok?: boolean;
@@ -124,6 +140,10 @@ export declare function fetchWebText(url: URL, allowlist: readonly string[], opt
124
140
  /** Hosts already approved by the caller (e.g. the initial target) —
125
141
  * their hops pass without a second dialog. */
126
142
  skipAskHosts?: Set<string>;
143
+ /** URL-level TTL cache (see tm/cache.ts). Consulted and written ONLY for
144
+ * a hop the static allowlist admitted, so a hit can never bypass a
145
+ * dialog the current config still requires. */
146
+ cache?: WebCache;
127
147
  }): Promise<WebFetchResult>;
128
148
  /** Content extraction: HTML stripped to text; JSON kept for the json
129
149
  * preview branch; anything else passes through untouched. */
@@ -139,6 +159,9 @@ export declare function buildTmWebfetchTool(deps: {
139
159
  cfg: TmConfig;
140
160
  args?: Record<string, unknown>;
141
161
  fetchImpl?: FetchImpl;
162
+ /** Shared URL cache (tm/index.ts owns the one instance so tm_search and
163
+ * tm_webfetch cannot drift into two stores of the same page). */
164
+ cache?: WebCache;
142
165
  }): {
143
166
  description: string;
144
167
  args: Record<string, unknown>;
@@ -1 +1 @@
1
- {"version":3,"file":"webfetch.d.ts","sourceRoot":"","sources":["../../src/tm/webfetch.ts"],"names":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