@nyte-ai/core 0.0.23 → 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.
Files changed (189) hide show
  1. package/THIRD-PARTY-NOTICES.md +2 -38
  2. package/dist/chunks/{compose-nj4nj5n9.js → compose-0f9x3cjd.js} +1 -1
  3. package/dist/chunks/{compose-yfcb6w2h.js → compose-0zrwy7nk.js} +1 -1
  4. package/dist/chunks/{compose-xhtgytrh.js → compose-122g5jvb.js} +1 -1
  5. package/dist/chunks/{compose-nkxwrphm.js → compose-17xxey5y.js} +6 -6
  6. package/dist/chunks/compose-1hgkp0q6.js +154 -0
  7. package/dist/chunks/{compose-ad80nkkn.js → compose-1kvvrw50.js} +6 -6
  8. package/dist/chunks/{compose-jeemzja1.js → compose-1nqjy2z5.js} +3 -3
  9. package/dist/chunks/compose-2e84znn8.js +62 -0
  10. package/dist/chunks/{compose-sprfv38c.js → compose-34cqydxc.js} +4 -4
  11. package/dist/chunks/{compose-ee0h1pk1.js → compose-3qkhfwtd.js} +4 -4
  12. package/dist/chunks/{compose-yr19b453.js → compose-4jqwbez4.js} +7 -7
  13. package/dist/chunks/{compose-5rg7askh.js → compose-4krv4vzw.js} +13 -5
  14. package/dist/chunks/{compose-byse0eqj.js → compose-4s0c5zqv.js} +6 -6
  15. package/dist/chunks/{compose-gj2ypr7q.js → compose-5ygdrc65.js} +3 -3
  16. package/dist/chunks/{compose-csh5vv2t.js → compose-6e9ktyhr.js} +1 -1
  17. package/dist/chunks/{compose-dbsn3bsy.js → compose-6zgf2dtw.js} +6 -3
  18. package/dist/chunks/{compose-ht1tbyr3.js → compose-75pnchkk.js} +22 -10
  19. package/dist/chunks/{compose-vzvm76dn.js → compose-79h43be5.js} +13 -5
  20. package/dist/chunks/compose-7bpnxft1.js +20 -0
  21. package/dist/chunks/{compose-jwy1gba9.js → compose-7sjf0y70.js} +3 -3
  22. package/dist/chunks/{compose-1tdb9ezw.js → compose-8nysak5a.js} +33 -22
  23. package/dist/chunks/{compose-ay7t13m9.js → compose-8p6emvvh.js} +8 -8
  24. package/dist/chunks/{compose-e3635qmn.js → compose-8ranx653.js} +17 -2
  25. package/dist/chunks/{compose-5njywhy8.js → compose-9tntshv3.js} +6 -6
  26. package/dist/chunks/{compose-gvm49f4b.js → compose-b10qcn9b.js} +1 -1
  27. package/dist/chunks/{compose-42egt9y7.js → compose-b4zb2rpb.js} +21 -12
  28. package/dist/chunks/{compose-767bb340.js → compose-c7jk6qr1.js} +1 -1
  29. package/dist/chunks/{compose-hfsn6pnt.js → compose-chcqk093.js} +39 -17
  30. package/dist/chunks/{compose-nw5hdpxk.js → compose-ct1h40fd.js} +8 -8
  31. package/dist/chunks/{compose-smsafpqe.js → compose-d5yhtpa7.js} +2 -2
  32. package/dist/chunks/{compose-qxfq6dn9.js → compose-d95420jw.js} +8 -8
  33. package/dist/chunks/{compose-gxjc6vz9.js → compose-dw8fvn94.js} +4 -2
  34. package/dist/chunks/{compose-fnncnk81.js → compose-dywbt4he.js} +5 -5
  35. package/dist/chunks/{compose-xvbyp65f.js → compose-gnfmty38.js} +30 -10
  36. package/dist/chunks/{compose-mdwr0er9.js → compose-h0d0vess.js} +4 -4
  37. package/dist/chunks/{compose-2gsbcjgv.js → compose-hf0nrd46.js} +22 -18
  38. package/dist/chunks/{compose-mcz93154.js → compose-ht5fhzzw.js} +10 -10
  39. package/dist/chunks/{compose-8pp3vtv0.js → compose-hx8j2kef.js} +4 -4
  40. package/dist/chunks/{compose-c4z4kp98.js → compose-j8xmyfy6.js} +118 -42
  41. package/dist/chunks/{compose-9jvn2wvh.js → compose-jawbhn7q.js} +21 -5
  42. package/dist/chunks/{compose-2rha31fc.js → compose-jbrtw0md.js} +4 -4
  43. package/dist/chunks/{compose-m01wspwf.js → compose-jrxg4vqg.js} +1 -1
  44. package/dist/chunks/{compose-bz70g01d.js → compose-kf2k4hq5.js} +5 -5
  45. package/dist/chunks/{compose-w6zb11k1.js → compose-kgdmzx0n.js} +6 -6
  46. package/dist/chunks/{compose-qjxtbzgq.js → compose-krkyrds4.js} +11 -5
  47. package/dist/chunks/{compose-tppkp915.js → compose-kw3bf8mf.js} +4 -4
  48. package/dist/chunks/{compose-d95fwwvw.js → compose-kwbs1f34.js} +2 -2
  49. package/dist/chunks/{compose-j42p9wfs.js → compose-n29d5dzv.js} +1 -1
  50. package/dist/chunks/{compose-qwbe95qs.js → compose-n5f6w2y6.js} +1 -1
  51. package/dist/chunks/{compose-a7k9h27z.js → compose-nc60858y.js} +4 -4
  52. package/dist/chunks/{compose-6r5ymwyr.js → compose-nenmmq5w.js} +30 -10
  53. package/dist/chunks/{compose-enq3x3rq.js → compose-p7j0gt4t.js} +22 -7
  54. package/dist/chunks/compose-pb3420v8.js +74 -0
  55. package/dist/chunks/{compose-ts08bth2.js → compose-pcfvksb2.js} +1 -1
  56. package/dist/chunks/{compose-917xy085.js → compose-pjkzf9ev.js} +9 -9
  57. package/dist/chunks/{compose-c9wxgbjp.js → compose-prek5sd9.js} +2 -2
  58. package/dist/chunks/{compose-h14pmqv3.js → compose-qgz6q016.js} +1 -1
  59. package/dist/chunks/{compose-y6xgbg2h.js → compose-qq85vkhf.js} +1 -1
  60. package/dist/chunks/{compose-bd8c5n7k.js → compose-qyjchprv.js} +2 -2
  61. package/dist/chunks/{compose-97y00axn.js → compose-rh1d2g0s.js} +30 -16
  62. package/dist/chunks/compose-s23st6q6.js +4 -0
  63. package/dist/chunks/{compose-bbhk8vnr.js → compose-s4kyfjj6.js} +2 -2
  64. package/dist/chunks/{compose-t9fcqtby.js → compose-sjfbxw65.js} +93 -85
  65. package/dist/chunks/{compose-a40dnhy5.js → compose-vphbntyn.js} +7 -7
  66. package/dist/chunks/compose-vxme67gg.js +63 -0
  67. package/dist/chunks/compose-wgs4rgfp.js +32 -0
  68. package/dist/chunks/{compose-1xn3eecn.js → compose-xdq54csy.js} +39 -35
  69. package/dist/chunks/{compose-v46qmh60.js → compose-yd5t8qj3.js} +63 -126
  70. package/dist/chunks/{compose-vn7b7fdj.js → compose-ydth4n0z.js} +7 -3
  71. package/dist/chunks/{compose-6gt28900.js → compose-yxhvzsed.js} +4 -4
  72. package/dist/chunks/{compose-matk94se.js → compose-zajq79k0.js} +6 -6
  73. package/dist/chunks/{compose-ae5t6v5b.js → compose-zq7ar8qm.js} +4 -4
  74. package/dist/chunks/{compose-4ppmas7g.js → compose-zt2qtrxj.js} +4 -4
  75. package/dist/chunks/compose-ztyjpn84.js +59 -0
  76. package/dist/chunks/{compose-m91ffwss.js → compose-zv0t13e7.js} +2 -2
  77. package/dist/chunks/{compose-r8tz1xfj.js → compose-zx78edb2.js} +9 -5
  78. package/dist/src/agent/agent-loop.d.ts +4 -0
  79. package/dist/src/agent/agent-loop.js +3 -1
  80. package/dist/src/agent/compaction.js +38 -37
  81. package/dist/src/agent/open-parts.d.ts +34 -0
  82. package/dist/src/agent/open-parts.js +22 -0
  83. package/dist/src/agent/request.js +27 -26
  84. package/dist/src/agent/tool-runner.d.ts +5 -5
  85. package/dist/src/agent/tool-runner.js +31 -30
  86. package/dist/src/agent/transcript.js +34 -33
  87. package/dist/src/agent/turn.js +48 -43
  88. package/dist/src/api/connection.js +61 -56
  89. package/dist/src/api/head.d.ts +1 -2
  90. package/dist/src/api/head.js +43 -39
  91. package/dist/src/api/hold.d.ts +7 -0
  92. package/dist/src/api/hold.js +7 -0
  93. package/dist/src/api/part.js +20 -18
  94. package/dist/src/api/server.js +48 -45
  95. package/dist/src/api/session.js +48 -44
  96. package/dist/src/builtins/delegation.js +1 -1
  97. package/dist/src/builtins/environment.d.ts +8 -0
  98. package/dist/src/builtins/environment.js +3 -1
  99. package/dist/src/builtins/interruptions.d.ts +4 -0
  100. package/dist/src/builtins/interruptions.js +8 -0
  101. package/dist/src/compose.js +75 -68
  102. package/dist/src/contract/host.d.ts +6 -0
  103. package/dist/src/contract/kernel.d.ts +9 -6
  104. package/dist/src/contract/parts.d.ts +48 -46
  105. package/dist/src/contract/records.d.ts +429 -419
  106. package/dist/src/contract/records.js +1 -1
  107. package/dist/src/contract/server.d.ts +3 -1
  108. package/dist/src/contract/session.d.ts +31 -1
  109. package/dist/src/contract/session.js +6 -0
  110. package/dist/src/contract/workspace.d.ts +3 -1
  111. package/dist/src/drive/execution.js +44 -43
  112. package/dist/src/drive/interruptions.d.ts +10 -2
  113. package/dist/src/drive/interruptions.js +9 -5
  114. package/dist/src/drive/pause.d.ts +11 -0
  115. package/dist/src/drive/pause.js +10 -0
  116. package/dist/src/engine/admission-writes.d.ts +22 -0
  117. package/dist/src/engine/admission-writes.js +15 -0
  118. package/dist/src/engine/admission.d.ts +15 -1
  119. package/dist/src/engine/admission.js +25 -20
  120. package/dist/src/engine/batches.js +18 -18
  121. package/dist/src/engine/branch-summary.js +17 -17
  122. package/dist/src/engine/durable.js +17 -17
  123. package/dist/src/engine/fence.js +16 -16
  124. package/dist/src/engine/holds.d.ts +4 -0
  125. package/dist/src/engine/holds.js +43 -0
  126. package/dist/src/engine/jobs.js +24 -23
  127. package/dist/src/engine/lease.d.ts +5 -4
  128. package/dist/src/engine/lease.js +1 -1
  129. package/dist/src/engine/move.js +19 -19
  130. package/dist/src/engine/presence.js +2 -2
  131. package/dist/src/engine/principals.js +14 -14
  132. package/dist/src/engine/receipts.js +17 -17
  133. package/dist/src/engine/runs.js +22 -21
  134. package/dist/src/engine/start.js +34 -33
  135. package/dist/src/engine/surface.js +3 -3
  136. package/dist/src/engine/waits.js +15 -15
  137. package/dist/src/env/browser.js +25 -24
  138. package/dist/src/env/environment.js +27 -26
  139. package/dist/src/env/mcp.js +29 -28
  140. package/dist/src/env/session-changes.js +3 -3
  141. package/dist/src/env/trust.js +28 -27
  142. package/dist/src/env/workspaces.js +32 -31
  143. package/dist/src/env/worktrees.js +33 -32
  144. package/dist/src/extend/activation.d.ts +3 -0
  145. package/dist/src/extend/activation.js +35 -32
  146. package/dist/src/extend/hooks.js +19 -19
  147. package/dist/src/extend/models.js +26 -25
  148. package/dist/src/extend/plugin-api.js +14 -14
  149. package/dist/src/extend/plugin-runtime.d.ts +3 -1
  150. package/dist/src/extend/plugin-runtime.js +39 -38
  151. package/dist/src/extend/registry.js +24 -23
  152. package/dist/src/extend/resources.js +29 -28
  153. package/dist/src/extend/setting-layers.js +3 -3
  154. package/dist/src/extend/settings.js +36 -35
  155. package/dist/src/extend/workspace-commands.js +40 -39
  156. package/dist/src/fold/calls.js +4 -4
  157. package/dist/src/fold/checkpoint.js +9 -9
  158. package/dist/src/fold/code.d.ts +1 -1
  159. package/dist/src/fold/code.js +1 -1
  160. package/dist/src/fold/commit.js +13 -13
  161. package/dist/src/fold/draft.d.ts +37 -37
  162. package/dist/src/fold/draft.js +3 -3
  163. package/dist/src/fold/fold.js +6 -6
  164. package/dist/src/fold/paths.js +4 -4
  165. package/dist/src/fold/project.d.ts +2 -2
  166. package/dist/src/fold/project.js +6 -6
  167. package/dist/src/fold/reads.js +3 -3
  168. package/dist/src/fold/seen.d.ts +3 -5
  169. package/dist/src/fold/seen.js +17 -17
  170. package/dist/src/fold/view.d.ts +7 -1
  171. package/dist/src/fold/view.js +8 -23
  172. package/dist/src/fold/watch.js +12 -12
  173. package/dist/src/harness.d.ts +257 -257
  174. package/dist/src/harness.js +78 -71
  175. package/dist/src/index.d.ts +3 -1
  176. package/dist/src/index.js +13 -3
  177. package/dist/src/server.js +73 -66
  178. package/dist/src/store/inspect.js +3 -3
  179. package/dist/src/store/memory-store.js +3 -3
  180. package/dist/src/store/migrations.js +2 -2
  181. package/dist/src/store/model-state.js +2 -2
  182. package/dist/src/store/parts.js +3 -3
  183. package/dist/src/store/session-index.js +2 -2
  184. package/dist/src/store/session.js +2 -2
  185. package/dist/src/store.js +5 -5
  186. package/dist/src/testing.js +76 -69
  187. package/dist/src/util/line-diff.d.ts +5 -5
  188. package/package.json +4 -5
  189. package/dist/chunks/compose-hfrjm4a1.js +0 -88
