@nyte-ai/host 0.0.0-stage → 0.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (250) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +6 -2
  3. package/THIRD-PARTY-NOTICES.md +866 -0
  4. package/dist/chunks/canvas-preview-0cmbkp2j.js +65 -0
  5. package/dist/chunks/canvas-preview-0nq75h9k.js +7 -0
  6. package/dist/chunks/canvas-preview-11nadadc.js +241 -0
  7. package/dist/chunks/canvas-preview-1sq7z9jq.js +17 -0
  8. package/dist/chunks/canvas-preview-2jwbe14k.js +130 -0
  9. package/dist/chunks/canvas-preview-2zdyh9ny.js +26 -0
  10. package/dist/chunks/canvas-preview-31w7xm8z.js +34 -0
  11. package/dist/chunks/canvas-preview-4b6sayhg.js +295 -0
  12. package/dist/chunks/canvas-preview-4e0pxa32.js +63 -0
  13. package/dist/chunks/canvas-preview-518dh8by.js +169 -0
  14. package/dist/chunks/canvas-preview-55s0y68g.js +387 -0
  15. package/dist/chunks/canvas-preview-5ekjx6sw.js +613 -0
  16. package/dist/chunks/canvas-preview-5mex725c.js +14 -0
  17. package/dist/chunks/canvas-preview-5z63am63.js +295 -0
  18. package/dist/chunks/canvas-preview-65xqjw7f.js +20 -0
  19. package/dist/chunks/canvas-preview-69fkk9yn.js +95 -0
  20. package/dist/chunks/canvas-preview-8xc0vn7v.js +458 -0
  21. package/dist/chunks/canvas-preview-9aqczacs.js +73 -0
  22. package/dist/chunks/canvas-preview-af86jz8t.js +141 -0
  23. package/dist/chunks/canvas-preview-aq5j4p25.js +240 -0
  24. package/dist/chunks/canvas-preview-b2v8wfnz.js +36 -0
  25. package/dist/chunks/canvas-preview-befkjea2.js +60 -0
  26. package/dist/chunks/canvas-preview-bxnqt8cd.js +103 -0
  27. package/dist/chunks/canvas-preview-cawy6vbz.js +352 -0
  28. package/dist/chunks/canvas-preview-crmzxxt8.js +518 -0
  29. package/dist/chunks/canvas-preview-drctegz4.js +591 -0
  30. package/dist/chunks/canvas-preview-e3vnkkc5.js +134 -0
  31. package/dist/chunks/canvas-preview-ec2mt7es.js +108 -0
  32. package/dist/chunks/canvas-preview-fxa0rfb0.js +61 -0
  33. package/dist/chunks/canvas-preview-g5fkjs34.js +598 -0
  34. package/dist/chunks/canvas-preview-jeddjex8.js +166 -0
  35. package/dist/chunks/canvas-preview-k1yg4fgp.js +571 -0
  36. package/dist/chunks/canvas-preview-kdqgrstc.js +194 -0
  37. package/dist/chunks/canvas-preview-kn7kvbfj.js +12 -0
  38. package/dist/chunks/canvas-preview-kp75gb63.js +141 -0
  39. package/dist/chunks/canvas-preview-mgcx2b2p.js +271 -0
  40. package/dist/chunks/canvas-preview-n2a35zv5.js +81 -0
  41. package/dist/chunks/canvas-preview-pkzqg96v.js +63 -0
  42. package/dist/chunks/canvas-preview-rp4x6y1h.js +144 -0
  43. package/dist/chunks/canvas-preview-s94ebwf5.js +112 -0
  44. package/dist/chunks/canvas-preview-skzwvw4d.js +23 -0
  45. package/dist/chunks/canvas-preview-srgfpdmf.js +60 -0
  46. package/dist/chunks/canvas-preview-tjhabynd.js +252 -0
  47. package/dist/chunks/canvas-preview-tnqe7k0b.js +374 -0
  48. package/dist/chunks/canvas-preview-vaatfznm.js +189 -0
  49. package/dist/chunks/canvas-preview-vm9zdp2t.js +398 -0
  50. package/dist/chunks/canvas-preview-w54ymtb3.js +272 -0
  51. package/dist/chunks/canvas-preview-wg80rbc2.js +46 -0
  52. package/dist/chunks/canvas-preview-y5y6ghaw.js +125 -0
  53. package/dist/chunks/canvas-preview-ycepb05s.js +176 -0
  54. package/dist/chunks/canvas-preview-yjz0f7n4.js +50 -0
  55. package/dist/chunks/canvas-preview-zaaj99wd.js +244 -0
  56. package/dist/src/canvas-preview.d.ts +29 -0
  57. package/dist/src/canvas-preview.js +271 -0
  58. package/dist/src/credentials.d.ts +44 -0
  59. package/dist/src/credentials.js +10 -0
  60. package/dist/src/deploy/cloudflare/worker.d.ts +50 -0
  61. package/dist/src/deploy/cloudflare/worker.js +196 -0
  62. package/dist/src/deploy/vercel/nitro.config.d.ts +2 -0
  63. package/dist/src/deploy/vercel/nitro.config.js +30 -0
  64. package/dist/src/deploy/vercel/server/routes/[...].d.ts +2 -0
  65. package/dist/src/deploy/vercel/server/routes/[...].js +18 -0
  66. package/dist/src/deploy/vercel/server/utils/host.d.ts +13 -0
  67. package/dist/src/deploy/vercel/server/utils/host.js +7 -0
  68. package/dist/src/deploy/vercel/server/utils/repair.d.ts +1 -0
  69. package/dist/src/deploy/vercel/server/utils/repair.js +6 -0
  70. package/dist/src/deploy/vercel/server/utils/step.d.ts +10 -0
  71. package/dist/src/deploy/vercel/server/utils/step.js +6 -0
  72. package/dist/src/deploy/vercel/server/workflows/drive.d.ts +14 -0
  73. package/dist/src/deploy/vercel/server/workflows/drive.js +13 -0
  74. package/dist/src/durable-object.d.ts +14 -0
  75. package/dist/src/durable-object.js +231 -0
  76. package/dist/src/hash.d.ts +1 -0
  77. package/dist/src/hash.js +6 -0
  78. package/dist/src/identity-key.d.ts +11 -0
  79. package/dist/src/identity-key.js +9 -0
  80. package/dist/src/identity.d.ts +12 -0
  81. package/dist/src/identity.js +6 -0
  82. package/dist/src/images/exif.d.ts +1 -0
  83. package/dist/src/images/exif.js +6 -0
  84. package/dist/src/images/node.d.ts +37 -0
  85. package/dist/src/images/node.js +12 -0
  86. package/dist/src/images/photon.d.ts +3 -0
  87. package/dist/src/images/photon.js +7 -0
  88. package/dist/src/images/worker.d.ts +1 -0
  89. package/dist/src/images/worker.js +23 -0
  90. package/dist/src/index.d.ts +20 -0
  91. package/dist/src/index.js +121 -0
  92. package/dist/src/key-file.d.ts +1 -0
  93. package/dist/src/key-file.js +7 -0
  94. package/dist/src/listen-fetch.d.ts +8 -0
  95. package/dist/src/listen-fetch.js +9 -0
  96. package/dist/src/listen.d.ts +4 -0
  97. package/dist/src/listen.js +10 -0
  98. package/dist/src/local/command.d.ts +20 -0
  99. package/dist/src/local/command.js +12 -0
  100. package/dist/src/local/feed.d.ts +7 -0
  101. package/dist/src/local/feed.js +6 -0
  102. package/dist/src/local/files.d.ts +18 -0
  103. package/dist/src/local/files.js +13 -0
  104. package/dist/src/local/git-watch.d.ts +15 -0
  105. package/dist/src/local/git-watch.js +7 -0
  106. package/dist/src/local/git.d.ts +5 -0
  107. package/dist/src/local/git.js +13 -0
  108. package/dist/src/local/github.d.ts +30 -0
  109. package/dist/src/local/github.js +9 -0
  110. package/dist/src/local/identity.d.ts +3 -0
  111. package/dist/src/local/identity.js +7 -0
  112. package/dist/src/local/jobs.d.ts +7 -0
  113. package/dist/src/local/jobs.js +7 -0
  114. package/dist/src/local/legacy-trust.d.ts +10 -0
  115. package/dist/src/local/legacy-trust.js +6 -0
  116. package/dist/src/local/patch.d.ts +16 -0
  117. package/dist/src/local/patch.js +17 -0
  118. package/dist/src/local/provider.d.ts +11 -0
  119. package/dist/src/local/provider.js +20 -0
  120. package/dist/src/local/snapshots.d.ts +7 -0
  121. package/dist/src/local/snapshots.js +11 -0
  122. package/dist/src/local/text.d.ts +1 -0
  123. package/dist/src/local/text.js +6 -0
  124. package/dist/src/local/tree.d.ts +50 -0
  125. package/dist/src/local/tree.js +16 -0
  126. package/dist/src/local/workspace-migration.d.ts +2 -0
  127. package/dist/src/local/workspace-migration.js +7 -0
  128. package/dist/src/local/worktrees.d.ts +46 -0
  129. package/dist/src/local/worktrees.js +14 -0
  130. package/dist/src/mcp/config.d.ts +75 -0
  131. package/dist/src/mcp/config.js +12 -0
  132. package/dist/src/mcp/connect.d.ts +15 -0
  133. package/dist/src/mcp/connect.js +9 -0
  134. package/dist/src/mcp/hub.d.ts +19 -0
  135. package/dist/src/mcp/hub.js +11 -0
  136. package/dist/src/mcp/oauth.d.ts +46 -0
  137. package/dist/src/mcp/oauth.js +12 -0
  138. package/dist/src/mcp/tools.d.ts +29 -0
  139. package/dist/src/mcp/tools.js +12 -0
  140. package/dist/src/open.d.ts +14 -0
  141. package/dist/src/open.js +46 -0
  142. package/dist/src/plugins/loader.d.ts +21 -0
  143. package/dist/src/plugins/loader.js +11 -0
  144. package/dist/src/postgres.d.ts +19 -0
  145. package/dist/src/postgres.js +8 -0
  146. package/dist/src/providers.d.ts +16 -0
  147. package/dist/src/providers.js +112 -0
  148. package/dist/src/secrets.d.ts +12 -0
  149. package/dist/src/secrets.js +8 -0
  150. package/dist/src/serve/binding.d.ts +39 -0
  151. package/dist/src/serve/binding.js +6 -0
  152. package/dist/src/serve/handler.d.ts +15 -0
  153. package/dist/src/serve/handler.js +8 -0
  154. package/dist/src/serve/stream-server.d.ts +6 -0
  155. package/dist/src/serve/stream-server.js +6 -0
  156. package/dist/src/session-index.d.ts +11 -0
  157. package/dist/src/session-index.js +11 -0
  158. package/dist/src/shell-env.d.ts +14 -0
  159. package/dist/src/shell-env.js +108 -0
  160. package/dist/src/sqlite-workers.d.ts +6 -0
  161. package/dist/src/sqlite-workers.js +6 -0
  162. package/dist/src/sqlite.d.ts +8 -0
  163. package/dist/src/sqlite.js +11 -0
  164. package/dist/src/store-rows.d.ts +13 -0
  165. package/dist/src/store-rows.js +26 -0
  166. package/dist/src/store-usage.d.ts +25 -0
  167. package/dist/src/store-usage.js +19 -0
  168. package/dist/src/usage-history.d.ts +54 -0
  169. package/dist/src/usage-history.js +14 -0
  170. package/dist/src/usage-scan.d.ts +24 -0
  171. package/dist/src/usage-scan.js +65 -0
  172. package/dist/src/usage-service.d.ts +23 -0
  173. package/dist/src/usage-service.js +16 -0
  174. package/dist/src/usage-summary.d.ts +9 -0
  175. package/dist/src/usage-summary.js +16 -0
  176. package/dist/src/usage-types.d.ts +86 -0
  177. package/dist/src/usage-types.js +0 -0
  178. package/dist/src/usage-worker.d.ts +1 -0
  179. package/dist/src/usage-worker.js +29 -0
  180. package/dist/src/usage.d.ts +195 -0
  181. package/dist/src/usage.js +23 -0
  182. package/package.json +140 -3
  183. package/src/canvas-preview.ts +403 -0
  184. package/src/credentials.ts +294 -0
  185. package/src/deploy/cloudflare/README.md +3 -0
  186. package/src/deploy/cloudflare/worker.ts +306 -0
  187. package/src/deploy/cloudflare/wrangler.jsonc +12 -0
  188. package/src/deploy/vercel/README.md +3 -0
  189. package/src/deploy/vercel/nitro.config.ts +29 -0
  190. package/src/deploy/vercel/server/routes/[...].ts +10 -0
  191. package/src/deploy/vercel/server/utils/host.ts +104 -0
  192. package/src/deploy/vercel/server/utils/repair.ts +35 -0
  193. package/src/deploy/vercel/server/utils/step.ts +25 -0
  194. package/src/deploy/vercel/server/workflows/drive.ts +46 -0
  195. package/src/deploy/vercel/tsconfig.json +9 -0
  196. package/src/deploy/vercel/types/bun.d.ts +2 -0
  197. package/src/durable-object.ts +386 -0
  198. package/src/hash.ts +5 -0
  199. package/src/identity-key.ts +20 -0
  200. package/src/identity.ts +66 -0
  201. package/src/images/exif.ts +69 -0
  202. package/src/images/node.ts +163 -0
  203. package/src/images/photon.ts +141 -0
  204. package/src/images/worker.ts +29 -0
  205. package/src/index.ts +39 -0
  206. package/src/key-file.ts +53 -0
  207. package/src/listen-fetch.ts +409 -0
  208. package/src/listen.ts +228 -0
  209. package/src/local/command.ts +161 -0
  210. package/src/local/feed.ts +70 -0
  211. package/src/local/files.ts +817 -0
  212. package/src/local/git-watch.ts +199 -0
  213. package/src/local/git.ts +919 -0
  214. package/src/local/github.ts +691 -0
  215. package/src/local/identity.ts +21 -0
  216. package/src/local/jobs.ts +573 -0
  217. package/src/local/legacy-trust.ts +105 -0
  218. package/src/local/patch.ts +334 -0
  219. package/src/local/provider.ts +184 -0
  220. package/src/local/snapshots.ts +778 -0
  221. package/src/local/text.ts +9 -0
  222. package/src/local/tree.ts +398 -0
  223. package/src/local/workspace-migration.ts +95 -0
  224. package/src/local/worktrees.ts +239 -0
  225. package/src/mcp/config.ts +330 -0
  226. package/src/mcp/connect.ts +92 -0
  227. package/src/mcp/hub.ts +836 -0
  228. package/src/mcp/oauth.ts +436 -0
  229. package/src/mcp/tools.ts +333 -0
  230. package/src/open.ts +449 -0
  231. package/src/plugins/loader.ts +186 -0
  232. package/src/postgres.ts +492 -0
  233. package/src/providers.ts +135 -0
  234. package/src/secrets.ts +31 -0
  235. package/src/serve/binding.ts +629 -0
  236. package/src/serve/handler.ts +362 -0
  237. package/src/serve/stream-server.ts +176 -0
  238. package/src/session-index.ts +99 -0
  239. package/src/shell-env.ts +153 -0
  240. package/src/sqlite-workers.ts +283 -0
  241. package/src/sqlite.ts +553 -0
  242. package/src/store-rows.ts +110 -0
  243. package/src/store-usage.ts +347 -0
  244. package/src/usage-history.ts +219 -0
  245. package/src/usage-scan.ts +81 -0
  246. package/src/usage-service.ts +82 -0
  247. package/src/usage-summary.ts +79 -0
  248. package/src/usage-types.ts +87 -0
  249. package/src/usage-worker.ts +24 -0
  250. package/src/usage.ts +776 -0
