@codetreker/daynight 0.21.9 → 0.21.11
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 +204 -27
- package/dist/api/client.d.ts +3 -1
- package/dist/api/client.js +12 -1
- package/dist/api/client.js.map +1 -1
- package/dist/api/parse.d.ts +2 -1
- package/dist/api/parse.js +8 -0
- package/dist/api/parse.js.map +1 -1
- package/dist/api/types.d.ts +7 -0
- package/dist/cli/commands.js +2 -0
- package/dist/cli/commands.js.map +1 -1
- 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/coordinator.d.ts +34 -0
- package/dist/commands/worker/coordinator.js +508 -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 +14 -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 +255 -0
- package/dist/commands/worker/execution.js.map +1 -0
- package/dist/commands/worker/herdr/agents.d.ts +185 -0
- package/dist/commands/worker/herdr/agents.js +654 -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/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 +10 -0
- package/dist/commands/worker/index.js +14 -0
- package/dist/commands/worker/index.js.map +1 -0
- 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 +18 -0
- package/dist/commands/worker/remote.js +134 -0
- package/dist/commands/worker/remote.js.map +1 -0
- package/dist/commands/worker/runtime.d.ts +8 -0
- package/dist/commands/worker/runtime.js +246 -0
- package/dist/commands/worker/runtime.js.map +1 -0
- package/dist/commands/worker/store.d.ts +55 -5
- package/dist/commands/worker/store.js +381 -26
- 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/package.json +2 -2
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { ApiError, createApiClient } from "../../api/client.js";
|
|
2
|
+
import { createOperation } from "../../api/operation.js";
|
|
3
|
+
import { canonicalId, ProtocolError } from "../../api/parse.js";
|
|
4
|
+
import { normalizeServerUrl } from "../../config/server.js";
|
|
5
|
+
import { validateServerToken, validateTokenTransport } from "../../config/server-token.js";
|
|
6
|
+
import { repositoryIdentity } from "../../repository/identity.js";
|
|
7
|
+
export const createWorkerRemote = (options) => {
|
|
8
|
+
const serverOrigin = normalizeServerUrl(options.serverUrl);
|
|
9
|
+
const serverToken = options.serverToken === undefined ? undefined : validateServerToken(options.serverToken);
|
|
10
|
+
if (serverToken !== undefined)
|
|
11
|
+
validateTokenTransport(serverOrigin);
|
|
12
|
+
let principal = null;
|
|
13
|
+
const query = async (signal, action, expectedUserId) => {
|
|
14
|
+
const operation = createOperation({ signal });
|
|
15
|
+
try {
|
|
16
|
+
return await action(createApiClient({ serverUrl: serverOrigin, ...(serverToken === undefined ? {} : { serverToken }), ...(expectedUserId === undefined ? {} : { expectedUserId }), operation }));
|
|
17
|
+
}
|
|
18
|
+
finally {
|
|
19
|
+
operation.dispose();
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const verifiedUserId = () => {
|
|
23
|
+
if (principal === null)
|
|
24
|
+
throw new Error("The worker must verify its authenticated user before accessing project ownership.");
|
|
25
|
+
return principal;
|
|
26
|
+
};
|
|
27
|
+
const request = (signal, action) => query(signal, action, verifiedUserId());
|
|
28
|
+
const pages = async function* (signal, read) {
|
|
29
|
+
const identities = new Set();
|
|
30
|
+
const cursors = new Set();
|
|
31
|
+
let cursor;
|
|
32
|
+
do {
|
|
33
|
+
signal.throwIfAborted();
|
|
34
|
+
const page = await request(signal, (api) => read(api, cursor));
|
|
35
|
+
for (const item of page.items) {
|
|
36
|
+
if (identities.has(item.id))
|
|
37
|
+
throw new ProtocolError("Duplicate resource identity across worker list pages.");
|
|
38
|
+
identities.add(item.id);
|
|
39
|
+
}
|
|
40
|
+
if (page.nextCursor !== null) {
|
|
41
|
+
if (cursors.has(page.nextCursor))
|
|
42
|
+
throw new ProtocolError("Repeated worker pagination cursor.");
|
|
43
|
+
cursors.add(page.nextCursor);
|
|
44
|
+
}
|
|
45
|
+
for (const item of page.items) {
|
|
46
|
+
signal.throwIfAborted();
|
|
47
|
+
yield item;
|
|
48
|
+
}
|
|
49
|
+
cursor = page.nextCursor === null ? undefined : page.nextCursor;
|
|
50
|
+
} while (cursor !== undefined);
|
|
51
|
+
signal.throwIfAborted();
|
|
52
|
+
};
|
|
53
|
+
const taskPages = (projectId, filters, signal) => pages(signal, (api, cursor) => api.listTaskPage(projectId, { ...filters, limit: 100, ...(cursor === undefined ? {} : { cursor }) }));
|
|
54
|
+
return {
|
|
55
|
+
serverOrigin,
|
|
56
|
+
currentUserId: async (signal) => {
|
|
57
|
+
signal.throwIfAborted();
|
|
58
|
+
if (principal !== null)
|
|
59
|
+
return principal;
|
|
60
|
+
const user = await query(signal, (api) => api.getCurrentUser());
|
|
61
|
+
if (principal !== null && principal !== user.id)
|
|
62
|
+
throw new ProtocolError("The worker's authenticated user changed during identity verification.");
|
|
63
|
+
principal = user.id;
|
|
64
|
+
return principal;
|
|
65
|
+
},
|
|
66
|
+
resolveProject: async (repository, signal) => {
|
|
67
|
+
const expected = repositoryIdentity(repository.repoUrl);
|
|
68
|
+
let project;
|
|
69
|
+
if (repository.projectId !== undefined) {
|
|
70
|
+
project = await request(signal, (api) => api.getProject(repository.projectId));
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
// Project discovery is finite; its own API operation cannot become the daemon's lifetime budget.
|
|
74
|
+
const projects = await request(signal, (api) => api.listProjects());
|
|
75
|
+
const matches = projects.filter((value) => repositoryIdentity(value.repoUrl) === expected);
|
|
76
|
+
if (matches.length === 0)
|
|
77
|
+
throw new Error("Project does not exist for the configured worker repository.");
|
|
78
|
+
if (matches.length !== 1)
|
|
79
|
+
throw new Error(`Multiple projects match the configured worker repository (${matches.map(({ id }) => id).join(", ")}); configure projectId.`);
|
|
80
|
+
project = await request(signal, (api) => api.getProject(matches[0].id));
|
|
81
|
+
}
|
|
82
|
+
if (repositoryIdentity(project.repoUrl) !== expected)
|
|
83
|
+
throw new Error(`Project ${project.id} does not match the configured worker repository.`);
|
|
84
|
+
signal.throwIfAborted();
|
|
85
|
+
return project;
|
|
86
|
+
},
|
|
87
|
+
ownInventory: async (projects, workerId, signal) => {
|
|
88
|
+
const owner = verifiedUserId();
|
|
89
|
+
const selected = new Map();
|
|
90
|
+
for (const project of projects) {
|
|
91
|
+
if (normalizeServerUrl(project.serverOrigin) !== serverOrigin)
|
|
92
|
+
throw new Error(`Worker project ${project.projectId} belongs to a different service origin.`);
|
|
93
|
+
const projectId = canonicalId(project.projectId);
|
|
94
|
+
if (projectId === null)
|
|
95
|
+
throw new Error("Worker project ID must be a hyphenated UUID.");
|
|
96
|
+
selected.set(projectId, project);
|
|
97
|
+
}
|
|
98
|
+
const result = [];
|
|
99
|
+
for (const projectId of selected.keys()) {
|
|
100
|
+
for await (const task of taskPages(projectId, { workerId }, signal)) {
|
|
101
|
+
if (task.properties.worker?.userId !== owner)
|
|
102
|
+
throw new ProtocolError("Worker inventory claim belongs to a different authenticated user.");
|
|
103
|
+
result.push(task);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
signal.throwIfAborted();
|
|
107
|
+
return result;
|
|
108
|
+
},
|
|
109
|
+
candidates: async function* (projectId, platform, signal) {
|
|
110
|
+
for await (const task of taskPages(projectId, { ready: true, allowAgents: true, compatiblePlatform: platform }, signal)) {
|
|
111
|
+
if (task.properties.worker?.state === "released")
|
|
112
|
+
continue;
|
|
113
|
+
if (task.properties.worker?.state === "active")
|
|
114
|
+
throw new ProtocolError("Worker candidate has an active claim.");
|
|
115
|
+
yield task;
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
claim: async (candidate, descriptor, signal) => {
|
|
119
|
+
const claimed = await request(signal, (api) => api.claimWorkerTask(candidate.projectId, candidate.id, { ...descriptor, version: candidate.version }));
|
|
120
|
+
if (claimed.properties.worker?.userId !== verifiedUserId())
|
|
121
|
+
throw new ApiError({ operation: "worker.claim", projectId: candidate.projectId, taskId: candidate.id }, "protocol", {
|
|
122
|
+
cause: new ProtocolError("The granted worker claim belongs to a different authenticated user."), outcomeUnconfirmed: true,
|
|
123
|
+
});
|
|
124
|
+
return claimed;
|
|
125
|
+
},
|
|
126
|
+
update: (task, input, signal) => {
|
|
127
|
+
const worker = task.properties.worker;
|
|
128
|
+
if (worker === null || worker.state !== "active" || worker.userId !== verifiedUserId())
|
|
129
|
+
throw new Error("Worker summary update requires the original active claim and authenticated user.");
|
|
130
|
+
return request(signal, (api) => api.updateWorkerClaim(task.projectId, task.id, { ...input, version: task.version, claimId: worker.claimId }));
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
//# sourceMappingURL=remote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote.js","sourceRoot":"","sources":["../../../src/commands/worker/remote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEhE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEhE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAC3F,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAalE,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAAsE,EAAgB,EAAE;IACzH,MAAM,YAAY,GAAG,kBAAkB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC3D,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,mBAAmB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAC7G,IAAI,WAAW,KAAK,SAAS;QAAE,sBAAsB,CAAC,YAAY,CAAC,CAAC;IACpE,IAAI,SAAS,GAAkB,IAAI,CAAC;IAEpC,MAAM,KAAK,GAAG,KAAK,EAAK,MAAmB,EAAE,MAAsC,EAAE,c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,QAAQ,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE;oBAC9K,KAAK,EAAE,IAAI,aAAa,CAAC,qEAAqE,CAAC,EAAE,kBAAkB,EAAE,IAAI;iBAC1H,CAAC,CAAC;YACH,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,MAAM,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;YAC9B,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;YACtC,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,CAAC,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,KAAK,cAAc,EAAE;gBAAE,MAAM,IAAI,KAAK,CAAC,kFAAkF,CAAC,CAAC;YAC5L,OAAO,OAAO,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QAChJ,CAAC;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TaskPlatform } from "../../api/types.js";
|
|
2
|
+
export declare const currentWorkerPlatform: (platform?: NodeJS.Platform) => TaskPlatform;
|
|
3
|
+
export declare const runWorker: (options: {
|
|
4
|
+
homeDirectory: string;
|
|
5
|
+
packageDirectory: string;
|
|
6
|
+
log?: (message: string) => void;
|
|
7
|
+
signal?: AbortSignal;
|
|
8
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { mkdir } from "node:fs/promises";
|
|
3
|
+
import { hostname } from "node:os";
|
|
4
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
5
|
+
import { createOperation } from "../../api/operation.js";
|
|
6
|
+
import { loadServerConfiguration } from "../../config/server.js";
|
|
7
|
+
import { readWorkerConfiguration } from "./config.js";
|
|
8
|
+
import { createWorkerCoordinator } from "./coordinator.js";
|
|
9
|
+
import { createWorkerDiagnostics } from "./diagnostics.js";
|
|
10
|
+
import { isWorkerCancellation } from "./execution.js";
|
|
11
|
+
import { createWorkerHerdr } from "./herdr.js";
|
|
12
|
+
import { ensureWorkerIdentity } from "./identity.js";
|
|
13
|
+
import { acquireWorkerInstanceLock } from "./instance-lock.js";
|
|
14
|
+
import { resolveWorkerPaths } from "./paths.js";
|
|
15
|
+
import { createWorkerPromptBuilder } from "./prompts.js";
|
|
16
|
+
import { createWorkerRemote } from "./remote.js";
|
|
17
|
+
import { openWorkerStore } from "./store.js";
|
|
18
|
+
import { createWorkerGitManager } from "./worktrees.js";
|
|
19
|
+
export const currentWorkerPlatform = (platform = process.platform) => {
|
|
20
|
+
switch (platform) {
|
|
21
|
+
case "linux": return "linux";
|
|
22
|
+
case "darwin": return "macos";
|
|
23
|
+
case "win32": return "windows";
|
|
24
|
+
default: throw new Error(`Worker execution is unsupported on platform ${platform}.`);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const machineDescription = (platform) => {
|
|
28
|
+
const name = hostname();
|
|
29
|
+
// This is a reported host label, independent of worker identity, not machine authentication.
|
|
30
|
+
const bytes = createHash("sha1").update(`daynight:machine:${platform}:${name}`).digest().subarray(0, 16);
|
|
31
|
+
bytes[6] = (bytes[6] & 0x0f) | 0x50;
|
|
32
|
+
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
|
33
|
+
const value = bytes.toString("hex");
|
|
34
|
+
return { id: `${value.slice(0, 8)}-${value.slice(8, 12)}-${value.slice(12, 16)}-${value.slice(16, 20)}-${value.slice(20)}`, name };
|
|
35
|
+
};
|
|
36
|
+
export const runWorker = async (options) => {
|
|
37
|
+
const platform = currentWorkerPlatform();
|
|
38
|
+
const paths = resolveWorkerPaths(options.homeDirectory);
|
|
39
|
+
const cancellation = new AbortController();
|
|
40
|
+
const cancel = () => { cancellation.abort(options.signal?.reason); };
|
|
41
|
+
const signals = process.platform === "win32" ? ["SIGINT", "SIGTERM", "SIGBREAK"] : ["SIGINT", "SIGTERM"];
|
|
42
|
+
const interrupt = () => { cancellation.abort(new Error("Worker shutdown requested.")); };
|
|
43
|
+
options.signal?.addEventListener("abort", cancel, { once: true });
|
|
44
|
+
if (options.signal?.aborted)
|
|
45
|
+
cancel();
|
|
46
|
+
for (const signal of signals)
|
|
47
|
+
process.on(signal, interrupt);
|
|
48
|
+
let lock;
|
|
49
|
+
let store;
|
|
50
|
+
let git;
|
|
51
|
+
let coordinator;
|
|
52
|
+
let herdr;
|
|
53
|
+
let diagnostics;
|
|
54
|
+
let cleanupLoop;
|
|
55
|
+
let cleanupFailure;
|
|
56
|
+
const cleanupJobs = new Map();
|
|
57
|
+
const failures = [];
|
|
58
|
+
try {
|
|
59
|
+
cancellation.signal.throwIfAborted();
|
|
60
|
+
const configuration = await readWorkerConfiguration(paths, cancellation.signal);
|
|
61
|
+
const { serverUrl, serverToken } = await loadServerConfiguration(paths, cancellation.signal);
|
|
62
|
+
if (serverToken === undefined)
|
|
63
|
+
throw new Error("You are not logged in. Run daynight login to authenticate.");
|
|
64
|
+
lock = await acquireWorkerInstanceLock(paths);
|
|
65
|
+
cancellation.signal.throwIfAborted();
|
|
66
|
+
const workerId = await ensureWorkerIdentity(paths, cancellation.signal);
|
|
67
|
+
for (const directory of [paths.temporaryDirectory, paths.logsDirectory])
|
|
68
|
+
await mkdir(directory, { recursive: true, mode: 0o700 });
|
|
69
|
+
store = openWorkerStore(paths.databaseFile);
|
|
70
|
+
diagnostics = await createWorkerDiagnostics({ paths, workerId, platform, ...(options.log === undefined ? {} : { log: options.log }), secrets: [serverToken] });
|
|
71
|
+
const emit = diagnostics.emit;
|
|
72
|
+
const buildPrompt = await createWorkerPromptBuilder(options.packageDirectory);
|
|
73
|
+
const remote = createWorkerRemote({ serverUrl, serverToken });
|
|
74
|
+
git = createWorkerGitManager({ temporaryDirectory: paths.temporaryDirectory });
|
|
75
|
+
herdr = createWorkerHerdr({ paths, homeDirectory: options.homeDirectory });
|
|
76
|
+
const repositories = [];
|
|
77
|
+
coordinator = createWorkerCoordinator({
|
|
78
|
+
store, git, herdr, remote, serverOrigin: serverUrl, workerId, platform,
|
|
79
|
+
machine: machineDescription(platform), repositories, maxConcurrent: configuration.maxConcurrent,
|
|
80
|
+
buildPrompt, emit, signal: cancellation.signal,
|
|
81
|
+
});
|
|
82
|
+
const cleanupCoordinator = coordinator;
|
|
83
|
+
const cleanupDiagnostics = diagnostics;
|
|
84
|
+
const cleanupStore = store;
|
|
85
|
+
cleanupLoop = (async () => {
|
|
86
|
+
while (!cancellation.signal.aborted) {
|
|
87
|
+
for (const task of cleanupStore.listUnfinishedTasks()) {
|
|
88
|
+
if (task.workerId !== workerId || (task.cleanup === null && task.control === null))
|
|
89
|
+
continue;
|
|
90
|
+
const identity = { serverOrigin: task.serverOrigin, projectId: task.projectId, taskId: task.taskId, claimId: task.claimId };
|
|
91
|
+
const key = JSON.stringify(identity);
|
|
92
|
+
if (cleanupJobs.has(key))
|
|
93
|
+
continue;
|
|
94
|
+
const job = (async () => {
|
|
95
|
+
while (!cancellation.signal.aborted) {
|
|
96
|
+
try {
|
|
97
|
+
await cleanupCoordinator.advanceCommittedCleanups(identity);
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
if (isWorkerCancellation(error, cancellation.signal))
|
|
101
|
+
return;
|
|
102
|
+
emit({ kind: "cleanup-error", message: "Committed cleanup could not advance; its original deadline and responsibility are retained.", error });
|
|
103
|
+
}
|
|
104
|
+
await cleanupDiagnostics.flush();
|
|
105
|
+
const current = cleanupStore.getTask(identity);
|
|
106
|
+
if (current === null)
|
|
107
|
+
throw new Error("The committed cleanup record disappeared.");
|
|
108
|
+
if (current.status === "done" || (current.cleanup === null && current.control === null))
|
|
109
|
+
return;
|
|
110
|
+
const state = current.cleanup;
|
|
111
|
+
if (state !== null && state.result !== null && state.agentStopped && state.workspaceClosed && (state.kind === "shutdown" || state.worktreeDeleted))
|
|
112
|
+
return;
|
|
113
|
+
const remaining = state === null ? 0 : state.deadline - Date.now();
|
|
114
|
+
try {
|
|
115
|
+
await delay(remaining > 0 ? Math.max(1, Math.min(1_000, remaining)) : 1_000, undefined, { signal: cancellation.signal });
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
if (!isWorkerCancellation(error, cancellation.signal))
|
|
119
|
+
throw error;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
})().catch((error) => { if (cleanupFailure === undefined)
|
|
123
|
+
cleanupFailure = error; cancellation.abort(error); });
|
|
124
|
+
cleanupJobs.set(key, job);
|
|
125
|
+
void job.then(() => { if (cleanupJobs.get(key) === job)
|
|
126
|
+
cleanupJobs.delete(key); });
|
|
127
|
+
}
|
|
128
|
+
try {
|
|
129
|
+
await delay(1_000, undefined, { signal: cancellation.signal });
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
if (!isWorkerCancellation(error, cancellation.signal))
|
|
133
|
+
throw error;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
})().catch((error) => { if (cleanupFailure === undefined)
|
|
137
|
+
cleanupFailure = error; cancellation.abort(error); });
|
|
138
|
+
emit({ kind: "started", message: `Foreground worker ${workerId} on ${platform}; maxConcurrent=${configuration.maxConcurrent}; pollIntervalMs=${configuration.pollIntervalMs}; logs=${diagnostics.filename}.` });
|
|
139
|
+
await remote.currentUserId(cancellation.signal);
|
|
140
|
+
for (const repository of configuration.repositories) {
|
|
141
|
+
cancellation.signal.throwIfAborted();
|
|
142
|
+
const project = await remote.resolveProject({ repoUrl: repository.remote, ...(repository.projectId === undefined ? {} : { projectId: repository.projectId }) }, cancellation.signal);
|
|
143
|
+
const binding = { serverOrigin: serverUrl, projectId: project.id, repoUrl: repository.remote, localPath: repository.path };
|
|
144
|
+
const operation = createOperation({ signal: cancellation.signal });
|
|
145
|
+
try {
|
|
146
|
+
await git.prepareRepository(binding, operation);
|
|
147
|
+
}
|
|
148
|
+
finally {
|
|
149
|
+
operation.dispose();
|
|
150
|
+
}
|
|
151
|
+
const registered = store.registerProject(binding);
|
|
152
|
+
const frozen = { agent: repository.agent, model: repository.model, args: repository.args, recoveryLimit: repository.recoveryLimit };
|
|
153
|
+
repositories.push({ project: registered, configuration: frozen });
|
|
154
|
+
}
|
|
155
|
+
let attachmentShown = false;
|
|
156
|
+
while (!cancellation.signal.aborted) {
|
|
157
|
+
try {
|
|
158
|
+
await coordinator.tick();
|
|
159
|
+
if (!attachmentShown) {
|
|
160
|
+
emit({ kind: "attach", message: `Original ready private Herdr session: ${JSON.stringify(herdr.attachment)}. Apply its environment and unsetEnvironment only to the attach process.` });
|
|
161
|
+
attachmentShown = true;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
if (isWorkerCancellation(error, cancellation.signal))
|
|
166
|
+
break;
|
|
167
|
+
if (cancellation.signal.aborted)
|
|
168
|
+
throw error;
|
|
169
|
+
emit({ kind: "reconciliation-error", message: "The reconciliation round failed; retained execution resources and unresolved writes require observation.", error });
|
|
170
|
+
}
|
|
171
|
+
await diagnostics.flush();
|
|
172
|
+
if (cancellation.signal.aborted)
|
|
173
|
+
break;
|
|
174
|
+
try {
|
|
175
|
+
await delay(configuration.pollIntervalMs, undefined, { signal: cancellation.signal });
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
if (!isWorkerCancellation(error, cancellation.signal))
|
|
179
|
+
throw error;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
if (!isWorkerCancellation(error, cancellation.signal))
|
|
185
|
+
failures.push(error);
|
|
186
|
+
}
|
|
187
|
+
finally {
|
|
188
|
+
if (!cancellation.signal.aborted)
|
|
189
|
+
cancellation.abort(new Error("Worker runtime is closing."));
|
|
190
|
+
await cleanupLoop;
|
|
191
|
+
await Promise.all(cleanupJobs.values());
|
|
192
|
+
if (cleanupFailure !== undefined && !failures.includes(cleanupFailure))
|
|
193
|
+
failures.push(cleanupFailure);
|
|
194
|
+
if (coordinator !== undefined && herdr !== undefined) {
|
|
195
|
+
try {
|
|
196
|
+
diagnostics?.emit({ kind: "shutdown", message: "Stopping acquisitions and ordinary input; cleaning original executions with their persisted deadlines." });
|
|
197
|
+
const stopped = await coordinator.shutdown();
|
|
198
|
+
if (!stopped)
|
|
199
|
+
throw new Error("Original task agents are not all confirmed stopped; their private Herdr instance was retained.");
|
|
200
|
+
const operation = createOperation({ limits: { totalMs: 30_000 } });
|
|
201
|
+
try {
|
|
202
|
+
const proof = await herdr.stopInstance(operation);
|
|
203
|
+
diagnostics?.emit({ kind: "stopped", message: `Private Herdr stop confirmed: ${JSON.stringify(proof)}. Unfinished claims, worktrees and native history are retained.` });
|
|
204
|
+
}
|
|
205
|
+
finally {
|
|
206
|
+
operation.dispose();
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
catch (error) {
|
|
210
|
+
failures.push(error);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
try {
|
|
214
|
+
await git?.dispose();
|
|
215
|
+
}
|
|
216
|
+
catch (error) {
|
|
217
|
+
failures.push(error);
|
|
218
|
+
}
|
|
219
|
+
try {
|
|
220
|
+
store?.close();
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
failures.push(error);
|
|
224
|
+
}
|
|
225
|
+
try {
|
|
226
|
+
await lock?.release();
|
|
227
|
+
}
|
|
228
|
+
catch (error) {
|
|
229
|
+
failures.push(error);
|
|
230
|
+
}
|
|
231
|
+
try {
|
|
232
|
+
await diagnostics?.flush();
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
failures.push(error);
|
|
236
|
+
}
|
|
237
|
+
for (const signal of signals)
|
|
238
|
+
process.off(signal, interrupt);
|
|
239
|
+
options.signal?.removeEventListener("abort", cancel);
|
|
240
|
+
}
|
|
241
|
+
if (failures.length === 1)
|
|
242
|
+
throw failures[0];
|
|
243
|
+
if (failures.length > 1)
|
|
244
|
+
throw new AggregateError(failures, "Worker execution or shutdown failed.");
|
|
245
|
+
};
|
|
246
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../../src/commands/worker/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAA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OAAO,CAAC,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACvD,CAAC;IACD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC7C,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;QAAE,MAAM,IAAI,cAAc,CAAC,QAAQ,EAAE,sCAAsC,CAAC,CAAC;AACtG,CAAC,CAAC"}
|
|
@@ -1,24 +1,68 @@
|
|
|
1
1
|
import type { WorkerHerdr } from "../../api/types.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { HerdrLaunchEvidence, HerdrStopObservation, HerdrTaskBinding, HerdrWorkspaceEvidence } from "./herdr/agents.js";
|
|
3
|
+
import type { ClaimAttempt, ClaimIdentity, CleanupState, ControlIntent, ExecutionSummary, FrozenExecutionConfiguration, LocalTask, NativeExecutionState, NativeSessionReference, PendingClaim, PendingConfiguration, ProjectIdentity, WorkerProject, WorkerProjectRecord, WorktreeBinding } from "./types.js";
|
|
4
|
+
export declare const isUnstartedPending: (task: LocalTask) => boolean;
|
|
3
5
|
export declare const openWorkerStore: (databaseFile: string, options?: {
|
|
4
6
|
busyTimeoutMs?: number;
|
|
5
7
|
}) => {
|
|
6
8
|
close: () => void;
|
|
7
|
-
getProject: (identity: ProjectIdentity) =>
|
|
8
|
-
listProjects: () =>
|
|
9
|
-
registerProject: (project: WorkerProject) =>
|
|
9
|
+
getProject: (identity: ProjectIdentity) => WorkerProjectRecord | null;
|
|
10
|
+
listProjects: () => WorkerProjectRecord[];
|
|
11
|
+
registerProject: (project: WorkerProject) => WorkerProjectRecord;
|
|
12
|
+
getClaimAttempt: (identity: ProjectIdentity) => ClaimAttempt | null;
|
|
13
|
+
listClaimAttempts: () => (ProjectIdentity & {
|
|
14
|
+
attempt: ClaimAttempt;
|
|
15
|
+
})[];
|
|
16
|
+
beginClaimAttempt: (identity: ProjectIdentity, input: ClaimAttempt) => ClaimAttempt;
|
|
17
|
+
rejectClaimAttempt: (identity: ProjectIdentity, expectedClaimId: string, proof: {
|
|
18
|
+
definiteRejection: true;
|
|
19
|
+
} | {
|
|
20
|
+
notSubmitted: true;
|
|
21
|
+
}) => void;
|
|
10
22
|
getTask: (identity: ClaimIdentity) => LocalTask | null;
|
|
11
23
|
listTasks: () => LocalTask[];
|
|
12
24
|
listUnfinishedTasks: () => LocalTask[];
|
|
13
|
-
|
|
25
|
+
recordObservedUnattemptedWorkspace: (owner: PendingClaim, now: number) => LocalTask | null;
|
|
26
|
+
registerPending: (claim: PendingClaim, input: PendingConfiguration, now: number, verifiedUserId?: string | null) => LocalTask;
|
|
27
|
+
bindUserScope: (identity: ClaimIdentity, userId: string, now: number) => LocalTask;
|
|
14
28
|
restoreOriginalConfiguration: (identity: ClaimIdentity, configuration: FrozenExecutionConfiguration, now: number) => LocalTask;
|
|
15
29
|
activateTask: (identity: ClaimIdentity, now: number) => LocalTask;
|
|
30
|
+
activatePausedRecovery: (identity: ClaimIdentity, reason: string, now: number) => LocalTask;
|
|
16
31
|
bindWorktree: (identity: ClaimIdentity, binding: WorktreeBinding, now: number) => LocalTask;
|
|
17
32
|
bindHerdr: (identity: ClaimIdentity, binding: WorkerHerdr, now: number) => LocalTask;
|
|
33
|
+
bindHerdrExecution: (identity: ClaimIdentity, binding: HerdrTaskBinding, workspaceEvidence: HerdrWorkspaceEvidence | null, now: number) => LocalTask;
|
|
34
|
+
markWorkspaceSubmitting: (identity: ClaimIdentity, now: number) => LocalTask;
|
|
35
|
+
recordWorkspaceNotSubmitted: (identity: ClaimIdentity, proof: {
|
|
36
|
+
notSubmitted: true;
|
|
37
|
+
} | {
|
|
38
|
+
definiteRejection: true;
|
|
39
|
+
}, now: number) => LocalTask;
|
|
40
|
+
markNativeLaunchSubmitting: (identity: ClaimIdentity, now: number) => LocalTask;
|
|
41
|
+
recordNativeLaunchNotSubmitted: (identity: ClaimIdentity, proof: {
|
|
42
|
+
notSubmitted: true;
|
|
43
|
+
} | {
|
|
44
|
+
definiteRejection: true;
|
|
45
|
+
}, now: number) => LocalTask;
|
|
46
|
+
markNativePromptSubmitting: (identity: ClaimIdentity, now: number) => LocalTask;
|
|
47
|
+
recordNativeStartOutcome: (identity: ClaimIdentity, input: {
|
|
48
|
+
launchEvidence?: HerdrLaunchEvidence;
|
|
49
|
+
promptSubmission: NativeExecutionState["promptSubmission"];
|
|
50
|
+
}, now: number) => LocalTask;
|
|
51
|
+
recordStopObservation: (identity: ClaimIdentity, observation: HerdrStopObservation, now: number) => LocalTask;
|
|
52
|
+
markExecutionSummarySubmitting: (identity: ClaimIdentity, input: Omit<ExecutionSummary, "submission">, now: number) => LocalTask;
|
|
53
|
+
recordExecutionSummaryOutcome: (identity: ClaimIdentity, expectedVersion: string, submission: "confirmed" | "rejected", now: number) => LocalTask;
|
|
54
|
+
recordExecutionSummaryNotSubmitted: (identity: ClaimIdentity, expectedVersion: string, proof: {
|
|
55
|
+
notSubmitted: true;
|
|
56
|
+
}, now: number) => LocalTask;
|
|
57
|
+
reconcileExecutionSummary: (identity: ClaimIdentity, input: Omit<ExecutionSummary, "submission">, now: number) => LocalTask;
|
|
18
58
|
rebindHerdr: (identity: ClaimIdentity, expectedPrevious: WorkerHerdr, next: WorkerHerdr, proof: {
|
|
19
59
|
originalAgentStopped: true;
|
|
20
60
|
oldWorkspaceClosed: true;
|
|
21
61
|
}, now: number) => LocalTask;
|
|
62
|
+
rebindHerdrExecution: (identity: ClaimIdentity, expectedPrevious: HerdrTaskBinding, next: HerdrTaskBinding, workspaceEvidence: HerdrWorkspaceEvidence | null, proof: {
|
|
63
|
+
originalAgentStopped: true;
|
|
64
|
+
oldWorkspaceClosed: true;
|
|
65
|
+
}, now: number) => LocalTask;
|
|
22
66
|
bindNativeSession: (identity: ClaimIdentity, reference: NativeSessionReference, now: number) => LocalTask;
|
|
23
67
|
pauseTask: (identity: ClaimIdentity, reason: string, now: number) => LocalTask;
|
|
24
68
|
clearPause: (identity: ClaimIdentity, now: number) => LocalTask;
|
|
@@ -30,6 +74,7 @@ export declare const openWorkerStore: (databaseFile: string, options?: {
|
|
|
30
74
|
}, now: number) => LocalTask;
|
|
31
75
|
markCleanupInputSubmitting: (identity: ClaimIdentity, now: number) => LocalTask;
|
|
32
76
|
recordCleanupInputOutcome: (identity: ClaimIdentity, input: "submitted" | "rejected" | "unavailable", now: number) => LocalTask;
|
|
77
|
+
recordCleanupInputEvidence: (identity: ClaimIdentity, baseline: NonNullable<CleanupState["baseline"]>, now: number) => LocalTask;
|
|
33
78
|
recordCleanupResult: (identity: ClaimIdentity, result: NonNullable<CleanupState["result"]>, error: string | null, now: number) => LocalTask;
|
|
34
79
|
recordCleanupError: (identity: ClaimIdentity, error: string, now: number) => LocalTask;
|
|
35
80
|
confirmAgentStopped: (identity: ClaimIdentity, proof: {
|
|
@@ -51,5 +96,10 @@ export declare const openWorkerStore: (databaseFile: string, options?: {
|
|
|
51
96
|
}, now: number) => LocalTask;
|
|
52
97
|
rejectControlSubmission: (identity: ClaimIdentity, error: string, now: number) => LocalTask;
|
|
53
98
|
completeTask: (identity: ClaimIdentity, now: number) => LocalTask;
|
|
99
|
+
completeUnstartedPending: (identity: ClaimIdentity, proof: {
|
|
100
|
+
completeOwnClaimInventory: true;
|
|
101
|
+
claimAbsent: true;
|
|
102
|
+
authenticatedUserId: string;
|
|
103
|
+
}, now: number) => LocalTask;
|
|
54
104
|
};
|
|
55
105
|
export type WorkerStore = ReturnType<typeof openWorkerStore>;
|