@dailephd/my-centcom 0.1.0 → 0.3.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/README.md +10 -5
- package/apps/daemon/dist/artifacts/returnSnapshots.d.ts +12 -0
- package/apps/daemon/dist/artifacts/returnSnapshots.js +41 -0
- package/apps/daemon/dist/bootstrap/app.d.ts +21 -0
- package/apps/daemon/dist/bootstrap/app.js +27 -0
- package/apps/daemon/dist/bootstrap/installLayout.d.ts +81 -0
- package/apps/daemon/dist/bootstrap/installLayout.js +164 -0
- package/apps/daemon/dist/bootstrap/main.d.ts +14 -0
- package/apps/daemon/dist/bootstrap/main.js +141 -0
- package/apps/daemon/dist/bootstrap/operatorConsole.d.ts +75 -0
- package/apps/daemon/dist/bootstrap/operatorConsole.js +293 -0
- package/apps/daemon/dist/bootstrap/privateDataRoot.d.ts +38 -0
- package/apps/daemon/dist/bootstrap/privateDataRoot.js +204 -0
- package/apps/daemon/dist/bootstrap/secureMain.d.ts +118 -0
- package/apps/daemon/dist/bootstrap/secureMain.js +403 -0
- package/apps/daemon/dist/bootstrap/setup.d.ts +93 -0
- package/apps/daemon/dist/bootstrap/setup.js +738 -0
- package/apps/daemon/dist/context/changeProposal.d.ts +97 -0
- package/apps/daemon/dist/context/changeProposal.js +259 -0
- package/apps/daemon/dist/context/gitEvidence.d.ts +88 -0
- package/apps/daemon/dist/context/gitEvidence.js +332 -0
- package/apps/daemon/dist/context/gitObservation.d.ts +30 -0
- package/apps/daemon/dist/context/gitObservation.js +113 -0
- package/apps/daemon/dist/context/projectReadIssuer.d.ts +68 -0
- package/apps/daemon/dist/context/projectReadIssuer.js +158 -0
- package/apps/daemon/dist/context/projectReadService.d.ts +153 -0
- package/apps/daemon/dist/context/projectReadService.js +652 -0
- package/apps/daemon/dist/context/projectViewService.d.ts +85 -0
- package/apps/daemon/dist/context/projectViewService.js +332 -0
- package/apps/daemon/dist/context/proposalRecorder.d.ts +11 -0
- package/apps/daemon/dist/context/proposalRecorder.js +19 -0
- package/apps/daemon/dist/plugins/drivers/codexMcpConfig.d.ts +40 -0
- package/apps/daemon/dist/plugins/drivers/codexMcpConfig.js +73 -0
- package/apps/daemon/dist/plugins/drivers/codexModelCompatibility.d.ts +49 -0
- package/apps/daemon/dist/plugins/drivers/codexModelCompatibility.js +70 -0
- package/apps/daemon/dist/plugins/drivers/fakePluginDriver.d.ts +16 -0
- package/apps/daemon/dist/plugins/drivers/fakePluginDriver.js +115 -0
- package/apps/daemon/dist/plugins/drivers/finiteCliDriver.d.ts +153 -0
- package/apps/daemon/dist/plugins/drivers/finiteCliDriver.js +505 -0
- package/apps/daemon/dist/plugins/registry/operationCatalog.d.ts +23 -0
- package/apps/daemon/dist/plugins/registry/operationCatalog.js +41 -0
- package/apps/daemon/dist/plugins/registry/registryOperationCatalog.d.ts +14 -0
- package/apps/daemon/dist/plugins/registry/registryOperationCatalog.js +29 -0
- package/apps/daemon/dist/plugins/registry/verifiedCapabilityRegistry.d.ts +151 -0
- package/apps/daemon/dist/plugins/registry/verifiedCapabilityRegistry.js +579 -0
- package/apps/daemon/dist/projects/codingAuthority.d.ts +102 -0
- package/apps/daemon/dist/projects/codingAuthority.js +244 -0
- package/apps/daemon/dist/projects/fixtureAuthorization.d.ts +54 -0
- package/apps/daemon/dist/projects/fixtureAuthorization.js +172 -0
- package/apps/daemon/dist/projects/pairedAuthority.d.ts +158 -0
- package/apps/daemon/dist/projects/pairedAuthority.js +273 -0
- package/apps/daemon/dist/projects/trustedCliConsent.d.ts +47 -0
- package/apps/daemon/dist/projects/trustedCliConsent.js +84 -0
- package/apps/daemon/dist/runs/changeApplier.d.ts +59 -0
- package/apps/daemon/dist/runs/changeApplier.js +319 -0
- package/apps/daemon/dist/runs/codingWorkflowService.d.ts +283 -0
- package/apps/daemon/dist/runs/codingWorkflowService.js +785 -0
- package/apps/daemon/dist/runs/durableIntentCoordinator.d.ts +72 -0
- package/apps/daemon/dist/runs/durableIntentCoordinator.js +160 -0
- package/apps/daemon/dist/runs/inMemoryCoordinator.d.ts +55 -0
- package/apps/daemon/dist/runs/inMemoryCoordinator.js +375 -0
- package/apps/daemon/dist/runs/runExecutor.d.ts +154 -0
- package/apps/daemon/dist/runs/runExecutor.js +295 -0
- package/apps/daemon/dist/runs/workflowService.d.ts +185 -0
- package/apps/daemon/dist/runs/workflowService.js +300 -0
- package/apps/daemon/dist/runtime/boundedProcessHost.d.ts +111 -0
- package/apps/daemon/dist/runtime/boundedProcessHost.js +752 -0
- package/apps/daemon/dist/runtime/evidenceRedaction.d.ts +30 -0
- package/apps/daemon/dist/runtime/evidenceRedaction.js +79 -0
- package/apps/daemon/dist/runtime/executionDiagnostics.d.ts +134 -0
- package/apps/daemon/dist/runtime/executionDiagnostics.js +213 -0
- package/apps/daemon/dist/runtime/modelExecutionPolicy.d.ts +22 -0
- package/apps/daemon/dist/runtime/modelExecutionPolicy.js +19 -0
- package/apps/daemon/dist/runtime/mxcExecution.d.ts +12 -0
- package/apps/daemon/dist/runtime/mxcExecution.js +163 -0
- package/apps/daemon/dist/runtime/mxcIntegrity.d.ts +24 -0
- package/apps/daemon/dist/runtime/mxcIntegrity.js +81 -0
- package/apps/daemon/dist/runtime/mxcWorker.d.ts +2 -0
- package/apps/daemon/dist/runtime/mxcWorker.js +45 -0
- package/apps/daemon/dist/runtime/provisionedExecution.d.ts +150 -0
- package/apps/daemon/dist/runtime/provisionedExecution.js +653 -0
- package/apps/daemon/dist/runtime/testExecution.d.ts +76 -0
- package/apps/daemon/dist/runtime/testExecution.js +106 -0
- package/apps/daemon/dist/runtime/testProfiles.d.ts +10 -0
- package/apps/daemon/dist/runtime/testProfiles.js +4 -0
- package/apps/daemon/dist/runtime/trustedAgentStaging.d.ts +89 -0
- package/apps/daemon/dist/runtime/trustedAgentStaging.js +262 -0
- package/apps/daemon/dist/runtime/trustedCaBundle.d.ts +77 -0
- package/apps/daemon/dist/runtime/trustedCaBundle.js +125 -0
- package/apps/daemon/dist/runtime/windows/windowsJobSupervisor.d.ts +166 -0
- package/apps/daemon/dist/runtime/windows/windowsJobSupervisor.js +521 -0
- package/apps/daemon/dist/storage/diagnosticLog.d.ts +63 -0
- package/apps/daemon/dist/storage/diagnosticLog.js +136 -0
- package/apps/daemon/dist/storage/executionTelemetry.d.ts +63 -0
- package/apps/daemon/dist/storage/executionTelemetry.js +247 -0
- package/apps/daemon/dist/storage/protectedSecrets.d.ts +39 -0
- package/apps/daemon/dist/storage/protectedSecrets.js +106 -0
- package/apps/daemon/dist/storage/sqliteLedger.d.ts +786 -0
- package/apps/daemon/dist/storage/sqliteLedger.js +1303 -0
- package/apps/daemon/dist/transports/http/dispatch.d.ts +43 -0
- package/apps/daemon/dist/transports/http/dispatch.js +405 -0
- package/apps/daemon/dist/transports/http/secureRoutes.d.ts +40 -0
- package/apps/daemon/dist/transports/http/secureRoutes.js +332 -0
- package/apps/daemon/dist/transports/http/workflowRoutes.d.ts +41 -0
- package/apps/daemon/dist/transports/http/workflowRoutes.js +473 -0
- package/apps/daemon/dist/transports/mcp/localProjectReadServer.d.ts +182 -0
- package/apps/daemon/dist/transports/mcp/localProjectReadServer.js +221 -0
- package/apps/daemon/dist/transports/native/nativeHost.d.ts +24 -0
- package/apps/daemon/dist/transports/native/nativeHost.js +344 -0
- package/apps/daemon/package.json +24 -0
- package/apps/daemon/src/runtime/benign/referenceEcho.mjs +27 -0
- package/apps/daemon/src/runtime/windows/buildSupervisor.mjs +87 -0
- package/apps/daemon/src/runtime/windows/supervisorMain.cs +676 -0
- package/apps/extension/manifest.secure.json +25 -0
- package/apps/extension/scripts/build.mjs +173 -0
- package/apps/extension/src/background/secureWorker.ts +1595 -0
- package/apps/extension/src/background/serviceWorker.ts +892 -0
- package/apps/extension/src/content/captureSelection.ts +64 -0
- package/apps/extension/src/content/secureInsert.ts +207 -0
- package/apps/extension/src/probe/index.html +41 -0
- package/apps/extension/src/probe/main.ts +201 -0
- package/apps/extension/src/sidepanel/index.html +203 -0
- package/apps/extension/src/sidepanel/main.ts +903 -0
- package/package.json +19 -3
- package/packages/contracts/dist/artifacts.d.ts +66 -0
- package/packages/contracts/dist/artifacts.js +64 -0
- package/packages/contracts/dist/automation.d.ts +540 -0
- package/packages/contracts/dist/automation.js +191 -0
- package/packages/contracts/dist/browser.d.ts +251 -0
- package/packages/contracts/dist/browser.js +131 -0
- package/packages/contracts/dist/context.d.ts +71 -0
- package/packages/contracts/dist/context.js +73 -0
- package/packages/contracts/dist/diagnostics.d.ts +99 -0
- package/packages/contracts/dist/diagnostics.js +284 -0
- package/packages/contracts/dist/effects.d.ts +42 -0
- package/packages/contracts/dist/effects.js +42 -0
- package/packages/contracts/dist/errors.d.ts +75 -0
- package/packages/contracts/dist/errors.js +70 -0
- package/packages/contracts/dist/events.d.ts +50 -0
- package/packages/contracts/dist/events.js +34 -0
- package/packages/contracts/dist/executionDiagnostics.d.ts +212 -0
- package/packages/contracts/dist/executionDiagnostics.js +101 -0
- package/packages/contracts/dist/identity.d.ts +54 -0
- package/packages/contracts/dist/identity.js +40 -0
- package/packages/contracts/dist/index.d.ts +20 -0
- package/packages/contracts/dist/index.js +20 -0
- package/packages/contracts/dist/invocation.d.ts +90 -0
- package/packages/contracts/dist/invocation.js +77 -0
- package/packages/contracts/dist/lifecycle.d.ts +130 -0
- package/packages/contracts/dist/lifecycle.js +135 -0
- package/packages/contracts/dist/plugin.d.ts +214 -0
- package/packages/contracts/dist/plugin.js +117 -0
- package/packages/contracts/dist/projectRead.d.ts +205 -0
- package/packages/contracts/dist/projectRead.js +162 -0
- package/packages/contracts/dist/secure.d.ts +128 -0
- package/packages/contracts/dist/secure.js +99 -0
- package/packages/contracts/package.json +32 -0
- package/packages/contracts/src/artifacts.ts +83 -0
- package/packages/contracts/src/automation.ts +238 -0
- package/packages/contracts/src/browser.ts +164 -0
- package/packages/contracts/src/context.ts +91 -0
- package/packages/contracts/src/diagnostics.ts +318 -0
- package/packages/contracts/src/effects.ts +49 -0
- package/packages/contracts/src/errors.ts +83 -0
- package/packages/contracts/src/events.ts +46 -0
- package/packages/contracts/src/executionDiagnostics.ts +116 -0
- package/packages/contracts/src/identity.ts +68 -0
- package/packages/contracts/src/index.ts +20 -0
- package/packages/contracts/src/invocation.ts +96 -0
- package/packages/contracts/src/lifecycle.ts +169 -0
- package/packages/contracts/src/plugin.ts +174 -0
- package/packages/contracts/src/projectRead.ts +179 -0
- package/packages/contracts/src/secure.ts +136 -0
- package/provenance.json +179 -9
- package/source.zip +0 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import type { AuthorizedInvocation, CancelReceipt, GitWorkingTreeStateV1, NormalizedEvent, RunLifecycleState, RunReceipt } from '../../../../packages/contracts/dist/index.js';
|
|
2
|
+
import type { ExecutionTelemetry } from '../storage/executionTelemetry.js';
|
|
3
|
+
import type { LifecycleStateName, SqliteLedger } from '../storage/sqliteLedger.js';
|
|
4
|
+
/**
|
|
5
|
+
* C05 run executor (SW-051): executes ONE already approved (QUEUED) run, exactly once, through an injected driver port.
|
|
6
|
+
*
|
|
7
|
+
* Ordering invariants, each enforced here or in the C09 transaction this module drives:
|
|
8
|
+
* 1. No process before durable intent: the C04 identity is prepared and the BEFORE Git state observed first (no process), then one
|
|
9
|
+
* BEGIN IMMEDIATE transaction re-reads the committed run, re-checks the C03 grant (revocation is honored at launch time), refuses a
|
|
10
|
+
* busy project or a run that was ever launched, and commits QUEUED -> STARTING with the single launch record. Only then is the
|
|
11
|
+
* driver invoked.
|
|
12
|
+
* 2. Never relaunch: a run id has at most one launch record; any state other than QUEUED is refused. After a restart, the existing
|
|
13
|
+
* startup reconciliation turns STARTING/RUNNING/CANCEL_REQUESTED into UNKNOWN, which this module never executes.
|
|
14
|
+
* 3. Cancel intent first: cancel() persists CANCEL_REQUESTED before signalling the driver; the terminal state is decided from the
|
|
15
|
+
* observed process evidence (confirmed tree termination -> CANCELLED; completion that won the race -> COMPLETED, flagged; anything
|
|
16
|
+
* unconfirmed -> UNKNOWN).
|
|
17
|
+
* 4. Truthful outcome: process outcome and validation are separate; validation is always NOT_VERIFIED here. An exit code of zero
|
|
18
|
+
* is COMPLETED only when the supervised tree was positively confirmed gone and the restricted identity was verified.
|
|
19
|
+
* Provider flags, parsing and process creation live behind the driver port; this module has no process capability of its own.
|
|
20
|
+
*/
|
|
21
|
+
/** Structural port to the selected C06 driver (no import of any runtime module). */
|
|
22
|
+
export interface ExecutionDriverPort {
|
|
23
|
+
readonly pluginId: string;
|
|
24
|
+
readonly executionIdentity: string;
|
|
25
|
+
/** SW-068 (optional): provider output profile, and the incremental evidence sink attachment used for execution telemetry. */
|
|
26
|
+
readonly outputProfile?: string;
|
|
27
|
+
attachObserver?(runId: string, observer: ExecutionObserverPort): void;
|
|
28
|
+
prepare(runId: string, operationId: string): Promise<{
|
|
29
|
+
ok: true;
|
|
30
|
+
plan: {
|
|
31
|
+
manifestFingerprint: string;
|
|
32
|
+
executableSha256: string;
|
|
33
|
+
timeoutMs: number;
|
|
34
|
+
executionIdentity: string;
|
|
35
|
+
inputTransport: 'ARGV' | 'STDIN' | 'NONE';
|
|
36
|
+
codeInputsSha256: string | null;
|
|
37
|
+
effectClass?: string;
|
|
38
|
+
maxOutputBytes?: number;
|
|
39
|
+
argvTemplate?: readonly string[];
|
|
40
|
+
environmentNames?: readonly string[];
|
|
41
|
+
pinnedFiles?: Readonly<Record<string, string>>;
|
|
42
|
+
};
|
|
43
|
+
} | {
|
|
44
|
+
ok: false;
|
|
45
|
+
code: string;
|
|
46
|
+
}>;
|
|
47
|
+
invoke(request: AuthorizedInvocation): Promise<RunReceipt>;
|
|
48
|
+
outcome(runId: string): Promise<DriverOutcomePort>;
|
|
49
|
+
cancel(runId: AuthorizedInvocation['runId'], reason: string): Promise<CancelReceipt>;
|
|
50
|
+
}
|
|
51
|
+
export type DriverOutcomePort = Readonly<{
|
|
52
|
+
kind: 'NOT_LAUNCHED';
|
|
53
|
+
code: string;
|
|
54
|
+
}> | Readonly<{
|
|
55
|
+
kind: 'FINISHED';
|
|
56
|
+
processOutcome: string;
|
|
57
|
+
processLaunched: boolean;
|
|
58
|
+
exitCode: number | null;
|
|
59
|
+
treeTerminated: boolean | null;
|
|
60
|
+
childTokenVerified: boolean;
|
|
61
|
+
supervisionProtocol: string | null;
|
|
62
|
+
stdoutSha256: string;
|
|
63
|
+
stdoutBytes: number;
|
|
64
|
+
stdoutTruncated: boolean;
|
|
65
|
+
stderrBytes: number;
|
|
66
|
+
stderrTruncated: boolean;
|
|
67
|
+
stdinStatus: 'NOT_REQUESTED' | 'NOT_ATTEMPTED' | 'DELIVERED_EOF' | 'EARLY_EXIT' | 'ERROR';
|
|
68
|
+
stdinBytesWritten: number | null;
|
|
69
|
+
durationMs: number;
|
|
70
|
+
finalMessage: string | null;
|
|
71
|
+
unparsedLines?: number;
|
|
72
|
+
events: readonly NormalizedEvent[];
|
|
73
|
+
}>;
|
|
74
|
+
export interface LaunchAuthorizationPort {
|
|
75
|
+
authorizeLaunch(principalId: string, projectId: string, pluginId: string, operationId: string): {
|
|
76
|
+
grantId: string;
|
|
77
|
+
} | undefined;
|
|
78
|
+
}
|
|
79
|
+
export interface GitObserverPort {
|
|
80
|
+
observe(projectId: string, canonicalRoot: string): Promise<{
|
|
81
|
+
ok: true;
|
|
82
|
+
state: GitWorkingTreeStateV1;
|
|
83
|
+
} | {
|
|
84
|
+
ok: false;
|
|
85
|
+
code: string;
|
|
86
|
+
}>;
|
|
87
|
+
}
|
|
88
|
+
export type ExecuteResult = {
|
|
89
|
+
kind: 'NOT_FOUND';
|
|
90
|
+
} | {
|
|
91
|
+
kind: 'CONFLICT';
|
|
92
|
+
code: string;
|
|
93
|
+
} | {
|
|
94
|
+
kind: 'FAILED_BEFORE_LAUNCH';
|
|
95
|
+
runId: string;
|
|
96
|
+
lifecycleState: 'FAILED';
|
|
97
|
+
reason: string;
|
|
98
|
+
} | {
|
|
99
|
+
kind: 'FINISHED';
|
|
100
|
+
runId: string;
|
|
101
|
+
lifecycleState: LifecycleStateName;
|
|
102
|
+
processOutcome: string;
|
|
103
|
+
reason: string;
|
|
104
|
+
finalMessage: string | null;
|
|
105
|
+
};
|
|
106
|
+
export type ExecutorCancelResult = {
|
|
107
|
+
kind: 'NOT_FOUND';
|
|
108
|
+
} | {
|
|
109
|
+
kind: 'CONFLICT';
|
|
110
|
+
code: string;
|
|
111
|
+
} | {
|
|
112
|
+
kind: 'CANCEL_REQUESTED';
|
|
113
|
+
acknowledged: boolean;
|
|
114
|
+
processTerminated: boolean;
|
|
115
|
+
};
|
|
116
|
+
type Hop = {
|
|
117
|
+
state: RunLifecycleState;
|
|
118
|
+
reason: string;
|
|
119
|
+
};
|
|
120
|
+
/** Pure classification of observed process evidence into lifecycle hops from the committed current state. Exported for tests. */
|
|
121
|
+
export declare function classifyOutcome(current: LifecycleStateName, o: DriverOutcomePort): {
|
|
122
|
+
hops: Hop[];
|
|
123
|
+
racing: boolean;
|
|
124
|
+
};
|
|
125
|
+
/** Structural evidence sink handed to the driver (identical in shape to the process host's observer; this module names no runtime module). */
|
|
126
|
+
export interface ExecutionObserverPort {
|
|
127
|
+
lifecycle(stage: string, data?: Record<string, string | number | boolean | null>): void;
|
|
128
|
+
chunk(stream: 'stdout' | 'stderr', bytes: Uint8Array): void;
|
|
129
|
+
}
|
|
130
|
+
export interface ExecutorTelemetryOptions {
|
|
131
|
+
readonly telemetry?: ExecutionTelemetry;
|
|
132
|
+
/**
|
|
133
|
+
* SW-068 acceptance gate: when true the executor FAILS CLOSED - if execution telemetry cannot be written, no external process is launched (the run ends FAILED with
|
|
134
|
+
* reason TELEMETRY_UNAVAILABLE before launch intent is committed, or NOT_LAUNCHED_TELEMETRY_UNAVAILABLE if it failed after it). Required for every real-CLI operation.
|
|
135
|
+
*/
|
|
136
|
+
readonly requireTelemetry?: boolean;
|
|
137
|
+
}
|
|
138
|
+
export declare class RunExecutor {
|
|
139
|
+
private readonly ledger;
|
|
140
|
+
private readonly authority;
|
|
141
|
+
private readonly driver;
|
|
142
|
+
private readonly git;
|
|
143
|
+
private readonly now;
|
|
144
|
+
private readonly tel;
|
|
145
|
+
private readonly inflight;
|
|
146
|
+
constructor(ledger: SqliteLedger, authority: LaunchAuthorizationPort, driver: ExecutionDriverPort, git: GitObserverPort, now?: () => number, tel?: ExecutorTelemetryOptions);
|
|
147
|
+
private iso;
|
|
148
|
+
execute(principalId: string, runId: string): Promise<ExecuteResult>;
|
|
149
|
+
private executeQueued;
|
|
150
|
+
/** Cancel of a run executing in THIS process: CANCEL_REQUESTED is committed before the driver is signalled. */
|
|
151
|
+
cancel(principalId: string, runId: string): Promise<ExecutorCancelResult>;
|
|
152
|
+
}
|
|
153
|
+
export {};
|
|
154
|
+
//# sourceMappingURL=runExecutor.d.ts.map
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { validatedPath } from './durableIntentCoordinator.js';
|
|
2
|
+
const toGitRow = (r, nowIso) => r.ok
|
|
3
|
+
? { status: 'OBSERVED', branch: r.state.branch, headCommit: r.state.headCommit, clean: r.state.clean, dirtyFiles: [...r.state.dirtyFiles], untrackedFiles: [...r.state.untrackedFiles], observedAt: r.state.observedAt }
|
|
4
|
+
: { status: 'FAILED', failureCode: r.code, observedAt: nowIso };
|
|
5
|
+
/** Pure classification of observed process evidence into lifecycle hops from the committed current state. Exported for tests. */
|
|
6
|
+
export function classifyOutcome(current, o) {
|
|
7
|
+
const cancelReq = current === 'CANCEL_REQUESTED';
|
|
8
|
+
const run = (hops) => (cancelReq ? hops : [{ state: 'RUNNING', reason: 'PROCESS_OBSERVED' }, ...hops]);
|
|
9
|
+
if (o.kind === 'NOT_LAUNCHED') {
|
|
10
|
+
return { hops: [cancelReq ? { state: 'CANCELLED', reason: 'CANCELLED_BEFORE_LAUNCH' } : { state: 'FAILED', reason: `NOT_LAUNCHED_${o.code}` }], racing: false };
|
|
11
|
+
}
|
|
12
|
+
if (!o.processLaunched) {
|
|
13
|
+
if (o.processOutcome === 'CANCELLED')
|
|
14
|
+
return { hops: cancelReq ? [{ state: 'CANCELLED', reason: 'CANCELLED_BEFORE_RESUME' }] : [{ state: 'FAILED', reason: 'CANCELLED_WITHOUT_INTENT' }], racing: false };
|
|
15
|
+
return { hops: [{ state: 'FAILED', reason: `NOT_LAUNCHED_${o.processOutcome}` }], racing: false };
|
|
16
|
+
}
|
|
17
|
+
const confirmed = o.treeTerminated === true && o.supervisionProtocol === 'OK' && o.childTokenVerified;
|
|
18
|
+
if (!confirmed)
|
|
19
|
+
return { hops: [{ state: 'UNKNOWN', reason: o.childTokenVerified ? 'TREE_NOT_CONFIRMED' : 'IDENTITY_NOT_CONFIRMED' }], racing: false };
|
|
20
|
+
switch (o.processOutcome) {
|
|
21
|
+
case 'EXITED':
|
|
22
|
+
// SW-052: when stdin delivery was requested, a zero exit is NOT a completion unless every byte was written and EOF was signalled.
|
|
23
|
+
if (o.exitCode === 0 && o.stdinStatus !== 'NOT_REQUESTED' && o.stdinStatus !== 'DELIVERED_EOF')
|
|
24
|
+
return { hops: run([{ state: 'FAILED', reason: 'INPUT_NOT_DELIVERED_' + o.stdinStatus }]), racing: false };
|
|
25
|
+
if (o.exitCode === 0)
|
|
26
|
+
return cancelReq ? { hops: [{ state: 'COMPLETED', reason: 'COMPLETED_RACED_CANCEL' }], racing: true } : { hops: run([{ state: 'COMPLETED', reason: 'PROCESS_EXITED_ZERO' }]), racing: false };
|
|
27
|
+
return { hops: run([{ state: 'FAILED', reason: 'PROCESS_EXITED_NONZERO' }]), racing: false };
|
|
28
|
+
case 'CANCELLED':
|
|
29
|
+
return { hops: cancelReq ? [{ state: 'CANCELLED', reason: 'CANCELLED_TREE_CONFIRMED' }] : [{ state: 'CANCEL_REQUESTED', reason: 'HOST_CLOSED' }, { state: 'CANCELLED', reason: 'CANCELLED_TREE_CONFIRMED' }], racing: false };
|
|
30
|
+
case 'TIMEOUT':
|
|
31
|
+
case 'OUTPUT_LIMIT_EXCEEDED':
|
|
32
|
+
return { hops: run([{ state: 'FAILED', reason: o.processOutcome }]), racing: false };
|
|
33
|
+
default:
|
|
34
|
+
return { hops: [{ state: 'UNKNOWN', reason: `UNCLASSIFIED_${o.processOutcome}` }], racing: false };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export class RunExecutor {
|
|
38
|
+
ledger;
|
|
39
|
+
authority;
|
|
40
|
+
driver;
|
|
41
|
+
git;
|
|
42
|
+
now;
|
|
43
|
+
tel;
|
|
44
|
+
inflight = new Set();
|
|
45
|
+
constructor(ledger, authority, driver, git, now = Date.now, tel = {}) {
|
|
46
|
+
this.ledger = ledger;
|
|
47
|
+
this.authority = authority;
|
|
48
|
+
this.driver = driver;
|
|
49
|
+
this.git = git;
|
|
50
|
+
this.now = now;
|
|
51
|
+
this.tel = tel;
|
|
52
|
+
}
|
|
53
|
+
iso() {
|
|
54
|
+
return new Date(this.now()).toISOString();
|
|
55
|
+
}
|
|
56
|
+
async execute(principalId, runId) {
|
|
57
|
+
const input = this.ledger.getRunExecutionInput(principalId, runId);
|
|
58
|
+
if (!input)
|
|
59
|
+
return { kind: 'NOT_FOUND' };
|
|
60
|
+
const { run } = input;
|
|
61
|
+
if (run.lifecycleState !== 'QUEUED')
|
|
62
|
+
return { kind: 'CONFLICT', code: 'NOT_QUEUED' };
|
|
63
|
+
if (run.pluginId !== this.driver.pluginId)
|
|
64
|
+
return { kind: 'CONFLICT', code: 'NO_DRIVER_FOR_PLUGIN' };
|
|
65
|
+
if (this.inflight.has(runId))
|
|
66
|
+
return { kind: 'CONFLICT', code: 'ALREADY_EXECUTING' };
|
|
67
|
+
this.inflight.add(runId);
|
|
68
|
+
try {
|
|
69
|
+
return await this.executeQueued(principalId, input);
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
this.inflight.delete(runId);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
async executeQueued(principalId, input) {
|
|
76
|
+
const { run, projectRoot } = input;
|
|
77
|
+
const prep = await this.driver.prepare(run.runId, run.operationId); // no process
|
|
78
|
+
const before = prep.ok ? await this.git.observe(run.projectId, projectRoot) : undefined; // no agent process
|
|
79
|
+
const nowIso = this.iso();
|
|
80
|
+
let telemetryReady = true;
|
|
81
|
+
if (this.tel.requireTelemetry === true) {
|
|
82
|
+
try {
|
|
83
|
+
if (!this.tel.telemetry)
|
|
84
|
+
throw new Error('NO_TELEMETRY');
|
|
85
|
+
this.tel.telemetry.assertWritable();
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
telemetryReady = false;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
let grantId;
|
|
92
|
+
const committed = this.ledger.commitLaunch(principalId, run.runId, nowIso, (ctx) => {
|
|
93
|
+
if (ctx.run.lifecycleState !== 'QUEUED')
|
|
94
|
+
return { kind: 'REJECT', code: 'NOT_QUEUED' };
|
|
95
|
+
if (ctx.alreadyLaunched)
|
|
96
|
+
return { kind: 'REJECT', code: 'ALREADY_LAUNCHED' };
|
|
97
|
+
if (ctx.otherActiveRunsOnProject > 0)
|
|
98
|
+
return { kind: 'REJECT', code: 'WORKTREE_BUSY' };
|
|
99
|
+
const promptOk = ctx.promptSnapshot !== undefined && ctx.promptSnapshot.sha256 === ctx.storedPromptSha256 && ctx.promptSnapshot.sha256 === input.promptSnapshotSha256;
|
|
100
|
+
const fail = (reason, gitBefore) => ({
|
|
101
|
+
kind: 'FAIL',
|
|
102
|
+
states: validatedPath('QUEUED', [{ state: 'STARTING', reason: 'LAUNCH_EVALUATED' }, { state: 'FAILED', reason }]),
|
|
103
|
+
...(gitBefore ? { gitBefore } : {}),
|
|
104
|
+
});
|
|
105
|
+
const grant = this.authority.authorizeLaunch(ctx.run.principalId, ctx.run.projectId, ctx.run.pluginId, ctx.run.operationId);
|
|
106
|
+
if (!grant)
|
|
107
|
+
return fail('GRANT_DENIED_AT_LAUNCH');
|
|
108
|
+
if (!prep.ok)
|
|
109
|
+
return fail(`PREPARE_${prep.code}`);
|
|
110
|
+
if (!telemetryReady)
|
|
111
|
+
return fail('TELEMETRY_UNAVAILABLE');
|
|
112
|
+
if (!promptOk)
|
|
113
|
+
return fail(ctx.promptSnapshot === undefined ? 'PROMPT_SNAPSHOT_MISSING' : 'PROMPT_DIGEST_MISMATCH');
|
|
114
|
+
if (prep.plan.executionIdentity !== 'RESTRICTED_LOW_INTEGRITY' || this.driver.executionIdentity !== 'RESTRICTED_LOW_INTEGRITY')
|
|
115
|
+
return fail('IDENTITY_UNSUPPORTED');
|
|
116
|
+
if (!before || !before.ok)
|
|
117
|
+
return fail('GIT_OBSERVATION_FAILED', before ? toGitRow(before, nowIso) : undefined);
|
|
118
|
+
grantId = grant.grantId;
|
|
119
|
+
return {
|
|
120
|
+
kind: 'LAUNCH',
|
|
121
|
+
states: validatedPath('QUEUED', [{ state: 'STARTING', reason: 'LAUNCH_INTENT_COMMITTED' }]),
|
|
122
|
+
launch: {
|
|
123
|
+
authorizationGrantId: grant.grantId,
|
|
124
|
+
manifestFingerprint: prep.plan.manifestFingerprint,
|
|
125
|
+
executableSha256: prep.plan.executableSha256,
|
|
126
|
+
executionIdentity: 'RESTRICTED_LOW_INTEGRITY',
|
|
127
|
+
securityTier: 'PATH_CHECKS_ONLY',
|
|
128
|
+
promptSha256: ctx.promptSnapshot.sha256,
|
|
129
|
+
promptBytes: ctx.promptSnapshot.bytes,
|
|
130
|
+
// SW-053: a fixed prompt-less command (transport NONE) records NULL; the ledger never claims a transport that did not carry the prompt.
|
|
131
|
+
...(prep.plan.inputTransport === 'NONE' ? {} : { inputTransport: prep.plan.inputTransport }),
|
|
132
|
+
codeInputsSha256: prep.plan.codeInputsSha256,
|
|
133
|
+
},
|
|
134
|
+
gitBefore: toGitRow(before, nowIso),
|
|
135
|
+
};
|
|
136
|
+
});
|
|
137
|
+
if (committed.kind === 'NOT_FOUND')
|
|
138
|
+
return { kind: 'NOT_FOUND' };
|
|
139
|
+
if (committed.kind === 'REJECTED')
|
|
140
|
+
return { kind: 'CONFLICT', code: committed.code };
|
|
141
|
+
if (committed.kind === 'FAILED') {
|
|
142
|
+
const ev = this.ledger.getRunEvidence(run.runId).lifecycle;
|
|
143
|
+
const failReason = ev[ev.length - 1]?.reason ?? 'FAILED';
|
|
144
|
+
// SW-068: a failure BEFORE any process (invalid executable, denied grant, unavailable telemetry...) still leaves a classified evidence record when the store allows it.
|
|
145
|
+
if (this.tel.telemetry) {
|
|
146
|
+
try {
|
|
147
|
+
const zero = '0'.repeat(64);
|
|
148
|
+
const rt0 = this.tel.telemetry.begin({
|
|
149
|
+
runId: run.runId, driver: this.driver.pluginId, outputProfile: this.driver.outputProfile ?? null, pluginId: run.pluginId, operationId: run.operationId,
|
|
150
|
+
executableSha256: prep.ok ? prep.plan.executableSha256 : zero, manifestFingerprint: prep.ok ? prep.plan.manifestFingerprint : zero, prompt: '', config: { prelaunch: true, reason: failReason },
|
|
151
|
+
});
|
|
152
|
+
rt0.stage('FAILED_PRELAUNCH', { reason: failReason });
|
|
153
|
+
rt0.finish({ lifecycleState: 'FAILED', observed: { kind: 'NOT_LAUNCHED', code: failReason } });
|
|
154
|
+
}
|
|
155
|
+
catch { /* no evidence store: the lifecycle reason above is still durable */ }
|
|
156
|
+
}
|
|
157
|
+
return { kind: 'FAILED_BEFORE_LAUNCH', runId: run.runId, lifecycleState: 'FAILED', reason: failReason };
|
|
158
|
+
}
|
|
159
|
+
if (!prep.ok || grantId === undefined)
|
|
160
|
+
throw new Error('UNREACHABLE_LAUNCH_STATE');
|
|
161
|
+
// ---- durable intent is committed; from here a process may exist ----
|
|
162
|
+
const invocation = {
|
|
163
|
+
schemaVersion: 1,
|
|
164
|
+
runId: run.runId,
|
|
165
|
+
projectId: run.projectId,
|
|
166
|
+
pluginId: run.pluginId,
|
|
167
|
+
operationId: run.operationId,
|
|
168
|
+
authorizationGrantId: grantId,
|
|
169
|
+
idempotencyKey: input.idempotencyKey,
|
|
170
|
+
params: { prompt: input.promptText, promptSha256: input.promptSnapshotSha256 },
|
|
171
|
+
workingDirectory: projectRoot,
|
|
172
|
+
securityTier: 'PATH_CHECKS_ONLY',
|
|
173
|
+
timeoutMs: prep.plan.timeoutMs,
|
|
174
|
+
createdAt: this.iso(),
|
|
175
|
+
};
|
|
176
|
+
let observed;
|
|
177
|
+
// SW-068: the evidence header is written BEFORE any external process can exist. When telemetry is required and cannot be written, nothing is launched.
|
|
178
|
+
let rt;
|
|
179
|
+
let telemetryFailed = false;
|
|
180
|
+
if (this.tel.telemetry) {
|
|
181
|
+
try {
|
|
182
|
+
const plan = prep.plan;
|
|
183
|
+
rt = this.tel.telemetry.begin({
|
|
184
|
+
runId: run.runId, driver: this.driver.pluginId, outputProfile: this.driver.outputProfile ?? null, pluginId: run.pluginId, operationId: run.operationId,
|
|
185
|
+
executableSha256: plan.executableSha256, manifestFingerprint: plan.manifestFingerprint, prompt: input.promptText,
|
|
186
|
+
config: {
|
|
187
|
+
effectClass: plan.effectClass ?? null, executionIdentity: plan.executionIdentity, securityTier: 'PATH_CHECKS_ONLY', timeoutMs: plan.timeoutMs, inputTransport: plan.inputTransport,
|
|
188
|
+
argvTemplate: plan.argvTemplate ?? null, maxOutputBytes: plan.maxOutputBytes ?? null, promptBytes: Buffer.byteLength(input.promptText, 'utf8'), promptSha256: input.promptSnapshotSha256,
|
|
189
|
+
codeInputsSha256: plan.codeInputsSha256, environmentNames: plan.environmentNames ?? null, pinnedFiles: plan.pinnedFiles ?? null,
|
|
190
|
+
},
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
catch {
|
|
194
|
+
telemetryFailed = true;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (telemetryFailed && this.tel.requireTelemetry === true) {
|
|
198
|
+
observed = { kind: 'NOT_LAUNCHED', code: 'TELEMETRY_UNAVAILABLE' };
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
try {
|
|
202
|
+
if (rt && this.driver.attachObserver) {
|
|
203
|
+
this.driver.attachObserver(run.runId, rt.observer);
|
|
204
|
+
rt.stage('DRIVER_INVOKE_REQUESTED');
|
|
205
|
+
}
|
|
206
|
+
await this.driver.invoke(invocation);
|
|
207
|
+
observed = await this.driver.outcome(run.runId);
|
|
208
|
+
}
|
|
209
|
+
catch (e) {
|
|
210
|
+
const code = typeof e?.code === 'string' ? e.code : 'INVOKE_FAILED';
|
|
211
|
+
observed = { kind: 'NOT_LAUNCHED', code };
|
|
212
|
+
try {
|
|
213
|
+
rt?.stage('FAILED_INVOKE', { code });
|
|
214
|
+
}
|
|
215
|
+
catch { /* best-effort */ }
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
const after = await this.git.observe(run.projectId, projectRoot);
|
|
219
|
+
const endIso = this.iso();
|
|
220
|
+
let summary;
|
|
221
|
+
const recorded = this.ledger.commitRunOutcome(run.runId, endIso, (cur) => {
|
|
222
|
+
if (cur.lifecycleState !== 'STARTING' && cur.lifecycleState !== 'CANCEL_REQUESTED')
|
|
223
|
+
return { kind: 'REJECT', code: `STATE_${cur.lifecycleState}` };
|
|
224
|
+
const { hops, racing } = classifyOutcome(cur.lifecycleState, observed);
|
|
225
|
+
const states = validatedPath(cur.lifecycleState, hops);
|
|
226
|
+
summary = states[states.length - 1];
|
|
227
|
+
const f = observed.kind === 'FINISHED' ? observed : undefined;
|
|
228
|
+
const outcome = {
|
|
229
|
+
processOutcome: f ? f.processOutcome : 'NOT_LAUNCHED',
|
|
230
|
+
processLaunched: f ? f.processLaunched : false,
|
|
231
|
+
exitCode: f ? f.exitCode : null,
|
|
232
|
+
treeTerminated: f ? f.treeTerminated : null,
|
|
233
|
+
childTokenVerified: f ? f.childTokenVerified : false,
|
|
234
|
+
stdoutSha256: f ? f.stdoutSha256 : null,
|
|
235
|
+
stdoutBytes: f ? f.stdoutBytes : null,
|
|
236
|
+
stdoutTruncated: f ? f.stdoutTruncated : null,
|
|
237
|
+
stderrBytes: f ? f.stderrBytes : null,
|
|
238
|
+
stderrTruncated: f ? f.stderrTruncated : null,
|
|
239
|
+
durationMs: f ? Math.round(f.durationMs) : null,
|
|
240
|
+
finalMessage: f ? f.finalMessage : null,
|
|
241
|
+
validationStatus: 'NOT_VERIFIED',
|
|
242
|
+
cancellationRacing: racing,
|
|
243
|
+
stdinStatus: f ? f.stdinStatus : null,
|
|
244
|
+
stdinBytesWritten: f ? f.stdinBytesWritten : null,
|
|
245
|
+
};
|
|
246
|
+
const events = (f ? f.events : []).map((e) => ({
|
|
247
|
+
eventId: e.eventId, eventKind: e.eventKind, payload: e.payload, ...(e.nativeSessionId ? { nativeSessionId: e.nativeSessionId } : {}), occurredAt: e.timestamp,
|
|
248
|
+
}));
|
|
249
|
+
return { kind: 'APPLY', states, outcome, events, gitAfter: toGitRow(after, endIso) };
|
|
250
|
+
});
|
|
251
|
+
if (recorded.kind === 'RECORDED' && summary && rt) {
|
|
252
|
+
try {
|
|
253
|
+
rt.stage('OUTCOME_COMMITTED', { state: summary.state, reason: summary.reason });
|
|
254
|
+
const f = observed.kind === 'FINISHED' ? observed : undefined;
|
|
255
|
+
rt.finish({
|
|
256
|
+
lifecycleState: summary.state,
|
|
257
|
+
observed: observed.kind === 'NOT_LAUNCHED' ? { kind: 'NOT_LAUNCHED', code: observed.code }
|
|
258
|
+
: f ? { kind: 'FINISHED', processOutcome: f.processOutcome, processLaunched: f.processLaunched, exitCode: f.exitCode, treeTerminated: f.treeTerminated, childTokenVerified: f.childTokenVerified, stdinStatus: f.stdinStatus, hasFinalMessage: f.finalMessage !== null, unparsedLines: f.unparsedLines ?? 0 } : { kind: 'NONE' },
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
catch { /* evidence finalization is best-effort; the recorded rows remain and the export recomputes */ }
|
|
262
|
+
}
|
|
263
|
+
if (recorded.kind !== 'RECORDED' || !summary)
|
|
264
|
+
return { kind: 'CONFLICT', code: recorded.kind === 'REJECTED' ? recorded.code : 'NOT_FOUND' };
|
|
265
|
+
return {
|
|
266
|
+
kind: 'FINISHED',
|
|
267
|
+
runId: run.runId,
|
|
268
|
+
lifecycleState: summary.state,
|
|
269
|
+
reason: summary.reason,
|
|
270
|
+
processOutcome: observed.kind === 'FINISHED' ? observed.processOutcome : 'NOT_LAUNCHED',
|
|
271
|
+
finalMessage: observed.kind === 'FINISHED' ? observed.finalMessage : null,
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
/** Cancel of a run executing in THIS process: CANCEL_REQUESTED is committed before the driver is signalled. */
|
|
275
|
+
async cancel(principalId, runId) {
|
|
276
|
+
if (!this.inflight.has(runId)) {
|
|
277
|
+
return this.ledger.getRunForPrincipal(principalId, runId) ? { kind: 'CONFLICT', code: 'NOT_EXECUTING_HERE' } : { kind: 'NOT_FOUND' };
|
|
278
|
+
}
|
|
279
|
+
const res = this.ledger.applyDecision(principalId, runId, undefined, this.iso(), (run) => {
|
|
280
|
+
if (run.lifecycleState === 'CANCEL_REQUESTED')
|
|
281
|
+
return { kind: 'REPLAY' };
|
|
282
|
+
if (run.lifecycleState === 'STARTING' || run.lifecycleState === 'RUNNING' || run.lifecycleState === 'WAITING_AGENT_APPROVAL') {
|
|
283
|
+
return { kind: 'APPLY', states: validatedPath(run.lifecycleState, [{ state: 'CANCEL_REQUESTED', reason: 'USER_CANCEL_REQUESTED' }]) };
|
|
284
|
+
}
|
|
285
|
+
return { kind: 'REJECT', code: 'CONFLICT' };
|
|
286
|
+
});
|
|
287
|
+
if (res.kind === 'NOT_FOUND')
|
|
288
|
+
return { kind: 'NOT_FOUND' };
|
|
289
|
+
if (res.kind === 'REJECTED')
|
|
290
|
+
return { kind: 'CONFLICT', code: res.code };
|
|
291
|
+
const receipt = await this.driver.cancel(runId, 'USER_CANCEL_REQUESTED');
|
|
292
|
+
return { kind: 'CANCEL_REQUESTED', acknowledged: receipt.acknowledged, processTerminated: receipt.processTerminated };
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
//# sourceMappingURL=runExecutor.js.map
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { type ActivityResponse, type CaptureFidelity, type TabBindingV1, type WorkflowCurrentResponseV1 } from '../../../../packages/contracts/dist/index.js';
|
|
2
|
+
import type { PairedAuthority, ConsentMode } from '../projects/pairedAuthority.js';
|
|
3
|
+
import type { ReturnStateName, SqliteLedger, ReturnSnapshotRow } from '../storage/sqliteLedger.js';
|
|
4
|
+
import type { Sealer } from '../storage/protectedSecrets.js';
|
|
5
|
+
import { DurableIntentCoordinator } from './durableIntentCoordinator.js';
|
|
6
|
+
import type { ExecutionTelemetry } from '../storage/executionTelemetry.js';
|
|
7
|
+
/**
|
|
8
|
+
* C05 durable workflow (SW-062). The daemon's SQLite is the single source of truth for "where is the user in capture -> run -> return"; the MV3 worker is
|
|
9
|
+
* a stateless handler that can be killed at any time and resumes from here. This module DRIVES the existing coordinator (it never writes lifecycle itself)
|
|
10
|
+
* and the existing C03 authority (it never decides admission itself):
|
|
11
|
+
*
|
|
12
|
+
* - a capture is stored encrypted, bound to the exact tab/document of the gesture, TTL-limited, and can feed exactly ONE run;
|
|
13
|
+
* - runCapture() is idempotent per capture (the request and idempotency keys are derived from the capture id): a duplicate click, a retry after a lost
|
|
14
|
+
* reply or a worker restart can never create a second run, and a run is never re-dispatched;
|
|
15
|
+
* - when C03 says the admitting grant is RUN_CLICK (trusted local setup, verified read only) the user's Run click is the per-run consent: a single-use
|
|
16
|
+
* approval challenge is issued and consumed in-process (never on the wire). Anything else stays AWAITING_USER_APPROVAL for the separate local confirmation;
|
|
17
|
+
* - the return has its own append-only state machine (RETURN_READY / INSERTED_UNSENT / RETURN_STALE / INSERT_FAILED), separate from the run lifecycle.
|
|
18
|
+
*/
|
|
19
|
+
export type WorkflowError = 'CAPTURE_NOT_FOUND' | 'CAPTURE_EXPIRED' | 'CAPTURE_CONFLICT' | 'CAPTURE_INVALID' | 'GRANT_DENIED' | 'NOT_FOUND' | 'RETURN_NOT_AVAILABLE' | 'RETURN_CHANGED' | 'ALREADY_INSERTED' | 'STATE_CONFLICT' | 'SEAL_FAILED' | 'RUN_NOT_RUNNABLE';
|
|
20
|
+
export declare class WorkflowRefusal extends Error {
|
|
21
|
+
readonly code: WorkflowError;
|
|
22
|
+
constructor(code: WorkflowError);
|
|
23
|
+
}
|
|
24
|
+
export declare class WorkflowService {
|
|
25
|
+
private readonly ledger;
|
|
26
|
+
private readonly authority;
|
|
27
|
+
private readonly coordinator;
|
|
28
|
+
private readonly sealer;
|
|
29
|
+
private readonly now;
|
|
30
|
+
/** SW-068: lets the workflow show a failed execution's category and correlation id directly. */
|
|
31
|
+
private readonly telemetry?;
|
|
32
|
+
private readonly presentation?;
|
|
33
|
+
constructor(ledger: SqliteLedger, authority: PairedAuthority, coordinator: DurableIntentCoordinator, sealer: () => Sealer, now?: () => number,
|
|
34
|
+
/** SW-068: lets the workflow show a failed execution's category and correlation id directly. */
|
|
35
|
+
telemetry?: ExecutionTelemetry | undefined, presentation?: ((pluginId: string, operationId: string) => {
|
|
36
|
+
agentLabel: string;
|
|
37
|
+
coding: boolean;
|
|
38
|
+
strictReady?: boolean;
|
|
39
|
+
} | undefined) | undefined);
|
|
40
|
+
private iso;
|
|
41
|
+
private openCapture;
|
|
42
|
+
storeCapture(principalId: string, input: {
|
|
43
|
+
text: string;
|
|
44
|
+
sha256: string;
|
|
45
|
+
bytes: number;
|
|
46
|
+
binding: TabBindingV1;
|
|
47
|
+
fidelity: CaptureFidelity;
|
|
48
|
+
lineEndingsNormalized?: number;
|
|
49
|
+
editOf?: string;
|
|
50
|
+
}): {
|
|
51
|
+
captureId: string;
|
|
52
|
+
createdAt: string;
|
|
53
|
+
expiresAt: string;
|
|
54
|
+
duplicate: boolean;
|
|
55
|
+
sha256: string;
|
|
56
|
+
bytes: number;
|
|
57
|
+
};
|
|
58
|
+
/** Idempotent capture -> run. `launch` is true ONLY for the single call whose approval committed QUEUED. */
|
|
59
|
+
runCapture(principalId: string, captureId: string, op: {
|
|
60
|
+
projectId: string;
|
|
61
|
+
pluginId: string;
|
|
62
|
+
operationId: string;
|
|
63
|
+
}): {
|
|
64
|
+
runId: string;
|
|
65
|
+
lifecycleState: string;
|
|
66
|
+
duplicate: boolean;
|
|
67
|
+
consent: ConsentMode;
|
|
68
|
+
effectClass: string;
|
|
69
|
+
launch: boolean;
|
|
70
|
+
};
|
|
71
|
+
/** Trusted LOCAL confirmation of a pending (non-run-click) run. Reachable only from the local admin channel, never from the browser. */
|
|
72
|
+
confirmLocally(principalId: string, runId: string): {
|
|
73
|
+
lifecycleState: string;
|
|
74
|
+
launch: boolean;
|
|
75
|
+
};
|
|
76
|
+
pendingConfirmations(principalId: string): Array<{
|
|
77
|
+
runId: string;
|
|
78
|
+
projectId: string;
|
|
79
|
+
pluginId: string;
|
|
80
|
+
operationId: string;
|
|
81
|
+
effectClass: string;
|
|
82
|
+
createdAt: string;
|
|
83
|
+
promptBytes: number;
|
|
84
|
+
}>;
|
|
85
|
+
/** Called after the immutable return snapshot exists: its first target is the tab/document the run departed from (if it came from a capture). */
|
|
86
|
+
ensureOriginTarget(principalId: string, snapshot: ReturnSnapshotRow): void;
|
|
87
|
+
private captureOfRun;
|
|
88
|
+
private targetOf;
|
|
89
|
+
private snapshotFor;
|
|
90
|
+
/** Records what the worker observed. INSERTED_UNSENT is terminal: a return is never inserted twice, even after any restart. */
|
|
91
|
+
recordReceipt(principalId: string, returnId: string, r: {
|
|
92
|
+
state: 'INSERTED_UNSENT' | 'RETURN_STALE' | 'INSERT_FAILED';
|
|
93
|
+
code?: string;
|
|
94
|
+
editor?: string;
|
|
95
|
+
sha256: string;
|
|
96
|
+
}): ReturnStateName;
|
|
97
|
+
/** The user's explicit choice of a NEW target for the SAME immutable result. The CLI is not re-run; validation of the tab happens in the worker first. */
|
|
98
|
+
rebind(principalId: string, returnId: string, sha256: string, binding: TabBindingV1): number;
|
|
99
|
+
setPreference(principalId: string, p: {
|
|
100
|
+
projectId: string;
|
|
101
|
+
pluginId: string;
|
|
102
|
+
operationId: string;
|
|
103
|
+
}): boolean;
|
|
104
|
+
dismiss(principalId: string, captureId: string): boolean;
|
|
105
|
+
current(principalId: string): WorkflowCurrentResponseV1;
|
|
106
|
+
/** Meaningful durable-state revision. Observation time is deliberately absent: quiet health does not manufacture activity. */
|
|
107
|
+
revision(principalId: string, snapshot?: {
|
|
108
|
+
schemaVersion: 1;
|
|
109
|
+
operations: {
|
|
110
|
+
projectId: string;
|
|
111
|
+
pluginId: string;
|
|
112
|
+
operationId: string;
|
|
113
|
+
effectClass: "read" | "write_project" | "external_network" | "destructive";
|
|
114
|
+
consent: "LOCAL_CONFIRM" | "RUN_CLICK";
|
|
115
|
+
expiresAt: string;
|
|
116
|
+
projectLabel?: string | undefined;
|
|
117
|
+
agentLabel?: string | undefined;
|
|
118
|
+
coding?: boolean | undefined;
|
|
119
|
+
strictReady?: boolean | undefined;
|
|
120
|
+
}[];
|
|
121
|
+
preferred: {
|
|
122
|
+
projectId: string;
|
|
123
|
+
pluginId: string;
|
|
124
|
+
operationId: string;
|
|
125
|
+
} | null;
|
|
126
|
+
capture: {
|
|
127
|
+
captureId: string;
|
|
128
|
+
text: string;
|
|
129
|
+
sha256: string;
|
|
130
|
+
bytes: number;
|
|
131
|
+
createdAt: string;
|
|
132
|
+
expiresAt: string;
|
|
133
|
+
state: "EXPIRED" | "CAPTURED" | "DISPATCHED";
|
|
134
|
+
binding: {
|
|
135
|
+
tabId: number;
|
|
136
|
+
windowId: number;
|
|
137
|
+
frameId: 0;
|
|
138
|
+
documentId: string;
|
|
139
|
+
nonce: string;
|
|
140
|
+
sourceUrl: string;
|
|
141
|
+
};
|
|
142
|
+
fidelity: "CAPTURED_RENDERED_TEXT" | "PASTED_PLAIN_TEXT" | "EDITED_TASK_TEXT";
|
|
143
|
+
lineEndingsNormalized: number;
|
|
144
|
+
} | null;
|
|
145
|
+
run: {
|
|
146
|
+
runId: string;
|
|
147
|
+
lifecycleState: "CREATED" | "AWAITING_USER_APPROVAL" | "QUEUED" | "STARTING" | "RUNNING" | "WAITING_AGENT_APPROVAL" | "CANCEL_REQUESTED" | "COMPLETED" | "FAILED" | "CANCELLED" | "UNKNOWN";
|
|
148
|
+
updatedAt: string;
|
|
149
|
+
consent: "LOCAL_CONFIRM" | "RUN_CLICK";
|
|
150
|
+
failure?: {
|
|
151
|
+
category: "CANCELLED" | "TIMEOUT" | "EXECUTABLE_INVALID" | "AUTHENTICATION_FAILURE" | "AUTHORIZATION_FAILURE" | "NETWORK_OR_TLS_FAILURE" | "PROVIDER_REJECTION" | "RATE_OR_USAGE_LIMIT" | "SANDBOX_FAILURE" | "PROCESS_START_FAILURE" | "PROCESS_EXIT_FAILURE" | "EVENT_PROTOCOL_ERROR" | "UNKNOWN_OUTCOME" | "UNCLASSIFIED_FAILURE";
|
|
152
|
+
basis: "OBSERVED_ERROR_TEXT" | "INFERRED" | "OBSERVED_HOST_FACT" | "NOT_DETERMINED";
|
|
153
|
+
causeDetermined: boolean;
|
|
154
|
+
correlationId: string;
|
|
155
|
+
} | null | undefined;
|
|
156
|
+
} | null;
|
|
157
|
+
ret: {
|
|
158
|
+
returnId: string;
|
|
159
|
+
sha256: string;
|
|
160
|
+
bytes: number;
|
|
161
|
+
text: string;
|
|
162
|
+
state: "RETURN_READY" | "INSERTED_UNSENT" | "RETURN_STALE" | "INSERT_FAILED";
|
|
163
|
+
code: string | null;
|
|
164
|
+
binding: {
|
|
165
|
+
tabId: number;
|
|
166
|
+
windowId: number;
|
|
167
|
+
frameId: 0;
|
|
168
|
+
documentId: string;
|
|
169
|
+
nonce: string;
|
|
170
|
+
sourceUrl: string;
|
|
171
|
+
};
|
|
172
|
+
rebinds: number;
|
|
173
|
+
} | null;
|
|
174
|
+
revision?: string | undefined;
|
|
175
|
+
daemonVersion?: string | undefined;
|
|
176
|
+
observedAt?: string | undefined;
|
|
177
|
+
}): string;
|
|
178
|
+
/** Authenticated, principal-scoped projection of durable lifecycle, process and coding evidence.
|
|
179
|
+
* Only fixed vocabulary is exposed from coding records; never detailJson, paths, patches or model text.
|
|
180
|
+
* Process text has already been redacted before persistence; redact again and remove terminal markup.
|
|
181
|
+
*/
|
|
182
|
+
activity(principalId: string, runId: string, cursor: string): ActivityResponse;
|
|
183
|
+
isTerminal(state: string): boolean;
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=workflowService.d.ts.map
|