@codetreker/daynight 0.21.9 → 0.21.13
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 +359 -27
- package/dist/api/client.d.ts +4 -1
- package/dist/api/client.js +18 -1
- package/dist/api/client.js.map +1 -1
- package/dist/api/parse.d.ts +3 -1
- package/dist/api/parse.js +27 -0
- package/dist/api/parse.js.map +1 -1
- package/dist/api/types.d.ts +18 -3
- package/dist/cli/commands.js +2 -0
- package/dist/cli/commands.js.map +1 -1
- package/dist/commands/skill/skills/using-daynight/references/handoff.md +3 -3
- package/dist/commands/worker/cleanup.d.ts +6 -0
- package/dist/commands/worker/cleanup.js +173 -0
- package/dist/commands/worker/cleanup.js.map +1 -0
- package/dist/commands/worker/config.d.ts +21 -0
- package/dist/commands/worker/config.js +144 -0
- package/dist/commands/worker/config.js.map +1 -0
- package/dist/commands/worker/control.d.ts +55 -0
- package/dist/commands/worker/control.js +151 -0
- package/dist/commands/worker/control.js.map +1 -0
- package/dist/commands/worker/coordinator.d.ts +35 -0
- package/dist/commands/worker/coordinator.js +548 -0
- package/dist/commands/worker/coordinator.js.map +1 -0
- package/dist/commands/worker/definition.d.ts +2 -0
- package/dist/commands/worker/definition.js +50 -0
- package/dist/commands/worker/definition.js.map +1 -0
- package/dist/commands/worker/diagnostics.d.ts +20 -0
- package/dist/commands/worker/diagnostics.js +56 -0
- package/dist/commands/worker/diagnostics.js.map +1 -0
- package/dist/commands/worker/execution.d.ts +41 -0
- package/dist/commands/worker/execution.js +318 -0
- package/dist/commands/worker/execution.js.map +1 -0
- package/dist/commands/worker/herdr/agents.d.ts +186 -0
- package/dist/commands/worker/herdr/agents.js +726 -0
- package/dist/commands/worker/herdr/agents.js.map +1 -0
- package/dist/commands/worker/herdr/arguments.d.ts +8 -0
- package/dist/commands/worker/herdr/arguments.js +58 -0
- package/dist/commands/worker/herdr/arguments.js.map +1 -0
- package/dist/commands/worker/herdr/codex-input.d.ts +2 -0
- package/dist/commands/worker/herdr/codex-input.js +35 -0
- package/dist/commands/worker/herdr/codex-input.js.map +1 -0
- package/dist/commands/worker/herdr/command.d.ts +22 -0
- package/dist/commands/worker/herdr/command.js +115 -0
- package/dist/commands/worker/herdr/command.js.map +1 -0
- package/dist/commands/worker/herdr/instance.d.ts +56 -0
- package/dist/commands/worker/herdr/instance.js +322 -0
- package/dist/commands/worker/herdr/instance.js.map +1 -0
- package/dist/commands/worker/herdr/preflight.d.ts +40 -0
- package/dist/commands/worker/herdr/preflight.js +251 -0
- package/dist/commands/worker/herdr/preflight.js.map +1 -0
- package/dist/commands/worker/herdr/rpc.d.ts +29 -0
- package/dist/commands/worker/herdr/rpc.js +186 -0
- package/dist/commands/worker/herdr/rpc.js.map +1 -0
- package/dist/commands/worker/herdr.d.ts +95 -0
- package/dist/commands/worker/herdr.js +35 -0
- package/dist/commands/worker/herdr.js.map +1 -0
- package/dist/commands/worker/index.d.ts +18 -0
- package/dist/commands/worker/index.js +58 -0
- package/dist/commands/worker/index.js.map +1 -0
- package/dist/commands/worker/instance-lock.d.ts +5 -0
- package/dist/commands/worker/instance-lock.js +11 -1
- package/dist/commands/worker/instance-lock.js.map +1 -1
- package/dist/commands/worker/prompts.d.ts +4 -0
- package/dist/commands/worker/prompts.js +64 -0
- package/dist/commands/worker/prompts.js.map +1 -0
- package/dist/commands/worker/remote.d.ts +23 -0
- package/dist/commands/worker/remote.js +146 -0
- package/dist/commands/worker/remote.js.map +1 -0
- package/dist/commands/worker/runtime.d.ts +16 -0
- package/dist/commands/worker/runtime.js +384 -0
- package/dist/commands/worker/runtime.js.map +1 -0
- package/dist/commands/worker/store.d.ts +73 -5
- package/dist/commands/worker/store.js +475 -36
- package/dist/commands/worker/store.js.map +1 -1
- package/dist/commands/worker/types.d.ts +37 -1
- package/dist/commands/worker/worktrees.d.ts +1 -0
- package/dist/commands/worker/worktrees.js +9 -0
- package/dist/commands/worker/worktrees.js.map +1 -1
- package/dist/config/document.d.ts +1 -1
- package/dist/config/document.js +1 -0
- package/dist/config/document.js.map +1 -1
- package/dist/platform/instance-lock.d.ts +4 -0
- package/dist/platform/instance-lock.js +9 -1
- package/dist/platform/instance-lock.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const help = { names: ["-h", "--help"], description: "Show this help", action: "help" };
|
|
2
|
+
const claim = { names: ["--claim-id"], description: "Identify the original execution claim", value: { name: "claim-id", kind: "text" }, required: true };
|
|
3
|
+
const project = { names: ["--project"], description: "Identify the task's project explicitly", value: { name: "project-id", kind: "text" } };
|
|
4
|
+
const version = { names: ["--if-version"], description: "Use exactly this observed task version", value: { name: "version", kind: "text" }, required: true };
|
|
5
|
+
const task = [{ name: "task-id", description: "Task UUID" }];
|
|
6
|
+
const controlDetails = "The original claim must have a matching local record. Persist the source management decision, then let the sole worker controller clean its agent, workspace and worktree before the version-bound remote operation. Cleanup keeps its original deadline of at most 10 minutes. An unknown remote result is reconciled without replaying the write. A definite refusal requires a new explicit decision with a freshly observed version.";
|
|
7
|
+
export const workerDefinition = {
|
|
8
|
+
name: "worker",
|
|
9
|
+
description: "Run automatically claimed tasks in dedicated worktrees and Herdr",
|
|
10
|
+
commands: [{
|
|
11
|
+
name: "run",
|
|
12
|
+
description: "Run the foreground task worker until interrupted",
|
|
13
|
+
options: [help],
|
|
14
|
+
details: "Read worker settings from ~/.daynight/config.yml at startup.\nState: ~/.daynight/worker/ (fixed to the current user's home directory).\nCtrl+C stops the original agents while preserving unfinished claims, worktrees and native history.",
|
|
15
|
+
}, {
|
|
16
|
+
name: "retry",
|
|
17
|
+
description: "Authorize one more recovery attempt for a paused original claim",
|
|
18
|
+
arguments: task,
|
|
19
|
+
options: [claim, project, help],
|
|
20
|
+
details: "Retain the original execution identity, frozen configuration and recovery count. Repeated requests do not accumulate extra attempts. The foreground worker remains the sole agent controller; without it, the command acquires the same instance lock.",
|
|
21
|
+
}, {
|
|
22
|
+
name: "release",
|
|
23
|
+
description: "Clean the original execution and release its claim to todo",
|
|
24
|
+
arguments: task,
|
|
25
|
+
options: [claim, version, project, help],
|
|
26
|
+
details: `${controlDetails}\nThe daemon skips released tasks until explicitly resumed.`,
|
|
27
|
+
}, {
|
|
28
|
+
name: "transfer",
|
|
29
|
+
description: "Clean the source and assign a fresh execution to a project member",
|
|
30
|
+
arguments: task,
|
|
31
|
+
options: [claim, version,
|
|
32
|
+
{ names: ["--target-user-id"], description: "Target project member UUID", value: { name: "user-id", kind: "text" }, required: true },
|
|
33
|
+
{ names: ["--target-worker-id"], description: "Target worker UUID", value: { name: "worker-id", kind: "text" }, required: true },
|
|
34
|
+
{ names: ["--target-machine-id"], description: "Target machine UUID", value: { name: "machine-id", kind: "text" }, required: true },
|
|
35
|
+
{ names: ["--target-machine-name"], description: "Target machine's reported name", value: { name: "machine-name", kind: "text" }, required: true },
|
|
36
|
+
{ names: ["--target-platform"], description: "Target worker's actual platform", value: { name: "platform", kind: "text", choices: ["windows", "linux", "macos"] }, required: true },
|
|
37
|
+
{ names: ["--target-agent"], description: "Agent type for the target's new execution", value: { name: "agent", kind: "text", choices: ["codex", "copilot"] }, required: true },
|
|
38
|
+
project, help],
|
|
39
|
+
details: `${controlDetails}\nThe target must remain a project member and satisfy automatic permission, platform and dependency requirements. A fresh claim and worktree identity are saved before submission. The target starts normally after receiving the grant; no source files or native history are transported.`,
|
|
40
|
+
}, {
|
|
41
|
+
name: "resume",
|
|
42
|
+
description: "Start a released task as a fresh execution on this worker",
|
|
43
|
+
arguments: task,
|
|
44
|
+
options: [claim, version, project, help],
|
|
45
|
+
details: "--claim-id identifies the previous released claim. The original owner or a project admin may explicitly resume a ready task, including the manual permission/platform exception. Use a fresh claim, worktree identity and native conversation with this worker's current effective configuration. The source worktree and native history are not required. The exact --if-version is never replaced; uncertain writes are reconciled without replay.",
|
|
46
|
+
}],
|
|
47
|
+
options: [help],
|
|
48
|
+
details: "Run daynight worker <command> --help for command usage.\nState: ~/.daynight/worker/ (fixed to the current user's home directory).",
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../../src/commands/worker/definition.ts"],"names":[],"mappings":"AAEA,MAAM,IAAI,GAAkB,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AACvG,MAAM,KAAK,GAAkB,EAAE,KAAK,EAAE,CAAC,YAAY,CAAC,EAAE,WAAW,EAAE,uCAAuC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AACxK,MAAM,OAAO,GAAkB,EAAE,KAAK,EAAE,CAAC,WAAW,CAAC,EAAE,WAAW,EAAE,wCAAwC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC;AAC5J,MAAM,OAAO,GAAkB,EAAE,KAAK,EAAE,CAAC,cAAc,CAAC,EAAE,WAAW,EAAE,wCAAwC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAC5K,MAAM,IAAI,GAAG,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC,CAAC;AAC7D,MAAM,cAAc,GAAG,0aAA0a,CAAC;AAElc,MAAM,CAAC,MAAM,gBAAgB,GAAsB;IACjD,IAAI,EAAE,QAAQ;IACd,WAAW,EAAE,kEAAkE;IAC/E,QAAQ,EAAE,CAAC;YACT,IAAI,EAAE,KAAK;YACX,WAAW,EAAE,kDAAkD;YAC/D,OAAO,EAAE,CAAC,IAAI,CAAC;YACf,OAAO,EAAE,4OAA4O;SACtP,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AAC,EAAE,WAAW,EAAE,iCAAiC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBACnL,EAAE,KAAK,EAAE,CAAC,gBAAgB,CAAC,EAAE,WAAW,EAAE,2CAA2C,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC9K,OAAO,EAAE,IAAI,CAAC;YAChB,OAAO,EAAE,GAAG,cAAc,6RAA6R;SACxT,EAAE;YACD,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,2DAA2D;YACxE,SAAS,EAAE,IAAI;YACf,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC;YACxC,OAAO,EAAE,sbAAsb;SAChc,CAAC;IACF,OAAO,EAAE,CAAC,IAAI,CAAC;IACf,OAAO,EAAE,mIAAmI;CAC7I,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { TaskPlatform } from "../../api/types.js";
|
|
2
|
+
import type { WorkerPaths } from "./paths.js";
|
|
3
|
+
import type { LocalTask } from "./types.js";
|
|
4
|
+
export type WorkerDiagnostic = {
|
|
5
|
+
kind: string;
|
|
6
|
+
message: string;
|
|
7
|
+
task?: LocalTask;
|
|
8
|
+
error?: unknown;
|
|
9
|
+
};
|
|
10
|
+
export declare const createWorkerDiagnostics: (options: {
|
|
11
|
+
paths: WorkerPaths;
|
|
12
|
+
workerId: string;
|
|
13
|
+
platform: TaskPlatform;
|
|
14
|
+
log?: (message: string) => void;
|
|
15
|
+
secrets?: readonly string[];
|
|
16
|
+
}) => Promise<{
|
|
17
|
+
emit: (event: WorkerDiagnostic) => void;
|
|
18
|
+
flush: () => Promise<void>;
|
|
19
|
+
filename: string;
|
|
20
|
+
}>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { appendFile, mkdir } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
export const createWorkerDiagnostics = async (options) => {
|
|
4
|
+
await mkdir(options.paths.logsDirectory, { recursive: true, mode: 0o700 });
|
|
5
|
+
const filename = path.join(options.paths.logsDirectory, `worker-${new Date().toISOString().slice(0, 10)}.jsonl`);
|
|
6
|
+
const redact = (value) => {
|
|
7
|
+
let result = value;
|
|
8
|
+
for (const secret of options.secrets === undefined ? [] : options.secrets) {
|
|
9
|
+
if (secret.length !== 0)
|
|
10
|
+
for (const representation of new Set([secret, encodeURIComponent(secret)]))
|
|
11
|
+
result = result.replaceAll(representation, "[redacted]");
|
|
12
|
+
}
|
|
13
|
+
return result.replace(/\b(Bearer\s+)[^\s"']+/gi, "$1[redacted]").replace(/\b(https?:\/\/)[^\s/@]+:[^\s/@]+@/gi, "$1[redacted]@");
|
|
14
|
+
};
|
|
15
|
+
const describeError = (value, depth = 0) => {
|
|
16
|
+
if (value instanceof Error)
|
|
17
|
+
return {
|
|
18
|
+
name: value.name, message: redact(value.message),
|
|
19
|
+
...(value.cause === undefined || depth >= 6 ? {} : { cause: describeError(value.cause, depth + 1) }),
|
|
20
|
+
...(value instanceof AggregateError && depth < 6 ? { errors: value.errors.map((error) => describeError(error, depth + 1)) } : {}),
|
|
21
|
+
};
|
|
22
|
+
return redact(String(value));
|
|
23
|
+
};
|
|
24
|
+
let pending = Promise.resolve();
|
|
25
|
+
let failed;
|
|
26
|
+
const emit = (event) => {
|
|
27
|
+
const task = event.task;
|
|
28
|
+
const record = {
|
|
29
|
+
timestamp: new Date().toISOString(), workerId: options.workerId, platform: options.platform,
|
|
30
|
+
kind: event.kind, message: redact(event.message),
|
|
31
|
+
...(task === undefined ? {} : {
|
|
32
|
+
serverOrigin: task.serverOrigin, projectId: task.projectId, taskId: task.taskId, claimId: task.claimId,
|
|
33
|
+
status: task.status, repositoryPath: task.repositoryPath, agent: task.configuration?.agent,
|
|
34
|
+
recovery: task.recovery, cleanup: task.cleanup,
|
|
35
|
+
}),
|
|
36
|
+
...(event.error === undefined ? {} : { error: describeError(event.error) }),
|
|
37
|
+
};
|
|
38
|
+
const serialized = JSON.stringify(record, (_key, value) => typeof value === "string" ? redact(value) : value);
|
|
39
|
+
if (failed === undefined)
|
|
40
|
+
pending = pending.then(() => appendFile(filename, `${serialized}\n`, { mode: 0o600 })).catch((cause) => { failed = cause; });
|
|
41
|
+
try {
|
|
42
|
+
options.log?.(`${record.timestamp} ${record.kind}${task === undefined ? "" : ` ${task.projectId}/${task.taskId}/${task.claimId} ${task.status}`} ${record.message}${event.error === undefined ? "" : ` ${JSON.stringify(describeError(event.error))}`}\n`);
|
|
43
|
+
}
|
|
44
|
+
catch (cause) {
|
|
45
|
+
if (failed === undefined)
|
|
46
|
+
failed = cause;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
return {
|
|
50
|
+
emit,
|
|
51
|
+
flush: async () => { await pending; if (failed !== undefined)
|
|
52
|
+
throw failed; },
|
|
53
|
+
filename,
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=diagnostics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../../../src/commands/worker/diagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,IAAI,MAAM,WAAW,CAAC;AAO7B,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,EAAE,OAG7C,EAAE,EAAE;IACH,MAAM,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,aAAa,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAC3E,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AAG,MAAM,OAAO,CAAC,CAAC,IAAI,MAAM,KAAK,SAAS;YAAE,MAAM,MAAM,CAAC,CAAC,CAAC;QAC5F,QAAQ;KACT,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Operation } from "../../api/operation.js";
|
|
2
|
+
import type { TaskPlatform, WorkerAgent } from "../../api/types.js";
|
|
3
|
+
import type { HerdrExecutionContext, HerdrOwnedWorkspace, HerdrTaskBinding, WorkerHerdrAdapter } from "./herdr.js";
|
|
4
|
+
import type { WorkerStore } from "./store.js";
|
|
5
|
+
import type { LocalTask } from "./types.js";
|
|
6
|
+
import type { createWorkerGitManager } from "./worktrees.js";
|
|
7
|
+
export type WorkerEvent = {
|
|
8
|
+
kind: string;
|
|
9
|
+
message: string;
|
|
10
|
+
task?: LocalTask;
|
|
11
|
+
error?: unknown;
|
|
12
|
+
};
|
|
13
|
+
export type WorkerGitManager = ReturnType<typeof createWorkerGitManager>;
|
|
14
|
+
export type ExecutionDependencies = {
|
|
15
|
+
store: WorkerStore;
|
|
16
|
+
git: WorkerGitManager;
|
|
17
|
+
herdr: WorkerHerdrAdapter;
|
|
18
|
+
platform: TaskPlatform;
|
|
19
|
+
buildPrompt: (task: LocalTask, platform: TaskPlatform) => string;
|
|
20
|
+
emit: (event: WorkerEvent) => void;
|
|
21
|
+
now: () => number;
|
|
22
|
+
};
|
|
23
|
+
export declare const isWorkerCancellation: (error: unknown, signal: AbortSignal) => boolean;
|
|
24
|
+
export declare const workerOperation: <T>(action: (operation: Operation) => Promise<T>, signal?: AbortSignal, totalMs?: number) => Promise<T>;
|
|
25
|
+
export declare const executionContext: (task: LocalTask, agent?: WorkerAgent) => HerdrExecutionContext;
|
|
26
|
+
export declare const taskBinding: (task: LocalTask) => HerdrTaskBinding | null;
|
|
27
|
+
export declare const ownedWorkspace: (task: LocalTask, resources: readonly HerdrOwnedWorkspace[]) => HerdrOwnedWorkspace | undefined;
|
|
28
|
+
export declare const actualTaskPane: (task: LocalTask, resources: readonly HerdrOwnedWorkspace[]) => {
|
|
29
|
+
binding: HerdrTaskBinding;
|
|
30
|
+
cwd: string | null;
|
|
31
|
+
kind: WorkerAgent | null;
|
|
32
|
+
status: string;
|
|
33
|
+
launchPending: boolean;
|
|
34
|
+
interactiveReady: boolean;
|
|
35
|
+
nativeSession: import("./herdr.js").HerdrNativeReference | null;
|
|
36
|
+
stateChangeSeq: number | null;
|
|
37
|
+
completionSeq: number | null;
|
|
38
|
+
} | undefined;
|
|
39
|
+
export declare const createExecutionDriver: (deps: ExecutionDependencies) => {
|
|
40
|
+
advance: (input: LocalTask, resources: readonly HerdrOwnedWorkspace[], signal?: AbortSignal) => Promise<LocalTask>;
|
|
41
|
+
};
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { createOperation, OperationError } from "../../api/operation.js";
|
|
3
|
+
import { HerdrAgentActionError } from "./herdr.js";
|
|
4
|
+
import { buildHerdrAgentArguments } from "./herdr/arguments.js";
|
|
5
|
+
import { herdrExecutionLabel } from "./herdr/agents.js";
|
|
6
|
+
export const isWorkerCancellation = (error, signal) => {
|
|
7
|
+
if (!signal.aborted)
|
|
8
|
+
return false;
|
|
9
|
+
if (error instanceof AggregateError && error.errors.some((failure) => !isWorkerCancellation(failure, signal)))
|
|
10
|
+
return false;
|
|
11
|
+
return error === signal.reason ||
|
|
12
|
+
(error instanceof OperationError && error.kind === "cancelled" && error.cause === signal.reason) ||
|
|
13
|
+
(error instanceof Error && error.cause !== undefined && isWorkerCancellation(error.cause, signal));
|
|
14
|
+
};
|
|
15
|
+
export const workerOperation = async (action, signal, totalMs = 120_000) => {
|
|
16
|
+
const operation = createOperation({ ...(signal === undefined ? {} : { signal }), limits: { totalMs } });
|
|
17
|
+
try {
|
|
18
|
+
return await action(operation);
|
|
19
|
+
}
|
|
20
|
+
finally {
|
|
21
|
+
operation.dispose();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
export const executionContext = (task, agent) => {
|
|
25
|
+
const selected = task.configuration?.agent ?? agent;
|
|
26
|
+
if (selected === undefined)
|
|
27
|
+
throw new Error("The original native agent kind is unavailable; the execution was retained.");
|
|
28
|
+
return { serverOrigin: task.serverOrigin, projectId: task.projectId, taskId: task.taskId, claimId: task.claimId, worktreeId: task.worktreeId,
|
|
29
|
+
cwd: task.resources.worktree?.worktreePath ?? path.join(task.repositoryPath, ".worktrees", "daynight", task.taskId), agent: selected };
|
|
30
|
+
};
|
|
31
|
+
export const taskBinding = (task) => {
|
|
32
|
+
const binding = task.resources.herdr;
|
|
33
|
+
const terminalId = task.nativeExecution?.terminalId;
|
|
34
|
+
return binding === null || terminalId === null || terminalId === undefined ? null : { ...binding, terminalId };
|
|
35
|
+
};
|
|
36
|
+
export const ownedWorkspace = (task, resources) => resources.find(({ owner }) => owner.serverOrigin === task.serverOrigin && owner.projectId === task.projectId && owner.taskId === task.taskId && owner.claimId === task.claimId && owner.worktreeId === task.worktreeId);
|
|
37
|
+
export const actualTaskPane = (task, resources) => {
|
|
38
|
+
const workspace = ownedWorkspace(task, resources);
|
|
39
|
+
if (workspace === undefined)
|
|
40
|
+
return undefined;
|
|
41
|
+
const binding = task.resources.herdr;
|
|
42
|
+
if (binding !== null && workspace.workspaceId === binding.workspaceId)
|
|
43
|
+
return workspace.panes.find((pane) => pane.binding.paneId === binding.paneId);
|
|
44
|
+
if (workspace.panes.length !== 1)
|
|
45
|
+
throw new Error("The original task workspace has ambiguous panes; it was retained.");
|
|
46
|
+
return workspace.panes[0];
|
|
47
|
+
};
|
|
48
|
+
const sameBinding = (left, right) => left.session === right.session && left.workspaceId === right.workspaceId && left.paneId === right.paneId && left.terminalId === right.terminalId;
|
|
49
|
+
const sameWorkspaceEvidence = (left, right) => sameBinding(left.binding, right.binding) && left.ownerLabel === right.ownerLabel && left.environment.XDG_CONFIG_HOME === right.environment.XDG_CONFIG_HOME && left.environment.XDG_STATE_HOME === right.environment.XDG_STATE_HOME;
|
|
50
|
+
const live = (observation) => observation.kind !== null || observation.launchPending || observation.interactiveReady;
|
|
51
|
+
const firstInputWaiting = "The original native launch is waiting before its first managed input; attach to its private session and retry after intervention.";
|
|
52
|
+
export const createExecutionDriver = (deps) => {
|
|
53
|
+
const refresh = (task) => {
|
|
54
|
+
const current = deps.store.getTask(task);
|
|
55
|
+
if (current === null)
|
|
56
|
+
throw new Error("The local execution record disappeared.");
|
|
57
|
+
return current;
|
|
58
|
+
};
|
|
59
|
+
const rememberStop = async (task, binding, signal) => {
|
|
60
|
+
if (task.nativeExecution?.stopObservation !== null && task.nativeExecution?.stopObservation !== undefined)
|
|
61
|
+
return;
|
|
62
|
+
try {
|
|
63
|
+
const observation = await workerOperation((operation) => deps.herdr.tasks.captureStop(executionContext(task), binding, operation), signal);
|
|
64
|
+
deps.store.recordStopObservation(task, observation, deps.now());
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
deps.emit({ kind: "stop-observation-unavailable", task, message: "Original native process identities are not yet available; cold recovery remains fenced.", error });
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
const rememberNative = (task, nativeSession) => nativeSession === null ? refresh(task) : deps.store.bindNativeSession(task, { source: "herdr", sessionId: nativeSession.sessionId }, deps.now());
|
|
71
|
+
const captureUnsentLaunch = async (task, binding, signal) => {
|
|
72
|
+
if (task.nativeExecution?.stopObservation !== null && task.nativeExecution?.stopObservation !== undefined)
|
|
73
|
+
return task;
|
|
74
|
+
const observed = await workerOperation((operation) => deps.herdr.tasks.captureStop(executionContext(task), binding, operation), signal);
|
|
75
|
+
const recorded = deps.store.recordStopObservation(task, observed, deps.now());
|
|
76
|
+
if (observed.nativeProcessIds === null)
|
|
77
|
+
throw new Error("The original native launch has no proven native process identity; its first input remains unsubmitted.");
|
|
78
|
+
return recorded;
|
|
79
|
+
};
|
|
80
|
+
const advanceUnsentInput = async (task, resources, signal) => {
|
|
81
|
+
const native = task.nativeExecution;
|
|
82
|
+
const binding = taskBinding(task);
|
|
83
|
+
const launch = native.launchEvidence;
|
|
84
|
+
const workspace = native.workspaceEvidence;
|
|
85
|
+
const actual = actualTaskPane(task, resources);
|
|
86
|
+
const context = executionContext(task);
|
|
87
|
+
const ownerLabel = herdrExecutionLabel(context);
|
|
88
|
+
if (task.resources.worktree === null || binding === null || actual === undefined || !sameBinding(binding, actual.binding))
|
|
89
|
+
throw new Error("The acknowledged native launch no longer has its original worktree and terminal binding; no first input was sent.");
|
|
90
|
+
if (launch === null || workspace === null || launch.referenceBaseline !== "empty" || launch.agent !== context.agent || launch.ownerLabel !== ownerLabel || workspace.ownerLabel !== ownerLabel || !sameBinding(launch.binding, binding) || !sameBinding(workspace.binding, binding) || !sameWorkspaceEvidence(workspace, launch.workspaceEvidence))
|
|
91
|
+
throw new Error("The acknowledged native launch receipt does not match the original execution; no first input was sent.");
|
|
92
|
+
const matchesArgv = (expected) => launch.argv.length === expected.length && launch.argv.every((argument, index) => argument === expected[index]);
|
|
93
|
+
let resumeSessionId;
|
|
94
|
+
if (!matchesArgv([context.agent, ...buildHerdrAgentArguments(task.configuration)])) {
|
|
95
|
+
const originalId = task.resources.nativeSession?.sessionId;
|
|
96
|
+
if (originalId === undefined || !matchesArgv([context.agent, ...buildHerdrAgentArguments(task.configuration, originalId)]))
|
|
97
|
+
throw new Error("The acknowledged native launch does not preserve its frozen invocation; no first input was sent.");
|
|
98
|
+
resumeSessionId = originalId;
|
|
99
|
+
}
|
|
100
|
+
await workerOperation((operation) => deps.git.verifyWorktree(task, operation), signal);
|
|
101
|
+
const before = await workerOperation((operation) => deps.herdr.tasks.observe(context, binding, operation), signal);
|
|
102
|
+
const original = native.stopObservation;
|
|
103
|
+
if (original === null || original.nativeProcessIds === null || !sameBinding(original.binding, binding) || original.ownerLabel !== ownerLabel || original.agent !== context.agent)
|
|
104
|
+
throw new Error("The original native launch process evidence is unavailable; no first input was sent.");
|
|
105
|
+
const current = await workerOperation((operation) => deps.herdr.tasks.captureStop(context, binding, operation), signal);
|
|
106
|
+
const currentNativeIds = current.nativeProcessIds;
|
|
107
|
+
if (!sameBinding(current.binding, binding) || current.ownerLabel !== ownerLabel || current.agent !== context.agent || current.shellPid !== original.shellPid || currentNativeIds === null || !original.nativeProcessIds.every((processId) => currentNativeIds.includes(processId)))
|
|
108
|
+
throw new Error("The original native launch is no longer executing in its original shell; no first input was sent.");
|
|
109
|
+
const expectedSession = task.resources.nativeSession?.sessionId;
|
|
110
|
+
if ((expectedSession !== undefined && before.nativeSession !== null && before.nativeSession.sessionId !== expectedSession) || (expectedSession !== undefined && current.nativeSessionId !== null && current.nativeSessionId !== expectedSession) || (original.nativeSessionId !== null && current.nativeSessionId !== null && original.nativeSessionId !== current.nativeSessionId))
|
|
111
|
+
throw new Error("The original native launch now reports a different conversation; no first input was sent.");
|
|
112
|
+
task = rememberNative(task, before.nativeSession);
|
|
113
|
+
if ((task.recovery.pauseReason !== null && !task.recovery.retryAuthorized) || before.status === "blocked") {
|
|
114
|
+
deps.emit({ kind: "waiting", task, message: "The original native launch is waiting before its first managed input; attach to its private session and retry the paused claim after intervention." });
|
|
115
|
+
return task;
|
|
116
|
+
}
|
|
117
|
+
if (task.recovery.retryAuthorized)
|
|
118
|
+
task = deps.store.beginRecovery(task, deps.now());
|
|
119
|
+
const prompt = deps.buildPrompt(task, deps.platform);
|
|
120
|
+
deps.store.markNativePromptSubmitting(task, deps.now());
|
|
121
|
+
try {
|
|
122
|
+
const outcome = await workerOperation((operation) => deps.herdr.tasks.start(context, binding, { configuration: task.configuration, prompt, initialPromptNotSubmitted: true, launchEvidence: launch, workspaceEvidence: workspace, ...(resumeSessionId === undefined ? {} : { resumeSessionId }) }, operation), signal);
|
|
123
|
+
deps.store.recordNativeStartOutcome(task, { ...(outcome.launchEvidence === null ? {} : { launchEvidence: outcome.launchEvidence }), promptSubmission: outcome.promptSubmission }, deps.now());
|
|
124
|
+
if (outcome.kind === "rebind-required")
|
|
125
|
+
throw new Error(`The original deferred startup input is fenced: ${outcome.reason}.`);
|
|
126
|
+
task = rememberNative(task, outcome.observation.nativeSession);
|
|
127
|
+
if (outcome.promptSubmission === "not-submitted")
|
|
128
|
+
task = deps.store.pauseTask(task, firstInputWaiting, deps.now());
|
|
129
|
+
deps.emit({ kind: outcome.kind === "waiting" || outcome.promptSubmission === "not-submitted" ? "waiting" : "started", task, message: outcome.promptSubmission === "submitted" ? "The first managed input was submitted to the original native launch without starting another agent." : firstInputWaiting });
|
|
130
|
+
return refresh(task);
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
if (error instanceof HerdrAgentActionError)
|
|
134
|
+
deps.store.recordNativeStartOutcome(task, { ...(error.launchEvidence === null ? {} : { launchEvidence: error.launchEvidence }), promptSubmission: error.promptSubmission === null ? "unknown" : error.promptSubmission }, deps.now());
|
|
135
|
+
throw error;
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
const prepareWorkspace = async (task, signal) => {
|
|
139
|
+
deps.store.markWorkspaceSubmitting(task, deps.now());
|
|
140
|
+
try {
|
|
141
|
+
return await workerOperation((operation) => deps.herdr.tasks.prepareWorkspace(executionContext(task), operation), signal);
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
if (error instanceof HerdrAgentActionError && error.action === "workspace.create" && error.submission !== "unknown")
|
|
145
|
+
deps.store.recordWorkspaceNotSubmitted(task, error.submission === "rejected" ? { definiteRejection: true } : { notSubmitted: true }, deps.now());
|
|
146
|
+
throw error;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
const rebind = async (task, actual, signal) => {
|
|
150
|
+
const original = taskBinding(task);
|
|
151
|
+
if (original === null)
|
|
152
|
+
throw new Error("The original Herdr terminal identity is unavailable; recovery was paused.");
|
|
153
|
+
const context = executionContext(task);
|
|
154
|
+
if (task.nativeExecution?.workspaceSubmission === "unknown" && actual === null)
|
|
155
|
+
throw new HerdrAgentActionError("The original replacement workspace request has an unknown outcome; absence does not authorize another creation.", "workspace.create", "unknown");
|
|
156
|
+
const evidence = task.nativeExecution?.stopObservation;
|
|
157
|
+
if (task.nativeExecution?.launchSubmission === "never-submitted") {
|
|
158
|
+
if (actual !== null)
|
|
159
|
+
await workerOperation((operation) => deps.herdr.tasks.confirmEmptyPane(context, actual, operation), signal);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
if (evidence === null || evidence === undefined)
|
|
163
|
+
throw new Error("The original persisted native stop observation is missing; recovery cannot infer that the agent stopped.");
|
|
164
|
+
if (actual === null)
|
|
165
|
+
await workerOperation((operation) => deps.herdr.tasks.confirmMissingWorkspaceStopped(context, original, evidence, operation), signal);
|
|
166
|
+
else if (sameBinding(original, actual))
|
|
167
|
+
await workerOperation((operation) => deps.herdr.tasks.confirmStopped(context, original, evidence, operation), signal);
|
|
168
|
+
else if (original.workspaceId !== actual.workspaceId || original.paneId !== actual.paneId)
|
|
169
|
+
await workerOperation((operation) => deps.herdr.tasks.confirmReplacedStop(context, original, actual, evidence, operation), signal);
|
|
170
|
+
else
|
|
171
|
+
await workerOperation((operation) => deps.herdr.tasks.confirmRestoredStop(context, original, actual, evidence, operation), signal);
|
|
172
|
+
}
|
|
173
|
+
if (task.nativeExecution?.workspaceSubmission === "unknown") {
|
|
174
|
+
// The exact observed replacement establishes the previous create outcome. Its
|
|
175
|
+
// environment receipt is unavailable, so a subsequent empty-pane rebind replaces it.
|
|
176
|
+
return deps.store.rebindHerdrExecution(task, original, actual, null, { originalAgentStopped: true, oldWorkspaceClosed: true }, deps.now());
|
|
177
|
+
}
|
|
178
|
+
await workerOperation((operation) => deps.herdr.tasks.closeWorkspace(context, actual === null ? original : actual, { agentStopped: true }, operation), signal);
|
|
179
|
+
const prepared = await prepareWorkspace(task, signal);
|
|
180
|
+
return deps.store.rebindHerdrExecution(task, original, prepared.binding, prepared.workspaceEvidence, { originalAgentStopped: true, oldWorkspaceClosed: true }, deps.now());
|
|
181
|
+
};
|
|
182
|
+
return {
|
|
183
|
+
advance: async (input, resources, signal) => {
|
|
184
|
+
let task = refresh(input);
|
|
185
|
+
if (task.cleanup !== null || task.control !== null)
|
|
186
|
+
throw new Error("Cleanup or source management prevents ordinary execution.");
|
|
187
|
+
if (task.configuration === null)
|
|
188
|
+
throw new Error("The original frozen execution configuration is missing; restore it before retrying.");
|
|
189
|
+
if (task.recovery.pauseReason !== null && !task.recovery.retryAuthorized && (task.resources.worktree === null || task.resources.herdr === null))
|
|
190
|
+
return task;
|
|
191
|
+
if (task.status !== "active")
|
|
192
|
+
throw new Error("Only an active execution may prepare resources.");
|
|
193
|
+
if (task.nativeExecution?.launchSubmission === "acknowledged" && task.nativeExecution.promptSubmission === "not-submitted")
|
|
194
|
+
return advanceUnsentInput(task, resources, signal);
|
|
195
|
+
const original = actualTaskPane(task, resources);
|
|
196
|
+
if (task.resources.nativeSession === null && task.nativeExecution?.launchSubmission !== "never-submitted") {
|
|
197
|
+
if (original === undefined || (!live(original) && original.nativeSession === null))
|
|
198
|
+
throw new Error("The original native session ID is missing; recover its exact history identity before preparing replacement resources.");
|
|
199
|
+
if (original.nativeSession !== null && task.resources.herdr !== null)
|
|
200
|
+
task = rememberNative(task, original.nativeSession);
|
|
201
|
+
}
|
|
202
|
+
if (task.resources.worktree === null) {
|
|
203
|
+
const binding = task.nativeExecution?.launchSubmission === "never-submitted"
|
|
204
|
+
? await workerOperation((operation) => deps.git.prepareWorktree(task, operation), signal, 180_000)
|
|
205
|
+
: await workerOperation((operation) => deps.git.findWorktree(task, operation), signal);
|
|
206
|
+
if (binding === null)
|
|
207
|
+
throw new Error("The original native launch provenance and owned worktree are unavailable; a fresh worktree cannot substitute for recovery.");
|
|
208
|
+
task = deps.store.bindWorktree(task, binding, deps.now());
|
|
209
|
+
}
|
|
210
|
+
else
|
|
211
|
+
await workerOperation((operation) => deps.git.verifyWorktree(task, operation), signal);
|
|
212
|
+
const actual = actualTaskPane(task, resources);
|
|
213
|
+
if (actual?.nativeSession !== undefined && actual.nativeSession !== null && task.resources.nativeSession !== null && actual.nativeSession.sessionId !== task.resources.nativeSession.sessionId)
|
|
214
|
+
throw new Error("The actual native history differs from the original execution; its resources were retained.");
|
|
215
|
+
let binding = taskBinding(task);
|
|
216
|
+
if (binding === null) {
|
|
217
|
+
if (task.resources.herdr !== null)
|
|
218
|
+
throw new Error("The original Herdr terminal identity is missing; an existing binding cannot be guessed.");
|
|
219
|
+
if (actual !== undefined) {
|
|
220
|
+
task = deps.store.bindHerdrExecution(task, actual.binding, null, deps.now());
|
|
221
|
+
binding = actual.binding;
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
if (task.nativeExecution?.workspaceSubmission === "unknown")
|
|
225
|
+
throw new HerdrAgentActionError("The original workspace creation has an unknown outcome; the absent snapshot does not authorize replay.", "workspace.create", "unknown");
|
|
226
|
+
const prepared = await prepareWorkspace(task, signal);
|
|
227
|
+
task = deps.store.bindHerdrExecution(task, prepared.binding, prepared.workspaceEvidence, deps.now());
|
|
228
|
+
binding = prepared.binding;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
else if ((actual !== undefined && !sameBinding(binding, actual.binding)) || ownedWorkspace(task, resources) === undefined) {
|
|
232
|
+
if (task.recovery.pauseReason !== null && !task.recovery.retryAuthorized)
|
|
233
|
+
return task;
|
|
234
|
+
if (task.nativeExecution?.workspaceSubmission === "unknown" && actual === undefined)
|
|
235
|
+
throw new HerdrAgentActionError("The original replacement workspace request is unresolved; the absent snapshot cannot authorize replay.", "workspace.create", "unknown");
|
|
236
|
+
if (task.nativeExecution?.launchSubmission !== "never-submitted" && task.nativeExecution?.workspaceSubmission !== "unknown") {
|
|
237
|
+
if (task.resources.nativeSession === null)
|
|
238
|
+
throw new Error("The original native history identity is unavailable; missing Herdr resources do not authorize a new conversation.");
|
|
239
|
+
task = deps.store.beginRecovery(task, deps.now());
|
|
240
|
+
}
|
|
241
|
+
task = await rebind(task, actual?.binding ?? null, signal);
|
|
242
|
+
binding = taskBinding(task);
|
|
243
|
+
}
|
|
244
|
+
const context = executionContext(task);
|
|
245
|
+
const before = await workerOperation((operation) => deps.herdr.tasks.observe(context, binding, operation), signal);
|
|
246
|
+
task = rememberNative(task, before.nativeSession);
|
|
247
|
+
if (live(before)) {
|
|
248
|
+
await rememberStop(task, binding, signal);
|
|
249
|
+
task = refresh(task);
|
|
250
|
+
deps.emit({ kind: before.status === "blocked" ? "waiting" : "reconnected", task: refresh(task), message: before.status === "blocked" ? "The original agent is waiting for input; attach to its private Herdr session." : "Observed the original live agent without replaying its startup input." });
|
|
251
|
+
return refresh(task);
|
|
252
|
+
}
|
|
253
|
+
if (task.recovery.pauseReason !== null && !task.recovery.retryAuthorized)
|
|
254
|
+
return task;
|
|
255
|
+
const native = task.nativeExecution;
|
|
256
|
+
if (native === null)
|
|
257
|
+
throw new Error("The original native launch provenance is missing; a new launch would be unsafe.");
|
|
258
|
+
if (native.launchSubmission !== "never-submitted") {
|
|
259
|
+
if (task.resources.nativeSession === null)
|
|
260
|
+
throw new Error("The original launch may have been submitted but its native history identity is unavailable; no second agent was started.");
|
|
261
|
+
deps.store.beginRecovery(task, deps.now());
|
|
262
|
+
task = refresh(task);
|
|
263
|
+
task = await rebind(task, binding, signal);
|
|
264
|
+
binding = taskBinding(task);
|
|
265
|
+
}
|
|
266
|
+
else if (native.workspaceEvidence === null) {
|
|
267
|
+
task = await rebind(task, binding, signal);
|
|
268
|
+
binding = taskBinding(task);
|
|
269
|
+
}
|
|
270
|
+
if (task.nativeExecution.workspaceEvidence === null) {
|
|
271
|
+
task = await rebind(task, binding, signal);
|
|
272
|
+
binding = taskBinding(task);
|
|
273
|
+
}
|
|
274
|
+
if (task.recovery.retryAuthorized)
|
|
275
|
+
task = deps.store.beginRecovery(task, deps.now());
|
|
276
|
+
const prompt = deps.buildPrompt(task, deps.platform);
|
|
277
|
+
deps.store.markNativeLaunchSubmitting(task, deps.now());
|
|
278
|
+
try {
|
|
279
|
+
const outcome = await workerOperation((operation) => deps.herdr.tasks.start(executionContext(task), binding, { configuration: task.configuration, prompt,
|
|
280
|
+
workspaceEvidence: task.nativeExecution.workspaceEvidence, ...(task.resources.nativeSession === null ? {} : { resumeSessionId: task.resources.nativeSession.sessionId }) }, operation), signal);
|
|
281
|
+
if (outcome.kind === "rebind-required")
|
|
282
|
+
throw new Error(`The native launch was fenced: ${outcome.reason}.`);
|
|
283
|
+
if (outcome.kind === "reconnected")
|
|
284
|
+
throw new Error("An unexpected live agent was observed during a fresh launch; its input was retained.");
|
|
285
|
+
deps.store.recordNativeStartOutcome(task, { ...(outcome.launchEvidence === null ? {} : { launchEvidence: outcome.launchEvidence }), promptSubmission: outcome.promptSubmission }, deps.now());
|
|
286
|
+
task = rememberNative(task, outcome.observation.nativeSession);
|
|
287
|
+
if (outcome.promptSubmission === "not-submitted") {
|
|
288
|
+
task = await captureUnsentLaunch(task, binding, signal);
|
|
289
|
+
task = deps.store.pauseTask(task, firstInputWaiting, deps.now());
|
|
290
|
+
}
|
|
291
|
+
else
|
|
292
|
+
await rememberStop(task, binding, signal);
|
|
293
|
+
deps.emit({ kind: outcome.kind === "waiting" ? "waiting" : "started", task: refresh(task), message: task.resources.nativeSession === null ? "Native launch acknowledged; waiting for the original agent." : "Managed startup input submitted to the original native conversation." });
|
|
294
|
+
return refresh(task);
|
|
295
|
+
}
|
|
296
|
+
catch (error) {
|
|
297
|
+
if (error instanceof HerdrAgentActionError) {
|
|
298
|
+
if (error.action === "agent.start" && error.submission !== "unknown" && error.launchEvidence === null && task.nativeExecution?.launchSubmission === "never-submitted") {
|
|
299
|
+
deps.store.recordNativeLaunchNotSubmitted(task, error.submission === "rejected" ? { definiteRejection: true } : { notSubmitted: true }, deps.now());
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
const recorded = deps.store.recordNativeStartOutcome(task, { ...(error.launchEvidence === null ? {} : { launchEvidence: error.launchEvidence }), promptSubmission: error.promptSubmission === null ? "unknown" : error.promptSubmission }, deps.now());
|
|
303
|
+
if (recorded.nativeExecution?.launchSubmission === "acknowledged" && recorded.nativeExecution.promptSubmission === "not-submitted") {
|
|
304
|
+
try {
|
|
305
|
+
await captureUnsentLaunch(recorded, binding, signal);
|
|
306
|
+
}
|
|
307
|
+
catch (observationError) {
|
|
308
|
+
throw new AggregateError([error, observationError], "The first input remains unsubmitted, but original native process observation failed.", { cause: error });
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
throw error;
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
};
|
|
317
|
+
};
|
|
318
|
+
//# sourceMappingURL=execution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution.js","sourceRoot":"","sources":["../../../src/commands/worker/execution.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAiBxD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAc,EAAE,MAAmB,EAAW,EAAE;IACnF,IAAI,CAAC,MAAM,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IAClC,IAAI,KAAK,YAAY,cAAc,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,oBAAoB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IAC5H,OAAO,KAAK,KAAK,MAAM,CAAC,MAAM;QAC5B,CAAC,KAAK,YAAY,cAAc,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,IAAI,KAAK,CAAC,KAAK,KAAK,MAAM,CAAC,MAAM,CAAC;QAChG,CAAC,KAAK,YAAY,KAAK,IAAI,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