@codetreker/daynight 0.22.1 → 0.24.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.
Files changed (84) hide show
  1. package/README.md +314 -334
  2. package/config.example.yml +8 -4
  3. package/dist/api/client.d.ts +2 -2
  4. package/dist/api/client.js +10 -7
  5. package/dist/api/client.js.map +1 -1
  6. package/dist/api/types.d.ts +1 -8
  7. package/dist/cli/prompts.d.ts +1 -0
  8. package/dist/commands/auth/credentials.js +1 -1
  9. package/dist/commands/auth/credentials.js.map +1 -1
  10. package/dist/commands/review/config.js +0 -9
  11. package/dist/commands/review/config.js.map +1 -1
  12. package/dist/commands/review/configuration-guide.js +3 -2
  13. package/dist/commands/review/configuration-guide.js.map +1 -1
  14. package/dist/commands/review/repositories.js +11 -4
  15. package/dist/commands/review/repositories.js.map +1 -1
  16. package/dist/commands/skill/skills/using-daynight/references/execute-task-in-managed.md +6 -5
  17. package/dist/commands/skill/skills/using-daynight/references/handbook.md +1 -1
  18. package/dist/commands/skill/skills/using-daynight/references/handoff.md +1 -1
  19. package/dist/commands/worker/cleanup.d.ts +8 -2
  20. package/dist/commands/worker/cleanup.js +44 -160
  21. package/dist/commands/worker/cleanup.js.map +1 -1
  22. package/dist/commands/worker/config.d.ts +3 -3
  23. package/dist/commands/worker/config.js +0 -6
  24. package/dist/commands/worker/config.js.map +1 -1
  25. package/dist/commands/worker/control.d.ts +11 -18
  26. package/dist/commands/worker/control.js +75 -132
  27. package/dist/commands/worker/control.js.map +1 -1
  28. package/dist/commands/worker/coordinator.d.ts +10 -8
  29. package/dist/commands/worker/coordinator.js +324 -472
  30. package/dist/commands/worker/coordinator.js.map +1 -1
  31. package/dist/commands/worker/definition.js +9 -17
  32. package/dist/commands/worker/definition.js.map +1 -1
  33. package/dist/commands/worker/diagnostics.js +2 -3
  34. package/dist/commands/worker/diagnostics.js.map +1 -1
  35. package/dist/commands/worker/execution.d.ts +35 -10
  36. package/dist/commands/worker/execution.js +109 -281
  37. package/dist/commands/worker/execution.js.map +1 -1
  38. package/dist/commands/worker/herdr/agents.d.ts +12 -91
  39. package/dist/commands/worker/herdr/agents.js +111 -358
  40. package/dist/commands/worker/herdr/agents.js.map +1 -1
  41. package/dist/commands/worker/herdr/preflight.d.ts +21 -9
  42. package/dist/commands/worker/herdr/preflight.js +118 -124
  43. package/dist/commands/worker/herdr/preflight.js.map +1 -1
  44. package/dist/commands/worker/herdr.d.ts +7 -63
  45. package/dist/commands/worker/herdr.js.map +1 -1
  46. package/dist/commands/worker/identity.js +2 -2
  47. package/dist/commands/worker/identity.js.map +1 -1
  48. package/dist/commands/worker/index.d.ts +1 -0
  49. package/dist/commands/worker/index.js +6 -13
  50. package/dist/commands/worker/index.js.map +1 -1
  51. package/dist/commands/worker/prompts.d.ts +10 -3
  52. package/dist/commands/worker/prompts.js +21 -32
  53. package/dist/commands/worker/prompts.js.map +1 -1
  54. package/dist/commands/worker/remote.d.ts +2 -3
  55. package/dist/commands/worker/remote.js +1 -6
  56. package/dist/commands/worker/remote.js.map +1 -1
  57. package/dist/commands/worker/repositories.d.ts +20 -3
  58. package/dist/commands/worker/repositories.js +100 -21
  59. package/dist/commands/worker/repositories.js.map +1 -1
  60. package/dist/commands/worker/runtime.js +112 -217
  61. package/dist/commands/worker/runtime.js.map +1 -1
  62. package/dist/commands/worker/setup-environment.d.ts +31 -0
  63. package/dist/commands/worker/setup-environment.js +146 -0
  64. package/dist/commands/worker/setup-environment.js.map +1 -0
  65. package/dist/commands/worker/setup.d.ts +11 -0
  66. package/dist/commands/worker/setup.js +113 -0
  67. package/dist/commands/worker/setup.js.map +1 -0
  68. package/dist/commands/worker/store.d.ts +12 -114
  69. package/dist/commands/worker/store.js +92 -817
  70. package/dist/commands/worker/store.js.map +1 -1
  71. package/dist/commands/worker/types.d.ts +10 -114
  72. package/dist/commands/worker/worktrees.d.ts +9 -9
  73. package/dist/commands/worker/worktrees.js +77 -37
  74. package/dist/commands/worker/worktrees.js.map +1 -1
  75. package/dist/config/document.d.ts +0 -1
  76. package/dist/config/document.js +1 -14
  77. package/dist/config/document.js.map +1 -1
  78. package/dist/config/files.d.ts +7 -1
  79. package/dist/config/files.js +4 -1
  80. package/dist/config/files.js.map +1 -1
  81. package/dist/config/ownership.d.ts +12 -0
  82. package/dist/config/ownership.js +39 -0
  83. package/dist/config/ownership.js.map +1 -0
  84. package/package.json +2 -2
