@nyte-ai/core 0.0.25-nightly.20261102.45 → 0.0.27

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 (229) hide show
  1. package/README.md +38 -6
  2. package/THIRD-PARTY-NOTICES.md +65 -0
  3. package/dist/chunks/{compose-c70pftcp.js → compose-055ad57g.js} +1 -1
  4. package/dist/chunks/{compose-hvm8h84y.js → compose-06npxy5m.js} +11 -11
  5. package/dist/chunks/{compose-g5dcx4x6.js → compose-0pgfd2m6.js} +3 -3
  6. package/dist/chunks/compose-0pgmfvqq.js +180 -0
  7. package/dist/chunks/{compose-9n22j1aj.js → compose-27jdjx5y.js} +1 -1
  8. package/dist/chunks/{compose-77td4ezy.js → compose-2k0vnyp3.js} +43 -22
  9. package/dist/chunks/{compose-d89dbcyn.js → compose-2khx6tjw.js} +44 -9
  10. package/dist/chunks/{compose-fe3d46kv.js → compose-2rze4dp0.js} +4 -4
  11. package/dist/chunks/{compose-4ar81ka1.js → compose-3hk932nc.js} +3 -7
  12. package/dist/chunks/compose-3v627j0s.js +18 -0
  13. package/dist/chunks/{compose-8py9dgfe.js → compose-3vbyrkdd.js} +91 -21
  14. package/dist/chunks/{compose-j377ywyv.js → compose-3z4yana6.js} +7 -7
  15. package/dist/chunks/compose-46w2zh74.js +334 -0
  16. package/dist/chunks/{compose-b9q4f4dt.js → compose-4s1p6hkf.js} +7 -4
  17. package/dist/chunks/compose-4vv109cy.js +183 -0
  18. package/dist/chunks/{compose-sh0w6j2t.js → compose-4xt553qr.js} +5 -5
  19. package/dist/chunks/{compose-eks0v2e1.js → compose-5a8v4p46.js} +50 -204
  20. package/dist/chunks/{compose-yb0nppw2.js → compose-5m8xpg89.js} +8 -8
  21. package/dist/chunks/{compose-8ranx653.js → compose-6010025t.js} +1 -1
  22. package/dist/chunks/{compose-8qzbd5v4.js → compose-63tdemgm.js} +4 -4
  23. package/dist/chunks/{compose-frk4x47e.js → compose-7rg4gapa.js} +10 -10
  24. package/dist/chunks/{compose-w4kyepe1.js → compose-7wnrbjj6.js} +5 -4
  25. package/dist/chunks/{compose-s54zz0gr.js → compose-7z3s2jh4.js} +12 -9
  26. package/dist/chunks/{compose-89mysm6t.js → compose-8e6d0bgc.js} +3 -3
  27. package/dist/chunks/{compose-3y7e4sk0.js → compose-8wgzd0xk.js} +28 -36
  28. package/dist/chunks/{compose-58sqsjb1.js → compose-998zw23w.js} +2 -2
  29. package/dist/chunks/{compose-65vwdtz0.js → compose-9btw2ftt.js} +8 -8
  30. package/dist/chunks/{compose-n6wx7af7.js → compose-9ea1z187.js} +1 -1
  31. package/dist/chunks/{compose-56k06pjv.js → compose-a3cden7x.js} +1 -1
  32. package/dist/chunks/compose-anx0exmp.js +74 -0
  33. package/dist/chunks/{compose-gbmt77cm.js → compose-b5m0rmfh.js} +33 -2
  34. package/dist/chunks/{compose-c944b1a5.js → compose-bkhsj5yx.js} +2 -2
  35. package/dist/chunks/{compose-ngp8g3dg.js → compose-c3b46yga.js} +6 -6
  36. package/dist/chunks/compose-cnwbszcc.js +61 -0
  37. package/dist/chunks/{compose-xrgykj1w.js → compose-cvh0zrhj.js} +4 -4
  38. package/dist/chunks/compose-deneqk7y.js +345 -0
  39. package/dist/chunks/{compose-5xjjq4zp.js → compose-fhre47zv.js} +7 -7
  40. package/dist/chunks/{compose-fsm5ydya.js → compose-fkj32m47.js} +7 -7
  41. package/dist/chunks/{compose-2an5qt0b.js → compose-fs0g7btz.js} +20 -3
  42. package/dist/chunks/{compose-g15n3r59.js → compose-g7939vn0.js} +3 -2
  43. package/dist/chunks/{compose-efp5vth9.js → compose-gqm6dxkj.js} +22 -36
  44. package/dist/chunks/{compose-4pe9jr17.js → compose-h2bxs4jj.js} +3 -3
  45. package/dist/chunks/{compose-ppxjmmfe.js → compose-h9p301x9.js} +43 -48
  46. package/dist/chunks/{compose-2t4tp1ab.js → compose-hf725nb9.js} +4 -4
  47. package/dist/chunks/{compose-1y6yrtw5.js → compose-hy53eheq.js} +7 -7
  48. package/dist/chunks/{compose-gx2jdx10.js → compose-jcdkrkrq.js} +5 -5
  49. package/dist/chunks/{compose-5z99fqgd.js → compose-jwnnb7rq.js} +56 -19
  50. package/dist/chunks/{compose-mcypbkjh.js → compose-k7zrqkwd.js} +14 -21
  51. package/dist/chunks/compose-kd2ythd8.js +41 -0
  52. package/dist/chunks/{compose-ny2p9g1g.js → compose-kdwr4f9h.js} +9 -3
  53. package/dist/chunks/{compose-9qymgf8n.js → compose-kw7fr9gb.js} +46 -18
  54. package/dist/chunks/{compose-67qwfgce.js → compose-m4nbk7cg.js} +19 -8
  55. package/dist/chunks/compose-n5ya4mwn.js +57 -0
  56. package/dist/chunks/compose-nn05pggt.js +132 -0
  57. package/dist/chunks/{compose-1z7vk4fr.js → compose-nqas4rj1.js} +2 -2
  58. package/dist/chunks/{compose-zjh6r2wz.js → compose-pbnycs2z.js} +3 -3
  59. package/dist/chunks/{compose-n37fj82b.js → compose-pe5q9ws1.js} +4 -4
  60. package/dist/chunks/{compose-dw6rvv7z.js → compose-pfesbnwr.js} +3 -3
  61. package/dist/chunks/{compose-1q6r13w3.js → compose-pvg74sc3.js} +2 -2
  62. package/dist/chunks/{compose-zxq8rtap.js → compose-q4xx59j9.js} +3 -3
  63. package/dist/chunks/{compose-hj9fyqtm.js → compose-q7an3bw4.js} +69 -22
  64. package/dist/chunks/compose-qdhj0nek.js +30 -0
  65. package/dist/chunks/{compose-az21dy3p.js → compose-qt8w23kc.js} +3 -3
  66. package/dist/chunks/compose-r1j3g6qs.js +42 -0
  67. package/dist/chunks/{compose-zfjxkavf.js → compose-r714e418.js} +1 -52
  68. package/dist/chunks/{compose-v10qawnc.js → compose-rthykcv3.js} +16 -22
  69. package/dist/chunks/{compose-h1ezbkcd.js → compose-ryqb4grg.js} +8 -8
  70. package/dist/chunks/{compose-9hkyfh6s.js → compose-s53kwh1s.js} +4 -4
  71. package/dist/chunks/{compose-q4y9x1z2.js → compose-sd9z9n34.js} +6 -10
  72. package/dist/chunks/{compose-r4t84f2g.js → compose-t04sevkp.js} +5 -5
  73. package/dist/chunks/{compose-1s6jt3sf.js → compose-t6r6mnry.js} +50 -105
  74. package/dist/chunks/{compose-efejrk5g.js → compose-tdjsw8a8.js} +12 -19
  75. package/dist/chunks/{compose-1sdtv9fx.js → compose-tsvc143b.js} +3 -3
  76. package/dist/chunks/{compose-bqxw5sad.js → compose-v1qy7at2.js} +19 -19
  77. package/dist/chunks/{compose-8qkapskh.js → compose-v393apkc.js} +5 -5
  78. package/dist/chunks/{compose-90679jqf.js → compose-v4wdxywp.js} +4 -1
  79. package/dist/chunks/compose-vdq5n6th.js +34 -0
  80. package/dist/chunks/{compose-8xg4vmyk.js → compose-vstnxkah.js} +10 -8
  81. package/dist/chunks/{compose-9cqmj6wb.js → compose-w9harpgf.js} +4 -4
  82. package/dist/chunks/{compose-fs1cxwk5.js → compose-wnh9mvp0.js} +20 -13
  83. package/dist/chunks/{compose-x4dc0b5h.js → compose-wq6n7832.js} +27 -18
  84. package/dist/chunks/{compose-ndtqjr1n.js → compose-wt8qer4v.js} +24 -8
  85. package/dist/chunks/{compose-gef9m827.js → compose-xe03b4qd.js} +17 -17
  86. package/dist/chunks/{compose-p8j7dvrt.js → compose-yt8mgrrz.js} +19 -19
  87. package/dist/chunks/{compose-1w7vhqzy.js → compose-ytybhb9r.js} +5 -5
  88. package/dist/chunks/{compose-tp28a0vz.js → compose-z5kyvvcn.js} +5 -5
  89. package/dist/chunks/{compose-k8204r78.js → compose-z7ex5h37.js} +16 -16
  90. package/dist/chunks/{compose-d0rtfrbc.js → compose-zt01bebj.js} +1 -1
  91. package/dist/src/agent/agent-loop.js +1 -1
  92. package/dist/src/agent/compaction.js +55 -51
  93. package/dist/src/agent/open-parts.js +7 -6
  94. package/dist/src/agent/prompt-sections.js +23 -21
  95. package/dist/src/agent/request.js +40 -36
  96. package/dist/src/agent/tool-runner.js +54 -49
  97. package/dist/src/agent/transcript.js +51 -46
  98. package/dist/src/agent/turn.js +64 -60
  99. package/dist/src/api/attach.d.ts +4 -0
  100. package/dist/src/api/attach.js +19 -0
  101. package/dist/src/api/connection.js +80 -73
  102. package/dist/src/api/head.js +59 -53
  103. package/dist/src/api/host.js +2 -2
  104. package/dist/src/api/part.js +26 -26
  105. package/dist/src/api/server.js +78 -59
  106. package/dist/src/api/session-changes.d.ts +3 -0
  107. package/dist/src/api/session-changes.js +86 -0
  108. package/dist/src/api/session.d.ts +9 -3
  109. package/dist/src/api/session.js +67 -60
  110. package/dist/src/builtins/environment.js +2 -1
  111. package/dist/src/compose.js +93 -84
  112. package/dist/src/contract/fold.d.ts +40 -3
  113. package/dist/src/contract/host.d.ts +11 -2
  114. package/dist/src/contract/kernel.d.ts +7 -7
  115. package/dist/src/contract/parts.d.ts +1 -3
  116. package/dist/src/contract/records.d.ts +45 -3
  117. package/dist/src/contract/records.js +3 -1
  118. package/dist/src/contract/server.d.ts +31 -1
  119. package/dist/src/contract/session.d.ts +15 -19
  120. package/dist/src/contract/store.d.ts +23 -7
  121. package/dist/src/contract/workspace.d.ts +2 -0
  122. package/dist/src/drive/execution.js +60 -56
  123. package/dist/src/drive/interruptions.js +7 -6
  124. package/dist/src/engine/admission-writes.js +6 -5
  125. package/dist/src/engine/admission.js +30 -28
  126. package/dist/src/engine/batches.js +27 -25
  127. package/dist/src/engine/branch-summary.js +26 -24
  128. package/dist/src/engine/children.js +6 -5
  129. package/dist/src/engine/contributions.js +6 -5
  130. package/dist/src/engine/durable.js +25 -23
  131. package/dist/src/engine/fence.js +25 -23
  132. package/dist/src/engine/fork.d.ts +9 -0
  133. package/dist/src/engine/fork.js +35 -0
  134. package/dist/src/engine/holds.js +31 -29
  135. package/dist/src/engine/jobs.js +34 -31
  136. package/dist/src/engine/move.js +28 -26
  137. package/dist/src/engine/presence.js +4 -4
  138. package/dist/src/engine/principals.js +23 -21
  139. package/dist/src/engine/receipts.js +26 -24
  140. package/dist/src/engine/runs.js +32 -29
  141. package/dist/src/engine/start.js +43 -46
  142. package/dist/src/engine/surface.d.ts +2 -0
  143. package/dist/src/engine/surface.js +10 -7
  144. package/dist/src/engine/waits.js +24 -22
  145. package/dist/src/env/browser.js +35 -32
  146. package/dist/src/env/environment.d.ts +7 -1
  147. package/dist/src/env/environment.js +46 -37
  148. package/dist/src/env/mcp.js +41 -38
  149. package/dist/src/env/session-changes.d.ts +5 -1
  150. package/dist/src/env/session-changes.js +13 -6
  151. package/dist/src/env/trust.js +40 -37
  152. package/dist/src/env/variables.js +24 -22
  153. package/dist/src/env/workspaces.d.ts +1 -9
  154. package/dist/src/env/workspaces.js +50 -52
  155. package/dist/src/env/worktrees.js +42 -45
  156. package/dist/src/extend/activation.js +50 -46
  157. package/dist/src/extend/hooks.js +27 -25
  158. package/dist/src/extend/models.js +39 -35
  159. package/dist/src/extend/plugin-api.js +23 -21
  160. package/dist/src/extend/plugin-folders.js +41 -38
  161. package/dist/src/extend/plugin-runtime.js +56 -50
  162. package/dist/src/extend/registry.js +36 -32
  163. package/dist/src/extend/resources.js +43 -40
  164. package/dist/src/extend/secret-settings.js +24 -22
  165. package/dist/src/extend/setting-layers.js +25 -23
  166. package/dist/src/extend/settings.js +53 -47
  167. package/dist/src/extend/workspace-commands.js +57 -51
  168. package/dist/src/fold/calls.js +9 -6
  169. package/dist/src/fold/checkpoint.d.ts +5 -1
  170. package/dist/src/fold/checkpoint.js +20 -14
  171. package/dist/src/fold/code.d.ts +1 -1
  172. package/dist/src/fold/code.js +1 -1
  173. package/dist/src/fold/commit.d.ts +6 -1
  174. package/dist/src/fold/commit.js +22 -20
  175. package/dist/src/fold/draft.d.ts +18 -100
  176. package/dist/src/fold/draft.js +40 -9
  177. package/dist/src/fold/fold.d.ts +1 -2
  178. package/dist/src/fold/fold.js +13 -11
  179. package/dist/src/fold/paths.d.ts +2 -1
  180. package/dist/src/fold/paths.js +14 -8
  181. package/dist/src/fold/project.d.ts +2 -9
  182. package/dist/src/fold/project.js +8 -14
  183. package/dist/src/fold/reads.js +6 -5
  184. package/dist/src/fold/seen.js +24 -22
  185. package/dist/src/fold/view.d.ts +1 -13
  186. package/dist/src/fold/view.js +14 -15
  187. package/dist/src/fold/watch.d.ts +1 -1
  188. package/dist/src/fold/watch.js +21 -19
  189. package/dist/src/fold/window.d.ts +6 -0
  190. package/dist/src/fold/window.js +24 -0
  191. package/dist/src/harness.d.ts +64 -62
  192. package/dist/src/harness.js +95 -87
  193. package/dist/src/index.d.ts +5 -3
  194. package/dist/src/index.js +34 -10
  195. package/dist/src/server.d.ts +1 -1
  196. package/dist/src/server.js +86 -77
  197. package/dist/src/store/catalogs.d.ts +7 -0
  198. package/dist/src/store/catalogs.js +12 -0
  199. package/dist/src/store/inspect.js +6 -5
  200. package/dist/src/store/log.js +2 -2
  201. package/dist/src/store/memory-store.js +6 -5
  202. package/dist/src/store/migrations.d.ts +12 -0
  203. package/dist/src/store/migrations.js +4 -3
  204. package/dist/src/store/model-state.js +6 -5
  205. package/dist/src/store/parts.js +6 -5
  206. package/dist/src/store/refs.d.ts +1 -0
  207. package/dist/src/store/refs.js +3 -1
  208. package/dist/src/store/session-index-steps.d.ts +4 -0
  209. package/dist/src/store/session-index-steps.js +10 -0
  210. package/dist/src/store/session-index.d.ts +5 -1
  211. package/dist/src/store/session-index.js +7 -3
  212. package/dist/src/store/session.d.ts +6 -1
  213. package/dist/src/store/session.js +7 -4
  214. package/dist/src/store.d.ts +2 -2
  215. package/dist/src/store.js +20 -14
  216. package/dist/src/testing.d.ts +3 -2
  217. package/dist/src/testing.js +105 -88
  218. package/dist/src/util/clip.d.ts +16 -0
  219. package/dist/src/util/clip.js +10 -0
  220. package/dist/src/util/iterable.d.ts +0 -12
  221. package/dist/src/util/iterable.js +3 -5
  222. package/dist/src/util/text.d.ts +1 -0
  223. package/dist/src/util/text.js +4 -2
  224. package/package.json +8 -8
  225. package/dist/chunks/compose-6p44ssmp.js +0 -173
  226. package/dist/chunks/compose-9xfsd802.js +0 -196
  227. package/dist/chunks/compose-gspk68s5.js +0 -122
  228. package/dist/chunks/compose-pk0fxwrs.js +0 -58
  229. package/dist/chunks/compose-rxsqmcgq.js +0 -8