@@ -15,6 +15,7 @@ var SHELL_BYTES = 32 * 1024;
15
15
  var PROGRESS_BYTES = 4 * 1024;
16
16
  var PROGRESS_MS = 80;
17
17
  var FIRST_OUTPUT_MS = 1000;
18
+ var FOREGROUND_TIMEOUT_MS = 2 * 60 * 1000;
18
19
  var MIME_TYPES = new Map([
19
20
  ["png", "image/png"],
20
21
  ["jpg", "image/jpeg"],
@@ -45,13 +46,19 @@ var listParameters = standard(Type.Object({
45
46
  path: Type.Optional(Type.String({ description: "The directory to list; the workspace root by default." })),
46
47
  limit: Type.Optional(Type.Integer({ minimum: 1, description: "How many entries to list." }))
47
48
  }));
48
- var bashParameters = standard(Type.Object({
49
+ var bashProperties2 = {
49
50
  command: Type.String({ description: "The shell command to run." }),
50
51
  description: Type.Optional(Type.String({ description: "What the command does, in a few words, for the user." })),
51
52
  background: Type.Optional(Type.Boolean({
52
53
  description: "Start the command and return a job id with its first output instead of waiting for it to exit. Use for servers, watchers, and other long-lived commands, without a trailing &. The command keeps running across turns, and you are told when it exits; read its output or stop it with the job tool. Do not use it to speed up ordinary commands."
54
+ })),
55
+ timeout: Type.Optional(Type.Integer({
56
+ minimum: 0,
57
+ maximum: 2147483647,
58
+ description: `Milliseconds before a foreground command is stopped; 0 for no limit. Default ${FOREGROUND_TIMEOUT_MS}. Background commands have no limit.`
53
59
  }))
54
- }));
60
+ };
61
+ var bashParameters = standard(Type.Object(bashProperties2));
55
62
  var jobParameters = standard(Type.Object({
56
63
  id: Type.String({ description: "The job id a background bash call returned." }),
57
64
  action: Type.Enum(["output", "stop"], {
@@ -197,12 +204,21 @@ var bash = {
197
204
  stop();
198
205
  const shell = createShellOutput((tail) => invocation.progress({ text: tail }));
199
206
  const frames = running.output()[Symbol.asyncIterator]();
207
+ const background = args.background === true;
208
+ const timeout = args.timeout ?? FOREGROUND_TIMEOUT_MS;
209
+ const waited = background ? FIRST_OUTPUT_MS : timeout;
200
210
  try {
201
- const exited = await shell.read(frames, args.background === true ? AbortSignal.any([foreground.released, AbortSignal.timeout(FIRST_OUTPUT_MS)]) : foreground.released);
202
- if (!exited && (foreground.released.aborted || foreground.release())) {
211
+ const exited = await shell.read(frames, waited === 0 ? foreground.released : AbortSignal.any([foreground.released, AbortSignal.timeout(waited)]));
212
+ if (!exited && (foreground.released.aborted || background && foreground.release())) {
203
213
  await frames.return?.();
204
214
  return text(shell.render(`[running in the background as job ${running.id}: you are told when it exits; the job tool reads its output or stops it]`));
205
215
  }
216
+ if (!exited && !background) {
217
+ stop();
218
+ await shell.read(frames, new AbortController().signal);
219
+ await running.settled();
220
+ return text(shell.render(`[stopped after ${timeout / 1000} s; pass a larger timeout if it needs longer]`));
221
+ }
206
222
  if (!exited)
207
223
  await shell.read(frames, new AbortController().signal);
208
224
  const end = await running.settled();
@@ -429,4 +445,4 @@ async function upload(files, path) {
429
445
  }
430
446
  }
431
447
 
432
- export { environmentPlugin2 };
448
+ export { bashProperties2, environmentPlugin2 };
@@ -4,17 +4,17 @@ import {
4
4
  } from "./compose-q6c7wswc.js";
5
5
  import {
6
6
  readReceipt2
7
- } from "./compose-vn7b7fdj.js";
7
+ } from "./compose-ydth4n0z.js";
8
8
  import {
9
9
  writeReceipt2
10
- } from "./compose-bbhk8vnr.js";
10
+ } from "./compose-s4kyfjj6.js";
11
11
  import {
12
12
  waitFor2
13
- } from "./compose-bz70g01d.js";
13
+ } from "./compose-kf2k4hq5.js";
14
14
  import {
15
15
  settleReceipt2,
16
16
  typedReceipt2
17
- } from "./compose-fnncnk81.js";
17
+ } from "./compose-dywbt4he.js";
18
18
 
19
19
  // src/engine/batches.ts
20
20
  import { asId, SdkError } from "@nyte-ai/schema";
@@ -3,7 +3,7 @@ import {
3
3
  } from "./compose-q6c7wswc.js";
4
4
  import {
5
5
  acquire2
6
- } from "./compose-nkxwrphm.js";
6
+ } from "./compose-17xxey5y.js";
7
7
 
8
8
  // src/env/browser.ts
9
9
  import { asId, asSeq, SdkError } from "@nyte-ai/schema";
@@ -3,7 +3,7 @@ import {
3
3
  decodePartRecord2,
4
4
  decodeCallRecord2,
5
5
  decodeJobRecord2
6
- } from "./compose-gxjc6vz9.js";
6
+ } from "./compose-dw8fvn94.js";
7
7
  import {
8
8
  runRef2,
9
9
  partRef2,
@@ -17,10 +17,10 @@ import {
17
17
  load2,
18
18
  put2,
19
19
  readCall2
20
- } from "./compose-vn7b7fdj.js";
20
+ } from "./compose-ydth4n0z.js";
21
21
  import {
22
22
  storedAnswer2
23
- } from "./compose-d95fwwvw.js";
23
+ } from "./compose-kwbs1f34.js";
24
24
  import {
25
25
  WAITS2,
26
26
  TIME2,
@@ -35,10 +35,10 @@ import {
35
35
  import {
36
36
  commit2,
37
37
  changeCall2
38
- } from "./compose-bbhk8vnr.js";
38
+ } from "./compose-s4kyfjj6.js";
39
39
  import {
40
40
  readRunEnd2
41
- } from "./compose-xhtgytrh.js";
41
+ } from "./compose-122g5jvb.js";
42
42
 
43
43
  // src/engine/waits.ts
44
44
  import { asId, SdkError } from "@nyte-ai/schema";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  decodeRunRecord2
3
- } from "./compose-gxjc6vz9.js";
3
+ } from "./compose-dw8fvn94.js";
4
4
  import {
5
5
  inboxRef2,
6
6
  runRef2,
@@ -17,20 +17,20 @@ import {
17
17
  put2,
18
18
  attempt2,
19
19
  readCall2
20
- } from "./compose-vn7b7fdj.js";
20
+ } from "./compose-ydth4n0z.js";
21
21
  import {
22
22
  stoppedParts2
23
- } from "./compose-d95fwwvw.js";
23
+ } from "./compose-kwbs1f34.js";
24
24
  import {
25
25
  commit2
26
- } from "./compose-bbhk8vnr.js";
26
+ } from "./compose-s4kyfjj6.js";
27
27
  import {
28
28
  liveParts2,
29
29
  readRunEnd2
30
- } from "./compose-xhtgytrh.js";
30
+ } from "./compose-122g5jvb.js";
31
31
  import {
32
32
  readParkedWait2
33
- } from "./compose-bz70g01d.js";
33
+ } from "./compose-kf2k4hq5.js";
34
34
 