@@ -0,0 +1,6 @@
1
+ import {
2
+ stepFrom2
3
+ } from "../../../../../chunks/canvas-preview-65xqjw7f.js";
4
+ export {
5
+ stepFrom2 as stepFrom
6
+ };
@@ -0,0 +1,14 @@
1
+ import type { AdvanceReport, HeadName, SessionId } from "@nyte-ai/schema";
2
+ /** Hands a head's wake to the workflow that drives it. */
3
+ export declare function dispatchHead(target: {
4
+ readonly session: SessionId;
5
+ readonly head: HeadName;
6
+ }): Promise<void>;
7
+ export declare function driveHead(input: {
8
+ readonly session: SessionId;
9
+ readonly head: HeadName;
10
+ }): Promise<void>;
11
+ export declare function advanceHead(input: {
12
+ readonly session: SessionId;
13
+ readonly head: HeadName;
14
+ }): Promise<AdvanceReport>;
@@ -0,0 +1,13 @@
1
+ import {
2
+ dispatchHead2,
3
+ driveHead2,
4
+ advanceHead2
5
+ } from "../../../../../chunks/canvas-preview-b2v8wfnz.js";
6
+ import"../../../../../chunks/canvas-preview-n2a35zv5.js";
7
+ import"../../../../../chunks/canvas-preview-2zdyh9ny.js";
8
+ import"../../../../../chunks/canvas-preview-65xqjw7f.js";
9
+ export {
10
+ advanceHead2 as advanceHead,
11
+ dispatchHead2 as dispatchHead,
12
+ driveHead2 as driveHead
13
+ };
@@ -0,0 +1,14 @@
1
+ import type { Store } from "@nyte-ai/core";
2
+ /** Returns one value Durable Object SQL binds and answers: text, a number, a blob as an `ArrayBuffer`, or null. */
3
+ export type SqlValue = ArrayBuffer | string | number | null;
4
+ /** Returns the part of a Durable Object's storage `durableObjectStore` uses, structurally, so a Worker passes `state.storage` as it is and a test passes a shim: `sql.exec` runs one statement with `?` bindings and answers its rows keyed by column name, and `transactionSync` runs a synchronous closure whose writes land all together or, when it throws, not at all (Durable Object SQL refuses `BEGIN`, so this is the only transaction). */
5
+ export type DurableObjectSql = {
6
+ readonly sql: {
7
+ exec(query: string, ...bindings: SqlValue[]): {
8
+ toArray(): Record<string, SqlValue>[];
9
+ };
10
+ };
11
+ transactionSync<T>(closure: () => T): T;
12
+ };
13
+ /** Returns a `Store` over a Durable Object's SQLite storage, node-free, with the sqlite store's tables, row helpers (`store-rows.ts`) and semantics (§41f): `objects(id TEXT PRIMARY KEY, body TEXT NULL, bytes BLOB NULL)`, `refs(name TEXT PRIMARY KEY, target TEXT NULL, revision TEXT NOT NULL)` and `log(session TEXT, seq INTEGER, at INTEGER, event TEXT, PRIMARY KEY (session, seq))`, brought to core's `STORE_VERSION` by `migrateStore` on first `open()`, each commit one `transactionSync` and no backup; the open rejects with `SdkError("unavailable")` for a store a newer Nyte migrated. `put` ids the value with core's `objectId` and stores its JSON once; `putBlob` buffers the stream, ids it with `blobId` and stores the bytes once as an `ArrayBuffer`; an object and a blob that share an id share the row, each column filled once; `blob` reads the bytes back with their size and a null mime; a body, blob or logged event past the Durable Object's 2 MB row limit throws `SdkError("invalid")` before anything is written (§42k). `refs.set` runs inside one `transactionSync` with no await between its reads and writes, first rejecting with `SdkError("unavailable")` when a newer Nyte has migrated the store, with `RefStore.set`'s semantics, each revision a random UUID, any throw inside rolling the whole batch back. `list(prefix)` reads the name range from `prefix` in name order; `log` returns the events after `after` in seq order up to `limit`, each validated as a `SessionEvent`; `tail` is the session's last seq, or 0. Every `open()` returns a connection over the one storage; `close()` releases nothing, the storage being the object's. In workerd, which allows code generation only while modules load, the Worker turns TypeBox acceleration off at startup (`Settings.Set({ useAcceleration: false })` from `typebox/system`, as `deploy/cloudflare/worker.ts` does), or `log`'s validation throws inside a request. */
14
+ export declare function durableObjectStore(storage: DurableObjectSql): Store;
@@ -0,0 +1,231 @@
1
+ import {
2
+ prefixEnd2,
3
+ mintRevision2,
4
+ decodeEvent2,
5
+ parseNumber2,
6
+ parseText2,
7
+ parseRef2,
8
+ parseStoredRecord2,
9
+ parseStoredObject2,
10
+ loggedRow2,
11
+ collect2,
12
+ memoryReader2
13
+ } from "../chunks/canvas-preview-69fkk9yn.js";
14
+ import {
15
+ sessionIndexChanges2,
16
+ sqlSessionIndex2
17
+ } from "../chunks/canvas-preview-0cmbkp2j.js";
18
+
19
+ // src/durable-object.ts
20
+ import { asSeq, SdkError } from "@nyte-ai/schema";
21
+ import {
22
+ admits,
23
+ fenceNames,
24
+ assertStoreVersion,
25
+ blobId,
26
+ decodeObject,
27
+ collectSessionEvents,
28
+ migrateStore,
29
+ objectId,
30
+ sessionIndexRef,
31
+ parseSessionRef
32
+ } from "@nyte-ai/core/store";
33
+ var ROW_LIMIT = 2000000;
34
+ var encoder = new TextEncoder;
35
+ function durableObjectStore(storage) {
36
+ let connection = null;
37
+ return {
38
+ async open() {
39
+ if (connection !== null)
40
+ return connection;
41
+ await migrateStore(durableObjectTarget(storage));
42
+ connection = connect(storage);
43
+ return connection;
44
+ },
45
+ async close() {
46
+ connection = null;
47
+ }
48
+ };
49
+ }
50
+ function storedVersion(storage) {
51
+ const stamped = storage.sql.exec("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'store_meta'").toArray();
52
+ if (stamped.length === 0)
53
+ return 0;
54
+ const version = storage.sql.exec("SELECT version FROM store_meta WHERE id = 1").toArray()[0]?.version;
55
+ return version === undefined ? 0 : parseNumber2(version);
56
+ }
57
+ function durableObjectTarget(storage) {
58
+ const rows = (query, ...bindings) => storage.sql.exec(query, ...bindings).toArray();
59
+ return {
60
+ dialect: "sqlite",
61
+ async stamp() {
62
+ const present = rows("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'refs'").length > 0;
63
+ return {
64
+ version: storedVersion(storage),
65
+ empty: !present || rows("SELECT 1 FROM refs LIMIT 1").length === 0
66
+ };
67
+ },
68
+ async records() {
69
+ return rows("SELECT refs.name, refs.target, refs.revision, objects.body FROM refs JOIN objects ON objects.id = refs.target WHERE objects.body IS NOT NULL").map(parseStoredRecord2);
70
+ },
71
+ async* objects(kind) {
72
+ yield* rows("SELECT id, body FROM objects WHERE body IS NOT NULL AND instr(body, ?) > 0", `"kind":${JSON.stringify(kind)}`).map(parseStoredObject2);
73
+ },
74
+ async* logs() {
75
+ if (rows("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'log'").length === 0)
76
+ return;
77
+ for (const row of rows("SELECT DISTINCT session FROM log")) {
78
+ const session = parseText2(row.session);
79
+ if (session !== null)
80
+ yield {
81
+ session,
82
+ events: rows("SELECT seq, event FROM log WHERE session = ? ORDER BY seq", session).map(loggedRow2)
83
+ };
84
+ }
85
+ },
86
+ async commit(change) {
87
+ return storage.transactionSync(() => {
88
+ if (storedVersion(storage) !== change.from)
89
+ return "moved";
90
+ const conflicted = change.repoints.some((moved) => rows("SELECT 1 FROM refs WHERE name = ? AND revision = ?", moved.name, moved.expect).length === 0);
91
+ const relogged = change.relogs.every((relog) => rows("SELECT 1 FROM log WHERE session = ? AND seq = ? AND event = ?", relog.session, relog.seq, relog.expect).length > 0);
92
+ if (conflicted || !relogged)
93
+ return "conflict";
94
+ for (const statement of change.sql)
95
+ rows(statement);
96
+ for (const moved of change.repoints) {
97
+ rows("INSERT INTO objects (id, body) VALUES (?, ?) ON CONFLICT (id) DO UPDATE SET body = excluded.body WHERE objects.body IS NULL", moved.id, moved.body);
98
+ rows("UPDATE refs SET target = ?, revision = ? WHERE name = ?", moved.id, mintRevision2(), moved.name);
99
+ updateSessionIndex(storage, moved.name, moved.id, mintRevision2());
100
+ }
101
+ for (const created of change.creates) {
102
+ rows("INSERT INTO objects (id, body) VALUES (?, ?) ON CONFLICT (id) DO UPDATE SET body = excluded.body WHERE objects.body IS NULL", created.target, created.body);
103
+ const revision = mintRevision2();
104
+ if (rows("INSERT INTO refs (name, target, revision) VALUES (?, ?, ?) ON CONFLICT (name) DO NOTHING RETURNING name", created.name, created.target, revision).length > 0)
105
+ updateSessionIndex(storage, created.name, created.target, revision);
106
+ }
107
+ for (const relog of change.relogs)
108
+ rows("UPDATE log SET event = ? WHERE session = ? AND seq = ?", relog.event, relog.session, relog.seq);
109
+ if (change.reindexSessions)
110
+ for (const row of rows("SELECT name, target, revision FROM refs")) {
111
+ const ref = parseRef2(row);
112
+ updateSessionIndex(storage, ref.name, ref.target, ref.revision);
113
+ }
114
+ rows("INSERT INTO store_meta (id, version) VALUES (1, ?) ON CONFLICT (id) DO UPDATE SET version = excluded.version", change.to);
115
+ return "committed";
116
+ });
117
+ }
118
+ };
119
+ }
120
+ function connect(storage) {
121
+ const rows = (query, ...bindings) => storage.sql.exec(query, ...bindings).toArray();
122
+ const tail = (session) => {
123
+ const value = rows("SELECT MAX(seq) AS tail FROM log WHERE session = ?", session)[0]?.tail;
124
+ return asSeq(value === null || value === undefined ? 0 : parseNumber2(value));
125
+ };
126
+ const ref = (name) => {
127
+ const row = rows("SELECT name, target, revision FROM refs WHERE name = ?", name)[0];
128
+ return row === undefined ? null : parseRef2(row);
129
+ };
130
+ return {
131
+ sessions: sqlSessionIndex2(async (text, values) => rows(text, ...values)),
132
+ objects: {
133
+ async put(object) {
134
+ const id = await objectId(object);
135
+ const body = JSON.stringify(object);
136
+ fits(encoder.encode(body).byteLength, `Object ${id}`);
137
+ rows("INSERT INTO objects (id, body) VALUES (?, ?) ON CONFLICT (id) DO UPDATE SET body = excluded.body WHERE objects.body IS NULL", id, body);
138
+ return id;
139
+ },
140
+ async get(id) {
141
+ const body = parseText2(rows("SELECT body FROM objects WHERE id = ?", id)[0]?.body);
142
+ return body === null ? null : decodeObject(body);
143
+ },
144
+ async putBlob(bytes) {
145
+ const joined = await collect2(bytes);
146
+ const id = await blobId(joined);
147
+ fits(joined.byteLength, `Blob ${id}`);
148
+ rows("INSERT INTO objects (id, bytes) VALUES (?, ?) ON CONFLICT (id) DO UPDATE SET bytes = excluded.bytes WHERE objects.bytes IS NULL", id, joined.slice().buffer);
149
+ return id;
150
+ },
151
+ async blob(id) {
152
+ const bytes = rows("SELECT bytes FROM objects WHERE id = ?", id)[0]?.bytes;
153
+ return bytes instanceof ArrayBuffer ? memoryReader2(new Uint8Array(bytes)) : null;
154
+ }
155
+ },
156
+ refs: {
157
+ get: async (name) => ref(name),
158
+ async list(prefix) {
159
+ const end = prefixEnd2(prefix);
160
+ const found = end === null ? rows("SELECT name, target, revision FROM refs WHERE name >= ? ORDER BY name", prefix) : rows("SELECT name, target, revision FROM refs WHERE name >= ? AND name < ? ORDER BY name", prefix, end);
161
+ return found.map(parseRef2);
162
+ },
163
+ async set(updates) {
164
+ const logged = collectSessionEvents(updates).map(({ session, event }) => {
165
+ const text = JSON.stringify(event);
166
+ fits(encoder.encode(text).byteLength, `An event on ${session}`);
167
+ return { session, text };
168
+ });
169
+ return storage.transactionSync(() => {
170
+ assertStoreVersion(storedVersion(storage));
171
+ const before = new Map;
172
+ for (const update of updates)
173
+ if (!before.has(update.name))
174
+ before.set(update.name, ref(update.name) ?? undefined);
175
+ const fenced = fenceNames(updates).find((name) => ref(name) === null);
176
+ if (fenced !== undefined)
177
+ return { kind: "fenced", name: fenced };
178
+ const stale = updates.find((update) => !admits(update, before.get(update.name)));
179
+ if (stale !== undefined)
180
+ return {
181
+ kind: "stale",
182
+ name: stale.name,
183
+ revision: before.get(stale.name)?.revision ?? null
184
+ };
185
+ const touched = new Map;
186
+ const revisions = updates.map((update) => {
187
+ const revision = mintRevision2();
188
+ if (update.target === null)
189
+ rows("DELETE FROM refs WHERE name = ?", update.name);
190
+ else
191
+ rows("INSERT INTO refs (name, target, revision) VALUES (?, ?, ?) ON CONFLICT (name) DO UPDATE SET target = excluded.target, revision = excluded.revision", update.name, update.target, revision);
192
+ updateSessionIndex(storage, update.name, update.target, revision);
193
+ const session = parseSessionRef(update.name);
194
+ if (session !== null)
195
+ touched.set(session, revision);
196
+ return revision;
197
+ });
198
+ for (const [session, version] of touched)
199
+ rows("UPDATE session_index SET version = ? WHERE session = ?", version, session);
200
+ const at = Date.now();
201
+ const tails = new Map;
202
+ const appended = logged.map(({ session, text }) => {
203
+ const seq = (tails.get(session) ?? tail(session)) + 1;
204
+ tails.set(session, seq);
205
+ rows("INSERT INTO log (session, seq, at, event) VALUES (?, ?, ?, ?)", session, seq, at, text);
206
+ return asSeq(seq);
207
+ });
208
+ return { kind: "set", logged: appended, at, revisions };
209
+ });
210
+ },
211
+ async log(session, after, limit) {
212
+ return rows("SELECT seq, at, event FROM log WHERE session = ? AND seq > ? ORDER BY seq LIMIT ?", session, after, limit).map((row) => decodeEvent2(parseNumber2(row.seq), parseNumber2(row.at), parseText2(row.event) ?? ""));
213
+ },
214
+ tail: async (session) => tail(session)
215
+ }
216
+ };
217
+ }
218
+ function updateSessionIndex(storage, name, target, revision) {
219
+ if (sessionIndexRef(name) === null)
220
+ return;
221
+ const body = target === null ? null : parseText2(storage.sql.exec("SELECT body FROM objects WHERE id = ?", target).toArray()[0]?.body);
222
+ for (const change of sessionIndexChanges2(name, body === null ? null : decodeObject(body), revision))
223
+ storage.sql.exec(change.text, ...change.values);
224
+ }
225
+ function fits(bytes, what) {
226
+ if (bytes > ROW_LIMIT)
227
+ throw new SdkError("invalid", `${what} is ${bytes} bytes, past the Durable Object store's 2 MB row limit.`);
228
+ }
229
+ export {
230
+ durableObjectStore
231
+ };
@@ -0,0 +1 @@
1
+ export declare function sha256(data: string | Uint8Array): string;
@@ -0,0 +1,6 @@
1
+ import {
2
+ sha2562
3
+ } from "../chunks/canvas-preview-0nq75h9k.js";
4
+ export {
5
+ sha2562 as sha256
6
+ };
@@ -0,0 +1,11 @@
1
+ import type { HostId } from "@nyte-ai/schema";
2
+ import type { ListenOptions } from "@nyte-ai/core";
3
+ /**
4
+ * Returns the Node host's identity signer (§50a): `seedSigner` over the
5
+ * Ed25519 seed in `<home>/.nyte/identity.key`, 32 raw bytes minted `0600` by
6
+ * `link` on first use as the secrets key is. The file is not encrypted; it is
7
+ * a signing key, protected as ssh protects one, and it never touches the
8
+ * secrets key. Named apart from core's `hostIdentity(store)`, which reads or
9
+ * mints the host's id.
10
+ */
11
+ export declare function identitySigner(id: HostId, home: string): Promise<NonNullable<ListenOptions["identity"]>>;
@@ -0,0 +1,9 @@
1
+ import {
2
+ identitySigner2
3
+ } from "../chunks/canvas-preview-5mex725c.js";
4
+ import"../chunks/canvas-preview-31w7xm8z.js";
5
+ import"../chunks/canvas-preview-wg80rbc2.js";
6
+ import"../chunks/canvas-preview-mgcx2b2p.js";
7
+ export {
8
+ identitySigner2 as identitySigner
9
+ };
@@ -0,0 +1,12 @@
1
+ import type { HostId } from "@nyte-ai/schema";
2
+ import type { ListenOptions } from "@nyte-ai/core";
3
+ /**
4
+ * Returns the signer a listener answers `GET /.nyte/identity?nonce=` with
5
+ * (`ListenOptions.identity`, §43a), over a 32-byte Ed25519 seed: `id` the
6
+ * host's id and `sign(nonce)` a signature over the UTF-8 bytes of
7
+ * `nyte/identity\n<id>\n<nonce>`, answered with the raw public key, both
8
+ * base64url without padding (§43k). The Node host reads the seed from
9
+ * `<home>/.nyte/identity.key` (`identitySigner`); a deploy passes one from its
10
+ * environment (§50a). Web Crypto only, no `node:*` (the `./identity` subpath).
11
+ */
12
+ export declare function seedSigner(id: HostId, seed: Uint8Array): Promise<NonNullable<ListenOptions["identity"]>>;
@@ -0,0 +1,6 @@
1
+ import {
2
+ seedSigner2
3
+ } from "../chunks/canvas-preview-31w7xm8z.js";
4
+ export {
5
+ seedSigner2 as seedSigner
6
+ };
@@ -0,0 +1 @@
1
+ export declare function exifOrientation(bytes: Uint8Array): number;
@@ -0,0 +1,6 @@
1
+ import {
2
+ exifOrientation2
3
+ } from "../../chunks/canvas-preview-befkjea2.js";
4
+ export {
5
+ exifOrientation2 as exifOrientation
6
+ };
@@ -0,0 +1,37 @@
1
+ import type { ImageLimits, ImageProcessor } from "@nyte-ai/core";
2
+ import { Type } from "typebox";
3
+ export interface NodeImagesOptions {
4
+ readonly worker?: string | URL;
5
+ readonly wasm?: string;
6
+ }
7
+ export interface PrepareRequest {
8
+ readonly id: number;
9
+ readonly bytes: Uint8Array;
10
+ readonly mimeType: string;
11
+ readonly limits: ImageLimits;
12
+ }
13
+ export declare const prepareReply: Type.TUnion<[Type.TObject<{
14
+ id: Type.TInteger;
15
+ result: Type.TNull;
16
+ }>, Type.TObject<{
17
+ id: Type.TInteger;
18
+ result: Type.TObject<{
19
+ data: Type.TString;
20
+ mimeType: Type.TString;
21
+ resized: Type.TOptional<Type.TObject<{
22
+ from: Type.TObject<{
23
+ width: Type.TNumber;
24
+ height: Type.TNumber;
25
+ }>;
26
+ to: Type.TObject<{
27
+ width: Type.TNumber;
28
+ height: Type.TNumber;
29
+ }>;
30
+ }>>;
31
+ }>;
32
+ }>, Type.TObject<{
33
+ id: Type.TInteger;
34
+ error: Type.TString;
35
+ }>]>;
36
+ export declare function nodeImages(options?: NodeImagesOptions): ImageProcessor;
37
+ export declare function resolvePhotonWasmPath(): string;
@@ -0,0 +1,12 @@
1
+ import {
2
+ prepareReply2,
3
+ nodeImages2,
4
+ resolvePhotonWasmPath2
5
+ } from "../../chunks/canvas-preview-y5y6ghaw.js";
6
+ import"../../chunks/canvas-preview-ec2mt7es.js";
7
+ import"../../chunks/canvas-preview-befkjea2.js";
8
+ export {
9
+ nodeImages2 as nodeImages,
10
+ prepareReply2 as prepareReply,
11
+ resolvePhotonWasmPath2 as resolvePhotonWasmPath
12
+ };
@@ -0,0 +1,3 @@
1
+ import type { SyncInitInput } from "@silvia-odwyer/photon/photon_rs.js";
2
+ import type { ImageProcessor } from "@nyte-ai/core";
3
+ export declare function photonImages(wasm: SyncInitInput): ImageProcessor;
@@ -0,0 +1,7 @@
1
+ import {
2
+ photonImages2
3
+ } from "../../chunks/canvas-preview-ec2mt7es.js";
4
+ import"../../chunks/canvas-preview-befkjea2.js";
5
+ export {
6
+ photonImages2 as photonImages
7
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,23 @@
1
+ import"../../chunks/canvas-preview-befkjea2.js";
2
+ import {
3
+ photonImages2
4
+ } from "../../chunks/canvas-preview-ec2mt7es.js";
5
+
6
+ // src/images/worker.ts
7
+ import { parentPort, workerData } from "node:worker_threads";
8
+ var port = parentPort;
9
+ if (port === null)
10
+ throw new Error("The image worker needs a parent thread");
11
+ var wasm = workerData;
12
+ if (!(wasm instanceof Uint8Array))
13
+ throw new Error("The image worker needs Photon's WebAssembly");
14
+ var images = photonImages2(wasm);
15
+ port.on("message", (request) => {
16
+ images.prepare(request.bytes, request.mimeType, request.limits).then((result) => port.postMessage({
17
+ id: request.id,
18
+ result: result ?? null
19
+ }), (cause) => port.postMessage({
20
+ id: request.id,
21
+ error: cause instanceof Error ? cause.message : String(cause)
22
+ }));
23
+ });
@@ -0,0 +1,20 @@
1
+ export * from "./credentials.ts";
2
+ export * from "./identity.ts";
3
+ export { identitySigner } from "./identity-key.ts";
4
+ export * from "./listen.ts";
5
+ export * from "./listen-fetch.ts";
6
+ export * from "./local/files.ts";
7
+ export * from "./local/git.ts";
8
+ export * from "./local/github.ts";
9
+ export * from "./local/identity.ts";
10
+ export * from "./local/jobs.ts";
11
+ export * from "./local/provider.ts";
12
+ export { createMcpHub } from "./mcp/hub.ts";
13
+ export type { McpConnector } from "./mcp/connect.ts";
14
+ export * from "./local/snapshots.ts";
15
+ export * from "./local/worktrees.ts";
16
+ export * from "./open.ts";
17
+ export * from "./plugins/loader.ts";
18
+ export * from "./postgres.ts";
19
+ export * from "./secrets.ts";
20
+ export * from "./sqlite.ts";
@@ -0,0 +1,121 @@
1
+ import {
2
+ credentialStore2,
3
+ sealSecret2,
4
+ openSecret2
5
+ } from "../chunks/canvas-preview-518dh8by.js";
6
+ import {
7
+ seedSigner2
8
+ } from "../chunks/canvas-preview-31w7xm8z.js";
9
+ import"../chunks/canvas-preview-mgcx2b2p.js";
10
+ import"../chunks/canvas-preview-wg80rbc2.js";
11
+ import {
12
+ identitySigner2
13
+ } from "../chunks/canvas-preview-5mex725c.js";
14
+ import"../chunks/canvas-preview-55s0y68g.js";
15
+ import"../chunks/canvas-preview-rp4x6y1h.js";
16
+ import"../chunks/canvas-preview-aq5j4p25.js";
17
+ import {
18
+ listenFetch2
19
+ } from "../chunks/canvas-preview-w54ymtb3.js";
20
+ import {
21
+ listen2
22
+ } from "../chunks/canvas-preview-ycepb05s.js";
23
+ import"../chunks/canvas-preview-0nq75h9k.js";
24
+ import"../chunks/canvas-preview-bxnqt8cd.js";
25
+ import"../chunks/canvas-preview-yjz0f7n4.js";
26
+ import"../chunks/canvas-preview-kn7kvbfj.js";
27
+ import {
28
+ TEXT_LIMIT2,
29
+ localFiles2
30
+ } from "../chunks/canvas-preview-drctegz4.js";
31
+ import"../chunks/canvas-preview-tjhabynd.js";
32
+ import"../chunks/canvas-preview-af86jz8t.js";
33
+ import {
34
+ localGit2
35
+ } from "../chunks/canvas-preview-5ekjx6sw.js";
36
+ import {
37
+ localGitHubAccount2,
38
+ localGitHub2
39
+ } from "../chunks/canvas-preview-8xc0vn7v.js";
40
+ import {
41
+ folderIdentity2
42
+ } from "../chunks/canvas-preview-1sq7z9jq.js";
43
+ import {
44
+ localExec2
45
+ } from "../chunks/canvas-preview-vm9zdp2t.js";
46
+ import {
47
+ localSnapshots2
48
+ } from "../chunks/canvas-preview-crmzxxt8.js";
49
+ import {
50
+ listWorktrees2,
51
+ addWorktree2,
52
+ hasBranch2,
53
+ localWorktrees2
54
+ } from "../chunks/canvas-preview-2jwbe14k.js";
55
+ import {
56
+ localProvider2
57
+ } from "../chunks/canvas-preview-e3vnkkc5.js";
58
+ import"../chunks/canvas-preview-kdqgrstc.js";
59
+ import"../chunks/canvas-preview-5z63am63.js";
60
+ import"../chunks/canvas-preview-pkzqg96v.js";
61
+ import"../chunks/canvas-preview-vaatfznm.js";
62
+ import {
63
+ createMcpHub2
64
+ } from "../chunks/canvas-preview-g5fkjs34.js";
65
+ import"../chunks/canvas-preview-9aqczacs.js";
66
+ import"../chunks/canvas-preview-4e0pxa32.js";
67
+ import"../chunks/canvas-preview-befkjea2.js";
68
+ import"../chunks/canvas-preview-ec2mt7es.js";
69
+ import"../chunks/canvas-preview-y5y6ghaw.js";
70
+ import {
71
+ loadPluginFiles2,
72
+ loadPluginDirectory2,
73
+ pluginLoader2
74
+ } from "../chunks/canvas-preview-s94ebwf5.js";
75
+ import {
76
+ defaultSecrets2
77
+ } from "../chunks/canvas-preview-skzwvw4d.js";
78
+ import"../chunks/canvas-preview-69fkk9yn.js";
79
+ import"../chunks/canvas-preview-zaaj99wd.js";
80
+ import"../chunks/canvas-preview-0cmbkp2j.js";
81
+ import {
82
+ storePath2,
83
+ sqliteStore2
84
+ } from "../chunks/canvas-preview-tnqe7k0b.js";
85
+ import {
86
+ openHost2
87
+ } from "../chunks/canvas-preview-cawy6vbz.js";
88
+ import {
89
+ postgresStore2
90
+ } from "../chunks/canvas-preview-4b6sayhg.js";
91
+ export {
92
+ TEXT_LIMIT2 as TEXT_LIMIT,
93
+ addWorktree2 as addWorktree,
94
+ createMcpHub2 as createMcpHub,
95
+ credentialStore2 as credentialStore,
96
+ defaultSecrets2 as defaultSecrets,
97
+ folderIdentity2 as folderIdentity,
98
+ hasBranch2 as hasBranch,
99
+ identitySigner2 as identitySigner,
100
+ listWorktrees2 as listWorktrees,
101
+ listen2 as listen,
102
+ listenFetch2 as listenFetch,
103
+ loadPluginDirectory2 as loadPluginDirectory,
104
+ loadPluginFiles2 as loadPluginFiles,
105
+ localExec2 as localExec,
106
+ localFiles2 as localFiles,
107
+ localGit2 as localGit,
108
+ localGitHub2 as localGitHub,
109
+ localGitHubAccount2 as localGitHubAccount,
110
+ localProvider2 as localProvider,
111
+ localSnapshots2 as localSnapshots,
112
+ localWorktrees2 as localWorktrees,
113
+ openHost2 as openHost,
114
+ openSecret2 as openSecret,
115
+ pluginLoader2 as pluginLoader,
116
+ postgresStore2 as postgresStore,
117
+ sealSecret2 as sealSecret,
118
+ seedSigner2 as seedSigner,
119
+ sqliteStore2 as sqliteStore,
120
+ storePath2 as storePath
121
+ };
@@ -0,0 +1 @@
1
+ export declare function readKeyFile(path: string, name: string): Promise<Uint8Array>;
@@ -0,0 +1,7 @@
1
+ import {
2
+ readKeyFile2
3
+ } from "../chunks/canvas-preview-wg80rbc2.js";
4
+ import"../chunks/canvas-preview-mgcx2b2p.js";
5
+ export {
6
+ readKeyFile2 as readKeyFile
7
+ };
@@ -0,0 +1,8 @@
1
+ import type { ListenOptions, Listener } from "@nyte-ai/core";
2
+ import type { ServedHost } from "@nyte-ai/core/server";
3
+ /** Serves a composed host as a bare fetch handler with no socket and no `node:*` import, so a Worker can serve it (§41j): `before`, the unauthenticated identity and describe routes, then `createHandler` over one cached connection per principal and authority, every response carrying `X-Nyte-Host` (§43a, §43j). A request authenticates by a pairing code, then the listener token (compared in constant time over SHA-256 digests) or a device token remembered until a commit from another process moves the host's principals, then `authorize` under `custom`; a revoke aborts that principal's open requests and streams. A `token` shorter than 16 characters throws `SdkError("invalid")`; `execution` (default: run covering all) drives covered sessions in process on an `admit-only` host, covers their leases otherwise and takes nothing on a `dispatch` host (§42v); `close()` disconnects the clients and releases the execution once, after which every request answers `unavailable`. */
4
+ export declare function listenFetch(host: ServedHost, options: ListenOptions & {
5
+ readonly transport: {
6
+ readonly kind: "fetch";
7
+ };
8
+ }): Promise<Listener>;
@@ -0,0 +1,9 @@
1
+ import {
2
+ listenFetch2
3
+ } from "../chunks/canvas-preview-w54ymtb3.js";
4
+ import"../chunks/canvas-preview-aq5j4p25.js";
5
+ import"../chunks/canvas-preview-55s0y68g.js";
6
+ import"../chunks/canvas-preview-rp4x6y1h.js";
7
+ export {
8
+ listenFetch2 as listenFetch
9
+ };
@@ -0,0 +1,4 @@
1
+ import type { ListenOptions, Listener } from "@nyte-ai/core";
2
+ import type { ServedHost } from "@nyte-ai/core/server";
3
+ /** Serves a composed host, the `Host.listen` `openHost` attaches: everything but the socket is `listenFetch`'s, and the `fetch` transport answers with it directly. The `http` transport binds `node:http` on `hostname` (default 127.0.0.1) and `port` (default 0), streaming each request body in and each response body out chunk by chunk, with a client gone aborting its request; a failed bind throws `SdkError("unavailable")` after releasing the execution. `disconnectClients()` also destroys every open Node response, and `close()` closes the socket once. */
4
+ export declare function listen(host: ServedHost, options: ListenOptions): Promise<Listener>;
@@ -0,0 +1,10 @@
1
+ import {
2
+ listen2
3
+ } from "../chunks/canvas-preview-ycepb05s.js";
4
+ import"../chunks/canvas-preview-w54ymtb3.js";
5
+ import"../chunks/canvas-preview-aq5j4p25.js";
6
+ import"../chunks/canvas-preview-55s0y68g.js";
7
+ import"../chunks/canvas-preview-rp4x6y1h.js";
8
+ export {
9
+ listen2 as listen
10
+ };