package/README.md CHANGED
@@ -1,16 +1,48 @@
1
1
  # @nyte-ai/core
2
2
 
3
- Core owns durable session state and execution. `composeHost` (`@nyte-ai/core/server`) builds a host from a `Store`, the `@nyte-ai/ai` models, core plugins and a default workspace; [host](../host/README.md)'s `openHost`, which the sdk's Node `sdk.open` is, calls it with what a machine supplies. Clients do not import core: they use `@nyte-ai/sdk`, whose types are core's and schema's.
3
+ Core owns durable session state and execution. You use it directly only to build a host. Clients use `@nyte-ai/sdk`, whose types come from core and `@nyte-ai/schema`.
4
+
5
+ ## Quick start
6
+
7
+ `composeHost` builds a host from a `Store`, a `Models` from `@nyte-ai/ai`, core plugins and a default workspace:
8
+
9
+ ```ts
10
+ import { createModels } from "@nyte-ai/ai/models";
11
+ import { InMemoryCredentialStore } from "@nyte-ai/ai/auth/credential-store";
12
+ import { composeHost } from "@nyte-ai/core/server";
13
+ import { memoryStore } from "@nyte-ai/core/store";
14
+ import { chatOnlyProvider } from "@nyte-ai/host/providers";
15
+
16
+ const host = await composeHost({
17
+ store: memoryStore(),
18
+ models: createModels({ credentials: new InMemoryCredentialStore() }),
19
+ plugins: [{ id: "chat-only", environment: chatOnlyProvider() }],
20
+ workspace: { kind: "chat-only", locator: null },
21
+ home: null,
22
+ description: { name: "my-host", platform: "node", version: "0.1.0" },
23
+ });
24
+ ```
4
25
 