35
35
  // src/engine/fence.ts
36
36
  var FENCED2 = { class: "aborted", message: "Stopped." };
@@ -3,21 +3,25 @@ import {
3
3
  } from "./compose-cqpjcx2t.js";
4
4
  import {
5
5
  sendReceipt2
6
- } from "./compose-fnncnk81.js";
6
+ } from "./compose-dywbt4he.js";
7
7
  import {
8
8
  move2
9
- } from "./compose-matk94se.js";
9
+ } from "./compose-zajq79k0.js";
10
10
  import {
11
11
  heldReceipt2,
12
12
  applyBatch2
13
- } from "./compose-2rha31fc.js";
13
+ } from "./compose-jbrtw0md.js";
14
14
  import {
15
15
  driveInProcess2
16
- } from "./compose-1tdb9ezw.js";
16
+ } from "./compose-8nysak5a.js";
17
+ import {
18
+ leaseHold2,
19
+ releaseHold2
20
+ } from "./compose-vxme67gg.js";
17
21
  import {
18
22
  redeemPairing2,
19
23
  authenticateToken2
20
- } from "./compose-jwy1gba9.js";
24
+ } from "./compose-7sjf0y70.js";
21
25
 
22
26
  // src/api/server.ts
23
27
  function createServerHost2(kernel) {
@@ -43,6 +47,8 @@ function createServerHost2(kernel) {
43
47
  loaded: (plugin) => kernel.plugins.host.includes(plugin),
44
48
  wire: {
45
49
  move: (session, head, position, options) => move2(kernel, session, head, position, options),
50
+ hold: (session, head, message) => leaseHold2(kernel, session, head, message),
51
+ release: (session, head, message) => releaseHold2(kernel, session, head, message),
46
52
  batch: (workspace, files, entries, id) => applyBatch2(kernel, { workspace }, files, entries, { id }),
47
53
  batchReceipt: (id) => heldReceipt2(kernel, id),
48
54
  sendReceipt: (session, id) => sendReceipt2(kernel, session, id),
@@ -13,16 +13,16 @@ import {
13
13
  walkCommitPath2,
14
14
  toCommitObjectId2,
15
15
  guard2
16
- } from "./compose-vn7b7fdj.js";
16
+ } from "./compose-ydth4n0z.js";
17
17
  import {
18
18
  commit2
19
- } from "./compose-bbhk8vnr.js";
19
+ } from "./compose-s4kyfjj6.js";
20
20
  import {
21
21
  withFold2
22
- } from "./compose-xhtgytrh.js";
22
+ } from "./compose-122g5jvb.js";
23
23
  import {
24
24
  fence2
25
- } from "./compose-w6zb11k1.js";
25
+ } from "./compose-kgdmzx0n.js";
26
26
 