@@ -1,151 +1,94 @@
1
1
  import { randomUUID } from "node:crypto";
2
2
  import { ApiError } from "../../api/client.js";
3
- const cleaned = (task) => task.cleanup?.kind === "terminal" && task.cleanup.result !== null && task.cleanup.agentStopped && task.cleanup.workspaceClosed && task.cleanup.worktreeDeleted;
4
- const message = (error) => error instanceof Error ? error.message : String(error);
5
- const sourceActive = (task, claimId) => task.properties.worker?.claimId === claimId && task.properties.worker.state === "active";
6
- const applied = (task, intent) => intent.kind === "release"
7
- ? task.properties.worker?.claimId === intent.sourceClaimId && task.properties.worker.state === "released"
8
- : task.properties.worker?.claimId === intent.targetClaimId && task.properties.worker.state === "active" && task.properties.worker.userId === intent.target.userId && task.properties.worker.workerId === intent.target.workerId && task.properties.worker.worktreeId === intent.target.worktreeId && task.properties.worker.agent === intent.target.agent;
9
- export const createWorkerControlDriver = (options) => ({
10
- advance: async (input, signal, mode = { submit: true }) => {
11
- let task = options.store.getTask(input);
12
- if (task === null)
13
- throw new Error("The source control execution disappeared.");
14
- if (task.status === "done" || task.control === null || !cleaned(task))
15
- return task;
16
- if (task.serverOrigin !== options.serverOrigin)
17
- return task;
18
- if (task.userId === null)
19
- throw new Error("Source control requires the original authenticated claim owner.");
20
- if (task.control.submission === "confirmed")
21
- return task.control.outcome === "applied"
22
- ? options.store.completeAppliedControl(task, task.control.intent, BigInt(task.control.resultVersion), options.now())
23
- : options.store.completeEndedControl(task, task.control.intent, { observedClaimId: null, observedState: null }, options.now());
24
- const intent = task.control.intent;
25
- const observed = await options.remote.readTask(task.projectId, task.taskId, signal);
26
- await options.remote.authorizeControl(task.projectId, task.userId, undefined, signal);
27
- const latest = options.store.getTask(task);
28
- if (latest === null)
29
- throw new Error("The source control execution disappeared.");
30
- if (latest.status === "done")
31
- return latest;
32
- if (latest.control === null || JSON.stringify(latest.control.intent) !== JSON.stringify(intent))
33
- throw new Error("The concrete source management decision changed during remote observation.");
34
- task = latest;
35
- if (!sourceActive(observed, task.claimId)) {
36
- if (applied(observed, intent) && task.control.submission === "unknown")
37
- return options.store.completeAppliedControl(task, intent, observed.version, options.now());
38
- return options.store.completeEndedControl(task, intent, { observedClaimId: observed.properties.worker?.claimId ?? null, observedState: observed.properties.worker?.state ?? null }, options.now());
39
- }
40
- if (!mode.submit || task.control.submission !== "not-submitted")
41
- return task;
42
- try {
43
- task = options.store.markControlSubmitting(task, BigInt(intent.version), options.now());
44
- }
45
- catch (error) {
46
- const winner = options.store.getTask(task);
47
- if (winner?.control !== null && winner?.control !== undefined && JSON.stringify(winner.control.intent) === JSON.stringify(intent) && (winner.control.submission === "unknown" || winner.control.submission === "confirmed"))
48
- return winner;
49
- throw error;
50
- }
51
- try {
52
- const result = intent.kind === "release"
53
- ? await options.remote.release(task.projectId, task.taskId, { claimId: task.claimId, version: BigInt(intent.version), stoppedConfirmed: true }, signal)
54
- : await options.remote.transfer(task.projectId, task.taskId, { claimId: task.claimId, version: BigInt(intent.version), newClaimId: intent.targetClaimId, target: { userId: intent.target.userId, workerId: intent.target.workerId, machine: intent.target.machine, platform: intent.target.platform, agent: intent.target.agent }, worktreeId: intent.target.worktreeId, stoppedConfirmed: true }, signal);
55
- return options.store.completeAppliedControl(task, intent, result.version, options.now());
56
- }
57
- catch (error) {
58
- const current = options.store.getTask(task);
59
- if (current?.status === "done" && current.control?.submission === "confirmed")
60
- return current;
61
- if (error instanceof ApiError && !error.outcomeUnconfirmed)
62
- options.store.rejectControlSubmission(task, message(error), options.now());
63
- throw error;
64
- }
65
- },
66
- });
3
+ const matchesTask = (task, identity) => task.projectId === identity.projectId && task.id === identity.taskId;
4
+ const matchesGrant = (task, identity, descriptor, userId) => {
5
+ const worker = task.properties.worker;
6
+ return matchesTask(task, identity) && task.status === "in_progress" && worker !== null && worker.state === "active"
7
+ && worker.claimId === descriptor.claimId && worker.workerId === descriptor.workerId && worker.worktreeId === descriptor.worktreeId
8
+ && worker.userId === userId && worker.agent === descriptor.agent && worker.platform === descriptor.platform
9
+ && worker.machine.id === descriptor.machine.id && worker.machine.name === descriptor.machine.name;
10
+ };
67
11
  export const submitWorkerControl = async (options) => {
68
- const now = options.now ?? Date.now;
69
- const request = options.request;
70
- const local = options.store.listTasks().filter((task) => task.taskId === request.taskId && task.claimId === request.claimId && (request.projectId === undefined || task.projectId === request.projectId));
71
- if (local.some((task) => task.serverOrigin !== options.serverOrigin))
72
- throw new Error("The original claim belongs to a different configured service origin; restore that service before managing it.");
73
- const matches = local.filter((task) => task.serverOrigin === options.serverOrigin);
12
+ const { store, remote, request, signal, coordinator } = options;
13
+ signal.throwIfAborted();
14
+ if (remote.serverOrigin !== options.serverOrigin)
15
+ throw new Error("Worker management must use the configured service origin.");
16
+ const matches = store.listTasks().filter((task) => task.taskId === request.taskId && task.claimId === request.claimId && (request.projectId === undefined || task.projectId === request.projectId));
74
17
  if (matches.length > 1)
75
18
  throw new Error("The source claim is ambiguous; supply --project.");
76
- let source = matches[0];
77
- if (source !== undefined && source.workerId !== options.workerId)
78
- throw new Error("The source execution belongs to another worker identity.");
79
- const projectId = source?.projectId ?? request.projectId ?? (options.repositories.length === 1 ? options.repositories[0].project.projectId : undefined);
19
+ const source = matches[0];
20
+ let projectId = source?.projectId ?? request.projectId;
21
+ if (projectId === undefined && options.repositories.length === 1)
22
+ projectId = options.repositories[0].project.projectId;
80
23
  if (projectId === undefined)
81
24
  throw new Error("This claim has no local execution; supply --project to resume it explicitly.");
82
- const principal = await options.remote.currentUserId(options.signal);
83
- const observed = await options.remote.readTask(projectId, request.taskId, options.signal);
25
+ const identity = { projectId, taskId: request.taskId, claimId: request.claimId };
26
+ const principal = await remote.currentUserId(signal);
27
+ const observed = await remote.readTask(projectId, request.taskId, signal);
28
+ if (!matchesTask(observed, identity))
29
+ throw new Error("The observed task does not match the requested project and task.");
84
30
  const worker = observed.properties.worker;
85
- if (request.kind === "resume") {
86
- const project = options.store.getProject({ serverOrigin: options.serverOrigin, projectId });
87
- const repository = options.repositories.find((entry) => entry.project.serverOrigin === options.serverOrigin && entry.project.projectId === projectId);
88
- if (project === null || repository === undefined)
89
- throw new Error("Resume requires a configured repository and its current agent settings.");
90
- const pending = options.store.getClaimAttempt(project);
91
- if (pending !== null) {
92
- if (pending.taskId !== request.taskId || pending.expectedVersion !== request.version.toString() || pending.userId !== principal)
93
- throw new Error("An unresolved original claim request cannot be replaced.");
94
- if (worker?.state === "active" && worker.claimId === pending.claimId && worker.userId === pending.userId && worker.workerId === pending.workerId && worker.worktreeId === pending.worktreeId && worker.agent === pending.configuration.agent) {
95
- const task = options.store.registerPending({ ...project, taskId: observed.id, claimId: pending.claimId, workerId: pending.workerId, worktreeId: pending.worktreeId }, { kind: "new", configuration: pending.configuration }, now(), principal);
96
- return { task, message: `Resume grant ${pending.claimId} recovered and committed as pending.` };
97
- }
98
- throw new Error(`Resume claim ${pending.claimId} has an unknown outcome; its original request will not be replayed.`);
99
- }
100
- if (observed.version !== request.version)
31
+ const exactVersion = () => {
32
+ if (request.kind !== "retry" && observed.version !== request.version)
101
33
  throw new Error("The explicit task version no longer matches; make a new decision with the observed version.");
102
- if (worker?.state !== "released" || worker.claimId !== request.claimId)
103
- throw new Error("Resume requires the exact released previous claim.");
104
- await options.remote.authorizeControl(projectId, worker.userId, undefined, options.signal);
105
- const descriptor = { claimId: randomUUID(), workerId: options.workerId, worktreeId: randomUUID(), machine: options.machine, platform: options.platform, agent: repository.configuration.agent };
106
- options.store.beginClaimAttempt(project, { taskId: request.taskId, claimId: descriptor.claimId, worktreeId: descriptor.worktreeId, workerId: options.workerId, userId: principal, expectedVersion: request.version.toString(), configuration: repository.configuration });
107
- let grant;
34
+ };
35
+ const confirmMutation = async (submit, applied, description) => {
36
+ signal.throwIfAborted();
108
37
  try {
109
- grant = await options.remote.resume(projectId, request.taskId, { ...descriptor, version: request.version, previousClaimId: request.claimId }, options.signal);
38
+ const result = await submit();
39
+ if (!applied(result))
40
+ throw new Error(`The ${description} response does not confirm the requested result.`);
41
+ return result;
110
42
  }
111
43
  catch (error) {
112
44
  if (error instanceof ApiError && !error.outcomeUnconfirmed)
113
- options.store.rejectClaimAttempt(project, descriptor.claimId, error.confirmedRefusal ? { definiteRejection: true } : { notSubmitted: true });
114
- throw error;
45
+ throw error;
46
+ let actual;
47
+ try {
48
+ actual = await remote.readTask(projectId, request.taskId, signal);
49
+ }
50
+ catch (readError) {
51
+ throw new AggregateError([error, readError], `The ${description} result is unknown. Reconcile the remote claim before restarting worker run; the request was not replayed.`);
52
+ }
53
+ if (applied(actual))
54
+ return actual;
55
+ throw new Error(`The ${description} result is unknown. Reconcile the remote claim before restarting worker run; the request was not replayed.`, { cause: error });
115
56
  }
116
- if (grant.properties.worker?.userId !== principal)
117
- throw new Error("The resume grant belongs to a different authenticated user; the original request remains unresolved.");
118
- const task = options.store.registerPending({ ...project, taskId: request.taskId, claimId: descriptor.claimId, workerId: descriptor.workerId, worktreeId: descriptor.worktreeId }, { kind: "new", configuration: repository.configuration }, now(), principal);
119
- return { task, message: `New resume claim ${task.claimId} committed as pending; worker run will prepare its new execution.` };
120
- }
121
- if (source === undefined || source.userId === null)
122
- throw new Error("Management requires the original local execution and its authenticated owner.");
123
- await options.remote.authorizeControl(projectId, source.userId, undefined, options.signal);
124
- const existing = source.control;
125
- if (request.kind !== "retry" && existing !== null && existing.submission !== "rejected") {
126
- const intent = existing.intent;
127
- const sameDecision = intent.kind === request.kind && intent.version === request.version.toString() && (request.kind !== "transfer" || (intent.kind === "transfer" && intent.target.userId === request.target.userId && intent.target.workerId === request.target.workerId && intent.target.agent === request.target.agent && intent.target.platform === request.target.platform && JSON.stringify(intent.target.machine) === JSON.stringify(request.target.machine)));
128
- if (!sameDecision)
129
- throw new Error("A different source management decision is already persisted; an unknown write cannot be replaced.");
130
- return { task: source, message: `Existing ${intent.kind} intent retained for claim ${source.claimId}; submission=${existing.submission}.` };
57
+ };
58
+ if (request.kind === "resume") {
59
+ exactVersion();
60
+ if (worker === null || worker.state !== "released" || worker.claimId !== request.claimId)
61
+ throw new Error("Resume requires the exact released previous claim.");
62
+ const project = store.getProject(identity);
63
+ const repository = options.repositories.find((entry) => entry.project.projectId === projectId);
64
+ if (project === null || repository === undefined)
65
+ throw new Error("Resume requires a configured repository and its current agent settings.");
66
+ await remote.authorizeControl(projectId, worker.userId, signal);
67
+ const descriptor = { claimId: randomUUID(), workerId: options.workerId, worktreeId: randomUUID(), machine: options.machine, platform: options.platform, agent: repository.configuration.agent };
68
+ options.emit({ kind: "management-request", message: `Resume ${projectId}/${request.taskId}: previousClaimId=${request.claimId}, claimId=${descriptor.claimId}, worktreeId=${descriptor.worktreeId}.` });
69
+ const granted = await confirmMutation(() => remote.resume(projectId, request.taskId, { ...descriptor, version: request.version, previousClaimId: request.claimId }, signal), (task) => matchesGrant(task, identity, descriptor, principal), "resume");
70
+ const task = store.registerPending({ projectId, taskId: granted.id, claimId: descriptor.claimId, agent: descriptor.agent });
71
+ return { task, message: `New resume claim ${task.claimId} committed as pending; worker run will start its new execution.` };
131
72
  }
132
- if (source.status === "done")
133
- throw new Error("The original local execution is already complete.");
134
- if (!sourceActive(observed, request.claimId) || worker.userId !== source.userId || worker.workerId !== source.workerId || worker.worktreeId !== source.worktreeId)
135
- throw new Error("The source claim is no longer the exact active execution; reconcile its existing management outcome first.");
73
+ if (source === undefined || source.status === "done")
74
+ throw new Error("Management requires the original unfinished local execution.");
75
+ if (worker === null || observed.status !== "in_progress" || worker.state !== "active" || worker.claimId !== request.claimId || worker.workerId !== options.workerId || worker.agent !== source.agent)
76
+ throw new Error("The source claim is no longer the exact active execution on this worker.");
77
+ await remote.authorizeControl(projectId, worker.userId, signal);
136
78
  if (request.kind === "retry") {
137
- if (principal !== source.userId)
138
- throw new Error("Retry must retain the original authenticated execution owner.");
139
- const task = options.store.authorizeRecoveryRetryAtCount(source, source.recovery.count, now());
140
- return { task, message: `One additional recovery attempt authorized for claim ${task.claimId}; persisted count=${task.recovery.count}.` };
79
+ if (principal !== worker.userId)
80
+ throw new Error("Retry requires the original authenticated execution owner.");
81
+ if (source.status !== "active")
82
+ throw new Error("Only an active original claim may be retried; pending work is started by worker run.");
83
+ signal.throwIfAborted();
84
+ await coordinator.advanceRetry(identity);
85
+ return { task: store.getTask(identity), message: `One recovery attempt completed for claim ${request.claimId}; worker run will connect its actual resources.` };
141
86
  }
142
- if (observed.version !== request.version)
143
- throw new Error("The explicit task version no longer matches; make a new decision with the observed version.");
144
- if (request.kind === "transfer")
145
- await options.remote.authorizeControl(projectId, source.userId, request.target.userId, options.signal);
146
- const intent = request.kind === "release" ? { kind: "release", sourceClaimId: source.claimId, version: request.version.toString() }
147
- : { kind: "transfer", sourceClaimId: source.claimId, version: request.version.toString(), targetClaimId: randomUUID(), target: { ...request.target, worktreeId: randomUUID() } };
148
- source = existing?.submission === "rejected" ? options.store.replaceRejectedControlIntent(source, intent, { observedVersion: observed.version }, now()) : options.store.recordControlIntent(source, intent, now());
149
- return { task: source, message: `${intent.kind} intent persisted for claim ${source.claimId}; source cleanup must finish before the remote write.` };
87
+ exactVersion();
88
+ signal.throwIfAborted();
89
+ const owner = await coordinator.cleanupSource(identity, { deleteWorktree: false });
90
+ await confirmMutation(() => remote.release(projectId, request.taskId, { claimId: request.claimId, version: request.version, stoppedConfirmed: true }, signal), (task) => matchesTask(task, identity) && task.status === "todo" && task.properties.worker?.claimId === request.claimId && task.properties.worker.state === "released", "release");
91
+ await coordinator.completeSource(owner);
92
+ return { task: store.getTask(identity), message: `${request.kind} completed for claim ${request.claimId}; its local resources were removed.` };
150
93
  };
151
94
  //# sourceMappingURL=control.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"control.js","sourceRoot":"","sources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,EAAE,QAAQ,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,KAAK,UAAU,EAAE,SAAS,CACjL,CAAC;IACF,MAAM,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IACxC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,wBAAwB,OAAO,CAAC,OAAO,qCAAqC,EAAE,CAAC;AACjJ,CAAC,CAAC"}
@@ -1,12 +1,13 @@
1
1
  import type { TaskPlatform, WorkerMachine } from "../../api/types.js";
2
2
  import type { WorkerEvent, WorkerGitManager } from "./execution.js";
3
3
  import type { WorkerHerdrAdapter } from "./herdr.js";
4
+ import type { ManagedAssignment } from "./prompts.js";
4
5
  import type { WorkerRemote } from "./remote.js";
5
6
  import type { WorkerStore } from "./store.js";
6
- import type { ClaimIdentity, CleanupState, FrozenExecutionConfiguration, LocalTask, WorkerProject } from "./types.js";
7
+ import type { ClaimIdentity, ExecutionConfiguration, ResourceOwner, WorkerProject } from "./types.js";
7
8
  export type WorkerRepositoryAssignment = {
8
9
  project: WorkerProject;
9
- configuration: FrozenExecutionConfiguration;
10
+ configuration: ExecutionConfiguration;
10
11
  };
11
12
  export type WorkerCoordinatorOptions = {
12
13
  store: WorkerStore;
@@ -18,18 +19,19 @@ export type WorkerCoordinatorOptions = {
18
19
  platform: TaskPlatform;
19
20
  machine: WorkerMachine;
20
21
  repositories: readonly WorkerRepositoryAssignment[];
22
+ globalConfiguration: ExecutionConfiguration;
21
23
  maxConcurrent: number;
22
- buildPrompt: (task: LocalTask, platform: TaskPlatform) => string;
24
+ buildPrompt: (assignment: ManagedAssignment, platform: TaskPlatform) => string;
23
25
  emit: (event: WorkerEvent) => void;
24
26
  signal?: AbortSignal;
25
27
  now?: () => number;
26
28
  };
27
29
  export declare const createWorkerCoordinator: (options: WorkerCoordinatorOptions) => {
28
- serializeTask: <T>(identity: Pick<ClaimIdentity, "serverOrigin" | "projectId" | "taskId">, action: () => Promise<T>) => Promise<T>;
29
- advanceCommittedCleanups: (identity?: ClaimIdentity) => Promise<void>;
30
- cleanupTask: (identity: ClaimIdentity, kind?: CleanupState["kind"]) => Promise<LocalTask>;
31
- advanceRetry: (identity: ClaimIdentity) => Promise<LocalTask>;
32
30
  tick: () => Promise<void>;
31
+ advanceRetry: (identity: ClaimIdentity) => Promise<void>;
32
+ cleanupSource: (identity: ClaimIdentity, settings?: {
33
+ deleteWorktree?: boolean;
34
+ }) => Promise<ResourceOwner>;
35
+ completeSource: (owner: ResourceOwner) => Promise<void>;
33
36
  shutdown: () => Promise<boolean>;
34
37
  };
35
- export type WorkerCoordinator = ReturnType<typeof createWorkerCoordinator>;