5
- The package has four entries: [src/index.ts](src/index.ts) (`.`), the client and plugin contract; [src/store.ts](src/store.ts) (`./store`), the store-backend SPI host's stores implement; [src/server.ts](src/server.ts) (`./server`), composition and the `ServerHost` port a listener serves a composed host through; and [src/testing.ts](src/testing.ts) (`./testing`), the kernel under a composed host, the steps the tests of other packages drive by hand and the scripted-turn harness ([src/harness.ts](src/harness.ts)) core's own tests share, outside the SDK contract.
26
+ On a machine, `openHost` in [`@nyte-ai/host`](../host/README.md) calls `composeHost` with that machine's store, models and workspace. The sdk's Node `sdk.open` is `openHost`.
6
27
 
7
- A store is two primitives: immutable content-addressed objects, written before any publish, and refs, the only mutable state, published as one all-or-nothing `refs.set` batch. `memoryStore` (`./store`) is the in-process one; sqlite, postgres and Durable Object storage live in host. A head's `watch()` folds the session into one `SessionView` per change, and the sdk folds the wire's deltas with the same code, so no client derives what the view carries.
28
+ ## Entry points
8
29
 
9
- Core imports no `node:*` module, so the sdk's browser and React Native entry can load it.
30
+ | Entry | What it holds |
31
+ | --- | --- |
32
+ | `@nyte-ai/core` | The client and plugin contract, and the `Store` interface that store backends implement |
33
+ | `@nyte-ai/core/store` | `memoryStore`, and the record decoders, ref names and migrations that store backends share |
34
+ | `@nyte-ai/core/server` | `composeHost`, and the `ServerHost` interface that a listener serves a composed host through |
35
+ | `@nyte-ai/core/testing` | The kernel under a composed host, the steps other packages' tests drive by hand, and the scripted-turn helpers core's tests share. It is outside the SDK contract. |
36
+
37
+ ## How it works
10
38
 