27
27
  // src/engine/branch-summary.ts
28
28
  import { asId } from "@nyte-ai/schema";
@@ -6,7 +6,7 @@ import {
6
6
  } from "./compose-fqsqjbrf.js";
7
7
  import {
8
8
  decodePartRecord2
9
- } from "./compose-gxjc6vz9.js";
9
+ } from "./compose-dw8fvn94.js";
10
10
  import {
11
11
  parseSessionRef2,
12
12
  headRef2,
@@ -18,7 +18,7 @@ import {
18
18
  put2,
19
19
  toCommitObjectId2,
20
20
  readCall2
21
- } from "./compose-vn7b7fdj.js";
21
+ } from "./compose-ydth4n0z.js";
22
22
 
23
23
  // src/store/parts.ts
24
24
  import { asId } from "@nyte-ai/schema";
@@ -2,7 +2,7 @@ import {
2
2
  updatePart2,
3
3
  setTurn2,
4
4
  liveRun2
5
- } from "./compose-h14pmqv3.js";
5
+ } from "./compose-qgz6q016.js";
6
6
 
7
7
  // src/fold/calls.ts
8
8
  import { compile, isJsonObject, ToolClassType } from "@nyte-ai/schema";
@@ -5,7 +5,7 @@ import {
5
5
  MAIN2,
6
6
  readSession2,
7
7
  readKv2
8
- } from "./compose-vn7b7fdj.js";
8
+ } from "./compose-ydth4n0z.js";
9
9
  import {
10
10
  convertJsonSchema2
11
11
  } from "./compose-bj54tkph.js";
