@ngockhoale/ckit 0.0.0-stage → 0.1.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/.env.example +21 -0
- package/README.md +70 -2
- package/dist/src/adapters/agent/claude/errors.d.ts +13 -0
- package/dist/src/adapters/agent/claude/errors.js +16 -0
- package/dist/src/adapters/agent/claude/normalize.d.ts +11 -0
- package/dist/src/adapters/agent/claude/normalize.js +83 -0
- package/dist/src/adapters/agent/errors.d.ts +13 -0
- package/dist/src/adapters/agent/errors.js +19 -0
- package/dist/src/adapters/agent/fixtures/claude-transcript.d.ts +70 -0
- package/dist/src/adapters/agent/fixtures/claude-transcript.js +15 -0
- package/dist/src/adapters/agent/fixtures/omp-transcript.d.ts +60 -0
- package/dist/src/adapters/agent/fixtures/omp-transcript.js +14 -0
- package/dist/src/adapters/agent/normalize.d.ts +18 -0
- package/dist/src/adapters/agent/normalize.js +77 -0
- package/dist/src/adapters/agent/transport.d.ts +35 -0
- package/dist/src/adapters/agent/transport.js +39 -0
- package/dist/src/adapters/agent/worker-service.d.ts +49 -0
- package/dist/src/adapters/agent/worker-service.js +77 -0
- package/dist/src/adapters/fake/fake-advisor.d.ts +15 -0
- package/dist/src/adapters/fake/fake-advisor.js +29 -0
- package/dist/src/adapters/fake/fake-agent.d.ts +12 -0
- package/dist/src/adapters/fake/fake-agent.js +21 -0
- package/dist/src/adapters/fake/fake-store.d.ts +13 -0
- package/dist/src/adapters/fake/fake-store.js +23 -0
- package/dist/src/adapters/fake/fake-web.d.ts +12 -0
- package/dist/src/adapters/fake/fake-web.js +21 -0
- package/dist/src/adapters/fake/fault-injector.d.ts +18 -0
- package/dist/src/adapters/fake/fault-injector.js +64 -0
- package/dist/src/adapters/fake/virtual-clock.d.ts +12 -0
- package/dist/src/adapters/fake/virtual-clock.js +35 -0
- package/dist/src/adapters/launch/discover.d.ts +18 -0
- package/dist/src/adapters/launch/discover.js +55 -0
- package/dist/src/adapters/launch/executor.d.ts +117 -0
- package/dist/src/adapters/launch/executor.js +383 -0
- package/dist/src/adapters/launch/profile.d.ts +35 -0
- package/dist/src/adapters/launch/profile.js +73 -0
- package/dist/src/adapters/launch/spawn.d.ts +29 -0
- package/dist/src/adapters/launch/spawn.js +18 -0
- package/dist/src/adapters/openai/openai-advisor.d.ts +56 -0
- package/dist/src/adapters/openai/openai-advisor.js +146 -0
- package/dist/src/cli/ckit.d.ts +5 -0
- package/dist/src/cli/ckit.js +384 -0
- package/dist/src/cli/demo.d.ts +1 -0
- package/dist/src/cli/demo.js +30 -0
- package/dist/src/cli/lifecycle.d.ts +19 -0
- package/dist/src/cli/lifecycle.js +90 -0
- package/dist/src/cli/sessions.d.ts +10 -0
- package/dist/src/cli/sessions.js +381 -0
- package/dist/src/cli/setup.d.ts +11 -0
- package/dist/src/cli/setup.js +115 -0
- package/dist/src/committee/decision.d.ts +84 -0
- package/dist/src/committee/decision.js +167 -0
- package/dist/src/committee/handover.d.ts +115 -0
- package/dist/src/committee/handover.js +191 -0
- package/dist/src/committee/no-progress.d.ts +44 -0
- package/dist/src/committee/no-progress.js +64 -0
- package/dist/src/committee/primary-registry.d.ts +15 -0
- package/dist/src/committee/primary-registry.js +60 -0
- package/dist/src/committee/reply-parser.d.ts +28 -0
- package/dist/src/committee/reply-parser.js +53 -0
- package/dist/src/committee/reviewer-scheduler.d.ts +101 -0
- package/dist/src/committee/reviewer-scheduler.js +163 -0
- package/dist/src/committee/role-epoch.d.ts +91 -0
- package/dist/src/committee/role-epoch.js +154 -0
- package/dist/src/core/control.d.ts +18 -0
- package/dist/src/core/control.js +29 -0
- package/dist/src/core/entities.d.ts +166 -0
- package/dist/src/core/entities.js +119 -0
- package/dist/src/core/errors.d.ts +9 -0
- package/dist/src/core/errors.js +17 -0
- package/dist/src/core/events.d.ts +72 -0
- package/dist/src/core/events.js +125 -0
- package/dist/src/core/ids.d.ts +47 -0
- package/dist/src/core/ids.js +32 -0
- package/dist/src/core/machine.d.ts +55 -0
- package/dist/src/core/machine.js +110 -0
- package/dist/src/core/policy.d.ts +34 -0
- package/dist/src/core/policy.js +59 -0
- package/dist/src/core/provenance.d.ts +20 -0
- package/dist/src/core/provenance.js +21 -0
- package/dist/src/core/record.d.ts +35 -0
- package/dist/src/core/record.js +67 -0
- package/dist/src/core/replay.d.ts +10 -0
- package/dist/src/core/replay.js +36 -0
- package/dist/src/core/run-task.d.ts +20 -0
- package/dist/src/core/run-task.js +48 -0
- package/dist/src/diagnostics/doctor.d.ts +78 -0
- package/dist/src/diagnostics/doctor.js +365 -0
- package/dist/src/diagnostics/journal-lock.d.ts +38 -0
- package/dist/src/diagnostics/journal-lock.js +181 -0
- package/dist/src/evidence/linker.d.ts +44 -0
- package/dist/src/evidence/linker.js +75 -0
- package/dist/src/evidence/report-parser.d.ts +27 -0
- package/dist/src/evidence/report-parser.js +17 -0
- package/dist/src/evidence/store.d.ts +36 -0
- package/dist/src/evidence/store.js +57 -0
- package/dist/src/gui/server.d.ts +27 -0
- package/dist/src/gui/server.js +497 -0
- package/dist/src/host/checkpoint.d.ts +22 -0
- package/dist/src/host/checkpoint.js +74 -0
- package/dist/src/host/export.d.ts +52 -0
- package/dist/src/host/export.js +45 -0
- package/dist/src/host/ipc.d.ts +57 -0
- package/dist/src/host/ipc.js +124 -0
- package/dist/src/host/leases.d.ts +27 -0
- package/dist/src/host/leases.js +40 -0
- package/dist/src/host/retention.d.ts +47 -0
- package/dist/src/host/retention.js +130 -0
- package/dist/src/host/supervisor.d.ts +59 -0
- package/dist/src/host/supervisor.js +64 -0
- package/dist/src/intake/owner-intake.d.ts +31 -0
- package/dist/src/intake/owner-intake.js +97 -0
- package/dist/src/intake/types.d.ts +46 -0
- package/dist/src/intake/types.js +2 -0
- package/dist/src/intent/context-packet.d.ts +68 -0
- package/dist/src/intent/context-packet.js +76 -0
- package/dist/src/intent/idea-ledger.d.ts +50 -0
- package/dist/src/intent/idea-ledger.js +136 -0
- package/dist/src/intent/ledger.d.ts +35 -0
- package/dist/src/intent/ledger.js +40 -0
- package/dist/src/intent/registry.d.ts +51 -0
- package/dist/src/intent/registry.js +44 -0
- package/dist/src/intent/revision.d.ts +37 -0
- package/dist/src/intent/revision.js +48 -0
- package/dist/src/orchestration/dispatcher.d.ts +32 -0
- package/dist/src/orchestration/dispatcher.js +136 -0
- package/dist/src/orchestration/milestone-loop.d.ts +149 -0
- package/dist/src/orchestration/milestone-loop.js +132 -0
- package/dist/src/orchestration/recovery-coordinator.d.ts +74 -0
- package/dist/src/orchestration/recovery-coordinator.js +180 -0
- package/dist/src/orchestration/work-order-contract.d.ts +44 -0
- package/dist/src/orchestration/work-order-contract.js +85 -0
- package/dist/src/orchestration/work-queue.d.ts +56 -0
- package/dist/src/orchestration/work-queue.js +95 -0
- package/dist/src/ports/advisor.d.ts +33 -0
- package/dist/src/ports/advisor.js +2 -0
- package/dist/src/ports/agent.d.ts +31 -0
- package/dist/src/ports/agent.js +2 -0
- package/dist/src/ports/capabilities.d.ts +3 -0
- package/dist/src/ports/capabilities.js +5 -0
- package/dist/src/ports/clock.d.ts +5 -0
- package/dist/src/ports/clock.js +5 -0
- package/dist/src/ports/store.d.ts +13 -0
- package/dist/src/ports/store.js +2 -0
- package/dist/src/ports/web.d.ts +29 -0
- package/dist/src/ports/web.js +2 -0
- package/dist/src/run/api-run.d.ts +49 -0
- package/dist/src/run/api-run.js +173 -0
- package/dist/src/run/plan-run.d.ts +22 -0
- package/dist/src/run/plan-run.js +233 -0
- package/dist/src/run/plan.d.ts +36 -0
- package/dist/src/run/plan.js +119 -0
- package/dist/src/run/verify.d.ts +25 -0
- package/dist/src/run/verify.js +81 -0
- package/dist/src/security/redact.d.ts +7 -0
- package/dist/src/security/redact.js +21 -0
- package/dist/src/settings/env-config.d.ts +64 -0
- package/dist/src/settings/env-config.js +232 -0
- package/dist/src/storage/artifacts.d.ts +30 -0
- package/dist/src/storage/artifacts.js +105 -0
- package/dist/src/storage/audit.d.ts +6 -0
- package/dist/src/storage/audit.js +6 -0
- package/dist/src/storage/db.d.ts +9 -0
- package/dist/src/storage/db.js +43 -0
- package/dist/src/storage/events.d.ts +20 -0
- package/dist/src/storage/events.js +69 -0
- package/dist/src/storage/migrations.d.ts +8 -0
- package/dist/src/storage/migrations.js +48 -0
- package/dist/src/storage/outbox.d.ts +25 -0
- package/dist/src/storage/outbox.js +40 -0
- package/dist/src/storage/projections.d.ts +18 -0
- package/dist/src/storage/projections.js +40 -0
- package/dist/src/storage/reconcile.d.ts +14 -0
- package/dist/src/storage/reconcile.js +93 -0
- package/dist/src/storage/reservations.d.ts +12 -0
- package/dist/src/storage/reservations.js +80 -0
- package/dist/src/storage/store.d.ts +34 -0
- package/dist/src/storage/store.js +105 -0
- package/dist/src/team/attachments.d.ts +22 -0
- package/dist/src/team/attachments.js +211 -0
- package/dist/src/team/cli-models.d.ts +24 -0
- package/dist/src/team/cli-models.js +72 -0
- package/dist/src/team/config.d.ts +20 -0
- package/dist/src/team/config.js +113 -0
- package/dist/src/team/engine.d.ts +28 -0
- package/dist/src/team/engine.js +443 -0
- package/dist/src/team/journal.d.ts +30 -0
- package/dist/src/team/journal.js +70 -0
- package/dist/src/team/runners.d.ts +79 -0
- package/dist/src/team/runners.js +436 -0
- package/dist/src/team/secrets.d.ts +10 -0
- package/dist/src/team/secrets.js +68 -0
- package/dist/src/team/types.d.ts +157 -0
- package/dist/src/team/types.js +5 -0
- package/dist/src/tui/app.d.ts +29 -0
- package/dist/src/tui/app.js +96 -0
- package/dist/src/tui/control-model.d.ts +101 -0
- package/dist/src/tui/control-model.js +109 -0
- package/dist/src/tui/control-screens.d.ts +27 -0
- package/dist/src/tui/control-screens.js +85 -0
- package/dist/src/tui/graph-model.d.ts +34 -0
- package/dist/src/tui/graph-model.js +29 -0
- package/dist/src/tui/graph-screens.d.ts +13 -0
- package/dist/src/tui/graph-screens.js +4 -0
- package/dist/src/tui/inspector-model.d.ts +150 -0
- package/dist/src/tui/inspector-model.js +15 -0
- package/dist/src/tui/inspector-screens.d.ts +14 -0
- package/dist/src/tui/inspector-screens.js +61 -0
- package/dist/src/tui/live.d.ts +16 -0
- package/dist/src/tui/live.js +39 -0
- package/dist/src/tui/mission-action-screens.d.ts +15 -0
- package/dist/src/tui/mission-action-screens.js +105 -0
- package/dist/src/tui/mission-actions.d.ts +46 -0
- package/dist/src/tui/mission-actions.js +53 -0
- package/dist/src/tui/mission-model.d.ts +120 -0
- package/dist/src/tui/mission-model.js +164 -0
- package/dist/src/tui/mission-nav.d.ts +82 -0
- package/dist/src/tui/mission-nav.js +131 -0
- package/dist/src/tui/mission-plan-screens.d.ts +11 -0
- package/dist/src/tui/mission-plan-screens.js +40 -0
- package/dist/src/tui/mission-plan.d.ts +45 -0
- package/dist/src/tui/mission-plan.js +166 -0
- package/dist/src/tui/mission-screens.d.ts +7 -0
- package/dist/src/tui/mission-screens.js +263 -0
- package/dist/src/tui/provenance-label.d.ts +11 -0
- package/dist/src/tui/provenance-label.js +16 -0
- package/dist/src/tui/screens.d.ts +10 -0
- package/dist/src/tui/screens.js +34 -0
- package/dist/src/tui/session-outcome.d.ts +14 -0
- package/dist/src/tui/session-outcome.js +57 -0
- package/dist/src/tui/setup-model.d.ts +159 -0
- package/dist/src/tui/setup-model.js +234 -0
- package/dist/src/tui/setup-screens.d.ts +66 -0
- package/dist/src/tui/setup-screens.js +72 -0
- package/dist/src/tui/team/app.d.ts +24 -0
- package/dist/src/tui/team/app.js +228 -0
- package/dist/src/tui/team/demo-handle.d.ts +22 -0
- package/dist/src/tui/team/demo-handle.js +42 -0
- package/dist/src/tui/team/model.d.ts +81 -0
- package/dist/src/tui/team/model.js +133 -0
- package/gui/app.css +177 -0
- package/gui/app.js +677 -0
- package/gui/index.html +51 -0
- package/gui/network.js +413 -0
- package/package.json +44 -4
- package/src/storage/schema.sql +42 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { classifyAgentError } from './errors.js';
|
|
2
|
+
export function applyLifecycleObservation(lifecycle, envelope, options = {}) {
|
|
3
|
+
const before = lifecycle.receipt();
|
|
4
|
+
const result = (transitioned) => Object.freeze({ receipt: lifecycle.receipt(), transitioned });
|
|
5
|
+
let next = null;
|
|
6
|
+
let transitionOptions = {};
|
|
7
|
+
if (envelope.eventType === 'AdvisorAcked' && envelope.status === 'accepted' && before.state === 'enqueued') {
|
|
8
|
+
const runId = options.runId ?? envelope.runId ?? undefined;
|
|
9
|
+
if (!runId)
|
|
10
|
+
return result(false);
|
|
11
|
+
next = 'accepted';
|
|
12
|
+
transitionOptions = { runId };
|
|
13
|
+
}
|
|
14
|
+
else if (envelope.status === 'running' && before.state === 'accepted') {
|
|
15
|
+
next = 'running';
|
|
16
|
+
}
|
|
17
|
+
else if (envelope.status === 'running' && before.state === 'enqueued' && options.runId) {
|
|
18
|
+
lifecycle.transition('accepted', { runId: options.runId });
|
|
19
|
+
next = 'running';
|
|
20
|
+
}
|
|
21
|
+
else if (envelope.status === 'waiting_input' && envelope.payload.type === 'AdvisorUnknownOutcome' && (before.state === 'accepted' || before.state === 'running')) {
|
|
22
|
+
const id = /^permission-request:(.+)$/.exec(envelope.payload.note)?.[1];
|
|
23
|
+
if (id) {
|
|
24
|
+
if (before.state === 'accepted')
|
|
25
|
+
lifecycle.transition('running');
|
|
26
|
+
next = 'waiting_input';
|
|
27
|
+
transitionOptions = { requestId: id };
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else if (envelope.eventType === 'AdvisorCompleted' && envelope.payload.type === 'AdvisorCompleted' && (before.state === 'accepted' || before.state === 'running' || before.state === 'waiting_input')) {
|
|
31
|
+
if (before.state === 'accepted')
|
|
32
|
+
lifecycle.transition('running');
|
|
33
|
+
if (before.state === 'waiting_input')
|
|
34
|
+
lifecycle.transition('running', { cause: 'input-resolved' });
|
|
35
|
+
next = 'finished';
|
|
36
|
+
transitionOptions = { cause: 'explicit-run-completion' };
|
|
37
|
+
}
|
|
38
|
+
else if (envelope.status === 'failed' && before.state !== 'finished' && before.state !== 'failed' && before.state !== 'unknown_delivery') {
|
|
39
|
+
next = 'failed';
|
|
40
|
+
transitionOptions = { cause: 'explicit-failure' };
|
|
41
|
+
}
|
|
42
|
+
if (next === null)
|
|
43
|
+
return result(false);
|
|
44
|
+
lifecycle.transition(next, transitionOptions);
|
|
45
|
+
return result(true);
|
|
46
|
+
}
|
|
47
|
+
export function classifyControlIntent(intent, receipt, evidence) {
|
|
48
|
+
const state = receipt.state === 'running' ? 'running' : receipt.state === 'waiting_input' ? 'waiting_input' : receipt.state === 'accepted' ? 'idle' : receipt.state === 'finished' ? 'exited' : receipt.state === 'failed' ? 'failed' : receipt.state === 'unknown_delivery' ? 'unknown' : 'not_started';
|
|
49
|
+
if (intent === 'pause')
|
|
50
|
+
return Object.freeze({ intent, action: 'queued', workState: state, evidence: null });
|
|
51
|
+
if (intent === 'interrupt' && state === 'running' && evidence?.interruptRequest && evidence.ackToken)
|
|
52
|
+
return Object.freeze({ intent, action: 'interrupted', workState: 'interrupted', evidence: Object.freeze({ ...evidence }) });
|
|
53
|
+
return Object.freeze({ intent, action: 'awaiting-ack', workState: state, evidence: null });
|
|
54
|
+
}
|
|
55
|
+
export function routePermissionRequest(envelope, receipt) {
|
|
56
|
+
if (receipt.state !== 'waiting_input' || envelope.status !== 'waiting_input' || envelope.payload.type !== 'AdvisorUnknownOutcome')
|
|
57
|
+
throw new TypeError('permission route requires waiting_input observation and receipt');
|
|
58
|
+
const match = /^permission-request:([A-Za-z0-9._:-]+)$/.exec(envelope.payload.note);
|
|
59
|
+
if (!match || !receipt.waitingRequestId || match[1] !== receipt.waitingRequestId)
|
|
60
|
+
throw new TypeError('permission request ID missing or mismatched');
|
|
61
|
+
return Object.freeze({ requestId: match[1], taskId: envelope.taskId, runId: receipt.runId, state: 'waiting_input', answered: false });
|
|
62
|
+
}
|
|
63
|
+
export function classifyFailure(cause, phase) {
|
|
64
|
+
const evidence = classifyAgentError(cause, { phase });
|
|
65
|
+
const unknown = evidence.kind === 'hung' || evidence.kind === 'timeout' || evidence.kind === 'unknown-delivery' || evidence.kind === 'shape-mismatch';
|
|
66
|
+
return Object.freeze({ kind: evidence.kind, workOutcome: unknown ? 'unknown' : 'failed', reconcileRequired: unknown, retryAllowed: false, reconcileState: evidence.kind === 'unknown-delivery' ? 'UNKNOWN_DELIVERY' : null, evidence });
|
|
67
|
+
}
|
|
68
|
+
export function turnResult(events) {
|
|
69
|
+
for (const event of events) {
|
|
70
|
+
if (event.eventType === 'AdvisorCompleted' && event.payload.type === 'AdvisorCompleted' && event.payload.resultRef.length > 0)
|
|
71
|
+
return Object.freeze({ completion: 'completed', resultRef: event.payload.resultRef, taskCompleted: false, reason: null });
|
|
72
|
+
if (event.eventType === 'AdvisorUnknownOutcome' && event.payload.type === 'AdvisorUnknownOutcome' && (event.payload.reason === 'timeout' || event.payload.reason === 'ack-lost'))
|
|
73
|
+
return Object.freeze({ completion: 'unknown', resultRef: null, taskCompleted: false, reason: event.payload.note });
|
|
74
|
+
}
|
|
75
|
+
return Object.freeze({ completion: 'none', resultRef: null, taskCompleted: false, reason: null });
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=worker-service.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AdvisorMessage, AdvisorPort, DispatchRequest } from '../../ports/advisor.js';
|
|
2
|
+
export type FaultInjection = 'none' | 'ack-lost' | 'timeout' | 'adapter-fault';
|
|
3
|
+
export interface FakeAdvisorOptions {
|
|
4
|
+
/** Simulated pre-ack latency in ms (default 0). */
|
|
5
|
+
readonly latencyMs?: number;
|
|
6
|
+
/** Deterministic fault to inject instead of a completed run. */
|
|
7
|
+
readonly fault?: FaultInjection;
|
|
8
|
+
}
|
|
9
|
+
export declare class FakeAdvisor implements AdvisorPort {
|
|
10
|
+
private readonly options;
|
|
11
|
+
readonly name = "fake-advisor:SIMULATED";
|
|
12
|
+
readonly isSimulated: true;
|
|
13
|
+
constructor(options?: FakeAdvisorOptions);
|
|
14
|
+
dispatch(req: DispatchRequest): AsyncIterable<AdvisorMessage>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export class FakeAdvisor {
|
|
2
|
+
options;
|
|
3
|
+
name = 'fake-advisor:SIMULATED';
|
|
4
|
+
isSimulated = true;
|
|
5
|
+
constructor(options = {}) {
|
|
6
|
+
this.options = options;
|
|
7
|
+
}
|
|
8
|
+
async *dispatch(req) {
|
|
9
|
+
void req;
|
|
10
|
+
const { latencyMs = 0, fault = 'none' } = this.options;
|
|
11
|
+
if (latencyMs > 0)
|
|
12
|
+
await new Promise((resolve) => setTimeout(resolve, latencyMs));
|
|
13
|
+
if (fault === 'ack-lost') {
|
|
14
|
+
yield { kind: 'unknown', reason: 'ack-lost', note: 'SIMULATED fault: ack never observed; outcome unverified' };
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (fault === 'timeout') {
|
|
18
|
+
yield { kind: 'unknown', reason: 'timeout', note: 'SIMULATED fault: deadline elapsed before completion' };
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (fault === 'adapter-fault') {
|
|
22
|
+
yield { kind: 'unknown', reason: 'adapter-fault', note: 'SIMULATED fault: adapter raised internally' };
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
yield { kind: 'ack' };
|
|
26
|
+
yield { kind: 'completed', resultRef: 'sim://result/fixture-001' };
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=fake-advisor.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AgentPort, AgentRequest } from '../../ports/agent.js';
|
|
2
|
+
import type { Capability } from '../../ports/capabilities.js';
|
|
3
|
+
import { type FaultOptions } from './fault-injector.js';
|
|
4
|
+
export declare class FakeAgent implements AgentPort {
|
|
5
|
+
private readonly options;
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly isSimulated: true;
|
|
8
|
+
readonly capabilities: Readonly<Record<string, Capability>>;
|
|
9
|
+
constructor(options?: FaultOptions);
|
|
10
|
+
dispatch(request: AgentRequest): AsyncGenerator<import("../../ports/agent.js").AgentObservation, void, any>;
|
|
11
|
+
reconcile(runId: string): Promise<'confirmed' | 'not-applied' | 'unknown'>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { isCapabilityEnabled } from '../../ports/capabilities.js';
|
|
2
|
+
import { capabilities, simulatedName, agentObservations } from './fault-injector.js';
|
|
3
|
+
export class FakeAgent {
|
|
4
|
+
options;
|
|
5
|
+
name = simulatedName('fake-agent');
|
|
6
|
+
isSimulated = true;
|
|
7
|
+
capabilities;
|
|
8
|
+
constructor(options = {}) {
|
|
9
|
+
this.options = options;
|
|
10
|
+
this.capabilities = capabilities(options.capability === undefined ? {} : { dispatch: options.capability });
|
|
11
|
+
}
|
|
12
|
+
async *dispatch(request) {
|
|
13
|
+
if (!isCapabilityEnabled(this.capabilities['dispatch'] ?? 'unknown'))
|
|
14
|
+
return;
|
|
15
|
+
yield* agentObservations(request.workOrderId, this.options);
|
|
16
|
+
}
|
|
17
|
+
async reconcile(runId) {
|
|
18
|
+
return this.options.fault === 'unknown-delivery' ? 'unknown' : runId.length > 0 ? 'confirmed' : 'unknown';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=fake-agent.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { StorePort, StoreSnapshot } from '../../ports/store.js';
|
|
2
|
+
export declare class FakeStore implements StorePort {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly isSimulated: true;
|
|
5
|
+
private bound;
|
|
6
|
+
private orders;
|
|
7
|
+
constructor(initial?: StoreSnapshot);
|
|
8
|
+
exportSnapshot(): Promise<StoreSnapshot>;
|
|
9
|
+
importSnapshot(snapshot: StoreSnapshot): Promise<void>;
|
|
10
|
+
isBound(): Promise<boolean>;
|
|
11
|
+
markBound(): Promise<void>;
|
|
12
|
+
pendingOrders(): Promise<readonly string[]>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { simulatedName } from './fault-injector.js';
|
|
2
|
+
export class FakeStore {
|
|
3
|
+
name = simulatedName('fake-store');
|
|
4
|
+
isSimulated = true;
|
|
5
|
+
bound = false;
|
|
6
|
+
orders;
|
|
7
|
+
constructor(initial = { bindingRequired: true, pendingOrderIds: [] }) {
|
|
8
|
+
this.orders = [...initial.pendingOrderIds];
|
|
9
|
+
}
|
|
10
|
+
async exportSnapshot() { return Object.freeze({ bindingRequired: !this.bound, pendingOrderIds: Object.freeze([...this.orders]) }); }
|
|
11
|
+
async importSnapshot(snapshot) {
|
|
12
|
+
if (typeof snapshot.bindingRequired !== 'boolean' || !Array.isArray(snapshot.pendingOrderIds) || snapshot.pendingOrderIds.some((id) => typeof id !== 'string' || !id))
|
|
13
|
+
throw new TypeError('invalid store snapshot');
|
|
14
|
+
if (new Set(snapshot.pendingOrderIds).size !== snapshot.pendingOrderIds.length)
|
|
15
|
+
throw new TypeError('duplicate pending order ID');
|
|
16
|
+
this.bound = false;
|
|
17
|
+
this.orders = [...snapshot.pendingOrderIds];
|
|
18
|
+
}
|
|
19
|
+
async isBound() { return this.bound; }
|
|
20
|
+
async markBound() { this.bound = true; }
|
|
21
|
+
async pendingOrders() { return Object.freeze([...this.orders]); }
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=fake-store.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { WebPort, WebRequest, DeliveryCertainty } from '../../ports/web.js';
|
|
2
|
+
import type { Capability } from '../../ports/capabilities.js';
|
|
3
|
+
import { type FaultOptions } from './fault-injector.js';
|
|
4
|
+
export declare class FakeWeb implements WebPort {
|
|
5
|
+
private readonly options;
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly isSimulated: true;
|
|
8
|
+
readonly capabilities: Readonly<Record<string, Capability>>;
|
|
9
|
+
constructor(options?: FaultOptions);
|
|
10
|
+
send(request: WebRequest): AsyncGenerator<import("../../ports/web.js").WebObservation, void, any>;
|
|
11
|
+
reconcile(requestId: string): Promise<DeliveryCertainty>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { isCapabilityEnabled } from '../../ports/capabilities.js';
|
|
2
|
+
import { capabilities, simulatedName, webObservations } from './fault-injector.js';
|
|
3
|
+
export class FakeWeb {
|
|
4
|
+
options;
|
|
5
|
+
name = simulatedName('fake-web');
|
|
6
|
+
isSimulated = true;
|
|
7
|
+
capabilities;
|
|
8
|
+
constructor(options = {}) {
|
|
9
|
+
this.options = options;
|
|
10
|
+
this.capabilities = capabilities(options.capability === undefined ? {} : { send: options.capability });
|
|
11
|
+
}
|
|
12
|
+
async *send(request) {
|
|
13
|
+
if (!isCapabilityEnabled(this.capabilities['send'] ?? 'unknown'))
|
|
14
|
+
return;
|
|
15
|
+
yield* webObservations(request.requestId, this.options);
|
|
16
|
+
}
|
|
17
|
+
async reconcile(requestId) {
|
|
18
|
+
return this.options.fault === 'unknown-delivery' ? 'unknown' : requestId.length > 0 ? 'confirmed' : 'unknown';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=fake-web.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Clock } from '../../ports/clock.js';
|
|
2
|
+
import type { Capability } from '../../ports/capabilities.js';
|
|
3
|
+
import type { AgentObservation } from '../../ports/agent.js';
|
|
4
|
+
import type { WebObservation, AdapterFault } from '../../ports/web.js';
|
|
5
|
+
export interface FaultOptions {
|
|
6
|
+
readonly fault?: AdapterFault;
|
|
7
|
+
readonly latencyMs?: number;
|
|
8
|
+
readonly clock?: Clock;
|
|
9
|
+
readonly capability?: Capability;
|
|
10
|
+
}
|
|
11
|
+
export declare const simulatedName: (name: string) => string;
|
|
12
|
+
export declare const capabilities: (overrides?: Readonly<Record<string, Capability>>) => Readonly<{
|
|
13
|
+
dispatch: 'supported';
|
|
14
|
+
cancel: 'unknown';
|
|
15
|
+
reconcile: 'supported';
|
|
16
|
+
}>;
|
|
17
|
+
export declare function webObservations(requestId: string, options?: FaultOptions): AsyncIterable<WebObservation>;
|
|
18
|
+
export declare function agentObservations(runId: string, options?: FaultOptions): AsyncIterable<AgentObservation>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export const simulatedName = (name) => `${name}:SIMULATED`;
|
|
2
|
+
export const capabilities = (overrides = {}) => Object.freeze({ dispatch: 'supported', cancel: 'unknown', reconcile: 'supported', ...overrides });
|
|
3
|
+
async function delay(options) {
|
|
4
|
+
const ms = options.latencyMs ?? (options.fault === 'latency' ? 100 : 0);
|
|
5
|
+
if (ms > 0) {
|
|
6
|
+
if (options.clock !== undefined) {
|
|
7
|
+
if ('advanceBy' in options.clock && typeof options.clock.advanceBy === 'function')
|
|
8
|
+
options.clock.advanceBy(ms);
|
|
9
|
+
else
|
|
10
|
+
await options.clock.sleep(ms);
|
|
11
|
+
}
|
|
12
|
+
// Clock-less fixture calls model immediate completion; deterministic latency scenarios inject a virtual clock.
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export async function* webObservations(requestId, options = {}) {
|
|
16
|
+
await delay(options);
|
|
17
|
+
switch (options.fault) {
|
|
18
|
+
case 'failure': throw new Error('SIMULATED fault: adapter failure');
|
|
19
|
+
case 'quota':
|
|
20
|
+
yield { kind: 'blocked', reason: 'quota' };
|
|
21
|
+
return;
|
|
22
|
+
case 'permission':
|
|
23
|
+
yield { kind: 'blocked', reason: 'permission' };
|
|
24
|
+
return;
|
|
25
|
+
case 'partial':
|
|
26
|
+
yield { kind: 'accepted', requestId };
|
|
27
|
+
yield { kind: 'chunk', text: 'partial fixture', complete: false };
|
|
28
|
+
return;
|
|
29
|
+
case 'unknown-delivery':
|
|
30
|
+
yield { kind: 'unknown-delivery', requestId };
|
|
31
|
+
return;
|
|
32
|
+
default:
|
|
33
|
+
yield { kind: 'accepted', requestId };
|
|
34
|
+
yield { kind: 'chunk', text: 'SIMULATED fixture response', complete: true };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export async function* agentObservations(runId, options = {}) {
|
|
38
|
+
await delay(options);
|
|
39
|
+
switch (options.fault) {
|
|
40
|
+
case 'failure': throw new Error('SIMULATED fault: agent failure');
|
|
41
|
+
case 'quota':
|
|
42
|
+
yield { kind: 'state', state: 'failed' };
|
|
43
|
+
return;
|
|
44
|
+
case 'permission':
|
|
45
|
+
yield { kind: 'permission-required', requestId: `${runId}-permission` };
|
|
46
|
+
return;
|
|
47
|
+
case 'unknown-delivery':
|
|
48
|
+
yield { kind: 'unknown-outcome', runId };
|
|
49
|
+
return;
|
|
50
|
+
case 'partial':
|
|
51
|
+
yield { kind: 'accepted', runId };
|
|
52
|
+
yield { kind: 'state', state: 'running' };
|
|
53
|
+
yield { kind: 'output', text: 'partial fixture' };
|
|
54
|
+
return;
|
|
55
|
+
case 'latency':
|
|
56
|
+
yield { kind: 'accepted', runId };
|
|
57
|
+
yield { kind: 'state', state: 'running' };
|
|
58
|
+
return;
|
|
59
|
+
default:
|
|
60
|
+
yield { kind: 'accepted', runId };
|
|
61
|
+
yield { kind: 'state', state: 'completed' };
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=fault-injector.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Clock } from '../../ports/clock.js';
|
|
2
|
+
/** Deterministic clock for SIMULATED fixture scenarios. */
|
|
3
|
+
export declare class VirtualClock implements Clock {
|
|
4
|
+
private time;
|
|
5
|
+
private order;
|
|
6
|
+
private sleepers;
|
|
7
|
+
constructor(startAt?: number);
|
|
8
|
+
now(): number;
|
|
9
|
+
sleep(ms: number): Promise<void>;
|
|
10
|
+
advanceBy(ms: number): void;
|
|
11
|
+
pendingSleepers(): number;
|
|
12
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** Deterministic clock for SIMULATED fixture scenarios. */
|
|
2
|
+
export class VirtualClock {
|
|
3
|
+
time;
|
|
4
|
+
order = 0;
|
|
5
|
+
sleepers = [];
|
|
6
|
+
constructor(startAt = 0) {
|
|
7
|
+
if (!Number.isFinite(startAt))
|
|
8
|
+
throw new RangeError('start time must be finite');
|
|
9
|
+
this.time = startAt;
|
|
10
|
+
}
|
|
11
|
+
now() { return this.time; }
|
|
12
|
+
sleep(ms) {
|
|
13
|
+
if (!Number.isFinite(ms) || ms < 0)
|
|
14
|
+
return Promise.reject(new RangeError('sleep duration must be finite and non-negative'));
|
|
15
|
+
if (ms === 0)
|
|
16
|
+
return Promise.resolve();
|
|
17
|
+
return new Promise((resolve) => {
|
|
18
|
+
this.sleepers.push({ due: this.time + ms, order: this.order++, resolve });
|
|
19
|
+
this.sleepers.sort((a, b) => a.due - b.due || a.order - b.order);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
advanceBy(ms) {
|
|
23
|
+
if (!Number.isFinite(ms))
|
|
24
|
+
throw new RangeError('advance must be finite');
|
|
25
|
+
if (ms < 0)
|
|
26
|
+
throw new RangeError('advance must be non-negative');
|
|
27
|
+
this.time += ms;
|
|
28
|
+
const due = this.sleepers.filter((s) => s.due <= this.time);
|
|
29
|
+
this.sleepers = this.sleepers.filter((s) => s.due > this.time);
|
|
30
|
+
for (const sleeper of due)
|
|
31
|
+
sleeper.resolve();
|
|
32
|
+
}
|
|
33
|
+
pendingSleepers() { return this.sleepers.length; }
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=virtual-clock.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface EvidenceReceipt {
|
|
2
|
+
readonly path: string;
|
|
3
|
+
readonly sha256: string;
|
|
4
|
+
readonly category: 'instructions' | 'skill' | 'hook';
|
|
5
|
+
}
|
|
6
|
+
export interface DiscoveryResult {
|
|
7
|
+
readonly executable?: string;
|
|
8
|
+
readonly alias: boolean;
|
|
9
|
+
readonly guidance?: string;
|
|
10
|
+
readonly ukitPresent: boolean;
|
|
11
|
+
readonly evidence: readonly EvidenceReceipt[];
|
|
12
|
+
readonly mutations: readonly never[];
|
|
13
|
+
}
|
|
14
|
+
export declare function discoverLaunch(input: {
|
|
15
|
+
readonly target: string;
|
|
16
|
+
readonly executable: string;
|
|
17
|
+
readonly aliases: readonly string[];
|
|
18
|
+
}): Promise<DiscoveryResult>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { lstat, readFile, readdir, realpath } from 'node:fs/promises';
|
|
3
|
+
import { join, relative, resolve, sep } from 'node:path';
|
|
4
|
+
export async function discoverLaunch(input) {
|
|
5
|
+
const target = await realpath(input.target);
|
|
6
|
+
const alias = input.aliases.includes(input.executable);
|
|
7
|
+
const evidence = [];
|
|
8
|
+
const candidates = ['AGENTS.md', 'CLAUDE.md', 'GEMINI.md', '.claude/settings.json', '.claude/hooks', '.claude/skills'];
|
|
9
|
+
for (const candidate of candidates) {
|
|
10
|
+
const full = join(target, candidate);
|
|
11
|
+
try {
|
|
12
|
+
const stat = await lstat(full);
|
|
13
|
+
if (stat.isSymbolicLink())
|
|
14
|
+
continue;
|
|
15
|
+
const paths = stat.isDirectory() ? await walk(full, target) : [full];
|
|
16
|
+
for (const path of paths) {
|
|
17
|
+
const bytes = await readFile(path);
|
|
18
|
+
const rel = relative(target, path).split(sep).join('/');
|
|
19
|
+
evidence.push({ path: rel, sha256: createHash('sha256').update(bytes).digest('hex'), category: category(rel) });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
if (error.code !== 'ENOENT')
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const ukitPresent = evidence.some((item) => item.path.includes('ukit') || item.path === '.claude/settings.json');
|
|
28
|
+
const base = { alias, ukitPresent, evidence: Object.freeze(evidence), mutations: [] };
|
|
29
|
+
if (alias)
|
|
30
|
+
return { ...base, guidance: `Configured name "${input.executable}" is a shell alias. Resolve its executable path explicitly; aliases are never spawned directly.` };
|
|
31
|
+
const executable = resolve(input.executable);
|
|
32
|
+
const absolute = { ...base, executable };
|
|
33
|
+
if (!ukitPresent)
|
|
34
|
+
return { ...absolute, guidance: 'Target has no UKit installation; continuing without self-install or target mutation.', evidence: Object.freeze([...evidence, { path: 'no UKit installation', sha256: createHash('sha256').update('no UKit installation').digest('hex'), category: 'instructions' }]) };
|
|
35
|
+
return absolute;
|
|
36
|
+
}
|
|
37
|
+
function category(path) { return path.includes('/skills/') || path.endsWith('/SKILL.md') ? 'skill' : path.includes('hook') || path.endsWith('.json') ? 'hook' : 'instructions'; }
|
|
38
|
+
async function walk(directory, root) {
|
|
39
|
+
const entries = await readdir(directory, { withFileTypes: true });
|
|
40
|
+
const result = [];
|
|
41
|
+
for (const entry of entries) {
|
|
42
|
+
if (entry.isSymbolicLink())
|
|
43
|
+
continue;
|
|
44
|
+
const path = join(directory, entry.name);
|
|
45
|
+
if (entry.isDirectory())
|
|
46
|
+
result.push(...await walk(path, root));
|
|
47
|
+
else if (entry.isFile()) {
|
|
48
|
+
const rel = relative(root, path);
|
|
49
|
+
if (!rel.startsWith(`..${sep}`))
|
|
50
|
+
result.push(path);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=discover.js.map
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { type ChildProcess, type SpawnOptions } from 'node:child_process';
|
|
2
|
+
import type { CkitConfig } from '../../settings/env-config.js';
|
|
3
|
+
export interface ExecutorSpec {
|
|
4
|
+
readonly kind: 'claude-code' | 'omp';
|
|
5
|
+
readonly executable: 'claude' | 'omp';
|
|
6
|
+
/** Fixed args; the instruction is appended as the final positional by runExecutor. */
|
|
7
|
+
readonly args: readonly string[];
|
|
8
|
+
}
|
|
9
|
+
/** claude: `-p` prompt as trailing positional (help documents `[prompt]`; stdin use is not documented in --help, so not relied on). omp: trailing MESSAGES positional. */
|
|
10
|
+
export declare function selectExecutor(config: Pick<CkitConfig, 'executor' | 'executorModel'> & Partial<Pick<CkitConfig, 'executorPermissionMode'>>): ExecutorSpec;
|
|
11
|
+
/** Preflight/doctor line for the opt-in worker permission mode. omp has no equivalent flag: it is never passed. */
|
|
12
|
+
export declare function describeWorkerPermission(kind: ExecutorSpec['kind'], mode: string | null): string;
|
|
13
|
+
export declare class ExecutorResolveError extends Error {
|
|
14
|
+
}
|
|
15
|
+
/** Finds an absolute executable path without running it. */
|
|
16
|
+
export declare function resolveExecutable(spec: ExecutorSpec, config: Pick<CkitConfig, 'executorPath'>, env?: Readonly<Record<string, string | undefined>>): string;
|
|
17
|
+
/**
|
|
18
|
+
* Worker-credential allowlist per adapter (TASK-T05-10, owner decision 2026-11-08). A name listed here is kept when inherited from the
|
|
19
|
+
* launching env even if its value equals the advisor key: an equal value does not mean CKit copied the advisor key.
|
|
20
|
+
* - claude-code: ANTHROPIC_AUTH_TOKEN and ANTHROPIC_API_KEY. Source: `claude --help` (--bare: "Anthropic auth is strictly ANTHROPIC_API_KEY or
|
|
21
|
+
* apiKeyHelper") and the ANTHROPIC_AUTH_TOKEN gateway convention the owner relies on. No other claude credential variable is confirmed locally.
|
|
22
|
+
* - omp: empty. `omp --help` lists ~40 provider keys and omp has its own credential vault (auth-broker), so which variable the worker uses cannot
|
|
23
|
+
* be confirmed; guessing would widen the boundary. Add names here only with a documented source.
|
|
24
|
+
* The lists are isolated: an omp run never keeps ANTHROPIC_* because of the claude list, and the reverse.
|
|
25
|
+
*/
|
|
26
|
+
export declare const WORKER_CREDENTIAL_ALLOWLIST: Readonly<Record<ExecutorSpec['kind'], readonly string[]>>;
|
|
27
|
+
export type WithheldReason = 'equals-advisor-key' | 'contains-advisor-key';
|
|
28
|
+
export interface WithheldVar {
|
|
29
|
+
readonly name: string;
|
|
30
|
+
readonly reason: WithheldReason;
|
|
31
|
+
}
|
|
32
|
+
/** present: an allowlisted credential is in the worker env. missing: the adapter has an allowlist and none is there. unmanaged: the adapter has no allowlist (it uses its own login). Presence never implies validity. */
|
|
33
|
+
export type WorkerAuth = 'present' | 'missing' | 'unmanaged';
|
|
34
|
+
export interface WorkerEnvPolicy {
|
|
35
|
+
readonly env: Record<string, string>;
|
|
36
|
+
readonly withheld: readonly WithheldVar[];
|
|
37
|
+
readonly workerAuth: WorkerAuth;
|
|
38
|
+
}
|
|
39
|
+
/** The single env-boundary policy shared by runs, the run preflight and doctor. Never reads or returns advisor-key values in names/reasons; never derives a worker credential from CKIT_*. */
|
|
40
|
+
export declare function executorEnvironmentReport(processEnv: Readonly<Record<string, string | undefined>>, advisorKey: string, kind: ExecutorSpec['kind']): WorkerEnvPolicy;
|
|
41
|
+
/** Child env. `kind` omitted means no allowlist (strictest). */
|
|
42
|
+
export declare function executorEnvironment(processEnv: Readonly<Record<string, string | undefined>>, advisorKey: string, kind?: ExecutorSpec['kind']): Record<string, string>;
|
|
43
|
+
/** One-line diagnostic for the run log and journal note; names and reason codes only. null when nothing was withheld. */
|
|
44
|
+
export declare function envBoundaryNote(withheld: readonly WithheldVar[]): string | null;
|
|
45
|
+
/** Preflight line (run and doctor): names, reason codes and worker-auth state; no values; presence is not validity. */
|
|
46
|
+
export declare function describeWorkerEnv(policy: WorkerEnvPolicy): string;
|
|
47
|
+
export type ExecutorResult = {
|
|
48
|
+
readonly status: 'completed';
|
|
49
|
+
readonly text: string;
|
|
50
|
+
} | {
|
|
51
|
+
readonly status: 'failed';
|
|
52
|
+
readonly exitCode: number | null;
|
|
53
|
+
readonly text: string;
|
|
54
|
+
readonly stderrTail?: string;
|
|
55
|
+
} | {
|
|
56
|
+
readonly status: 'unknown';
|
|
57
|
+
readonly reason: 'timeout' | 'cancelled' | 'spawn-error';
|
|
58
|
+
readonly note: string;
|
|
59
|
+
readonly stderrTail?: string;
|
|
60
|
+
};
|
|
61
|
+
export type SpawnImpl = (command: string, args: readonly string[], options: SpawnOptions) => ChildProcess;
|
|
62
|
+
/** What the owner needs to see after a failed worker: its result text and redacted stderr tail (bounded) and the env-boundary note. */
|
|
63
|
+
export declare function executorFailureDetail(xr: ExecutorResult, withheld: readonly WithheldVar[]): string;
|
|
64
|
+
export interface SubagentObservation {
|
|
65
|
+
readonly childId: string;
|
|
66
|
+
readonly subagentType: string | null;
|
|
67
|
+
readonly description: string | null;
|
|
68
|
+
readonly via: 'task-tool-use' | 'parent-tool-use-id';
|
|
69
|
+
}
|
|
70
|
+
/** Pure: a claude stream-json frame yields an observation only when it explicitly names a subagent. Nothing is inferred. */
|
|
71
|
+
export declare function claudeSubagentObservations(frame: unknown): SubagentObservation[];
|
|
72
|
+
/** Pure NDJSON parse; non-JSON lines are skipped. claude: final `result` line. omp: `agent_end` messages, else last assistant text seen. */
|
|
73
|
+
export declare function parseExecutorOutput(kind: ExecutorSpec['kind'], stdout: string): {
|
|
74
|
+
text: string;
|
|
75
|
+
isError: boolean;
|
|
76
|
+
};
|
|
77
|
+
/** onEvent observer for a run log. claude: one line per observed subagent (deduped by id). omp: states once that child visibility is unsupported; never invents a child. */
|
|
78
|
+
export declare function subagentLogger(kind: ExecutorSpec['kind'], log: (line: string) => void): {
|
|
79
|
+
readonly announce: () => void;
|
|
80
|
+
readonly onEvent: (frame: unknown) => void;
|
|
81
|
+
readonly seen: () => readonly SubagentObservation[];
|
|
82
|
+
};
|
|
83
|
+
export interface RunExecutorOptions {
|
|
84
|
+
readonly cwd: string;
|
|
85
|
+
readonly timeoutMs: number;
|
|
86
|
+
readonly signal?: AbortSignal; /** Aborting this escalates a cancel straight to SIGKILL on the CKit-owned group (no grace wait). */
|
|
87
|
+
readonly hardKill?: AbortSignal;
|
|
88
|
+
readonly spawnImpl?: SpawnImpl;
|
|
89
|
+
readonly env?: Readonly<Record<string, string>>;
|
|
90
|
+
readonly onSpawn?: () => void;
|
|
91
|
+
readonly killGraceMs?: number;
|
|
92
|
+
/** Receives each parsed NDJSON stdout object as soon as its line is complete (line-buffered across chunks). */
|
|
93
|
+
readonly onEvent?: (frame: unknown) => void;
|
|
94
|
+
/** Exact secret values redacted from stderrTail (in addition to pattern redaction). */
|
|
95
|
+
readonly secrets?: readonly string[];
|
|
96
|
+
}
|
|
97
|
+
export declare function runExecutor(spec: ExecutorSpec, path: string, instruction: string, options: RunExecutorOptions): Promise<ExecutorResult>;
|
|
98
|
+
/** Whitespace split with simple double quotes; no escapes, globbing or expansion (the command runs with shell:false). */
|
|
99
|
+
export declare function splitCommand(command: string): string[];
|
|
100
|
+
export interface AcceptanceCommandOptions {
|
|
101
|
+
readonly cwd: string;
|
|
102
|
+
readonly timeoutMs: number;
|
|
103
|
+
readonly env?: Readonly<Record<string, string>>;
|
|
104
|
+
readonly signal?: AbortSignal;
|
|
105
|
+
readonly spawnImpl?: SpawnImpl;
|
|
106
|
+
readonly killGraceMs?: number;
|
|
107
|
+
}
|
|
108
|
+
export interface AcceptanceCommandResult {
|
|
109
|
+
readonly exitCode: number | null;
|
|
110
|
+
readonly signal: string | null;
|
|
111
|
+
readonly timedOut: boolean;
|
|
112
|
+
readonly cancelled: boolean;
|
|
113
|
+
readonly spawnError: string | null;
|
|
114
|
+
readonly output: string;
|
|
115
|
+
}
|
|
116
|
+
/** Runs one allow-listed acceptance command (argv[0] resolved via the child env PATH) with the same kill discipline as the executor. */
|
|
117
|
+
export declare function runAcceptanceCommand(argv: readonly string[], options: AcceptanceCommandOptions): Promise<AcceptanceCommandResult>;
|