11
- ## Verification
39
+ A store holds two kinds of data. Objects are immutable and content-addressed, and core writes them before any publish. Refs are the only mutable state, and core publishes them in one all-or-nothing `refs.set` batch. `memoryStore` keeps both in process. The SQLite, PostgreSQL and Durable Object stores live in `@nyte-ai/host`.
40
+
41
+ Core folds a session's log into its current state. `Head.view()` answers one `SessionView` from that fold. Clients in another process read rows and apply change events instead, as the [host protocol](../../docs/host-protocol/README.md) describes.
42
+
43
+ Core imports no `node:*` module, so the sdk's browser and React Native entry can load it.
12
44
 
13
- From the repository root:
45
+ ## Development
14
46
 
15
47
  ```sh
16
48
  pnpm --dir packages/core test
@@ -611,6 +611,71 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
611
611
  SOFTWARE.
612
612
  ```
613
613
 
614
+ ## Ghostty (`ghostty-org/ghostty`)
615
+
616
+ - Repository: https://github.com/ghostty-org/ghostty
617
+ - What: `packages/vt/ghostty-vt.wasm` is the signed libghostty-vt WebAssembly
618
+ build from Ghostty's `tip` release at the commit recorded in
619
+ `packages/vt/pin.json`, shipped unmodified. `packages/vt` binds its C API.
620
+
621
+ License: MIT, with the following notice:
622
+
623
+ ```text
624
+ MIT License
625
+
626
+ Copyright (c) 2024 Mitchell Hashimoto, Ghostty contributors
627
+
628
+ Permission is hereby granted, free of charge, to any person obtaining a copy
629
+ of this software and associated documentation files (the "Software"), to deal
630
+ in the Software without restriction, including without limitation the rights
631
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
632
+ copies of the Software, and to permit persons to whom the Software is
633
+ furnished to do so, subject to the following conditions:
634
+
635
+ The above copyright notice and this permission notice shall be included in all
636
+ copies or substantial portions of the Software.
637
+
638
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
639
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
640
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
641
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
642
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
643
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
644
+ SOFTWARE.
645
+ ```
646
+
647
+ ## ghostty-web (`coder/ghostty-web`)
648
+
649
+ - Repository: https://github.com/coder/ghostty-web
650
+ - What: the escape-heavy viewport row-merge fixture in `packages/vt/test` is
651
+ ported from ghostty-web's `lib/viewport-row-merge.test.ts`.
652
+
653
+ License: MIT, with the following notice:
654
+
655
+ ```text
656
+ MIT License
657
+
658
+ Copyright (c) 2025 Coder
659
+
660
+ Permission is hereby granted, free of charge, to any person obtaining a copy
661
+ of this software and associated documentation files (the "Software"), to deal
662
+ in the Software without restriction, including without limitation the rights
663
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
664
+ copies of the Software, and to permit persons to whom the Software is
665
+ furnished to do so, subject to the following conditions:
666
+
667
+ The above copyright notice and this permission notice shall be included in all
668
+ copies or substantial portions of the Software.
669
+
670
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
671
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
672
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
673
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
674
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
675
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
676
+ SOFTWARE.
677
+ ```
678
+
614
679
  ## Naybr, "Copyright Free Gameplay (No Commentary) - Minecraft Survival"