@@ -3,22 +3,22 @@ import {
3
3
  } from "./compose-1c6w12g1.js";
4
4
  import {
5
5
  STORED_RECORD_TYPES2
6
- } from "./compose-gxjc6vz9.js";
6
+ } from "./compose-dw8fvn94.js";
7
7
  import {
8
8
  decodeObject2
9
9
  } from "./compose-kwkna3cg.js";
10
10
  import {
11
11
  STORE_VERSION2
12
- } from "./compose-nj4nj5n9.js";
12
+ } from "./compose-0f9x3cjd.js";
13
13
  import {
14
14
  dev2
15
15
  } from "./compose-n116fnmp.js";
16
16
  import {
17
17
  FOLD_CODE2
18
- } from "./compose-767bb340.js";
18
+ } from "./compose-c7jk6qr1.js";
19
19
  import {
20
20
  EMPTY_CATALOG2
21
- } from "./compose-6gt28900.js";
21
+ } from "./compose-yxhvzsed.js";
22
22
 
23
23
  // src/fold/checkpoint.ts
24
24
  import {
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  START2,
6
6
  readPositionCommit2
7
- } from "./compose-vn7b7fdj.js";
7
+ } from "./compose-ydth4n0z.js";
8
8
  import {
9
9
  ZERO_USAGE2,
10
10
  addUsage2
@@ -13,7 +13,7 @@ import {
13
13
  snapshots2,
14
14
  emptyHead2,
15
15
  reuse2
16
- } from "./compose-h14pmqv3.js";
16
+ } from "./compose-qgz6q016.js";
17
17
 
