@te-river/opencode-team-mode 1.7.1 → 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.
- package/README.md +1009 -849
- package/README.zh-CN.md +906 -756
- package/dist/host/v2-browser-gate.d.ts +4 -1
- package/dist/host/v2-browser-gate.d.ts.map +1 -1
- package/dist/host/v2-browser-gate.js +1 -1
- package/dist/host/v2-browser-gate.js.map +1 -1
- package/dist/host/v2-capabilities.js +1 -1
- package/dist/host/v2-capabilities.js.map +1 -1
- package/dist/host/v2-guard.d.ts +3 -1
- package/dist/host/v2-guard.d.ts.map +1 -1
- package/dist/host/v2-guard.js +2 -2
- package/dist/host/v2-guard.js.map +1 -1
- package/dist/host/v2-offload.d.ts +12 -2
- package/dist/host/v2-offload.d.ts.map +1 -1
- package/dist/host/v2-offload.js +9 -9
- package/dist/host/v2-offload.js.map +1 -1
- package/dist/host/v2-probe-chain.d.ts +5 -1
- package/dist/host/v2-probe-chain.d.ts.map +1 -1
- package/dist/host/v2-probe-chain.js +4 -6
- package/dist/host/v2-probe-chain.js.map +1 -1
- package/dist/host/v2-probe.d.ts.map +1 -1
- package/dist/host/v2-probe.js +2 -1
- package/dist/host/v2-probe.js.map +1 -1
- package/dist/host/v2-prune.d.ts +5 -1
- package/dist/host/v2-prune.d.ts.map +1 -1
- package/dist/host/v2-prune.js +8 -14
- package/dist/host/v2-prune.js.map +1 -1
- package/dist/host/v2-retry.d.ts +9 -2
- package/dist/host/v2-retry.d.ts.map +1 -1
- package/dist/host/v2-retry.js +13 -15
- package/dist/host/v2-retry.js.map +1 -1
- package/dist/host/v2-session.d.ts +6 -2
- package/dist/host/v2-session.d.ts.map +1 -1
- package/dist/host/v2-session.js +7 -13
- package/dist/host/v2-session.js.map +1 -1
- package/dist/host/v2.d.ts +7 -2
- package/dist/host/v2.d.ts.map +1 -1
- package/dist/host/v2.js +38 -35
- package/dist/host/v2.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 +23 -7
- package/dist/prompts/lead.js.map +1 -1
- package/dist/prompts/specialists.d.ts +1 -1
- package/dist/prompts/specialists.d.ts.map +1 -1
- package/dist/prompts/specialists.js +1 -1
- package/dist/tm/args-schema.d.ts +1 -1
- package/dist/tm/args-schema.js +6 -6
- package/dist/tm/args-schema.js.map +1 -1
- package/dist/tm/board.js +2 -2
- package/dist/tm/board.js.map +1 -1
- package/dist/tm/config-files.d.ts +41 -17
- package/dist/tm/config-files.d.ts.map +1 -1
- package/dist/tm/config-files.js +68 -73
- package/dist/tm/config-files.js.map +1 -1
- package/dist/tm/config-layers.d.ts +65 -33
- package/dist/tm/config-layers.d.ts.map +1 -1
- package/dist/tm/config-layers.js +165 -81
- package/dist/tm/config-layers.js.map +1 -1
- package/dist/tm/config-template.d.ts +32 -0
- package/dist/tm/config-template.d.ts.map +1 -0
- package/dist/tm/config-template.js +74 -0
- package/dist/tm/config-template.js.map +1 -0
- package/dist/tm/config.d.ts +115 -140
- package/dist/tm/config.d.ts.map +1 -1
- package/dist/tm/config.js +100 -200
- package/dist/tm/config.js.map +1 -1
- package/dist/tm/index.d.ts +11 -3
- package/dist/tm/index.d.ts.map +1 -1
- package/dist/tm/index.js +46 -16
- package/dist/tm/index.js.map +1 -1
- package/dist/tm/ledger.d.ts +7 -3
- package/dist/tm/ledger.d.ts.map +1 -1
- package/dist/tm/ledger.js +5 -4
- package/dist/tm/ledger.js.map +1 -1
- package/dist/tm/memory.js +3 -3
- package/dist/tm/pipelines.js +1 -1
- package/dist/tm/search.js +6 -6
- package/dist/tm/search.js.map +1 -1
- package/dist/tm/stats.js +2 -2
- package/dist/tm/stats.js.map +1 -1
- package/dist/tm/tools.js +2 -2
- package/dist/tm/webfetch.d.ts +5 -2
- package/dist/tm/webfetch.d.ts.map +1 -1
- package/dist/tm/webfetch.js +24 -18
- package/dist/tm/webfetch.js.map +1 -1
- package/docs/installation-v2.md +61 -38
- package/docs/installation.md +4 -4
- package/docs/v2-port-notes.md +31 -0
- package/package.json +1 -1
- package/scripts/gen-v2-config.mjs +40 -4
- package/dist/approval-gate.d.ts +0 -205
- package/dist/approval-gate.d.ts.map +0 -1
- package/dist/approval-gate.js +0 -627
- package/dist/approval-gate.js.map +0 -1
- package/dist/host/v1.d.ts +0 -14
- package/dist/host/v1.d.ts.map +0 -1
- package/dist/host/v1.js +0 -340
- package/dist/host/v1.js.map +0 -1
- package/dist/host/v2-client.d.ts +0 -53
- package/dist/host/v2-client.d.ts.map +0 -1
- package/dist/host/v2-client.js +0 -193
- package/dist/host/v2-client.js.map +0 -1
- package/dist/host/v2-transcript.d.ts +0 -73
- package/dist/host/v2-transcript.d.ts.map +0 -1
- package/dist/host/v2-transcript.js +0 -151
- package/dist/host/v2-transcript.js.map +0 -1
- package/dist/host-hooks.d.ts +0 -126
- package/dist/host-hooks.d.ts.map +0 -1
- package/dist/host-hooks.js +0 -284
- package/dist/host-hooks.js.map +0 -1
- package/dist/tm/bash-timeout.d.ts +0 -72
- package/dist/tm/bash-timeout.d.ts.map +0 -1
- package/dist/tm/bash-timeout.js +0 -100
- package/dist/tm/bash-timeout.js.map +0 -1
- package/dist/tm/browser.d.ts +0 -642
- package/dist/tm/browser.d.ts.map +0 -1
- package/dist/tm/browser.js +0 -2836
- package/dist/tm/browser.js.map +0 -1
- package/dist/tm/ptc/budgets.d.ts +0 -59
- package/dist/tm/ptc/budgets.d.ts.map +0 -1
- package/dist/tm/ptc/budgets.js +0 -138
- package/dist/tm/ptc/budgets.js.map +0 -1
- package/dist/tm/ptc/contract.d.ts +0 -171
- package/dist/tm/ptc/contract.d.ts.map +0 -1
- package/dist/tm/ptc/contract.js +0 -85
- package/dist/tm/ptc/contract.js.map +0 -1
- package/dist/tm/ptc/driver.d.ts +0 -40
- package/dist/tm/ptc/driver.d.ts.map +0 -1
- package/dist/tm/ptc/driver.js +0 -213
- package/dist/tm/ptc/driver.js.map +0 -1
- package/dist/tm/ptc/engines.d.ts +0 -43
- package/dist/tm/ptc/engines.d.ts.map +0 -1
- package/dist/tm/ptc/engines.js +0 -454
- package/dist/tm/ptc/engines.js.map +0 -1
- package/dist/tm/ptc/gate.d.ts +0 -28
- package/dist/tm/ptc/gate.d.ts.map +0 -1
- package/dist/tm/ptc/gate.js +0 -130
- package/dist/tm/ptc/gate.js.map +0 -1
- package/dist/tm/ptc/index.d.ts +0 -19
- package/dist/tm/ptc/index.d.ts.map +0 -1
- package/dist/tm/ptc/index.js +0 -15
- package/dist/tm/ptc/index.js.map +0 -1
- package/dist/tm/ptc/pscan.d.ts +0 -30
- package/dist/tm/ptc/pscan.d.ts.map +0 -1
- package/dist/tm/ptc/pscan.js +0 -341
- package/dist/tm/ptc/pscan.js.map +0 -1
- package/dist/tm/ptc/summary.d.ts +0 -17
- package/dist/tm/ptc/summary.d.ts.map +0 -1
- package/dist/tm/ptc/summary.js +0 -134
- package/dist/tm/ptc/summary.js.map +0 -1
- package/dist/tm/ptc/tool.d.ts +0 -66
- package/dist/tm/ptc/tool.d.ts.map +0 -1
- package/dist/tm/ptc/tool.js +0 -231
- package/dist/tm/ptc/tool.js.map +0 -1
- package/dist/tm/ptc.d.ts +0 -298
- package/dist/tm/ptc.d.ts.map +0 -1
- package/dist/tm/ptc.js +0 -865
- package/dist/tm/ptc.js.map +0 -1
- package/dist/tm/pty.d.ts +0 -70
- package/dist/tm/pty.d.ts.map +0 -1
- package/dist/tm/pty.js +0 -245
- package/dist/tm/pty.js.map +0 -1
- package/dist/tool-coerce.d.ts +0 -24
- package/dist/tool-coerce.d.ts.map +0 -1
- package/dist/tool-coerce.js +0 -63
- package/dist/tool-coerce.js.map +0 -1
package/dist/tm/ptc/contract.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* tm_ptc_run — public contract types + the frozen engine seam.
|
|
3
|
-
*
|
|
4
|
-
* Design: .git/opencode-team/.../ptc-run/02-architect-ptc-run-design.md §2/§3.
|
|
5
|
-
* Everything in this module is CONTRACT — frozen since M1 so M2's engines and
|
|
6
|
-
* M3's registration could land without touching the driver or the tool.
|
|
7
|
-
* (Split out of the former monolithic ptc.ts; behavior unchanged.)
|
|
8
|
-
*
|
|
9
|
-
* Governance is REUSED, never forked (D6 lock): the bridge calls the exact
|
|
10
|
-
* four exported pipelines, so threshold offload, P2/P3, R6 and handle/TTL
|
|
11
|
-
* semantics apply to every bridged call verbatim. PTC is NOT a bypass layer.
|
|
12
|
-
*/
|
|
13
|
-
import { shorten } from "../config.js";
|
|
14
|
-
// ---------- statuses + bridge surface (design §2) ---------------------------
|
|
15
|
-
/** The six PTC run statuses (design §2; "program-error" added in the fix
|
|
16
|
-
* batch to separate PROGRAM faults — the body threw, engine healthy, no
|
|
17
|
-
* auto-degrade — from ENGINE faults). */
|
|
18
|
-
export const PTC_STATUS_VALUES = [
|
|
19
|
-
"ok",
|
|
20
|
-
"stopped-error-budget",
|
|
21
|
-
"stopped-call-budget",
|
|
22
|
-
"timeout",
|
|
23
|
-
"engine-error",
|
|
24
|
-
"program-error",
|
|
25
|
-
];
|
|
26
|
-
/**
|
|
27
|
-
* Bridge allow set — read-only; tm_ptc_run itself is excluded (no nesting).
|
|
28
|
-
* T6 added the two WEB bridges (tm_search / tm_webfetch): they are gated a
|
|
29
|
-
* second time at the bridge layer (TM_PTC_WEB_BRIDGE=off → the bridge returns
|
|
30
|
-
* an args error) and a THIRD time by the host ruleset — a bridged call runs
|
|
31
|
-
* the real tm_search/tm_webfetch execute with the CALLER's per-execute ctx, so
|
|
32
|
-
* ctx.ask evaluates against that agent's grant and a non-web role is denied
|
|
33
|
-
* with a permission error (zero new mechanism).
|
|
34
|
-
*/
|
|
35
|
-
export const BRIDGE_ALLOW = [
|
|
36
|
-
"tm_read",
|
|
37
|
-
"tm_grep",
|
|
38
|
-
"tm_bash",
|
|
39
|
-
"tm_fetch",
|
|
40
|
-
"tm_search",
|
|
41
|
-
"tm_webfetch",
|
|
42
|
-
];
|
|
43
|
-
/** The web bridge tools — the subset gated behind TM_PTC_WEB_BRIDGE + role. */
|
|
44
|
-
export const WEB_BRIDGE_TOOLS = ["tm_search", "tm_webfetch"];
|
|
45
|
-
/** Phases safe to retry once (idempotent read-only bridges; design §4.2). */
|
|
46
|
-
// T6: tm_search / tm_webfetch issue GETs — idempotent — so their transient
|
|
47
|
-
// failures (client/execute/store phases) inherit the SAME one-retry policy;
|
|
48
|
-
// a permission/args error is never retried (the role denial must stand).
|
|
49
|
-
export const RETRYABLE_PHASES = ["client", "execute", "store"];
|
|
50
|
-
/**
|
|
51
|
-
* The stop signal unwinding a program on a budget/time hit. Thrown by the
|
|
52
|
-
* StepGate (call/error budget, pre-call deadline) and rejected through the
|
|
53
|
-
* engines' abort promises (wall-clock timeout); caught by the driver, which
|
|
54
|
-
* maps it to a status. Never escapes as an engine-error.
|
|
55
|
-
*/
|
|
56
|
-
export class PtcStopSignal extends Error {
|
|
57
|
-
reason;
|
|
58
|
-
constructor(reason) {
|
|
59
|
-
super(`ptc-stop:${reason}`);
|
|
60
|
-
this.reason = reason;
|
|
61
|
-
this.name = "PtcStopSignal";
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* A PROGRAM fault — the program body itself threw (the worker bootstrap
|
|
66
|
-
* posts kind:"program"; the inline-vm engine tags promise rejections).
|
|
67
|
-
* Distinct from an engine fault: the engine is healthy, so the driver maps
|
|
68
|
-
* it to status "program-error" and NEVER auto-degrades (re-running the same
|
|
69
|
-
* program would just throw again).
|
|
70
|
-
*/
|
|
71
|
-
export class PtcProgramError extends Error {
|
|
72
|
-
constructor(message, stack) {
|
|
73
|
-
super(message);
|
|
74
|
-
this.name = "PtcProgramError";
|
|
75
|
-
if (typeof stack === "string" && stack)
|
|
76
|
-
this.stack = stack;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
/** Short display code for a ref: the `steps/<id>` step segment. Shared by
|
|
80
|
-
* the gate (success table) and the summary renderer (error refs). */
|
|
81
|
-
export function shortRefCode(ref) {
|
|
82
|
-
const m = /\/steps\/([^/]+)\/result/.exec(ref);
|
|
83
|
-
return m ? m[1] : shorten(ref, 24);
|
|
84
|
-
}
|
|
85
|
-
//# sourceMappingURL=contract.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../../src/tm/ptc/contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAGtC,+EAA+E;AAE/E;;0CAE0C;AAC1C,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI;IACJ,sBAAsB;IACtB,qBAAqB;IACrB,SAAS;IACT,cAAc;IACd,eAAe;CACP,CAAA;AAWV;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,YAAY,GAA0B;IACjD,SAAS;IACT,SAAS;IACT,SAAS;IACT,UAAU;IACV,WAAW;IACX,aAAa;CACd,CAAA;AAED,+EAA+E;AAC/E,MAAM,CAAC,MAAM,gBAAgB,GAA0B,CAAC,WAAW,EAAE,aAAa,CAAC,CAAA;AAEnF,6EAA6E;AAC7E,2EAA2E;AAC3E,4EAA4E;AAC5E,yEAAyE;AACzE,MAAM,CAAC,MAAM,gBAAgB,GAAuB,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;AA0FlF;;;;;GAKG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IACjB;IAArB,YAAqB,MAAkD;QACrE,KAAK,CAAC,YAAY,MAAM,EAAE,CAAC,CAAA;QADR,WAAM,GAAN,MAAM,CAA4C;QAErE,IAAI,CAAC,IAAI,GAAG,eAAe,CAAA;IAC7B,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxC,YAAY,OAAe,EAAE,KAAc;QACzC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAA;QAC7B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK;YAAE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IAC5D,CAAC;CACF;AAED;sEACsE;AACtE,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,MAAM,CAAC,GAAG,0BAA0B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAC9C,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;AACpC,CAAC"}
|
package/dist/tm/ptc/driver.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* tm_ptc_run — the run driver: engine selection (auto / worker / inline),
|
|
3
|
-
* the static pre-scan handoff, wall-clock timeout, status mapping, and the
|
|
4
|
-
* trajectory parent events. Split out of the former monolithic ptc.ts;
|
|
5
|
-
* behavior unchanged.
|
|
6
|
-
*/
|
|
7
|
-
import type { TmConfig } from "../config.js";
|
|
8
|
-
import type { RunStore } from "../store.js";
|
|
9
|
-
import type { PtcBridge, PtcEngine, PtcRunOutcome } from "./contract.js";
|
|
10
|
-
import type { PtcBudgets } from "./budgets.js";
|
|
11
|
-
export interface EngineSelection {
|
|
12
|
-
engine: PtcEngine;
|
|
13
|
-
/** true when the auto chain degraded from worker to inline. */
|
|
14
|
-
degraded: boolean;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Select the PTC engine based on the TM_PTC_ENGINE mode.
|
|
18
|
-
* - "worker": WorkerEngine only (throws on failure → engine-error status).
|
|
19
|
-
* - "inline": InlineVmEngine only (script timeout for pre-await busy-loops).
|
|
20
|
-
* - "auto" (default): worker-first — the REAL auto-degrade happens in
|
|
21
|
-
* runPtc, which re-runs the whole program on InlineVmEngine ONLY when a
|
|
22
|
-
* worker run returns engine-error having made ZERO bridged calls (the
|
|
23
|
-
* worker could not start). A worker that started and then crashed is
|
|
24
|
-
* reported program-error / engine-error-with-calls and is NEVER replayed
|
|
25
|
-
* on the inline realm (C1: never re-run a started program).
|
|
26
|
-
*/
|
|
27
|
-
export declare function selectEngine(mode: "auto" | "worker" | "inline", bridge: PtcBridge): EngineSelection;
|
|
28
|
-
export interface RunPtcOptions {
|
|
29
|
-
program: string;
|
|
30
|
-
label: string;
|
|
31
|
-
budgets: PtcBudgets;
|
|
32
|
-
parentStepId: string;
|
|
33
|
-
cfg: TmConfig;
|
|
34
|
-
store?: RunStore;
|
|
35
|
-
bridge: PtcBridge;
|
|
36
|
-
engine?: PtcEngine;
|
|
37
|
-
now?: () => number;
|
|
38
|
-
}
|
|
39
|
-
export declare function runPtc(o: RunPtcOptions): Promise<PtcRunOutcome>;
|
|
40
|
-
//# sourceMappingURL=driver.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../../../src/tm/ptc/driver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAa,MAAM,eAAe,CAAA;AAMnF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAI9C,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,SAAS,CAAA;IACjB,+DAA+D;IAC/D,QAAQ,EAAE,OAAO,CAAA;CAClB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,EAAE,MAAM,EAAE,SAAS,GAAG,eAAe,CAQnG;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,UAAU,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,GAAG,EAAE,QAAQ,CAAA;IACb,KAAK,CAAC,EAAE,QAAQ,CAAA;IAChB,MAAM,EAAE,SAAS,CAAA;IACjB,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CACnB;AAED,wBAAsB,MAAM,CAAC,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAoKrE"}
|
package/dist/tm/ptc/driver.js
DELETED
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* tm_ptc_run — the run driver: engine selection (auto / worker / inline),
|
|
3
|
-
* the static pre-scan handoff, wall-clock timeout, status mapping, and the
|
|
4
|
-
* trajectory parent events. Split out of the former monolithic ptc.ts;
|
|
5
|
-
* behavior unchanged.
|
|
6
|
-
*/
|
|
7
|
-
import * as crypto from "node:crypto";
|
|
8
|
-
import { PtcProgramError, PtcStopSignal } from "./contract.js";
|
|
9
|
-
import { createGateBridge } from "./gate.js";
|
|
10
|
-
import { InlineVmEngine, WorkerEngine } from "./engines.js";
|
|
11
|
-
import { staticPscan } from "./pscan.js";
|
|
12
|
-
/**
|
|
13
|
-
* Select the PTC engine based on the TM_PTC_ENGINE mode.
|
|
14
|
-
* - "worker": WorkerEngine only (throws on failure → engine-error status).
|
|
15
|
-
* - "inline": InlineVmEngine only (script timeout for pre-await busy-loops).
|
|
16
|
-
* - "auto" (default): worker-first — the REAL auto-degrade happens in
|
|
17
|
-
* runPtc, which re-runs the whole program on InlineVmEngine ONLY when a
|
|
18
|
-
* worker run returns engine-error having made ZERO bridged calls (the
|
|
19
|
-
* worker could not start). A worker that started and then crashed is
|
|
20
|
-
* reported program-error / engine-error-with-calls and is NEVER replayed
|
|
21
|
-
* on the inline realm (C1: never re-run a started program).
|
|
22
|
-
*/
|
|
23
|
-
export function selectEngine(mode, bridge) {
|
|
24
|
-
void bridge;
|
|
25
|
-
if (mode === "inline") {
|
|
26
|
-
return { engine: new InlineVmEngine(), degraded: false };
|
|
27
|
-
}
|
|
28
|
-
// auto and worker both start on the worker engine (construction never
|
|
29
|
-
// throws — no spawn until run()).
|
|
30
|
-
return { engine: new WorkerEngine(), degraded: false };
|
|
31
|
-
}
|
|
32
|
-
export async function runPtc(o) {
|
|
33
|
-
const now = o.now ?? Date.now;
|
|
34
|
-
const start = now();
|
|
35
|
-
const deadlineAt = start + o.budgets.timeoutMs;
|
|
36
|
-
// engine selection — explicit override or auto/worker/inline from config.
|
|
37
|
-
let engine;
|
|
38
|
-
let degraded = false;
|
|
39
|
-
if (o.engine) {
|
|
40
|
-
engine = o.engine;
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
const sel = selectEngine(o.cfg.ptcEngine, o.bridge);
|
|
44
|
-
engine = sel.engine;
|
|
45
|
-
degraded = sel.degraded;
|
|
46
|
-
}
|
|
47
|
-
// static pre-scan — reject programs with banned tokens before any
|
|
48
|
-
// engine runs. Shape: engine-error with the pscan tokens listed.
|
|
49
|
-
// (Design §3: "辅助手段,声明不作安全边界".)
|
|
50
|
-
const pscan = staticPscan(o.program);
|
|
51
|
-
if (pscan.rejected) {
|
|
52
|
-
return {
|
|
53
|
-
label: o.label,
|
|
54
|
-
status: "engine-error",
|
|
55
|
-
steps: [],
|
|
56
|
-
okCount: 0,
|
|
57
|
-
errCount: 0,
|
|
58
|
-
retries: 0,
|
|
59
|
-
calls: 0,
|
|
60
|
-
ms: 0,
|
|
61
|
-
engine: engine.name,
|
|
62
|
-
degraded,
|
|
63
|
-
returnValue: undefined,
|
|
64
|
-
returned: false,
|
|
65
|
-
engineError: {
|
|
66
|
-
tool: "tm_ptc_run",
|
|
67
|
-
phase: "args",
|
|
68
|
-
message: `程序包含禁止标识符(${pscan.tokens.join(", ")}),已拒绝执行。`,
|
|
69
|
-
},
|
|
70
|
-
budgets: o.budgets,
|
|
71
|
-
parentStepId: o.parentStepId,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
// Auto-degrade: if the selected engine reports an ENGINE fault (not a
|
|
75
|
-
// budget stop, not a program fault), and we're in auto mode, retry with
|
|
76
|
-
// InlineVmEngine. A program fault is tagged PtcProgramError by the
|
|
77
|
-
// engines and mapped to "program-error" below — it never re-runs (the
|
|
78
|
-
// same program would just throw again).
|
|
79
|
-
const tryRun = async (eng, parentId = o.parentStepId) => {
|
|
80
|
-
const state = { calls: 0, errors: 0, retries: 0, steps: [] };
|
|
81
|
-
const gate = createGateBridge(o.bridge, parentId, o.budgets, state, {
|
|
82
|
-
now,
|
|
83
|
-
deadlineAt,
|
|
84
|
-
store: o.store,
|
|
85
|
-
});
|
|
86
|
-
// parent call event (design §6)
|
|
87
|
-
o.store?.appendTrajectory({
|
|
88
|
-
tool: "tm_ptc_run",
|
|
89
|
-
step_id: parentId,
|
|
90
|
-
event: "call",
|
|
91
|
-
label: o.label,
|
|
92
|
-
program_sha256: crypto.createHash("sha256").update(o.program).digest("hex"),
|
|
93
|
-
budgets: o.budgets,
|
|
94
|
-
});
|
|
95
|
-
const ac = new AbortController();
|
|
96
|
-
const remaining = Math.max(0, deadlineAt - now());
|
|
97
|
-
const timer = setTimeout(() => ac.abort(), remaining);
|
|
98
|
-
let status;
|
|
99
|
-
let returnValue;
|
|
100
|
-
let returned = false;
|
|
101
|
-
let engineError;
|
|
102
|
-
try {
|
|
103
|
-
returnValue = await eng.run(o.program, gate, ac.signal, {
|
|
104
|
-
startDeadlineMs: deadlineAt,
|
|
105
|
-
timeoutMs: o.budgets.timeoutMs,
|
|
106
|
-
});
|
|
107
|
-
returned = true;
|
|
108
|
-
status = state.stopReason ? mapStop(state.stopReason) : "ok";
|
|
109
|
-
}
|
|
110
|
-
catch (err) {
|
|
111
|
-
if (err instanceof PtcStopSignal) {
|
|
112
|
-
status = mapStop(err.reason);
|
|
113
|
-
}
|
|
114
|
-
else if (err instanceof PtcProgramError) {
|
|
115
|
-
// T5: the PROGRAM threw — distinct status, NO auto-degrade re-run.
|
|
116
|
-
status = "program-error";
|
|
117
|
-
const line = extractLine(err);
|
|
118
|
-
engineError = {
|
|
119
|
-
tool: "tm_ptc_run",
|
|
120
|
-
phase: "execute",
|
|
121
|
-
message: err.message,
|
|
122
|
-
...(line != null ? { line } : {}),
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
status = "engine-error";
|
|
127
|
-
const line = extractLine(err);
|
|
128
|
-
engineError = {
|
|
129
|
-
tool: "tm_ptc_run",
|
|
130
|
-
phase: "execute",
|
|
131
|
-
message: err instanceof Error ? err.message : String(err ?? "engine error"),
|
|
132
|
-
...(line != null ? { line } : {}),
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
finally {
|
|
137
|
-
clearTimeout(timer);
|
|
138
|
-
}
|
|
139
|
-
const ms = now() - start;
|
|
140
|
-
const outcome = {
|
|
141
|
-
label: o.label,
|
|
142
|
-
status,
|
|
143
|
-
steps: state.steps,
|
|
144
|
-
okCount: state.steps.filter((s) => s.ok).length,
|
|
145
|
-
errCount: state.steps.filter((s) => !s.ok).length,
|
|
146
|
-
retries: state.retries,
|
|
147
|
-
calls: state.calls,
|
|
148
|
-
ms,
|
|
149
|
-
engine: eng.name,
|
|
150
|
-
degraded,
|
|
151
|
-
returnValue,
|
|
152
|
-
returned,
|
|
153
|
-
...(engineError ? { engineError } : {}),
|
|
154
|
-
budgets: o.budgets,
|
|
155
|
-
parentStepId: parentId,
|
|
156
|
-
};
|
|
157
|
-
o.store?.appendTrajectory({
|
|
158
|
-
tool: "tm_ptc_run",
|
|
159
|
-
step_id: parentId,
|
|
160
|
-
event: "finish",
|
|
161
|
-
status: outcome.status,
|
|
162
|
-
calls: outcome.calls,
|
|
163
|
-
errors: outcome.errCount,
|
|
164
|
-
retries: outcome.retries,
|
|
165
|
-
ms: outcome.ms,
|
|
166
|
-
});
|
|
167
|
-
return outcome;
|
|
168
|
-
};
|
|
169
|
-
// Auto mode: try worker first. C1 (never replay a started program): degrade
|
|
170
|
-
// to the inline-vm engine ONLY when the worker could not START at all — an
|
|
171
|
-
// ENGINE fault with ZERO bridged calls dispatched (the program never ran).
|
|
172
|
-
// A worker that started and THEN crashed surfaces as `program-error` (the
|
|
173
|
-
// engines tag any post-online crash a program fault) or as an `engine-error`
|
|
174
|
-
// with calls > 0; in BOTH such cases we return as-is and do NOT re-run the
|
|
175
|
-
// program on the more-privileged inline/ESM realm — re-running a program
|
|
176
|
-
// that already executed is exactly the sandbox-escape amplification the
|
|
177
|
-
// reviewer's PoC turned on. An INJECTED engine participates too (tests
|
|
178
|
-
// inject crashers); the fallback is always the real InlineVmEngine.
|
|
179
|
-
if (o.cfg.ptcEngine === "auto" && engine.name === "worker") {
|
|
180
|
-
const result = await tryRun(engine);
|
|
181
|
-
if (result.status === "engine-error" && result.calls === 0) {
|
|
182
|
-
// Degrade to inline-vm and re-run.
|
|
183
|
-
const inlineEngine = new InlineVmEngine();
|
|
184
|
-
const fallback = await tryRun(inlineEngine, `${o.parentStepId}.r2`);
|
|
185
|
-
fallback.degraded = true;
|
|
186
|
-
fallback.engine = "inline";
|
|
187
|
-
fallback.parentStepId = o.parentStepId;
|
|
188
|
-
return fallback;
|
|
189
|
-
}
|
|
190
|
-
return result;
|
|
191
|
-
}
|
|
192
|
-
return tryRun(engine);
|
|
193
|
-
}
|
|
194
|
-
function mapStop(reason) {
|
|
195
|
-
if (reason === "timeout")
|
|
196
|
-
return "timeout";
|
|
197
|
-
if (reason === "error-budget")
|
|
198
|
-
return "stopped-error-budget";
|
|
199
|
-
return "stopped-call-budget";
|
|
200
|
-
}
|
|
201
|
-
/** Best-effort line extraction from a program-side thrown error stack. */
|
|
202
|
-
function extractLine(err) {
|
|
203
|
-
const s = err instanceof Error ? err.stack ?? "" : String(err ?? "");
|
|
204
|
-
const m = /:(\d+):/.exec(s);
|
|
205
|
-
if (m) {
|
|
206
|
-
const n = Number(m[1]);
|
|
207
|
-
if (Number.isFinite(n))
|
|
208
|
-
return n;
|
|
209
|
-
}
|
|
210
|
-
const m2 = /line[:#]?\s*(\d+)/i.exec(s);
|
|
211
|
-
return m2 ? Number(m2[1]) : undefined;
|
|
212
|
-
}
|
|
213
|
-
//# sourceMappingURL=driver.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"driver.js","sourceRoot":"","sources":["../../../src/tm/ptc/driver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAIrC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAE9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAWxC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY,CAAC,IAAkC,EAAE,MAAiB;IAChF,KAAK,MAAM,CAAA;IACX,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtB,OAAO,EAAE,MAAM,EAAE,IAAI,cAAc,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAA;IAC1D,CAAC;IACD,sEAAsE;IACtE,kCAAkC;IAClC,OAAO,EAAE,MAAM,EAAE,IAAI,YAAY,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAA;AACxD,CAAC;AAcD,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,CAAgB;IAC3C,MAAM,GAAG,GAAG,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAA;IAC7B,MAAM,KAAK,GAAG,GAAG,EAAE,CAAA;IACnB,MAAM,UAAU,GAAG,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,SAAS,CAAA;IAC9C,0EAA0E;IAC1E,IAAI,MAAiB,CAAA;IACrB,IAAI,QAAQ,G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;IAClC,CAAC;IACD,MAAM,EAAE,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACvC,OAAO,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;AACvC,CAAC"}
|
package/dist/tm/ptc/engines.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* tm_ptc_run — the three engines behind the frozen `PtcEngine` seam.
|
|
3
|
-
* Split out of the former monolithic ptc.ts; behavior unchanged.
|
|
4
|
-
*
|
|
5
|
-
* M1 legacy: InlineSequentialEngine (test-only — runs on the MAIN thread,
|
|
6
|
-
* no sandbox, no timeout; a post-await busy loop blocks the host event loop
|
|
7
|
-
* irrecoverably).
|
|
8
|
-
* M2 primary: WorkerEngine (worker_threads + MessagePort RPC, env:{},
|
|
9
|
-
* resourceLimits, hard `terminate()` wall-clock kill; bootstrap as a
|
|
10
|
-
* build-time string; the program body runs inside a node:vm sandbox —
|
|
11
|
-
* whitelist { tm, console, setTimeout, clearTimeout }, no node globals —
|
|
12
|
-
* with the run's timeoutMs as the in-engine script timeout).
|
|
13
|
-
* M2 fallback: InlineVmEngine (node:vm runInContext — the script timeout
|
|
14
|
-
* kills PRE-await synchronous busy-loops; a POST-await busy loop blocks the
|
|
15
|
-
* host event loop irrecoverably, documented — prefer worker/auto).
|
|
16
|
-
*
|
|
17
|
-
* C1 fix batch: BOTH vm engines now build their `tm` facade IN-CONTEXT via
|
|
18
|
-
* `vm.compileFunction` (parsingContext) and compile the context with
|
|
19
|
-
* `codeGeneration:{strings:false,wasm:false}`, so an injected facade's
|
|
20
|
-
* `.constructor` is the sandbox Function
|
|
21
|
-
* and `tm.read.constructor("return process")()` / `eval` / `new Function` THROW
|
|
22
|
-
* instead of escaping into the worker/plugin realm. A started worker that
|
|
23
|
-
* then crashes is reported as a program fault (never auto-replayed on the
|
|
24
|
-
* more-privileged inline realm) — see engines WorkerEngine error/exit handling.
|
|
25
|
-
*/
|
|
26
|
-
import type { PtcBridge, PtcEngine, PtcEngineName, PtcEngineRunOpts } from "./contract.js";
|
|
27
|
-
export declare class InlineSequentialEngine implements PtcEngine {
|
|
28
|
-
readonly name: PtcEngineName;
|
|
29
|
-
run(program: string, bridge: PtcBridge, signal: AbortSignal): Promise<unknown>;
|
|
30
|
-
}
|
|
31
|
-
export declare class WorkerEngine implements PtcEngine {
|
|
32
|
-
readonly name: PtcEngineName;
|
|
33
|
-
run(program: string, bridge: PtcBridge, signal: AbortSignal, opts?: PtcEngineRunOpts): Promise<unknown>;
|
|
34
|
-
}
|
|
35
|
-
export declare class InlineVmEngine implements PtcEngine {
|
|
36
|
-
readonly name: PtcEngineName;
|
|
37
|
-
/** Script execution timeout in ms (kills pre-await synchronous
|
|
38
|
-
* busy-loops). Injectable so tests can pin the kill fast. */
|
|
39
|
-
private readonly compileTimeoutMs;
|
|
40
|
-
constructor(compileTimeoutMs?: number);
|
|
41
|
-
run(program: string, bridge: PtcBridge, signal: AbortSignal): Promise<unknown>;
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=engines.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"engines.d.ts","sourceRoot":"","sources":["../../../src/tm/ptc/engines.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,gBAAgB,EAAiC,MAAM,eAAe,CAAA;AAuHzH,qBAAa,sBAAuB,YAAW,SAAS;IACtD,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAW;IACjC,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;CAyBrF;AAID,qBAAa,YAAa,YAAW,SAAS;IAC5C,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAW;IAEjC,GAAG,CACP,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,WAAW,EACnB,IAAI,CAAC,EAAE,gBAAgB,GACtB,OAAO,CAAC,OAAO,CAAC;CAkOpB;AAID,qBAAa,cAAe,YAAW,SAAS;IAC9C,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAW;IACvC;mEAC+D;IAC/D,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAQ;gBAC7B,gBAAgB,SAAS;IAI/B,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;CAoFrF"}
|