615
680
 
616
681
  - Source: https://www.youtube.com/watch?v=GPsGyv5zTlM, by Naybr (youtube.com/@Naybr)
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  requireSession2
3
- } from "./compose-2an5qt0b.js";
3
+ } from "./compose-fs0g7btz.js";
4
4
 
5
5
  // src/engine/contributions.ts
6
6
  import { SdkError } from "@nyte-ai/schema";
@@ -6,7 +6,7 @@ import {
6
6
  inboxRef2,
7
7
  receiptRef2,
8
8
  callRef2
9
- } from "./compose-90679jqf.js";
9
+ } from "./compose-v4wdxywp.js";
10
10
  import {
11
11
  dev2
12
12
  } from "./compose-n116fnmp.js";
@@ -27,7 +27,7 @@ import {
27
27
  readCall2,
28
28
  coveredHere2,
29
29
  guard2
30
- } from "./compose-2an5qt0b.js";
30
+ } from "./compose-fs0g7btz.js";
31
31
  import {
32
32
  traced2,
33
33
  followTrace2,
@@ -35,29 +35,29 @@ import {
35
35
  } from "./compose-sp6d0d37.js";
36
36
  import {
37
37
  holdsReports2
38
- } from "./compose-9xfsd802.js";
38
+ } from "./compose-kd2ythd8.js";
39
39
  import {
40
40
  commit2
41
- } from "./compose-s54zz0gr.js";
41
+ } from "./compose-7z3s2jh4.js";
42
42
  import {
43
43
  withFold2
44
- } from "./compose-9n22j1aj.js";
44
+ } from "./compose-27jdjx5y.js";
45
45
  import {
46
46
  buildMessage2,
47
47
  admitted2,
48
48
  pendingReceipt2
49
- } from "./compose-58sqsjb1.js";
49
+ } from "./compose-998zw23w.js";
50
50
  import {
51
51
  fence2,
52
52
  finishFence2
53
- } from "./compose-fsm5ydya.js";
53
+ } from "./compose-fkj32m47.js";
54
54
  import {
55
55
  holdSummary2,
56
56
  summarizedMove2
57
- } from "./compose-1w7vhqzy.js";
57
+ } from "./compose-ytybhb9r.js";
58
58
  import {
59
59
  resolveHeadConfiguration2
60
- } from "./compose-c70pftcp.js";
60
+ } from "./compose-055ad57g.js";
61
61
  import {
62
62
  freezeMentions2
63
63
  } from "./compose-ac5efwd1.js";
@@ -66,7 +66,7 @@ import {
66
66
  settleReceipt2,
67
67
  reserve2,
68
68
  known2
69
- } from "./compose-ngp8g3dg.js";
69
+ } from "./compose-c3b46yga.js";
70
70
  import {
71
71
  landed2,
72
72
  chooseSendSchedule2
@@ -153,7 +153,7 @@ function selectRunStart2(state, head, inputs) {
153
153
  const execution = state.heads.get(head)?.info.execution;
154
154
  if (execution?.kind !== "idle" || holdsReports2(execution))
155
155
  return null;
156
- const report = inputs.flatMap((input) => input.source.kind === "child" || input.source.kind === "job" ? [{ origin: { kind: "continuation", from: input.source.kind }, input }] : []).at(0);
156
+ const report = inputs.flatMap((input) => input.source.kind === "child" || input.source.kind === "job" || input.source.kind === "answer" ? [{ origin: { kind: "continuation", from: input.source.kind }, input }] : []).at(0);
157
157
  return report ?? null;
158
158
  }
159
159
  async function landing2(kernel, session, head, ids, run, start = null) {
@@ -5,17 +5,17 @@ import {
5
5
  headRef2,
6
6
  runRef2,
7
7
  runCallsPrefix2
8
- } from "./compose-90679jqf.js";
8
+ } from "./compose-v4wdxywp.js";
9
9
  import {
10
10
  dev2
11
11
  } from "./compose-n116fnmp.js";
12
12
  import {
13
13
  liveRun3,
14
14
  put2
15
- } from "./compose-2an5qt0b.js";
15
+ } from "./compose-fs0g7btz.js";
16
16
  import {
17
17
  withFold2
18
- } from "./compose-9n22j1aj.js";
18
+ } from "./compose-27jdjx5y.js";
19
19
 
