@nyte-ai/core 0.0.24 → 0.0.25-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{compose-nj4nj5n9.js → compose-0f9x3cjd.js} +1 -1
- package/dist/chunks/{compose-yfcb6w2h.js → compose-0zrwy7nk.js} +1 -1
- package/dist/chunks/{compose-xhtgytrh.js → compose-122g5jvb.js} +1 -1
- package/dist/chunks/{compose-nkxwrphm.js → compose-17xxey5y.js} +6 -6
- package/dist/chunks/compose-1hgkp0q6.js +154 -0
- package/dist/chunks/{compose-ad80nkkn.js → compose-1kvvrw50.js} +6 -6
- package/dist/chunks/{compose-jeemzja1.js → compose-1nqjy2z5.js} +3 -3
- package/dist/chunks/compose-2e84znn8.js +62 -0
- package/dist/chunks/{compose-sprfv38c.js → compose-34cqydxc.js} +4 -4
- package/dist/chunks/{compose-ee0h1pk1.js → compose-3qkhfwtd.js} +4 -4
- package/dist/chunks/{compose-yr19b453.js → compose-4jqwbez4.js} +7 -7
- package/dist/chunks/{compose-5rg7askh.js → compose-4krv4vzw.js} +13 -5
- package/dist/chunks/{compose-byse0eqj.js → compose-4s0c5zqv.js} +6 -6
- package/dist/chunks/{compose-gj2ypr7q.js → compose-5ygdrc65.js} +3 -3
- package/dist/chunks/{compose-csh5vv2t.js → compose-6e9ktyhr.js} +1 -1
- package/dist/chunks/{compose-dbsn3bsy.js → compose-6zgf2dtw.js} +6 -3
- package/dist/chunks/{compose-ht1tbyr3.js → compose-75pnchkk.js} +22 -10
- package/dist/chunks/{compose-vzvm76dn.js → compose-79h43be5.js} +13 -5
- package/dist/chunks/compose-7bpnxft1.js +20 -0
- package/dist/chunks/{compose-jwy1gba9.js → compose-7sjf0y70.js} +3 -3
- package/dist/chunks/{compose-1tdb9ezw.js → compose-8nysak5a.js} +33 -22
- package/dist/chunks/{compose-ay7t13m9.js → compose-8p6emvvh.js} +8 -8
- package/dist/chunks/{compose-e3635qmn.js → compose-8ranx653.js} +17 -2
- package/dist/chunks/{compose-5njywhy8.js → compose-9tntshv3.js} +6 -6
- package/dist/chunks/{compose-gvm49f4b.js → compose-b10qcn9b.js} +1 -1
- package/dist/chunks/{compose-42egt9y7.js → compose-b4zb2rpb.js} +21 -12
- package/dist/chunks/{compose-767bb340.js → compose-c7jk6qr1.js} +1 -1
- package/dist/chunks/{compose-hfsn6pnt.js → compose-chcqk093.js} +39 -17
- package/dist/chunks/{compose-nw5hdpxk.js → compose-ct1h40fd.js} +8 -8
- package/dist/chunks/{compose-smsafpqe.js → compose-d5yhtpa7.js} +2 -2
- package/dist/chunks/{compose-qxfq6dn9.js → compose-d95420jw.js} +8 -8
- package/dist/chunks/{compose-gxjc6vz9.js → compose-dw8fvn94.js} +4 -2
- package/dist/chunks/{compose-fnncnk81.js → compose-dywbt4he.js} +5 -5
- package/dist/chunks/{compose-xvbyp65f.js → compose-gnfmty38.js} +30 -10
- package/dist/chunks/{compose-mdwr0er9.js → compose-h0d0vess.js} +4 -4
- package/dist/chunks/{compose-2gsbcjgv.js → compose-hf0nrd46.js} +22 -18
- package/dist/chunks/{compose-mcz93154.js → compose-ht5fhzzw.js} +10 -10
- package/dist/chunks/{compose-8pp3vtv0.js → compose-hx8j2kef.js} +4 -4
- package/dist/chunks/{compose-c4z4kp98.js → compose-j8xmyfy6.js} +118 -42
- package/dist/chunks/{compose-9jvn2wvh.js → compose-jawbhn7q.js} +21 -5
- package/dist/chunks/{compose-2rha31fc.js → compose-jbrtw0md.js} +4 -4
- package/dist/chunks/{compose-m01wspwf.js → compose-jrxg4vqg.js} +1 -1
- package/dist/chunks/{compose-bz70g01d.js → compose-kf2k4hq5.js} +5 -5
- package/dist/chunks/{compose-w6zb11k1.js → compose-kgdmzx0n.js} +6 -6
- package/dist/chunks/{compose-qjxtbzgq.js → compose-krkyrds4.js} +11 -5
- package/dist/chunks/{compose-tppkp915.js → compose-kw3bf8mf.js} +4 -4
- package/dist/chunks/{compose-d95fwwvw.js → compose-kwbs1f34.js} +2 -2
- package/dist/chunks/{compose-j42p9wfs.js → compose-n29d5dzv.js} +1 -1
- package/dist/chunks/{compose-qwbe95qs.js → compose-n5f6w2y6.js} +1 -1
- package/dist/chunks/{compose-a7k9h27z.js → compose-nc60858y.js} +4 -4
- package/dist/chunks/{compose-6r5ymwyr.js → compose-nenmmq5w.js} +30 -10
- package/dist/chunks/{compose-enq3x3rq.js → compose-p7j0gt4t.js} +22 -7
- package/dist/chunks/compose-pb3420v8.js +74 -0
- package/dist/chunks/{compose-ts08bth2.js → compose-pcfvksb2.js} +1 -1
- package/dist/chunks/{compose-917xy085.js → compose-pjkzf9ev.js} +9 -9
- package/dist/chunks/{compose-c9wxgbjp.js → compose-prek5sd9.js} +2 -2
- package/dist/chunks/{compose-h14pmqv3.js → compose-qgz6q016.js} +1 -1
- package/dist/chunks/{compose-y6xgbg2h.js → compose-qq85vkhf.js} +1 -1
- package/dist/chunks/{compose-bd8c5n7k.js → compose-qyjchprv.js} +2 -2
- package/dist/chunks/{compose-97y00axn.js → compose-rh1d2g0s.js} +30 -16
- package/dist/chunks/compose-s23st6q6.js +4 -0
- package/dist/chunks/{compose-bbhk8vnr.js → compose-s4kyfjj6.js} +2 -2
- package/dist/chunks/{compose-t9fcqtby.js → compose-sjfbxw65.js} +93 -85
- package/dist/chunks/{compose-a40dnhy5.js → compose-vphbntyn.js} +7 -7
- package/dist/chunks/compose-vxme67gg.js +63 -0
- package/dist/chunks/compose-wgs4rgfp.js +32 -0
- package/dist/chunks/{compose-1xn3eecn.js → compose-xdq54csy.js} +39 -35
- package/dist/chunks/{compose-v46qmh60.js → compose-yd5t8qj3.js} +63 -126
- package/dist/chunks/{compose-vn7b7fdj.js → compose-ydth4n0z.js} +7 -3
- package/dist/chunks/{compose-6gt28900.js → compose-yxhvzsed.js} +4 -4
- package/dist/chunks/{compose-matk94se.js → compose-zajq79k0.js} +6 -6
- package/dist/chunks/{compose-ae5t6v5b.js → compose-zq7ar8qm.js} +4 -4
- package/dist/chunks/{compose-4ppmas7g.js → compose-zt2qtrxj.js} +4 -4
- package/dist/chunks/compose-ztyjpn84.js +59 -0
- package/dist/chunks/{compose-m91ffwss.js → compose-zv0t13e7.js} +2 -2
- package/dist/chunks/{compose-r8tz1xfj.js → compose-zx78edb2.js} +9 -5
- package/dist/src/agent/agent-loop.d.ts +4 -0
- package/dist/src/agent/agent-loop.js +3 -1
- package/dist/src/agent/compaction.js +38 -37
- package/dist/src/agent/open-parts.d.ts +34 -0
- package/dist/src/agent/open-parts.js +22 -0
- package/dist/src/agent/request.js +27 -26
- package/dist/src/agent/tool-runner.d.ts +5 -5
- package/dist/src/agent/tool-runner.js +31 -30
- package/dist/src/agent/transcript.js +34 -33
- package/dist/src/agent/turn.js +48 -43
- package/dist/src/api/connection.js +61 -56
- package/dist/src/api/head.d.ts +1 -2
- package/dist/src/api/head.js +43 -39
- package/dist/src/api/hold.d.ts +7 -0
- package/dist/src/api/hold.js +7 -0
- package/dist/src/api/part.js +20 -18
- package/dist/src/api/server.js +48 -45
- package/dist/src/api/session.js +48 -44
- package/dist/src/builtins/delegation.js +1 -1
- package/dist/src/builtins/environment.d.ts +8 -0
- package/dist/src/builtins/environment.js +3 -1
- package/dist/src/builtins/interruptions.d.ts +4 -0
- package/dist/src/builtins/interruptions.js +8 -0
- package/dist/src/compose.js +75 -68
- package/dist/src/contract/host.d.ts +6 -0
- package/dist/src/contract/kernel.d.ts +9 -6
- package/dist/src/contract/parts.d.ts +48 -46
- package/dist/src/contract/records.d.ts +429 -419
- package/dist/src/contract/records.js +1 -1
- package/dist/src/contract/server.d.ts +3 -1
- package/dist/src/contract/session.d.ts +31 -1
- package/dist/src/contract/session.js +6 -0
- package/dist/src/contract/workspace.d.ts +3 -1
- package/dist/src/drive/execution.js +44 -43
- package/dist/src/drive/interruptions.d.ts +10 -2
- package/dist/src/drive/interruptions.js +9 -5
- package/dist/src/drive/pause.d.ts +11 -0
- package/dist/src/drive/pause.js +10 -0
- package/dist/src/engine/admission-writes.d.ts +22 -0
- package/dist/src/engine/admission-writes.js +15 -0
- package/dist/src/engine/admission.d.ts +15 -1
- package/dist/src/engine/admission.js +25 -20
- package/dist/src/engine/batches.js +18 -18
- package/dist/src/engine/branch-summary.js +17 -17
- package/dist/src/engine/durable.js +17 -17
- package/dist/src/engine/fence.js +16 -16
- package/dist/src/engine/holds.d.ts +4 -0
- package/dist/src/engine/holds.js +43 -0
- package/dist/src/engine/jobs.js +24 -23
- package/dist/src/engine/lease.d.ts +5 -4
- package/dist/src/engine/lease.js +1 -1
- package/dist/src/engine/move.js +19 -19
- package/dist/src/engine/presence.js +2 -2
- package/dist/src/engine/principals.js +14 -14
- package/dist/src/engine/receipts.js +17 -17
- package/dist/src/engine/runs.js +22 -21
- package/dist/src/engine/start.js +34 -33
- package/dist/src/engine/surface.js +3 -3
- package/dist/src/engine/waits.js +15 -15
- package/dist/src/env/browser.js +25 -24
- package/dist/src/env/environment.js +27 -26
- package/dist/src/env/mcp.js +29 -28
- package/dist/src/env/session-changes.js +3 -3
- package/dist/src/env/trust.js +28 -27
- package/dist/src/env/workspaces.js +32 -31
- package/dist/src/env/worktrees.js +33 -32
- package/dist/src/extend/activation.d.ts +3 -0
- package/dist/src/extend/activation.js +35 -32
- package/dist/src/extend/hooks.js +19 -19
- package/dist/src/extend/models.js +26 -25
- package/dist/src/extend/plugin-api.js +14 -14
- package/dist/src/extend/plugin-runtime.d.ts +3 -1
- package/dist/src/extend/plugin-runtime.js +39 -38
- package/dist/src/extend/registry.js +24 -23
- package/dist/src/extend/resources.js +29 -28
- package/dist/src/extend/setting-layers.js +3 -3
- package/dist/src/extend/settings.js +36 -35
- package/dist/src/extend/workspace-commands.js +40 -39
- package/dist/src/fold/calls.js +4 -4
- package/dist/src/fold/checkpoint.js +9 -9
- package/dist/src/fold/code.d.ts +1 -1
- package/dist/src/fold/code.js +1 -1
- package/dist/src/fold/commit.js +13 -13
- package/dist/src/fold/draft.d.ts +37 -37
- package/dist/src/fold/draft.js +3 -3
- package/dist/src/fold/fold.js +6 -6
- package/dist/src/fold/paths.js +4 -4
- package/dist/src/fold/project.d.ts +2 -2
- package/dist/src/fold/project.js +6 -6
- package/dist/src/fold/reads.js +3 -3
- package/dist/src/fold/seen.d.ts +3 -5
- package/dist/src/fold/seen.js +17 -17
- package/dist/src/fold/view.d.ts +7 -1
- package/dist/src/fold/view.js +8 -23
- package/dist/src/fold/watch.js +12 -12
- package/dist/src/harness.d.ts +257 -257
- package/dist/src/harness.js +78 -71
- package/dist/src/index.d.ts +3 -1
- package/dist/src/index.js +13 -3
- package/dist/src/server.js +73 -66
- package/dist/src/store/inspect.js +3 -3
- package/dist/src/store/memory-store.js +3 -3
- package/dist/src/store/migrations.js +2 -2
- package/dist/src/store/model-state.js +2 -2
- package/dist/src/store/parts.js +3 -3
- package/dist/src/store/session-index.js +2 -2
- package/dist/src/store/session.js +2 -2
- package/dist/src/store.js +5 -5
- package/dist/src/testing.js +76 -69
- package/dist/src/util/line-diff.d.ts +5 -5
- package/package.json +4 -5
- package/dist/chunks/compose-hfrjm4a1.js +0 -88
|
@@ -9,35 +9,42 @@ import {
|
|
|
9
9
|
import {
|
|
10
10
|
createWorkspaces2,
|
|
11
11
|
workspaceHandle2
|
|
12
|
-
} from "./compose-
|
|
12
|
+
} from "./compose-pjkzf9ev.js";
|
|
13
13
|
import {
|
|
14
14
|
cover2,
|
|
15
15
|
advance2,
|
|
16
16
|
repair2
|
|
17
|
-
} from "./compose-
|
|
17
|
+
} from "./compose-8nysak5a.js";
|
|
18
|
+
import {
|
|
19
|
+
pause2,
|
|
20
|
+
resume2
|
|
21
|
+
} from "./compose-wgs4rgfp.js";
|
|
18
22
|
import {
|
|
19
23
|
gate2,
|
|
20
24
|
gated2,
|
|
21
25
|
createPrincipals2
|
|
22
|
-
} from "./compose-
|
|
26
|
+
} from "./compose-7sjf0y70.js";
|
|
27
|
+
import {
|
|
28
|
+
loadPlugins2
|
|
29
|
+
} from "./compose-75pnchkk.js";
|
|
23
30
|
import {
|
|
24
31
|
createSettingsApi2
|
|
25
|
-
} from "./compose-
|
|
32
|
+
} from "./compose-vphbntyn.js";
|
|
26
33
|
import {
|
|
27
34
|
readWorkspaceCatalog2,
|
|
28
35
|
runWorkspaceCommand2,
|
|
29
36
|
completeWorkspaceCommand2
|
|
30
|
-
} from "./compose-
|
|
37
|
+
} from "./compose-4jqwbez4.js";
|
|
31
38
|
import {
|
|
32
39
|
inspect2
|
|
33
|
-
} from "./compose-
|
|
40
|
+
} from "./compose-d5yhtpa7.js";
|
|
34
41
|
import {
|
|
35
42
|
watchHost2
|
|
36
43
|
} from "./compose-xm52jghq.js";
|
|
37
44
|
import {
|
|
38
45
|
sessionHandle2,
|
|
39
46
|
createSessions2
|
|
40
|
-
} from "./compose-
|
|
47
|
+
} from "./compose-hf0nrd46.js";
|
|
41
48
|
|
|
42
49
|
// src/api/connection.ts
|
|
43
50
|
import { SdkError } from "@nyte-ai/schema";
|
|
@@ -89,7 +96,11 @@ function createConnection2(kernel, models, context) {
|
|
|
89
96
|
...handle,
|
|
90
97
|
watch: (options) => track(handle.watch(options)),
|
|
91
98
|
...watchStore2(() => track(handle.watch())),
|
|
92
|
-
head: (name) => head(handle.head(name))
|
|
99
|
+
head: (name) => head(handle.head(name)),
|
|
100
|
+
part: (id) => {
|
|
101
|
+
const part = handle.part(id);
|
|
102
|
+
return { ...part, watch: () => track(part.watch()) };
|
|
103
|
+
}
|
|
93
104
|
});
|
|
94
105
|
const capability = async (kind, found) => {
|
|
95
106
|
const provided = await found();
|
|
@@ -156,7 +167,7 @@ function createConnection2(kernel, models, context) {
|
|
|
156
167
|
}),
|
|
157
168
|
settings: gated2("settings", createSettingsApi2(kernel), authority),
|
|
158
169
|
plugins: gated2("plugins", {
|
|
159
|
-
replace:
|
|
170
|
+
replace: (plugins, scope) => replaceFiles(kernel, plugins, scope),
|
|
160
171
|
check: async (plugins) => kernel.plugins.check(await kernel.plugins.load(listPluginPaths(plugins)))
|
|
161
172
|
}, authority),
|
|
162
173
|
principals: gated2("principals", createPrincipals2(kernel), authority),
|
|
@@ -175,23 +186,26 @@ function createHost2(kernel, input) {
|
|
|
175
186
|
return {
|
|
176
187
|
...connection,
|
|
177
188
|
plugins: {
|
|
178
|
-
replace:
|
|
179
|
-
check: async (plugins) => kernel.plugins.check(await
|
|
189
|
+
replace: (plugins, scope) => kernel.plugins.replace(plugins, scope),
|
|
190
|
+
check: async (plugins) => kernel.plugins.check(await loadPlugins2(kernel, plugins))
|
|
180
191
|
},
|
|
181
192
|
inspect: (session) => inspect2(kernel.store, session),
|
|
182
193
|
execution: {
|
|
183
194
|
cover: (coverage) => cover2(kernel, coverage),
|
|
184
195
|
advance: (step) => advance2(kernel, step),
|
|
185
|
-
repair: (page) => repair2(kernel, page)
|
|
196
|
+
repair: (page) => repair2(kernel, page),
|
|
197
|
+
pause: () => pause2(kernel),
|
|
198
|
+
resume: () => resume2(kernel)
|
|
186
199
|
}
|
|
187
200
|
};
|
|
188
201
|
}
|
|
202
|
+
async function replaceFiles(kernel, files, scope) {
|
|
203
|
+
const paths = listPluginPaths(files);
|
|
204
|
+
await kernel.plugins.load(paths);
|
|
205
|
+
return kernel.plugins.replace(paths.map((path) => ({ path })), scope);
|
|
206
|
+
}
|
|
189
207
|
function listPluginPaths(files) {
|
|
190
208
|
return files.map((file) => file.path);
|
|
191
209
|
}
|
|
192
|
-
async function loaded(kernel, plugins) {
|
|
193
|
-
const each = await Promise.all(plugins.map(async (plugin) => ("id" in plugin) ? [plugin] : kernel.plugins.load([plugin.path])));
|
|
194
|
-
return each.flat();
|
|
195
|
-
}
|
|
196
210
|
|
|
197
211
|
export { createConnection2, createHost2 };
|
|
@@ -10,10 +10,10 @@ import {
|
|
|
10
10
|
readRefExpectation2,
|
|
11
11
|
put2,
|
|
12
12
|
readCall2
|
|
13
|
-
} from "./compose-
|
|
13
|
+
} from "./compose-ydth4n0z.js";
|
|
14
14
|
import {
|
|
15
15
|
publishSet2
|
|
16
|
-
} from "./compose-
|
|
16
|
+
} from "./compose-1kvvrw50.js";
|
|
17
17
|
|
|
18
18
|
// src/fold/commit.ts
|
|
19
19
|
import { SdkError } from "@nyte-ai/schema";
|
|
@@ -27,26 +27,34 @@ import {
|
|
|
27
27
|
readCall2,
|
|
28
28
|
coveredHere2,
|
|
29
29
|
guard2
|
|
30
|
-
} from "./compose-
|
|
30
|
+
} from "./compose-ydth4n0z.js";
|
|
31
31
|
import {
|
|
32
32
|
traced2,
|
|
33
33
|
followTrace2,
|
|
34
34
|
takeReceiptTrace2
|
|
35
35
|
} from "./compose-sd0stm97.js";
|
|
36
|
+
import {
|
|
37
|
+
holdsReports2
|
|
38
|
+
} from "./compose-nenmmq5w.js";
|
|
36
39
|
import {
|
|
37
40
|
commit2
|
|
38
|
-
} from "./compose-
|
|
41
|
+
} from "./compose-s4kyfjj6.js";
|
|
39
42
|
import {
|
|
40
43
|
withFold2
|
|
41
|
-
} from "./compose-
|
|
44
|
+
} from "./compose-122g5jvb.js";
|
|
45
|
+
import {
|
|
46
|
+
buildMessage2,
|
|
47
|
+
admitted2,
|
|
48
|
+
pendingReceipt2
|
|
49
|
+
} from "./compose-2e84znn8.js";
|
|
42
50
|
import {
|
|
43
51
|
fence2,
|
|
44
52
|
finishFence2
|
|
45
|
-
} from "./compose-
|
|
53
|
+
} from "./compose-kgdmzx0n.js";
|
|
46
54
|
import {
|
|
47
55
|
holdSummary2,
|
|
48
56
|
summarizedMove2
|
|
49
|
-
} from "./compose-
|
|
57
|
+
} from "./compose-kw3bf8mf.js";
|
|
50
58
|
import {
|
|
51
59
|
refusalError2,
|
|
52
60
|
collectContributions2
|
|
@@ -59,7 +67,7 @@ import {
|
|
|
59
67
|
settleReceipt2,
|
|
60
68
|
reserve2,
|
|
61
69
|
known2
|
|
62
|
-
} from "./compose-
|
|
70
|
+
} from "./compose-dywbt4he.js";
|
|
63
71
|
import {
|
|
64
72
|
landed2,
|
|
65
73
|
chooseSendSchedule2
|
|
@@ -94,8 +102,7 @@ async function sendNow2(kernel, input) {
|
|
|
94
102
|
const target = sending.options.replace;
|
|
95
103
|
if (target === undefined)
|
|
96
104
|
return admit(sending);
|
|
97
|
-
|
|
98
|
-
throw new SdkError("invalid", `Message ${target} is still being decided.`);
|
|
105
|
+
await refuseDeciding(kernel, input.session, target);
|
|
99
106
|
const keyed = {
|
|
100
107
|
id: sending.options.id ?? asId(crypto.randomUUID()),
|
|
101
108
|
digest: await hashSendRequest(sending)
|
|
@@ -104,7 +111,38 @@ async function sendNow2(kernel, input) {
|
|
|
104
111
|
if (replayed !== null)
|
|
105
112
|
return replayed;
|
|
106
113
|
const inbox = await readInbox2(kernel.store, input.session, input.head);
|
|
107
|
-
|
|
114
|
+
if (!inbox.messages.includes(target))
|
|
115
|
+
return edit(sending, target, keyed);
|
|
116
|
+
const gated = await gateRevision(sending, target);
|
|
117
|
+
return await revise(sending, target, gated, keyed) ?? editGated(sending, target, { ...keyed, ...gated });
|
|
118
|
+
}
|
|
119
|
+
async function reviseQueued2(kernel, input, activation = false) {
|
|
120
|
+
const { session, head, message } = input;
|
|
121
|
+
if (!activation)
|
|
122
|
+
await kernel.plugins.runtime(session).ready;
|
|
123
|
+
await refuseDeciding(kernel, session, message);
|
|
124
|
+
const sending = {
|
|
125
|
+
kernel,
|
|
126
|
+
session,
|
|
127
|
+
head,
|
|
128
|
+
context: input.context,
|
|
129
|
+
content: input.content,
|
|
130
|
+
options: input.options ?? {},
|
|
131
|
+
stop: null
|
|
132
|
+
};
|
|
133
|
+
const queued = (await readInbox2(kernel.store, session, head)).messages.includes(message);
|
|
134
|
+
if (queued && await revise(sending, message, await gateRevision(sending, message), null) !== null)
|
|
135
|
+
return { kind: "revised" };
|
|
136
|
+
return readDeparture2(kernel, session, message);
|
|
137
|
+
}
|
|
138
|
+
async function readDeparture2(kernel, session, message) {
|
|
139
|
+
const landed = await withFold2(kernel, session, (state) => state.inputs.get(message)?.landed ?? null);
|
|
140
|
+
return landed === null ? { kind: "missing" } : { kind: "sent" };
|
|
141
|
+
}
|
|
142
|
+
async function refuseDeciding(kernel, session, message) {
|
|
143
|
+
const input = await withFold2(kernel, session, (state) => state.inputs.get(message));
|
|
144
|
+
if (input?.schedule.kind === "deciding")
|
|
145
|
+
throw new SdkError("invalid", `Message ${message} is still being decided.`);
|
|
108
146
|
}
|
|
109
147
|
function selectRunStart2(state, head, inputs) {
|
|
110
148
|
if (inputs.some((input) => input.schedule.kind === "deciding"))
|
|
@@ -113,7 +151,7 @@ function selectRunStart2(state, head, inputs) {
|
|
|
113
151
|
if (prompt !== undefined)
|
|
114
152
|
return { origin: { kind: "input", message: prompt.id }, input: prompt };
|
|
115
153
|
const execution = state.heads.get(head)?.info.execution;
|
|
116
|
-
if (execution?.kind !== "idle" || execution
|
|
154
|
+
if (execution?.kind !== "idle" || holdsReports2(execution))
|
|
117
155
|
return null;
|
|
118
156
|
const report = inputs.flatMap((input) => input.source.kind === "child" || input.source.kind === "job" ? [{ origin: { kind: "continuation", from: input.source.kind }, input }] : []).at(0);
|
|
119
157
|
return report ?? null;
|
|
@@ -124,7 +162,10 @@ async function landing2(kernel, session, head, ids, run, start = null) {
|
|
|
124
162
|
readTip2(kernel.store, session, head),
|
|
125
163
|
readInbox2(kernel.store, session, head)
|
|
126
164
|
]);
|
|
127
|
-
const
|
|
165
|
+
const held = inbox.hold?.message;
|
|
166
|
+
if (start !== null && held !== undefined && ids.includes(held))
|
|
167
|
+
return [];
|
|
168
|
+
const due = inbox.messages.filter((message) => ids.includes(message) && message !== held);
|
|
128
169
|
if (due.length === 0)
|
|
129
170
|
return [];
|
|
130
171
|
const { inputs, siblings, starts } = await withFold2(kernel, session, (state) => ({
|
|
@@ -215,7 +256,7 @@ async function admit(sending) {
|
|
|
215
256
|
resolve(sending, submission.configuration)
|
|
216
257
|
]);
|
|
217
258
|
const landing = landed2(kernel, submission, run?.record ?? null);
|
|
218
|
-
const message =
|
|
259
|
+
const message = buildMessage2(asId(id), landing, {
|
|
219
260
|
schedule: await chooseSendSchedule2(landing.delivery, configuration, run?.record ?? null),
|
|
220
261
|
covered,
|
|
221
262
|
configuration,
|
|
@@ -223,8 +264,8 @@ async function admit(sending) {
|
|
|
223
264
|
position: inbox.messages.length
|
|
224
265
|
});
|
|
225
266
|
const outcome = await commit2(kernel, [
|
|
226
|
-
await
|
|
227
|
-
await
|
|
267
|
+
await admitted2(kernel, session, head, inbox, [...inbox.messages, message.id], message),
|
|
268
|
+
await pendingReceipt2(kernel.store, session, id, digest, "absent")
|
|
228
269
|
]);
|
|
229
270
|
if (outcome.kind === "stale")
|
|
230
271
|
return outcome.name === receiptRef2(session, id) && await known2(kernel.store, session, id, "send", digest) ? sendReceipt2(kernel, session, id) : STALE2;
|
|
@@ -233,9 +274,8 @@ async function admit(sending) {
|
|
|
233
274
|
return sendReceipt2(kernel, session, id);
|
|
234
275
|
});
|
|
235
276
|
}
|
|
236
|
-
async function
|
|
237
|
-
const { kernel, session,
|
|
238
|
-
const { id, digest } = keyed;
|
|
277
|
+
async function gateRevision(sending, target) {
|
|
278
|
+
const { kernel, session, options } = sending;
|
|
239
279
|
const previous = await withFold2(kernel, session, (state) => state.inputs.get(target));
|
|
240
280
|
const submission = await gate(sending, target, {
|
|
241
281
|
content: sending.content,
|
|
@@ -244,9 +284,17 @@ async function revise(sending, target, keyed) {
|
|
|
244
284
|
configuration: options.configuration ?? null,
|
|
245
285
|
replace: target
|
|
246
286
|
});
|
|
247
|
-
|
|
287
|
+
return {
|
|
288
|
+
previous,
|
|
289
|
+
submission,
|
|
290
|
+
configured: async () => submission.configuration === null && previous !== undefined ? previous.configuration : resolve(sending, submission.configuration)
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
async function revise(sending, target, gated, keyed) {
|
|
294
|
+
const { kernel, session, head, options } = sending;
|
|
295
|
+
const { previous, submission, configured } = gated;
|
|
248
296
|
const covered = await coveredHere2(kernel, session);
|
|
249
|
-
|
|
297
|
+
return attempt2(`Revising ${target}`, async () => {
|
|
250
298
|
const [inbox, run, configuration] = await Promise.all([
|
|
251
299
|
readInbox2(kernel.store, session, head),
|
|
252
300
|
liveRun3(kernel.store, session, head),
|
|
@@ -258,25 +306,19 @@ async function revise(sending, target, keyed) {
|
|
|
258
306
|
const rest = inbox.messages.filter((message) => message !== target);
|
|
259
307
|
const position = findInsertionIndex(options.position, rest, current);
|
|
260
308
|
const landing = landed2(kernel, submission, run?.record ?? null);
|
|
261
|
-
const message =
|
|
309
|
+
const message = buildMessage2(target, landing, {
|
|
262
310
|
schedule: await chooseSendSchedule2(landing.delivery, configuration, run?.record ?? null),
|
|
263
311
|
covered,
|
|
264
312
|
configuration,
|
|
265
313
|
replaced: previous?.replaced ?? null,
|
|
266
314
|
position
|
|
267
315
|
});
|
|
316
|
+
const update = await admitted2(kernel, session, head, inbox, [...rest.slice(0, position), target, ...rest.slice(position)], message);
|
|
268
317
|
const outcome = await commit2(kernel, [
|
|
269
|
-
await admitted(kernel, session, head, inbox, [...rest.slice(0, position), target, ...rest.slice(position)], message),
|
|
270
318
|
{
|
|
271
|
-
|
|
272
|
-
target: await put2(kernel.store, "receipt", {
|
|
273
|
-
id: asId(target),
|
|
274
|
-
kind: "send",
|
|
275
|
-
digest,
|
|
276
|
-
outcome: null
|
|
277
|
-
}),
|
|
278
|
-
expect: "absent",
|
|
319
|
+
...update,
|
|
279
320
|
events: [
|
|
321
|
+
...update.events ?? [],
|
|
280
322
|
{
|
|
281
323
|
head,
|
|
282
324
|
kind: "input",
|
|
@@ -286,16 +328,27 @@ async function revise(sending, target, keyed) {
|
|
|
286
328
|
position
|
|
287
329
|
}
|
|
288
330
|
]
|
|
289
|
-
}
|
|
331
|
+
},
|
|
332
|
+
...keyed === null ? [] : [
|
|
333
|
+
{
|
|
334
|
+
name: receiptRef2(session, keyed.id),
|
|
335
|
+
target: await put2(kernel.store, "receipt", {
|
|
336
|
+
id: asId(target),
|
|
337
|
+
kind: "send",
|
|
338
|
+
digest: keyed.digest,
|
|
339
|
+
outcome: null
|
|
340
|
+
}),
|
|
341
|
+
expect: "absent"
|
|
342
|
+
}
|
|
343
|
+
]
|
|
290
344
|
]);
|
|
291
345
|
if (outcome.kind === "stale")
|
|
292
|
-
return outcome.name === receiptRef2(session, id) ? await readReplayReceipt(kernel, session, keyed) ?? STALE2 : STALE2;
|
|
346
|
+
return keyed !== null && outcome.name === receiptRef2(session, keyed.id) ? await readReplayReceipt(kernel, session, keyed) ?? STALE2 : STALE2;
|
|
293
347
|
if (covered)
|
|
294
348
|
kernel.wakes.notify(session, head);
|
|
295
349
|
dev2("admission", "revised", { session, head, message: target });
|
|
296
350
|
return sendReceipt2(kernel, session, asId(target));
|
|
297
351
|
});
|
|
298
|
-
return revised ?? editGated(sending, target, { id, digest, submission, configured });
|
|
299
352
|
}
|
|
300
353
|
async function edit(sending, target, keyed) {
|
|
301
354
|
const { kernel, session, options } = sending;
|
|
@@ -321,7 +374,7 @@ async function editGated(sending, target, gated) {
|
|
|
321
374
|
const covered = await coveredHere2(kernel, session);
|
|
322
375
|
const abandoned = options.abandoned;
|
|
323
376
|
const running = options.running ?? "stop";
|
|
324
|
-
const message = async (stopped, position) =>
|
|
377
|
+
const message = async (stopped, position) => buildMessage2(asId(id), submission, {
|
|
325
378
|
schedule: submission.delivery === "attach" ? { kind: "attached" } : { kind: "next-turn", reason: "idle" },
|
|
326
379
|
covered,
|
|
327
380
|
configuration: await configured(),
|
|
@@ -357,8 +410,8 @@ async function editGated(sending, target, gated) {
|
|
|
357
410
|
expect: readRefExpectation2(checked.tip.ref),
|
|
358
411
|
events: [{ head, kind: "head", from: checked.tip.id, to: parent, reason: "moved" }]
|
|
359
412
|
},
|
|
360
|
-
await
|
|
361
|
-
await
|
|
413
|
+
await admitted2(kernel, session, head, checked.inbox, [...checked.inbox.messages, record.id], record),
|
|
414
|
+
await pendingReceipt2(kernel.store, session, id, digest, "absent")
|
|
362
415
|
]);
|
|
363
416
|
dev2("admission", "edit", { session, head, target, outcome: outcome.kind });
|
|
364
417
|
if (outcome.kind === "set")
|
|
@@ -390,7 +443,7 @@ async function editGated(sending, target, gated) {
|
|
|
390
443
|
updates: async ({ inbox, receipt, stopped }) => {
|
|
391
444
|
const record = await message(stopped, inbox.messages.length);
|
|
392
445
|
return [
|
|
393
|
-
await
|
|
446
|
+
await admitted2(kernel, session, head, inbox, [...inbox.messages, record.id], record),
|
|
394
447
|
{ name: receipt.ref.name, target: receipt.ref.target, expect: receipt.ref.revision }
|
|
395
448
|
];
|
|
396
449
|
}
|
|
@@ -438,7 +491,7 @@ async function admitDeciding2(kernel, session, first) {
|
|
|
438
491
|
position: 0
|
|
439
492
|
};
|
|
440
493
|
return [
|
|
441
|
-
await
|
|
494
|
+
await admitted2(kernel, session, MAIN2, await readInbox2(kernel.store, session, MAIN2), [message.id], message),
|
|
442
495
|
{
|
|
443
496
|
name: receiptRef2(session, id),
|
|
444
497
|
target: await put2(kernel.store, "receipt", {
|
|
@@ -481,7 +534,7 @@ async function readmitDeciding2(kernel, context, session, input, stop) {
|
|
|
481
534
|
return null;
|
|
482
535
|
if (!deciding)
|
|
483
536
|
return input.id;
|
|
484
|
-
const message =
|
|
537
|
+
const message = buildMessage2(input.id, submission, {
|
|
485
538
|
schedule: await chooseSendSchedule2(submission.delivery, configuration, null),
|
|
486
539
|
covered,
|
|
487
540
|
configuration,
|
|
@@ -489,7 +542,7 @@ async function readmitDeciding2(kernel, context, session, input, stop) {
|
|
|
489
542
|
position
|
|
490
543
|
});
|
|
491
544
|
const outcome = await commit2(kernel, [
|
|
492
|
-
await
|
|
545
|
+
await admitted2(kernel, session, MAIN2, inbox, inbox.messages, message)
|
|
493
546
|
]);
|
|
494
547
|
if (outcome.kind === "stale")
|
|
495
548
|
return STALE2;
|
|
@@ -498,16 +551,6 @@ async function readmitDeciding2(kernel, context, session, input, stop) {
|
|
|
498
551
|
return message.id;
|
|
499
552
|
});
|
|
500
553
|
}
|
|
501
|
-
function buildMessage(id, submission, placed) {
|
|
502
|
-
return {
|
|
503
|
-
id,
|
|
504
|
-
at: Date.now(),
|
|
505
|
-
content: submission.content,
|
|
506
|
-
source: submission.source,
|
|
507
|
-
delivery: submission.delivery,
|
|
508
|
-
...placed
|
|
509
|
-
};
|
|
510
|
-
}
|
|
511
554
|
async function announce(kernel, session, head, message) {
|
|
512
555
|
if (message.covered)
|
|
513
556
|
kernel.wakes.notify(session, head);
|
|
@@ -604,41 +647,6 @@ async function resolve(sending, patch) {
|
|
|
604
647
|
return result;
|
|
605
648
|
throw refusalError2(result);
|
|
606
649
|
}
|
|
607
|
-
async function admitted(kernel, session, head, inbox, messages, message) {
|
|
608
|
-
const input = message.source.kind === "user" && message.delivery !== "attach";
|
|
609
|
-
const pendingInput = [
|
|
610
|
-
...inbox.pendingInput.filter((id) => id !== message.id),
|
|
611
|
-
...input ? [message.id] : []
|
|
612
|
-
];
|
|
613
|
-
return {
|
|
614
|
-
name: inboxRef2(session, head),
|
|
615
|
-
target: await put2(kernel.store, "inbox", { messages, pendingInput }),
|
|
616
|
-
expect: readRefExpectation2(inbox.ref),
|
|
617
|
-
events: [
|
|
618
|
-
{
|
|
619
|
-
head,
|
|
620
|
-
kind: "input",
|
|
621
|
-
message: message.id,
|
|
622
|
-
change: "admitted",
|
|
623
|
-
content: message.content,
|
|
624
|
-
source: message.source,
|
|
625
|
-
delivery: message.delivery,
|
|
626
|
-
schedule: message.schedule,
|
|
627
|
-
covered: message.covered,
|
|
628
|
-
configuration: message.configuration,
|
|
629
|
-
replaced: message.replaced,
|
|
630
|
-
requires: [...kernel.presence?.member.capabilities ?? []]
|
|
631
|
-
}
|
|
632
|
-
]
|
|
633
|
-
};
|
|
634
|
-
}
|
|
635
|
-
async function pendingReceipt(store, session, id, digest, expect) {
|
|
636
|
-
return {
|
|
637
|
-
name: receiptRef2(session, id),
|
|
638
|
-
target: await put2(store, "receipt", { id, kind: "send", digest, outcome: null }),
|
|
639
|
-
expect
|
|
640
|
-
};
|
|
641
|
-
}
|
|
642
650
|
function hashSendRequest(sending) {
|
|
643
651
|
const { options } = sending;
|
|
644
652
|
return objectId2({
|
|
@@ -663,4 +671,4 @@ function findInsertionIndex(position, rest, current) {
|
|
|
663
671
|
return before < 0 ? Math.min(current, rest.length) : before;
|
|
664
672
|
}
|
|
665
673
|
|
|
666
|
-
export { send2, sendNow2, selectRunStart2, landing2, admitDeciding2, readmitDeciding2 };
|
|
674
|
+
export { send2, sendNow2, reviseQueued2, readDeparture2, selectRunStart2, landing2, admitDeciding2, readmitDeciding2 };
|
|
@@ -13,31 +13,31 @@ import {
|
|
|
13
13
|
requireSession2,
|
|
14
14
|
put2,
|
|
15
15
|
attempt2
|
|
16
|
-
} from "./compose-
|
|
16
|
+
} from "./compose-ydth4n0z.js";
|
|
17
17
|
import {
|
|
18
18
|
check2
|
|
19
19
|
} from "./compose-bj54tkph.js";
|
|
20
20
|
import {
|
|
21
21
|
commit2
|
|
22
|
-
} from "./compose-
|
|
22
|
+
} from "./compose-s4kyfjj6.js";
|
|
23
23
|
import {
|
|
24
24
|
WORKSPACE_TRUST2
|
|
25
|
-
} from "./compose-
|
|
25
|
+
} from "./compose-hx8j2kef.js";
|
|
26
26
|
import {
|
|
27
27
|
SKILL_PATHS2,
|
|
28
28
|
dropScans2
|
|
29
|
-
} from "./compose-
|
|
29
|
+
} from "./compose-j8xmyfy6.js";
|
|
30
30
|
import {
|
|
31
31
|
trustChanged2
|
|
32
|
-
} from "./compose-
|
|
32
|
+
} from "./compose-pjkzf9ev.js";
|
|
33
33
|
import {
|
|
34
34
|
settingInfos2,
|
|
35
35
|
readSettingLayers2,
|
|
36
36
|
findSettingDefinition2
|
|
37
|
-
} from "./compose-
|
|
37
|
+
} from "./compose-n5f6w2y6.js";
|
|
38
38
|
import {
|
|
39
39
|
publishCatalog2
|
|
40
|
-
} from "./compose-
|
|
40
|
+
} from "./compose-zq7ar8qm.js";
|
|
41
41
|
|
|
42
42
|
// src/extend/settings.ts
|
|
43
43
|
import { isJson, SdkError } from "@nyte-ai/schema";
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HOLD_MS2
|
|
3
|
+
} from "./compose-s23st6q6.js";
|
|
4
|
+
import {
|
|
5
|
+
inboxRef2
|
|
6
|
+
} from "./compose-cqpjcx2t.js";
|
|
7
|
+
import {
|
|
8
|
+
STALE2,
|
|
9
|
+
readInbox2,
|
|
10
|
+
inboxWithout2,
|
|
11
|
+
readRefExpectation2,
|
|
12
|
+
put2,
|
|
13
|
+
attempt2
|
|
14
|
+
} from "./compose-ydth4n0z.js";
|
|
15
|
+
import {
|
|
16
|
+
commit2
|
|
17
|
+
} from "./compose-s4kyfjj6.js";
|
|
18
|
+
import {
|
|
19
|
+
readDeparture2
|
|
20
|
+
} from "./compose-sjfbxw65.js";
|
|
21
|
+
|
|
22
|
+
// src/engine/holds.ts
|
|
23
|
+
async function leaseHold2(kernel, session, head, message) {
|
|
24
|
+
const held = await attempt2(`Holding ${message}`, async () => {
|
|
25
|
+
const inbox = await readInbox2(kernel.store, session, head);
|
|
26
|
+
if (!inbox.messages.includes(message))
|
|
27
|
+
return null;
|
|
28
|
+
const outcome = await commit2(kernel, [
|
|
29
|
+
{
|
|
30
|
+
name: inboxRef2(session, head),
|
|
31
|
+
target: await put2(kernel.store, "inbox", {
|
|
32
|
+
...inboxWithout2(inbox, []),
|
|
33
|
+
hold: { message, until: Date.now() + HOLD_MS2 }
|
|
34
|
+
}),
|
|
35
|
+
expect: readRefExpectation2(inbox.ref)
|
|
36
|
+
}
|
|
37
|
+
]);
|
|
38
|
+
return outcome.kind === "set" ? { kind: "held" } : STALE2;
|
|
39
|
+
});
|
|
40
|
+
return held ?? readDeparture2(kernel, session, message);
|
|
41
|
+
}
|
|
42
|
+
async function releaseHold2(kernel, session, head, message) {
|
|
43
|
+
const released = await attempt2(`Releasing ${message}`, async () => {
|
|
44
|
+
const inbox = await readInbox2(kernel.store, session, head);
|
|
45
|
+
if (inbox.hold?.message !== message)
|
|
46
|
+
return false;
|
|
47
|
+
const outcome = await commit2(kernel, [
|
|
48
|
+
{
|
|
49
|
+
name: inboxRef2(session, head),
|
|
50
|
+
target: await put2(kernel.store, "inbox", {
|
|
51
|
+
messages: inbox.messages,
|
|
52
|
+
pendingInput: inbox.pendingInput
|
|
53
|
+
}),
|
|
54
|
+
expect: readRefExpectation2(inbox.ref)
|
|
55
|
+
}
|
|
56
|
+
]);
|
|
57
|
+
return outcome.kind === "set" ? true : STALE2;
|
|
58
|
+
});
|
|
59
|
+
if (released)
|
|
60
|
+
kernel.wakes.notify(session, head);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { leaseHold2, releaseHold2 };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// src/drive/pause.ts
|
|
2
|
+
function pause2(kernel) {
|
|
3
|
+
const state = kernel.executionState;
|
|
4
|
+
if (state.paused !== null)
|
|
5
|
+
return;
|
|
6
|
+
state.paused = Promise.withResolvers();
|
|
7
|
+
state.streams.abort();
|
|
8
|
+
}
|
|
9
|
+
function resume2(kernel) {
|
|
10
|
+
const state = kernel.executionState;
|
|
11
|
+
const paused = state.paused;
|
|
12
|
+
if (paused === null)
|
|
13
|
+
return;
|
|
14
|
+
state.paused = null;
|
|
15
|
+
state.streams = new AbortController;
|
|
16
|
+
paused.resolve();
|
|
17
|
+
}
|
|
18
|
+
async function unpaused2(kernel, signal) {
|
|
19
|
+
const paused = kernel.executionState.paused;
|
|
20
|
+
if (paused === null || signal.aborted)
|
|
21
|
+
return;
|
|
22
|
+
const aborted = Promise.withResolvers();
|
|
23
|
+
const stop = () => aborted.resolve();
|
|
24
|
+
signal.addEventListener("abort", stop, { once: true });
|
|
25
|
+
try {
|
|
26
|
+
await Promise.race([paused.promise, aborted.promise]);
|
|
27
|
+
} finally {
|
|
28
|
+
signal.removeEventListener("abort", stop);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { pause2, resume2, unpaused2 };
|