@nyte-ai/core 0.0.18 → 0.0.21
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 +1 -1
- package/THIRD-PARTY-NOTICES.md +66 -0
- package/dist/chunks/{compose-yk3y0jap.js → compose-0m65m83c.js} +7 -7
- package/dist/chunks/{compose-r12cnkpc.js → compose-12jnd50a.js} +11 -11
- package/dist/chunks/{compose-q1n2dgrs.js → compose-1knxqqm1.js} +4 -4
- package/dist/chunks/{compose-xtkavyrw.js → compose-1r0wr5dc.js} +17 -9
- package/dist/chunks/{compose-9tqm6g18.js → compose-2rha31fc.js} +4 -4
- package/dist/chunks/{compose-0bpspysf.js → compose-4ppmas7g.js} +5 -5
- package/dist/chunks/compose-5rg7askh.js +52 -0
- package/dist/chunks/{compose-mryw0674.js → compose-5z835ej2.js} +6 -1
- package/dist/chunks/{compose-7k6nsmtq.js → compose-6gt28900.js} +11 -14
- package/dist/chunks/{compose-2eg8w67t.js → compose-6r5ymwyr.js} +15 -4
- package/dist/chunks/{compose-xd0kdp3t.js → compose-753gc057.js} +8 -8
- package/dist/chunks/{compose-q1ts0v6k.js → compose-767bb340.js} +1 -1
- package/dist/chunks/{compose-rpq9n0nz.js → compose-8mkfr84d.js} +89 -32
- package/dist/chunks/{compose-5w5bbakh.js → compose-8pp3vtv0.js} +5 -5
- package/dist/chunks/{compose-gaps3heh.js → compose-9hy3p236.js} +9 -9
- package/dist/chunks/{compose-pgeemk2b.js → compose-a7k9h27z.js} +6 -5
- package/dist/chunks/{compose-dc2ns6gd.js → compose-a8ddt55n.js} +10 -10
- package/dist/chunks/{compose-7b8ajk7a.js → compose-ad80nkkn.js} +8 -8
- package/dist/chunks/{compose-064y3n82.js → compose-ae5t6v5b.js} +5 -5
- package/dist/chunks/{compose-amr0k1m1.js → compose-b2bf1jvy.js} +122 -41
- package/dist/chunks/{compose-xpfr4wt3.js → compose-bbhk8vnr.js} +7 -4
- package/dist/chunks/compose-bd8c5n7k.js +32 -0
- package/dist/chunks/{compose-rehp8epe.js → compose-byse0eqj.js} +7 -7
- package/dist/chunks/{compose-ef936rsa.js → compose-bz70g01d.js} +27 -11
- package/dist/chunks/compose-c4238qkb.js +105 -0
- package/dist/chunks/{compose-q1b0tppc.js → compose-c9wxgbjp.js} +4 -4
- package/dist/chunks/{compose-h272znxk.js → compose-cdj05t7x.js} +7 -7
- package/dist/chunks/{compose-kb22bkpt.js → compose-cqpjcx2t.js} +12 -1
- package/dist/chunks/{compose-dbx6ftbm.js → compose-csh5vv2t.js} +42 -4
- package/dist/chunks/{compose-eqr5qwp1.js → compose-d1m94kzq.js} +62 -22
- package/dist/chunks/{compose-drdej9yt.js → compose-d95fwwvw.js} +4 -4
- package/dist/chunks/{compose-jc22rsz4.js → compose-dbsn3bsy.js} +2 -2
- package/dist/chunks/{compose-s2aew2c9.js → compose-e2fyz3xc.js} +5 -5
- package/dist/chunks/{compose-gg8b9b21.js → compose-e9f6nrwp.js} +23 -18
- package/dist/chunks/{compose-52afaf3v.js → compose-fnncnk81.js} +7 -7
- package/dist/chunks/{compose-bjx8s01m.js → compose-fqsqjbrf.js} +1 -1
- package/dist/chunks/{compose-1gd9vkye.js → compose-gj2ypr7q.js} +3 -3
- package/dist/chunks/compose-gvm49f4b.js +155 -0
- package/dist/chunks/{compose-1jz2j92f.js → compose-gxjc6vz9.js} +30 -2
- package/dist/chunks/{compose-cq1zx4gp.js → compose-h14pmqv3.js} +1 -1
- package/dist/chunks/{compose-d2s80zg2.js → compose-hfrjm4a1.js} +5 -5
- package/dist/chunks/{compose-kmzr06mw.js → compose-hfsn6pnt.js} +8 -5
- package/dist/chunks/{compose-jjchxce6.js → compose-j42p9wfs.js} +1 -1
- package/dist/chunks/{compose-4b1zf3p0.js → compose-jd4bsnqh.js} +63 -47
- package/dist/chunks/{compose-2g3enfv5.js → compose-jeemzja1.js} +4 -4
- package/dist/chunks/{compose-y478gv6x.js → compose-jmmyw9hd.js} +4 -4
- package/dist/chunks/{compose-5tkyrzr0.js → compose-jwy1gba9.js} +4 -4
- package/dist/chunks/{compose-k35b75k9.js → compose-kwkna3cg.js} +2 -4
- package/dist/chunks/{compose-t53j8yxv.js → compose-m01wspwf.js} +1 -1
- package/dist/chunks/{compose-n93897b0.js → compose-m91ffwss.js} +1 -1
- package/dist/chunks/{compose-madtxnp1.js → compose-matk94se.js} +7 -7
- package/dist/chunks/{compose-aa73dbe8.js → compose-mcz93154.js} +117 -58
- package/dist/chunks/{compose-r7dx7rpz.js → compose-mdwr0er9.js} +72 -15
- package/dist/chunks/{compose-j12n448k.js → compose-nj4nj5n9.js} +36 -3
- package/dist/chunks/{compose-yn2et568.js → compose-nkxwrphm.js} +141 -15
- package/dist/chunks/{compose-k8aghhv2.js → compose-pkprmn5b.js} +16 -16
- package/dist/chunks/{compose-1z7q169s.js → compose-q2zxbg41.js} +69 -41
- package/dist/chunks/{compose-b5xz0dj7.js → compose-qwbe95qs.js} +2 -2
- package/dist/chunks/{compose-vmhv4e00.js → compose-qxfq6dn9.js} +13 -12
- package/dist/chunks/{compose-wgphshsn.js → compose-r8tz1xfj.js} +8 -8
- package/dist/chunks/{compose-ffk8dnbh.js → compose-smsafpqe.js} +3 -3
- package/dist/chunks/{compose-djq2bt61.js → compose-sprfv38c.js} +6 -6
- package/dist/chunks/{compose-cdy4q5mv.js → compose-t9fcqtby.js} +17 -16
- package/dist/chunks/{compose-p3q14yt1.js → compose-tppkp915.js} +5 -5
- package/dist/chunks/{compose-dckpgtks.js → compose-ts08bth2.js} +3 -3
- package/dist/chunks/{compose-n10w4nkk.js → compose-vn7b7fdj.js} +12 -3
- package/dist/chunks/{compose-9m19b27b.js → compose-w6zb11k1.js} +7 -7
- package/dist/chunks/{compose-j3tkz0tb.js → compose-wvzzf8n2.js} +6 -6
- package/dist/chunks/{compose-6vf6dkk2.js → compose-xhtgytrh.js} +2 -2
- package/dist/chunks/{compose-4tb2vn84.js → compose-y6xgbg2h.js} +1 -1
- package/dist/chunks/compose-yfcb6w2h.js +58 -0
- package/dist/chunks/{compose-0rx7ygxq.js → compose-zaanjpb7.js} +1 -1
- package/dist/chunks/{compose-7pc3p5ex.js → compose-zjj072km.js} +8 -8
- package/dist/src/agent/compaction.js +41 -39
- package/dist/src/agent/images.d.ts +7 -0
- package/dist/src/agent/images.js +8 -0
- package/dist/src/agent/request.js +30 -30
- package/dist/src/agent/tool-runner.d.ts +3 -7
- package/dist/src/agent/tool-runner.js +34 -30
- package/dist/src/agent/transcript.d.ts +0 -1
- package/dist/src/agent/transcript.js +37 -35
- package/dist/src/agent/turn.js +46 -43
- package/dist/src/api/connection.js +60 -56
- package/dist/src/api/head.js +42 -41
- package/dist/src/api/part.js +22 -22
- package/dist/src/api/server.js +48 -44
- package/dist/src/api/session.js +48 -47
- package/dist/src/builtins/delegation.js +2 -2
- package/dist/src/builtins/environment.js +1 -2
- package/dist/src/compose.d.ts +6 -7
- package/dist/src/compose.js +72 -67
- package/dist/src/contract/fold.d.ts +1 -3
- package/dist/src/contract/host.d.ts +30 -1
- package/dist/src/contract/host.js +4 -2
- package/dist/src/contract/kernel.d.ts +6 -35
- package/dist/src/contract/parts.d.ts +4 -0
- package/dist/src/contract/parts.js +1 -1
- package/dist/src/contract/records.d.ts +69 -3
- package/dist/src/contract/records.js +5 -1
- package/dist/src/contract/session.d.ts +2 -1
- package/dist/src/contract/tools.d.ts +10 -1
- package/dist/src/contract/workspace.d.ts +7 -3
- package/dist/src/drive/execution.js +46 -42
- package/dist/src/drive/interruptions.d.ts +7 -0
- package/dist/src/drive/interruptions.js +17 -0
- package/dist/src/engine/admission.js +24 -24
- package/dist/src/engine/batches.js +22 -22
- package/dist/src/engine/branch-summary.js +21 -21
- package/dist/src/engine/durable.d.ts +0 -2
- package/dist/src/engine/durable.js +20 -20
- package/dist/src/engine/fence.js +20 -20
- package/dist/src/engine/jobs.d.ts +2 -0
- package/dist/src/engine/jobs.js +31 -27
- package/dist/src/engine/move.js +23 -23
- package/dist/src/engine/part-definitions.js +2 -2
- package/dist/src/engine/presence.d.ts +39 -0
- package/dist/src/engine/presence.js +16 -0
- package/dist/src/engine/principals.js +17 -17
- package/dist/src/engine/receipts.js +21 -21
- package/dist/src/engine/runs.d.ts +1 -1
- package/dist/src/engine/runs.js +25 -25
- package/dist/src/engine/start.js +36 -35
- package/dist/src/engine/surface.d.ts +4 -0
- package/dist/src/engine/surface.js +13 -0
- package/dist/src/engine/waits.d.ts +5 -15
- package/dist/src/engine/waits.js +23 -19
- package/dist/src/env/browser.js +27 -27
- package/dist/src/env/environment.js +29 -29
- package/dist/src/env/mcp.js +31 -31
- package/dist/src/env/session-changes.d.ts +10 -0
- package/dist/src/env/session-changes.js +15 -0
- package/dist/src/env/trust.js +30 -30
- package/dist/src/env/workspaces.js +34 -33
- package/dist/src/env/worktrees.js +35 -34
- package/dist/src/extend/activation.js +35 -34
- package/dist/src/extend/hooks.js +22 -22
- package/dist/src/extend/models.d.ts +2 -1
- package/dist/src/extend/models.js +32 -30
- package/dist/src/extend/plugin-api.js +18 -18
- package/dist/src/extend/plugin-runtime.js +42 -41
- package/dist/src/extend/registry.js +27 -27
- package/dist/src/extend/resources.js +31 -31
- package/dist/src/extend/setting-layers.js +4 -4
- package/dist/src/extend/settings.js +38 -37
- package/dist/src/extend/workspace-commands.js +43 -42
- package/dist/src/fold/calls.js +5 -5
- package/dist/src/fold/checkpoint.js +11 -11
- package/dist/src/fold/code.d.ts +1 -2
- package/dist/src/fold/code.js +1 -1
- package/dist/src/fold/commit.d.ts +0 -4
- package/dist/src/fold/commit.js +16 -16
- package/dist/src/fold/draft.js +4 -4
- package/dist/src/fold/fold.js +7 -7
- package/dist/src/fold/paths.js +5 -5
- package/dist/src/fold/project.d.ts +3 -1
- package/dist/src/fold/project.js +8 -6
- package/dist/src/fold/reads.js +5 -5
- package/dist/src/fold/seen.js +19 -19
- package/dist/src/fold/view.d.ts +1 -1
- package/dist/src/fold/view.js +20 -20
- package/dist/src/fold/watch.js +15 -15
- package/dist/src/harness.d.ts +3 -1
- package/dist/src/harness.js +75 -70
- package/dist/src/index.d.ts +3 -3
- package/dist/src/index.js +5 -3
- package/dist/src/server.js +70 -65
- package/dist/src/store/inspect.js +4 -4
- package/dist/src/store/log.d.ts +0 -2
- package/dist/src/store/log.js +2 -2
- package/dist/src/store/memory-store.js +5 -5
- package/dist/src/store/migrations.js +3 -3
- package/dist/src/store/model-state.d.ts +6 -1
- package/dist/src/store/model-state.js +14 -4
- package/dist/src/store/parts.js +5 -5
- package/dist/src/store/refs.d.ts +6 -5
- package/dist/src/store/refs.js +11 -1
- package/dist/src/store/session-index.js +2 -2
- package/dist/src/store/session.d.ts +3 -1
- package/dist/src/store/session.js +5 -3
- package/dist/src/store.d.ts +1 -1
- package/dist/src/store.js +11 -7
- package/dist/src/testing.d.ts +2 -0
- package/dist/src/testing.js +83 -70
- package/package.json +4 -4
|
@@ -1,26 +1,43 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CORE_CONTEXT2
|
|
3
|
-
} from "./compose-
|
|
3
|
+
} from "./compose-5z835ej2.js";
|
|
4
|
+
import {
|
|
5
|
+
decodeJobRecord2
|
|
6
|
+
} from "./compose-gxjc6vz9.js";
|
|
7
|
+
import {
|
|
8
|
+
JOBS2,
|
|
9
|
+
jobRef2
|
|
10
|
+
} from "./compose-cqpjcx2t.js";
|
|
4
11
|
import {
|
|
5
12
|
dev2
|
|
6
13
|
} from "./compose-n116fnmp.js";
|
|
7
14
|
import {
|
|
8
15
|
MAIN2,
|
|
9
|
-
|
|
10
|
-
|
|
16
|
+
load2,
|
|
17
|
+
readSession2,
|
|
18
|
+
put2
|
|
19
|
+
} from "./compose-vn7b7fdj.js";
|
|
20
|
+
import {
|
|
21
|
+
followedTrace2,
|
|
22
|
+
traceparent2
|
|
23
|
+
} from "./compose-sd0stm97.js";
|
|
24
|
+
import {
|
|
25
|
+
commit2
|
|
26
|
+
} from "./compose-bbhk8vnr.js";
|
|
11
27
|
import {
|
|
12
28
|
closable2
|
|
13
29
|
} from "./compose-zfjxkavf.js";
|
|
14
30
|
import {
|
|
31
|
+
readJob2,
|
|
15
32
|
waitFor2
|
|
16
|
-
} from "./compose-
|
|
33
|
+
} from "./compose-bz70g01d.js";
|
|
17
34
|
import {
|
|
18
35
|
send2
|
|
19
|
-
} from "./compose-
|
|
36
|
+
} from "./compose-t9fcqtby.js";
|
|
20
37
|
import {
|
|
21
38
|
recordAcquisition2,
|
|
22
39
|
recordedAcquisition2
|
|
23
|
-
} from "./compose-
|
|
40
|
+
} from "./compose-byse0eqj.js";
|
|
24
41
|
|
|
25
42
|
// src/engine/jobs.ts
|
|
26
43
|
import { asId, asSeq, foldJobChange, SdkError } from "@nyte-ai/schema";
|
|
@@ -30,6 +47,8 @@ var READER_BYTES = 64 * 1024;
|
|
|
30
47
|
var ORPHAN_MS = 60000;
|
|
31
48
|
var REPORT_BYTES = 4096;
|
|
32
49
|
var ENDED_KEPT = 32;
|
|
50
|
+
var ENDED_JOB_MS = 60 * 60000;
|
|
51
|
+
var LOST = { kind: "lost" };
|
|
33
52
|
function createJobTable2(kernel) {
|
|
34
53
|
const entries = new Map;
|
|
35
54
|
const starts = new Map;
|
|
@@ -102,13 +121,19 @@ function createJobTable2(kernel) {
|
|
|
102
121
|
background: (session) => [...entries.values()].flatMap((entry) => {
|
|
103
122
|
const item = createJobBackgroundItem(entry);
|
|
104
123
|
return entry.owner?.session === session && item !== null ? [{ head: entry.owner.head, item }] : [];
|
|
105
|
-
})
|
|
124
|
+
}),
|
|
125
|
+
release(session, call) {
|
|
126
|
+
const started = [...entries.values()].filter((entry) => entry.owner?.session === session && entry.owner.startedBy === call && entry.view.state.kind === "running");
|
|
127
|
+
for (const entry of started)
|
|
128
|
+
entries.set(entry.view.id, { ...entry, held: false });
|
|
129
|
+
return started.length > 0;
|
|
130
|
+
}
|
|
106
131
|
};
|
|
107
132
|
}
|
|
108
133
|
function createJobs2(kernel, context, workspace) {
|
|
109
134
|
const views = () => kernel.jobs.list(workspace).map((entry) => entry.view);
|
|
110
135
|
return {
|
|
111
|
-
start: (input) =>
|
|
136
|
+
start: (input) => startJob2(kernel, context.origin, workspace, input),
|
|
112
137
|
async recover(key) {
|
|
113
138
|
const entry = kernel.jobs.byKey(key);
|
|
114
139
|
if (entry === undefined || entry.workspace !== workspace)
|
|
@@ -243,16 +268,21 @@ async function endJob(kernel, id, end) {
|
|
|
243
268
|
const entry = kernel.jobs.get(id);
|
|
244
269
|
if (entry === undefined || entry.view.state.kind !== "running")
|
|
245
270
|
return;
|
|
271
|
+
const recorded = entry.owner === null ? true : await recordJobEnd(kernel, id, end).catch((error) => {
|
|
272
|
+
dev2("jobs", "end not stored", { job: id, error: String(error) });
|
|
273
|
+
return false;
|
|
274
|
+
});
|
|
246
275
|
kernel.jobs.update(id, (view) => ({
|
|
247
276
|
...view,
|
|
248
277
|
state: end,
|
|
249
278
|
endedAt: Date.now(),
|
|
250
279
|
tail: entry.output.tail()
|
|
251
280
|
}));
|
|
281
|
+
const held = kernel.jobs.get(id)?.held === true;
|
|
252
282
|
entry.output.end(end.kind === "exited" ? end.code : null);
|
|
253
283
|
const consumed = await kernel.waits.jobEnded(id, end);
|
|
254
284
|
const owner = entry.owner;
|
|
255
|
-
if (consumed || owner === null)
|
|
285
|
+
if (consumed || owner === null || !recorded || held)
|
|
256
286
|
return;
|
|
257
287
|
await send2(kernel, {
|
|
258
288
|
session: owner.session,
|
|
@@ -264,7 +294,7 @@ async function endJob(kernel, id, end) {
|
|
|
264
294
|
return;
|
|
265
295
|
});
|
|
266
296
|
}
|
|
267
|
-
async function
|
|
297
|
+
async function startJob2(kernel, origin, workspace, input, hold = false) {
|
|
268
298
|
const digest = JSON.stringify([
|
|
269
299
|
input.command ?? null,
|
|
270
300
|
input.session ?? null,
|
|
@@ -284,22 +314,54 @@ async function startJob(kernel, origin, workspace, input) {
|
|
|
284
314
|
if (acquired.kind === "recorded")
|
|
285
315
|
return held(asId(acquired.id));
|
|
286
316
|
const id = acquired.value.id;
|
|
287
|
-
await kernel.jobs.start(id, digest, () => spawn(kernel, origin, workspace, input, id, digest));
|
|
317
|
+
await kernel.jobs.start(id, digest, () => spawn(kernel, origin, workspace, input, { id, digest, held: hold }));
|
|
288
318
|
return jobHandle2(kernel, id);
|
|
289
319
|
}
|
|
290
|
-
async function spawn(kernel, origin, workspace, input, id, digest) {
|
|
320
|
+
async function spawn(kernel, origin, workspace, input, { id, digest, held }) {
|
|
291
321
|
const on = async (session) => (await readSession2(kernel.store, session))?.record.workspace === workspace;
|
|
292
322
|
if (input.session !== undefined && !await on(input.session))
|
|
293
323
|
throw new SdkError("invalid", `Session ${input.session} is not on workspace ${workspace}.`);
|
|
294
324
|
const runner = input.session ?? (origin !== null && await on(origin.session) ? origin.session : null);
|
|
295
325
|
const env = runner === null ? await kernel.environments.attachWorkspace(workspace) : await kernel.environments.attach(runner);
|
|
296
|
-
const process = await env.exec(input.command ?? [], { cwd: env.cwd, pty: input.pty });
|
|
297
326
|
const own = origin !== null && input.session !== undefined && origin.session === input.session;
|
|
298
327
|
const owner = input.session === undefined ? null : {
|
|
299
328
|
session: input.session,
|
|
300
329
|
head: own && origin.head !== null ? origin.head : MAIN2,
|
|
301
330
|
startedBy: own ? origin.call : null
|
|
302
331
|
};
|
|
332
|
+
if (owner !== null) {
|
|
333
|
+
const reserved = await commit2(kernel, [
|
|
334
|
+
{
|
|
335
|
+
name: jobRef2(id),
|
|
336
|
+
target: await put2(kernel.store, "job", {
|
|
337
|
+
id,
|
|
338
|
+
instance: kernel.instance,
|
|
339
|
+
workspace,
|
|
340
|
+
session: owner.session,
|
|
341
|
+
head: owner.head,
|
|
342
|
+
startedBy: owner.startedBy,
|
|
343
|
+
title: input.title ?? input.command ?? "Shell",
|
|
344
|
+
command: input.command ?? "",
|
|
345
|
+
startedAt: Date.now(),
|
|
346
|
+
end: null,
|
|
347
|
+
endedAt: null
|
|
348
|
+
}),
|
|
349
|
+
expect: "absent"
|
|
350
|
+
}
|
|
351
|
+
]);
|
|
352
|
+
if (reserved.kind !== "set")
|
|
353
|
+
throw new SdkError("stale", `Job ${id} was already started.`);
|
|
354
|
+
}
|
|
355
|
+
const trace = owner === null || owner.startedBy === null ? null : followedTrace2(owner.session);
|
|
356
|
+
const process = await env.exec(input.command ?? [], {
|
|
357
|
+
cwd: env.cwd,
|
|
358
|
+
pty: input.pty,
|
|
359
|
+
env: trace === null ? undefined : { TRACEPARENT: traceparent2(trace) }
|
|
360
|
+
}).catch(async (cause) => {
|
|
361
|
+
if (owner !== null)
|
|
362
|
+
await recordJobEnd(kernel, id, LOST).catch(() => false);
|
|
363
|
+
throw cause;
|
|
364
|
+
});
|
|
303
365
|
const output = createOutput(input.pty !== undefined && input.session === undefined ? {
|
|
304
366
|
orphaned: () => void process.stop().catch((error) => {
|
|
305
367
|
dev2("jobs", "orphan stop failed", { job: id, error: String(error) });
|
|
@@ -322,10 +384,74 @@ async function spawn(kernel, origin, workspace, input, id, digest) {
|
|
|
322
384
|
process,
|
|
323
385
|
owner,
|
|
324
386
|
digest,
|
|
325
|
-
output
|
|
387
|
+
output,
|
|
388
|
+
held
|
|
326
389
|
});
|
|
327
390
|
pump(kernel, id, process, output);
|
|
328
391
|
}
|
|
392
|
+
async function recordJobEnd(kernel, id, end) {
|
|
393
|
+
for (;; ) {
|
|
394
|
+
const found = await readJob2(kernel.store, id);
|
|
395
|
+
if (found === null || found.record.end !== null)
|
|
396
|
+
return false;
|
|
397
|
+
const outcome = await commit2(kernel, [
|
|
398
|
+
{
|
|
399
|
+
name: jobRef2(id),
|
|
400
|
+
target: await put2(kernel.store, "job", { ...found.record, end }),
|
|
401
|
+
expect: found.ref.revision
|
|
402
|
+
}
|
|
403
|
+
]);
|
|
404
|
+
if (outcome.kind === "set")
|
|
405
|
+
return true;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
async function reapJobs2(kernel) {
|
|
409
|
+
const presence = kernel.presence;
|
|
410
|
+
if (presence === null)
|
|
411
|
+
return;
|
|
412
|
+
for (const ref of await kernel.store.refs.list(JOBS2)) {
|
|
413
|
+
const found = await load2(kernel.store, ref, decodeJobRecord2);
|
|
414
|
+
if (found === null)
|
|
415
|
+
continue;
|
|
416
|
+
const { record } = found;
|
|
417
|
+
if (record.end !== null) {
|
|
418
|
+
if (Date.now() - (record.endedAt ?? record.startedAt) > ENDED_JOB_MS)
|
|
419
|
+
await commit2(kernel, [{ name: ref.name, target: null, expect: ref.revision }]);
|
|
420
|
+
continue;
|
|
421
|
+
}
|
|
422
|
+
if (record.instance === kernel.instance)
|
|
423
|
+
continue;
|
|
424
|
+
const holder = await presence.holder(record.instance);
|
|
425
|
+
if (holder.kind !== "dead" && holder.kind !== "absent")
|
|
426
|
+
continue;
|
|
427
|
+
const reaped = await commit2(kernel, [
|
|
428
|
+
{
|
|
429
|
+
name: ref.name,
|
|
430
|
+
target: await put2(kernel.store, "job", { ...record, end: LOST, endedAt: Date.now() }),
|
|
431
|
+
expect: ref.revision
|
|
432
|
+
},
|
|
433
|
+
...holder.kind === "dead" ? [{ name: holder.name, target: null, expect: holder.expect }] : []
|
|
434
|
+
]);
|
|
435
|
+
if (reaped.kind !== "set")
|
|
436
|
+
continue;
|
|
437
|
+
dev2("jobs", "abandoned", { job: record.id, instance: record.instance });
|
|
438
|
+
if (await kernel.waits.jobEnded(record.id, LOST))
|
|
439
|
+
continue;
|
|
440
|
+
await send2(kernel, {
|
|
441
|
+
session: record.session,
|
|
442
|
+
head: record.head,
|
|
443
|
+
context: CORE_CONTEXT2,
|
|
444
|
+
content: abandonedReport(record),
|
|
445
|
+
options: { source: { kind: "job", job: record.id }, delivery: "attach" }
|
|
446
|
+
}).catch(() => {
|
|
447
|
+
return;
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
function abandonedReport(record) {
|
|
452
|
+
const named = record.command === "" ? record.title : `${record.title} (${record.command})`;
|
|
453
|
+
return `Job ${named} was abandoned: the Nyte that ran it exited, so its output and exit status are unknown, and the command may still be running.`;
|
|
454
|
+
}
|
|
329
455
|
async function acquire2(kernel, step, key, create, release) {
|
|
330
456
|
if (step === null || step.call === null)
|
|
331
457
|
return { kind: "created", value: await create() };
|
|
@@ -530,4 +656,4 @@ function report(view, end, tail) {
|
|
|
530
656
|
${text}`;
|
|
531
657
|
}
|
|
532
658
|
|
|
533
|
-
export { createJobTable2, createJobs2, jobHandle2, acquire2 };
|
|
659
|
+
export { createJobTable2, createJobs2, jobHandle2, startJob2, reapJobs2, acquire2 };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
LOCAL2,
|
|
3
3
|
PARTICIPANT_AUTHORITY2
|
|
4
|
-
} from "./compose-
|
|
4
|
+
} from "./compose-5z835ej2.js";
|
|
5
5
|
import {
|
|
6
6
|
decodeRunRecord2,
|
|
7
7
|
decodePartRecord2
|
|
8
|
-
} from "./compose-
|
|
8
|
+
} from "./compose-gxjc6vz9.js";
|
|
9
9
|
import {
|
|
10
10
|
runRef2,
|
|
11
11
|
partRef2,
|
|
12
12
|
callRef2
|
|
13
|
-
} from "./compose-
|
|
13
|
+
} from "./compose-cqpjcx2t.js";
|
|
14
14
|
import {
|
|
15
15
|
dev2
|
|
16
16
|
} from "./compose-n116fnmp.js";
|
|
@@ -21,11 +21,11 @@ import {
|
|
|
21
21
|
readRefExpectation2,
|
|
22
22
|
put2,
|
|
23
23
|
attempt2
|
|
24
|
-
} from "./compose-
|
|
24
|
+
} from "./compose-vn7b7fdj.js";
|
|
25
25
|
import {
|
|
26
26
|
settling2,
|
|
27
27
|
failedParts2
|
|
28
|
-
} from "./compose-
|
|
28
|
+
} from "./compose-d95fwwvw.js";
|
|
29
29
|
import {
|
|
30
30
|
startSpan2,
|
|
31
31
|
traced2,
|
|
@@ -36,26 +36,26 @@ import {
|
|
|
36
36
|
} from "./compose-84272xbk.js";
|
|
37
37
|
import {
|
|
38
38
|
commit2
|
|
39
|
-
} from "./compose-
|
|
39
|
+
} from "./compose-bbhk8vnr.js";
|
|
40
40
|
import {
|
|
41
41
|
withFold2
|
|
42
|
-
} from "./compose-
|
|
42
|
+
} from "./compose-xhtgytrh.js";
|
|
43
43
|
import {
|
|
44
44
|
intendedCall2
|
|
45
|
-
} from "./compose-
|
|
45
|
+
} from "./compose-byse0eqj.js";
|
|
46
46
|
import {
|
|
47
47
|
stopRequested2
|
|
48
|
-
} from "./compose-
|
|
48
|
+
} from "./compose-w6zb11k1.js";
|
|
49
49
|
import {
|
|
50
50
|
awaitMcpServers2
|
|
51
|
-
} from "./compose-
|
|
51
|
+
} from "./compose-gj2ypr7q.js";
|
|
52
52
|
import {
|
|
53
53
|
publishPatch2
|
|
54
|
-
} from "./compose-
|
|
54
|
+
} from "./compose-qxfq6dn9.js";
|
|
55
55
|
import {
|
|
56
56
|
modelInfo2,
|
|
57
57
|
withLimits2
|
|
58
|
-
} from "./compose-
|
|
58
|
+
} from "./compose-mdwr0er9.js";
|
|
59
59
|
import {
|
|
60
60
|
agentLoop2
|
|
61
61
|
} from "./compose-e3635qmn.js";
|
|
@@ -65,19 +65,19 @@ import {
|
|
|
65
65
|
charge2,
|
|
66
66
|
requestEvent2,
|
|
67
67
|
providerContext2
|
|
68
|
-
} from "./compose-
|
|
68
|
+
} from "./compose-sprfv38c.js";
|
|
69
69
|
import {
|
|
70
70
|
requestBody2,
|
|
71
71
|
estimateTranscriptTokens2
|
|
72
|
-
} from "./compose-
|
|
72
|
+
} from "./compose-jd4bsnqh.js";
|
|
73
73
|
import {
|
|
74
74
|
compact2,
|
|
75
75
|
failLeftoverCompactions2,
|
|
76
76
|
readProviderCheckpoint2
|
|
77
|
-
} from "./compose-
|
|
77
|
+
} from "./compose-12jnd50a.js";
|
|
78
78
|
import {
|
|
79
79
|
executeCall2
|
|
80
|
-
} from "./compose-
|
|
80
|
+
} from "./compose-mcz93154.js";
|
|
81
81
|
|
|
82
82
|
// src/agent/turn.ts
|
|
83
83
|
import { asId, isJson, SdkError } from "@nyte-ai/schema";
|
|
@@ -1,133 +1,138 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CORE_CONTEXT2
|
|
3
|
-
} from "./compose-
|
|
3
|
+
} from "./compose-5z835ej2.js";
|
|
4
4
|
import {
|
|
5
5
|
envelope2,
|
|
6
6
|
decodeHostIdentity2
|
|
7
|
-
} from "./compose-
|
|
7
|
+
} from "./compose-gxjc6vz9.js";
|
|
8
8
|
import {
|
|
9
9
|
kvRef2,
|
|
10
10
|
hostIdentityRef2
|
|
11
|
-
} from "./compose-
|
|
11
|
+
} from "./compose-cqpjcx2t.js";
|
|
12
12
|
import {
|
|
13
13
|
dev2
|
|
14
14
|
} from "./compose-n116fnmp.js";
|
|
15
15
|
import {
|
|
16
16
|
readKv2
|
|
17
|
-
} from "./compose-
|
|
17
|
+
} from "./compose-vn7b7fdj.js";
|
|
18
18
|
import {
|
|
19
19
|
createPartTable2
|
|
20
|
-
} from "./compose-
|
|
20
|
+
} from "./compose-d95fwwvw.js";
|
|
21
21
|
import {
|
|
22
22
|
EMPTY_CATALOG2
|
|
23
|
-
} from "./compose-
|
|
23
|
+
} from "./compose-6gt28900.js";
|
|
24
24
|
import {
|
|
25
25
|
createFoldCache2,
|
|
26
26
|
createLogPublisher2,
|
|
27
27
|
pollStore2
|
|
28
|
-
} from "./compose-
|
|
28
|
+
} from "./compose-ad80nkkn.js";
|
|
29
29
|
import {
|
|
30
30
|
createModelState2
|
|
31
|
-
} from "./compose-
|
|
31
|
+
} from "./compose-csh5vv2t.js";
|
|
32
32
|
import {
|
|
33
33
|
createWaitRegistry2
|
|
34
|
-
} from "./compose-
|
|
34
|
+
} from "./compose-bz70g01d.js";
|
|
35
35
|
import {
|
|
36
36
|
pluginSecrets2
|
|
37
|
-
} from "./compose-
|
|
37
|
+
} from "./compose-c9wxgbjp.js";
|
|
38
38
|
import {
|
|
39
39
|
settingInfos2
|
|
40
|
-
} from "./compose-
|
|
40
|
+
} from "./compose-qwbe95qs.js";
|
|
41
41
|
import {
|
|
42
42
|
bumpGeneration2
|
|
43
|
-
} from "./compose-
|
|
43
|
+
} from "./compose-ae5t6v5b.js";
|
|
44
44
|
import {
|
|
45
45
|
createModelsApi2,
|
|
46
|
-
createConfigurationResolver2
|
|
47
|
-
|
|
46
|
+
createConfigurationResolver2,
|
|
47
|
+
rememberChoice2
|
|
48
|
+
} from "./compose-mdwr0er9.js";
|
|
48
49
|
import {
|
|
49
50
|
createRequest2
|
|
50
|
-
} from "./compose-
|
|
51
|
+
} from "./compose-sprfv38c.js";
|
|
51
52
|
import {
|
|
52
|
-
createJobTable2
|
|
53
|
-
|
|
53
|
+
createJobTable2,
|
|
54
|
+
jobHandle2
|
|
55
|
+
} from "./compose-nkxwrphm.js";
|
|
54
56
|
import {
|
|
55
57
|
createPageTable2
|
|
56
|
-
} from "./compose-
|
|
58
|
+
} from "./compose-m01wspwf.js";
|
|
57
59
|
import {
|
|
58
60
|
createEnvironmentRegistry2
|
|
59
|
-
} from "./compose-
|
|
61
|
+
} from "./compose-4ppmas7g.js";
|
|
60
62
|
import {
|
|
61
63
|
dropScans2,
|
|
62
64
|
resourcesPlugin2
|
|
63
|
-
} from "./compose-
|
|
65
|
+
} from "./compose-jmmyw9hd.js";
|
|
64
66
|
import {
|
|
65
67
|
createCompactor2,
|
|
66
68
|
createSummarizer2
|
|
67
|
-
} from "./compose-
|
|
69
|
+
} from "./compose-12jnd50a.js";
|
|
68
70
|
import {
|
|
69
71
|
stoppableTool2
|
|
70
|
-
} from "./compose-
|
|
72
|
+
} from "./compose-mcz93154.js";
|
|
71
73
|
import {
|
|
72
74
|
readMcpWorkspace2
|
|
73
|
-
} from "./compose-
|
|
75
|
+
} from "./compose-gj2ypr7q.js";
|
|
74
76
|
import {
|
|
75
77
|
createTurnDriver2
|
|
76
|
-
} from "./compose-
|
|
78
|
+
} from "./compose-pkprmn5b.js";
|
|
79
|
+
import {
|
|
80
|
+
openPresence2
|
|
81
|
+
} from "./compose-gvm49f4b.js";
|
|
77
82
|
import {
|
|
78
83
|
createWorkspaceState2,
|
|
79
84
|
createWorkspaces2
|
|
80
|
-
} from "./compose-
|
|
85
|
+
} from "./compose-d1m94kzq.js";
|
|
81
86
|
import {
|
|
82
87
|
sweepWorktrees2
|
|
83
|
-
} from "./compose-
|
|
88
|
+
} from "./compose-e2fyz3xc.js";
|
|
84
89
|
import {
|
|
85
90
|
stopStart2
|
|
86
|
-
} from "./compose-
|
|
91
|
+
} from "./compose-a8ddt55n.js";
|
|
87
92
|
import {
|
|
88
93
|
createExecutionState2,
|
|
89
94
|
driveInProcess2,
|
|
90
95
|
dispatchHead2
|
|
91
|
-
} from "./compose-
|
|
96
|
+
} from "./compose-8mkfr84d.js";
|
|
92
97
|
import {
|
|
93
98
|
createConnectionRegistry2
|
|
94
|
-
} from "./compose-
|
|
99
|
+
} from "./compose-jwy1gba9.js";
|
|
95
100
|
import {
|
|
96
101
|
createSettingsApi2
|
|
97
|
-
} from "./compose-
|
|
102
|
+
} from "./compose-753gc057.js";
|
|
98
103
|
import {
|
|
99
104
|
createPartDefinitions2
|
|
100
|
-
} from "./compose-
|
|
105
|
+
} from "./compose-zaanjpb7.js";
|
|
101
106
|
import {
|
|
102
107
|
createPluginState2,
|
|
103
108
|
createPluginRuntime2,
|
|
104
109
|
checkPlugins2,
|
|
105
110
|
replacePlugins2,
|
|
106
111
|
hostPluginRows2
|
|
107
|
-
} from "./compose-
|
|
112
|
+
} from "./compose-9hy3p236.js";
|
|
108
113
|
import {
|
|
109
114
|
createHostState2
|
|
110
115
|
} from "./compose-xm52jghq.js";
|
|
111
116
|
import {
|
|
112
117
|
rerunAction2
|
|
113
|
-
} from "./compose-
|
|
118
|
+
} from "./compose-r8tz1xfj.js";
|
|
114
119
|
import {
|
|
115
120
|
sessionHandle2,
|
|
116
121
|
activationSession2
|
|
117
|
-
} from "./compose-
|
|
122
|
+
} from "./compose-e9f6nrwp.js";
|
|
118
123
|
import {
|
|
119
124
|
createConnection2,
|
|
120
125
|
createHost2
|
|
121
|
-
} from "./compose-
|
|
126
|
+
} from "./compose-zjj072km.js";
|
|
122
127
|
import {
|
|
123
128
|
createServerHost2
|
|
124
|
-
} from "./compose-
|
|
129
|
+
} from "./compose-wvzzf8n2.js";
|
|
125
130
|
import {
|
|
126
131
|
delegationPlugin2
|
|
127
|
-
} from "./compose-
|
|
132
|
+
} from "./compose-m91ffwss.js";
|
|
128
133
|
import {
|
|
129
134
|
environmentPlugin2
|
|
130
|
-
} from "./compose-
|
|
135
|
+
} from "./compose-b2bf1jvy.js";
|
|
131
136
|
import {
|
|
132
137
|
mcpPlugin2
|
|
133
138
|
} from "./compose-597de3tc.js";
|
|
@@ -149,6 +154,7 @@ var NO_MODELS = {
|
|
|
149
154
|
usage: async () => unavailable("models"),
|
|
150
155
|
refresh: async () => unavailable("models"),
|
|
151
156
|
setDefault: async () => unavailable("models"),
|
|
157
|
+
setListing: async () => unavailable("models"),
|
|
152
158
|
verify: async () => unavailable("models"),
|
|
153
159
|
login: () => unavailable("models"),
|
|
154
160
|
logout: async () => unavailable("models")
|
|
@@ -267,9 +273,13 @@ async function applySeed(kernel, seed) {
|
|
|
267
273
|
}
|
|
268
274
|
async function composeKernel(options, store) {
|
|
269
275
|
const identity = await hostIdentity2(store);
|
|
276
|
+
const instance = crypto.randomUUID();
|
|
277
|
+
const presence = options.member === undefined ? null : await openPresence2(store, { instance, holder: identity.id, member: options.member });
|
|
270
278
|
const kernel = createKernel2({
|
|
271
279
|
hostId: identity.id,
|
|
272
|
-
|
|
280
|
+
instance,
|
|
281
|
+
presence,
|
|
282
|
+
store: presence?.store ?? store,
|
|
273
283
|
description: options.description,
|
|
274
284
|
host: createHostState2({
|
|
275
285
|
catalog: asId(crypto.randomUUID()),
|
|
@@ -281,6 +291,7 @@ async function composeKernel(options, store) {
|
|
|
281
291
|
models: options.models,
|
|
282
292
|
mcp: options.mcp,
|
|
283
293
|
github: options.github,
|
|
294
|
+
images: options.images,
|
|
284
295
|
builtins: BUILTINS,
|
|
285
296
|
hostPlugins: options.plugins,
|
|
286
297
|
pluginSources: options.pluginSources,
|
|
@@ -290,6 +301,10 @@ async function composeKernel(options, store) {
|
|
|
290
301
|
loadPlugins: options.loadPlugins
|
|
291
302
|
});
|
|
292
303
|
kernel.host.update({ plugins: hostPluginRows2(kernel) });
|
|
304
|
+
presence?.revoked.addEventListener("abort", () => {
|
|
305
|
+
kernel.executionState.closing.abort();
|
|
306
|
+
options.revoked?.();
|
|
307
|
+
}, { once: true });
|
|
293
308
|
return kernel;
|
|
294
309
|
}
|
|
295
310
|
function createKernel2(input) {
|
|
@@ -318,7 +333,8 @@ function createKernel2(input) {
|
|
|
318
333
|
let pages = null;
|
|
319
334
|
const kernel = {
|
|
320
335
|
hostId: input.hostId,
|
|
321
|
-
instance: crypto.randomUUID(),
|
|
336
|
+
instance: input.instance ?? crypto.randomUUID(),
|
|
337
|
+
presence: input.presence ?? null,
|
|
322
338
|
poll: input.poll ?? null,
|
|
323
339
|
externalCommits: new Set,
|
|
324
340
|
store: input.store,
|
|
@@ -358,6 +374,10 @@ function createKernel2(input) {
|
|
|
358
374
|
get resolveConfiguration() {
|
|
359
375
|
return resolveConfiguration ??= models === undefined ? async () => unavailable("resolveConfiguration") : createConfigurationResolver2(kernel, models);
|
|
360
376
|
},
|
|
377
|
+
rememberChoice: async (choice, scope) => {
|
|
378
|
+
if (models !== undefined)
|
|
379
|
+
await rememberChoice2(kernel, models, choice, scope);
|
|
380
|
+
},
|
|
361
381
|
get waits() {
|
|
362
382
|
return waits ??= createWaitRegistry2(kernel, (session, call) => rerunAction2(kernel, session, call));
|
|
363
383
|
},
|
|
@@ -382,6 +402,7 @@ function createKernel2(input) {
|
|
|
382
402
|
connections: createConnectionRegistry2(),
|
|
383
403
|
secrets: input.secrets ?? null,
|
|
384
404
|
github: input.github ?? null,
|
|
405
|
+
images: input.images ?? null,
|
|
385
406
|
get mcp() {
|
|
386
407
|
if (mcp === undefined)
|
|
387
408
|
mcp = input.mcp?.({ secrets: pluginSecrets2(kernel, "mcp") }) ?? null;
|
|
@@ -428,7 +449,9 @@ async function release(kernel, driver) {
|
|
|
428
449
|
await driver?.close();
|
|
429
450
|
const sessions = [...kernel.plugins.runtimes().keys()];
|
|
430
451
|
const workspaces = (await kernel.store.refs.list("workspaces/")).map((ref) => asId(ref.name.slice("workspaces/".length)));
|
|
431
|
-
|
|
452
|
+
const running = workspaces.flatMap((workspace) => kernel.jobs.list(workspace).filter((job) => job.view.state.kind === "running"));
|
|
453
|
+
await Promise.allSettled(running.map((job) => job.process.stop()));
|
|
454
|
+
await Promise.allSettled(running.map((job) => jobHandle2(kernel, job.view.id).settled()));
|
|
432
455
|
for (const session of sessions)
|
|
433
456
|
await kernel.plugins.close(session);
|
|
434
457
|
dropScans2(kernel);
|
|
@@ -436,6 +459,11 @@ async function release(kernel, driver) {
|
|
|
436
459
|
await kernel.environments.detach(session);
|
|
437
460
|
for (const workspace of workspaces)
|
|
438
461
|
await kernel.environments.detachWorkspace(workspace);
|
|
462
|
+
const state = kernel.executionState;
|
|
463
|
+
await kernel.presence?.close([...state.undrained].flatMap((name) => {
|
|
464
|
+
const held = state.held.get(name);
|
|
465
|
+
return held === undefined ? [] : [{ name, expect: held.revision }];
|
|
466
|
+
}));
|
|
439
467
|
}
|
|
440
468
|
async function storedIdentity(store) {
|
|
441
469
|
const ref = await store.refs.get(hostIdentityRef2());
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
kvRef2
|
|
3
|
-
} from "./compose-
|
|
3
|
+
} from "./compose-cqpjcx2t.js";
|
|
4
4
|
import {
|
|
5
5
|
MAIN2,
|
|
6
6
|
readSession2,
|
|
7
7
|
readKv2
|
|
8
|
-
} from "./compose-
|
|
8
|
+
} from "./compose-vn7b7fdj.js";
|
|
9
9
|
import {
|
|
10
10
|
convertJsonSchema2
|
|
11
11
|
} from "./compose-bj54tkph.js";
|