20
20
  // src/drive/interruptions.ts
21
21
  var RESTART_LIMIT2 = 5;
@@ -0,0 +1,180 @@
1
+ import {
2
+ sessionRef2,
3
+ headRef2,
4
+ promptRef2,
5
+ seenRef2,
6
+ partRef2
7
+ } from "./compose-v4wdxywp.js";
8
+ import {
9
+ MAIN2,
10
+ STALE2,
11
+ requireSession2,
12
+ readTip2,
13
+ put2,
14
+ attempt2,
15
+ walkCommitPath2,
16
+ toCommitObjectId2,
17
+ sessionEvent2
18
+ } from "./compose-fs0g7btz.js";
19
+ import {
20
+ commit2
21
+ } from "./compose-7z3s2jh4.js";
22
+
23
+ // src/engine/fork.ts
24
+ import { asId, asSeq } from "@nyte-ai/schema";
25
+ var LOG_PAGE = 256;
26
+ async function forkSession2(kernel, context, source, from) {
27
+ const id = asId(crypto.randomUUID());
28
+ return attempt2(`Forking ${source}`, async () => {
29
+ const found = await requireSession2(kernel.store, source);
30
+ const tip = from ?? (await readTip2(kernel.store, source, MAIN2)).id;
31
+ if (tip === null)
32
+ return { kind: "missing-source" };
33
+ const log = await readLog(kernel.store, source, asSeq(0));
34
+ const history = forkHistory(log, tip);
35
+ if (history.kind !== "ready")
36
+ return history;
37
+ const shared = await Promise.all(history.parts.map(async (part) => ({
38
+ part,
39
+ target: (await kernel.store.refs.get(partRef2(source, part)))?.target ?? null
40
+ })));
41
+ if (shared.some((entry) => entry.target === null))
42
+ return { kind: "missing-source" };
43
+ const read = log.at(-1)?.seq ?? asSeq(0);
44
+ const changed = (await readLog(kernel.store, source, read)).some((event) => event.kind === "part" && history.parts.includes(event.part));
45
+ if (changed)
46
+ return STALE2;
47
+ const prompt = (await kernel.store.refs.get(promptRef2(source, MAIN2)))?.target ?? null;
48
+ const main = found.record.heads.find((head) => head.name === MAIN2);
49
+ const at = Date.now();
50
+ const record = {
51
+ id,
52
+ name: found.record.name,
53
+ parent: null,
54
+ origin: null,
55
+ workspace: found.record.workspace,
56
+ pinned: false,
57
+ archived: false,
58
+ createdAt: at,
59
+ lastActivityAt: at,
60
+ heads: [
61
+ {
62
+ name: MAIN2,
63
+ stack: null,
64
+ selected: main?.selected ?? null,
65
+ lastRun: history.lastRun,
66
+ response: main?.lastRun?.id === history.lastRun?.id ? main?.response : undefined
67
+ }
68
+ ],
69
+ prompt: found.record.prompt,
70
+ contextFiles: found.record.contextFiles
71
+ };
72
+ const seen = { commit: tip };
73
+ const outcome = await commit2(kernel, [
74
+ {
75
+ name: sessionRef2(id),
76
+ target: await put2(kernel.store, "session", record, at),
77
+ expect: "absent",
78
+ fences: [sessionRef2(source)],
79
+ events: [await sessionEvent2(kernel, record), ...history.events]
80
+ },
81
+ {
82
+ name: headRef2(id, MAIN2),
83
+ target: toCommitObjectId2(tip),
84
+ expect: "absent",
85
+ events: [{ head: MAIN2, kind: "head", from: null, to: tip, reason: "created" }]
86
+ },
87
+ {
88
+ name: seenRef2(id, context.principal, MAIN2),
89
+ target: await put2(kernel.store, "seen", seen),
90
+ expect: "absent",
91
+ events: [{ head: MAIN2, kind: "seen", principal: context.principal, commit: tip }]
92
+ },
93
+ ...shared.flatMap((entry) => entry.target === null ? [] : [{ name: partRef2(id, entry.part), target: entry.target, expect: "absent" }]),
94
+ ...prompt === null ? [] : [{ name: promptRef2(id, MAIN2), target: prompt, expect: "absent" }]
95
+ ]);
96
+ if (outcome.kind === "fenced")
97
+ return { kind: "missing-source" };
98
+ return outcome.kind === "set" ? { kind: "forked", session: id } : STALE2;
99
+ });
100
+ }
101
+ function forkHistory(log, tip) {
102
+ const commits = new Map(log.flatMap((event) => event.kind === "commit" ? [[event.id, event]] : []));
103
+ if (!commits.has(tip))
104
+ return { kind: "missing-source" };
105
+ const path = new Set(walkCommitPath2(commits, tip));
106
+ const bodies = [...path].flatMap((commit) => commits.get(commit)?.body ?? []);
107
+ const parts = new Set(bodies.flatMap((body) => body.kind === "user" ? [] : [body.part]));
108
+ const runs = new Set(log.flatMap((event) => {
109
+ if (event.kind === "commit" && path.has(event.id) && event.run !== null)
110
+ return [event.run];
111
+ return event.kind === "part" && event.change === "created" && parts.has(event.part) && event.run !== null ? [event.run] : [];
112
+ }));
113
+ const ends = log.flatMap((event) => event.kind === "run" && event.change === "ended" && runs.has(event.run) ? [event] : []);
114
+ const live = [...runs].find((run) => !ends.some((end) => end.run === run));
115
+ if (live !== undefined)
116
+ return { kind: "busy", run: live };
117
+ const kept = {
118
+ path,
119
+ prompts: new Set(bodies.flatMap((body) => body.kind === "user" ? [body.message] : [])),
120
+ parts,
121
+ runs
122
+ };
123
+ const last = ends.at(-1);
124
+ return {
125
+ kind: "ready",
126
+ events: log.flatMap((event) => {
127
+ const copy = keep(event, kept);
128
+ return copy === null ? [] : [onMain(copy)];
129
+ }),
130
+ parts: [...parts],
131
+ lastRun: last === undefined ? null : { id: last.run, end: last.end, endedAt: last.at }
132
+ };
133
+ }
134
+ function keep(event, kept) {
135
+ switch (event.kind) {
136
+ case "commit":
137
+ if (!kept.path.has(event.id))
138
+ return null;
139
+ return event.body.kind === "user" ? { ...event, body: { ...event.body, siblings: [] } } : event;
140
+ case "input":
141
+ return kept.prompts.has(event.message) ? event : null;
142
+ case "part":
143
+ case "call":
144
+ return kept.parts.has(event.part) ? event : null;
145
+ case "run":
146
+ if (!kept.runs.has(event.run))
147
+ return null;
148
+ return event.change === "started" ? { ...event, view: { ...event.view, head: MAIN2 } } : event;
149
+ case "configured":
150
+ return event.head === MAIN2 ? event : null;
151
+ case "head":
152
+ case "seen":
153
+ case "background":
154
+ case "request":
155
+ case "changes":
156
+ case "session":
157
+ case "activation":
158
+ case "catalog":
159
+ return null;
160
+ default: {
161
+ const _exhaustive = event;
162
+ return _exhaustive;
163
+ }
164
+ }
165
+ }
166
+ function onMain(event) {
167
+ const copy = { ...event, head: event.head === null ? null : MAIN2, seq: undefined };
168
+ return copy;
169
+ }
170
+ async function readLog(store, session, after) {
171
+ const events = [];
172
+ for (;; ) {
173
+ const page = await store.refs.log(session, events.at(-1)?.seq ?? after, LOG_PAGE);
174
+ events.push(...page);
175
+ if (page.length < LOG_PAGE)
176
+ return events;
177
+ }
178
+ }
179
+
180
+ export { forkSession2 };
@@ -3,7 +3,7 @@ import {
3
3
  } from "./compose-5z835ej2.js";