18
18
  // src/fold/project.ts
19
19
  var DEFAULT_TAIL = 200;
@@ -21,6 +21,7 @@ var projections = new WeakMap;
21
21
  var unreads = new WeakMap;
22
22
  var NOTHING_SEEN = new Map;
23
23
  var tails = new WeakMap;
24
+ var queues = new WeakMap;
24
25
  var absent = new WeakMap;
25
26
  var windows = new WeakMap;
26
27
  var usages = new WeakMap;
@@ -33,7 +34,8 @@ function project2(state, head, options) {
33
34
  const cached = byTail.get(tail);
34
35
  if (cached !== undefined && cached.seq === state.seq && cached.activation === state.activation && cached.parts === state.partViews && cached.heads === heads && cached.changes === state.changes && cached.catalog === state.catalog)
35
36
  return cached;
36
- const messages = readMessageTail(folded.messages, tail);
37
+ const execution = folded.info.execution;
38
+ const messages = readMessageTail(folded.messages, tail, execution);
37
39
  const turns = frozen(folded.turns);
38
40
  const path = state[INDEX2].paths.get(head);
39
41
  const view = {
@@ -41,11 +43,13 @@ function project2(state, head, options) {
41
43
  seq: state.seq,
42
44
  activation: state.activation,
43
45
  messages,
44
- leadingPrompt: findLeadingPrompt2(path, folded.messages.length - messages.length),
46
+ queue: readQueue(state, folded),
47
+ leadingPrompt: findLeadingPrompt2(path, Math.max(0, folded.messages.length - tail)),
45
48
  parts: state.partViews,
46
49
  turns: readTurnWindow(turns, path, messages),
47
50
  usage: sumCompletedUsage(turns),
48
- execution: folded.info.execution,
51
+ execution,
52
+ reportsHeld: holdsReports2(execution),
49
53
  background: folded.background,
50
54
  configuration: folded.configuration,
51
55
  context: folded.context,
@@ -58,8 +62,8 @@ function project2(state, head, options) {
58
62
  projections.set(folded, byPrincipal);
59
63
  return view;
60
64
  }
61
- function readSeenCommit2(state, head) {
62
- return state.seen.get(state.principal)?.get(head) ?? null;
65
+ function holdsReports2(execution) {
66
+ return execution.kind === "idle" && execution.lastRun?.end.kind !== "completed";
63
67
  }
64
68
  function headsFor(state) {
65
69
  const seen = state.seen.get(state.principal) ?? NOTHING_SEEN;
@@ -93,13 +97,29 @@ function absentHead(heads, name) {
93
97
  absent.set(heads, known);
94
98
  return head;
95
99
  }
96
- function readMessageTail(messages, tail) {
100
+ function readMessageTail(messages, tail, execution) {
97
101
  const known = tails.get(messages) ?? new Map;
98
- const slice = reuse2(known.get(tail) ?? [], messages.slice(Math.max(0, messages.length - tail)));
102
+ const slice = reuse2(known.get(tail) ?? [], messages.slice(Math.max(0, messages.length - tail)).filter((message) => !belongsInQueue(message, execution)));
99
103
  known.set(tail, slice);
100
104
  tails.set(messages, known);
101
105
  return slice;
102
106
  }
107
+ function readQueue(state, folded) {
108
+ const queue = reuse2(queues.get(folded.messages) ?? [], folded.pending.flatMap((id) => {
109
+ const message = state.messages.get(id);
110
+ return message !== undefined && belongsInQueue(message, folded.info.execution) ? [message] : [];
111
+ }));
112
+ queues.set(folded.messages, queue);
113
+ return queue;
114
+ }
115
+ function belongsInQueue(message, execution) {
116
+ if (message.kind !== "user" || message.status.kind !== "pending")
117
+ return false;
118
+ if (message.source.kind === "child" || message.source.kind === "job")
119
+ return false;
120
+ const schedule = message.status.schedule;
121
+ return schedule.kind === "attached" || schedule.kind === "next-turn" && (schedule.reason !== "idle" || execution.kind !== "idle" && message.delivery !== "steer");
122
+ }
103
123
  function findLeadingPrompt2(path, start) {
104
124
  const first = path?.messages[start];
105
125
  if (path === undefined || first === undefined)
@@ -138,4 +158,4 @@ function frozen(turns) {
138
158
  return snapshot;
139
159
  }
140
160
 
141
- export { project2, readSeenCommit2, withPair2, findLeadingPrompt2 };
161
+ export { project2, holdsReports2, withPair2, findLeadingPrompt2 };
@@ -13,7 +13,7 @@ import {
13
13
  } from "./compose-fqsqjbrf.js";
14
14
  import {
15
15
  decodeRunRecord2
16
- } from "./compose-gxjc6vz9.js";
16
+ } from "./compose-dw8fvn94.js";
17
17
  import {
18
18
  runRef2
19
19
  } from "./compose-cqpjcx2t.js";
@@ -23,22 +23,22 @@ import {
23
23
  requireSession2,
24
24
  walkCommitPath2,
25
25
  readPositionCommit2
26
- } from "./compose-vn7b7fdj.js";
26
+ } from "./compose-ydth4n0z.js";
27
27
  import {
28
28
  withFold2
29
- } from "./compose-xhtgytrh.js";
29
+ } from "./compose-122g5jvb.js";
30
30
  import {
31
31
  modelImage2
32
32
  } from "./compose-c4238qkb.js";
33
33
  import {
34
34
  scanResources2
35
- } from "./compose-c4z4kp98.js";
35
+ } from "./compose-j8xmyfy6.js";
36
36
  import {
37
37
  hiddenOwners2
38
- } from "./compose-bd8c5n7k.js";
38
+ } from "./compose-qyjchprv.js";
39
39
  import {
40
40
  toolSource2
41
- } from "./compose-ae5t6v5b.js";
41
+ } from "./compose-zq7ar8qm.js";
42
42
 
43
43
  // src/agent/transcript.ts
44
44
  import { isJsonObject } from "@nyte-ai/schema";
@@ -48,6 +48,7 @@ var THOUGHTS = `
48
48
  `;
49
49
  var SUMMARISED = "The earlier conversation was summarised to fit the context window. The summary:";
50
50
  var ABANDONED = "The conversation moved back to an earlier point, abandoning a path. What that path did:";
51
+ var CONTINUE = "The previous response was interrupted. Continue from where you left off without repeating completed content.";
51
52
  var projections = new WeakMap;
52
53
  var IMAGE_CACHE_CHARS = 64 * 1024 * 1024;
53
54
  var imageCache = new WeakMap;
@@ -193,6 +194,7 @@ async function conversation(kernel, models, input) {
193
194
  for (const call of ordered)
194
195
  push(await toolResult(kernel, call.id, call.state, call.at, input.images), call.commit);
195
196
  };
197
+ const continueAfter = (cut) => push({ role: "user", content: CONTINUE, timestamp: cut.at }, cut.commit);
196
198
  const calls = steps.flatMap((step) => step.part?.partKind === "tool" ? [step.part.id] : []);
197
199
  for (const step of steps) {
198
200
  for (const compacted of anchors.get(step.commit) ?? []) {
@@ -222,13 +224,18 @@ async function conversation(kernel, models, input) {
222
224
  const blocks = await assistantBlocks(part, step.record.run);
223
225
  const call = blocks.call;
224
226
  const response = call === null ? null : parseResponseIndex(call.call, step.record.run);
225
- if (group !== null && (group.run !== step.record.run || call === null && group.calls.length > 0 || call !== null && group.response !== null && response !== group.response))
227
+ const attempt = call === null ? parseAttempt(part.id, step.record.run) : null;
228
+ const cut = group !== null && group.run === step.record.run && group.calls.length === 0 && group.attempt !== null && attempt !== null && attempt !== group.attempt ? group : null;
229
+ if (group !== null && (cut !== null || group.run !== step.record.run || call === null && group.calls.length > 0 || call !== null && group.response !== null && response !== group.response))
226
230
  await flush();
231
+ if (cut !== null)
232
+ continueAfter(cut);
227
233
  if (blocks.content.length === 0)
228
234
  continue;
229
235
  group ??= {
230
236
  commit: step.commit,
231
237
  run: step.record.run,
238
+ attempt,
232
239
  model: step.model,
233
240
  at: step.record.at,
234
241
  response: null,
@@ -255,7 +262,10 @@ async function conversation(kernel, models, input) {
255
262
  if (note !== null)
256
263
  push({ role: "user", content: note, timestamp: step.record.at }, step.commit);
257
264
  }
265
+ const trailing = group;
258
266
  await flush();
267
+ if (trailing !== null && input.run !== null && trailing.run === input.run && trailing.calls.length === 0)
268
+ continueAfter(trailing);
259
269
  const answered = answers.at(-1);
260
270
  if (answered === undefined || answered.run === null)
261
271
  return messages;
@@ -519,6 +529,11 @@ function fencedExcerpt(text) {
519
529
  function escapeAttribute(value) {
520
530
  return value.replaceAll("&", "&amp;").replaceAll('"', "&quot;").replaceAll("<", "&lt;");
521
531
  }
532
+ function parseAttempt(part, run) {
533
+ if (run === null || !part.startsWith(`${run}:`))
534
+ return null;
535
+ return /^a(\d+):/.exec(part.slice(run.length + 1))?.[1] ?? null;
536
+ }
522
537
  function parseResponseIndex(call, run) {
523
538
  if (run === null || !call.startsWith(`${run}:`))
524
539
  return null;
@@ -0,0 +1,74 @@
1
+ import {
2
+ HOLD_MS2
3
+ } from "./compose-s23st6q6.js";
4
+
5
+ // src/api/hold.ts
6
+ var RENEW_MS = 5000;
7
+ async function holdMessage2(message, operations) {
8
+ const asked = Date.now();
9
+ const first = await operations.hold();
10
+ if (first.kind !== "held")
11
+ return first;
12
+ const lost = Promise.withResolvers();
13
+ const expired = Promise.withResolvers();
14
+ let renewing = true;
15
+ let renewal = Promise.resolve();
16
+ let released = null;
17
+ const stop = () => {
18
+ renewing = false;
19
+ clearTimeout(timer);
20
+ };
21
+ const lose = (reason) => {
22
+ if (!renewing)
23
+ return;
24
+ stop();
25
+ lost.resolve(reason);
26
+ };
27
+ const expire = () => {
28
+ expired.resolve();
29
+ lose({ kind: "lapsed" });
30
+ };
31
+ const renewLater = () => {
32
+ if (renewing)
33
+ timer = setTimeout(renew, RENEW_MS);
34
+ };
35
+ const renew = () => {
36
+ const sent = Date.now();
37
+ renewal = operations.hold().then((lease) => {
38
+ if (lease.kind !== "held")
39
+ return lose(lease);
40
+ if (!renewing)
41
+ return;
42
+ clearTimeout(expiry);
43
+ expiry = setTimeout(expire, sent + HOLD_MS2 - Date.now());
44
+ renewLater();
45
+ }, renewLater);
46
+ };
47
+ let timer = setTimeout(renew, RENEW_MS);
48
+ let expiry = setTimeout(expire, asked + HOLD_MS2 - Date.now());
49
+ const release = () => {
50
+ stop();
51
+ released ??= Promise.race([
52
+ renewal.then(() => operations.release()).then(() => ({ kind: "released" }), () => ({ kind: "lapsing" })),
53
+ expired.promise.then(() => ({ kind: "lapsing" }))
54
+ ]).finally(() => clearTimeout(expiry));
55
+ return released;
56
+ };
57
+ return {
58
+ kind: "held",
59
+ message,
60
+ lost: lost.promise,
61
+ async save(content, options) {
62
+ stop();
63
+ const revised = await operations.revise(content, options);
64
+ await release();
65
+ return revised;
66
+ },
67
+ release,
68
+ async[Symbol.asyncDispose]() {
69
+ await release();
70
+ }
71
+ };
72
+ }
73
+
74
+ export { holdMessage2 };
@@ -15,7 +15,7 @@ import {
15
15
  import {
16
16
  sessionIndexRef2,
17
17
  projectSessionIndex2
18
- } from "./compose-y6xgbg2h.js";
18
+ } from "./compose-qq85vkhf.js";
19
19
 
20
20
  // src/store/memory-store.ts
21
21
  import { asId, asSeq } from "@nyte-ai/schema";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  decodeRunRecord2
3
- } from "./compose-gxjc6vz9.js";
3
+ } from "./compose-dw8fvn94.js";
4
4
  import {
5
5
  objectId2
6
6
  } from "./compose-q6c7wswc.js";
@@ -19,10 +19,10 @@ import {
19
19
  put2,
20
20
  attempt2,
21
21
  listSessionRecords2
22
- } from "./compose-vn7b7fdj.js";
22
+ } from "./compose-ydth4n0z.js";
23
23
  import {
24
24
  commit2
25
- } from "./compose-bbhk8vnr.js";
25
+ } from "./compose-s4kyfjj6.js";
26
26
  import {
27
27
  latest2,
28
28
  closable2,
@@ -31,26 +31,26 @@ import {
31
31
  import {
32
32
  createJobs2,
33
33
  jobHandle2
34
- } from "./compose-nkxwrphm.js";
34
+ } from "./compose-17xxey5y.js";
35
35
  import {
36
36
  inspectWorkspaceAvailability2,
37
37
  readWorkspace2,
38
38
  workspaceRecords2
39
- } from "./compose-4ppmas7g.js";
39
+ } from "./compose-zt2qtrxj.js";
40
40
  import {
41
41
  readFolderTrust2,
42
42
  decideTrust2
43
- } from "./compose-8pp3vtv0.js";
43
+ } from "./compose-hx8j2kef.js";
44
44
  import {
45
45
  dropScans2
46
- } from "./compose-c4z4kp98.js";
46
+ } from "./compose-j8xmyfy6.js";
47
47
  import {
48
48
  mcpApi2
49
- } from "./compose-gj2ypr7q.js";
49
+ } from "./compose-5ygdrc65.js";
50
50
  import {
51
51
  readAttributedPaths2,
52
52
  ownedChanges2
53
- } from "./compose-yfcb6w2h.js";
53
+ } from "./compose-0zrwy7nk.js";
54
54
 
