@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,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
decodeRunRecord2
|
|
3
|
-
} from "./compose-
|
|
3
|
+
} from "./compose-gxjc6vz9.js";
|
|
4
4
|
import {
|
|
5
5
|
objectId2
|
|
6
6
|
} from "./compose-q6c7wswc.js";
|
|
@@ -8,44 +8,49 @@ import {
|
|
|
8
8
|
runRef2,
|
|
9
9
|
endedRunRef2,
|
|
10
10
|
workspaceRef2
|
|
11
|
-
} from "./compose-
|
|
11
|
+
} from "./compose-cqpjcx2t.js";
|
|
12
12
|
import {
|
|
13
13
|
MAIN2,
|
|
14
14
|
STALE2,
|
|
15
15
|
load2,
|
|
16
16
|
readSession2,
|
|
17
17
|
liveRuns2,
|
|
18
|
+
threadStart2,
|
|
18
19
|
put2,
|
|
19
20
|
attempt2,
|
|
20
21
|
listSessionRecords2
|
|
21
|
-
} from "./compose-
|
|
22
|
+
} from "./compose-vn7b7fdj.js";
|
|
23
|
+
import {
|
|
24
|
+
commit2
|
|
25
|
+
} from "./compose-bbhk8vnr.js";
|
|
22
26
|
import {
|
|
23
27
|
latest2,
|
|
24
28
|
closable2,
|
|
25
29
|
coalesce2
|
|
26
30
|
} from "./compose-zfjxkavf.js";
|
|
27
|
-
import {
|
|
28
|
-
commit2
|
|
29
|
-
} from "./compose-xpfr4wt3.js";
|
|
30
31
|
import {
|
|
31
32
|
createJobs2,
|
|
32
33
|
jobHandle2
|
|
33
|
-
} from "./compose-
|
|
34
|
+
} from "./compose-nkxwrphm.js";
|
|
34
35
|
import {
|
|
35
36
|
inspectWorkspaceAvailability2,
|
|
36
37
|
readWorkspace2,
|
|
37
38
|
workspaceRecords2
|
|
38
|
-
} from "./compose-
|
|
39
|
+
} from "./compose-4ppmas7g.js";
|
|
39
40
|
import {
|
|
40
41
|
readFolderTrust2,
|
|
41
42
|
decideTrust2
|
|
42
|
-
} from "./compose-
|
|
43
|
+
} from "./compose-8pp3vtv0.js";
|
|
43
44
|
import {
|
|
44
45
|
dropScans2
|
|
45
|
-
} from "./compose-
|
|
46
|
+
} from "./compose-jmmyw9hd.js";
|
|
46
47
|
import {
|
|
47
48
|
mcpApi2
|
|
48
|
-
} from "./compose-
|
|
49
|
+
} from "./compose-gj2ypr7q.js";
|
|
50
|
+
import {
|
|
51
|
+
readAttributedPaths2,
|
|
52
|
+
ownedChanges2
|
|
53
|
+
} from "./compose-yfcb6w2h.js";
|
|
49
54
|
|
|
50
55
|
// src/env/workspaces.ts
|
|
51
56
|
import { asId, SdkError } from "@nyte-ai/schema";
|
|
@@ -264,13 +269,13 @@ function workspaceHandle2(kernel, context, id, client = null) {
|
|
|
264
269
|
},
|
|
265
270
|
jobs: createJobs2(kernel, context, id),
|
|
266
271
|
job: (job) => jobHandle2(kernel, job),
|
|
267
|
-
async changes(
|
|
272
|
+
async changes(source) {
|
|
268
273
|
const found = await snapshots();
|
|
269
|
-
const range = await
|
|
270
|
-
return
|
|
274
|
+
const range = await changeRange(kernel.store, id, source, found);
|
|
275
|
+
return source.kind === "session" ? ownedChanges2(kernel.store, found, source.session, range.to) : found.diff(range.from, range.to);
|
|
271
276
|
},
|
|
272
|
-
patches(
|
|
273
|
-
return streamWorkspacePatches(kernel, { workspace: id,
|
|
277
|
+
patches(source, paths, options) {
|
|
278
|
+
return streamWorkspacePatches(kernel, { workspace: id, source, paths, options, snapshots });
|
|
274
279
|
},
|
|
275
280
|
files: async () => (await capabilities()).files,
|
|
276
281
|
git: async () => (await capabilities()).git,
|
|
@@ -314,14 +319,12 @@ function settle2(kernel, session, workspace, activation) {
|
|
|
314
319
|
changed2(kernel, workspace);
|
|
315
320
|
}
|
|
316
321
|
async function* streamWorkspacePatches(kernel, input) {
|
|
317
|
-
const {
|
|
322
|
+
const { source, options } = input;
|
|
318
323
|
const snapshots = await input.snapshots();
|
|
319
|
-
const
|
|
320
|
-
const from = range?.from ?? await snapshots.before(run);
|
|
321
|
-
const to = range?.to ?? await snapshots.after(run);
|
|
324
|
+
const { from, to } = await changeRange(kernel.store, input.workspace, source, snapshots);
|
|
322
325
|
let statuses = null;
|
|
323
326
|
const caches = kernel.workspaceState.patches;
|
|
324
|
-
const key = JSON.stringify([input.workspace,
|
|
327
|
+
const key = JSON.stringify([input.workspace, source, options?.ignoreWhitespace === true]);
|
|
325
328
|
const previous = caches.get(key);
|
|
326
329
|
const current = previous?.revision === to ? previous : { revision: to, slots: new Map };
|
|
327
330
|
caches.delete(key);
|
|
@@ -332,7 +335,8 @@ async function* streamWorkspacePatches(kernel, input) {
|
|
|
332
335
|
caches.delete(oldest);
|
|
333
336
|
}
|
|
334
337
|
const held = previous === current ? null : previous ?? null;
|
|
335
|
-
const
|
|
338
|
+
const attributed = source.kind === "session" ? await readAttributedPaths2(kernel.store, source.session) : null;
|
|
339
|
+
const paths = [...new Set(input.paths)].filter((path) => attributed === null || attributed.has(path));
|
|
336
340
|
const unread = paths.filter((path) => !current.slots.has(path));
|
|
337
341
|
const limit = limiter(PATCH_READS);
|
|
338
342
|
const mine = new Map;
|
|
@@ -424,6 +428,42 @@ function limiter(size) {
|
|
|
424
428
|
queue.push(run);
|
|
425
429
|
});
|
|
426
430
|
}
|
|
431
|
+
async function changeRange(store, workspace, source, snapshots) {
|
|
432
|
+
switch (source.kind) {
|
|
433
|
+
case "run": {
|
|
434
|
+
const range = await runSnapshots(store, workspace, source.run);
|
|
435
|
+
return {
|
|
436
|
+
from: range?.from ?? await snapshots.before(source.run),
|
|
437
|
+
to: range?.to ?? await snapshots.after(source.run)
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
case "session":
|
|
441
|
+
return sessionSnapshots(store, source.session, snapshots);
|
|
442
|
+
default: {
|
|
443
|
+
const _exhaustive = source;
|
|
444
|
+
return _exhaustive;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
async function sessionSnapshots(store, session, snapshots) {
|
|
449
|
+
const [found, from] = await Promise.all([
|
|
450
|
+
readSession2(store, session),
|
|
451
|
+
threadStart2(store, session)
|
|
452
|
+
]);
|
|
453
|
+
if (found === null || from === null)
|
|
454
|
+
throw new SdkError("unavailable", `No run of session ${session} has snapshotted its workspace.`);
|
|
455
|
+
const [live] = await liveRuns2(store, session);
|
|
456
|
+
if (live !== undefined)
|
|
457
|
+
return { from, to: await snapshots.after(live.record.view.id) };
|
|
458
|
+
const [last] = found.record.heads.flatMap((head) => head.lastRun === null ? [] : [head.lastRun]).toSorted((left, right) => right.endedAt - left.endedAt);
|
|
459
|
+
if (last === undefined)
|
|
460
|
+
return { from, to: from };
|
|
461
|
+
const ended = await load2(store, await store.refs.get(endedRunRef2(session, last.id)), decodeRunRecord2);
|
|
462
|
+
return {
|
|
463
|
+
from,
|
|
464
|
+
to: ended?.record.lastSnapshot ?? ended?.record.snapshot ?? await snapshots.after(last.id)
|
|
465
|
+
};
|
|
466
|
+
}
|
|
427
467
|
async function runSnapshots(store, workspace, run) {
|
|
428
468
|
for (const session of await sessionsOn2(store, workspace)) {
|
|
429
469
|
const live = await load2(store, await store.refs.get(runRef2(session, run)), decodeRunRecord2);
|
|
@@ -3,22 +3,22 @@ import {
|
|
|
3
3
|
} from "./compose-bj54tkph.js";
|
|
4
4
|
import {
|
|
5
5
|
tool2
|
|
6
|
-
} from "./compose-
|
|
6
|
+
} from "./compose-fqsqjbrf.js";
|
|
7
7
|
import {
|
|
8
8
|
decodePartRecord2
|
|
9
|
-
} from "./compose-
|
|
9
|
+
} from "./compose-gxjc6vz9.js";
|
|
10
10
|
import {
|
|
11
11
|
parseSessionRef2,
|
|
12
12
|
headRef2,
|
|
13
13
|
partRef2
|
|
14
|
-
} from "./compose-
|
|
14
|
+
} from "./compose-cqpjcx2t.js";
|
|
15
15
|
import {
|
|
16
16
|
load2,
|
|
17
17
|
readRefExpectation2,
|
|
18
18
|
put2,
|
|
19
19
|
toCommitObjectId2,
|
|
20
20
|
readCall2
|
|
21
|
-
} from "./compose-
|
|
21
|
+
} from "./compose-vn7b7fdj.js";
|
|
22
22
|
|
|
23
23
|
// src/store/parts.ts
|
|
24
24
|
import { asId } from "@nyte-ai/schema";
|
|
@@ -4,14 +4,14 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
walkCommitPath2,
|
|
6
6
|
readPositionCommit2
|
|
7
|
-
} from "./compose-
|
|
7
|
+
} from "./compose-vn7b7fdj.js";
|
|
8
8
|
import {
|
|
9
9
|
committed2,
|
|
10
10
|
setTurn2,
|
|
11
11
|
stale2,
|
|
12
12
|
reuse2,
|
|
13
13
|
toPartMessageId2
|
|
14
|
-
} from "./compose-
|
|
14
|
+
} from "./compose-h14pmqv3.js";
|
|
15
15
|
|
|
16
16
|
// src/fold/paths.ts
|
|
17
17
|
function finish2(state, draft) {
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./compose-q6c7wswc.js";
|
|
4
4
|
import {
|
|
5
5
|
workspaceRef2
|
|
6
|
-
} from "./compose-
|
|
6
|
+
} from "./compose-cqpjcx2t.js";
|
|
7
7
|
import {
|
|
8
8
|
dev2
|
|
9
9
|
} from "./compose-n116fnmp.js";
|
|
@@ -11,19 +11,19 @@ import {
|
|
|
11
11
|
STALE2,
|
|
12
12
|
put2,
|
|
13
13
|
attempt2
|
|
14
|
-
} from "./compose-
|
|
14
|
+
} from "./compose-vn7b7fdj.js";
|
|
15
15
|
import {
|
|
16
16
|
commit2
|
|
17
|
-
} from "./compose-
|
|
17
|
+
} from "./compose-bbhk8vnr.js";
|
|
18
18
|
import {
|
|
19
19
|
readWorkspace2,
|
|
20
20
|
workspaceRecords2
|
|
21
|
-
} from "./compose-
|
|
21
|
+
} from "./compose-4ppmas7g.js";
|
|
22
22
|
import {
|
|
23
23
|
sessionsOn2,
|
|
24
24
|
byIdentity2,
|
|
25
25
|
changed2
|
|
26
|
-
} from "./compose-
|
|
26
|
+
} from "./compose-d1m94kzq.js";
|
|
27
27
|
|
|
28
28
|
// src/env/worktrees.ts
|
|
29
29
|
import { asId, SdkError } from "@nyte-ai/schema";
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CORE_CONTEXT2
|
|
3
|
+
} from "./compose-5z835ej2.js";
|
|
1
4
|
import {
|
|
2
5
|
decodeSessionRecord2,
|
|
3
6
|
decodeSeenRecord2
|
|
4
|
-
} from "./compose-
|
|
7
|
+
} from "./compose-gxjc6vz9.js";
|
|
5
8
|
import {
|
|
6
9
|
objectId2
|
|
7
10
|
} from "./compose-q6c7wswc.js";
|
|
@@ -10,7 +13,7 @@ import {
|
|
|
10
13
|
headRef2,
|
|
11
14
|
seenRef2,
|
|
12
15
|
workspaceRef2
|
|
13
|
-
} from "./compose-
|
|
16
|
+
} from "./compose-cqpjcx2t.js";
|
|
14
17
|
import {
|
|
15
18
|
MAIN2,
|
|
16
19
|
STALE2,
|
|
@@ -24,7 +27,7 @@ import {
|
|
|
24
27
|
attempt2,
|
|
25
28
|
coversRecord2,
|
|
26
29
|
sessionEvent2
|
|
27
|
-
} from "./compose-
|
|
30
|
+
} from "./compose-vn7b7fdj.js";
|
|
28
31
|
import {
|
|
29
32
|
traced2,
|
|
30
33
|
followTrace2,
|
|
@@ -32,10 +35,10 @@ import {
|
|
|
32
35
|
} from "./compose-sd0stm97.js";
|
|
33
36
|
import {
|
|
34
37
|
commit2
|
|
35
|
-
} from "./compose-
|
|
38
|
+
} from "./compose-bbhk8vnr.js";
|
|
36
39
|
import {
|
|
37
40
|
stopRun2
|
|
38
|
-
} from "./compose-
|
|
41
|
+
} from "./compose-w6zb11k1.js";
|
|
39
42
|
import {
|
|
40
43
|
refusalError2,
|
|
41
44
|
staticContributions2
|
|
@@ -44,17 +47,17 @@ import {
|
|
|
44
47
|
receiptHandle2,
|
|
45
48
|
sendReceipt2,
|
|
46
49
|
withdraw2
|
|
47
|
-
} from "./compose-
|
|
50
|
+
} from "./compose-fnncnk81.js";
|
|
48
51
|
import {
|
|
49
52
|
sendNow2,
|
|
50
53
|
admitDeciding2
|
|
51
|
-
} from "./compose-
|
|
54
|
+
} from "./compose-t9fcqtby.js";
|
|
52
55
|
import {
|
|
53
56
|
recordAcquisition2
|
|
54
|
-
} from "./compose-
|
|
57
|
+
} from "./compose-byse0eqj.js";
|
|
55
58
|
import {
|
|
56
59
|
runHandle2
|
|
57
|
-
} from "./compose-
|
|
60
|
+
} from "./compose-qxfq6dn9.js";
|
|
58
61
|
import {
|
|
59
62
|
latest2,
|
|
60
63
|
closable2,
|
|
@@ -63,29 +66,29 @@ import {
|
|
|
63
66
|
import {
|
|
64
67
|
isolateWorkspace2,
|
|
65
68
|
releaseWorktree2
|
|
66
|
-
} from "./compose-
|
|
69
|
+
} from "./compose-e2fyz3xc.js";
|
|
67
70
|
import {
|
|
68
71
|
releaseStart2,
|
|
69
72
|
stopStart2,
|
|
70
73
|
discardSession2
|
|
71
|
-
} from "./compose-
|
|
74
|
+
} from "./compose-a8ddt55n.js";
|
|
72
75
|
import {
|
|
73
76
|
runCommand2,
|
|
74
77
|
completeSessionCommand2
|
|
75
|
-
} from "./compose-
|
|
78
|
+
} from "./compose-ae5t6v5b.js";
|
|
76
79
|
import {
|
|
77
80
|
configure2
|
|
78
|
-
} from "./compose-
|
|
81
|
+
} from "./compose-753gc057.js";
|
|
79
82
|
import {
|
|
80
83
|
headHandle2,
|
|
81
84
|
createHead2,
|
|
82
85
|
mergeHead2,
|
|
83
86
|
removeHead2
|
|
84
|
-
} from "./compose-
|
|
87
|
+
} from "./compose-1r0wr5dc.js";
|
|
85
88
|
import {
|
|
86
89
|
createPart2,
|
|
87
90
|
partHandle2
|
|
88
|
-
} from "./compose-
|
|
91
|
+
} from "./compose-r8tz1xfj.js";
|
|
89
92
|
|
|
90
93
|
// src/api/session.ts
|
|
91
94
|
import { asId, SdkError } from "@nyte-ai/schema";
|
|
@@ -301,11 +304,11 @@ async function start(kernel, context, input) {
|
|
|
301
304
|
const trace = (origin === null ? null : followedTrace2(origin.session)) ?? receipt;
|
|
302
305
|
followTrace2(id, trace);
|
|
303
306
|
return traced2("host.admit", trace, { session: id }, async () => {
|
|
304
|
-
await attempt2(`Starting ${id}`, async () => {
|
|
307
|
+
const chosen = await attempt2(`Starting ${id}`, async () => {
|
|
305
308
|
if (await readSession2(kernel.store, id) !== null) {
|
|
306
309
|
const started = (await readReceipt2(kernel.store, id, receipt))?.record;
|
|
307
310
|
if (started?.kind === "send" && started.digest === digest)
|
|
308
|
-
return
|
|
311
|
+
return null;
|
|
309
312
|
throw new SdkError("invalid", `Session ${id} already exists.`);
|
|
310
313
|
}
|
|
311
314
|
const parent = input.parent === undefined ? null : await requireSession2(kernel.store, input.parent);
|
|
@@ -356,9 +359,11 @@ async function start(kernel, context, input) {
|
|
|
356
359
|
principal: context.principal
|
|
357
360
|
})
|
|
358
361
|
]);
|
|
359
|
-
return outcome.kind === "set" ?
|
|
362
|
+
return outcome.kind === "set" ? selected : STALE2;
|
|
360
363
|
});
|
|
361
364
|
await releaseStart2(kernel, context, id);
|
|
365
|
+
if (chosen !== null && context !== CORE_CONTEXT2 && origin === null && context.authority.has("owner"))
|
|
366
|
+
await kernel.rememberChoice(chosen, "model");
|
|
362
367
|
return id;
|
|
363
368
|
});
|
|
364
369
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
LOCAL2
|
|
3
|
-
} from "./compose-
|
|
3
|
+
} from "./compose-5z835ej2.js";
|
|
4
4
|
import {
|
|
5
5
|
inboxRef2,
|
|
6
6
|
receiptRef2
|
|
7
|
-
} from "./compose-
|
|
7
|
+
} from "./compose-cqpjcx2t.js";
|
|
8
8
|
import {
|
|
9
9
|
STALE2,
|
|
10
10
|
readReceipt2,
|
|
@@ -13,19 +13,19 @@ import {
|
|
|
13
13
|
readRefExpectation2,
|
|
14
14
|
put2,
|
|
15
15
|
attempt2
|
|
16
|
-
} from "./compose-
|
|
16
|
+
} from "./compose-vn7b7fdj.js";
|
|
17
17
|
import {
|
|
18
18
|
commit2
|
|
19
|
-
} from "./compose-
|
|
19
|
+
} from "./compose-bbhk8vnr.js";
|
|
20
20
|
import {
|
|
21
21
|
withFold2
|
|
22
|
-
} from "./compose-
|
|
22
|
+
} from "./compose-xhtgytrh.js";
|
|
23
23
|
import {
|
|
24
24
|
waitFor2
|
|
25
|
-
} from "./compose-
|
|
25
|
+
} from "./compose-bz70g01d.js";
|
|
26
26
|
import {
|
|
27
27
|
stopRun2
|
|
28
|
-
} from "./compose-
|
|
28
|
+
} from "./compose-w6zb11k1.js";
|
|
29
29
|
|
|
30
30
|
// src/engine/receipts.ts
|
|
31
31
|
import { asId, SdkError } from "@nyte-ai/schema";
|
|
@@ -44,7 +44,7 @@ var thinking2 = definePart2({
|
|
|
44
44
|
var tool2 = definePart2({
|
|
45
45
|
kind: "tool",
|
|
46
46
|
state: ToolPartStateSchema,
|
|
47
|
-
actions: { stop: { input: EMPTY_INPUT } },
|
|
47
|
+
actions: { stop: { input: EMPTY_INPUT }, background: { input: EMPTY_INPUT } },
|
|
48
48
|
fallback: (state, { id }) => `${clip(state.name)} ${state.phase}${state.phase === "settled" ? ` ${state.outcome.kind}` : ""} [${id}]`
|
|
49
49
|
});
|
|
50
50
|
var compaction2 = definePart2({
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
requireSession2
|
|
3
|
-
} from "./compose-
|
|
3
|
+
} from "./compose-vn7b7fdj.js";
|
|
4
4
|
import {
|
|
5
5
|
forwarded2
|
|
6
6
|
} from "./compose-zfjxkavf.js";
|
|
7
7
|
import {
|
|
8
8
|
readWorkspace2
|
|
9
|
-
} from "./compose-
|
|
9
|
+
} from "./compose-4ppmas7g.js";
|
|
10
10
|
import {
|
|
11
11
|
projectTrust2
|
|
12
|
-
} from "./compose-
|
|
12
|
+
} from "./compose-8pp3vtv0.js";
|
|
13
13
|
|
|
14
14
|
// src/env/mcp.ts
|
|
15
15
|
import { SdkError } from "@nyte-ai/schema";
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import {
|
|
2
|
+
envelope2
|
|
3
|
+
} from "./compose-gxjc6vz9.js";
|
|
4
|
+
import {
|
|
5
|
+
PROCESSES2,
|
|
6
|
+
processRef2
|
|
7
|
+
} from "./compose-cqpjcx2t.js";
|
|
8
|
+
import {
|
|
9
|
+
dev2
|
|
10
|
+
} from "./compose-n116fnmp.js";
|
|
11
|
+
|
|
12
|
+
// src/engine/presence.ts
|
|
13
|
+
import { SdkError } from "@nyte-ai/schema";
|
|
14
|
+
var BEAT_MS2 = 5000;
|
|
15
|
+
var LAPSE_MS2 = 20000;
|
|
16
|
+
var FORGET_MS = 10 * 60000;
|
|
17
|
+
var GAP_MS = 2 * BEAT_MS2;
|
|
18
|
+
var REVOKED2 = "Another Nyte took over this one's work while it was paused, so this host stopped; it reopens on its own.";
|
|
19
|
+
async function openPresence2(raw, input) {
|
|
20
|
+
const name = processRef2(input.instance);
|
|
21
|
+
const body = envelope2("process", {
|
|
22
|
+
instance: input.instance,
|
|
23
|
+
holder: input.holder,
|
|
24
|
+
label: input.member.label,
|
|
25
|
+
pid: input.member.pid,
|
|
26
|
+
capabilities: [...input.member.capabilities],
|
|
27
|
+
startedAt: Date.now()
|
|
28
|
+
}, Date.now());
|
|
29
|
+
const target = await raw.objects.put(body);
|
|
30
|
+
const registered = await raw.refs.set([{ name, target, expect: "absent" }]);
|
|
31
|
+
if (registered.kind !== "set")
|
|
32
|
+
throw new SdkError("internal", `${name} already exists; process instances must be unique.`);
|
|
33
|
+
let revision = registered.revisions[0];
|
|
34
|
+
const revocation = new AbortController;
|
|
35
|
+
const seen = new Map;
|
|
36
|
+
let wroteAt = performance.now();
|
|
37
|
+
let beating = false;
|
|
38
|
+
let closed = false;
|
|
39
|
+
const revoke = () => {
|
|
40
|
+
if (revocation.signal.aborted)
|
|
41
|
+
return;
|
|
42
|
+
dev2("presence", "revoked", { instance: input.instance });
|
|
43
|
+
clearInterval(timer);
|
|
44
|
+
revocation.abort();
|
|
45
|
+
};
|
|
46
|
+
const wrote = () => {
|
|
47
|
+
const now = performance.now();
|
|
48
|
+
if (now - wroteAt > GAP_MS)
|
|
49
|
+
for (const entry of seen.values())
|
|
50
|
+
entry.since = now;
|
|
51
|
+
wroteAt = now;
|
|
52
|
+
};
|
|
53
|
+
const writable = (now) => now - wroteAt <= GAP_MS;
|
|
54
|
+
const observe = (instance, current, now) => {
|
|
55
|
+
const known = seen.get(instance);
|
|
56
|
+
if (known !== undefined && known.revision === current)
|
|
57
|
+
return known;
|
|
58
|
+
const fresh = { revision: current, since: now };
|
|
59
|
+
seen.set(instance, fresh);
|
|
60
|
+
return fresh;
|
|
61
|
+
};
|
|
62
|
+
const beat = async () => {
|
|
63
|
+
if (beating || closed || revocation.signal.aborted)
|
|
64
|
+
return;
|
|
65
|
+
beating = true;
|
|
66
|
+
try {
|
|
67
|
+
const outcome = await raw.refs.set([{ name, target, expect: revision }]);
|
|
68
|
+
if (outcome.kind !== "set")
|
|
69
|
+
return revoke();
|
|
70
|
+
revision = outcome.revisions[0];
|
|
71
|
+
wrote();
|
|
72
|
+
} catch (error) {
|
|
73
|
+
dev2("presence", "beat failed", {
|
|
74
|
+
error: error instanceof Error ? error.message : String(error)
|
|
75
|
+
});
|
|
76
|
+
} finally {
|
|
77
|
+
beating = false;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const timer = setInterval(() => void beat(), BEAT_MS2);
|
|
81
|
+
const store = {
|
|
82
|
+
...raw,
|
|
83
|
+
refs: {
|
|
84
|
+
...raw.refs,
|
|
85
|
+
async set(updates) {
|
|
86
|
+
if (revocation.signal.aborted)
|
|
87
|
+
throw new SdkError("unavailable", REVOKED2);
|
|
88
|
+
const outcome = await raw.refs.set(updates.map((update) => ({ ...update, fences: [...update.fences ?? [], name] })));
|
|
89
|
+
if (outcome.kind === "fenced" && outcome.name === name) {
|
|
90
|
+
revoke();
|
|
91
|
+
throw new SdkError("unavailable", REVOKED2);
|
|
92
|
+
}
|
|
93
|
+
return outcome;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
return {
|
|
98
|
+
instance: input.instance,
|
|
99
|
+
member: input.member,
|
|
100
|
+
store,
|
|
101
|
+
revoked: revocation.signal,
|
|
102
|
+
async holder(instance) {
|
|
103
|
+
if (instance === input.instance)
|
|
104
|
+
return { kind: "me" };
|
|
105
|
+
const ref = await raw.refs.get(processRef2(instance));
|
|
106
|
+
const now = performance.now();
|
|
107
|
+
if (ref === null) {
|
|
108
|
+
seen.delete(instance);
|
|
109
|
+
return { kind: "absent" };
|
|
110
|
+
}
|
|
111
|
+
const lapsed = now - observe(instance, ref.revision, now).since;
|
|
112
|
+
return writable(now) && lapsed >= LAPSE_MS2 ? { kind: "dead", name: ref.name, expect: ref.revision } : { kind: "alive", until: Date.now() + Math.max(LAPSE_MS2 - lapsed, BEAT_MS2) };
|
|
113
|
+
},
|
|
114
|
+
async sweep() {
|
|
115
|
+
const listed = await raw.refs.list(PROCESSES2);
|
|
116
|
+
const now = performance.now();
|
|
117
|
+
const present = new Set;
|
|
118
|
+
for (const ref of listed) {
|
|
119
|
+
const instance = ref.name.slice(PROCESSES2.length);
|
|
120
|
+
present.add(instance);
|
|
121
|
+
if (instance === input.instance)
|
|
122
|
+
continue;
|
|
123
|
+
const known = observe(instance, ref.revision, now);
|
|
124
|
+
if (!writable(now) || now - known.since < FORGET_MS)
|
|
125
|
+
continue;
|
|
126
|
+
await raw.refs.set([{ name: ref.name, target: null, expect: ref.revision }]);
|
|
127
|
+
seen.delete(instance);
|
|
128
|
+
}
|
|
129
|
+
for (const instance of seen.keys())
|
|
130
|
+
if (!present.has(instance))
|
|
131
|
+
seen.delete(instance);
|
|
132
|
+
if (!present.has(input.instance) && !closed)
|
|
133
|
+
revoke();
|
|
134
|
+
},
|
|
135
|
+
async close(leases = []) {
|
|
136
|
+
if (closed)
|
|
137
|
+
return;
|
|
138
|
+
closed = true;
|
|
139
|
+
clearInterval(timer);
|
|
140
|
+
if (revocation.signal.aborted)
|
|
141
|
+
return;
|
|
142
|
+
const leaving = [
|
|
143
|
+
{ name, target: null, expect: revision },
|
|
144
|
+
...leases.map((lease) => ({ name: lease.name, target: null, expect: lease.expect }))
|
|
145
|
+
];
|
|
146
|
+
const left = await raw.refs.set(leaving).catch(() => null);
|
|
147
|
+
if (left?.kind !== "set")
|
|
148
|
+
await raw.refs.set([{ name, target: null, expect: revision }]).catch(() => {
|
|
149
|
+
return;
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export { BEAT_MS2, LAPSE_MS2, REVOKED2, openPresence2 };
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
cyclicWithJson,
|
|
9
9
|
HeadInfoType,
|
|
10
10
|
idSchema,
|
|
11
|
+
JobEndType,
|
|
11
12
|
isJsonObject,
|
|
12
13
|
JsonObjectType,
|
|
13
14
|
JsonType,
|
|
@@ -71,7 +72,9 @@ var RunRecordType = record({
|
|
|
71
72
|
usage: nullable(typed()(UsageType)),
|
|
72
73
|
requests: Type.Number(),
|
|
73
74
|
response: Type.Optional(typed()(UsageType)),
|
|
74
|
-
parked: list(idSchema())
|
|
75
|
+
parked: list(idSchema()),
|
|
76
|
+
interrupted: Type.Optional(record({ count: Type.Number(), mark: Type.String() })),
|
|
77
|
+
requires: Type.Optional(list(Type.String()))
|
|
75
78
|
});
|
|
76
79
|
var PartRecordType = record({
|
|
77
80
|
id: idSchema(),
|
|
@@ -174,6 +177,27 @@ var LeaseType = record({
|
|
|
174
177
|
instance: Type.String(),
|
|
175
178
|
expiresAt: Type.Number()
|
|
176
179
|
});
|
|
180
|
+
var ProcessRecordType = record({
|
|
181
|
+
instance: Type.String(),
|
|
182
|
+
holder: idSchema(),
|
|
183
|
+
label: Type.String(),
|
|
184
|
+
pid: nullable(Type.Number()),
|
|
185
|
+
capabilities: list(Type.String()),
|
|
186
|
+
startedAt: Type.Number()
|
|
187
|
+
});
|
|
188
|
+
var JobRecordType = record({
|
|
189
|
+
id: idSchema(),
|
|
190
|
+
instance: Type.String(),
|
|
191
|
+
workspace: idSchema(),
|
|
192
|
+
session: idSchema(),
|
|
193
|
+
head: idSchema(),
|
|
194
|
+
startedBy: nullable(idSchema()),
|
|
195
|
+
title: Type.String(),
|
|
196
|
+
command: Type.String(),
|
|
197
|
+
startedAt: Type.Number(),
|
|
198
|
+
end: nullable(typed()(JobEndType)),
|
|
199
|
+
endedAt: nullable(Type.Number())
|
|
200
|
+
});
|
|
177
201
|
var HostIdentityType = record({ id: idSchema(), createdAt: Type.Number() });
|
|
178
202
|
var STORED_RECORD_TYPES2 = {
|
|
179
203
|
session: SessionRecordType,
|
|
@@ -186,6 +210,8 @@ var STORED_RECORD_TYPES2 = {
|
|
|
186
210
|
workspace: WorkspaceRecordType,
|
|
187
211
|
trust: TrustRecordType,
|
|
188
212
|
lease: LeaseType,
|
|
213
|
+
process: ProcessRecordType,
|
|
214
|
+
job: JobRecordType,
|
|
189
215
|
call: CallRecordType,
|
|
190
216
|
principals: PrincipalRecordType,
|
|
191
217
|
identity: HostIdentityType
|
|
@@ -205,6 +231,8 @@ var decodeTrustRecord2 = decoder("trust", TrustRecordType);
|
|
|
205
231
|
var decodeCallRecord2 = decoder("call", CallRecordType);
|
|
206
232
|
var decodePrincipalRecord2 = decoder("principals", PrincipalRecordType);
|
|
207
233
|
var decodeLease2 = decoder("lease", LeaseType);
|
|
234
|
+
var decodeProcessRecord2 = decoder("process", ProcessRecordType);
|
|
235
|
+
var decodeJobRecord2 = decoder("job", JobRecordType);
|
|
208
236
|
var decodeHostIdentity2 = decoder("identity", HostIdentityType);
|
|
209
237
|
function decodeKvValue2(object) {
|
|
210
238
|
return isJsonObject(object) && object.kind === "kv" ? object.body : undefined;
|
|
@@ -226,4 +254,4 @@ function nullable(schema) {
|
|
|
226
254
|
return Type.Union([schema, Type.Null()]);
|
|
227
255
|
}
|
|
228
256
|
|
|
229
|
-
export { STORED_RECORD_TYPES2, envelope2, decodeSessionRecord2, decodeCommitRecord2, decodeRunRecord2, decodeSeenRecord2, decodeInboxRecord2, decodePartRecord2, decodeReceiptRecord2, decodeWorkspaceRecord2, decodeTrustRecord2, decodeCallRecord2, decodePrincipalRecord2, decodeLease2, decodeHostIdentity2, decodeKvValue2 };
|
|
257
|
+
export { STORED_RECORD_TYPES2, envelope2, decodeSessionRecord2, decodeCommitRecord2, decodeRunRecord2, decodeSeenRecord2, decodeInboxRecord2, decodePartRecord2, decodeReceiptRecord2, decodeWorkspaceRecord2, decodeTrustRecord2, decodeCallRecord2, decodePrincipalRecord2, decodeLease2, decodeProcessRecord2, decodeJobRecord2, decodeHostIdentity2, decodeKvValue2 };
|