4
4
  import {
5
5
  readSession2
6
- } from "./compose-2an5qt0b.js";
6
+ } from "./compose-fs0g7btz.js";
7
7
 
8
8
  // src/fold/reads.ts
9
9
  async function withFold2(kernel, session, read) {
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  START2,
6
6
  readPositionCommit2
7
- } from "./compose-2an5qt0b.js";
7
+ } from "./compose-fs0g7btz.js";
8
8
  import {
9
9
  IDLE2,
10
10
  WORKING2,
@@ -12,6 +12,15 @@ import {
12
12
  committed2,
13
13
  setMessage2,
14
14
  setTurn2,
15
+ hidesTurn2,
16
+ touchRow2,
17
+ dropRow2,
18
+ setChanges2,
19
+ setCatalogId2,
20
+ noteHead2,
21
+ dropHead2,
22
+ emptyStamps2,
23
+ newTouched2,
15
24
  openTurn2,
16
25
  turnInfo2,
17
26
  updateHead2,
@@ -22,17 +31,17 @@ import {
22
31
  partView2,
23
32
  toPartMessageId2,
24
33
  pendingTurn2
25
- } from "./compose-6p44ssmp.js";
34
+ } from "./compose-46w2zh74.js";
26
35
  import {
27
36
  applyCall2,
28
37
  describeLiveActivity2
29
- } from "./compose-4ar81ka1.js";
38
+ } from "./compose-3hk932nc.js";
30
39
  import {
31
40
  mergeChanges2
32
41
  } from "./compose-gg8n7dtw.js";
33
42
  import {
34
43
  finish2
35
- } from "./compose-8py9dgfe.js";
44
+ } from "./compose-3vbyrkdd.js";
36
45
 
37
46
  // src/fold/fold.ts
38
47
  import { asId, asSeq, isJsonObject } from "@nyte-ai/schema";
@@ -42,14 +51,8 @@ var SINGLE = {
42
51
  count: 1,
43
52
  ids: []
44
53
  };
45
- var EMPTY_CATALOG2 = {
46
- commands: [],
47
- settings: [],
48
- skills: [],
49
- agents: [],
50
- tools: []
51
- };
52
54
  var STOPPED = { class: "aborted", message: "Stopped." };
