@osovv/vv-opencode 2.0.1 → 2.1.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/CHANGELOG.md +42 -0
- package/README.md +87 -86
- package/dist/commands/completion.js +0 -1
- package/dist/commands/completion.js.map +1 -1
- package/dist/commands/doctor.js +6 -9
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/init.d.ts +2 -1
- package/dist/commands/init.js +7 -12
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/install.d.ts +4 -0
- package/dist/commands/install.js +40 -37
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/launch.d.ts +2 -1
- package/dist/commands/launch.js +18 -14
- package/dist/commands/launch.js.map +1 -1
- package/dist/commands/patch-provider.d.ts +225 -307
- package/dist/commands/patch-provider.js +92 -296
- package/dist/commands/patch-provider.js.map +1 -1
- package/dist/commands/status.js +7 -10
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/sync.d.ts +4 -0
- package/dist/commands/sync.js +38 -35
- package/dist/commands/sync.js.map +1 -1
- package/dist/index.d.ts +25 -5
- package/dist/index.js +73 -34
- package/dist/index.js.map +1 -1
- package/dist/lib/agent-tool-catalog.d.ts +1 -1
- package/dist/lib/agent-tool-catalog.js +3 -6
- package/dist/lib/agent-tool-catalog.js.map +1 -1
- package/dist/lib/agent-tool-contract.d.ts +22 -13
- package/dist/lib/agent-tool-contract.js +20 -20
- package/dist/lib/agent-tool-contract.js.map +1 -1
- package/dist/lib/analytics/types.d.ts +7 -1
- package/dist/lib/analytics/types.js +2 -2
- package/dist/lib/analytics/types.js.map +1 -1
- package/dist/lib/config-layers.d.ts +28 -6
- package/dist/lib/config-layers.js +268 -73
- package/dist/lib/config-layers.js.map +1 -1
- package/dist/lib/managed-agents.d.ts +24 -2
- package/dist/lib/managed-agents.js +45 -15
- package/dist/lib/managed-agents.js.map +1 -1
- package/dist/lib/model-roles.d.ts +5 -0
- package/dist/lib/model-roles.js +22 -1
- package/dist/lib/model-roles.js.map +1 -1
- package/dist/lib/opencode/agent-registrations.d.ts +4 -4
- package/dist/lib/opencode/agent-registrations.js +386 -197
- package/dist/lib/opencode/agent-registrations.js.map +1 -1
- package/dist/lib/opencode/inspection.d.ts +13 -13
- package/dist/lib/opencode/inspection.js +69 -106
- package/dist/lib/opencode/inspection.js.map +1 -1
- package/dist/lib/opencode/model-overrides.d.ts +2 -2
- package/dist/lib/opencode/model-overrides.js +192 -47
- package/dist/lib/opencode/model-overrides.js.map +1 -1
- package/dist/lib/opencode/paths.d.ts +6 -2
- package/dist/lib/opencode/paths.js +12 -11
- package/dist/lib/opencode/paths.js.map +1 -1
- package/dist/lib/opencode/plugin-registration.d.ts +10 -11
- package/dist/lib/opencode/plugin-registration.js +76 -138
- package/dist/lib/opencode/plugin-registration.js.map +1 -1
- package/dist/lib/opencode/shared-utils.d.ts +47 -3
- package/dist/lib/opencode/shared-utils.js +346 -15
- package/dist/lib/opencode/shared-utils.js.map +1 -1
- package/dist/lib/opencode.d.ts +5 -6
- package/dist/lib/opencode.js +10 -10
- package/dist/lib/opencode.js.map +1 -1
- package/dist/lib/vvoc-config.js +4 -4
- package/dist/lib/vvoc-config.js.map +1 -1
- package/dist/lib/vvoc-paths.d.ts +7 -0
- package/dist/lib/vvoc-paths.js +15 -1
- package/dist/lib/vvoc-paths.js.map +1 -1
- package/dist/lib/vvoc-preset-registry.d.ts +38 -50
- package/dist/lib/vvoc-preset-registry.js +38 -48
- package/dist/lib/vvoc-preset-registry.js.map +1 -1
- package/dist/plugins/analytics/index.d.ts +20 -14
- package/dist/plugins/analytics/index.js +281 -133
- package/dist/plugins/analytics/index.js.map +1 -1
- package/dist/plugins/guardian/index.d.ts +63 -42
- package/dist/plugins/guardian/index.js +217 -759
- package/dist/plugins/guardian/index.js.map +1 -1
- package/dist/plugins/hashline-edit/index.d.ts +145 -31
- package/dist/plugins/hashline-edit/index.js +679 -244
- package/dist/plugins/hashline-edit/index.js.map +1 -1
- package/dist/plugins/hashline-edit/schemas.d.ts +1 -1
- package/dist/plugins/hashline-edit/schemas.js +3 -3
- package/dist/plugins/hashline-edit/schemas.js.map +1 -1
- package/dist/plugins/model-roles/index.d.ts +18 -4
- package/dist/plugins/model-roles/index.js +44 -181
- package/dist/plugins/model-roles/index.js.map +1 -1
- package/dist/plugins/peak-hours/index.d.ts +23 -23
- package/dist/plugins/peak-hours/index.js +211 -180
- package/dist/plugins/peak-hours/index.js.map +1 -1
- package/dist/plugins/secrets-redaction/deep.js +35 -51
- package/dist/plugins/secrets-redaction/deep.js.map +1 -1
- package/dist/plugins/secrets-redaction/index.d.ts +96 -8
- package/dist/plugins/secrets-redaction/index.js +290 -102
- package/dist/plugins/secrets-redaction/index.js.map +1 -1
- package/dist/plugins/secrets-redaction/session.d.ts +9 -0
- package/dist/plugins/secrets-redaction/session.js +21 -4
- package/dist/plugins/secrets-redaction/session.js.map +1 -1
- package/dist/plugins/secrets-redaction/stream.d.ts +92 -0
- package/dist/plugins/secrets-redaction/stream.js +772 -0
- package/dist/plugins/secrets-redaction/stream.js.map +1 -0
- package/dist/plugins/spec-guard/index.d.ts +49 -18
- package/dist/plugins/spec-guard/index.js +231 -129
- package/dist/plugins/spec-guard/index.js.map +1 -1
- package/dist/plugins/system-context-injection/index.d.ts +10 -4
- package/dist/plugins/system-context-injection/index.js +271 -78
- package/dist/plugins/system-context-injection/index.js.map +1 -1
- package/dist/plugins/tool-history-compaction/index.d.ts +26 -4
- package/dist/plugins/tool-history-compaction/index.js +170 -32
- package/dist/plugins/tool-history-compaction/index.js.map +1 -1
- package/dist/plugins/tool-history-compaction/transform.d.ts +47 -16
- package/dist/plugins/tool-history-compaction/transform.js +173 -55
- package/dist/plugins/tool-history-compaction/transform.js.map +1 -1
- package/dist/plugins/web-tools/fetch-service.d.ts +51 -13
- package/dist/plugins/web-tools/fetch-service.js +106 -75
- package/dist/plugins/web-tools/fetch-service.js.map +1 -1
- package/dist/plugins/web-tools/index.d.ts +58 -16
- package/dist/plugins/web-tools/index.js +202 -91
- package/dist/plugins/web-tools/index.js.map +1 -1
- package/dist/plugins/web-tools/media-loader.d.ts +3 -3
- package/dist/plugins/web-tools/media-loader.js +3 -3
- package/dist/plugins/web-tools/media-loader.js.map +1 -1
- package/dist/plugins/web-tools/providers/native-fetch.d.ts +2 -2
- package/dist/plugins/web-tools/providers/native-fetch.js +1 -1
- package/dist/plugins/web-tools/providers/native-fetch.js.map +1 -1
- package/dist/plugins/web-tools/providers/spider.d.ts +2 -2
- package/dist/plugins/web-tools/providers/spider.js +1 -1
- package/dist/plugins/web-tools/providers/spider.js.map +1 -1
- package/dist/plugins/web-tools/providers/zai.d.ts +2 -2
- package/dist/plugins/web-tools/providers/zai.js +1 -1
- package/dist/plugins/web-tools/providers/zai.js.map +1 -1
- package/dist/plugins/web-tools/schemas.d.ts +1 -1
- package/dist/plugins/web-tools/schemas.js +3 -3
- package/dist/plugins/web-tools/schemas.js.map +1 -1
- package/dist/plugins/web-tools/search-service.d.ts +81 -12
- package/dist/plugins/web-tools/search-service.js +104 -57
- package/dist/plugins/web-tools/search-service.js.map +1 -1
- package/dist/plugins/workflow/authorization.d.ts +44 -10
- package/dist/plugins/workflow/authorization.js +113 -73
- package/dist/plugins/workflow/authorization.js.map +1 -1
- package/dist/plugins/workflow/cancellation.d.ts +86 -0
- package/dist/plugins/workflow/cancellation.js +202 -0
- package/dist/plugins/workflow/cancellation.js.map +1 -0
- package/dist/plugins/workflow/checkpoints.d.ts +7 -1
- package/dist/plugins/workflow/checkpoints.js +141 -21
- package/dist/plugins/workflow/checkpoints.js.map +1 -1
- package/dist/plugins/workflow/delegated.d.ts +14 -0
- package/dist/plugins/workflow/delegated.js +6 -5
- package/dist/plugins/workflow/delegated.js.map +1 -1
- package/dist/plugins/workflow/host.d.ts +81 -0
- package/dist/plugins/workflow/host.js +189 -0
- package/dist/plugins/workflow/host.js.map +1 -0
- package/dist/plugins/workflow/index.d.ts +69 -4
- package/dist/plugins/workflow/index.js +1391 -1026
- package/dist/plugins/workflow/index.js.map +1 -1
- package/dist/plugins/workflow/recovery.d.ts +3 -5
- package/dist/plugins/workflow/recovery.js +18 -33
- package/dist/plugins/workflow/recovery.js.map +1 -1
- package/dist/plugins/workflow/repair.d.ts +31 -5
- package/dist/plugins/workflow/repair.js +116 -48
- package/dist/plugins/workflow/repair.js.map +1 -1
- package/dist/plugins/workflow/results.d.ts +31 -31
- package/dist/plugins/workflow/results.js +4 -4
- package/dist/plugins/workflow/results.js.map +1 -1
- package/dist/plugins/workflow/schemas.d.ts +3 -3
- package/dist/plugins/workflow/schemas.js +5 -5
- package/dist/plugins/workflow/schemas.js.map +1 -1
- package/dist/plugins/workflow/system-instruction.md +4 -0
- package/dist/plugins/workflow/tooling.d.ts +6 -0
- package/dist/plugins/workflow/tooling.js +3 -1
- package/dist/plugins/workflow/tooling.js.map +1 -1
- package/dist/runtime/auxiliary.d.ts +13 -0
- package/dist/runtime/auxiliary.js +108 -0
- package/dist/runtime/auxiliary.js.map +1 -0
- package/dist/runtime/client.d.ts +88 -0
- package/dist/runtime/client.js +174 -0
- package/dist/runtime/client.js.map +1 -0
- package/dist/runtime/context-inspection-contract.d.ts +397 -0
- package/dist/runtime/context-inspection-contract.js +622 -0
- package/dist/runtime/context-inspection-contract.js.map +1 -0
- package/dist/runtime/context-inspection.d.ts +52 -0
- package/dist/runtime/context-inspection.js +324 -0
- package/dist/runtime/context-inspection.js.map +1 -0
- package/dist/runtime/context.d.ts +192 -0
- package/dist/runtime/context.js +1246 -0
- package/dist/runtime/context.js.map +1 -0
- package/dist/runtime/coordination.d.ts +40 -0
- package/dist/runtime/coordination.js +87 -0
- package/dist/runtime/coordination.js.map +1 -0
- package/dist/runtime/model-registry.d.ts +34 -0
- package/dist/runtime/model-registry.js +227 -0
- package/dist/runtime/model-registry.js.map +1 -0
- package/dist/runtime/permissions.d.ts +20 -0
- package/dist/runtime/permissions.js +250 -0
- package/dist/runtime/permissions.js.map +1 -0
- package/dist/runtime/snapshot-config.d.ts +80 -0
- package/dist/runtime/snapshot-config.js +268 -0
- package/dist/runtime/snapshot-config.js.map +1 -0
- package/dist/runtime/snapshot-store.d.ts +25 -0
- package/dist/runtime/snapshot-store.js +519 -0
- package/dist/runtime/snapshot-store.js.map +1 -0
- package/dist/runtime/snapshots.d.ts +59 -0
- package/dist/runtime/snapshots.js +721 -0
- package/dist/runtime/snapshots.js.map +1 -0
- package/dist/runtime/types.d.ts +713 -0
- package/dist/runtime/types.js +190 -0
- package/dist/runtime/types.js.map +1 -0
- package/dist/tui/analytics/indicator.d.ts +25 -26
- package/dist/tui/analytics/indicator.js +66 -74
- package/dist/tui/analytics/indicator.js.map +1 -1
- package/dist/tui/branding/footer.d.ts +7 -12
- package/dist/tui/branding/footer.js +16 -24
- package/dist/tui/branding/footer.js.map +1 -1
- package/dist/tui/context/analyze.d.ts +20 -9
- package/dist/tui/context/analyze.js +295 -257
- package/dist/tui/context/analyze.js.map +1 -1
- package/dist/tui/context/collect.d.ts +29 -3
- package/dist/tui/context/collect.js +450 -66
- package/dist/tui/context/collect.js.map +1 -1
- package/dist/tui/context/plugin.d.ts +21 -7
- package/dist/tui/context/plugin.js +65 -70
- package/dist/tui/context/plugin.js.map +1 -1
- package/dist/tui/context/types.d.ts +174 -43
- package/dist/tui/context/types.js +25 -19
- package/dist/tui/context/types.js.map +1 -1
- package/dist/tui/context/view.d.ts +33 -7
- package/dist/tui/context/view.js +136 -81
- package/dist/tui/context/view.js.map +1 -1
- package/dist/tui/peak-hours/banner.d.ts +13 -11
- package/dist/tui/peak-hours/banner.js +48 -80
- package/dist/tui/peak-hours/banner.js.map +1 -1
- package/dist/tui/policy.d.ts +69 -0
- package/dist/tui/policy.js +169 -0
- package/dist/tui/policy.js.map +1 -0
- package/dist/tui.d.ts +3 -8
- package/dist/tui.js +72 -68
- package/dist/tui.js.map +1 -1
- package/package.json +19 -15
- package/schemas/vvoc/v3.json +1 -1
- package/server.js +3 -5
- package/templates/agents/enhancer.md +10 -5
- package/templates/agents/guardian.md +10 -4
- package/templates/agents/investigator.md +4 -2
- package/templates/agents/vv-code-reviewer.md +4 -2
- package/templates/agents/vv-spec-reviewer.md +4 -2
- package/templates/skills/vv-execute/references/tool-contracts.md +1 -1
- package/tui.js +3 -5
- package/dist/plugins/analytics/v2.d.ts +0 -21
- package/dist/plugins/analytics/v2.js +0 -133
- package/dist/plugins/analytics/v2.js.map +0 -1
- package/dist/plugins/guardian/v2.d.ts +0 -13
- package/dist/plugins/guardian/v2.js +0 -204
- package/dist/plugins/guardian/v2.js.map +0 -1
- package/dist/plugins/hashline-edit/v2.d.ts +0 -12
- package/dist/plugins/hashline-edit/v2.js +0 -145
- package/dist/plugins/hashline-edit/v2.js.map +0 -1
- package/dist/plugins/model-roles/v2.d.ts +0 -24
- package/dist/plugins/model-roles/v2.js +0 -274
- package/dist/plugins/model-roles/v2.js.map +0 -1
- package/dist/plugins/peak-hours/v2.d.ts +0 -12
- package/dist/plugins/peak-hours/v2.js +0 -99
- package/dist/plugins/peak-hours/v2.js.map +0 -1
- package/dist/plugins/secrets-redaction/v2.d.ts +0 -19
- package/dist/plugins/secrets-redaction/v2.js +0 -138
- package/dist/plugins/secrets-redaction/v2.js.map +0 -1
- package/dist/plugins/spec-guard/v2.d.ts +0 -12
- package/dist/plugins/spec-guard/v2.js +0 -139
- package/dist/plugins/spec-guard/v2.js.map +0 -1
- package/dist/plugins/system-context-injection/agent-contexts.d.ts +0 -5
- package/dist/plugins/system-context-injection/agent-contexts.js +0 -164
- package/dist/plugins/system-context-injection/agent-contexts.js.map +0 -1
- package/dist/plugins/system-context-injection/v2.d.ts +0 -13
- package/dist/plugins/system-context-injection/v2.js +0 -60
- package/dist/plugins/system-context-injection/v2.js.map +0 -1
- package/dist/plugins/tool-history-compaction/v2.d.ts +0 -11
- package/dist/plugins/tool-history-compaction/v2.js +0 -56
- package/dist/plugins/tool-history-compaction/v2.js.map +0 -1
- package/dist/plugins/v2-runtime/config-watcher.d.ts +0 -26
- package/dist/plugins/v2-runtime/config-watcher.js +0 -111
- package/dist/plugins/v2-runtime/config-watcher.js.map +0 -1
- package/dist/plugins/v2-runtime/index.d.ts +0 -50
- package/dist/plugins/v2-runtime/index.js +0 -114
- package/dist/plugins/v2-runtime/index.js.map +0 -1
- package/dist/plugins/v2-runtime/location-config.d.ts +0 -51
- package/dist/plugins/v2-runtime/location-config.js +0 -91
- package/dist/plugins/v2-runtime/location-config.js.map +0 -1
- package/dist/plugins/v2-runtime/setup.d.ts +0 -48
- package/dist/plugins/v2-runtime/setup.js +0 -174
- package/dist/plugins/v2-runtime/setup.js.map +0 -1
- package/dist/plugins/web-tools/v2.d.ts +0 -11
- package/dist/plugins/web-tools/v2.js +0 -99
- package/dist/plugins/web-tools/v2.js.map +0 -1
- package/dist/plugins/workflow/v2.d.ts +0 -76
- package/dist/plugins/workflow/v2.js +0 -283
- package/dist/plugins/workflow/v2.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// FILE: src/plugins/workflow/authorization.ts
|
|
2
|
-
// VERSION:
|
|
2
|
+
// VERSION: 2.0.0
|
|
3
3
|
// START_MODULE_CONTRACT
|
|
4
|
-
// PURPOSE: Workflow tool access guards and
|
|
5
|
-
// SCOPE: Agent gating for workflow tools, primary root-controller mutation authorization (agent, trusted workspace, invalid-hydration, and root
|
|
6
|
-
// DEPENDS: [
|
|
4
|
+
// PURPOSE: Workflow tool access guards and native-session-backed read-only authorization message lookups over an explicit plugin context.
|
|
5
|
+
// SCOPE: Agent gating for workflow tools, primary root-controller mutation authorization (agent, trusted workspace, invalid-hydration, and root/fork identity through the native session.get), and the recovery and advance-authority message lookups through the native session.context retaining only identity, timing, and eligibility metadata. No tool definitions, stores, or persistence here.
|
|
6
|
+
// DEPENDS: [src/plugins/workflow/delegated.ts (LookupRecoveryUserMessage type), src/plugins/workflow/authority.ts (AuthorityMessageSnapshot type)]
|
|
7
7
|
// LINKS: [M-PLUGIN-WORKFLOW, M-WORKFLOW-DELEGATED, M-WORKFLOW-AUTHORITY]
|
|
8
8
|
// ROLE: RUNTIME
|
|
9
9
|
// MAP_MODE: EXPORTS
|
|
@@ -11,16 +11,19 @@
|
|
|
11
11
|
//
|
|
12
12
|
// START_MODULE_MAP
|
|
13
13
|
// WORKFLOW_CONTROLLER_AGENT - Canonical agent name allowed to use workflow tools and control mutations.
|
|
14
|
-
//
|
|
14
|
+
// NativeWorkflowSessionInfo - Structural native session info used for root/fork/workspace identity.
|
|
15
|
+
// NativeWorkflowSession - Narrow native session surface (get + context) used for identity.
|
|
16
|
+
// NativeAuthorizationClient - Narrow full-client surface (session.get + exact session.message.get) used for identity and message lookups.
|
|
17
|
+
// WorkflowAuthorizationContext - Explicit plugin context (native client, trusted directory/root, invalid-hydration sessions) consumed by the factory.
|
|
15
18
|
// WorkflowAuthorization - Authorization guards and lookups bound to one plugin instance.
|
|
16
19
|
// canUseWorkflowTools - True when the calling agent is the workflow controller.
|
|
17
20
|
// assertWorkflowToolAccess - Throws WORKFLOW_TOOL_DENIED for non-controller agents.
|
|
18
21
|
// shouldInjectForAgent - True when workflow guidance should be injected for the agent.
|
|
19
|
-
// createWorkflowAuthorization - Binds the primary-controller mutation guard and the
|
|
22
|
+
// createWorkflowAuthorization - Binds the primary-controller mutation guard and the native message lookups to an explicit context.
|
|
20
23
|
// END_MODULE_MAP
|
|
21
24
|
//
|
|
22
25
|
// START_CHANGE_SUMMARY
|
|
23
|
-
// LAST_CHANGE: [C-
|
|
26
|
+
// LAST_CHANGE: [C-OPENCODE-V2-NATIVE T-004 attempt 3 - Authorization message lookups now use the authenticated full client's exact session.message.get by id (surviving context compaction) instead of the projected session.context list; root identity still rejects child and fork sessions and verifies host location.]
|
|
24
27
|
// END_CHANGE_SUMMARY
|
|
25
28
|
import { WorkflowDiagnosticError } from "./results.js";
|
|
26
29
|
export const WORKFLOW_CONTROLLER_AGENT = "vv-controller";
|
|
@@ -40,106 +43,143 @@ export function assertWorkflowToolAccess(agentName, toolName) {
|
|
|
40
43
|
export function shouldInjectForAgent(agentName) {
|
|
41
44
|
return canUseWorkflowTools(agentName);
|
|
42
45
|
}
|
|
46
|
+
function isRecord(value) {
|
|
47
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
48
|
+
}
|
|
49
|
+
function readMessageId(message) {
|
|
50
|
+
if (!isRecord(message))
|
|
51
|
+
return undefined;
|
|
52
|
+
return typeof message.id === "string" ? message.id : undefined;
|
|
53
|
+
}
|
|
54
|
+
function readMessageType(message) {
|
|
55
|
+
if (!isRecord(message))
|
|
56
|
+
return undefined;
|
|
57
|
+
return typeof message.type === "string" ? message.type : undefined;
|
|
58
|
+
}
|
|
59
|
+
function readMessageCreated(message) {
|
|
60
|
+
if (!isRecord(message) || !isRecord(message.time))
|
|
61
|
+
return undefined;
|
|
62
|
+
const created = message.time.created;
|
|
63
|
+
return typeof created === "number" && Number.isFinite(created) ? created : undefined;
|
|
64
|
+
}
|
|
65
|
+
function readTextParts(message) {
|
|
66
|
+
if (!isRecord(message))
|
|
67
|
+
return [];
|
|
68
|
+
const type = message.type;
|
|
69
|
+
if (type === "user" || type === "synthetic" || type === "system") {
|
|
70
|
+
return typeof message.text === "string" ? [message.text] : [];
|
|
71
|
+
}
|
|
72
|
+
if (type === "assistant") {
|
|
73
|
+
const content = message.content;
|
|
74
|
+
if (!Array.isArray(content))
|
|
75
|
+
return [];
|
|
76
|
+
return content
|
|
77
|
+
.filter((part) => {
|
|
78
|
+
return isRecord(part) && part.type === "text" && typeof part.text === "string";
|
|
79
|
+
})
|
|
80
|
+
.map((part) => part.text);
|
|
81
|
+
}
|
|
82
|
+
return [];
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Read one exact native message by id through the authenticated full client.
|
|
86
|
+
* Returns undefined only when the message genuinely does not exist; a transport
|
|
87
|
+
* or authentication failure propagates so the domain reports a lookup failure
|
|
88
|
+
* instead of conflating it with a missing message.
|
|
89
|
+
*/
|
|
90
|
+
async function readNativeMessageById(client, sessionId, messageId) {
|
|
91
|
+
const message = await client.session.message.get({ sessionID: sessionId, messageID: messageId });
|
|
92
|
+
return message ?? undefined;
|
|
93
|
+
}
|
|
43
94
|
export function createWorkflowAuthorization(context) {
|
|
44
|
-
const {
|
|
95
|
+
const { getClient, directory, trustedWorkspaceRoot, invalidHydrationSessions } = context;
|
|
96
|
+
/** Normalized trusted workspace comparison (native reports absolute paths). */
|
|
97
|
+
function isTrustedWorkspacePath(candidate) {
|
|
98
|
+
if (typeof candidate !== "string" || candidate === "")
|
|
99
|
+
return false;
|
|
100
|
+
return candidate === directory || candidate === trustedWorkspaceRoot;
|
|
101
|
+
}
|
|
45
102
|
// New control mutations require the primary vv-controller session: the calling
|
|
46
|
-
// agent must be vv-controller, the session must be a root session
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
async function assertPrimaryControllerMutation(agent, sessionId,
|
|
103
|
+
// agent must be vv-controller, the host session must be a root session with no
|
|
104
|
+
// parent and no fork lineage, and the host-reported location must match the
|
|
105
|
+
// plugin's trusted workspace. None of this identity comes from tool arguments.
|
|
106
|
+
async function assertPrimaryControllerMutation(agent, sessionId, toolName) {
|
|
50
107
|
if (!canUseWorkflowTools(agent)) {
|
|
51
108
|
throw controlDenied(`CONTROL_DENIED: ${toolName} is only available to ${WORKFLOW_CONTROLLER_AGENT} sessions. Current agent: ${agent?.trim() || "unknown-agent"}.`);
|
|
52
109
|
}
|
|
53
|
-
if (contextWorkspace.worktree !== undefined &&
|
|
54
|
-
contextWorkspace.worktree !== worktree &&
|
|
55
|
-
contextWorkspace.worktree !== trustedWorkspaceRoot) {
|
|
56
|
-
throw controlDenied(`CONTROL_DENIED: ${toolName} workspace ${contextWorkspace.worktree} does not match the trusted plugin workspace.`);
|
|
57
|
-
}
|
|
58
|
-
if (contextWorkspace.worktree === undefined &&
|
|
59
|
-
contextWorkspace.directory !== undefined &&
|
|
60
|
-
contextWorkspace.directory !== directory) {
|
|
61
|
-
throw controlDenied(`CONTROL_DENIED: ${toolName} directory ${contextWorkspace.directory} does not match the trusted plugin directory.`);
|
|
62
|
-
}
|
|
63
110
|
if (invalidHydrationSessions.has(sessionId)) {
|
|
64
111
|
// Invalid persisted state is a persistence/host condition, not a caller
|
|
65
112
|
// authorization failure; keep the failure closed and the text explicit.
|
|
66
113
|
throw new WorkflowDiagnosticError("PERSISTENCE_FAILED", "persistence", `PERSISTENCE_FAILED: persisted workflow state for session ${sessionId} is invalid; resolve or remove it before new control mutations.`);
|
|
67
114
|
}
|
|
68
|
-
let
|
|
115
|
+
let info;
|
|
69
116
|
try {
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
throw new Error("missing session payload");
|
|
73
|
-
}
|
|
74
|
-
parentID = response.data.parentID;
|
|
117
|
+
const client = await getClient();
|
|
118
|
+
info = await client.session.get({ sessionID: sessionId });
|
|
75
119
|
}
|
|
76
120
|
catch (error) {
|
|
77
|
-
// A missing or failing
|
|
121
|
+
// A missing or failing native session lookup is unavailable trusted host
|
|
78
122
|
// context, not a denial of authorization.
|
|
79
123
|
throw new WorkflowDiagnosticError("HOST_CONTEXT_UNAVAILABLE", "host_context", `HOST_CONTEXT_UNAVAILABLE: ${toolName} requires root-session identity for ${sessionId}, which could not be verified: ${error.message}`);
|
|
80
124
|
}
|
|
125
|
+
const parentID = info.parentID;
|
|
81
126
|
if (parentID !== undefined && parentID !== null && parentID !== "") {
|
|
82
|
-
throw controlDenied(`CONTROL_DENIED: ${toolName} may only run in the root session; session ${sessionId} is a child of ${parentID}.`);
|
|
127
|
+
throw controlDenied(`CONTROL_DENIED: ${toolName} may only run in the root session; session ${sessionId} is a child of ${String(parentID)}.`);
|
|
128
|
+
}
|
|
129
|
+
const forkedFrom = info.fork?.sessionID;
|
|
130
|
+
if (forkedFrom !== undefined && forkedFrom !== null && forkedFrom !== "") {
|
|
131
|
+
throw controlDenied(`CONTROL_DENIED: ${toolName} may only run in the root session; session ${sessionId} is a fork of ${String(forkedFrom)}.`);
|
|
132
|
+
}
|
|
133
|
+
const hostDirectory = info.location?.directory;
|
|
134
|
+
if (hostDirectory !== undefined && !isTrustedWorkspacePath(hostDirectory)) {
|
|
135
|
+
throw controlDenied(`CONTROL_DENIED: ${toolName} workspace ${String(hostDirectory)} does not match the trusted plugin workspace.`);
|
|
83
136
|
}
|
|
84
137
|
}
|
|
85
|
-
// Read-only
|
|
138
|
+
// Read-only native message lookup for user-authorized recovery. Only identity
|
|
86
139
|
// and timing metadata (role, sessionID, id, time.created) are retained;
|
|
87
140
|
// message bodies never enter validation, persistence, or logs. Transport
|
|
88
141
|
// failures throw so the domain reports AUTHORIZATION_LOOKUP_FAILED instead
|
|
89
142
|
// of conflating an unreachable lookup with a nonexistent message.
|
|
90
143
|
const lookupRecoveryUserMessage = async (sessionId, messageId) => {
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
144
|
+
const message = await readNativeMessageById(await getClient(), sessionId, messageId);
|
|
145
|
+
if (message === undefined) {
|
|
146
|
+
return undefined;
|
|
147
|
+
}
|
|
148
|
+
const type = readMessageType(message);
|
|
149
|
+
const id = readMessageId(message);
|
|
150
|
+
// Only the exact requested id participates; a mismatched payload id is a
|
|
151
|
+
// lookup defect, never silently accepted as the requested message.
|
|
152
|
+
if (type !== "user" || (id !== undefined && id !== messageId)) {
|
|
100
153
|
return undefined;
|
|
101
154
|
}
|
|
102
|
-
const info = response.data.info;
|
|
103
155
|
return {
|
|
104
|
-
role:
|
|
105
|
-
sessionID:
|
|
106
|
-
id:
|
|
107
|
-
timeCreatedMs:
|
|
108
|
-
? info.time.created
|
|
109
|
-
: undefined,
|
|
156
|
+
role: "user",
|
|
157
|
+
sessionID: sessionId,
|
|
158
|
+
id: messageId,
|
|
159
|
+
timeCreatedMs: readMessageCreated(message),
|
|
110
160
|
};
|
|
111
161
|
};
|
|
112
|
-
// Advance-authority provenance uses the same
|
|
113
|
-
//
|
|
114
|
-
//
|
|
162
|
+
// Advance-authority provenance uses the same exact native message lookup. Only
|
|
163
|
+
// verified identity/timing/eligibility metadata leaves this lookup; raw user
|
|
164
|
+
// text is never persisted or logged.
|
|
115
165
|
const lookupAuthorityMessage = async (input) => {
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
throw new Error(`authority message lookup failed: ${errorName}`);
|
|
124
|
-
}
|
|
166
|
+
const message = await readNativeMessageById(await getClient(), input.sessionId, input.messageId);
|
|
167
|
+
if (message === undefined) {
|
|
168
|
+
return undefined;
|
|
169
|
+
}
|
|
170
|
+
const type = readMessageType(message);
|
|
171
|
+
const id = readMessageId(message);
|
|
172
|
+
if (id !== undefined && id !== input.messageId) {
|
|
125
173
|
return undefined;
|
|
126
174
|
}
|
|
127
|
-
const info = response.data.info;
|
|
128
|
-
const parts = Array.isArray(response.data.parts) ? response.data.parts : [];
|
|
129
|
-
const textParts = parts
|
|
130
|
-
.map((part) => part)
|
|
131
|
-
.filter((part) => part.type === "text" && typeof part.text === "string")
|
|
132
|
-
.map((part) => part.text);
|
|
133
175
|
return {
|
|
134
|
-
messageId:
|
|
135
|
-
sessionId:
|
|
136
|
-
role:
|
|
137
|
-
createdMs:
|
|
138
|
-
|
|
139
|
-
: 0,
|
|
140
|
-
ignored: info.ignored === true,
|
|
176
|
+
messageId: input.messageId,
|
|
177
|
+
sessionId: input.sessionId,
|
|
178
|
+
role: type === "user" ? "user" : "assistant",
|
|
179
|
+
createdMs: readMessageCreated(message) ?? 0,
|
|
180
|
+
ignored: isRecord(message) && message.ignored === true,
|
|
141
181
|
syntheticOnly: false,
|
|
142
|
-
textParts,
|
|
182
|
+
textParts: readTextParts(message),
|
|
143
183
|
};
|
|
144
184
|
};
|
|
145
185
|
return { assertPrimaryControllerMutation, lookupRecoveryUserMessage, lookupAuthorityMessage };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization.js","sourceRoot":"","sources":["../../../src/plugins/workflow/authorization.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,iBAAiB;AACjB,wBAAwB;AACxB,
|
|
1
|
+
{"version":3,"file":"authorization.js","sourceRoot":"","sources":["../../../src/plugins/workflow/authorization.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,iBAAiB;AACjB,wBAAwB;AACxB,4IAA4I;AAC5I,wYAAwY;AACxY,qJAAqJ;AACrJ,2EAA2E;AAC3E,kBAAkB;AAClB,sBAAsB;AACtB,sBAAsB;AACtB,EAAE;AACF,mBAAmB;AACnB,0GAA0G;AAC1G,sGAAsG;AACtG,6FAA6F;AAC7F,4IAA4I;AAC5I,wJAAwJ;AACxJ,2FAA2F;AAC3F,kFAAkF;AAClF,sFAAsF;AACtF,yFAAyF;AACzF,qIAAqI;AACrI,iBAAiB;AACjB,EAAE;AACF,uBAAuB;AACvB,8TAA8T;AAC9T,qBAAqB;AAIrB,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAEvD,MAAM,CAAC,MAAM,yBAAyB,GAAG,eAAe,CAAC;AAEzD,SAAS,aAAa,CAAC,OAAe;IACpC,OAAO,IAAI,uBAAuB,CAAC,gBAAgB,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;AACjF,CAAC;AAqDD,MAAM,UAAU,mBAAmB,CAAC,SAA6B;IAC/D,OAAO,SAAS,KAAK,yBAAyB,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,SAA6B,EAAE,QAAgB;IACtF,IAAI,mBAAmB,CAAC,SAAS,CAAC,EAAE,CAAC;QACnC,OAAO;IACT,CAAC;IAED,MAAM,aAAa,GAAG,SAAS,EAAE,IAAI,EAAE,IAAI,eAAe,CAAC;IAC3D,MAAM,IAAI,uBAAuB,CAC/B,sBAAsB,EACtB,eAAe,EACf,yBAAyB,QAAQ,yBAAyB,yBAAyB,6BAA6B,aAAa,GAAG,CACjI,C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
readonly type: string;
|
|
4
|
+
readonly message: string;
|
|
5
|
+
readonly status?: number;
|
|
6
|
+
}
|
|
7
|
+
/** Decoded native `session.tool.success` / `session.tool.failed` terminal event. */
|
|
8
|
+
export interface NativeToolTerminalEvent {
|
|
9
|
+
readonly sessionID: string;
|
|
10
|
+
readonly callID: string;
|
|
11
|
+
readonly status: "success" | "failed";
|
|
12
|
+
/** Present only on failed. */
|
|
13
|
+
readonly error?: NativeStructuredError;
|
|
14
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
15
|
+
}
|
|
16
|
+
/** Decoded native `session.synthetic` event. */
|
|
17
|
+
export interface NativeSyntheticEvent {
|
|
18
|
+
readonly sessionID: string;
|
|
19
|
+
readonly text: string;
|
|
20
|
+
readonly description?: string;
|
|
21
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
22
|
+
}
|
|
23
|
+
/** Decoded native `session.execution.failed` / `session.execution.interrupted` event. */
|
|
24
|
+
export interface NativeExecutionTerminalEvent {
|
|
25
|
+
readonly sessionID: string;
|
|
26
|
+
readonly status: "failed" | "interrupted";
|
|
27
|
+
readonly error?: NativeStructuredError;
|
|
28
|
+
readonly reason?: "user" | "shutdown" | "superseded" | "inactivity";
|
|
29
|
+
}
|
|
30
|
+
/** Native mapping of a foreground subagent tool-call termination. */
|
|
31
|
+
export type SubagentToolFailureKind = "cancelled" | "failed" | "interrupted";
|
|
32
|
+
/** Parsed subagent tool-call termination naming the child session it belongs to. */
|
|
33
|
+
export interface SubagentToolFailure {
|
|
34
|
+
readonly kind: SubagentToolFailureKind;
|
|
35
|
+
readonly childSessionId: string;
|
|
36
|
+
readonly detail?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Parse only the exact pinned subagent termination messages, covering both
|
|
40
|
+
* native interrupt shapes (live root interrupt and stale post-death settle). A
|
|
41
|
+
* generic provider or transport error, an unrelated tool interrupt, or an
|
|
42
|
+
* interrupt without a subagent child session id is not a cancellation and
|
|
43
|
+
* returns undefined.
|
|
44
|
+
*/
|
|
45
|
+
export declare function parseSubagentToolFailure(message: string): SubagentToolFailure | undefined;
|
|
46
|
+
/** True only for a terminal native `{type:"aborted"}` structured error. */
|
|
47
|
+
export declare function isAbortedStructuredError(error: NativeStructuredError | undefined): error is NativeStructuredError;
|
|
48
|
+
/** Decode a native session.tool.success/session.tool.failed envelope, or undefined for any other event. */
|
|
49
|
+
export declare function decodeToolTerminalEvent(event: unknown): NativeToolTerminalEvent | undefined;
|
|
50
|
+
/** Decode a native session.synthetic envelope, or undefined for any other event. */
|
|
51
|
+
export declare function decodeSyntheticEvent(event: unknown): NativeSyntheticEvent | undefined;
|
|
52
|
+
/** Decode a native session.execution.failed/session.execution.interrupted envelope. */
|
|
53
|
+
export declare function decodeExecutionTerminalEvent(event: unknown): NativeExecutionTerminalEvent | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Strict evidence bundle for one candidate cancellation recovery. Every field is
|
|
56
|
+
* required and independently verified; the caller must supply evidence observed
|
|
57
|
+
* from authoritative native sources only.
|
|
58
|
+
*/
|
|
59
|
+
export interface CancellationEvidence {
|
|
60
|
+
/** Session that owned the subagent tool call (the workflow/controller session). */
|
|
61
|
+
readonly parentSessionId: string;
|
|
62
|
+
/** Stable native tool call identity of the terminated subagent call. */
|
|
63
|
+
readonly callID: string;
|
|
64
|
+
/** Child session the termination names; must match every other child reference. */
|
|
65
|
+
readonly childSessionId: string;
|
|
66
|
+
/** Parent tool-call termination; only cancelled/interrupted qualify, never a generic failure. */
|
|
67
|
+
readonly parentToolFailure: SubagentToolFailure;
|
|
68
|
+
/** Child's structured terminal abort; only `{type:"aborted"}` qualifies. */
|
|
69
|
+
readonly childTerminalError: NativeStructuredError;
|
|
70
|
+
/** True when the child still has an active execution/inbox; quiescence requires false. */
|
|
71
|
+
readonly childActive: boolean;
|
|
72
|
+
}
|
|
73
|
+
/** Cancellation evidence evaluation outcome. */
|
|
74
|
+
export type CancellationEvidenceDecision = {
|
|
75
|
+
readonly ok: true;
|
|
76
|
+
} | {
|
|
77
|
+
readonly ok: false;
|
|
78
|
+
readonly reason: string;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Approve cancellation settlement only when the parent tool-call termination is an
|
|
82
|
+
* authoritative cancellation/interruption naming the child, the child reports a
|
|
83
|
+
* terminal structured abort, and the child is quiescent. A plain provider failure,
|
|
84
|
+
* a different/wrong child, an unspecified call, or an active child all refuse.
|
|
85
|
+
*/
|
|
86
|
+
export declare function evaluateCancellationEvidence(evidence: CancellationEvidence): CancellationEvidenceDecision;
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
// FILE: src/plugins/workflow/cancellation.ts
|
|
2
|
+
// VERSION: 1.0.0
|
|
3
|
+
// START_MODULE_CONTRACT
|
|
4
|
+
// PURPOSE: Decode native OpenCode 2.0.18 terminal tool/execution/synthetic events and decide, under a strict evidence rule, whether a workflow attempt was authoritatively cancelled.
|
|
5
|
+
// SCOPE: Pure native event decoding and cancellation-evidence evaluation only. No session/client access, no state mutation, no persistence, no budgets. The approved evidence rule requires an authoritative parent subagent tool-call termination, the actual child's terminal abort, and child quiescence; every other shape refuses.
|
|
6
|
+
// DEPENDS: []
|
|
7
|
+
// LINKS: [M-PLUGIN-WORKFLOW, M-WORKFLOW-DELEGATED, M-WORKFLOW-EXECUTION, V-M-PLUGIN-WORKFLOW]
|
|
8
|
+
// ROLE: RUNTIME
|
|
9
|
+
// MAP_MODE: EXPORTS
|
|
10
|
+
// END_MODULE_CONTRACT
|
|
11
|
+
//
|
|
12
|
+
// START_MODULE_MAP
|
|
13
|
+
// NativeStructuredError - Native SessionError.Error shape ({type, message, status?}).
|
|
14
|
+
// NativeToolTerminalEvent - Decoded session.tool.success/session.tool.failed terminal event.
|
|
15
|
+
// NativeSyntheticEvent - Decoded session.synthetic event delivered to a parent session.
|
|
16
|
+
// NativeExecutionTerminalEvent - Decoded session.execution.failed/interrupted terminal event.
|
|
17
|
+
// SubagentToolFailureKind - Native mapping of a foreground subagent tool-call termination.
|
|
18
|
+
// SubagentToolFailure - Parsed subagent tool-call termination with the child session it names.
|
|
19
|
+
// parseSubagentToolFailure - Parse the exact pinned subagent failure/cancel/interrupt messages (both native interrupt shapes).
|
|
20
|
+
// isAbortedStructuredError - True only for a terminal native `{type:"aborted"}` error.
|
|
21
|
+
// decodeToolTerminalEvent - Decode a native session.tool.success/session.tool.failed envelope.
|
|
22
|
+
// decodeSyntheticEvent - Decode a native session.synthetic envelope.
|
|
23
|
+
// decodeExecutionTerminalEvent - Decode a native session.execution.failed/interrupted envelope.
|
|
24
|
+
// CancellationEvidence - Strict evidence bundle for one candidate cancellation recovery.
|
|
25
|
+
// CancellationEvidenceDecision - Approved or refused cancellation settlement outcome.
|
|
26
|
+
// evaluateCancellationEvidence - Approve cancellation settlement only with complete, matching, quiescent evidence.
|
|
27
|
+
// END_MODULE_MAP
|
|
28
|
+
//
|
|
29
|
+
// START_CHANGE_SUMMARY
|
|
30
|
+
// LAST_CHANGE: [C-OPENCODE-V2-NATIVE wi-20 - parseSubagentToolFailure now recognizes BOTH pinned 2.0.18 interrupt shapes: the live in-process root-interrupt `Tool execution interrupted (sessionID: <id>)` (step.ts TOOLS_INTERRUPTED composed by publish-llm-event.ts failTool) in addition to the stale post-process-death `Tool execution interrupted: subagent (sessionID: <id>)` (llm.ts settleStaleToolCalls). A root interrupt now yields kind 'interrupted' with the child session id, so explicit recovery can settle the attempt; a bare interrupt without a child session id, a generic provider/transport error, or unrelated text still returns undefined. T-004 originally added the authoritative native cancellation mapping and strict recovery evidence rule, replacing the V1 Task cancelled / MessageAbortedError assumption with verified 2.0.18 shapes.]
|
|
31
|
+
// END_CHANGE_SUMMARY
|
|
32
|
+
// Exact pinned messages from the 2.0.18 source:
|
|
33
|
+
// - packages/core/src/tool/plugin/subagent.ts: `Subagent cancelled (sessionID: <id>)`
|
|
34
|
+
// and `Subagent failed (sessionID: <id>): <detail>`.
|
|
35
|
+
// - LIVE in-process root interrupt (parent session interrupted while the subagent
|
|
36
|
+
// tool part is unsettled — the common TUI Esc / API interrupt case):
|
|
37
|
+
// packages/core/src/session/runner/step.ts:61 `TOOLS_INTERRUPTED`
|
|
38
|
+
// (`{ type: "aborted", message: "Tool execution interrupted" }`) composed by
|
|
39
|
+
// packages/core/src/session/runner/publish-llm-event.ts:342-358 (`failTool`
|
|
40
|
+
// subagent special case) into `Tool execution interrupted (sessionID: <id>)`.
|
|
41
|
+
// - STALE post-process-death settle: packages/core/src/session/runner/llm.ts:348
|
|
42
|
+
// (`settleStaleToolCalls`) `Tool execution interrupted: subagent (sessionID: <id>)`.
|
|
43
|
+
// Both interrupt shapes carry a subagent child session id; a bare
|
|
44
|
+
// `Tool execution interrupted` (no child session id) is not evidence here.
|
|
45
|
+
const SUBAGENT_CANCELLED_RE = /^Subagent cancelled \(sessionID: ([^)\s]+)\)$/;
|
|
46
|
+
const SUBAGENT_FAILED_RE = /^Subagent failed \(sessionID: ([^)\s]+)\)(?:: ([\s\S]*))?$/;
|
|
47
|
+
const SUBAGENT_INTERRUPTED_LIVE_RE = /^Tool execution interrupted \(sessionID: ([^)\s]+)\)$/;
|
|
48
|
+
const SUBAGENT_INTERRUPTED_STALE_RE = /^Tool execution interrupted: subagent \(sessionID: ([^)\s]+)\)$/;
|
|
49
|
+
/**
|
|
50
|
+
* Parse only the exact pinned subagent termination messages, covering both
|
|
51
|
+
* native interrupt shapes (live root interrupt and stale post-death settle). A
|
|
52
|
+
* generic provider or transport error, an unrelated tool interrupt, or an
|
|
53
|
+
* interrupt without a subagent child session id is not a cancellation and
|
|
54
|
+
* returns undefined.
|
|
55
|
+
*/
|
|
56
|
+
export function parseSubagentToolFailure(message) {
|
|
57
|
+
const cancelled = SUBAGENT_CANCELLED_RE.exec(message);
|
|
58
|
+
if (cancelled) {
|
|
59
|
+
return { kind: "cancelled", childSessionId: cancelled[1] };
|
|
60
|
+
}
|
|
61
|
+
const failed = SUBAGENT_FAILED_RE.exec(message);
|
|
62
|
+
if (failed) {
|
|
63
|
+
const detail = failed[2];
|
|
64
|
+
return {
|
|
65
|
+
kind: "failed",
|
|
66
|
+
childSessionId: failed[1],
|
|
67
|
+
...(detail === undefined || detail === "" ? {} : { detail }),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const liveInterrupted = SUBAGENT_INTERRUPTED_LIVE_RE.exec(message);
|
|
71
|
+
if (liveInterrupted) {
|
|
72
|
+
return { kind: "interrupted", childSessionId: liveInterrupted[1] };
|
|
73
|
+
}
|
|
74
|
+
const staleInterrupted = SUBAGENT_INTERRUPTED_STALE_RE.exec(message);
|
|
75
|
+
if (staleInterrupted) {
|
|
76
|
+
return { kind: "interrupted", childSessionId: staleInterrupted[1] };
|
|
77
|
+
}
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
/** True only for a terminal native `{type:"aborted"}` structured error. */
|
|
81
|
+
export function isAbortedStructuredError(error) {
|
|
82
|
+
return error !== undefined && error.type === "aborted";
|
|
83
|
+
}
|
|
84
|
+
function isRecord(value) {
|
|
85
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
86
|
+
}
|
|
87
|
+
function decodeStructuredError(value) {
|
|
88
|
+
if (!isRecord(value))
|
|
89
|
+
return undefined;
|
|
90
|
+
const type = value.type;
|
|
91
|
+
const message = value.message;
|
|
92
|
+
if (typeof type !== "string" || typeof message !== "string")
|
|
93
|
+
return undefined;
|
|
94
|
+
const status = value.status;
|
|
95
|
+
return {
|
|
96
|
+
type,
|
|
97
|
+
message,
|
|
98
|
+
...(typeof status === "number" && Number.isFinite(status) ? { status } : {}),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function readEnvelope(event) {
|
|
102
|
+
if (!isRecord(event))
|
|
103
|
+
return undefined;
|
|
104
|
+
const type = event.type;
|
|
105
|
+
const data = event.data;
|
|
106
|
+
if (typeof type !== "string" || !isRecord(data))
|
|
107
|
+
return undefined;
|
|
108
|
+
return { type, data };
|
|
109
|
+
}
|
|
110
|
+
/** Decode a native session.tool.success/session.tool.failed envelope, or undefined for any other event. */
|
|
111
|
+
export function decodeToolTerminalEvent(event) {
|
|
112
|
+
const envelope = readEnvelope(event);
|
|
113
|
+
if (!envelope)
|
|
114
|
+
return undefined;
|
|
115
|
+
const { type, data } = envelope;
|
|
116
|
+
if (type !== "session.tool.success" && type !== "session.tool.failed")
|
|
117
|
+
return undefined;
|
|
118
|
+
const sessionID = data.sessionID;
|
|
119
|
+
const callID = data.id;
|
|
120
|
+
if (typeof sessionID !== "string" || typeof callID !== "string")
|
|
121
|
+
return undefined;
|
|
122
|
+
const metadata = isRecord(data.metadata) ? data.metadata : undefined;
|
|
123
|
+
if (type === "session.tool.success") {
|
|
124
|
+
return { sessionID, callID, status: "success", ...(metadata ? { metadata } : {}) };
|
|
125
|
+
}
|
|
126
|
+
const error = decodeStructuredError(data.error);
|
|
127
|
+
if (error === undefined)
|
|
128
|
+
return undefined;
|
|
129
|
+
return { sessionID, callID, status: "failed", error, ...(metadata ? { metadata } : {}) };
|
|
130
|
+
}
|
|
131
|
+
/** Decode a native session.synthetic envelope, or undefined for any other event. */
|
|
132
|
+
export function decodeSyntheticEvent(event) {
|
|
133
|
+
const envelope = readEnvelope(event);
|
|
134
|
+
if (!envelope || envelope.type !== "session.synthetic")
|
|
135
|
+
return undefined;
|
|
136
|
+
const { data } = envelope;
|
|
137
|
+
const sessionID = data.sessionID;
|
|
138
|
+
const text = data.text;
|
|
139
|
+
if (typeof sessionID !== "string" || typeof text !== "string")
|
|
140
|
+
return undefined;
|
|
141
|
+
const description = typeof data.description === "string" ? data.description : undefined;
|
|
142
|
+
const metadata = isRecord(data.metadata) ? data.metadata : undefined;
|
|
143
|
+
return {
|
|
144
|
+
sessionID,
|
|
145
|
+
text,
|
|
146
|
+
...(description === undefined ? {} : { description }),
|
|
147
|
+
...(metadata === undefined ? {} : { metadata }),
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/** Decode a native session.execution.failed/session.execution.interrupted envelope. */
|
|
151
|
+
export function decodeExecutionTerminalEvent(event) {
|
|
152
|
+
const envelope = readEnvelope(event);
|
|
153
|
+
if (!envelope)
|
|
154
|
+
return undefined;
|
|
155
|
+
const { type, data } = envelope;
|
|
156
|
+
if (type === "session.execution.failed") {
|
|
157
|
+
const error = decodeStructuredError(data.error);
|
|
158
|
+
if (error === undefined)
|
|
159
|
+
return undefined;
|
|
160
|
+
const sessionID = data.sessionID;
|
|
161
|
+
if (typeof sessionID !== "string")
|
|
162
|
+
return undefined;
|
|
163
|
+
return { sessionID, status: "failed", error };
|
|
164
|
+
}
|
|
165
|
+
if (type === "session.execution.interrupted") {
|
|
166
|
+
const sessionID = data.sessionID;
|
|
167
|
+
const reason = data.reason;
|
|
168
|
+
if (typeof sessionID !== "string")
|
|
169
|
+
return undefined;
|
|
170
|
+
if (reason !== "user" &&
|
|
171
|
+
reason !== "shutdown" &&
|
|
172
|
+
reason !== "superseded" &&
|
|
173
|
+
reason !== "inactivity") {
|
|
174
|
+
return undefined;
|
|
175
|
+
}
|
|
176
|
+
return { sessionID, status: "interrupted", reason };
|
|
177
|
+
}
|
|
178
|
+
return undefined;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Approve cancellation settlement only when the parent tool-call termination is an
|
|
182
|
+
* authoritative cancellation/interruption naming the child, the child reports a
|
|
183
|
+
* terminal structured abort, and the child is quiescent. A plain provider failure,
|
|
184
|
+
* a different/wrong child, an unspecified call, or an active child all refuse.
|
|
185
|
+
*/
|
|
186
|
+
export function evaluateCancellationEvidence(evidence) {
|
|
187
|
+
const { parentToolFailure } = evidence;
|
|
188
|
+
if (parentToolFailure.kind === "failed") {
|
|
189
|
+
return { ok: false, reason: "PARENT_TOOL_FAILURE_NOT_CANCELLATION" };
|
|
190
|
+
}
|
|
191
|
+
if (parentToolFailure.childSessionId !== evidence.childSessionId) {
|
|
192
|
+
return { ok: false, reason: "PARENT_CHILD_SESSION_MISMATCH" };
|
|
193
|
+
}
|
|
194
|
+
if (!isAbortedStructuredError(evidence.childTerminalError)) {
|
|
195
|
+
return { ok: false, reason: "CHILD_TERMINAL_NOT_ABORTED" };
|
|
196
|
+
}
|
|
197
|
+
if (evidence.childActive) {
|
|
198
|
+
return { ok: false, reason: "CHILD_STILL_ACTIVE" };
|
|
199
|
+
}
|
|
200
|
+
return { ok: true };
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=cancellation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cancellation.js","sourceRoot":"","sources":["../../../src/plugins/workflow/cancellation.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,iBAAiB;AACjB,wBAAwB;AACxB,wLAAwL;AACxL,0UAA0U;AAC1U,gBAAgB;AAChB,gGAAgG;AAChG,kBAAkB;AAClB,sBAAsB;AACtB,sBAAsB;AACtB,EAAE;AACF,mBAAmB;AACnB,wFAAwF;AACxF,+FAA+F;AAC/F,0FAA0F;AAC1F,gGAAgG;AAChG,6FAA6F;AAC7F,iGAAiG;AACjG,iIAAiI;AACjI,yFAAyF;AACzF,iGAAiG;AACjG,uEAAuE;AACvE,kGAAkG;AAClG,2FAA2F;AAC3F,wFAAwF;AACxF,qHAAqH;AACrH,iBAAiB;AACjB,EAAE;AACF,uBAAuB;AACvB,k1BAAk1B;AACl1B,qBAAqB;AA6CrB,gDAAgD;AAChD,sFAAsF;AACtF,uDAAuD;AACvD,kFAAkF;AAClF,uEAAuE;AACvE,oEAAoE;AACpE,+EAA+E;AAC/E,8EAA8E;AAC9E,gFAAgF;AAChF,iFAAiF;AACjF,uFAAuF;AACvF,kEAAkE;AAClE,2EAA2E;AAC3E,MAAM,qBAAqB,GAAG,+CAA+C,CAAC;AAC9E,MAAM,kBAAkB,GAAG,4DAA4D,CAAC;AACxF,MAAM,4BAA4B,GAAG,uDAAuD,CAAC;AAC7F,MAAM,6BAA6B,GACjC,iEAAiE,CAAC;AAEpE;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,C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}
|
|
@@ -197,7 +197,7 @@ export type AuthorizeReworkResult = {
|
|
|
197
197
|
grantedAttempts: number;
|
|
198
198
|
} | {
|
|
199
199
|
ok: false;
|
|
200
|
-
errorCode: "RUN_NOT_FOUND" | "SESSION_MISMATCH" | "CHECKPOINT_NOT_FOUND" | "RUN_SEALED" | "CHECKPOINT_NOT_FAILED" | "HARD_STOP_CHECKPOINT" | "TASK_NOT_COVERED" | "WORK_ITEM_NOT_BOUND" | "REWORK_REJECTED";
|
|
200
|
+
errorCode: "RUN_NOT_FOUND" | "SESSION_MISMATCH" | "CHECKPOINT_NOT_FOUND" | "RUN_SEALED" | "CHECKPOINT_NOT_FAILED" | "HARD_STOP_CHECKPOINT" | "TASK_NOT_COVERED" | "WORK_ITEM_NOT_BOUND" | "NOT_ACCEPTED" | "STALE_ATTEMPT" | "REWORK_REJECTED";
|
|
201
201
|
message: string;
|
|
202
202
|
};
|
|
203
203
|
export interface AuthorizeReworkInput {
|
|
@@ -206,6 +206,12 @@ export interface AuthorizeReworkInput {
|
|
|
206
206
|
checkpointId: string;
|
|
207
207
|
workItemId: string;
|
|
208
208
|
reason: string;
|
|
209
|
+
/**
|
|
210
|
+
* Public attempt identity the caller believes is the accepted result to
|
|
211
|
+
* reopen. When provided it must match the item's current accepted attempt so
|
|
212
|
+
* a stale attempt number can never silently target a newer accepted result.
|
|
213
|
+
*/
|
|
214
|
+
attempt?: number;
|
|
209
215
|
}
|
|
210
216
|
export declare function authorizeReworkFromFailedCheckpoint(store: WorkItemStore, input: AuthorizeReworkInput): AuthorizeReworkResult;
|
|
211
217
|
export declare function authorizeReworkFromFailedCheckpointInStore(data: WorkItemStoreData, input: AuthorizeReworkInput): AuthorizeReworkResult;
|