@cleocode/core 2026.11.1-canary.9 → 2026.11.1
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/dist/.source-stamp.json +1 -1
- package/dist/build-provenance.json +2 -2
- package/dist/config.js +2 -0
- package/dist/config.js.map +1 -1
- package/dist/doctor/db-substrate.js +14 -6
- package/dist/doctor/db-substrate.js.map +1 -1
- package/dist/doctor/migrations.d.ts +16 -0
- package/dist/doctor/migrations.js +85 -1
- package/dist/doctor/migrations.js.map +1 -1
- package/dist/doctor/system-health.d.ts +77 -1
- package/dist/doctor/system-health.js +145 -0
- package/dist/doctor/system-health.js.map +1 -1
- package/dist/errors-to-engine.d.ts +8 -4
- package/dist/errors-to-engine.js +9 -5
- package/dist/errors-to-engine.js.map +1 -1
- package/dist/errors.d.ts +14 -0
- package/dist/errors.js +10 -0
- package/dist/errors.js.map +1 -1
- package/dist/git/work-tree.js +1 -1
- package/dist/git/work-tree.js.map +1 -1
- package/dist/hygiene/census.d.ts +181 -12
- package/dist/hygiene/census.js +564 -86
- package/dist/hygiene/census.js.map +1 -1
- package/dist/hygiene/prune-plan-worker.d.ts +17 -0
- package/dist/hygiene/prune-plan-worker.js +42 -0
- package/dist/hygiene/prune-plan-worker.js.map +1 -0
- package/dist/hygiene/task-status.d.ts +20 -0
- package/dist/hygiene/task-status.js +71 -0
- package/dist/hygiene/task-status.js.map +1 -0
- package/dist/memory/pipeline-manifest-sqlite.d.ts +2 -1
- package/dist/memory/pipeline-manifest-sqlite.js +3 -2
- package/dist/memory/pipeline-manifest-sqlite.js.map +1 -1
- package/dist/orchestrate/agentmbx.d.ts +5 -2
- package/dist/orchestrate/agentmbx.js +7 -4
- package/dist/orchestrate/agentmbx.js.map +1 -1
- package/dist/orchestrate/dispatch-workers.d.ts +10 -3
- package/dist/orchestrate/dispatch-workers.js +26 -14
- package/dist/orchestrate/dispatch-workers.js.map +1 -1
- package/dist/orchestrate/lead.d.ts +3 -0
- package/dist/orchestrate/lead.js +1 -0
- package/dist/orchestrate/lead.js.map +1 -1
- package/dist/orchestrate/orca-execution.d.ts +151 -0
- package/dist/orchestrate/orca-execution.js +571 -0
- package/dist/orchestrate/orca-execution.js.map +1 -0
- package/dist/orchestrate/orca-routing.d.ts +13 -0
- package/dist/orchestrate/orca-routing.js +142 -0
- package/dist/orchestrate/orca-routing.js.map +1 -0
- package/dist/orchestrate/spawn-ops.d.ts +50 -20
- package/dist/orchestrate/spawn-ops.js +332 -86
- package/dist/orchestrate/spawn-ops.js.map +1 -1
- package/dist/orchestrate/worker-records.d.ts +97 -5
- package/dist/orchestrate/worker-records.js +503 -11
- package/dist/orchestrate/worker-records.js.map +1 -1
- package/dist/orchestrate/worker-report.js +1 -0
- package/dist/orchestrate/worker-report.js.map +1 -1
- package/dist/orchestration/index.d.ts +8 -2
- package/dist/orchestration/index.js +70 -17
- package/dist/orchestration/index.js.map +1 -1
- package/dist/orchestration/spawn-prompt.d.ts +9 -2
- package/dist/orchestration/spawn-prompt.js +47 -18
- package/dist/orchestration/spawn-prompt.js.map +1 -1
- package/dist/orchestration/spawn.d.ts +20 -6
- package/dist/orchestration/spawn.js +14 -6
- package/dist/orchestration/spawn.js.map +1 -1
- package/dist/release/ci-evidence.d.ts +55 -2
- package/dist/release/ci-evidence.js +161 -51
- package/dist/release/ci-evidence.js.map +1 -1
- package/dist/resources/admission-ledger.d.ts +6 -0
- package/dist/resources/admission-ledger.js +100 -10
- package/dist/resources/admission-ledger.js.map +1 -1
- package/dist/resources/agent-lease.d.ts +7 -0
- package/dist/resources/agent-lease.js +37 -4
- package/dist/resources/agent-lease.js.map +1 -1
- package/dist/resources/hook-footprint.d.ts +22 -0
- package/dist/resources/hook-footprint.js +49 -2
- package/dist/resources/hook-footprint.js.map +1 -1
- package/dist/resources/run-class.d.ts +9 -1
- package/dist/resources/run-class.js +87 -6
- package/dist/resources/run-class.js.map +1 -1
- package/dist/spawn/adapter-registry.js +5 -0
- package/dist/spawn/adapter-registry.js.map +1 -1
- package/dist/spawn/branch-integration.d.ts +4 -0
- package/dist/spawn/branch-integration.js +10 -1
- package/dist/spawn/branch-integration.js.map +1 -1
- package/dist/store/open-cleo-db.d.ts +17 -0
- package/dist/store/open-cleo-db.js +39 -0
- package/dist/store/open-cleo-db.js.map +1 -1
- package/dist/store/restore-marker.js +4 -0
- package/dist/store/restore-marker.js.map +1 -1
- package/dist/store/sqlite.d.ts +21 -0
- package/dist/store/sqlite.js +33 -0
- package/dist/store/sqlite.js.map +1 -1
- package/dist/store/worktree-build-guard.js +3 -0
- package/dist/store/worktree-build-guard.js.map +1 -1
- package/dist/tasks/add.js +8 -0
- package/dist/tasks/add.js.map +1 -1
- package/dist/tasks/complete.d.ts +7 -3
- package/dist/tasks/complete.js +5 -0
- package/dist/tasks/complete.js.map +1 -1
- package/dist/tasks/engine-wrap.d.ts +3 -1
- package/dist/tasks/engine-wrap.js +6 -18
- package/dist/tasks/engine-wrap.js.map +1 -1
- package/dist/tasks/merge-close.d.ts +5 -3
- package/dist/tasks/merge-close.js +30 -10
- package/dist/tasks/merge-close.js.map +1 -1
- package/dist/tasks/pipeline-stage.d.ts +7 -1
- package/dist/tasks/pipeline-stage.js +44 -0
- package/dist/tasks/pipeline-stage.js.map +1 -1
- package/dist/tasks/update.js +8 -0
- package/dist/tasks/update.js.map +1 -1
- package/dist/upgrade.d.ts +4 -0
- package/dist/upgrade.js +32 -0
- package/dist/upgrade.js.map +1 -1
- package/dist/worktree/in-use-probe.d.ts +19 -0
- package/dist/worktree/in-use-probe.js +87 -0
- package/dist/worktree/in-use-probe.js.map +1 -1
- package/dist/worktree/list.d.ts +6 -6
- package/dist/worktree/list.js +42 -30
- package/dist/worktree/list.js.map +1 -1
- package/dist/worktree/own-project.d.ts +32 -0
- package/dist/worktree/own-project.js +68 -0
- package/dist/worktree/own-project.js.map +1 -0
- package/dist/worktree/prune.d.ts +11 -1
- package/dist/worktree/prune.js +83 -2
- package/dist/worktree/prune.js.map +1 -1
- package/package.json +12 -12
- package/templates/CLEO-INJECTION.md +1 -1
- package/templates/CLEO-REFERENCE.md +2 -2
|
@@ -0,0 +1,571 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Durable policy for prepared Orca assignments; no lifecycle settlement at launch.
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
5
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
6
|
+
import { realpathSync } from 'node:fs';
|
|
7
|
+
import { isAbsolute, relative } from 'node:path';
|
|
8
|
+
import { ExitCode } from '@cleocode/contracts/exit-codes.js';
|
|
9
|
+
import { orcaLaunchSchema, orcaWorkerDoneSchema, orcaWorkerRequestSchema, } from '@cleocode/contracts/orca-execution.js';
|
|
10
|
+
import { computeProjectHash, readDeclaredProjectIdentity, resolveTaskWorktreePath, } from '@cleocode/paths';
|
|
11
|
+
import { readWorktreeTaskLock } from '@cleocode/worktree';
|
|
12
|
+
import { EngineResultError, engineError } from '../engine-result.js';
|
|
13
|
+
import { CleoError } from '../errors.js';
|
|
14
|
+
import { readContainedFile } from '../memory/manifest-identity.js';
|
|
15
|
+
import { readManifestEntries } from '../memory/pipeline-manifest-sqlite.js';
|
|
16
|
+
import { resolveSpawnReturnContract } from '../orchestration/spawn-prompt.js';
|
|
17
|
+
import { getTaskAccessor } from '../store/data-accessor.js';
|
|
18
|
+
import { isLiveClaim } from '../store/task-claim.js';
|
|
19
|
+
import { parseReturnMessage } from '../validation/protocol-common.js';
|
|
20
|
+
import { createAgentMbxClient, MBX_NAME } from './agentmbx.js';
|
|
21
|
+
import { isCurrentOrcaWorker, listWorkerRecords, newWorkerInstanceId, recordWorker, recordWorkerReport, recordWorkerReportDelivery, settleOrcaWorkerResource, updateWorkerExecution, } from './worker-records.js';
|
|
22
|
+
import { checkWorkerReport } from './worker-report.js';
|
|
23
|
+
/**
|
|
24
|
+
* Launch a payload already prepared once by CLEO's canonical spawn path. The
|
|
25
|
+
* worker claim and worktree lock remain held on every uncertain outcome.
|
|
26
|
+
* Routing consumes this primitive; final report settlement remains separate.
|
|
27
|
+
* @remarks Consumes canonical preparation once; never provisions another checkout.
|
|
28
|
+
* @param input - Prepared task, prompt, session and worktree lock receipt.
|
|
29
|
+
* @param context - Verified local Orca runtime and original coordinator.
|
|
30
|
+
* @param backend - Process adapter, injectable for offline fixtures.
|
|
31
|
+
* @param runId - Previously persisted Run for this exact coordinator, if known.
|
|
32
|
+
* @returns The durable attempt after recording its start receipt.
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* const record = await launchOrcaWorker(prepared, context, backend);
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export async function launchOrcaWorker(input, context, backend, runId = null) {
|
|
39
|
+
const launch = orcaLaunchSchema.parse(input);
|
|
40
|
+
await validatePreparedAssignment(launch);
|
|
41
|
+
const workspace = await backend.preflight(launch, context);
|
|
42
|
+
await validatePreparedAssignment(launch);
|
|
43
|
+
const execution = {
|
|
44
|
+
backend: 'orca',
|
|
45
|
+
version: 1,
|
|
46
|
+
revision: 0,
|
|
47
|
+
context,
|
|
48
|
+
launch,
|
|
49
|
+
promptDigest: createHash('sha256').update(launch.prompt).digest('hex'),
|
|
50
|
+
...workspace,
|
|
51
|
+
state: 'prepared',
|
|
52
|
+
runId,
|
|
53
|
+
orcaTaskId: null,
|
|
54
|
+
dispatchId: null,
|
|
55
|
+
retryOf: null,
|
|
56
|
+
startBinding: { runId, orcaTaskId: null, retryOf: null },
|
|
57
|
+
startRequestId: null,
|
|
58
|
+
stopRequestId: null,
|
|
59
|
+
failureCount: 0,
|
|
60
|
+
resourceState: 'unknown',
|
|
61
|
+
lastReceipt: null,
|
|
62
|
+
lastError: null,
|
|
63
|
+
observedAt: new Date().toISOString(),
|
|
64
|
+
};
|
|
65
|
+
const record = await recordWorker({
|
|
66
|
+
taskId: launch.taskId,
|
|
67
|
+
instanceId: launch.instanceId,
|
|
68
|
+
agentId: launch.agentId,
|
|
69
|
+
provider: launch.harness,
|
|
70
|
+
pid: null,
|
|
71
|
+
pgid: null,
|
|
72
|
+
worktree: launch.worktreePath,
|
|
73
|
+
leadMailbox: launch.leadMailbox,
|
|
74
|
+
sessionId: launch.workerSessionId,
|
|
75
|
+
execution,
|
|
76
|
+
}, launch.projectRoot);
|
|
77
|
+
const reserved = await updateWorkerExecution(record, { ...execution, state: 'launching' }, launch.projectRoot);
|
|
78
|
+
const result = await backend.start(requireExecution(reserved));
|
|
79
|
+
return updateWorkerExecution(reserved, result, launch.projectRoot);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Observe a stored exact Dispatch after a CLI restart.
|
|
83
|
+
* @remarks Only exact provider release proof closes physical resources; it never settles a CLEO task.
|
|
84
|
+
* @param recordId - Existing local worker record id.
|
|
85
|
+
* @param cwd - Owning CLEO project root.
|
|
86
|
+
* @param backend - Process adapter for the recorded runtime.
|
|
87
|
+
* @returns The record with a validated observation and a new CAS revision.
|
|
88
|
+
* @example
|
|
89
|
+
* ```ts
|
|
90
|
+
* const observed = await observeOrcaWorker(record.recordId, projectRoot, backend);
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export async function observeOrcaWorker(recordId, cwd, backend) {
|
|
94
|
+
const record = await loadOrcaWorker(recordId, cwd);
|
|
95
|
+
const observed = await updateWorkerExecution(record, await backend.show(requireExecution(record)), cwd);
|
|
96
|
+
return settleOrcaWorkerResource(observed, cwd);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Replay an issued or pre-reserved start request after a durable reservation.
|
|
100
|
+
* @remarks A missing receipt never authorizes an unkeyed replacement; reserved
|
|
101
|
+
* retries must still hold the original live claim and canonical checkout lock.
|
|
102
|
+
* @param recordId - Exact pending worker record id.
|
|
103
|
+
* @param cwd - Owning CLEO project root.
|
|
104
|
+
* @param backend - Process adapter for the original runtime and caller.
|
|
105
|
+
* @returns The same worker record with the replayed receipt.
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* const recovered = await recoverOrcaWorkerStart(record.recordId, projectRoot, backend);
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
export async function recoverOrcaWorkerStart(recordId, cwd, backend) {
|
|
112
|
+
const record = await loadOrcaWorker(recordId, cwd);
|
|
113
|
+
const execution = requireExecution(record);
|
|
114
|
+
if (!['outcome_unknown', 'launching'].includes(execution.state) ||
|
|
115
|
+
!(execution.startRequestId || execution.startRequestKey) ||
|
|
116
|
+
!execution.startBinding ||
|
|
117
|
+
execution.failureCount >= 3) {
|
|
118
|
+
// @sync-invariant none:local-only only an issued or pre-reserved unresolved operation may be replayed
|
|
119
|
+
throw new CleoError(ExitCode.SPAWN_VALIDATION_FAILED, 'No recoverable start request is stored for this attempt.', {
|
|
120
|
+
fix: 'Inspect its original receipt; an absent receipt never authorizes a replacement worker.',
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
if (execution.startRequestKey)
|
|
124
|
+
await validatePreparedAssignment(execution.launch);
|
|
125
|
+
const reserved = await updateWorkerExecution(record, { ...execution, state: 'launching' }, cwd);
|
|
126
|
+
try {
|
|
127
|
+
const result = await backend.replayStart({ ...execution, state: 'outcome_unknown' });
|
|
128
|
+
return await updateWorkerExecution(reserved, result, cwd);
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
await updateWorkerExecution(reserved, { ...execution, state: 'outcome_unknown', lastError: String(error) }, cwd);
|
|
132
|
+
throw error;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Retry a confirmed failed or stopped attempt on the same Orca Task and Run.
|
|
137
|
+
* @remarks Atomically retires the predecessor and reserves its successor before launch;
|
|
138
|
+
* uncertain outcomes and breaker history retain custody, claims and the checkout.
|
|
139
|
+
* @param recordId - Exact predecessor record, with no remaining agent resources.
|
|
140
|
+
* @param cwd - Owning CLEO project root.
|
|
141
|
+
* @param backend - Adapter for the predecessor's runtime and caller.
|
|
142
|
+
* @returns The durably reserved successor and its full launch receipt.
|
|
143
|
+
* @example
|
|
144
|
+
* ```ts
|
|
145
|
+
* const successor = await retryOrcaWorker(record.recordId, projectRoot, backend);
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
export async function retryOrcaWorker(recordId, cwd, backend) {
|
|
149
|
+
const predecessor = await observeOrcaWorker(recordId, cwd, backend);
|
|
150
|
+
const execution = requireExecution(predecessor);
|
|
151
|
+
if (!execution.dispatchId ||
|
|
152
|
+
!execution.runId ||
|
|
153
|
+
!execution.orcaTaskId ||
|
|
154
|
+
!['failed', 'stopped'].includes(execution.state) ||
|
|
155
|
+
execution.resourceState !== 'stopped' ||
|
|
156
|
+
execution.failureCount >= 3) {
|
|
157
|
+
// @sync-invariant none:local-only a retry cannot evade uncertain custody or the original Task's breaker
|
|
158
|
+
throw new CleoError(ExitCode.SPAWN_VALIDATION_FAILED, 'The predecessor has no confirmed resource-free failure or stop eligible for retry.', {
|
|
159
|
+
fix: `Inspect its exact Dispatch with cleo orchestrate worker show ${recordId}; every read re-reads each helper named by the stored stop, so retry admits once the parent and all helpers are released. If the stop receipt was lost or carries no helper evidence, replay its reserved key with cleo orchestrate worker recover-stop ${recordId}. A helper still running or kept open must be stopped or released in Orca first (orca orchestration worker-stop|worker-release --dispatch <helper dispatch id from that receipt>).`,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
await validatePreparedAssignment(execution.launch);
|
|
163
|
+
const workspace = await backend.preflight(execution.launch, execution.context);
|
|
164
|
+
if (workspace.workspaceId !== execution.workspaceId ||
|
|
165
|
+
workspace.workspaceSelector !== execution.workspaceSelector) {
|
|
166
|
+
// @sync-invariant none:local-only retries must attach the original exact canonical workspace
|
|
167
|
+
throw new CleoError(ExitCode.SPAWN_VALIDATION_FAILED, 'The retry workspace binding changed.', {
|
|
168
|
+
fix: 'Resolve the original workspace explicitly; do not substitute another checkout.',
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
await validatePreparedAssignment(execution.launch);
|
|
172
|
+
const launch = {
|
|
173
|
+
...execution.launch,
|
|
174
|
+
instanceId: newWorkerInstanceId(execution.launch.harness),
|
|
175
|
+
};
|
|
176
|
+
const retry = {
|
|
177
|
+
...execution,
|
|
178
|
+
revision: 0,
|
|
179
|
+
launch,
|
|
180
|
+
state: 'launching',
|
|
181
|
+
dispatchId: null,
|
|
182
|
+
retryOf: execution.dispatchId,
|
|
183
|
+
startBinding: {
|
|
184
|
+
runId: execution.runId,
|
|
185
|
+
orcaTaskId: execution.orcaTaskId,
|
|
186
|
+
retryOf: execution.dispatchId,
|
|
187
|
+
},
|
|
188
|
+
startRequestKey: randomUUID(),
|
|
189
|
+
startRequestId: null,
|
|
190
|
+
stopRequestKey: undefined,
|
|
191
|
+
stopRequestId: null,
|
|
192
|
+
resourceState: 'unknown',
|
|
193
|
+
lastReceipt: null,
|
|
194
|
+
lastError: null,
|
|
195
|
+
observedAt: new Date().toISOString(),
|
|
196
|
+
};
|
|
197
|
+
const reserved = await recordWorker({ ...predecessor, instanceId: launch.instanceId, execution: retry }, cwd, predecessor);
|
|
198
|
+
return updateWorkerExecution(reserved, await backend.start(retry), cwd);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Read one archived or live output page.
|
|
202
|
+
* @remarks Retired predecessors remain readable without changing custody.
|
|
203
|
+
* Does not consume coordinator mail; callers retain the source-pinned cursor.
|
|
204
|
+
* @param recordId - Exact worker record id.
|
|
205
|
+
* @param cwd - Owning CLEO project root.
|
|
206
|
+
* @param backend - Process adapter for the recorded runtime.
|
|
207
|
+
* @param cursor - Cursor from the preceding output page, if any.
|
|
208
|
+
* @returns Original bounded JSON receipt, including output and pagination.
|
|
209
|
+
* @example
|
|
210
|
+
* ```ts
|
|
211
|
+
* const page = await readOrcaWorker(record.recordId, projectRoot, backend, undefined);
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
214
|
+
export async function readOrcaWorker(recordId, cwd, backend, cursor) {
|
|
215
|
+
return backend.read(requireExecution(await loadOrcaWorker(recordId, cwd, true)), cursor);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Ingest one current-dispatch report after an Orca wake, without accepting the task.
|
|
219
|
+
* @param recordId - Exact open CLEO worker record.
|
|
220
|
+
* @param cwd - Owning project root.
|
|
221
|
+
* @param backend - Read-only report transport, injectable for fixtures.
|
|
222
|
+
* @param messageId - Exact worker_done id supplied by the coordinator's wake.
|
|
223
|
+
* @param mailboxClient - Report delivery port, injected by offline fixtures.
|
|
224
|
+
* @returns The worker with its first durable canonical report and manifest link.
|
|
225
|
+
* @throws For stale provenance, missing proof, unsuccessful work or an invalid manifest.
|
|
226
|
+
* @remarks Report settlement never changes task gates, invokes integration or emits SubagentStop.
|
|
227
|
+
* @example
|
|
228
|
+
* ```ts
|
|
229
|
+
* const settled = await ingestOrcaWorkerReport(recordId, root, backend, messageId);
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
export async function ingestOrcaWorkerReport(recordId, cwd, backend, messageId, mailboxClient = createAgentMbxClient()) {
|
|
233
|
+
const record = await loadOrcaWorker(recordId, cwd);
|
|
234
|
+
const execution = requireExecution(record);
|
|
235
|
+
const event = orcaWorkerDoneSchema.parse(await backend.readReport(execution, messageId));
|
|
236
|
+
if (readDeclaredProjectIdentity(cwd)?.projectId !== execution.launch.projectId ||
|
|
237
|
+
event.messageId !== messageId ||
|
|
238
|
+
event.runtimeId !== execution.context.runtimeId ||
|
|
239
|
+
event.runId !== execution.runId ||
|
|
240
|
+
event.orcaTaskId !== execution.orcaTaskId ||
|
|
241
|
+
event.dispatchId !== execution.dispatchId ||
|
|
242
|
+
event.outcome !== 'succeeded') {
|
|
243
|
+
// @sync-invariant none:local-only a failed or stale transport delivery cannot settle a successful report
|
|
244
|
+
throw new EngineResultError({
|
|
245
|
+
code: 'E_ORCA_REPORT_IDENTITY',
|
|
246
|
+
message: 'No successful current-dispatch worker_done matches this worker.',
|
|
247
|
+
fix: 'Inspect the exact worker record and original worker_done; retain failed or stale delivery as history.',
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
if (record.report?.event.messageId === event.messageId) {
|
|
251
|
+
if (JSON.stringify(record.report.event) !== JSON.stringify(event)) {
|
|
252
|
+
// @sync-invariant none:local-only repeated event identity cannot replace its original transport bytes
|
|
253
|
+
throw new EngineResultError({
|
|
254
|
+
code: 'E_ORCA_REPORT_CONFLICT',
|
|
255
|
+
message: 'The stored report event changed.',
|
|
256
|
+
fix: 'Inspect the original durable report; do not overwrite it with a repeated event id.',
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
await recordWorkerReport(record, record.report, cwd);
|
|
260
|
+
return relayOrcaWorkerReport(recordId, cwd, mailboxClient);
|
|
261
|
+
}
|
|
262
|
+
const task = await (await getTaskAccessor(cwd)).loadSingleTask(record.taskId);
|
|
263
|
+
if (!task?.claim ||
|
|
264
|
+
!isLiveClaim(task.claim) ||
|
|
265
|
+
task.claim.sessionId !== record.sessionId ||
|
|
266
|
+
task.claim.agentId !== record.agentId) {
|
|
267
|
+
// @sync-invariant none:local-only a report cannot settle a reassigned or expired CLEO claim
|
|
268
|
+
throw new EngineResultError({
|
|
269
|
+
code: 'E_ORCA_REPORT_IDENTITY',
|
|
270
|
+
message: 'The worker no longer owns the current CLEO task claim.',
|
|
271
|
+
fix: 'Inspect the task and exact dispatch; a previous assignment cannot settle a replacement worker.',
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
const file = isAbsolute(event.reportPath)
|
|
275
|
+
? relative(record.worktree, event.reportPath)
|
|
276
|
+
: event.reportPath;
|
|
277
|
+
const read = readContainedFile(record.worktree, file);
|
|
278
|
+
if (read.status !== 'ok') {
|
|
279
|
+
// @sync-invariant none:input-shape report pointers must name readable files contained in the assigned checkout
|
|
280
|
+
throw new EngineResultError({
|
|
281
|
+
code: 'E_ORCA_REPORT_FILE',
|
|
282
|
+
message: `Canonical worker report is ${read.status}.`,
|
|
283
|
+
fix: 'Supply worker_done with a report-path inside its assigned worktree; prose is not canonical report proof.',
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
const check = checkWorkerReport(read.content);
|
|
287
|
+
if (!check.ok) {
|
|
288
|
+
// @sync-invariant none:input-shape every original report must satisfy the existing proof and word-count contract
|
|
289
|
+
throw new EngineResultError({
|
|
290
|
+
code: check.code,
|
|
291
|
+
message: check.message,
|
|
292
|
+
fix: check.fix,
|
|
293
|
+
exitCode: check.exitCode,
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
const parsed = parseReturnMessage(read.content);
|
|
297
|
+
const contract = resolveSpawnReturnContract(execution.launch.protocol);
|
|
298
|
+
if (!parsed?.entryId ||
|
|
299
|
+
parsed.type !== contract.type ||
|
|
300
|
+
!['complete', 'completed'].includes(parsed.status) ||
|
|
301
|
+
check.report.blocker) {
|
|
302
|
+
// @sync-invariant none:input-shape successful transport cannot promote a blocked or partial report to completion
|
|
303
|
+
throw new EngineResultError({
|
|
304
|
+
code: 'E_ORCA_REPORT_OUTCOME',
|
|
305
|
+
message: 'The report does not claim successful work under the assigned protocol.',
|
|
306
|
+
fix: 'Keep partial and blocked work open; use the original protocol report and its actual outcome.',
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
const [manifest] = await readManifestEntries(cwd, parsed.entryId);
|
|
310
|
+
if (!manifest?.linked_tasks?.includes(record.taskId) ||
|
|
311
|
+
manifest.status !== 'completed' ||
|
|
312
|
+
manifest.agent_type !== contract.manifestType) {
|
|
313
|
+
// @sync-invariant none:local-only only an existing manifest for the exact task and protocol backs a complete report
|
|
314
|
+
throw new EngineResultError({
|
|
315
|
+
code: 'E_ORCA_REPORT_MANIFEST',
|
|
316
|
+
message: 'No matching completed worker manifest backs this report.',
|
|
317
|
+
fix: `Read back a completed ${contract.manifestType} manifest whose linked_tasks includes ${record.taskId}, and use its id in the report.`,
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
await recordWorkerReport(record, {
|
|
321
|
+
event,
|
|
322
|
+
manifestId: manifest.id,
|
|
323
|
+
manifestDigest: createHash('sha256').update(JSON.stringify(manifest)).digest('hex'),
|
|
324
|
+
reportText: read.content,
|
|
325
|
+
reportDigest: createHash('sha256').update(read.content).digest('hex'),
|
|
326
|
+
ingestedAt: new Date().toISOString(),
|
|
327
|
+
}, cwd);
|
|
328
|
+
return relayOrcaWorkerReport(recordId, cwd, mailboxClient);
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Deliver a stored canonical report to its lead using the same durable AgentMBX key.
|
|
332
|
+
* @param recordId - Worker whose original report and outbox are already persisted.
|
|
333
|
+
* @param cwd - Owning project root.
|
|
334
|
+
* @param client - Injected mailbox client; tests never contact a real mailbox.
|
|
335
|
+
* @returns Its delivered receipt, or explicit pending delivery with a retry diagnostic.
|
|
336
|
+
* @remarks Does not consume wakes, require live resources, accept work or release custody.
|
|
337
|
+
* @example
|
|
338
|
+
* ```ts
|
|
339
|
+
* const delivered = await relayOrcaWorkerReport(recordId, root, mailboxClient);
|
|
340
|
+
* ```
|
|
341
|
+
*/
|
|
342
|
+
export async function relayOrcaWorkerReport(recordId, cwd, client = createAgentMbxClient()) {
|
|
343
|
+
let record = await loadOrcaWorker(recordId, cwd, true);
|
|
344
|
+
if (!record.report ||
|
|
345
|
+
readDeclaredProjectIdentity(cwd)?.projectId !== record.execution?.launch.projectId) {
|
|
346
|
+
// @sync-invariant none:local-only only a validated report in the owning portable project can reach its lead
|
|
347
|
+
throw new EngineResultError({
|
|
348
|
+
code: 'E_ORCA_REPORT_DELIVERY',
|
|
349
|
+
message: 'No validated report exists for this worker and project.',
|
|
350
|
+
fix: 'Ingest the exact current worker_done before retrying report delivery.',
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
if (!record.reportDelivery)
|
|
354
|
+
record = await recordWorkerReport(record, record.report, cwd);
|
|
355
|
+
const delivery = record.reportDelivery;
|
|
356
|
+
if (!delivery || !record.report) {
|
|
357
|
+
// @sync-invariant none:local-only no mailbox side effect is allowed without a durable outbox reservation
|
|
358
|
+
throw new Error('No durable report delivery reservation exists.');
|
|
359
|
+
}
|
|
360
|
+
if (delivery.state === 'delivered')
|
|
361
|
+
return record;
|
|
362
|
+
let lastError = null;
|
|
363
|
+
let messageId = null;
|
|
364
|
+
try {
|
|
365
|
+
if (!delivery.mailbox || !MBX_NAME.test(delivery.mailbox)) {
|
|
366
|
+
lastError =
|
|
367
|
+
'No valid lead mailbox was recorded; retain the report and restore its original lead routing.';
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
const result = await client.send({
|
|
371
|
+
as: delivery.mailbox,
|
|
372
|
+
to: delivery.mailbox,
|
|
373
|
+
subject: `${record.taskId} worker report (${record.recordId}; ${record.report.event.messageId})`,
|
|
374
|
+
body: record.report.reportText,
|
|
375
|
+
kind: 'message',
|
|
376
|
+
idempotencyKey: delivery.key,
|
|
377
|
+
});
|
|
378
|
+
if (result.ok)
|
|
379
|
+
messageId = result.value.id;
|
|
380
|
+
lastError = result.ok
|
|
381
|
+
? messageId
|
|
382
|
+
? null
|
|
383
|
+
: 'AgentMBX returned no message id; retry the stored idempotency key.'
|
|
384
|
+
: result.warning;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
catch (error) {
|
|
388
|
+
lastError = String(error);
|
|
389
|
+
}
|
|
390
|
+
return recordWorkerReportDelivery(recordId, {
|
|
391
|
+
...delivery,
|
|
392
|
+
state: messageId ? 'delivered' : 'pending',
|
|
393
|
+
messageId,
|
|
394
|
+
deliveredAt: messageId ? new Date().toISOString() : null,
|
|
395
|
+
lastError,
|
|
396
|
+
}, cwd);
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Explicit cancellation of an exact attempt. stop_unknown fences another stop;
|
|
400
|
+
* neither a stopped result nor a launch hint disposes a checkout or closes a task.
|
|
401
|
+
* @remarks Requires an explicit cancellation request; uncertainty retains custody.
|
|
402
|
+
* The stop key is reserved before the send, so a lost receipt still replays exactly.
|
|
403
|
+
* @param recordId - Exact worker record id to cancel.
|
|
404
|
+
* @param cwd - Owning CLEO project root.
|
|
405
|
+
* @param backend - Process adapter for the recorded runtime.
|
|
406
|
+
* @returns The persisted stop receipt, including an unresolved stop_unknown.
|
|
407
|
+
* @example
|
|
408
|
+
* ```ts
|
|
409
|
+
* const stopped = await stopOrcaWorker(record.recordId, projectRoot, backend);
|
|
410
|
+
* ```
|
|
411
|
+
*/
|
|
412
|
+
export async function stopOrcaWorker(recordId, cwd, backend) {
|
|
413
|
+
const record = await loadOrcaWorker(recordId, cwd);
|
|
414
|
+
const execution = requireExecution(record);
|
|
415
|
+
if (!execution.dispatchId || !execution.runId || !execution.orcaTaskId) {
|
|
416
|
+
// @sync-invariant none:local-only an unresolved start with no exact dispatch cannot authorize cancellation
|
|
417
|
+
throw new CleoError(ExitCode.SPAWN_VALIDATION_FAILED, 'No exact Dispatch binding is stored for cancellation.', { fix: 'Recover the original issued start request before requesting a guarded stop.' });
|
|
418
|
+
}
|
|
419
|
+
if (['stop_pending', 'stop_unknown', 'stopped'].includes(execution.state)) {
|
|
420
|
+
// @sync-invariant none:local-only an uncertain stop cannot be replaced by another unkeyed stop
|
|
421
|
+
throw new CleoError(ExitCode.SPAWN_VALIDATION_FAILED, 'The stored stop is already sent or settled.', {
|
|
422
|
+
fix: 'Inspect the exact Dispatch and original stop request; do not repeat cancellation blindly.',
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
const reserved = await updateWorkerExecution(record, { ...execution, state: 'stop_pending', stopRequestKey: randomUUID() }, cwd);
|
|
426
|
+
return updateWorkerExecution(reserved, await backend.stop(requireExecution(reserved)), cwd);
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Replay a previously issued or reserved uncertain cancellation after a CLI restart.
|
|
430
|
+
* @remarks The reserved stop key replays every send, so a lost stop receipt without
|
|
431
|
+
* an issued id remains replayable; a record with neither stays fenced and is never
|
|
432
|
+
* sent a fresh unkeyed stop.
|
|
433
|
+
* @param recordId - Exact open worker record containing the issued stop request.
|
|
434
|
+
* @param cwd - Owning CLEO project root.
|
|
435
|
+
* @param backend - Adapter for the original runtime and caller.
|
|
436
|
+
* @returns The same record with its replayed stop receipt.
|
|
437
|
+
* @example
|
|
438
|
+
* ```ts
|
|
439
|
+
* const recovered = await recoverOrcaWorkerStop(record.recordId, projectRoot, backend);
|
|
440
|
+
* ```
|
|
441
|
+
*/
|
|
442
|
+
export async function recoverOrcaWorkerStop(recordId, cwd, backend) {
|
|
443
|
+
const record = await loadOrcaWorker(recordId, cwd);
|
|
444
|
+
const execution = requireExecution(record);
|
|
445
|
+
if (!['stop_unknown', 'stop_pending'].includes(execution.state) ||
|
|
446
|
+
!(execution.stopRequestId ?? execution.stopRequestKey)) {
|
|
447
|
+
// @sync-invariant none:local-only only the original issued cancellation may be replayed
|
|
448
|
+
throw new CleoError(ExitCode.SPAWN_VALIDATION_FAILED, 'No recoverable stop request is stored for this attempt.', { fix: 'Inspect the exact Dispatch and original receipt; do not repeat an unkeyed stop.' });
|
|
449
|
+
}
|
|
450
|
+
const reserved = await updateWorkerExecution(record, { ...execution, state: 'stop_pending' }, cwd);
|
|
451
|
+
try {
|
|
452
|
+
const result = await backend.replayStop({ ...execution, state: 'stop_unknown' });
|
|
453
|
+
return await updateWorkerExecution(reserved, result, cwd);
|
|
454
|
+
}
|
|
455
|
+
catch (error) {
|
|
456
|
+
await updateWorkerExecution(reserved, { ...execution, state: 'stop_unknown', lastError: String(error) }, cwd);
|
|
457
|
+
throw error;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Inspect or recover an exact durable worker through the supplied execution port.
|
|
462
|
+
* @remarks Every invocation reloads the record; no current environment, newest
|
|
463
|
+
* Run, native PID or launch status can replace its saved dispatch addressing.
|
|
464
|
+
* @param request - Exact record, operation and optional source-pinned read cursor.
|
|
465
|
+
* @param cwd - Owning CLEO project root.
|
|
466
|
+
* @param backend - Process adapter, injected at the CLI boundary.
|
|
467
|
+
* @param mailboxClient - AgentMBX port for the recorded lead's logical report delivery.
|
|
468
|
+
* @returns The persisted record or original output receipt, or an actionable refusal.
|
|
469
|
+
* @example
|
|
470
|
+
* ```ts
|
|
471
|
+
* const request: OrcaWorkerRequest = { action: 'show', recordId };
|
|
472
|
+
* const result = await orchestrateOrcaWorker(request, root, backend);
|
|
473
|
+
* ```
|
|
474
|
+
*/
|
|
475
|
+
export async function orchestrateOrcaWorker(request, cwd, backend, mailboxClient = createAgentMbxClient()) {
|
|
476
|
+
const parsed = orcaWorkerRequestSchema.safeParse(request);
|
|
477
|
+
if (!parsed.success) {
|
|
478
|
+
// @sync-invariant none:input-shape an invalid supervision request cannot reach the execution port
|
|
479
|
+
return engineError('E_INVALID_INPUT', parsed.error.message, {
|
|
480
|
+
exitCode: ExitCode.VALIDATION_ERROR,
|
|
481
|
+
fix: 'Use cleo orchestrate worker --help; read alone accepts a source-pinned cursor.',
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
const { action, recordId, cursor, messageId } = parsed.data;
|
|
485
|
+
const operations = {
|
|
486
|
+
show: observeOrcaWorker,
|
|
487
|
+
read: readOrcaWorker,
|
|
488
|
+
'recover-start': recoverOrcaWorkerStart,
|
|
489
|
+
'recover-stop': recoverOrcaWorkerStop,
|
|
490
|
+
retry: retryOrcaWorker,
|
|
491
|
+
stop: stopOrcaWorker,
|
|
492
|
+
};
|
|
493
|
+
try {
|
|
494
|
+
if (action === 'ingest-report') {
|
|
495
|
+
return {
|
|
496
|
+
success: true,
|
|
497
|
+
data: await ingestOrcaWorkerReport(recordId, cwd, backend, messageId ?? '', mailboxClient),
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
if (action === 'relay-report')
|
|
501
|
+
return { success: true, data: await relayOrcaWorkerReport(recordId, cwd, mailboxClient) };
|
|
502
|
+
return { success: true, data: await operations[action](recordId, cwd, backend, cursor) };
|
|
503
|
+
}
|
|
504
|
+
catch (error) {
|
|
505
|
+
const code = error instanceof CleoError
|
|
506
|
+
? error.toLAFSError().code
|
|
507
|
+
: error instanceof Error && 'code' in error && typeof error.code === 'string'
|
|
508
|
+
? error.code
|
|
509
|
+
: 'E_ORCA_WORKER_FAILED';
|
|
510
|
+
const fix = error instanceof Error && 'fix' in error && typeof error.fix === 'string'
|
|
511
|
+
? error.fix
|
|
512
|
+
: `Inspect the stored record ${recordId} with cleo orchestrate status; retain its claim and worktree until its exact operation is resolved.`;
|
|
513
|
+
// @sync-invariant none:local-only refused recovery retains the original durable custody
|
|
514
|
+
return engineError(code, error instanceof Error ? error.message : String(error), {
|
|
515
|
+
exitCode: error instanceof CleoError
|
|
516
|
+
? error.code
|
|
517
|
+
: error instanceof EngineResultError
|
|
518
|
+
? error.exitCode
|
|
519
|
+
: ExitCode.SPAWN_VALIDATION_FAILED,
|
|
520
|
+
fix,
|
|
521
|
+
details: { recordId, action },
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
async function loadOrcaWorker(recordId, cwd, includeRetired = false) {
|
|
526
|
+
const record = (await listWorkerRecords(cwd, true)).find((candidate) => candidate.recordId === recordId);
|
|
527
|
+
if (!record?.execution || (!includeRetired && !isCurrentOrcaWorker(record))) {
|
|
528
|
+
// @sync-invariant none:local-only only archived output reads may address a retired attempt
|
|
529
|
+
throw new CleoError(ExitCode.SPAWN_VALIDATION_FAILED, `No ${includeRetired ? '' : 'open '}Orca worker record matches that id.`, { fix: 'Inspect the existing worker records and use the exact record id.' });
|
|
530
|
+
}
|
|
531
|
+
return record;
|
|
532
|
+
}
|
|
533
|
+
function requireExecution(record) {
|
|
534
|
+
if (!record.execution) {
|
|
535
|
+
// @sync-invariant none:local-only native process records are never adopted as Orca attempts
|
|
536
|
+
throw new CleoError(ExitCode.SPAWN_VALIDATION_FAILED, 'Worker record has no Orca binding.', {
|
|
537
|
+
fix: 'Use its recorded execution backend.',
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
if (createHash('sha256').update(record.execution.launch.prompt).digest('hex') !==
|
|
541
|
+
record.execution.promptDigest) {
|
|
542
|
+
// @sync-invariant none:local-only recovery must replay the original prepared prompt bytes
|
|
543
|
+
throw new CleoError(ExitCode.SPAWN_VALIDATION_FAILED, 'The stored prompt no longer matches its launch digest.', { fix: 'Retain custody and inspect the original prepared assignment before recovery.' });
|
|
544
|
+
}
|
|
545
|
+
return record.execution;
|
|
546
|
+
}
|
|
547
|
+
/** Recheck custody after read-only host preflight, which may outlive a claim. */
|
|
548
|
+
async function validatePreparedAssignment(launch) {
|
|
549
|
+
const expectedPath = resolveTaskWorktreePath(computeProjectHash(launch.projectRoot), launch.taskId);
|
|
550
|
+
const lock = readWorktreeTaskLock(launch.projectHash, launch.taskId);
|
|
551
|
+
const task = await (await getTaskAccessor(launch.projectRoot)).loadSingleTask(launch.taskId);
|
|
552
|
+
if (readDeclaredProjectIdentity(launch.projectRoot)?.projectId !== launch.projectId ||
|
|
553
|
+
launch.worktreePath !== expectedPath ||
|
|
554
|
+
realpathSync(launch.worktreePath) !== expectedPath ||
|
|
555
|
+
launch.projectHash !== computeProjectHash(launch.projectRoot) ||
|
|
556
|
+
launch.worktreeBranch !== `task/${launch.taskId}` ||
|
|
557
|
+
!lock ||
|
|
558
|
+
lock.token !== launch.lockToken ||
|
|
559
|
+
lock.sessionId !== launch.workerSessionId ||
|
|
560
|
+
lock.agentId !== launch.agentId ||
|
|
561
|
+
!task?.claim ||
|
|
562
|
+
!isLiveClaim(task.claim) ||
|
|
563
|
+
task.claim.sessionId !== launch.workerSessionId ||
|
|
564
|
+
task.claim.agentId !== launch.agentId) {
|
|
565
|
+
// @sync-invariant none:local-only an Orca launch must retain the canonical checkout and its allocated claim
|
|
566
|
+
throw new CleoError(ExitCode.SPAWN_VALIDATION_FAILED, 'The canonical worktree, lock or allocated task claim is unproven.', {
|
|
567
|
+
fix: 'Prepare the task once through cleo orchestrate spawn and pass its exact worker identity and lock receipt.',
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
//# sourceMappingURL=orca-execution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orca-execution.js","sourceRoot":"","sources":["../../src/orchestrate/orca-execution.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAC7D,OAAO,EAML,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACL,kBAAkB,EAClB,2BAA2B,EAC3B,uBAAuB,GACxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAqB,iBAAiB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACxF,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAuB,oBAAoB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACpF,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,EAClB,0BAA0B,EAC1B,wBAAwB,EACxB,qBAAqB,GAEtB,MAAM,qBAAqB,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pC,YAAY,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,YAAY;QAClD,MAAM,CAAC,WAAW,KAAK,kBAAkB,CAAC,MAAM,CAAC,WAAW,CAAC;QAC7D,MAAM,CAAC,cAAc,KAAK,QAAQ,MAAM,CAAC,MAAM,EAAE;QACjD,CAAC,IAAI;QACL,IAAI,CAAC,KAAK,KAAK,MAAM,CAAC,SAAS;QAC/B,IAAI,CAAC,SAAS,KAAK,MAAM,CAAC,eAAe;QACzC,IAAI,CAAC,OAAO,KAAK,MAAM,CAAC,OAAO;QAC/B,CAAC,IAAI,EAAE,KAAK;QACZ,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC;QACxB,IAAI,CAAC,KAAK,CAAC,SAAS,KAAK,MAAM,CAAC,eAAe;QAC/C,IAAI,CAAC,KAAK,CAAC,OAAO,KAAK,MAAM,CAAC,OAAO,EACrC,CAAC;QACD,4GAA4G;QAC5G,MAAM,IAAI,SAAS,CACjB,QAAQ,CAAC,uBAAuB,EAChC,mEAAmE,EACnE;YACE,GAAG,EAAE,2GAA2G;SACjH,CACF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type OrcaDiscovery, type OrcaLaunch, type OrcaRoutingAdapter } from '@cleocode/contracts/orca-execution.js';
|
|
2
|
+
import { type WorkerRecord } from './worker-records.js';
|
|
3
|
+
/**
|
|
4
|
+
* Rotate across usable configured agents, retaining every sent attempt durably.
|
|
5
|
+
* @remarks Only a proven pre-dispatch `agent_unconfigured` refusal may advance
|
|
6
|
+
* to another candidate. Unknown outcomes fence the task; retries keep their harness.
|
|
7
|
+
* @param prepared - Canonical prompt, worker identity and worktree lock.
|
|
8
|
+
* @param discovery - Proven local caller and sanitized account availability.
|
|
9
|
+
* @param backend - Injected host execution port, never a model provider.
|
|
10
|
+
* @param adapterId - Optional explicit CLEO harness restriction.
|
|
11
|
+
* @returns The exact durable worker, including any uncertain launch outcome.
|
|
12
|
+
*/
|
|
13
|
+
export declare function launchRoutedOrcaWorker(prepared: Omit<OrcaLaunch, 'instanceId' | 'harness'>, discovery: OrcaDiscovery, backend: OrcaRoutingAdapter, adapterId?: string): Promise<WorkerRecord>;
|