55
+ var UNTOUCHED = newTouched2();
53
56
  function emptyFold2(input) {
54
57
  const index = {
55
58
  heads: new Map,
@@ -64,7 +67,9 @@ function emptyFold2(input) {
64
67
  byRun: new Map,
65
68
  riders: new Set,
66
69
  thinking: new Map,
67
- paths: new Map
70
+ paths: new Map,
71
+ stamps: emptyStamps2(),
72
+ ring: { steps: [], from: asSeq(0), mark: 0 }
68
73
  };
69
74
  return {
70
75
  [INDEX2]: index,
@@ -72,8 +77,9 @@ function emptyFold2(input) {
72
77
  principal: input.principal,
73
78
  seen: new Map,
74
79
  seq: asSeq(0),
80
+ base: asSeq(0),
75
81
  activation: INACTIVE,
76
- catalog: EMPTY_CATALOG2,
82
+ catalogId: null,
77
83
  changes: [],
78
84
  heads: index.heads,
79
85
  headInfos: [],
@@ -89,7 +95,7 @@ function emptyFold2(input) {
89
95
  };
90
96
  }
91
97
  function fold2(state, event) {
92
- const draft = open(state);
98
+ const draft = open(state, event.kind !== "patch");
93
99
  if (event.kind === "patch") {
94
100
  if (!applyPatch(draft, event))
95
101
  return state;
@@ -100,13 +106,13 @@ function fold2(state, event) {
100
106
  }
101
107
  return finish2(state, draft);
102
108
  }
103
- function open(state) {
109
+ function open(state, durable) {
104
110
  return {
105
111
  ...state[INDEX2],
106
112
  seen: state.seen,
107
113
  seq: state.seq,
108
114
  activation: state.activation,
109
- catalog: state.catalog,
115
+ catalogId: state.catalogId,
110
116
  changes: state.changes,
111
117
  partViews: state.partViews,
112
118
  walk: new Set,
@@ -114,7 +120,9 @@ function open(state) {
114
120
  rebuild: new Set,
115
121
  swapped: new Set,
116
122
  retitled: new Set,
117
- steps: new Map
123
+ steps: new Map,
124
+ durable,
125
+ touched: durable ? newTouched2() : UNTOUCHED
118
126
  };
119
127
  }
120
128
  function apply(draft, event) {
@@ -146,15 +154,14 @@ function apply(draft, event) {
146
154
  case "request":
147
155
  return eachHead(draft, event.head, (head) => ({ ...head, context: event.context }));
148
156
  case "changes":
149
- draft.changes = "cleared" in event ? mergeChanges2(draft.changes, event) : event.files;
150
- return;
157
+ return setChanges2(draft, "cleared" in event ? mergeChanges2(draft.changes, event) : event.files);
151
158
  case "session":
152
159
  return applySession(draft, event);
153
160
  case "activation":
154
161
  draft.activation = event.activation;
155
162
  return;
156
163
  case "catalog":
157
- draft.catalog = event.catalog;
164
+ return setCatalogId2(draft, event.id);
158
165
  }
159
166
  }
160
167
  function applyCommit(draft, event) {
@@ -236,6 +243,7 @@ function applyHead(draft, event) {
236
243
  if (name === null)
237
244
  return;
238
245
  if (event.reason === "removed") {
246
+ dropHead2(draft, name);
239
247
  draft.heads.delete(name);
240
248
  draft.paths.delete(name);
241
249
  forget(draft, name);
@@ -255,6 +263,7 @@ function applySeen(draft, event) {
255
263
  if (name === null || !draft.heads.has(name) || marks?.get(name) === event.commit)
256
264
  return;
257
265
  draft.seen = new Map(draft.seen).set(event.principal, new Map(marks).set(name, event.commit));
266
+ touchRow2(draft, "heads", name);
258
267
  }
259
268
  function forget(draft, name) {
260
269
  if (![...draft.seen.values()].some((marks) => marks.has(name)))
@@ -282,6 +291,11 @@ function applySession(draft, event) {
282
291
  }
283
292
  if (sameEntries(draft.heads, heads))
284
293
  return;
294
+ for (const name of draft.heads.keys())
295
+ if (!heads.has(name))
296
+ dropHead2(draft, name);
297
+ for (const [name, head] of heads)
298
+ noteHead2(draft, name, draft.heads.get(name), head);
285
299
  draft.heads.clear();
286
300
  for (const [name, head] of heads)
287
301
  draft.heads.set(name, head);
@@ -367,8 +381,13 @@ function leave(draft, input) {
367
381
  const message = draft.messages.get(input.id);
368
382
  draft.inputs.delete(input.id);
369
383
  draft.messages.delete(input.id);
370
- if (message?.turn === pendingTurn2(input.id))
384
+ dropRow2(draft, "messages", input.id);
385
+ if (message?.turn === pendingTurn2(input.id)) {
386
+ const info = draft.turns.get(message.turn)?.info;
371
387
  draft.turns.delete(message.turn);
388
+ if (info === undefined || !hidesTurn2(info, message))
389
+ dropRow2(draft, "turns", message.turn);
390
+ }
372
391
  updateHead2(draft, input.head, (head) => ({
373
392
  ...head,
374
393
  pending: head.pending.filter((id) => id !== input.id)
@@ -533,6 +552,7 @@ function applyPart(draft, event) {
533
552
  return;
534
553
  draft.parts.delete(id);
535
554
  draft.partViews = draft.partViews.filter((view) => view.id !== id);
555
+ dropRow2(draft, "parts", id);
536
556
  }
537
557
  }
538
558
  function create(draft, event) {
@@ -559,6 +579,7 @@ function create(draft, event) {
559
579
  }
560
580
  if (role === null) {
561
581
  draft.partViews = [...draft.partViews.filter((view) => view.id !== id), partView2(record)];
582
+ touchRow2(draft, "parts", id);
562
583
  return;
563
584
  }
564
585
  const folded = run === null ? undefined : draft.runs.get(run);
@@ -657,4 +678,4 @@ function sameTurnState(left, right) {
657
678
  return left === right;
658
679
  }
659
680
 
660
- export { EMPTY_CATALOG2, emptyFold2, fold2 };
681
+ export { emptyFold2, fold2 };