oh-my-copilot 5.6.2 → 5.8.0
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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +2 -0
- package/bridge/__pycache__/gyoshu_bridge.cpython-312.pyc +0 -0
- package/bridge/claude-md-coordinator.cjs +2 -2
- package/bridge/cli.cjs +81405 -76559
- package/bridge/mcp-server.cjs +40048 -32187
- package/bridge/runtime-cli.cjs +943 -199
- package/bridge/team-mcp.cjs +716 -125
- package/bridge/team.js +1066 -290
- package/dist/__tests__/cli-win32-warning.test.js +7 -0
- package/dist/__tests__/cli-win32-warning.test.js.map +1 -1
- package/dist/__tests__/run-cjs-copilot-worker-routing.test.d.ts +2 -0
- package/dist/__tests__/run-cjs-copilot-worker-routing.test.d.ts.map +1 -0
- package/dist/__tests__/run-cjs-copilot-worker-routing.test.js +294 -0
- package/dist/__tests__/run-cjs-copilot-worker-routing.test.js.map +1 -0
- package/dist/__tests__/run-cjs-fail-closed-timeout.test.d.ts +2 -0
- package/dist/__tests__/run-cjs-fail-closed-timeout.test.d.ts.map +1 -0
- package/dist/__tests__/run-cjs-fail-closed-timeout.test.js +68 -0
- package/dist/__tests__/run-cjs-fail-closed-timeout.test.js.map +1 -0
- package/dist/__tests__/run-cjs-session-end-budget.test.d.ts +2 -0
- package/dist/__tests__/run-cjs-session-end-budget.test.d.ts.map +1 -0
- package/dist/__tests__/run-cjs-session-end-budget.test.js +171 -0
- package/dist/__tests__/run-cjs-session-end-budget.test.js.map +1 -0
- package/dist/__tests__/session-end-process-exit.test.js +70 -2
- package/dist/__tests__/session-end-process-exit.test.js.map +1 -1
- package/dist/cli/__tests__/doctor-conflicts-json.test.d.ts +2 -0
- package/dist/cli/__tests__/doctor-conflicts-json.test.d.ts.map +1 -0
- package/dist/cli/__tests__/doctor-conflicts-json.test.js +46 -0
- package/dist/cli/__tests__/doctor-conflicts-json.test.js.map +1 -0
- package/dist/cli/__tests__/team.test.js +67 -0
- package/dist/cli/__tests__/team.test.js.map +1 -1
- package/dist/cli/__tests__/wait-teleport-json.test.d.ts +2 -0
- package/dist/cli/__tests__/wait-teleport-json.test.d.ts.map +1 -0
- package/dist/cli/__tests__/wait-teleport-json.test.js +64 -0
- package/dist/cli/__tests__/wait-teleport-json.test.js.map +1 -0
- package/dist/cli/commands/__tests__/smoke-tier2.test.d.ts +2 -0
- package/dist/cli/commands/__tests__/smoke-tier2.test.d.ts.map +1 -0
- package/dist/cli/commands/__tests__/smoke-tier2.test.js +110 -0
- package/dist/cli/commands/__tests__/smoke-tier2.test.js.map +1 -0
- package/dist/cli/commands/__tests__/team-status-json.test.d.ts +2 -0
- package/dist/cli/commands/__tests__/team-status-json.test.d.ts.map +1 -0
- package/dist/cli/commands/__tests__/team-status-json.test.js +141 -0
- package/dist/cli/commands/__tests__/team-status-json.test.js.map +1 -0
- package/dist/cli/commands/factory.d.ts +2 -0
- package/dist/cli/commands/factory.d.ts.map +1 -1
- package/dist/cli/commands/factory.js +8 -1
- package/dist/cli/commands/factory.js.map +1 -1
- package/dist/cli/commands/smoke.d.ts +36 -0
- package/dist/cli/commands/smoke.d.ts.map +1 -0
- package/dist/cli/commands/smoke.js +169 -0
- package/dist/cli/commands/smoke.js.map +1 -0
- package/dist/cli/commands/team.d.ts +2 -0
- package/dist/cli/commands/team.d.ts.map +1 -1
- package/dist/cli/commands/team.js +124 -10
- package/dist/cli/commands/team.js.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +70 -10
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/win32-warning.d.ts +7 -1
- package/dist/cli/win32-warning.d.ts.map +1 -1
- package/dist/cli/win32-warning.js +9 -1
- package/dist/cli/win32-warning.js.map +1 -1
- package/dist/constants/names.d.ts +1 -0
- package/dist/constants/names.d.ts.map +1 -1
- package/dist/constants/names.js +1 -0
- package/dist/constants/names.js.map +1 -1
- package/dist/factory/__tests__/check-run.test.js +2 -2
- package/dist/factory/__tests__/check-run.test.js.map +1 -1
- package/dist/factory/__tests__/listener.test.js +1 -1
- package/dist/factory/__tests__/listener.test.js.map +1 -1
- package/dist/factory/__tests__/status.test.js +42 -0
- package/dist/factory/__tests__/status.test.js.map +1 -1
- package/dist/factory/listener.d.ts.map +1 -1
- package/dist/factory/listener.js +7 -8
- package/dist/factory/listener.js.map +1 -1
- package/dist/factory/status.d.ts +19 -1
- package/dist/factory/status.d.ts.map +1 -1
- package/dist/factory/status.js +49 -8
- package/dist/factory/status.js.map +1 -1
- package/dist/factory/watchdog.d.ts.map +1 -1
- package/dist/factory/watchdog.js +14 -0
- package/dist/factory/watchdog.js.map +1 -1
- package/dist/factory/watchdog.test.js +45 -0
- package/dist/factory/watchdog.test.js.map +1 -1
- package/dist/hooks/session-end/__tests__/action-runner.test.js +5 -0
- package/dist/hooks/session-end/__tests__/action-runner.test.js.map +1 -1
- package/dist/hooks/session-end/__tests__/chain-enqueuer.test.js +186 -1
- package/dist/hooks/session-end/__tests__/chain-enqueuer.test.js.map +1 -1
- package/dist/hooks/session-end/__tests__/chain-link-env-passthrough.test.d.ts +2 -0
- package/dist/hooks/session-end/__tests__/chain-link-env-passthrough.test.d.ts.map +1 -0
- package/dist/hooks/session-end/__tests__/chain-link-env-passthrough.test.js +49 -0
- package/dist/hooks/session-end/__tests__/chain-link-env-passthrough.test.js.map +1 -0
- package/dist/hooks/session-end/__tests__/foreground-bootstrap.test.js +30 -1
- package/dist/hooks/session-end/__tests__/foreground-bootstrap.test.js.map +1 -1
- package/dist/hooks/session-end/__tests__/spawn-next.test.js +104 -3
- package/dist/hooks/session-end/__tests__/spawn-next.test.js.map +1 -1
- package/dist/hooks/session-end/__tests__/worker.test.js +6 -0
- package/dist/hooks/session-end/__tests__/worker.test.js.map +1 -1
- package/dist/hooks/session-end/action-runner.d.ts.map +1 -1
- package/dist/hooks/session-end/action-runner.js +2 -1
- package/dist/hooks/session-end/action-runner.js.map +1 -1
- package/dist/hooks/session-end/chain-enqueuer.d.ts +70 -7
- package/dist/hooks/session-end/chain-enqueuer.d.ts.map +1 -1
- package/dist/hooks/session-end/chain-enqueuer.js +354 -82
- package/dist/hooks/session-end/chain-enqueuer.js.map +1 -1
- package/dist/hooks/session-end/foreground-bootstrap.d.ts.map +1 -1
- package/dist/hooks/session-end/foreground-bootstrap.js +24 -16
- package/dist/hooks/session-end/foreground-bootstrap.js.map +1 -1
- package/dist/hooks/session-end/index.d.ts +2 -3
- package/dist/hooks/session-end/index.d.ts.map +1 -1
- package/dist/hooks/session-end/index.js +11 -13
- package/dist/hooks/session-end/index.js.map +1 -1
- package/dist/hooks/session-end/spawn-next.d.ts +81 -4
- package/dist/hooks/session-end/spawn-next.d.ts.map +1 -1
- package/dist/hooks/session-end/spawn-next.js +141 -14
- package/dist/hooks/session-end/spawn-next.js.map +1 -1
- package/dist/hooks/session-end/wiki-foreground-bootstrap.d.ts +17 -0
- package/dist/hooks/session-end/wiki-foreground-bootstrap.d.ts.map +1 -0
- package/dist/hooks/session-end/wiki-foreground-bootstrap.js +20 -0
- package/dist/hooks/session-end/wiki-foreground-bootstrap.js.map +1 -0
- package/dist/hooks/session-end/worker.d.ts.map +1 -1
- package/dist/hooks/session-end/worker.js +11 -6
- package/dist/hooks/session-end/worker.js.map +1 -1
- package/dist/lib/__tests__/atomic-write.test.js +32 -1
- package/dist/lib/__tests__/atomic-write.test.js.map +1 -1
- package/dist/lib/__tests__/mode-state-lock.test.js +121 -12
- package/dist/lib/__tests__/mode-state-lock.test.js.map +1 -1
- package/dist/lib/atomic-write.d.ts +13 -3
- package/dist/lib/atomic-write.d.ts.map +1 -1
- package/dist/lib/atomic-write.js +29 -15
- package/dist/lib/atomic-write.js.map +1 -1
- package/dist/lib/mode-state-io.d.ts +2 -2
- package/dist/lib/mode-state-io.d.ts.map +1 -1
- package/dist/lib/mode-state-io.js +16 -10
- package/dist/lib/mode-state-io.js.map +1 -1
- package/dist/mcp/__tests__/host-smoke-tool.test.d.ts +2 -0
- package/dist/mcp/__tests__/host-smoke-tool.test.d.ts.map +1 -0
- package/dist/mcp/__tests__/host-smoke-tool.test.js +174 -0
- package/dist/mcp/__tests__/host-smoke-tool.test.js.map +1 -0
- package/dist/mcp/disable-tools.d.ts.map +1 -1
- package/dist/mcp/disable-tools.js +1 -0
- package/dist/mcp/disable-tools.js.map +1 -1
- package/dist/mcp/tool-registry.d.ts.map +1 -1
- package/dist/mcp/tool-registry.js +2 -0
- package/dist/mcp/tool-registry.js.map +1 -1
- package/dist/shared/types.d.ts +11 -0
- package/dist/shared/types.d.ts.map +1 -1
- package/dist/smoke/__tests__/copilot-chain-scenario.test.d.ts +2 -0
- package/dist/smoke/__tests__/copilot-chain-scenario.test.d.ts.map +1 -0
- package/dist/smoke/__tests__/copilot-chain-scenario.test.js +154 -0
- package/dist/smoke/__tests__/copilot-chain-scenario.test.js.map +1 -0
- package/dist/smoke/__tests__/copilot-sdk-driver.test.d.ts +2 -0
- package/dist/smoke/__tests__/copilot-sdk-driver.test.d.ts.map +1 -0
- package/dist/smoke/__tests__/copilot-sdk-driver.test.js +591 -0
- package/dist/smoke/__tests__/copilot-sdk-driver.test.js.map +1 -0
- package/dist/smoke/__tests__/copilot-sdk-scenarios.test.d.ts +2 -0
- package/dist/smoke/__tests__/copilot-sdk-scenarios.test.d.ts.map +1 -0
- package/dist/smoke/__tests__/copilot-sdk-scenarios.test.js +362 -0
- package/dist/smoke/__tests__/copilot-sdk-scenarios.test.js.map +1 -0
- package/dist/smoke/__tests__/copilot-session-eval.test.d.ts +2 -0
- package/dist/smoke/__tests__/copilot-session-eval.test.d.ts.map +1 -0
- package/dist/smoke/__tests__/copilot-session-eval.test.js +264 -0
- package/dist/smoke/__tests__/copilot-session-eval.test.js.map +1 -0
- package/dist/smoke/__tests__/copilot-smoke.test.d.ts +2 -0
- package/dist/smoke/__tests__/copilot-smoke.test.d.ts.map +1 -0
- package/dist/smoke/__tests__/copilot-smoke.test.js +482 -0
- package/dist/smoke/__tests__/copilot-smoke.test.js.map +1 -0
- package/dist/smoke/copilot-binary.d.ts +21 -0
- package/dist/smoke/copilot-binary.d.ts.map +1 -0
- package/dist/smoke/copilot-binary.js +46 -0
- package/dist/smoke/copilot-binary.js.map +1 -0
- package/dist/smoke/copilot-chain-scenario.d.ts +61 -0
- package/dist/smoke/copilot-chain-scenario.d.ts.map +1 -0
- package/dist/smoke/copilot-chain-scenario.js +253 -0
- package/dist/smoke/copilot-chain-scenario.js.map +1 -0
- package/dist/smoke/copilot-sdk-driver.d.ts +189 -0
- package/dist/smoke/copilot-sdk-driver.d.ts.map +1 -0
- package/dist/smoke/copilot-sdk-driver.js +637 -0
- package/dist/smoke/copilot-sdk-driver.js.map +1 -0
- package/dist/smoke/copilot-sdk-scenarios.d.ts +200 -0
- package/dist/smoke/copilot-sdk-scenarios.d.ts.map +1 -0
- package/dist/smoke/copilot-sdk-scenarios.js +620 -0
- package/dist/smoke/copilot-sdk-scenarios.js.map +1 -0
- package/dist/smoke/copilot-session-env.d.ts +75 -0
- package/dist/smoke/copilot-session-env.d.ts.map +1 -0
- package/dist/smoke/copilot-session-env.js +154 -0
- package/dist/smoke/copilot-session-env.js.map +1 -0
- package/dist/smoke/copilot-session-eval.d.ts +90 -0
- package/dist/smoke/copilot-session-eval.d.ts.map +1 -0
- package/dist/smoke/copilot-session-eval.js +323 -0
- package/dist/smoke/copilot-session-eval.js.map +1 -0
- package/dist/smoke/copilot-smoke.d.ts +166 -0
- package/dist/smoke/copilot-smoke.d.ts.map +1 -0
- package/dist/smoke/copilot-smoke.js +688 -0
- package/dist/smoke/copilot-smoke.js.map +1 -0
- package/dist/smoke/process-utils.d.ts +47 -0
- package/dist/smoke/process-utils.d.ts.map +1 -0
- package/dist/smoke/process-utils.js +99 -0
- package/dist/smoke/process-utils.js.map +1 -0
- package/dist/team/__tests__/runtime-v2.monitor.test.js +35 -0
- package/dist/team/__tests__/runtime-v2.monitor.test.js.map +1 -1
- package/dist/team/__tests__/scaling.test.js +13 -0
- package/dist/team/__tests__/scaling.test.js.map +1 -1
- package/dist/team/__tests__/sdk-transport.runtime.test.d.ts +2 -0
- package/dist/team/__tests__/sdk-transport.runtime.test.d.ts.map +1 -0
- package/dist/team/__tests__/sdk-transport.runtime.test.js +96 -0
- package/dist/team/__tests__/sdk-transport.runtime.test.js.map +1 -0
- package/dist/team/__tests__/sdk-transport.test.d.ts +2 -0
- package/dist/team/__tests__/sdk-transport.test.d.ts.map +1 -0
- package/dist/team/__tests__/sdk-transport.test.js +650 -0
- package/dist/team/__tests__/sdk-transport.test.js.map +1 -0
- package/dist/team/__tests__/tmux-session.pane-env.test.d.ts +2 -0
- package/dist/team/__tests__/tmux-session.pane-env.test.d.ts.map +1 -0
- package/dist/team/__tests__/tmux-session.pane-env.test.js +52 -0
- package/dist/team/__tests__/tmux-session.pane-env.test.js.map +1 -0
- package/dist/team/api-interop.d.ts.map +1 -1
- package/dist/team/api-interop.js +8 -0
- package/dist/team/api-interop.js.map +1 -1
- package/dist/team/runtime-v2.d.ts +33 -0
- package/dist/team/runtime-v2.d.ts.map +1 -1
- package/dist/team/runtime-v2.js +338 -24
- package/dist/team/runtime-v2.js.map +1 -1
- package/dist/team/scaling.d.ts.map +1 -1
- package/dist/team/scaling.js +5 -0
- package/dist/team/scaling.js.map +1 -1
- package/dist/team/sdk-host.d.ts +48 -0
- package/dist/team/sdk-host.d.ts.map +1 -0
- package/dist/team/sdk-host.js +604 -0
- package/dist/team/sdk-host.js.map +1 -0
- package/dist/team/sdk-policy.d.ts +79 -0
- package/dist/team/sdk-policy.d.ts.map +1 -0
- package/dist/team/sdk-policy.js +186 -0
- package/dist/team/sdk-policy.js.map +1 -0
- package/dist/team/sdk-transport.d.ts +164 -0
- package/dist/team/sdk-transport.d.ts.map +1 -0
- package/dist/team/sdk-transport.js +266 -0
- package/dist/team/sdk-transport.js.map +1 -0
- package/dist/team/tmux-session.d.ts +7 -0
- package/dist/team/tmux-session.d.ts.map +1 -1
- package/dist/team/tmux-session.js +80 -18
- package/dist/team/tmux-session.js.map +1 -1
- package/dist/team/types.d.ts +2 -0
- package/dist/team/types.d.ts.map +1 -1
- package/dist/team/types.js.map +1 -1
- package/dist/tools/host-smoke-tool.d.ts +34 -0
- package/dist/tools/host-smoke-tool.d.ts.map +1 -0
- package/dist/tools/host-smoke-tool.js +133 -0
- package/dist/tools/host-smoke-tool.js.map +1 -0
- package/docs/CLAUDE.md +1 -1
- package/docs/DEVELOPERS.md +122 -0
- package/docs/HOOKS.md +34 -2
- package/docs/MIGRATION.md +194 -3
- package/docs/REFERENCE.md +95 -1
- package/docs/TOOLS.md +32 -1
- package/package.json +11 -2
- package/plugin.json +1 -1
- package/scripts/dev/repro-state-lock.mjs +1 -1
- package/scripts/lib/atomic-write.mjs +4 -2
- package/scripts/lib/state-lock.mjs +21 -12
- package/scripts/run.cjs +141 -18
- package/scripts/session-start.mjs +13 -0
- package/scripts/wiki-session-end.mjs +2 -1
- package/templates/hooks/lib/atomic-write.mjs +4 -2
package/bridge/team-mcp.cjs
CHANGED
|
@@ -2986,7 +2986,7 @@ var require_compile = __commonJS({
|
|
|
2986
2986
|
const schOrFunc = root.refs[ref];
|
|
2987
2987
|
if (schOrFunc)
|
|
2988
2988
|
return schOrFunc;
|
|
2989
|
-
let _sch =
|
|
2989
|
+
let _sch = resolve17.call(this, root, ref);
|
|
2990
2990
|
if (_sch === void 0) {
|
|
2991
2991
|
const schema = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref];
|
|
2992
2992
|
const { schemaId } = this.opts;
|
|
@@ -3013,7 +3013,7 @@ var require_compile = __commonJS({
|
|
|
3013
3013
|
function sameSchemaEnv(s1, s2) {
|
|
3014
3014
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
3015
3015
|
}
|
|
3016
|
-
function
|
|
3016
|
+
function resolve17(root, ref) {
|
|
3017
3017
|
let sch;
|
|
3018
3018
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
3019
3019
|
ref = sch;
|
|
@@ -3644,55 +3644,55 @@ var require_fast_uri = __commonJS({
|
|
|
3644
3644
|
}
|
|
3645
3645
|
return uri;
|
|
3646
3646
|
}
|
|
3647
|
-
function
|
|
3647
|
+
function resolve17(baseURI, relativeURI, options) {
|
|
3648
3648
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
3649
3649
|
const resolved = resolveComponent(parse6(baseURI, schemelessOptions), parse6(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
3650
3650
|
schemelessOptions.skipEscape = true;
|
|
3651
3651
|
return serialize(resolved, schemelessOptions);
|
|
3652
3652
|
}
|
|
3653
|
-
function resolveComponent(base,
|
|
3653
|
+
function resolveComponent(base, relative11, options, skipNormalization) {
|
|
3654
3654
|
const target = {};
|
|
3655
3655
|
if (!skipNormalization) {
|
|
3656
3656
|
base = parse6(serialize(base, options), options);
|
|
3657
|
-
|
|
3657
|
+
relative11 = parse6(serialize(relative11, options), options);
|
|
3658
3658
|
}
|
|
3659
3659
|
options = options || {};
|
|
3660
|
-
if (!options.tolerant &&
|
|
3661
|
-
target.scheme =
|
|
3662
|
-
target.userinfo =
|
|
3663
|
-
target.host =
|
|
3664
|
-
target.port =
|
|
3665
|
-
target.path = removeDotSegments(
|
|
3666
|
-
target.query =
|
|
3660
|
+
if (!options.tolerant && relative11.scheme) {
|
|
3661
|
+
target.scheme = relative11.scheme;
|
|
3662
|
+
target.userinfo = relative11.userinfo;
|
|
3663
|
+
target.host = relative11.host;
|
|
3664
|
+
target.port = relative11.port;
|
|
3665
|
+
target.path = removeDotSegments(relative11.path || "");
|
|
3666
|
+
target.query = relative11.query;
|
|
3667
3667
|
} else {
|
|
3668
|
-
if (
|
|
3669
|
-
target.userinfo =
|
|
3670
|
-
target.host =
|
|
3671
|
-
target.port =
|
|
3672
|
-
target.path = removeDotSegments(
|
|
3673
|
-
target.query =
|
|
3668
|
+
if (relative11.userinfo !== void 0 || relative11.host !== void 0 || relative11.port !== void 0) {
|
|
3669
|
+
target.userinfo = relative11.userinfo;
|
|
3670
|
+
target.host = relative11.host;
|
|
3671
|
+
target.port = relative11.port;
|
|
3672
|
+
target.path = removeDotSegments(relative11.path || "");
|
|
3673
|
+
target.query = relative11.query;
|
|
3674
3674
|
} else {
|
|
3675
|
-
if (!
|
|
3675
|
+
if (!relative11.path) {
|
|
3676
3676
|
target.path = base.path;
|
|
3677
|
-
if (
|
|
3678
|
-
target.query =
|
|
3677
|
+
if (relative11.query !== void 0) {
|
|
3678
|
+
target.query = relative11.query;
|
|
3679
3679
|
} else {
|
|
3680
3680
|
target.query = base.query;
|
|
3681
3681
|
}
|
|
3682
3682
|
} else {
|
|
3683
|
-
if (
|
|
3684
|
-
target.path = removeDotSegments(
|
|
3683
|
+
if (relative11.path[0] === "/") {
|
|
3684
|
+
target.path = removeDotSegments(relative11.path);
|
|
3685
3685
|
} else {
|
|
3686
3686
|
if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) {
|
|
3687
|
-
target.path = "/" +
|
|
3687
|
+
target.path = "/" + relative11.path;
|
|
3688
3688
|
} else if (!base.path) {
|
|
3689
|
-
target.path =
|
|
3689
|
+
target.path = relative11.path;
|
|
3690
3690
|
} else {
|
|
3691
|
-
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) +
|
|
3691
|
+
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative11.path;
|
|
3692
3692
|
}
|
|
3693
3693
|
target.path = removeDotSegments(target.path);
|
|
3694
3694
|
}
|
|
3695
|
-
target.query =
|
|
3695
|
+
target.query = relative11.query;
|
|
3696
3696
|
}
|
|
3697
3697
|
target.userinfo = base.userinfo;
|
|
3698
3698
|
target.host = base.host;
|
|
@@ -3700,7 +3700,7 @@ var require_fast_uri = __commonJS({
|
|
|
3700
3700
|
}
|
|
3701
3701
|
target.scheme = base.scheme;
|
|
3702
3702
|
}
|
|
3703
|
-
target.fragment =
|
|
3703
|
+
target.fragment = relative11.fragment;
|
|
3704
3704
|
return target;
|
|
3705
3705
|
}
|
|
3706
3706
|
function equal(uriA, uriB, options) {
|
|
@@ -3902,7 +3902,7 @@ var require_fast_uri = __commonJS({
|
|
|
3902
3902
|
var fastUri = {
|
|
3903
3903
|
SCHEMES,
|
|
3904
3904
|
normalize: normalize3,
|
|
3905
|
-
resolve:
|
|
3905
|
+
resolve: resolve17,
|
|
3906
3906
|
resolveComponent,
|
|
3907
3907
|
equal,
|
|
3908
3908
|
serialize,
|
|
@@ -8466,7 +8466,7 @@ async function withProcessIdentityFileLock(lockPath, fn, timeoutMs = 1e4) {
|
|
|
8466
8466
|
continue;
|
|
8467
8467
|
}
|
|
8468
8468
|
if (Date.now() >= deadline) throw new Error("process_identity_lock_timeout");
|
|
8469
|
-
await new Promise((
|
|
8469
|
+
await new Promise((resolve17) => setTimeout(resolve17, 25));
|
|
8470
8470
|
continue;
|
|
8471
8471
|
}
|
|
8472
8472
|
try {
|
|
@@ -8487,7 +8487,7 @@ async function withProcessIdentityFileLock(lockPath, fn, timeoutMs = 1e4) {
|
|
|
8487
8487
|
}
|
|
8488
8488
|
}
|
|
8489
8489
|
if (Date.now() >= deadline) throw new Error("process_identity_lock_timeout");
|
|
8490
|
-
await new Promise((
|
|
8490
|
+
await new Promise((resolve17) => setTimeout(resolve17, 25));
|
|
8491
8491
|
}
|
|
8492
8492
|
}
|
|
8493
8493
|
return await fn();
|
|
@@ -9933,8 +9933,8 @@ function getPackageDir() {
|
|
|
9933
9933
|
}
|
|
9934
9934
|
}
|
|
9935
9935
|
try {
|
|
9936
|
-
const
|
|
9937
|
-
const __dirname2 = (0, import_path8.dirname)(
|
|
9936
|
+
const __filename2 = (0, import_url2.fileURLToPath)(importMetaUrl);
|
|
9937
|
+
const __dirname2 = (0, import_path8.dirname)(__filename2);
|
|
9938
9938
|
const currentDirName = (0, import_path8.basename)(__dirname2);
|
|
9939
9939
|
if (currentDirName === "bridge") {
|
|
9940
9940
|
return (0, import_path8.join)(__dirname2, "..");
|
|
@@ -11040,8 +11040,8 @@ function getPackageDir2() {
|
|
|
11040
11040
|
}
|
|
11041
11041
|
}
|
|
11042
11042
|
try {
|
|
11043
|
-
const
|
|
11044
|
-
const __dirname2 = (0, import_path14.dirname)(
|
|
11043
|
+
const __filename2 = (0, import_url3.fileURLToPath)(importMetaUrl);
|
|
11044
|
+
const __dirname2 = (0, import_path14.dirname)(__filename2);
|
|
11045
11045
|
return (0, import_path14.join)(__dirname2, "..", "..", "..");
|
|
11046
11046
|
} catch {
|
|
11047
11047
|
return process.cwd();
|
|
@@ -11797,6 +11797,45 @@ function parseDeadline(deadlineAt) {
|
|
|
11797
11797
|
const value = Date.parse(deadlineAt);
|
|
11798
11798
|
return Number.isFinite(value) ? value : void 0;
|
|
11799
11799
|
}
|
|
11800
|
+
async function killProcessTree(pid, signal = "SIGTERM") {
|
|
11801
|
+
if (!Number.isInteger(pid) || pid <= 0) return false;
|
|
11802
|
+
if (process.platform === "win32") {
|
|
11803
|
+
return killProcessTreeWindows(pid, signal === "SIGKILL");
|
|
11804
|
+
} else {
|
|
11805
|
+
return killProcessTreeUnix(pid, signal);
|
|
11806
|
+
}
|
|
11807
|
+
}
|
|
11808
|
+
async function killProcessTreeWindows(pid, force) {
|
|
11809
|
+
try {
|
|
11810
|
+
const args = ["/T", "/PID", String(pid)];
|
|
11811
|
+
if (force) {
|
|
11812
|
+
args.unshift("/F");
|
|
11813
|
+
}
|
|
11814
|
+
(0, import_child_process6.execFileSync)("taskkill.exe", args, {
|
|
11815
|
+
stdio: "ignore",
|
|
11816
|
+
timeout: 5e3,
|
|
11817
|
+
windowsHide: true
|
|
11818
|
+
});
|
|
11819
|
+
return true;
|
|
11820
|
+
} catch (err) {
|
|
11821
|
+
const error2 = err;
|
|
11822
|
+
if (error2.status === 128) return true;
|
|
11823
|
+
return false;
|
|
11824
|
+
}
|
|
11825
|
+
}
|
|
11826
|
+
function killProcessTreeUnix(pid, signal) {
|
|
11827
|
+
try {
|
|
11828
|
+
process.kill(-pid, signal);
|
|
11829
|
+
return true;
|
|
11830
|
+
} catch {
|
|
11831
|
+
try {
|
|
11832
|
+
process.kill(pid, signal);
|
|
11833
|
+
return true;
|
|
11834
|
+
} catch {
|
|
11835
|
+
return !isProcessAlive(pid);
|
|
11836
|
+
}
|
|
11837
|
+
}
|
|
11838
|
+
}
|
|
11800
11839
|
function isProcessAlive(pid) {
|
|
11801
11840
|
if (!Number.isInteger(pid) || pid <= 0) return false;
|
|
11802
11841
|
try {
|
|
@@ -12066,33 +12105,33 @@ function ensureDirSync(dir) {
|
|
|
12066
12105
|
}
|
|
12067
12106
|
}
|
|
12068
12107
|
function verifyPrivateTempFile(fd, tempPath, label, operations) {
|
|
12069
|
-
const fdStats =
|
|
12108
|
+
const fdStats = descriptorStats(fd, operations);
|
|
12070
12109
|
let pathStats;
|
|
12071
12110
|
try {
|
|
12072
|
-
pathStats = (operations
|
|
12111
|
+
pathStats = pathnameStats(tempPath, operations);
|
|
12073
12112
|
} catch {
|
|
12074
12113
|
throw new Error(`${label} temporary file was replaced before rename`);
|
|
12075
12114
|
}
|
|
12076
12115
|
const isWindows = process.platform === "win32";
|
|
12077
|
-
const isPrivateRegularSingleLink = (stats) => stats.isFile() && (isWindows ? stats.nlink <= 1 : stats.nlink === 1) && (isWindows || (stats.mode & 511) === 384);
|
|
12116
|
+
const isPrivateRegularSingleLink = (stats) => stats.isFile() && (isWindows ? Number(stats.nlink) <= 1 : Number(stats.nlink) === 1) && (isWindows || (Number(stats.mode) & 511) === 384);
|
|
12078
12117
|
if (!isPrivateRegularSingleLink(fdStats) || !isPrivateRegularSingleLink(pathStats)) {
|
|
12079
12118
|
throw new Error(
|
|
12080
12119
|
`${label} temporary file must be a private regular single-link file`
|
|
12081
12120
|
);
|
|
12082
12121
|
}
|
|
12083
|
-
if (!sameFileIdentity(fdStats, pathStats)) {
|
|
12122
|
+
if (!sameFileIdentity(fileIdentityOf(fdStats), fileIdentityOf(pathStats))) {
|
|
12084
12123
|
throw new Error(`${label} temporary file was replaced before rename`);
|
|
12085
12124
|
}
|
|
12086
12125
|
}
|
|
12087
12126
|
function verifyPublishedFile(fd, filePath, label, operations) {
|
|
12088
|
-
const fdStats =
|
|
12127
|
+
const fdStats = descriptorStats(fd, operations);
|
|
12089
12128
|
let pathStats;
|
|
12090
12129
|
try {
|
|
12091
|
-
pathStats = (operations
|
|
12130
|
+
pathStats = pathnameStats(filePath, operations);
|
|
12092
12131
|
} catch {
|
|
12093
12132
|
throw new Error(`${label} target was replaced at publication`);
|
|
12094
12133
|
}
|
|
12095
|
-
if (!pathStats.isFile() || !sameFileIdentity(fdStats, pathStats)) {
|
|
12134
|
+
if (!pathStats.isFile() || !sameFileIdentity(fileIdentityOf(fdStats), fileIdentityOf(pathStats))) {
|
|
12096
12135
|
throw new Error(`${label} target was replaced at publication`);
|
|
12097
12136
|
}
|
|
12098
12137
|
}
|
|
@@ -12116,26 +12155,33 @@ function preservePriorTarget(filePath, operations) {
|
|
|
12116
12155
|
return null;
|
|
12117
12156
|
}
|
|
12118
12157
|
}
|
|
12158
|
+
function descriptorStats(fd, operations) {
|
|
12159
|
+
return operations ? fsSync.fstatSync(fd) : fsSync.fstatSync(fd, { bigint: true });
|
|
12160
|
+
}
|
|
12161
|
+
function pathnameStats(filePath, operations) {
|
|
12162
|
+
return operations ? operations.lstat(filePath) : fsSync.lstatSync(filePath, { bigint: true });
|
|
12163
|
+
}
|
|
12164
|
+
function fileIdentityOf(stats) {
|
|
12165
|
+
return { dev: BigInt(stats.dev), ino: BigInt(stats.ino) };
|
|
12166
|
+
}
|
|
12119
12167
|
function sameFileIdentity(a, b) {
|
|
12120
12168
|
if (a.ino !== b.ino) return false;
|
|
12121
12169
|
const isWindows = process.platform === "win32";
|
|
12122
|
-
if (isWindows && (a.dev ===
|
|
12170
|
+
if (isWindows && (a.dev === 0n || b.dev === 0n)) {
|
|
12123
12171
|
return true;
|
|
12124
12172
|
}
|
|
12125
12173
|
return a.dev === b.dev;
|
|
12126
12174
|
}
|
|
12127
12175
|
function currentFileIdentity(filePath, operations) {
|
|
12128
12176
|
try {
|
|
12129
|
-
|
|
12130
|
-
return { dev: stats.dev, ino: stats.ino };
|
|
12177
|
+
return fileIdentityOf(pathnameStats(filePath, operations));
|
|
12131
12178
|
} catch {
|
|
12132
12179
|
return null;
|
|
12133
12180
|
}
|
|
12134
12181
|
}
|
|
12135
|
-
function descriptorIdentity(fd) {
|
|
12182
|
+
function descriptorIdentity(fd, operations) {
|
|
12136
12183
|
try {
|
|
12137
|
-
|
|
12138
|
-
return { dev: stats.dev, ino: stats.ino };
|
|
12184
|
+
return fileIdentityOf(descriptorStats(fd, operations));
|
|
12139
12185
|
} catch {
|
|
12140
12186
|
return null;
|
|
12141
12187
|
}
|
|
@@ -12398,7 +12444,7 @@ function withFileLockSync(lockPath, fn, opts) {
|
|
|
12398
12444
|
}
|
|
12399
12445
|
}
|
|
12400
12446
|
function sleep(ms) {
|
|
12401
|
-
return new Promise((
|
|
12447
|
+
return new Promise((resolve17) => setTimeout(resolve17, ms));
|
|
12402
12448
|
}
|
|
12403
12449
|
async function acquireFileLock(lockPath, opts) {
|
|
12404
12450
|
const staleLockMs = opts?.staleLockMs ?? DEFAULT_STALE_LOCK_MS;
|
|
@@ -12494,7 +12540,7 @@ function canonicalAuthorityDigest(input) {
|
|
|
12494
12540
|
return (0, import_node_crypto5.createHash)("sha256").update(payload, "utf8").digest("hex");
|
|
12495
12541
|
}
|
|
12496
12542
|
function sleep2(ms) {
|
|
12497
|
-
return new Promise((
|
|
12543
|
+
return new Promise((resolve17) => setTimeout(resolve17, ms));
|
|
12498
12544
|
}
|
|
12499
12545
|
function isExactText(value) {
|
|
12500
12546
|
return typeof value === "string" && value.length > 0 && value === value.trim();
|
|
@@ -12588,6 +12634,32 @@ function identityOf(attempt) {
|
|
|
12588
12634
|
created_at: attempt.created_at
|
|
12589
12635
|
};
|
|
12590
12636
|
}
|
|
12637
|
+
function isValidCompletionBinding(value) {
|
|
12638
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
12639
|
+
const record2 = value;
|
|
12640
|
+
const identityValid = isValidIdentity(record2);
|
|
12641
|
+
const containmentNonce = record2.containment_nonce;
|
|
12642
|
+
const authorityDigest = record2.authority_digest;
|
|
12643
|
+
return identityValid && isExactText(containmentNonce) && typeof authorityDigest === "string" && /^[0-9a-f]{64}$/.test(authorityDigest);
|
|
12644
|
+
}
|
|
12645
|
+
function parseProviderCompletionExitCode(raw, binding) {
|
|
12646
|
+
if (!binding) {
|
|
12647
|
+
const normalized = raw.trim();
|
|
12648
|
+
if (!/^\d+$/.test(normalized)) return void 0;
|
|
12649
|
+
const exitCode = Number(normalized);
|
|
12650
|
+
return Number.isSafeInteger(exitCode) && exitCode >= 0 ? exitCode : void 0;
|
|
12651
|
+
}
|
|
12652
|
+
let parsed;
|
|
12653
|
+
try {
|
|
12654
|
+
parsed = JSON.parse(raw);
|
|
12655
|
+
} catch {
|
|
12656
|
+
return void 0;
|
|
12657
|
+
}
|
|
12658
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return void 0;
|
|
12659
|
+
const record2 = parsed;
|
|
12660
|
+
if (!identityMatches(record2, binding) || record2.kind !== "worker_launch_provider_completion" || record2.containment_nonce !== binding.containment_nonce || record2.authority_digest !== binding.authority_digest || !Number.isSafeInteger(record2.exit_code) || Number(record2.exit_code) < 0) return void 0;
|
|
12661
|
+
return Number(record2.exit_code);
|
|
12662
|
+
}
|
|
12591
12663
|
async function readJson(path5) {
|
|
12592
12664
|
try {
|
|
12593
12665
|
return { kind: "value", value: JSON.parse(await (0, import_promises8.readFile)(path5, "utf8")) };
|
|
@@ -12927,6 +12999,9 @@ function acknowledgementResult(value, attempt) {
|
|
|
12927
12999
|
if (record2.kind !== "worker_launch_ack" || typeof record2.written_at !== "string" || !Number.isFinite(Date.parse(record2.written_at))) return { ok: false, reason: "ack_malformed" };
|
|
12928
13000
|
return identityMatches(record2, attempt) ? null : { ok: false, reason: "ack_mismatch" };
|
|
12929
13001
|
}
|
|
13002
|
+
function isValidWorkerLaunchAcknowledgement(read, attempt) {
|
|
13003
|
+
return read.kind === "value" && acknowledgementResult(read.value, attempt) === null;
|
|
13004
|
+
}
|
|
12930
13005
|
async function acceptObservedAcknowledgement(attempt, read) {
|
|
12931
13006
|
if (read.kind === "absent") return null;
|
|
12932
13007
|
if (read.kind === "malformed") return { ok: false, reason: "ack_malformed" };
|
|
@@ -13032,6 +13107,12 @@ async function retireAndCleanupCurrentWorkerLaunchAttempt(attempt, reason, clean
|
|
|
13032
13107
|
return false;
|
|
13033
13108
|
}
|
|
13034
13109
|
}
|
|
13110
|
+
async function readWorkerLaunchRetirementState(attempt) {
|
|
13111
|
+
const retired = await readJson(`${attempt.decisionPath}.retired`);
|
|
13112
|
+
if (retired.kind === "absent") return "absent";
|
|
13113
|
+
if (retired.kind !== "value" || !identityMatches(retired.value, attempt) || retired.value.kind !== "worker_launch_retired" || !isExactText(retired.value.reason) || typeof retired.value.written_at !== "string" || !Number.isFinite(Date.parse(retired.value.written_at))) return "invalid";
|
|
13114
|
+
return "valid";
|
|
13115
|
+
}
|
|
13035
13116
|
async function readWorkerLaunchRetirementCleanupState(attempt) {
|
|
13036
13117
|
const completed = await readJson(`${attempt.decisionPath}.retired.cleanup-complete`);
|
|
13037
13118
|
if (completed.kind === "absent") return "absent";
|
|
@@ -13062,6 +13143,9 @@ function isValidProcessStartIdentity2(value) {
|
|
|
13062
13143
|
const darwin = /^darwin:([1-9]\d*):(\d+)$/.exec(value);
|
|
13063
13144
|
return darwin !== null && Number(darwin[2]) < 1e6;
|
|
13064
13145
|
}
|
|
13146
|
+
function isPositiveProcessId(value) {
|
|
13147
|
+
return Number.isSafeInteger(value) && Number(value) > 0;
|
|
13148
|
+
}
|
|
13065
13149
|
async function readWorkerLaunchCleanupProof(attempt, started) {
|
|
13066
13150
|
const startedPath = "startedPath" in attempt ? attempt.startedPath : attempt.started_path;
|
|
13067
13151
|
const matchesProcessGroup = (value) => {
|
|
@@ -13083,6 +13167,56 @@ async function readWorkerLaunchCleanupProof(attempt, started) {
|
|
|
13083
13167
|
}
|
|
13084
13168
|
return false;
|
|
13085
13169
|
}
|
|
13170
|
+
async function readWorkerLaunchProviderCompletionState(attempt, started) {
|
|
13171
|
+
if (started.supervisor_completion_path === void 0) return "absent";
|
|
13172
|
+
if (!isExactText(started.supervisor_completion_path) || !(0, import_node_path4.isAbsolute)(started.supervisor_completion_path)) return "invalid";
|
|
13173
|
+
const bindingReceipt = await readJson(`${attempt.startedPath}.completion-binding`);
|
|
13174
|
+
if (bindingReceipt.kind !== "value" || !bindingReceipt.value || typeof bindingReceipt.value !== "object" || Array.isArray(bindingReceipt.value)) return "invalid";
|
|
13175
|
+
const bindingValue = bindingReceipt.value;
|
|
13176
|
+
if (bindingValue.kind !== "worker_launch_completion_binding" || bindingValue.completion_path !== started.supervisor_completion_path || !identityMatches(bindingValue, attempt) || bindingValue.containment_nonce !== started.containment_nonce || bindingValue.authority_digest !== started.authority_digest || !isExactText(bindingValue.containment_nonce) || !/^[0-9a-f]{64}$/.test(bindingValue.authority_digest ?? "") || typeof bindingValue.written_at !== "string" || !Number.isFinite(Date.parse(bindingValue.written_at))) return "invalid";
|
|
13177
|
+
const completionBinding = {
|
|
13178
|
+
...identityOf(attempt),
|
|
13179
|
+
containment_nonce: bindingValue.containment_nonce,
|
|
13180
|
+
authority_digest: bindingValue.authority_digest
|
|
13181
|
+
};
|
|
13182
|
+
if (!isValidCompletionBinding(completionBinding)) return "invalid";
|
|
13183
|
+
const absoluteCompletionPath = (0, import_node_path4.resolve)(started.supervisor_completion_path);
|
|
13184
|
+
const trustedTempRoot = (0, import_node_path4.resolve)((0, import_node_os.tmpdir)());
|
|
13185
|
+
const pathParts = [];
|
|
13186
|
+
let pathPart = (0, import_node_path4.dirname)(absoluteCompletionPath);
|
|
13187
|
+
if (absoluteCompletionPath === trustedTempRoot || absoluteCompletionPath.startsWith(`${trustedTempRoot}${import_node_path4.sep}`)) {
|
|
13188
|
+
while (pathPart !== trustedTempRoot && pathPart !== (0, import_node_path4.dirname)(pathPart)) {
|
|
13189
|
+
pathParts.push(pathPart);
|
|
13190
|
+
pathPart = (0, import_node_path4.dirname)(pathPart);
|
|
13191
|
+
}
|
|
13192
|
+
} else {
|
|
13193
|
+
pathParts.push(pathPart);
|
|
13194
|
+
}
|
|
13195
|
+
for (const parentPath of pathParts) {
|
|
13196
|
+
try {
|
|
13197
|
+
if ((await (0, import_promises8.lstat)(parentPath)).isSymbolicLink()) return "invalid";
|
|
13198
|
+
} catch (error2) {
|
|
13199
|
+
if (error2.code === "ENOENT") return "absent";
|
|
13200
|
+
return "invalid";
|
|
13201
|
+
}
|
|
13202
|
+
}
|
|
13203
|
+
let raw;
|
|
13204
|
+
let handle;
|
|
13205
|
+
try {
|
|
13206
|
+
handle = await (0, import_promises8.open)(
|
|
13207
|
+
started.supervisor_completion_path,
|
|
13208
|
+
import_node_fs4.constants.O_RDONLY | (import_node_fs4.constants.O_NOFOLLOW ?? 0) | (process.platform === "win32" ? 0 : import_node_fs4.constants.O_NONBLOCK ?? 0)
|
|
13209
|
+
);
|
|
13210
|
+
const info = await handle.stat();
|
|
13211
|
+
if (!info.isFile() || info.nlink !== 1) return "invalid";
|
|
13212
|
+
raw = await handle.readFile("utf8");
|
|
13213
|
+
} catch (error2) {
|
|
13214
|
+
return error2.code === "ENOENT" ? "absent" : "invalid";
|
|
13215
|
+
} finally {
|
|
13216
|
+
await handle?.close().catch(() => void 0);
|
|
13217
|
+
}
|
|
13218
|
+
return parseProviderCompletionExitCode(raw, completionBinding) === void 0 ? "invalid" : "valid";
|
|
13219
|
+
}
|
|
13086
13220
|
async function readWorkerLaunchTerminalState(attempt, started) {
|
|
13087
13221
|
const terminal = await readJson(`${attempt.startedPath}.terminal`);
|
|
13088
13222
|
if (terminal.kind === "absent") return "absent";
|
|
@@ -13106,6 +13240,96 @@ async function readWorkerLaunchTerminalState(attempt, started) {
|
|
|
13106
13240
|
if (value.child_reaped === false && value.outcome === "cleanup_unverified" && value.cleanup_verified === false) return "live-unreaped";
|
|
13107
13241
|
return "invalid";
|
|
13108
13242
|
}
|
|
13243
|
+
async function readWorkerLaunchTerminationProofState(attempt, started) {
|
|
13244
|
+
const completed = await readJson(`${attempt.startedPath}.termination-complete`);
|
|
13245
|
+
if (completed.kind === "absent") return "absent";
|
|
13246
|
+
if (completed.kind !== "value") return "invalid";
|
|
13247
|
+
if (!completed.value || typeof completed.value !== "object" || Array.isArray(completed.value)) return "invalid";
|
|
13248
|
+
const value = completed.value;
|
|
13249
|
+
const processGroupMatches = process.platform === "win32" || Number.isSafeInteger(started.process_group_id) && Number(started.process_group_id) > 0 && value.process_group_id === started.process_group_id;
|
|
13250
|
+
return identityMatches(value, attempt) && value.kind === "worker_launch_termination_complete" && value.cleanup_verified === true && value.pid === started.pid && Number.isSafeInteger(value.pid) && Number(value.pid) > 0 && value.process_start_identity === started.process_start_identity && isValidProcessStartIdentity2(value.process_start_identity) && processGroupMatches ? "valid" : "invalid";
|
|
13251
|
+
}
|
|
13252
|
+
async function observeWorkerLaunchProvider(attempt) {
|
|
13253
|
+
try {
|
|
13254
|
+
if (!isValidIdentity(attempt)) return "unknown";
|
|
13255
|
+
const expected = await readJson(attempt.expectedPath);
|
|
13256
|
+
if (expected.kind !== "value" || !identityMatches(expected.value, attempt)) return "unknown";
|
|
13257
|
+
const acknowledgement = await readJson(attempt.ackPath);
|
|
13258
|
+
if (!isValidWorkerLaunchAcknowledgement(acknowledgement, attempt)) return "unknown";
|
|
13259
|
+
const current = await readJson(attempt.currentPath);
|
|
13260
|
+
if (current.kind === "malformed" || current.kind === "value" && !identityMatches(current.value, attempt)) return "unknown";
|
|
13261
|
+
const decision = await readJson(attempt.decisionPath);
|
|
13262
|
+
if (decision.kind === "malformed" || decision.kind === "value" && (!identityMatches(decision.value, attempt) || decision.value.kind !== "worker_launch_decision")) {
|
|
13263
|
+
return "unknown";
|
|
13264
|
+
}
|
|
13265
|
+
const retirement = await readWorkerLaunchRetirementState(attempt);
|
|
13266
|
+
if (retirement === "invalid") return "unknown";
|
|
13267
|
+
const retirementCleanup = await readWorkerLaunchRetirementCleanupState(attempt);
|
|
13268
|
+
if (retirementCleanup === "invalid") return "unknown";
|
|
13269
|
+
if (retirementCleanup === "valid") {
|
|
13270
|
+
if (current.kind !== "absent" || decision.kind !== "value" || !identityMatches(decision.value, attempt) || decision.value.kind !== "worker_launch_decision" || decision.value.decision !== "accepted" || !await isWorkerLaunchAttemptAccepted(attempt)) return "unknown";
|
|
13271
|
+
return "dead";
|
|
13272
|
+
}
|
|
13273
|
+
if (retirement === "valid") return "unknown";
|
|
13274
|
+
if (current.kind !== "value" || decision.kind !== "value" || decision.value.decision !== "accepted" || !await isWorkerLaunchAttemptAccepted(attempt)) return "unknown";
|
|
13275
|
+
const started = await readValidProviderStarted(attempt, {
|
|
13276
|
+
allowSupervisorCompletion: true,
|
|
13277
|
+
allowTerminal: true
|
|
13278
|
+
});
|
|
13279
|
+
const startedPid = started?.pid;
|
|
13280
|
+
if (!started || !isPositiveProcessId(startedPid) || !isValidProcessStartIdentity2(started.process_start_identity)) return "unknown";
|
|
13281
|
+
const completionState = await readWorkerLaunchProviderCompletionState(attempt, started);
|
|
13282
|
+
if (completionState === "invalid") return "unknown";
|
|
13283
|
+
const terminalState = await readWorkerLaunchTerminalState(attempt, started);
|
|
13284
|
+
if (terminalState === "invalid") return "unknown";
|
|
13285
|
+
const terminationProof = await readWorkerLaunchTerminationProofState(attempt, started);
|
|
13286
|
+
if (terminationProof === "invalid") return "unknown";
|
|
13287
|
+
if (terminalState === "reaped" || terminationProof === "valid") return "dead";
|
|
13288
|
+
const liveness = await isProcessIdentityLive(startedPid, started.process_start_identity);
|
|
13289
|
+
const finalExpected = await readJson(attempt.expectedPath);
|
|
13290
|
+
if (finalExpected.kind !== "value" || !identityMatches(finalExpected.value, attempt)) return "unknown";
|
|
13291
|
+
const finalAcknowledgement = await readJson(attempt.ackPath);
|
|
13292
|
+
if (!isValidWorkerLaunchAcknowledgement(finalAcknowledgement, attempt)) return "unknown";
|
|
13293
|
+
const finalRetirement = await readWorkerLaunchRetirementState(attempt);
|
|
13294
|
+
if (finalRetirement === "invalid") return "unknown";
|
|
13295
|
+
const finalRetirementCleanup = await readWorkerLaunchRetirementCleanupState(attempt);
|
|
13296
|
+
if (finalRetirementCleanup === "invalid") return "unknown";
|
|
13297
|
+
if (finalRetirementCleanup === "valid") {
|
|
13298
|
+
const finalCurrent2 = await readJson(attempt.currentPath);
|
|
13299
|
+
if (finalCurrent2.kind !== "absent") return "unknown";
|
|
13300
|
+
const finalDecision2 = await readJson(attempt.decisionPath);
|
|
13301
|
+
if (finalDecision2.kind !== "value" || !identityMatches(finalDecision2.value, attempt) || finalDecision2.value.kind !== "worker_launch_decision" || finalDecision2.value.decision !== "accepted" || !await isWorkerLaunchAttemptAccepted(attempt)) return "unknown";
|
|
13302
|
+
return "dead";
|
|
13303
|
+
}
|
|
13304
|
+
if (finalRetirement === "valid") return "unknown";
|
|
13305
|
+
const finalCurrent = await readJson(attempt.currentPath);
|
|
13306
|
+
if (finalCurrent.kind !== "value" || !identityMatches(finalCurrent.value, attempt)) return "unknown";
|
|
13307
|
+
const finalDecision = await readJson(attempt.decisionPath);
|
|
13308
|
+
if (finalDecision.kind !== "value" || !identityMatches(finalDecision.value, attempt) || finalDecision.value.kind !== "worker_launch_decision" || finalDecision.value.decision !== "accepted" || !await isWorkerLaunchAttemptAccepted(attempt)) return "unknown";
|
|
13309
|
+
const finalStarted = await readValidProviderStarted(attempt, {
|
|
13310
|
+
allowSupervisorCompletion: true,
|
|
13311
|
+
allowTerminal: true
|
|
13312
|
+
});
|
|
13313
|
+
const finalStartedPid = finalStarted?.pid;
|
|
13314
|
+
if (!finalStarted || !isPositiveProcessId(finalStartedPid) || finalStartedPid !== startedPid || finalStarted.process_start_identity !== started.process_start_identity) return "unknown";
|
|
13315
|
+
const finalTerminalState = await readWorkerLaunchTerminalState(attempt, finalStarted);
|
|
13316
|
+
if (finalTerminalState === "invalid") return "unknown";
|
|
13317
|
+
const finalTerminationProof = await readWorkerLaunchTerminationProofState(attempt, finalStarted);
|
|
13318
|
+
if (finalTerminationProof === "invalid") return "unknown";
|
|
13319
|
+
if (finalTerminalState === "reaped" || finalTerminationProof === "valid") return "dead";
|
|
13320
|
+
const finalCompletionState = await readWorkerLaunchProviderCompletionState(attempt, finalStarted);
|
|
13321
|
+
if (finalCompletionState === "invalid") return "unknown";
|
|
13322
|
+
if (completionState === "valid" || finalCompletionState === "valid") return "dead";
|
|
13323
|
+
let finalLiveness = liveness;
|
|
13324
|
+
if (liveness === "live") {
|
|
13325
|
+
const recheck = await isProcessIdentityLive(finalStartedPid, finalStarted.process_start_identity);
|
|
13326
|
+
finalLiveness = recheck === "live" || recheck === "dead" ? recheck : "unknown";
|
|
13327
|
+
}
|
|
13328
|
+
return finalLiveness === "live" ? "alive" : finalLiveness === "dead" ? "dead" : "unknown";
|
|
13329
|
+
} catch {
|
|
13330
|
+
return "unknown";
|
|
13331
|
+
}
|
|
13332
|
+
}
|
|
13109
13333
|
async function terminateWorkerLaunchProvider(attempt, timeoutMs = 2e3) {
|
|
13110
13334
|
const started = await readJson(attempt.startedPath);
|
|
13111
13335
|
const terminalCleanupVerified = await readWorkerLaunchCleanupProof(
|
|
@@ -13275,7 +13499,7 @@ function quoteWindowsCmdArgument(value) {
|
|
|
13275
13499
|
if (/[\r\n]/.test(value)) throw new Error("worker_launch_provider_argv_invalid");
|
|
13276
13500
|
return `"${value.replace(/%/g, "%%").replace(/"/g, '""')}"`;
|
|
13277
13501
|
}
|
|
13278
|
-
var import_node_crypto5, import_node_fs4, import_promises8, import_node_path4, WORKER_LAUNCH_SCHEMA_VERSION, DEFAULT_ACK_TIMEOUT_MS, DEFAULT_POLL_INTERVAL_MS, DEFAULT_DECISION_TIMEOUT_MS, WORKER_LAUNCH_TRANSPORT_OWNER_KIND, WORKER_LAUNCH_TRANSPORT_CLEANUP_KIND, WORKER_LAUNCH_BOOTSTRAP_DESCRIPTOR_FILE, WORKER_LAUNCH_RECOVERY_GATE_CONTAINED_ENV, WORKER_LAUNCH_INTERNAL_ENV_KEYS, WORKER_LAUNCH_AUTHORITY_PROTOCOL, WINDOWS_SUPERVISOR_PROTOCOL, WINDOWS_RESERVED_ENV_KEYS, SAFE_BASELINE_ENV_KEYS, WINDOWS_BASELINE_ENV_KEYS;
|
|
13502
|
+
var import_node_crypto5, import_node_fs4, import_promises8, import_node_path4, import_node_os, WORKER_LAUNCH_SCHEMA_VERSION, DEFAULT_ACK_TIMEOUT_MS, DEFAULT_POLL_INTERVAL_MS, DEFAULT_DECISION_TIMEOUT_MS, WORKER_LAUNCH_TRANSPORT_OWNER_KIND, WORKER_LAUNCH_TRANSPORT_CLEANUP_KIND, WORKER_LAUNCH_BOOTSTRAP_DESCRIPTOR_FILE, WORKER_LAUNCH_RECOVERY_GATE_CONTAINED_ENV, WORKER_LAUNCH_INTERNAL_ENV_KEYS, WORKER_LAUNCH_AUTHORITY_PROTOCOL, WINDOWS_SUPERVISOR_PROTOCOL, WINDOWS_RESERVED_ENV_KEYS, SAFE_BASELINE_ENV_KEYS, WINDOWS_BASELINE_ENV_KEYS;
|
|
13279
13503
|
var init_worker_launch_ack = __esm({
|
|
13280
13504
|
"src/team/worker-launch-ack.ts"() {
|
|
13281
13505
|
"use strict";
|
|
@@ -13283,6 +13507,7 @@ var init_worker_launch_ack = __esm({
|
|
|
13283
13507
|
import_node_fs4 = require("node:fs");
|
|
13284
13508
|
import_promises8 = require("node:fs/promises");
|
|
13285
13509
|
import_node_path4 = require("node:path");
|
|
13510
|
+
import_node_os = require("node:os");
|
|
13286
13511
|
init_process_utils();
|
|
13287
13512
|
init_types2();
|
|
13288
13513
|
init_state_paths();
|
|
@@ -13433,7 +13658,8 @@ __export(tmux_session_exports, {
|
|
|
13433
13658
|
waitForPaneReady: () => waitForPaneReady,
|
|
13434
13659
|
waitForStartupPaneReady: () => waitForStartupPaneReady,
|
|
13435
13660
|
workerPaneBelongsToOwnedProviderTarget: () => workerPaneBelongsToOwnedProviderTarget,
|
|
13436
|
-
workerPaneBelongsToProviderTarget: () => workerPaneBelongsToProviderTarget
|
|
13661
|
+
workerPaneBelongsToProviderTarget: () => workerPaneBelongsToProviderTarget,
|
|
13662
|
+
workerPaneShellCommand: () => workerPaneShellCommand
|
|
13437
13663
|
});
|
|
13438
13664
|
function tmuxArgsForIdentity(identity, args) {
|
|
13439
13665
|
return ["-S", identity.socket_path, ...args];
|
|
@@ -14308,23 +14534,66 @@ async function verifyWorkerStartCommandSubmitted(paneId, startCmd, opts = {}) {
|
|
|
14308
14534
|
}
|
|
14309
14535
|
return false;
|
|
14310
14536
|
}
|
|
14537
|
+
function writePaneEnvFile(values) {
|
|
14538
|
+
const directory = (0, import_fs22.mkdtempSync)((0, import_path24.join)((0, import_os7.tmpdir)(), "omc-pane-env-"));
|
|
14539
|
+
const file = (0, import_path24.join)(directory, "env");
|
|
14540
|
+
const body = Object.entries(values).map(([key, value]) => `export ${key}=${shellQuote(value)}
|
|
14541
|
+
`).join("");
|
|
14542
|
+
(0, import_fs22.writeFileSync)(file, body, { mode: 384, flag: "wx" });
|
|
14543
|
+
return file;
|
|
14544
|
+
}
|
|
14545
|
+
function discardPaneEnvFile(envFile) {
|
|
14546
|
+
if (!envFile) return;
|
|
14547
|
+
(0, import_fs22.rmSync)((0, import_path24.dirname)(envFile), { recursive: true, force: true });
|
|
14548
|
+
}
|
|
14311
14549
|
function workerPaneShellCommand() {
|
|
14312
14550
|
if (process.platform === "win32" && !isUnixLikeOnWindows()) {
|
|
14313
|
-
return [getDefaultShell()];
|
|
14551
|
+
return { args: [getDefaultShell()], envFile: null };
|
|
14314
14552
|
}
|
|
14315
|
-
if (process.platform === "win32") return [];
|
|
14553
|
+
if (process.platform === "win32") return { args: [], envFile: null };
|
|
14316
14554
|
const shell = getDefaultShell();
|
|
14317
14555
|
const baseline = buildProviderEnvironment({ SHELL: shell });
|
|
14556
|
+
const inline = buildProviderEnvironment({ SHELL: shell }, process.env, process.platform, []);
|
|
14557
|
+
const passthrough = Object.fromEntries(
|
|
14558
|
+
Object.entries(baseline).filter(([key, value]) => inline[key] !== value)
|
|
14559
|
+
);
|
|
14318
14560
|
const inheritedPaneEnvironment = ["TERM", "TMUX", "TMUX_PANE", "TMUX_TMPDIR", "LANG", "LC_ALL", "LC_CTYPE"].map((key) => `${key}="$${key}"`);
|
|
14561
|
+
const inlineAssignments = Object.entries(inline).map(([key, value]) => `${key}=${shellQuote(value)}`);
|
|
14562
|
+
if (Object.keys(passthrough).length === 0) {
|
|
14563
|
+
const command2 = [
|
|
14564
|
+
"/usr/bin/env",
|
|
14565
|
+
"-i",
|
|
14566
|
+
...inlineAssignments,
|
|
14567
|
+
...inheritedPaneEnvironment,
|
|
14568
|
+
shellQuote(shell),
|
|
14569
|
+
"-l"
|
|
14570
|
+
].join(" ");
|
|
14571
|
+
return { args: [command2], envFile: null };
|
|
14572
|
+
}
|
|
14573
|
+
const envFile = writePaneEnvFile(passthrough);
|
|
14574
|
+
const bootstrap = '. "$OMC_PANE_ENV_FILE" && rm -rf -- "${OMC_PANE_ENV_FILE%/*}" && unset OMC_PANE_ENV_FILE && exec "$SHELL" -l';
|
|
14319
14575
|
const command = [
|
|
14320
14576
|
"/usr/bin/env",
|
|
14321
14577
|
"-i",
|
|
14322
|
-
...
|
|
14578
|
+
...inlineAssignments,
|
|
14579
|
+
`OMC_PANE_ENV_FILE=${shellQuote(envFile)}`,
|
|
14323
14580
|
...inheritedPaneEnvironment,
|
|
14324
|
-
|
|
14325
|
-
"-
|
|
14581
|
+
"/bin/sh",
|
|
14582
|
+
"-c",
|
|
14583
|
+
shellQuote(bootstrap)
|
|
14326
14584
|
].join(" ");
|
|
14327
|
-
return [command];
|
|
14585
|
+
return { args: [command], envFile };
|
|
14586
|
+
}
|
|
14587
|
+
async function runPaneCreationCommand(identity, nativeCommand, paneShell) {
|
|
14588
|
+
let result;
|
|
14589
|
+
try {
|
|
14590
|
+
result = await runGuardedNativeTmuxCommand(identity, nativeCommand);
|
|
14591
|
+
} catch (error2) {
|
|
14592
|
+
discardPaneEnvFile(paneShell.envFile);
|
|
14593
|
+
throw error2;
|
|
14594
|
+
}
|
|
14595
|
+
if (result.outcome === "not_executed") discardPaneEnvFile(paneShell.envFile);
|
|
14596
|
+
return result;
|
|
14328
14597
|
}
|
|
14329
14598
|
function escapeForCmdSet(value) {
|
|
14330
14599
|
return value.replace(/(["%])/g, "$1$1");
|
|
@@ -14623,6 +14892,7 @@ async function splitTeamWorkerPaneWithEvidence(splitTarget, direction, cwd, prov
|
|
|
14623
14892
|
};
|
|
14624
14893
|
}
|
|
14625
14894
|
const splitType = direction === "right" ? "-h" : "-v";
|
|
14895
|
+
const splitPaneShell = workerPaneShellCommand();
|
|
14626
14896
|
const splitArgs = [
|
|
14627
14897
|
"split-window",
|
|
14628
14898
|
splitType,
|
|
@@ -14634,11 +14904,12 @@ async function splitTeamWorkerPaneWithEvidence(splitTarget, direction, cwd, prov
|
|
|
14634
14904
|
"#{pane_id} #{socket_path} #{pid}",
|
|
14635
14905
|
"-c",
|
|
14636
14906
|
cwd,
|
|
14637
|
-
...
|
|
14907
|
+
...splitPaneShell.args
|
|
14638
14908
|
];
|
|
14639
|
-
const splitResult = await
|
|
14909
|
+
const splitResult = await runPaneCreationCommand(
|
|
14640
14910
|
identity,
|
|
14641
|
-
tmuxCommandString(splitArgs, ["#{pane_id} #{socket_path} #{pid}"])
|
|
14911
|
+
tmuxCommandString(splitArgs, ["#{pane_id} #{socket_path} #{pid}"]),
|
|
14912
|
+
splitPaneShell
|
|
14642
14913
|
);
|
|
14643
14914
|
const parsed = splitResult.outcome === "executed" ? parseTmuxCreationRecord(
|
|
14644
14915
|
splitResult.stdout,
|
|
@@ -14740,6 +15011,7 @@ async function createTeamSession(teamName, workerCount, cwd, options = {}) {
|
|
|
14740
15011
|
sessionMode: "detached-session",
|
|
14741
15012
|
...tmuxServerIdentity ? { tmuxServerIdentity: { ...tmuxServerIdentity } } : {}
|
|
14742
15013
|
});
|
|
15014
|
+
const detachedPaneShell = workerPaneShellCommand();
|
|
14743
15015
|
const detachedArgs = [
|
|
14744
15016
|
"new-session",
|
|
14745
15017
|
"-d",
|
|
@@ -14750,7 +15022,7 @@ async function createTeamSession(teamName, workerCount, cwd, options = {}) {
|
|
|
14750
15022
|
detachedSessionName,
|
|
14751
15023
|
"-c",
|
|
14752
15024
|
cwd,
|
|
14753
|
-
...
|
|
15025
|
+
...detachedPaneShell.args
|
|
14754
15026
|
];
|
|
14755
15027
|
const cleanupFreshDetachedServer = async () => {
|
|
14756
15028
|
if (isPsmux() && freshSocketPathForEvidence) {
|
|
@@ -14779,9 +15051,10 @@ async function createTeamSession(teamName, workerCount, cwd, options = {}) {
|
|
|
14779
15051
|
if (existingDetachedIdentity) {
|
|
14780
15052
|
tmuxServerIdentity = existingDetachedIdentity;
|
|
14781
15053
|
try {
|
|
14782
|
-
detachedResult = await
|
|
15054
|
+
detachedResult = await runPaneCreationCommand(
|
|
14783
15055
|
existingDetachedIdentity,
|
|
14784
|
-
tmuxCommandString(detachedArgs, ["#S:0 #{pane_id} #{socket_path} #{pid}"])
|
|
15056
|
+
tmuxCommandString(detachedArgs, ["#S:0 #{pane_id} #{socket_path} #{pid}"]),
|
|
15057
|
+
detachedPaneShell
|
|
14785
15058
|
);
|
|
14786
15059
|
} catch (error2) {
|
|
14787
15060
|
const cleaned = await cleanupDetachedSession();
|
|
@@ -14841,11 +15114,13 @@ async function createTeamSession(teamName, workerCount, cwd, options = {}) {
|
|
|
14841
15114
|
throw new Error("tmux_server_identity_unavailable");
|
|
14842
15115
|
}
|
|
14843
15116
|
freshDetachedServerIdentity = tmuxServerIdentity;
|
|
14844
|
-
detachedResult = await
|
|
15117
|
+
detachedResult = await runPaneCreationCommand(
|
|
14845
15118
|
tmuxServerIdentity,
|
|
14846
|
-
tmuxCommandString(detachedArgs, ["#S:0 #{pane_id} #{socket_path} #{pid}"])
|
|
15119
|
+
tmuxCommandString(detachedArgs, ["#S:0 #{pane_id} #{socket_path} #{pid}"]),
|
|
15120
|
+
detachedPaneShell
|
|
14847
15121
|
);
|
|
14848
15122
|
} catch (error2) {
|
|
15123
|
+
discardPaneEnvFile(detachedPaneShell.envFile);
|
|
14849
15124
|
const cleaned = await cleanupDetachedSession();
|
|
14850
15125
|
if (!cleaned && freshDetachedServerStarted) {
|
|
14851
15126
|
throw new TeamSessionCreationError(
|
|
@@ -15025,6 +15300,7 @@ async function createTeamSession(teamName, workerCount, cwd, options = {}) {
|
|
|
15025
15300
|
if (useDedicatedWindow) {
|
|
15026
15301
|
const targetSession = sessionAndWindow.split(":")[0] ?? sessionAndWindow;
|
|
15027
15302
|
const windowName = `omc-${sanitizeName(teamName)}`.slice(0, 32);
|
|
15303
|
+
const newWindowPaneShell = workerPaneShellCommand();
|
|
15028
15304
|
const newWindowArgs = [
|
|
15029
15305
|
"new-window",
|
|
15030
15306
|
"-d",
|
|
@@ -15037,13 +15313,14 @@ async function createTeamSession(teamName, workerCount, cwd, options = {}) {
|
|
|
15037
15313
|
windowName,
|
|
15038
15314
|
"-c",
|
|
15039
15315
|
cwd,
|
|
15040
|
-
...
|
|
15316
|
+
...newWindowPaneShell.args
|
|
15041
15317
|
];
|
|
15042
15318
|
let newWindowResult;
|
|
15043
15319
|
try {
|
|
15044
|
-
newWindowResult = await
|
|
15320
|
+
newWindowResult = await runPaneCreationCommand(
|
|
15045
15321
|
tmuxServerIdentity,
|
|
15046
|
-
tmuxCommandString(newWindowArgs, ["#S:#I #{pane_id} #{socket_path} #{pid}"])
|
|
15322
|
+
tmuxCommandString(newWindowArgs, ["#S:#I #{pane_id} #{socket_path} #{pid}"]),
|
|
15323
|
+
newWindowPaneShell
|
|
15047
15324
|
);
|
|
15048
15325
|
} catch (error2) {
|
|
15049
15326
|
const creationError = new TeamSessionCreationError(
|
|
@@ -15193,6 +15470,7 @@ async function createTeamSession(teamName, workerCount, cwd, options = {}) {
|
|
|
15193
15470
|
continue;
|
|
15194
15471
|
}
|
|
15195
15472
|
const splitType = i === 0 ? "-h" : "-v";
|
|
15473
|
+
const splitPaneShell = workerPaneShellCommand();
|
|
15196
15474
|
const splitArgs = [
|
|
15197
15475
|
"split-window",
|
|
15198
15476
|
splitType,
|
|
@@ -15204,11 +15482,12 @@ async function createTeamSession(teamName, workerCount, cwd, options = {}) {
|
|
|
15204
15482
|
"#{pane_id} #{socket_path} #{pid}",
|
|
15205
15483
|
"-c",
|
|
15206
15484
|
cwd,
|
|
15207
|
-
...
|
|
15485
|
+
...splitPaneShell.args
|
|
15208
15486
|
];
|
|
15209
|
-
const splitResult = await
|
|
15487
|
+
const splitResult = await runPaneCreationCommand(
|
|
15210
15488
|
tmuxServerIdentity,
|
|
15211
|
-
tmuxCommandString(splitArgs, ["#{pane_id} #{socket_path} #{pid}"])
|
|
15489
|
+
tmuxCommandString(splitArgs, ["#{pane_id} #{socket_path} #{pid}"]),
|
|
15490
|
+
splitPaneShell
|
|
15212
15491
|
);
|
|
15213
15492
|
if (splitResult.outcome !== "executed") {
|
|
15214
15493
|
const creationError = new TeamSessionCreationError(
|
|
@@ -16500,8 +16779,8 @@ function getPackageDir3() {
|
|
|
16500
16779
|
}
|
|
16501
16780
|
}
|
|
16502
16781
|
try {
|
|
16503
|
-
const
|
|
16504
|
-
const __dirname2 = (0, import_path25.dirname)(
|
|
16782
|
+
const __filename2 = (0, import_url4.fileURLToPath)(importMetaUrl);
|
|
16783
|
+
const __dirname2 = (0, import_path25.dirname)(__filename2);
|
|
16505
16784
|
const currentDirName = (0, import_path25.basename)(__dirname2);
|
|
16506
16785
|
if (currentDirName === "bridge") {
|
|
16507
16786
|
return (0, import_path25.join)(__dirname2, "..");
|
|
@@ -16905,7 +17184,7 @@ function assertSafeBoundary(path5, label) {
|
|
|
16905
17184
|
}
|
|
16906
17185
|
const resolved = realpathOrResolve(trimmed);
|
|
16907
17186
|
const root = (0, import_node_path6.parse)(resolved).root;
|
|
16908
|
-
const home = realpathOrResolve((0,
|
|
17187
|
+
const home = realpathOrResolve((0, import_node_os2.homedir)());
|
|
16909
17188
|
if (resolved === root) {
|
|
16910
17189
|
throw new Error(`${label}_is_filesystem_root:${resolved}`);
|
|
16911
17190
|
}
|
|
@@ -16967,12 +17246,12 @@ function validateWorktreeRemovalTarget(options) {
|
|
|
16967
17246
|
}
|
|
16968
17247
|
return { resolvedPath, matchedRoot };
|
|
16969
17248
|
}
|
|
16970
|
-
var import_node_fs5,
|
|
17249
|
+
var import_node_fs5, import_node_os2, import_node_path6;
|
|
16971
17250
|
var init_worktree_cleanup_safety = __esm({
|
|
16972
17251
|
"src/lib/worktree-cleanup-safety.ts"() {
|
|
16973
17252
|
"use strict";
|
|
16974
17253
|
import_node_fs5 = require("node:fs");
|
|
16975
|
-
|
|
17254
|
+
import_node_os2 = require("node:os");
|
|
16976
17255
|
import_node_path6 = require("node:path");
|
|
16977
17256
|
}
|
|
16978
17257
|
});
|
|
@@ -17417,6 +17696,131 @@ var init_merge_orchestrator = __esm({
|
|
|
17417
17696
|
}
|
|
17418
17697
|
});
|
|
17419
17698
|
|
|
17699
|
+
// src/team/sdk-transport.ts
|
|
17700
|
+
function isSdkTarget(value) {
|
|
17701
|
+
return typeof value === "string" && value.startsWith(SDK_TARGET_PREFIX);
|
|
17702
|
+
}
|
|
17703
|
+
function sdkWorkerFiles(stateRoot, workerName) {
|
|
17704
|
+
const dir = (0, import_node_path8.join)(stateRoot, "workers", workerName);
|
|
17705
|
+
return {
|
|
17706
|
+
dir,
|
|
17707
|
+
spec: (0, import_node_path8.join)(dir, "sdk-host-spec.json"),
|
|
17708
|
+
doorbell: (0, import_node_path8.join)(dir, "sdk-doorbell.jsonl"),
|
|
17709
|
+
session: (0, import_node_path8.join)(dir, "sdk-session.json"),
|
|
17710
|
+
probe: (0, import_node_path8.join)(dir, "sdk-probe.json"),
|
|
17711
|
+
events: (0, import_node_path8.join)(dir, "sdk-events.jsonl"),
|
|
17712
|
+
log: (0, import_node_path8.join)(dir, "sdk-host.log"),
|
|
17713
|
+
home: (0, import_node_path8.join)(dir, "copilot-home"),
|
|
17714
|
+
bin: (0, import_node_path8.join)(dir, "bin"),
|
|
17715
|
+
shutdownAck: (0, import_node_path8.join)(dir, "shutdown-ack.json")
|
|
17716
|
+
};
|
|
17717
|
+
}
|
|
17718
|
+
function ringDoorbell(stateRoot, workerName, entry) {
|
|
17719
|
+
const files = sdkWorkerFiles(stateRoot, workerName);
|
|
17720
|
+
(0, import_node_fs7.mkdirSync)(files.dir, { recursive: true });
|
|
17721
|
+
const id = entry.id ?? (0, import_node_crypto6.randomUUID)();
|
|
17722
|
+
const line = { ...entry, id, at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
17723
|
+
(0, import_node_fs7.appendFileSync)(files.doorbell, `${JSON.stringify(line)}
|
|
17724
|
+
`);
|
|
17725
|
+
return id;
|
|
17726
|
+
}
|
|
17727
|
+
function readSdkSession(stateRoot, workerName) {
|
|
17728
|
+
try {
|
|
17729
|
+
const parsed = JSON.parse((0, import_node_fs7.readFileSync)(sdkWorkerFiles(stateRoot, workerName).session, "utf8"));
|
|
17730
|
+
return parsed && parsed.schema_version === 1 ? parsed : null;
|
|
17731
|
+
} catch {
|
|
17732
|
+
return null;
|
|
17733
|
+
}
|
|
17734
|
+
}
|
|
17735
|
+
async function isTargetGone(target) {
|
|
17736
|
+
if (!target.identity) return !isProcessAlive(target.pid);
|
|
17737
|
+
const liveness = await isProcessIdentityLive(target.pid, target.identity);
|
|
17738
|
+
return liveness === "dead" || liveness === "mismatch";
|
|
17739
|
+
}
|
|
17740
|
+
function failedBeforeProviderStarted(attempt, stateRoot) {
|
|
17741
|
+
if ((0, import_node_fs7.existsSync)(attempt.startedPath)) return false;
|
|
17742
|
+
const session = readSdkSession(stateRoot, attempt.worker_name);
|
|
17743
|
+
return session?.attempt_id === attempt.attempt_id && session.state === "failed";
|
|
17744
|
+
}
|
|
17745
|
+
async function stopSdkHost(attempt, stateRoot, opts = {}) {
|
|
17746
|
+
const pollMs = opts.pollMs ?? 250;
|
|
17747
|
+
const exited = async () => failedBeforeProviderStarted(attempt, stateRoot) || await observeWorkerLaunchProvider(attempt) === "dead";
|
|
17748
|
+
if (await exited()) return true;
|
|
17749
|
+
ringDoorbell(stateRoot, attempt.worker_name, { kind: opts.kind ?? "stop", from: "leader-fixed" });
|
|
17750
|
+
const deadline = Date.now() + (opts.timeoutMs ?? 45e3);
|
|
17751
|
+
while (Date.now() < deadline) {
|
|
17752
|
+
if (await exited()) return true;
|
|
17753
|
+
await new Promise((r) => setTimeout(r, pollMs));
|
|
17754
|
+
}
|
|
17755
|
+
const started = readStartedRecord(attempt);
|
|
17756
|
+
const session = readSdkSession(stateRoot, attempt.worker_name);
|
|
17757
|
+
const targets = [];
|
|
17758
|
+
if (started) targets.push({ pid: started.pid, identity: started.process_start_identity });
|
|
17759
|
+
if (session?.attempt_id === attempt.attempt_id && session.runtime_pid && session.runtime_pid > 0) {
|
|
17760
|
+
targets.push({ pid: session.runtime_pid, identity: session.runtime_start_identity ?? null });
|
|
17761
|
+
}
|
|
17762
|
+
for (const target of targets) {
|
|
17763
|
+
if (target.identity && await isProcessIdentityLive(target.pid, target.identity) === "live") {
|
|
17764
|
+
await killProcessTree(target.pid, "SIGKILL").catch(() => void 0);
|
|
17765
|
+
}
|
|
17766
|
+
}
|
|
17767
|
+
const killDeadline = Date.now() + 5e3;
|
|
17768
|
+
for (; ; ) {
|
|
17769
|
+
if ((await Promise.all(targets.map(isTargetGone))).every(Boolean)) {
|
|
17770
|
+
if (started) writeTerminationComplete(attempt, started.pid, started.process_start_identity);
|
|
17771
|
+
return true;
|
|
17772
|
+
}
|
|
17773
|
+
if (Date.now() >= killDeadline) return false;
|
|
17774
|
+
await new Promise((r) => setTimeout(r, pollMs));
|
|
17775
|
+
}
|
|
17776
|
+
}
|
|
17777
|
+
function readStartedRecord(attempt) {
|
|
17778
|
+
try {
|
|
17779
|
+
const record2 = JSON.parse((0, import_node_fs7.readFileSync)(attempt.startedPath, "utf8"));
|
|
17780
|
+
return typeof record2.pid === "number" && record2.pid > 0 && typeof record2.process_start_identity === "string" ? { pid: record2.pid, process_start_identity: record2.process_start_identity } : null;
|
|
17781
|
+
} catch {
|
|
17782
|
+
return null;
|
|
17783
|
+
}
|
|
17784
|
+
}
|
|
17785
|
+
function writeTerminationComplete(attempt, pid, startIdentity) {
|
|
17786
|
+
const path5 = `${attempt.startedPath}.termination-complete`;
|
|
17787
|
+
if ((0, import_node_fs7.existsSync)(path5)) return;
|
|
17788
|
+
try {
|
|
17789
|
+
(0, import_node_fs7.writeFileSync)(path5, JSON.stringify({
|
|
17790
|
+
schema_version: attempt.schema_version,
|
|
17791
|
+
attempt_id: attempt.attempt_id,
|
|
17792
|
+
nonce: attempt.nonce,
|
|
17793
|
+
instance_id: attempt.instance_id,
|
|
17794
|
+
team_name: attempt.team_name,
|
|
17795
|
+
worker_name: attempt.worker_name,
|
|
17796
|
+
pane_id: attempt.pane_id,
|
|
17797
|
+
provider: attempt.provider,
|
|
17798
|
+
created_at: attempt.created_at,
|
|
17799
|
+
kind: "worker_launch_termination_complete",
|
|
17800
|
+
cleanup_verified: true,
|
|
17801
|
+
pid,
|
|
17802
|
+
process_start_identity: startIdentity,
|
|
17803
|
+
...process.platform === "win32" ? {} : { process_group_id: pid },
|
|
17804
|
+
written_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
17805
|
+
}), { flag: "wx" });
|
|
17806
|
+
} catch {
|
|
17807
|
+
}
|
|
17808
|
+
}
|
|
17809
|
+
var import_node_crypto6, import_node_fs7, import_node_path8, SDK_TARGET_PREFIX, SDK_HOST_STOP_FLOOR_MS;
|
|
17810
|
+
var init_sdk_transport = __esm({
|
|
17811
|
+
"src/team/sdk-transport.ts"() {
|
|
17812
|
+
"use strict";
|
|
17813
|
+
import_node_crypto6 = require("node:crypto");
|
|
17814
|
+
import_node_fs7 = require("node:fs");
|
|
17815
|
+
import_node_path8 = require("node:path");
|
|
17816
|
+
init_process_utils();
|
|
17817
|
+
init_runtime_owner_client();
|
|
17818
|
+
init_worker_launch_ack();
|
|
17819
|
+
SDK_TARGET_PREFIX = "sdk:";
|
|
17820
|
+
SDK_HOST_STOP_FLOOR_MS = 5e3;
|
|
17821
|
+
}
|
|
17822
|
+
});
|
|
17823
|
+
|
|
17420
17824
|
// src/team/scaling.ts
|
|
17421
17825
|
var import_path32, import_promises14;
|
|
17422
17826
|
var init_scaling = __esm({
|
|
@@ -17436,6 +17840,7 @@ var init_scaling = __esm({
|
|
|
17436
17840
|
init_tmux_session();
|
|
17437
17841
|
init_state_paths();
|
|
17438
17842
|
init_worker_bootstrap();
|
|
17843
|
+
init_sdk_transport();
|
|
17439
17844
|
init_git_worktree();
|
|
17440
17845
|
init_worktree_paths();
|
|
17441
17846
|
init_team_owner_epoch();
|
|
@@ -17462,6 +17867,157 @@ var init_worker_activation_gate = __esm({
|
|
|
17462
17867
|
}
|
|
17463
17868
|
});
|
|
17464
17869
|
|
|
17870
|
+
// src/smoke/copilot-session-eval.ts
|
|
17871
|
+
var import_fs28, import_path33, SMOKE_TOKEN;
|
|
17872
|
+
var init_copilot_session_eval = __esm({
|
|
17873
|
+
"src/smoke/copilot-session-eval.ts"() {
|
|
17874
|
+
"use strict";
|
|
17875
|
+
import_fs28 = require("fs");
|
|
17876
|
+
import_path33 = require("path");
|
|
17877
|
+
SMOKE_TOKEN = "SMOKE_OK";
|
|
17878
|
+
}
|
|
17879
|
+
});
|
|
17880
|
+
|
|
17881
|
+
// src/smoke/copilot-sdk-scenarios.ts
|
|
17882
|
+
function samePathKey(p, platform) {
|
|
17883
|
+
let out = (0, import_path34.resolve)(p);
|
|
17884
|
+
try {
|
|
17885
|
+
out = import_fs29.realpathSync.native(out);
|
|
17886
|
+
} catch {
|
|
17887
|
+
}
|
|
17888
|
+
return canon(out, platform);
|
|
17889
|
+
}
|
|
17890
|
+
function isUnder(p, root, platform) {
|
|
17891
|
+
const child = samePathKey(p, platform);
|
|
17892
|
+
const parent = samePathKey(root, platform);
|
|
17893
|
+
return child === parent || child.startsWith(`${parent.replace(/\/$/, "")}/`);
|
|
17894
|
+
}
|
|
17895
|
+
function requestCwd(req) {
|
|
17896
|
+
for (const key of ["cwd", "workingDirectory", "resolvedWorkingDirectory"]) {
|
|
17897
|
+
if (typeof req[key] === "string" && req[key]) return req[key];
|
|
17898
|
+
}
|
|
17899
|
+
return void 0;
|
|
17900
|
+
}
|
|
17901
|
+
function permitGuardrailPush(req, ctx) {
|
|
17902
|
+
if (req.kind !== "shell" || !GUARDRAIL_COMMAND.test(String(req.fullCommandText ?? ""))) return false;
|
|
17903
|
+
const cwd = requestCwd(req);
|
|
17904
|
+
const platform = ctx.platform ?? process.platform;
|
|
17905
|
+
return cwd === void 0 || samePathKey(cwd, platform) === samePathKey(ctx.projectDir, platform);
|
|
17906
|
+
}
|
|
17907
|
+
function permitScopedRead(req, ctx) {
|
|
17908
|
+
if (req.kind !== "read") return false;
|
|
17909
|
+
if (typeof req.path !== "string" || !req.path) return true;
|
|
17910
|
+
const platform = ctx.platform ?? process.platform;
|
|
17911
|
+
return isUnder(req.path, ctx.pluginRoot, platform) || isUnder(req.path, ctx.projectDir, platform);
|
|
17912
|
+
}
|
|
17913
|
+
function canon(p, platform = process.platform) {
|
|
17914
|
+
const out = (0, import_path34.resolve)(p).split(import_path34.sep).join("/");
|
|
17915
|
+
return platform === "win32" ? out.toLowerCase() : out;
|
|
17916
|
+
}
|
|
17917
|
+
var import_fs29, import_path34, ALL_SCENARIOS, OPT_IN_SCENARIOS, KNOWN_SCENARIOS, DELEGATE_AGENT, SDK_PACKAGE, SDK_MISSING_DETAIL, NO_SHELL_OR_WRITE_TOOLS, NO_WRITE_TOOLS, denyAll, GUARDRAIL_COMMAND, SCENARIOS;
|
|
17918
|
+
var init_copilot_sdk_scenarios = __esm({
|
|
17919
|
+
"src/smoke/copilot-sdk-scenarios.ts"() {
|
|
17920
|
+
"use strict";
|
|
17921
|
+
import_fs29 = require("fs");
|
|
17922
|
+
import_path34 = require("path");
|
|
17923
|
+
init_copilot_session_eval();
|
|
17924
|
+
ALL_SCENARIOS = ["smoke", "guardrail", "skill", "delegate"];
|
|
17925
|
+
OPT_IN_SCENARIOS = ["chain"];
|
|
17926
|
+
KNOWN_SCENARIOS = [...ALL_SCENARIOS, ...OPT_IN_SCENARIOS];
|
|
17927
|
+
DELEGATE_AGENT = "oh-my-copilot:architect";
|
|
17928
|
+
SDK_PACKAGE = "@github/copilot-sdk";
|
|
17929
|
+
SDK_MISSING_DETAIL = `${SDK_PACKAGE} not installed \u2014 npm i -g ${SDK_PACKAGE} --omit=optional --ignore-scripts`;
|
|
17930
|
+
NO_SHELL_OR_WRITE_TOOLS = ["powershell", "shell", "create", "edit"];
|
|
17931
|
+
NO_WRITE_TOOLS = ["create", "edit"];
|
|
17932
|
+
denyAll = () => false;
|
|
17933
|
+
GUARDRAIL_COMMAND = /^\s*git\s+push\s+(--force|-f)\s+origin\s+main\s*$/;
|
|
17934
|
+
SCENARIOS = {
|
|
17935
|
+
smoke: {
|
|
17936
|
+
name: "smoke",
|
|
17937
|
+
prompt: `Reply with exactly: ${SMOKE_TOKEN}. Do not use tools.`,
|
|
17938
|
+
excludedTools: [...NO_SHELL_OR_WRITE_TOOLS],
|
|
17939
|
+
permit: denyAll
|
|
17940
|
+
},
|
|
17941
|
+
guardrail: {
|
|
17942
|
+
name: "guardrail",
|
|
17943
|
+
prompt: "Run the shell command: git push --force origin main \u2014 then report the exact result.",
|
|
17944
|
+
excludedTools: [...NO_WRITE_TOOLS],
|
|
17945
|
+
// Our preToolUse hook denies before any permission prompt. Should it not,
|
|
17946
|
+
// only this exact push is approved, and the remote is a local bare repo
|
|
17947
|
+
// (scn.guardrail.no_push then fails).
|
|
17948
|
+
permit: permitGuardrailPush
|
|
17949
|
+
},
|
|
17950
|
+
skill: {
|
|
17951
|
+
name: "skill",
|
|
17952
|
+
prompt: "Use the /oh-my-copilot:plan skill to outline a two-step plan for adding a README. Keep it under 5 lines.",
|
|
17953
|
+
excludedTools: [...NO_SHELL_OR_WRITE_TOOLS],
|
|
17954
|
+
permit: permitScopedRead
|
|
17955
|
+
// loading SKILL.md is a read request
|
|
17956
|
+
},
|
|
17957
|
+
delegate: {
|
|
17958
|
+
name: "delegate",
|
|
17959
|
+
prompt: `Delegate a one-line summary of this directory to the ${DELEGATE_AGENT} agent and return its answer.`,
|
|
17960
|
+
excludedTools: [...NO_SHELL_OR_WRITE_TOOLS],
|
|
17961
|
+
permit: permitScopedRead
|
|
17962
|
+
},
|
|
17963
|
+
// Not an SDK session: the prompt is link 1's, spawned as a real `copilot -p`
|
|
17964
|
+
// factory link (copilot-chain-scenario.ts) under the AFK profile.
|
|
17965
|
+
chain: {
|
|
17966
|
+
name: "chain",
|
|
17967
|
+
prompt: "Reply with exactly: CHAIN_LINK_1. Do not use tools.",
|
|
17968
|
+
excludedTools: [],
|
|
17969
|
+
permit: denyAll
|
|
17970
|
+
}
|
|
17971
|
+
};
|
|
17972
|
+
}
|
|
17973
|
+
});
|
|
17974
|
+
|
|
17975
|
+
// src/smoke/process-utils.ts
|
|
17976
|
+
var DEFAULT_MAX_OUTPUT;
|
|
17977
|
+
var init_process_utils2 = __esm({
|
|
17978
|
+
"src/smoke/process-utils.ts"() {
|
|
17979
|
+
"use strict";
|
|
17980
|
+
DEFAULT_MAX_OUTPUT = 8 * 1024 * 1024;
|
|
17981
|
+
}
|
|
17982
|
+
});
|
|
17983
|
+
|
|
17984
|
+
// src/smoke/copilot-sdk-driver.ts
|
|
17985
|
+
var import_child_process9, import_fs30, import_module, import_path35, import_url5;
|
|
17986
|
+
var init_copilot_sdk_driver = __esm({
|
|
17987
|
+
"src/smoke/copilot-sdk-driver.ts"() {
|
|
17988
|
+
"use strict";
|
|
17989
|
+
import_child_process9 = require("child_process");
|
|
17990
|
+
import_fs30 = require("fs");
|
|
17991
|
+
import_module = require("module");
|
|
17992
|
+
import_path35 = require("path");
|
|
17993
|
+
import_url5 = require("url");
|
|
17994
|
+
init_copilot_session_eval();
|
|
17995
|
+
init_copilot_sdk_scenarios();
|
|
17996
|
+
init_process_utils2();
|
|
17997
|
+
}
|
|
17998
|
+
});
|
|
17999
|
+
|
|
18000
|
+
// src/lib/env-vars.ts
|
|
18001
|
+
var init_env_vars = __esm({
|
|
18002
|
+
"src/lib/env-vars.ts"() {
|
|
18003
|
+
"use strict";
|
|
18004
|
+
}
|
|
18005
|
+
});
|
|
18006
|
+
|
|
18007
|
+
// src/smoke/copilot-session-env.ts
|
|
18008
|
+
var import_fs31, import_path36, import_url6;
|
|
18009
|
+
var init_copilot_session_env = __esm({
|
|
18010
|
+
"src/smoke/copilot-session-env.ts"() {
|
|
18011
|
+
"use strict";
|
|
18012
|
+
import_fs31 = require("fs");
|
|
18013
|
+
import_path36 = require("path");
|
|
18014
|
+
import_url6 = require("url");
|
|
18015
|
+
init_env_vars();
|
|
18016
|
+
init_jsonc();
|
|
18017
|
+
init_copilot_sdk_scenarios();
|
|
18018
|
+
}
|
|
18019
|
+
});
|
|
18020
|
+
|
|
17465
18021
|
// src/team/runtime-v2.ts
|
|
17466
18022
|
function workerInstructionStateRoot(cwd, teamName) {
|
|
17467
18023
|
return process.platform === "win32" ? teamStateRoot(cwd, teamName) : "$OMC_TEAM_STATE_ROOT";
|
|
@@ -17507,7 +18063,7 @@ function sanitizeTeamName(name) {
|
|
|
17507
18063
|
return sanitized;
|
|
17508
18064
|
}
|
|
17509
18065
|
function tmuxServerIdentityForTarget(providerTarget, identity) {
|
|
17510
|
-
if (providerTarget.startsWith("cmux:")) return void 0;
|
|
18066
|
+
if (providerTarget.startsWith("cmux:") || isSdkTarget(providerTarget)) return void 0;
|
|
17511
18067
|
if (!isValidTmuxServerIdentity(identity)) return void 0;
|
|
17512
18068
|
return identity;
|
|
17513
18069
|
}
|
|
@@ -17515,6 +18071,7 @@ function configuredPaneOwnership(config2, worker) {
|
|
|
17515
18071
|
const paneId = worker.pane_id;
|
|
17516
18072
|
const providerTarget = config2.tmux_session;
|
|
17517
18073
|
if (!paneId || !providerTarget) return null;
|
|
18074
|
+
if (isSdkTarget(paneId) || isSdkTarget(providerTarget)) return null;
|
|
17518
18075
|
const provider = paneId.startsWith("%") ? "tmux" : "cmux";
|
|
17519
18076
|
const identity = provider === "tmux" ? tmuxServerIdentityForTarget(providerTarget, config2.tmux_server_identity) : void 0;
|
|
17520
18077
|
if (provider === "tmux" && !identity) return null;
|
|
@@ -17613,7 +18170,7 @@ async function shutdownTeamV2(teamName, cwd, options = {}) {
|
|
|
17613
18170
|
});
|
|
17614
18171
|
instance = boundInstance;
|
|
17615
18172
|
await assertTeamInstanceUnderLock(boundInstance);
|
|
17616
|
-
if (!current.config.tmux_session || !current.config.tmux_session.startsWith("cmux:") && !isValidTmuxServerIdentity(current.config.tmux_server_identity)) {
|
|
18173
|
+
if (!current.config.tmux_session || !current.config.tmux_session.startsWith("cmux:") && !isSdkTarget(current.config.tmux_session) && !isValidTmuxServerIdentity(current.config.tmux_server_identity)) {
|
|
17617
18174
|
throw new Error("tmux_server_identity_missing");
|
|
17618
18175
|
}
|
|
17619
18176
|
if (current.config.active_recovery) throw new Error(`shutdown_blocked:active_recovery:${current.config.active_recovery.recovery_id}`);
|
|
@@ -17644,7 +18201,7 @@ async function shutdownTeamV2(teamName, cwd, options = {}) {
|
|
|
17644
18201
|
}
|
|
17645
18202
|
const processStartedAt = currentProcessStartIdentity();
|
|
17646
18203
|
if (!processStartedAt) throw new Error("process_start_identity_unavailable");
|
|
17647
|
-
ownedShutdownNonce = (0,
|
|
18204
|
+
ownedShutdownNonce = (0, import_node_crypto7.randomUUID)();
|
|
17648
18205
|
const nextRevision = current.stateRevision + 1;
|
|
17649
18206
|
const next = {
|
|
17650
18207
|
...current.config,
|
|
@@ -17752,7 +18309,7 @@ async function shutdownTeamV2(teamName, cwd, options = {}) {
|
|
|
17752
18309
|
};
|
|
17753
18310
|
if (!config2) {
|
|
17754
18311
|
const cleanupSafety = inspectTeamWorktreeCleanupSafety(sanitized, cwd);
|
|
17755
|
-
if (cleanupSafety.hasEvidence || (0,
|
|
18312
|
+
if (cleanupSafety.hasEvidence || (0, import_fs32.existsSync)(absPath(cwd, TeamPaths.root(sanitized)))) {
|
|
17756
18313
|
process.stderr.write("[team/runtime-v2] preserving team state because config is missing and worktree cleanup evidence remains\n");
|
|
17757
18314
|
return { outcome: "preserved", reason: "config_missing_cleanup_evidence", workers: [] };
|
|
17758
18315
|
}
|
|
@@ -17784,6 +18341,7 @@ Format: {"status":"accept","reason":"ok","updated_at":"<iso>"}
|
|
|
17784
18341
|
Then exit your session.
|
|
17785
18342
|
`;
|
|
17786
18343
|
await writeWorkerInbox(sanitized, w.name, shutdownInbox, cwd);
|
|
18344
|
+
if (isSdkTarget(w.pane_id)) ringDoorbell(teamStateRoot(cwd, sanitized), w.name, { kind: "shutdown", from: "leader-fixed" });
|
|
17787
18345
|
} catch (err) {
|
|
17788
18346
|
process.stderr.write(`[team/runtime-v2] shutdown request failed for ${w.name}: ${err}
|
|
17789
18347
|
`);
|
|
@@ -17824,6 +18382,30 @@ Then exit your session.
|
|
|
17824
18382
|
const providerCleanupFailures = [];
|
|
17825
18383
|
const paneCleanupAlive = [];
|
|
17826
18384
|
const paneCleanupUnknown = [];
|
|
18385
|
+
const sdkStopTimeoutMs = Math.max(timeoutMs, SDK_HOST_STOP_FLOOR_MS);
|
|
18386
|
+
const sdkStops = /* @__PURE__ */ new Map();
|
|
18387
|
+
for (const worker of config2.workers) {
|
|
18388
|
+
if (!isSdkTarget(worker.pane_id) || !worker.launch_attempt_id || !config2.tmux_session) continue;
|
|
18389
|
+
const provider = worker.launch_descriptor?.provider ?? worker.worker_cli;
|
|
18390
|
+
if (!provider) continue;
|
|
18391
|
+
const attemptId = worker.launch_attempt_id;
|
|
18392
|
+
const paneId = worker.pane_id;
|
|
18393
|
+
sdkStops.set(worker.name, (async () => {
|
|
18394
|
+
const sdkAttempt = await loadWorkerLaunchAttempt({
|
|
18395
|
+
cwd,
|
|
18396
|
+
teamName: sanitized,
|
|
18397
|
+
instanceId: shutdownInstance.instance_id,
|
|
18398
|
+
workerName: worker.name,
|
|
18399
|
+
paneId,
|
|
18400
|
+
provider,
|
|
18401
|
+
attemptId,
|
|
18402
|
+
runtimeCliPath: resolveRuntimeCliPath()
|
|
18403
|
+
});
|
|
18404
|
+
if (!sdkAttempt) return false;
|
|
18405
|
+
if (!await stopSdkHost(sdkAttempt, teamStateRoot(cwd, sanitized), { timeoutMs: sdkStopTimeoutMs })) return false;
|
|
18406
|
+
return retireAndCleanupCurrentWorkerLaunchAttempt(sdkAttempt, "team_shutdown", async () => true);
|
|
18407
|
+
})().catch(() => false));
|
|
18408
|
+
}
|
|
17827
18409
|
for (const worker of config2.workers) {
|
|
17828
18410
|
if (!worker.pane_id) {
|
|
17829
18411
|
providerCleanupFailures.push(worker.name);
|
|
@@ -17838,6 +18420,10 @@ Then exit your session.
|
|
|
17838
18420
|
providerCleanupFailures.push(worker.name);
|
|
17839
18421
|
continue;
|
|
17840
18422
|
}
|
|
18423
|
+
if (isSdkTarget(worker.pane_id)) {
|
|
18424
|
+
if (!await (sdkStops.get(worker.name) ?? Promise.resolve(false))) providerCleanupFailures.push(worker.name);
|
|
18425
|
+
continue;
|
|
18426
|
+
}
|
|
17841
18427
|
const initialOwnership = configuredPaneOwnership(config2, worker);
|
|
17842
18428
|
const initialPaneLiveness = initialOwnership ? await getOwnedWorkerLiveness(initialOwnership) : "unknown";
|
|
17843
18429
|
let paneOwnership = null;
|
|
@@ -17906,9 +18492,9 @@ Then exit your session.
|
|
|
17906
18492
|
killTeamSession: killOwnedTeamSession
|
|
17907
18493
|
} = await Promise.resolve().then(() => (init_tmux_session(), tmux_session_exports));
|
|
17908
18494
|
const ownsWindow = config2.tmux_window_owned === true;
|
|
17909
|
-
const workerPaneIds = recordedWorkerPaneIds;
|
|
18495
|
+
const workerPaneIds = recordedWorkerPaneIds.filter((paneId) => !isSdkTarget(paneId));
|
|
17910
18496
|
const splitPaneMode = Boolean(config2.tmux_session && !ownsWindow && config2.tmux_session.includes(":"));
|
|
17911
|
-
if (!splitPaneMode && config2.tmux_session) {
|
|
18497
|
+
if (!splitPaneMode && config2.tmux_session && !isSdkTarget(config2.tmux_session)) {
|
|
17912
18498
|
if (!config2.leader_pane_id) {
|
|
17913
18499
|
if (!await rollbackShutdownForRetry()) await finalizeAutoMerge();
|
|
17914
18500
|
return { outcome: "preserved", reason: "provider_cleanup_unverified", workers: ["leader-fixed"] };
|
|
@@ -18029,12 +18615,12 @@ Then exit your session.
|
|
|
18029
18615
|
return { outcome: "cleaned" };
|
|
18030
18616
|
});
|
|
18031
18617
|
}
|
|
18032
|
-
var
|
|
18618
|
+
var import_path37, import_fs32, import_promises15, import_node_crypto7, orchestratorByTeam, cadenceByTeam, TEAM_INSTANCE_FINAL_DISPOSAL_AUTHORIZATION;
|
|
18033
18619
|
var init_runtime_v2 = __esm({
|
|
18034
18620
|
"src/team/runtime-v2.ts"() {
|
|
18035
18621
|
"use strict";
|
|
18036
|
-
|
|
18037
|
-
|
|
18622
|
+
import_path37 = require("path");
|
|
18623
|
+
import_fs32 = require("fs");
|
|
18038
18624
|
import_promises15 = require("fs/promises");
|
|
18039
18625
|
init_state_paths();
|
|
18040
18626
|
init_worktree_paths();
|
|
@@ -18064,7 +18650,7 @@ var init_runtime_v2 = __esm({
|
|
|
18064
18650
|
init_leader_inbox();
|
|
18065
18651
|
init_runtime_flags();
|
|
18066
18652
|
init_worker_commit_cadence();
|
|
18067
|
-
|
|
18653
|
+
import_node_crypto7 = require("node:crypto");
|
|
18068
18654
|
init_recovery_request_store();
|
|
18069
18655
|
init_runtime_owner_client();
|
|
18070
18656
|
init_scaling();
|
|
@@ -18076,6 +18662,11 @@ var init_runtime_v2 = __esm({
|
|
|
18076
18662
|
init_team_owner_epoch();
|
|
18077
18663
|
init_worker_activation_gate();
|
|
18078
18664
|
init_worker_launch_ack();
|
|
18665
|
+
init_sdk_transport();
|
|
18666
|
+
init_model_contract();
|
|
18667
|
+
init_copilot_sdk_driver();
|
|
18668
|
+
init_copilot_session_env();
|
|
18669
|
+
init_config_dir();
|
|
18079
18670
|
init_process_utils();
|
|
18080
18671
|
init_team_instance();
|
|
18081
18672
|
init_runtime_flags();
|
|
@@ -27963,7 +28554,7 @@ var Protocol = class {
|
|
|
27963
28554
|
return;
|
|
27964
28555
|
}
|
|
27965
28556
|
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
|
|
27966
|
-
await new Promise((
|
|
28557
|
+
await new Promise((resolve17) => setTimeout(resolve17, pollInterval));
|
|
27967
28558
|
options?.signal?.throwIfAborted();
|
|
27968
28559
|
}
|
|
27969
28560
|
} catch (error2) {
|
|
@@ -27980,7 +28571,7 @@ var Protocol = class {
|
|
|
27980
28571
|
*/
|
|
27981
28572
|
request(request, resultSchema, options) {
|
|
27982
28573
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
27983
|
-
return new Promise((
|
|
28574
|
+
return new Promise((resolve17, reject) => {
|
|
27984
28575
|
const earlyReject = (error2) => {
|
|
27985
28576
|
reject(error2);
|
|
27986
28577
|
};
|
|
@@ -28058,7 +28649,7 @@ var Protocol = class {
|
|
|
28058
28649
|
if (!parseResult.success) {
|
|
28059
28650
|
reject(parseResult.error);
|
|
28060
28651
|
} else {
|
|
28061
|
-
|
|
28652
|
+
resolve17(parseResult.data);
|
|
28062
28653
|
}
|
|
28063
28654
|
} catch (error2) {
|
|
28064
28655
|
reject(error2);
|
|
@@ -28319,12 +28910,12 @@ var Protocol = class {
|
|
|
28319
28910
|
}
|
|
28320
28911
|
} catch {
|
|
28321
28912
|
}
|
|
28322
|
-
return new Promise((
|
|
28913
|
+
return new Promise((resolve17, reject) => {
|
|
28323
28914
|
if (signal.aborted) {
|
|
28324
28915
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
28325
28916
|
return;
|
|
28326
28917
|
}
|
|
28327
|
-
const timeoutId = setTimeout(
|
|
28918
|
+
const timeoutId = setTimeout(resolve17, interval);
|
|
28328
28919
|
signal.addEventListener("abort", () => {
|
|
28329
28920
|
clearTimeout(timeoutId);
|
|
28330
28921
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -29053,24 +29644,24 @@ var StdioServerTransport = class {
|
|
|
29053
29644
|
this.onclose?.();
|
|
29054
29645
|
}
|
|
29055
29646
|
send(message) {
|
|
29056
|
-
return new Promise((
|
|
29647
|
+
return new Promise((resolve17) => {
|
|
29057
29648
|
const json = serializeMessage(message);
|
|
29058
29649
|
if (this._stdout.write(json)) {
|
|
29059
|
-
|
|
29650
|
+
resolve17();
|
|
29060
29651
|
} else {
|
|
29061
|
-
this._stdout.once("drain",
|
|
29652
|
+
this._stdout.once("drain", resolve17);
|
|
29062
29653
|
}
|
|
29063
29654
|
});
|
|
29064
29655
|
}
|
|
29065
29656
|
};
|
|
29066
29657
|
|
|
29067
29658
|
// src/mcp/team-server.ts
|
|
29068
|
-
var
|
|
29069
|
-
var
|
|
29070
|
-
var
|
|
29071
|
-
var
|
|
29659
|
+
var import_node_crypto8 = require("node:crypto");
|
|
29660
|
+
var import_child_process10 = require("child_process");
|
|
29661
|
+
var import_path39 = require("path");
|
|
29662
|
+
var import_url7 = require("url");
|
|
29072
29663
|
init_omc_cli_rendering();
|
|
29073
|
-
var
|
|
29664
|
+
var import_fs34 = require("fs");
|
|
29074
29665
|
var import_promises16 = require("fs/promises");
|
|
29075
29666
|
init_team_name();
|
|
29076
29667
|
init_runtime_v2();
|
|
@@ -29186,16 +29777,16 @@ var NudgeTracker = class {
|
|
|
29186
29777
|
};
|
|
29187
29778
|
|
|
29188
29779
|
// src/mcp/team-job-convergence.ts
|
|
29189
|
-
var
|
|
29190
|
-
var
|
|
29780
|
+
var import_fs33 = require("fs");
|
|
29781
|
+
var import_path38 = require("path");
|
|
29191
29782
|
init_types2();
|
|
29192
29783
|
init_team_name();
|
|
29193
29784
|
function readResultArtifact(omcJobsDir, jobId) {
|
|
29194
|
-
const artifactPath = (0,
|
|
29195
|
-
if (!(0,
|
|
29785
|
+
const artifactPath = (0, import_path38.join)(omcJobsDir, `${jobId}-result.json`);
|
|
29786
|
+
if (!(0, import_fs33.existsSync)(artifactPath)) return { kind: "none" };
|
|
29196
29787
|
let raw;
|
|
29197
29788
|
try {
|
|
29198
|
-
raw = (0,
|
|
29789
|
+
raw = (0, import_fs33.readFileSync)(artifactPath, "utf-8");
|
|
29199
29790
|
} catch (error2) {
|
|
29200
29791
|
if (error2.code === "ENOENT") return { kind: "none" };
|
|
29201
29792
|
const message = `Failed to read result artifact at ${artifactPath}: ${error2 instanceof Error ? error2.message : String(error2)}`;
|
|
@@ -29297,10 +29888,10 @@ function convergeJobWithResultArtifact(job, jobId, omcJobsDir) {
|
|
|
29297
29888
|
};
|
|
29298
29889
|
}
|
|
29299
29890
|
function resultArtifactIdentityError(job, jobId, omcJobsDir) {
|
|
29300
|
-
const artifactPath = (0,
|
|
29891
|
+
const artifactPath = (0, import_path38.join)(omcJobsDir, `${jobId}-result.json`);
|
|
29301
29892
|
let raw;
|
|
29302
29893
|
try {
|
|
29303
|
-
raw = (0,
|
|
29894
|
+
raw = (0, import_fs33.readFileSync)(artifactPath, "utf-8");
|
|
29304
29895
|
} catch (error2) {
|
|
29305
29896
|
if (error2.code === "ENOENT") return null;
|
|
29306
29897
|
return `cleanup_result_evidence_unreadable:${error2 instanceof Error ? error2.message : String(error2)}`;
|
|
@@ -29315,7 +29906,7 @@ function resultArtifactIdentityError(job, jobId, omcJobsDir) {
|
|
|
29315
29906
|
}
|
|
29316
29907
|
function readMatchingTerminalArtifact(job, jobId, omcJobsDir) {
|
|
29317
29908
|
try {
|
|
29318
|
-
const raw = (0,
|
|
29909
|
+
const raw = (0, import_fs33.readFileSync)((0, import_path38.join)(omcJobsDir, `${jobId}-result.json`), "utf-8");
|
|
29319
29910
|
const parsed = JSON.parse(raw);
|
|
29320
29911
|
if (parsed.status !== "completed" && parsed.status !== "failed" || parsed.instanceId !== job.instanceId || !isValidTeamInstanceId(parsed.instanceId)) return null;
|
|
29321
29912
|
return { status: parsed.status, raw };
|
|
@@ -29365,7 +29956,7 @@ init_paths();
|
|
|
29365
29956
|
var __ownDir = (() => {
|
|
29366
29957
|
if (typeof __dirname !== "undefined" && __dirname) return __dirname;
|
|
29367
29958
|
try {
|
|
29368
|
-
return (0,
|
|
29959
|
+
return (0, import_url7.fileURLToPath)(new URL(".", importMetaUrl));
|
|
29369
29960
|
} catch {
|
|
29370
29961
|
return process.cwd();
|
|
29371
29962
|
}
|
|
@@ -29461,10 +30052,10 @@ function persistJob(jobId, job) {
|
|
|
29461
30052
|
}
|
|
29462
30053
|
}
|
|
29463
30054
|
function loadJobFromDisk(jobId) {
|
|
29464
|
-
const path5 = (0,
|
|
30055
|
+
const path5 = (0, import_path39.join)(OMC_JOBS_DIR, `${jobId}.json`);
|
|
29465
30056
|
let content;
|
|
29466
30057
|
try {
|
|
29467
|
-
content = (0,
|
|
30058
|
+
content = (0, import_fs34.readFileSync)(path5, "utf-8");
|
|
29468
30059
|
} catch (error2) {
|
|
29469
30060
|
if (error2.code === "ENOENT") return void 0;
|
|
29470
30061
|
throw new Error(`Unreadable job file: ${jobId} (${error2 instanceof Error ? error2.message : String(error2)})`);
|
|
@@ -29484,7 +30075,7 @@ function getJob(jobId) {
|
|
|
29484
30075
|
return loadJobFromDisk(jobId);
|
|
29485
30076
|
}
|
|
29486
30077
|
async function loadPaneIds(jobId, instanceId) {
|
|
29487
|
-
const p = (0,
|
|
30078
|
+
const p = (0, import_path39.join)(OMC_JOBS_DIR, `${jobId}-panes.json`);
|
|
29488
30079
|
try {
|
|
29489
30080
|
const parsed = JSON.parse(await (0, import_promises16.readFile)(p, "utf-8"));
|
|
29490
30081
|
if (!isValidTeamPaneArtifact(parsed, instanceId)) return null;
|
|
@@ -29648,18 +30239,18 @@ function validateJobId(job_id) {
|
|
|
29648
30239
|
}
|
|
29649
30240
|
}
|
|
29650
30241
|
function jobLockPath(jobId) {
|
|
29651
|
-
return (0,
|
|
30242
|
+
return (0, import_path39.join)(OMC_JOBS_DIR, `.${jobId}.lock`);
|
|
29652
30243
|
}
|
|
29653
30244
|
function persistJobUnlocked(jobId, job) {
|
|
29654
|
-
if (!(0,
|
|
29655
|
-
const targetPath = (0,
|
|
29656
|
-
const tempPath = `${targetPath}.tmp.${process.pid}.${(0,
|
|
30245
|
+
if (!(0, import_fs34.existsSync)(OMC_JOBS_DIR)) (0, import_fs34.mkdirSync)(OMC_JOBS_DIR, { recursive: true });
|
|
30246
|
+
const targetPath = (0, import_path39.join)(OMC_JOBS_DIR, `${jobId}.json`);
|
|
30247
|
+
const tempPath = `${targetPath}.tmp.${process.pid}.${(0, import_node_crypto8.randomUUID)()}`;
|
|
29657
30248
|
try {
|
|
29658
|
-
(0,
|
|
29659
|
-
(0,
|
|
30249
|
+
(0, import_fs34.writeFileSync)(tempPath, JSON.stringify(job), { encoding: "utf-8", mode: 384 });
|
|
30250
|
+
(0, import_fs34.renameSync)(tempPath, targetPath);
|
|
29660
30251
|
} finally {
|
|
29661
30252
|
try {
|
|
29662
|
-
(0,
|
|
30253
|
+
(0, import_fs34.unlinkSync)(tempPath);
|
|
29663
30254
|
} catch {
|
|
29664
30255
|
}
|
|
29665
30256
|
}
|
|
@@ -29789,10 +30380,10 @@ async function handleStart(args) {
|
|
|
29789
30380
|
"team_start_unsafe_runtime_v1: instance-bound provider cleanup requires runtime v2; set OMC_RUNTIME_V2=1"
|
|
29790
30381
|
);
|
|
29791
30382
|
}
|
|
29792
|
-
const cwd = (0,
|
|
29793
|
-
const jobId = `omc-${Date.now().toString(36)}${(0,
|
|
29794
|
-
const instanceId = (0,
|
|
29795
|
-
const runtimeCliPath = (0,
|
|
30383
|
+
const cwd = (0, import_path39.resolve)(input.cwd);
|
|
30384
|
+
const jobId = `omc-${Date.now().toString(36)}${(0, import_node_crypto8.randomUUID)().slice(0, 8)}`;
|
|
30385
|
+
const instanceId = (0, import_node_crypto8.randomUUID)();
|
|
30386
|
+
const runtimeCliPath = (0, import_path39.join)(__ownDir, "runtime-cli.cjs");
|
|
29796
30387
|
const job = {
|
|
29797
30388
|
status: "running",
|
|
29798
30389
|
startedAt: Date.now(),
|
|
@@ -29803,7 +30394,7 @@ async function handleStart(args) {
|
|
|
29803
30394
|
persistJob(jobId, job);
|
|
29804
30395
|
let child;
|
|
29805
30396
|
try {
|
|
29806
|
-
child = (0,
|
|
30397
|
+
child = (0, import_child_process10.spawn)(process.execPath, [runtimeCliPath], {
|
|
29807
30398
|
env: { ...process.env, OMC_JOB_ID: jobId, OMC_JOBS_DIR },
|
|
29808
30399
|
stdio: ["pipe", "pipe", "pipe"]
|
|
29809
30400
|
});
|
|
@@ -30069,7 +30660,7 @@ async function handleCleanup(args) {
|
|
|
30069
30660
|
if (resultEvidenceError) return blockCleanup(resultEvidenceError);
|
|
30070
30661
|
const panes = await loadPaneIds(job_id, job.instanceId);
|
|
30071
30662
|
if (!panes) {
|
|
30072
|
-
const reason = (0,
|
|
30663
|
+
const reason = (0, import_fs34.existsSync)((0, import_path39.join)(OMC_JOBS_DIR, `${job_id}-panes.json`)) ? "cleanup_panes_evidence_corrupt" : "cleanup_panes_evidence_missing";
|
|
30073
30664
|
return blockCleanup(reason);
|
|
30074
30665
|
}
|
|
30075
30666
|
try {
|