55
55
  // src/env/workspaces.ts
56
56
  import { asId, SdkError } from "@nyte-ai/schema";
@@ -8,10 +8,10 @@ import {
8
8
  requireSession2,
9
9
  put2,
10
10
  readKv2
11
- } from "./compose-vn7b7fdj.js";
11
+ } from "./compose-ydth4n0z.js";
12
12
  import {
13
13
  commit2
14
- } from "./compose-bbhk8vnr.js";
14
+ } from "./compose-s4kyfjj6.js";
15
15
 
16
16
  // src/extend/plugin-api.ts
17
17
  import { isJsonObject, SdkError } from "@nyte-ai/schema";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  START2
3
- } from "./compose-vn7b7fdj.js";
3
+ } from "./compose-ydth4n0z.js";
4
4
 
5
5
  // src/fold/draft.ts
6
6
  import { asId } from "@nyte-ai/schema";
@@ -4,7 +4,7 @@ import {
4
4
  decodeInboxRecord2,
5
5
  decodeReceiptRecord2,
6
6
  decodeCallRecord2
7
- } from "./compose-gxjc6vz9.js";
7
+ } from "./compose-dw8fvn94.js";
8
8
 
9
9
  // src/store/session-index.ts
10
10
  import { asId } from "@nyte-ai/schema";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  decodeRunRecord2
3
- } from "./compose-gxjc6vz9.js";
3
+ } from "./compose-dw8fvn94.js";
4
4
  import {
5
5
  runRef2
6
6
  } from "./compose-cqpjcx2t.js";
7
7
  import {
8
8
  load2
9
- } from "./compose-vn7b7fdj.js";
9
+ } from "./compose-ydth4n0z.js";
10
10
 
11
11
  // src/engine/surface.ts
12
12
  var NONE = new Set;