@nyte-ai/core 0.0.18 → 0.0.19
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-q1b0tppc.js → compose-0827b2k4.js} +4 -4
- package/dist/chunks/{compose-j3tkz0tb.js → compose-1g03zpvn.js} +6 -6
- package/dist/chunks/{compose-2g3enfv5.js → compose-31zqcfte.js} +4 -4
- package/dist/chunks/{compose-4b1zf3p0.js → compose-4770pb1s.js} +62 -46
- package/dist/chunks/{compose-madtxnp1.js → compose-47f47sgy.js} +7 -7
- package/dist/chunks/{compose-1z7q169s.js → compose-5489evqa.js} +67 -39
- package/dist/chunks/{compose-yk3y0jap.js → compose-54svedb8.js} +7 -7
- package/dist/chunks/{compose-9tqm6g18.js → compose-57j0pme0.js} +4 -4
- package/dist/chunks/{compose-k8aghhv2.js → compose-5cmp34zp.js} +16 -16
- 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-q1n2dgrs.js → compose-6m60v1pk.js} +4 -4
- package/dist/chunks/{compose-2eg8w67t.js → compose-6r5ymwyr.js} +15 -4
- package/dist/chunks/{compose-q1ts0v6k.js → compose-767bb340.js} +1 -1
- package/dist/chunks/{compose-pgeemk2b.js → compose-a7k9h27z.js} +6 -5
- package/dist/chunks/{compose-wgphshsn.js → compose-azq5jxr2.js} +7 -7
- package/dist/chunks/compose-bd8c5n7k.js +32 -0
- package/dist/chunks/{compose-drdej9yt.js → compose-c2rnebv0.js} +3 -3
- package/dist/chunks/compose-c4238qkb.js +105 -0
- package/dist/chunks/{compose-djq2bt61.js → compose-ccrh32hd.js} +6 -6
- 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-jc22rsz4.js → compose-dbsn3bsy.js} +2 -2
- package/dist/chunks/{compose-rehp8epe.js → compose-eemt6sea.js} +7 -7
- package/dist/chunks/{compose-r7dx7rpz.js → compose-exfx5b4d.js} +72 -15
- package/dist/chunks/{compose-p3q14yt1.js → compose-g2a1f1yx.js} +5 -5
- package/dist/chunks/compose-gvm49f4b.js +155 -0
- package/dist/chunks/{compose-9m19b27b.js → compose-gvrqkyn4.js} +7 -7
- package/dist/chunks/{compose-1jz2j92f.js → compose-gxjc6vz9.js} +30 -2
- package/dist/chunks/{compose-s2aew2c9.js → compose-gxvetm0j.js} +5 -5
- package/dist/chunks/{compose-cq1zx4gp.js → compose-h14pmqv3.js} +1 -1
- package/dist/chunks/{compose-5w5bbakh.js → compose-h3pch7ch.js} +5 -5
- package/dist/chunks/{compose-r12cnkpc.js → compose-hf6xkwdw.js} +10 -10
- package/dist/chunks/{compose-aa73dbe8.js → compose-hms4hf6p.js} +92 -49
- package/dist/chunks/{compose-jjchxce6.js → compose-j42p9wfs.js} +1 -1
- package/dist/chunks/{compose-vmhv4e00.js → compose-jehg40ce.js} +13 -12
- package/dist/chunks/{compose-5tkyrzr0.js → compose-jhs91x01.js} +4 -4
- package/dist/chunks/{compose-xd0kdp3t.js → compose-jrqn6xhy.js} +8 -8
- package/dist/chunks/{compose-ef936rsa.js → compose-ks2rdteq.js} +27 -11
- package/dist/chunks/{compose-k35b75k9.js → compose-kwkna3cg.js} +2 -4
- package/dist/chunks/{compose-gaps3heh.js → compose-m1ecjzm2.js} +8 -8
- package/dist/chunks/{compose-xtkavyrw.js → compose-m6nsbnkk.js} +17 -9
- package/dist/chunks/{compose-y478gv6x.js → compose-mamr4qwf.js} +4 -4
- package/dist/chunks/{compose-j12n448k.js → compose-nj4nj5n9.js} +36 -3
- package/dist/chunks/{compose-cdy4q5mv.js → compose-pe0cgbv0.js} +17 -16
- package/dist/chunks/{compose-xpfr4wt3.js → compose-pnsvwd3m.js} +7 -4
- package/dist/chunks/{compose-52afaf3v.js → compose-prchdrqk.js} +7 -7
- package/dist/chunks/{compose-7pc3p5ex.js → compose-q1d09qpr.js} +8 -8
- package/dist/chunks/{compose-amr0k1m1.js → compose-q1rrtq3a.js} +2 -2
- package/dist/chunks/{compose-0bpspysf.js → compose-qknd62yj.js} +5 -5
- package/dist/chunks/{compose-b5xz0dj7.js → compose-qwbe95qs.js} +2 -2
- package/dist/chunks/{compose-064y3n82.js → compose-r1pxdxbw.js} +5 -5
- package/dist/chunks/{compose-7b8ajk7a.js → compose-rd5e5nxg.js} +8 -8
- package/dist/chunks/{compose-gg8b9b21.js → compose-s5522cth.js} +23 -18
- package/dist/chunks/{compose-t53j8yxv.js → compose-se7wwcq1.js} +1 -1
- package/dist/chunks/{compose-dc2ns6gd.js → compose-seyhq3fb.js} +10 -10
- package/dist/chunks/{compose-ffk8dnbh.js → compose-smsafpqe.js} +3 -3
- package/dist/chunks/{compose-eqr5qwp1.js → compose-tb5ywdfk.js} +56 -21
- package/dist/chunks/{compose-dckpgtks.js → compose-ts08bth2.js} +3 -3
- package/dist/chunks/{compose-1gd9vkye.js → compose-v9yf9mrh.js} +3 -3
- package/dist/chunks/{compose-n10w4nkk.js → compose-vn7b7fdj.js} +12 -3
- package/dist/chunks/{compose-kmzr06mw.js → compose-w2ac7xjx.js} +8 -5
- package/dist/chunks/{compose-rpq9n0nz.js → compose-xaegezm3.js} +84 -26
- 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-yn2et568.js → compose-y9c31w4e.js} +118 -9
- package/dist/chunks/{compose-h272znxk.js → compose-z6hbq6y0.js} +7 -7
- package/dist/chunks/{compose-d2s80zg2.js → compose-zch4zapc.js} +5 -5
- package/dist/src/agent/compaction.js +39 -37
- package/dist/src/agent/images.d.ts +7 -0
- package/dist/src/agent/images.js +8 -0
- package/dist/src/agent/request.js +28 -28
- package/dist/src/agent/tool-runner.d.ts +1 -7
- package/dist/src/agent/tool-runner.js +29 -28
- package/dist/src/agent/transcript.d.ts +0 -1
- package/dist/src/agent/transcript.js +35 -33
- package/dist/src/agent/turn.js +43 -41
- package/dist/src/api/connection.js +56 -53
- package/dist/src/api/head.js +39 -39
- package/dist/src/api/part.js +20 -20
- package/dist/src/api/server.js +45 -42
- package/dist/src/api/session.js +44 -44
- package/dist/src/builtins/environment.js +1 -1
- package/dist/src/compose.d.ts +6 -7
- package/dist/src/compose.js +68 -64
- 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/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/workspace.d.ts +5 -3
- package/dist/src/drive/execution.js +43 -40
- package/dist/src/drive/interruptions.d.ts +7 -0
- package/dist/src/drive/interruptions.js +17 -0
- package/dist/src/engine/admission.js +22 -22
- package/dist/src/engine/batches.js +21 -21
- package/dist/src/engine/branch-summary.js +20 -20
- package/dist/src/engine/durable.d.ts +0 -2
- package/dist/src/engine/durable.js +19 -19
- package/dist/src/engine/fence.js +19 -19
- package/dist/src/engine/jobs.d.ts +1 -0
- package/dist/src/engine/jobs.js +27 -25
- package/dist/src/engine/move.js +22 -22
- package/dist/src/engine/presence.d.ts +39 -0
- package/dist/src/engine/presence.js +16 -0
- package/dist/src/engine/principals.js +16 -16
- package/dist/src/engine/receipts.js +20 -20
- package/dist/src/engine/runs.d.ts +1 -1
- package/dist/src/engine/runs.js +23 -23
- package/dist/src/engine/start.js +33 -33
- 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 +22 -18
- package/dist/src/env/browser.js +25 -25
- package/dist/src/env/environment.js +27 -27
- package/dist/src/env/mcp.js +29 -29
- package/dist/src/env/trust.js +28 -28
- package/dist/src/env/workspaces.js +31 -31
- package/dist/src/env/worktrees.js +32 -32
- package/dist/src/extend/activation.js +32 -32
- package/dist/src/extend/hooks.js +21 -21
- package/dist/src/extend/models.d.ts +2 -1
- package/dist/src/extend/models.js +30 -28
- package/dist/src/extend/plugin-api.js +17 -17
- package/dist/src/extend/plugin-runtime.js +38 -38
- package/dist/src/extend/registry.js +25 -25
- package/dist/src/extend/resources.js +29 -29
- package/dist/src/extend/setting-layers.js +4 -4
- package/dist/src/extend/settings.js +35 -35
- package/dist/src/extend/workspace-commands.js +39 -39
- 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 +15 -15
- 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 +18 -18
- package/dist/src/fold/view.d.ts +1 -1
- package/dist/src/fold/view.js +19 -19
- package/dist/src/fold/watch.js +14 -14
- package/dist/src/harness.d.ts +2 -1
- package/dist/src/harness.js +71 -67
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.js +4 -2
- package/dist/src/server.js +66 -62
- 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 +4 -4
- 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 +77 -65
- package/package.json +4 -4
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PARTICIPANT_AUTHORITY2
|
|
3
|
-
} from "./compose-
|
|
3
|
+
} from "./compose-5z835ej2.js";
|
|
4
4
|
import {
|
|
5
5
|
decodeRunRecord2,
|
|
6
6
|
decodeLease2
|
|
7
|
-
} from "./compose-
|
|
7
|
+
} from "./compose-gxjc6vz9.js";
|
|
8
8
|
import {
|
|
9
9
|
objectId2
|
|
10
10
|
} from "./compose-q6c7wswc.js";
|
|
11
11
|
import {
|
|
12
12
|
runRef2,
|
|
13
13
|
leaseRef2
|
|
14
|
-
} from "./compose-
|
|
14
|
+
} from "./compose-cqpjcx2t.js";
|
|
15
15
|
import {
|
|
16
16
|
dev2
|
|
17
17
|
} from "./compose-n116fnmp.js";
|
|
@@ -24,46 +24,57 @@ import {
|
|
|
24
24
|
covers2,
|
|
25
25
|
coveredSessions2,
|
|
26
26
|
coveredHere2
|
|
27
|
-
} from "./compose-
|
|
27
|
+
} from "./compose-vn7b7fdj.js";
|
|
28
28
|
import {
|
|
29
29
|
commit2
|
|
30
|
-
} from "./compose-
|
|
30
|
+
} from "./compose-pnsvwd3m.js";
|
|
31
31
|
import {
|
|
32
32
|
holdLease2
|
|
33
33
|
} from "./compose-vzvm76dn.js";
|
|
34
34
|
import {
|
|
35
35
|
withFold2
|
|
36
|
-
} from "./compose-
|
|
36
|
+
} from "./compose-xhtgytrh.js";
|
|
37
37
|
import {
|
|
38
38
|
loadWaits2,
|
|
39
39
|
earliestWake2
|
|
40
|
-
} from "./compose-
|
|
40
|
+
} from "./compose-ks2rdteq.js";
|
|
41
41
|
import {
|
|
42
42
|
LEASE_MS2
|
|
43
|
-
} from "./compose-
|
|
43
|
+
} from "./compose-eemt6sea.js";
|
|
44
44
|
import {
|
|
45
45
|
stopRequested2
|
|
46
|
-
} from "./compose-
|
|
46
|
+
} from "./compose-gvrqkyn4.js";
|
|
47
47
|
import {
|
|
48
48
|
selectRunStart2,
|
|
49
49
|
landing2
|
|
50
|
-
} from "./compose-
|
|
50
|
+
} from "./compose-pe0cgbv0.js";
|
|
51
51
|
import {
|
|
52
52
|
newRun2,
|
|
53
53
|
begin2,
|
|
54
54
|
endRun2
|
|
55
|
-
} from "./compose-
|
|
55
|
+
} from "./compose-jehg40ce.js";
|
|
56
56
|
import {
|
|
57
57
|
executeCall2,
|
|
58
58
|
owedCalls2,
|
|
59
59
|
readToolInput2
|
|
60
|
-
} from "./compose-
|
|
60
|
+
} from "./compose-hms4hf6p.js";
|
|
61
61
|
import {
|
|
62
62
|
recoverMoves2
|
|
63
|
-
} from "./compose-
|
|
63
|
+
} from "./compose-47f47sgy.js";
|
|
64
|
+
import {
|
|
65
|
+
reapJobs2
|
|
66
|
+
} from "./compose-y9c31w4e.js";
|
|
67
|
+
import {
|
|
68
|
+
BEAT_MS2
|
|
69
|
+
} from "./compose-gvm49f4b.js";
|
|
64
70
|
import {
|
|
65
71
|
recoverStarts2
|
|
66
|
-
} from "./compose-
|
|
72
|
+
} from "./compose-seyhq3fb.js";
|
|
73
|
+
import {
|
|
74
|
+
crashLooping2,
|
|
75
|
+
parkedFailure2,
|
|
76
|
+
interruption2
|
|
77
|
+
} from "./compose-5rg7askh.js";
|
|
67
78
|
|
|
68
79
|
// src/drive/execution.ts
|
|
69
80
|
import { asId, SdkError } from "@nyte-ai/schema";
|
|
@@ -79,6 +90,7 @@ function createExecutionState2() {
|
|
|
79
90
|
driving: new Map,
|
|
80
91
|
covers: new Map,
|
|
81
92
|
advancing: new Set,
|
|
93
|
+
undrained: new Set,
|
|
82
94
|
leaseQueue: keyedSerial(),
|
|
83
95
|
pending: new Map,
|
|
84
96
|
summaries: new Set,
|
|
@@ -103,11 +115,11 @@ async function cover2(kernel, coverage) {
|
|
|
103
115
|
}
|
|
104
116
|
const released = [];
|
|
105
117
|
for (const [name, entry] of state.held) {
|
|
106
|
-
if (!entry.owners.delete(handle) || entry.owners.size > 0 || state.advancing.has(name))
|
|
118
|
+
if (!entry.owners.delete(handle) || entry.owners.size > 0 || state.advancing.has(name) || state.undrained.has(name))
|
|
107
119
|
continue;
|
|
108
120
|
released.push(release(kernel, entry.session, entry.head));
|
|
109
121
|
}
|
|
110
|
-
await Promise.
|
|
122
|
+
await Promise.allSettled(released);
|
|
111
123
|
})();
|
|
112
124
|
return closing;
|
|
113
125
|
};
|
|
@@ -154,7 +166,7 @@ async function advance2(kernel, input) {
|
|
|
154
166
|
return report;
|
|
155
167
|
} finally {
|
|
156
168
|
state.advancing.delete(name);
|
|
157
|
-
if (claimed && (report?.kind !== "continue" || (state.held.get(name)?.owners.size ?? 0) === 0)) {
|
|
169
|
+
if (claimed && !state.undrained.has(name) && (report?.kind !== "continue" || (state.held.get(name)?.owners.size ?? 0) === 0)) {
|
|
158
170
|
await release(kernel, session, head);
|
|
159
171
|
if (report?.kind === "idle" && await owed(kernel, session, head))
|
|
160
172
|
kernel.wakes.notify(session, head);
|
|
@@ -169,7 +181,7 @@ async function step(kernel, session, head) {
|
|
|
169
181
|
const due = await dueInputs(kernel, session, head);
|
|
170
182
|
if (due === null)
|
|
171
183
|
return { kind: "idle" };
|
|
172
|
-
const run = await newRun2(kernel.store, session, head, due.origin, due.input.configuration);
|
|
184
|
+
const run = await newRun2(kernel.store, session, head, due.origin, due.input.configuration, due.input.requires ?? kernel.presence?.member.capabilities ?? []);
|
|
173
185
|
if ((await landing2(kernel, session, head, due.ids, run.view.id, run.updates)).length === 0)
|
|
174
186
|
return next(kernel, session, head);
|
|
175
187
|
begin2(kernel, session, run.view);
|
|
@@ -183,7 +195,10 @@ async function failStep(kernel, session, head, cause) {
|
|
|
183
195
|
await endRun2(kernel, session, live.record.view.id, failed(cause));
|
|
184
196
|
return next(kernel, session, head);
|
|
185
197
|
}
|
|
186
|
-
|
|
198
|
+
function repair2(kernel, input) {
|
|
199
|
+
return owedPage(kernel, input, true);
|
|
200
|
+
}
|
|
201
|
+
async function owedPage(kernel, input, operations) {
|
|
187
202
|
if (input.cursor !== undefined && !input.cursor.startsWith("work:"))
|
|
188
203
|
throw new SdkError("invalid", `${input.cursor} is not a recovery cursor`);
|
|
189
204
|
const limit = Math.max(1, input.limit);
|
|
@@ -197,7 +212,7 @@ async function repair2(kernel, input) {
|
|
|
197
212
|
for (const session of sessions) {
|
|
198
213
|
const found = await readSession2(kernel.store, session);
|
|
199
214
|
if (found !== null)
|
|
200
|
-
for (const head of await recover(kernel, session, found.record.heads))
|
|
215
|
+
for (const head of await recover(kernel, session, found.record.heads, operations))
|
|
201
216
|
runnable.push({ session, head });
|
|
202
217
|
}
|
|
203
218
|
for (const entry of runnable)
|
|
@@ -209,9 +224,11 @@ async function repair2(kernel, input) {
|
|
|
209
224
|
next: refs.length > limit && last !== undefined ? asId(`work:${last}`) : null
|
|
210
225
|
};
|
|
211
226
|
}
|
|
212
|
-
async function recover(kernel, session, heads) {
|
|
213
|
-
|
|
214
|
-
|
|
227
|
+
async function recover(kernel, session, heads, operations = true) {
|
|
228
|
+
if (operations) {
|
|
229
|
+
await recoverMoves2(kernel, session);
|
|
230
|
+
await recoverStarts2(kernel, session);
|
|
231
|
+
}
|
|
215
232
|
const runnable = [];
|
|
216
233
|
for (const head of heads)
|
|
217
234
|
if (await owed(kernel, session, head.name))
|
|
@@ -299,6 +316,29 @@ function driveInProcess2(kernel, coverage) {
|
|
|
299
316
|
retries.add(retry);
|
|
300
317
|
};
|
|
301
318
|
const dispose = kernel.wakes.subscribe(step);
|
|
319
|
+
let sweeping = false;
|
|
320
|
+
const sweep = async () => {
|
|
321
|
+
if (sweeping || closed)
|
|
322
|
+
return;
|
|
323
|
+
sweeping = true;
|
|
324
|
+
try {
|
|
325
|
+
await covering;
|
|
326
|
+
await kernel.presence?.sweep();
|
|
327
|
+
await kernel.waits.tick(Date.now());
|
|
328
|
+
await reapJobs2(kernel);
|
|
329
|
+
if (coverage.kind === "all") {
|
|
330
|
+
let cursor;
|
|
331
|
+
do {
|
|
332
|
+
cursor = (await owedPage(kernel, { cursor, limit: PAGE }, false)).next ?? undefined;
|
|
333
|
+
} while (cursor !== undefined && !closed);
|
|
334
|
+
}
|
|
335
|
+
} catch (error) {
|
|
336
|
+
dev2("execution", "sweep failed", { error: formatError(error) });
|
|
337
|
+
} finally {
|
|
338
|
+
sweeping = false;
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
const sweeper = kernel.presence === null ? null : setInterval(() => void sweep(), BEAT_MS2);
|
|
302
342
|
if (coverage.kind === "all")
|
|
303
343
|
(async () => {
|
|
304
344
|
await covering;
|
|
@@ -312,6 +352,8 @@ function driveInProcess2(kernel, coverage) {
|
|
|
312
352
|
closing ??= (async () => {
|
|
313
353
|
closed = true;
|
|
314
354
|
dispose();
|
|
355
|
+
if (sweeper !== null)
|
|
356
|
+
clearInterval(sweeper);
|
|
315
357
|
if (timer !== null)
|
|
316
358
|
clearTimeout(timer);
|
|
317
359
|
for (const retry of retries)
|
|
@@ -355,14 +397,20 @@ async function claimNow(kernel, session, head) {
|
|
|
355
397
|
}
|
|
356
398
|
const lease = ref?.target ? decodeLease2(await kernel.store.objects.get(ref.target)) : null;
|
|
357
399
|
const now = Date.now();
|
|
358
|
-
|
|
400
|
+
const foreign = mine === undefined && lease !== null && (lease.holder !== kernel.hostId || lease.instance !== kernel.instance);
|
|
401
|
+
const holder = !foreign || kernel.presence === null ? null : await kernel.presence.holder(lease.instance);
|
|
402
|
+
if (foreign && (holder === null || holder.kind === "absent") && lease.expiresAt > now)
|
|
359
403
|
return { kind: "busy", until: lease.expiresAt };
|
|
404
|
+
if (holder?.kind === "alive")
|
|
405
|
+
return { kind: "busy", until: holder.until };
|
|
360
406
|
const outcome = await commit2(kernel, [
|
|
361
407
|
{
|
|
362
408
|
name,
|
|
363
409
|
target: await put2(kernel.store, "lease", { holder: kernel.hostId, instance: kernel.instance, expiresAt: now + LEASE_MS2 }, now),
|
|
364
410
|
expect: ref === null ? "absent" : ref.revision
|
|
365
|
-
}
|
|
411
|
+
},
|
|
412
|
+
...holder?.kind === "dead" ? [{ name: holder.name, target: null, expect: holder.expect }] : [],
|
|
413
|
+
...foreign ? await interruption2(kernel, session, head) : []
|
|
366
414
|
]);
|
|
367
415
|
dev2("execution", "claim", { session, head, outcome: outcome.kind });
|
|
368
416
|
if (outcome.kind !== "set") {
|
|
@@ -392,6 +440,10 @@ async function settleLive(kernel, session, head, live) {
|
|
|
392
440
|
const run = live.record.view.id;
|
|
393
441
|
if (kernel.executionState.driving.has(run))
|
|
394
442
|
return await holding(kernel.store, session, live.record) ?? { kind: "idle" };
|
|
443
|
+
if (crashLooping2(live.record)) {
|
|
444
|
+
await endRun2(kernel, session, run, { kind: "failed", failure: parkedFailure2(live.record) });
|
|
445
|
+
return null;
|
|
446
|
+
}
|
|
395
447
|
if (live.record.stopping) {
|
|
396
448
|
kernel.runs.start(session, run).abort();
|
|
397
449
|
await kernel.waits.runStopped(session, run);
|
|
@@ -427,7 +479,11 @@ async function holding(store, session, record) {
|
|
|
427
479
|
}
|
|
428
480
|
async function resume(kernel, session, head, run) {
|
|
429
481
|
const renewal = holdHead(kernel, session, head);
|
|
430
|
-
const signal = AbortSignal.any([
|
|
482
|
+
const signal = AbortSignal.any([
|
|
483
|
+
kernel.runs.start(session, run).signal,
|
|
484
|
+
renewal.lease.signal,
|
|
485
|
+
kernel.executionState.closing.signal
|
|
486
|
+
]);
|
|
431
487
|
const runtime = kernel.plugins.runtime(session);
|
|
432
488
|
const release = runtime.hold();
|
|
433
489
|
const unreadable = [];
|
|
@@ -511,6 +567,8 @@ async function drive(kernel, session, head, run) {
|
|
|
511
567
|
closing.addEventListener("abort", () => resolve(null), { once: true });
|
|
512
568
|
});
|
|
513
569
|
const ended = await Promise.race([turned, closed]);
|
|
570
|
+
if (ended === null && kernel.presence !== null)
|
|
571
|
+
kernel.executionState.undrained.add(leaseRef2(session, head));
|
|
514
572
|
const stopping = await stopRequested2(kernel.store, session, run.id);
|
|
515
573
|
const refused = renewal.refused();
|
|
516
574
|
if (refused !== null) {
|
|
@@ -1,26 +1,39 @@
|
|
|
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
|
+
commit2
|
|
22
|
+
} from "./compose-pnsvwd3m.js";
|
|
11
23
|
import {
|
|
12
24
|
closable2
|
|
13
25
|
} from "./compose-zfjxkavf.js";
|
|
14
26
|
import {
|
|
27
|
+
readJob2,
|
|
15
28
|
waitFor2
|
|
16
|
-
} from "./compose-
|
|
29
|
+
} from "./compose-ks2rdteq.js";
|
|
17
30
|
import {
|
|
18
31
|
send2
|
|
19
|
-
} from "./compose-
|
|
32
|
+
} from "./compose-pe0cgbv0.js";
|
|
20
33
|
import {
|
|
21
34
|
recordAcquisition2,
|
|
22
35
|
recordedAcquisition2
|
|
23
|
-
} from "./compose-
|
|
36
|
+
} from "./compose-eemt6sea.js";
|
|
24
37
|
|
|
25
38
|
// src/engine/jobs.ts
|
|
26
39
|
import { asId, asSeq, foldJobChange, SdkError } from "@nyte-ai/schema";
|
|
@@ -30,6 +43,8 @@ var READER_BYTES = 64 * 1024;
|
|
|
30
43
|
var ORPHAN_MS = 60000;
|
|
31
44
|
var REPORT_BYTES = 4096;
|
|
32
45
|
var ENDED_KEPT = 32;
|
|
46
|
+
var ENDED_JOB_MS = 60 * 60000;
|
|
47
|
+
var LOST = { kind: "lost" };
|
|
33
48
|
function createJobTable2(kernel) {
|
|
34
49
|
const entries = new Map;
|
|
35
50
|
const starts = new Map;
|
|
@@ -243,6 +258,10 @@ async function endJob(kernel, id, end) {
|
|
|
243
258
|
const entry = kernel.jobs.get(id);
|
|
244
259
|
if (entry === undefined || entry.view.state.kind !== "running")
|
|
245
260
|
return;
|
|
261
|
+
const recorded = entry.owner === null ? true : await recordJobEnd(kernel, id, end).catch((error) => {
|
|
262
|
+
dev2("jobs", "end not stored", { job: id, error: String(error) });
|
|
263
|
+
return false;
|
|
264
|
+
});
|
|
246
265
|
kernel.jobs.update(id, (view) => ({
|
|
247
266
|
...view,
|
|
248
267
|
state: end,
|
|
@@ -252,7 +271,7 @@ async function endJob(kernel, id, end) {
|
|
|
252
271
|
entry.output.end(end.kind === "exited" ? end.code : null);
|
|
253
272
|
const consumed = await kernel.waits.jobEnded(id, end);
|
|
254
273
|
const owner = entry.owner;
|
|
255
|
-
if (consumed || owner === null)
|
|
274
|
+
if (consumed || owner === null || !recorded)
|
|
256
275
|
return;
|
|
257
276
|
await send2(kernel, {
|
|
258
277
|
session: owner.session,
|
|
@@ -293,13 +312,40 @@ async function spawn(kernel, origin, workspace, input, id, digest) {
|
|
|
293
312
|
throw new SdkError("invalid", `Session ${input.session} is not on workspace ${workspace}.`);
|
|
294
313
|
const runner = input.session ?? (origin !== null && await on(origin.session) ? origin.session : null);
|
|
295
314
|
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
315
|
const own = origin !== null && input.session !== undefined && origin.session === input.session;
|
|
298
316
|
const owner = input.session === undefined ? null : {
|
|
299
317
|
session: input.session,
|
|
300
318
|
head: own && origin.head !== null ? origin.head : MAIN2,
|
|
301
319
|
startedBy: own ? origin.call : null
|
|
302
320
|
};
|
|
321
|
+
if (owner !== null) {
|
|
322
|
+
const reserved = await commit2(kernel, [
|
|
323
|
+
{
|
|
324
|
+
name: jobRef2(id),
|
|
325
|
+
target: await put2(kernel.store, "job", {
|
|
326
|
+
id,
|
|
327
|
+
instance: kernel.instance,
|
|
328
|
+
workspace,
|
|
329
|
+
session: owner.session,
|
|
330
|
+
head: owner.head,
|
|
331
|
+
startedBy: owner.startedBy,
|
|
332
|
+
title: input.title ?? input.command ?? "Shell",
|
|
333
|
+
command: input.command ?? "",
|
|
334
|
+
startedAt: Date.now(),
|
|
335
|
+
end: null,
|
|
336
|
+
endedAt: null
|
|
337
|
+
}),
|
|
338
|
+
expect: "absent"
|
|
339
|
+
}
|
|
340
|
+
]);
|
|
341
|
+
if (reserved.kind !== "set")
|
|
342
|
+
throw new SdkError("stale", `Job ${id} was already started.`);
|
|
343
|
+
}
|
|
344
|
+
const process = await env.exec(input.command ?? [], { cwd: env.cwd, pty: input.pty }).catch(async (cause) => {
|
|
345
|
+
if (owner !== null)
|
|
346
|
+
await recordJobEnd(kernel, id, LOST).catch(() => false);
|
|
347
|
+
throw cause;
|
|
348
|
+
});
|
|
303
349
|
const output = createOutput(input.pty !== undefined && input.session === undefined ? {
|
|
304
350
|
orphaned: () => void process.stop().catch((error) => {
|
|
305
351
|
dev2("jobs", "orphan stop failed", { job: id, error: String(error) });
|
|
@@ -326,6 +372,69 @@ async function spawn(kernel, origin, workspace, input, id, digest) {
|
|
|
326
372
|
});
|
|
327
373
|
pump(kernel, id, process, output);
|
|
328
374
|
}
|
|
375
|
+
async function recordJobEnd(kernel, id, end) {
|
|
376
|
+
for (;; ) {
|
|
377
|
+
const found = await readJob2(kernel.store, id);
|
|
378
|
+
if (found === null || found.record.end !== null)
|
|
379
|
+
return false;
|
|
380
|
+
const outcome = await commit2(kernel, [
|
|
381
|
+
{
|
|
382
|
+
name: jobRef2(id),
|
|
383
|
+
target: await put2(kernel.store, "job", { ...found.record, end }),
|
|
384
|
+
expect: found.ref.revision
|
|
385
|
+
}
|
|
386
|
+
]);
|
|
387
|
+
if (outcome.kind === "set")
|
|
388
|
+
return true;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
async function reapJobs2(kernel) {
|
|
392
|
+
const presence = kernel.presence;
|
|
393
|
+
if (presence === null)
|
|
394
|
+
return;
|
|
395
|
+
for (const ref of await kernel.store.refs.list(JOBS2)) {
|
|
396
|
+
const found = await load2(kernel.store, ref, decodeJobRecord2);
|
|
397
|
+
if (found === null)
|
|
398
|
+
continue;
|
|
399
|
+
const { record } = found;
|
|
400
|
+
if (record.end !== null) {
|
|
401
|
+
if (Date.now() - (record.endedAt ?? record.startedAt) > ENDED_JOB_MS)
|
|
402
|
+
await commit2(kernel, [{ name: ref.name, target: null, expect: ref.revision }]);
|
|
403
|
+
continue;
|
|
404
|
+
}
|
|
405
|
+
if (record.instance === kernel.instance)
|
|
406
|
+
continue;
|
|
407
|
+
const holder = await presence.holder(record.instance);
|
|
408
|
+
if (holder.kind !== "dead" && holder.kind !== "absent")
|
|
409
|
+
continue;
|
|
410
|
+
const reaped = await commit2(kernel, [
|
|
411
|
+
{
|
|
412
|
+
name: ref.name,
|
|
413
|
+
target: await put2(kernel.store, "job", { ...record, end: LOST, endedAt: Date.now() }),
|
|
414
|
+
expect: ref.revision
|
|
415
|
+
},
|
|
416
|
+
...holder.kind === "dead" ? [{ name: holder.name, target: null, expect: holder.expect }] : []
|
|
417
|
+
]);
|
|
418
|
+
if (reaped.kind !== "set")
|
|
419
|
+
continue;
|
|
420
|
+
dev2("jobs", "abandoned", { job: record.id, instance: record.instance });
|
|
421
|
+
if (await kernel.waits.jobEnded(record.id, LOST))
|
|
422
|
+
continue;
|
|
423
|
+
await send2(kernel, {
|
|
424
|
+
session: record.session,
|
|
425
|
+
head: record.head,
|
|
426
|
+
context: CORE_CONTEXT2,
|
|
427
|
+
content: abandonedReport(record),
|
|
428
|
+
options: { source: { kind: "job", job: record.id }, delivery: "attach" }
|
|
429
|
+
}).catch(() => {
|
|
430
|
+
return;
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
function abandonedReport(record) {
|
|
435
|
+
const named = record.command === "" ? record.title : `${record.title} (${record.command})`;
|
|
436
|
+
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.`;
|
|
437
|
+
}
|
|
329
438
|
async function acquire2(kernel, step, key, create, release) {
|
|
330
439
|
if (step === null || step.call === null)
|
|
331
440
|
return { kind: "created", value: await create() };
|
|
@@ -530,4 +639,4 @@ function report(view, end, tail) {
|
|
|
530
639
|
${text}`;
|
|
531
640
|
}
|
|
532
641
|
|
|
533
|
-
export { createJobTable2, createJobs2, jobHandle2, acquire2 };
|
|
642
|
+
export { createJobTable2, createJobs2, jobHandle2, reapJobs2, acquire2 };
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import {
|
|
2
2
|
envelope2
|
|
3
|
-
} from "./compose-
|
|
3
|
+
} from "./compose-gxjc6vz9.js";
|
|
4
4
|
import {
|
|
5
5
|
partRef2,
|
|
6
6
|
workspaceRef2,
|
|
7
7
|
trustRef2,
|
|
8
8
|
leaseRef2
|
|
9
|
-
} from "./compose-
|
|
9
|
+
} from "./compose-cqpjcx2t.js";
|
|
10
10
|
import {
|
|
11
11
|
publishSet2
|
|
12
|
-
} from "./compose-
|
|
12
|
+
} from "./compose-rd5e5nxg.js";
|
|
13
13
|
import {
|
|
14
14
|
newRun2,
|
|
15
15
|
begin2
|
|
16
|
-
} from "./compose-
|
|
16
|
+
} from "./compose-jehg40ce.js";
|
|
17
17
|
import {
|
|
18
18
|
createHostState2
|
|
19
19
|
} from "./compose-xm52jghq.js";
|
|
20
20
|
import {
|
|
21
21
|
createHost2
|
|
22
|
-
} from "./compose-
|
|
22
|
+
} from "./compose-q1d09qpr.js";
|
|
23
23
|
import {
|
|
24
24
|
createKernel2
|
|
25
|
-
} from "./compose-
|
|
25
|
+
} from "./compose-5489evqa.js";
|
|
26
26
|
import {
|
|
27
27
|
memoryStore2
|
|
28
|
-
} from "./compose-
|
|
28
|
+
} from "./compose-ts08bth2.js";
|
|
29
29
|
|
|
30
30
|
// src/harness.ts
|
|
31
31
|
import { asId } from "@nyte-ai/schema";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
decodeSeenRecord2
|
|
3
|
-
} from "./compose-
|
|
3
|
+
} from "./compose-gxjc6vz9.js";
|
|
4
4
|
import {
|
|
5
5
|
seenRef2
|
|
6
|
-
} from "./compose-
|
|
6
|
+
} from "./compose-cqpjcx2t.js";
|
|
7
7
|
import {
|
|
8
8
|
dev2
|
|
9
9
|
} from "./compose-n116fnmp.js";
|
|
@@ -16,13 +16,13 @@ import {
|
|
|
16
16
|
attempt2,
|
|
17
17
|
walkCommitPath2,
|
|
18
18
|
readPositionCommit2
|
|
19
|
-
} from "./compose-
|
|
19
|
+
} from "./compose-vn7b7fdj.js";
|
|
20
20
|
import {
|
|
21
21
|
commit2
|
|
22
|
-
} from "./compose-
|
|
22
|
+
} from "./compose-pnsvwd3m.js";
|
|
23
23
|
import {
|
|
24
24
|
withFold2
|
|
25
|
-
} from "./compose-
|
|
25
|
+
} from "./compose-xhtgytrh.js";
|
|
26
26
|
|
|
27
27
|
// src/fold/seen.ts
|
|
28
28
|
import { serial } from "@nyte-ai/schema/serial";
|
|
@@ -4,56 +4,58 @@ import {
|
|
|
4
4
|
createSummarizer2,
|
|
5
5
|
failLeftoverCompactions2,
|
|
6
6
|
readProviderCheckpoint2
|
|
7
|
-
} from "../../chunks/compose-
|
|
8
|
-
import"../../chunks/compose-
|
|
9
|
-
import"../../chunks/compose-
|
|
10
|
-
import"../../chunks/compose-
|
|
11
|
-
import"../../chunks/compose-
|
|
12
|
-
import"../../chunks/compose-
|
|
13
|
-
import"../../chunks/compose-
|
|
14
|
-
import"../../chunks/compose-
|
|
15
|
-
import"../../chunks/compose-
|
|
16
|
-
import"../../chunks/compose-
|
|
17
|
-
import"../../chunks/compose-
|
|
18
|
-
import"../../chunks/compose-
|
|
19
|
-
import"../../chunks/compose-
|
|
20
|
-
import"../../chunks/compose-
|
|
7
|
+
} from "../../chunks/compose-hf6xkwdw.js";
|
|
8
|
+
import"../../chunks/compose-ccrh32hd.js";
|
|
9
|
+
import"../../chunks/compose-4770pb1s.js";
|
|
10
|
+
import"../../chunks/compose-c4238qkb.js";
|
|
11
|
+
import"../../chunks/compose-bd8c5n7k.js";
|
|
12
|
+
import"../../chunks/compose-exfx5b4d.js";
|
|
13
|
+
import"../../chunks/compose-r1pxdxbw.js";
|
|
14
|
+
import"../../chunks/compose-0827b2k4.js";
|
|
15
|
+
import"../../chunks/compose-qwbe95qs.js";
|
|
16
|
+
import"../../chunks/compose-mamr4qwf.js";
|
|
17
|
+
import"../../chunks/compose-h3pch7ch.js";
|
|
18
|
+
import"../../chunks/compose-qknd62yj.js";
|
|
19
|
+
import"../../chunks/compose-57j0pme0.js";
|
|
20
|
+
import"../../chunks/compose-se7wwcq1.js";
|
|
21
|
+
import"../../chunks/compose-y9c31w4e.js";
|
|
22
|
+
import"../../chunks/compose-eemt6sea.js";
|
|
21
23
|
import"../../chunks/compose-vzvm76dn.js";
|
|
22
|
-
import"../../chunks/compose-
|
|
24
|
+
import"../../chunks/compose-pe0cgbv0.js";
|
|
23
25
|
import"../../chunks/compose-rb9gqgp9.js";
|
|
24
|
-
import"../../chunks/compose-
|
|
25
|
-
import"../../chunks/compose-
|
|
26
|
+
import"../../chunks/compose-prchdrqk.js";
|
|
27
|
+
import"../../chunks/compose-g2a1f1yx.js";
|
|
26
28
|
import"../../chunks/compose-66009v9f.js";
|
|
27
|
-
import"../../chunks/compose-
|
|
29
|
+
import"../../chunks/compose-gvrqkyn4.js";
|
|
28
30
|
import"../../chunks/compose-ac5efwd1.js";
|
|
29
|
-
import"../../chunks/compose-
|
|
30
|
-
import"../../chunks/compose-
|
|
31
|
-
import"../../chunks/compose-
|
|
32
|
-
import"../../chunks/compose-
|
|
33
|
-
import"../../chunks/compose-
|
|
34
|
-
import"../../chunks/compose-
|
|
35
|
-
import"../../chunks/compose-
|
|
36
|
-
import"../../chunks/compose-
|
|
31
|
+
import"../../chunks/compose-ks2rdteq.js";
|
|
32
|
+
import"../../chunks/compose-xhtgytrh.js";
|
|
33
|
+
import"../../chunks/compose-pnsvwd3m.js";
|
|
34
|
+
import"../../chunks/compose-rd5e5nxg.js";
|
|
35
|
+
import"../../chunks/compose-6r5ymwyr.js";
|
|
36
|
+
import"../../chunks/compose-a7k9h27z.js";
|
|
37
|
+
import"../../chunks/compose-6gt28900.js";
|
|
38
|
+
import"../../chunks/compose-dbsn3bsy.js";
|
|
37
39
|
import"../../chunks/compose-1c6w12g1.js";
|
|
38
|
-
import"../../chunks/compose-
|
|
39
|
-
import"../../chunks/compose-
|
|
40
|
-
import"../../chunks/compose-
|
|
41
|
-
import"../../chunks/compose-
|
|
42
|
-
import"../../chunks/compose-
|
|
40
|
+
import"../../chunks/compose-j42p9wfs.js";
|
|
41
|
+
import"../../chunks/compose-767bb340.js";
|
|
42
|
+
import"../../chunks/compose-h14pmqv3.js";
|
|
43
|
+
import"../../chunks/compose-c2rnebv0.js";
|
|
44
|
+
import"../../chunks/compose-vn7b7fdj.js";
|
|
43
45
|
import"../../chunks/compose-rxsqmcgq.js";
|
|
44
46
|
import"../../chunks/compose-84272xbk.js";
|
|
45
|
-
import"../../chunks/compose-
|
|
47
|
+
import"../../chunks/compose-5z835ej2.js";
|
|
46
48
|
import"../../chunks/compose-bjx8s01m.js";
|
|
47
49
|
import"../../chunks/compose-n116fnmp.js";
|
|
48
50
|
import"../../chunks/compose-zfjxkavf.js";
|
|
49
51
|
import"../../chunks/compose-bj54tkph.js";
|
|
50
52
|
import"../../chunks/compose-sd0stm97.js";
|
|
51
|
-
import"../../chunks/compose-
|
|
52
|
-
import"../../chunks/compose-
|
|
53
|
+
import"../../chunks/compose-kwkna3cg.js";
|
|
54
|
+
import"../../chunks/compose-nj4nj5n9.js";
|
|
53
55
|
import"../../chunks/compose-0wq555bd.js";
|
|
54
|
-
import"../../chunks/compose-
|
|
55
|
-
import"../../chunks/compose-
|
|
56
|
-
import"../../chunks/compose-
|
|
56
|
+
import"../../chunks/compose-csh5vv2t.js";
|
|
57
|
+
import"../../chunks/compose-cqpjcx2t.js";
|
|
58
|
+
import"../../chunks/compose-gxjc6vz9.js";
|
|
57
59
|
import"../../chunks/compose-ry29956g.js";
|
|
58
60
|
import"../../chunks/compose-q6c7wswc.js";
|
|
59
61
|
export {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ImageContent, TextContent } from "@nyte-ai/schema/model";
|
|
2
|
+
import type { ImageProcessor } from "../contract/host.ts";
|
|
3
|
+
export declare function modelImage(images: ImageProcessor | null, file: {
|
|
4
|
+
readonly bytes: Uint8Array;
|
|
5
|
+
readonly mime: string;
|
|
6
|
+
readonly name: string;
|
|
7
|
+
}): Promise<readonly (TextContent | ImageContent)[]>;
|