@nyte-ai/host 0.0.23 → 0.0.24

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 (41) hide show
  1. package/README.md +2 -2
  2. package/THIRD-PARTY-NOTICES.md +2 -38
  3. package/dist/chunks/{canvas-preview-ayayyd43.js → canvas-preview-w0mr5bkn.js} +147 -4
  4. package/dist/src/durable-object.d.ts +1 -1
  5. package/dist/src/index.js +1 -1
  6. package/dist/src/open.js +1 -1
  7. package/package.json +8 -30
  8. package/src/durable-object.ts +1 -1
  9. package/src/open.ts +7 -1
  10. package/src/usage-history.ts +0 -1
  11. package/dist/chunks/canvas-preview-1f8h0he1.js +0 -81
  12. package/dist/chunks/canvas-preview-2zdyh9ny.js +0 -26
  13. package/dist/chunks/canvas-preview-65xqjw7f.js +0 -20
  14. package/dist/chunks/canvas-preview-dsb5829c.js +0 -166
  15. package/dist/chunks/canvas-preview-kzmp015w.js +0 -36
  16. package/dist/src/deploy/cloudflare/worker.d.ts +0 -50
  17. package/dist/src/deploy/cloudflare/worker.js +0 -196
  18. package/dist/src/deploy/vercel/nitro.config.d.ts +0 -2
  19. package/dist/src/deploy/vercel/nitro.config.js +0 -30
  20. package/dist/src/deploy/vercel/server/routes/[...].d.ts +0 -2
  21. package/dist/src/deploy/vercel/server/routes/[...].js +0 -18
  22. package/dist/src/deploy/vercel/server/utils/host.d.ts +0 -13
  23. package/dist/src/deploy/vercel/server/utils/host.js +0 -7
  24. package/dist/src/deploy/vercel/server/utils/repair.d.ts +0 -1
  25. package/dist/src/deploy/vercel/server/utils/repair.js +0 -6
  26. package/dist/src/deploy/vercel/server/utils/step.d.ts +0 -10
  27. package/dist/src/deploy/vercel/server/utils/step.js +0 -6
  28. package/dist/src/deploy/vercel/server/workflows/drive.d.ts +0 -14
  29. package/dist/src/deploy/vercel/server/workflows/drive.js +0 -13
  30. package/src/deploy/cloudflare/README.md +0 -3
  31. package/src/deploy/cloudflare/worker.ts +0 -306
  32. package/src/deploy/cloudflare/wrangler.jsonc +0 -12
  33. package/src/deploy/vercel/README.md +0 -3
  34. package/src/deploy/vercel/nitro.config.ts +0 -29
  35. package/src/deploy/vercel/server/routes/[...].ts +0 -10
  36. package/src/deploy/vercel/server/utils/host.ts +0 -104
  37. package/src/deploy/vercel/server/utils/repair.ts +0 -35
  38. package/src/deploy/vercel/server/utils/step.ts +0 -25
  39. package/src/deploy/vercel/server/workflows/drive.ts +0 -46
  40. package/src/deploy/vercel/tsconfig.json +0 -9
  41. package/src/deploy/vercel/types/bun.d.ts +0 -2
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # @nyte-ai/host
2
2
 
3
- The Node and edge sides of a Nyte host, around the host `composeHost` builds in `@nyte-ai/core`: `listen` serves it over `node:http` or as a bare fetch handler, and `listenFetch` (`@nyte-ai/host/listen-fetch`, node-free) is that fetch handler for Workers, both through `src/serve`'s handler, which binds `@nyte-ai/protocol`'s table to the server port `composeHost` returns, with token, pairing and custom authentication, CORS, the `/.nyte/identity` and `/.nyte/describe` routes, and in-process driving when the kernel only admits; `sqliteStore` (`node:sqlite`), `postgresStore` (any `pg`-shaped pool) and `durableObjectStore` (`@nyte-ai/host/durable-object`, a Durable Object's SQLite) implement core's `Store`, each publish one transaction with its compare-and-set and log append; `localProvider` serves a folder on this machine, with files over `node:fs` versioned by content, `.gitignore`-aware scan, find, search (ripgrep, else a scan) and watch, processes over pipes or a pty (`@lydell/node-pty`, loaded on first use), git over its CLI, each file's patch sent as its unified diff text, and run snapshots kept as hidden git refs or a content-addressed tree walk; `chatOnlyProvider` and `sandboxProvider` (`@nyte-ai/host/providers`, node-free) serve a workspace with no files and one in a remote sandbox; `loadPluginFiles` and `pluginLoader` import the core plugins in `.nyte/plugins` directories; and `src/deploy` holds two deployments, a Cloudflare Worker whose Durable Object runs one host from its alarm (`@nyte-ai/host/deploy/cloudflare`) and a Nitro app for Vercel whose heads run as workflows (`@nyte-ai/host/deploy/vercel`).
3
+ The Node and edge sides of a Nyte host, around the host `composeHost` builds in `@nyte-ai/core`: `listen` serves it over `node:http` or as a bare fetch handler, and `listenFetch` (`@nyte-ai/host/listen-fetch`, node-free) is that fetch handler for Workers, both through `src/serve`'s handler, which binds `@nyte-ai/protocol`'s table to the server port `composeHost` returns, with token, pairing and custom authentication, CORS, the `/.nyte/identity` and `/.nyte/describe` routes, and in-process driving when the kernel only admits; `sqliteStore` (`node:sqlite`), `postgresStore` (any `pg`-shaped pool) and `durableObjectStore` (`@nyte-ai/host/durable-object`, a Durable Object's SQLite) implement core's `Store`, each publish one transaction with its compare-and-set and log append; `localProvider` serves a folder on this machine, with files over `node:fs` versioned by content, `.gitignore`-aware scan, find, search (ripgrep, else a scan) and watch, processes over pipes or a pty (`@lydell/node-pty`, loaded on first use), git over its CLI, each file's patch sent as its unified diff text, and run snapshots kept as hidden git refs or a content-addressed tree walk; `chatOnlyProvider` and `sandboxProvider` (`@nyte-ai/host/providers`, node-free) serve a workspace with no files and one in a remote sandbox; and `loadPluginFiles` and `pluginLoader` import the core plugins in `.nyte/plugins` directories. Deployments built on these live in `packages/examples`: a Cloudflare Worker whose Durable Object runs one host from its alarm, and a Nitro app for Vercel whose heads run as workflows.
4
4
 
5
5
  ## Tests
6
6
 
7
- `pnpm --dir packages/host test` runs every store against one conformance suite: sqlite, postgres over pglite, and the Durable Object store over a `node:sqlite` stand-in of its SQL storage (`test/do-sql-stub.ts`), the same stand-in the alarm `pass` and the `NyteHost` cold-start tests use. Deferred (Part 2 §43i): running the Worker and the Durable Object store inside workerd, and checking that the Worker's import graph reaches no `node:*` module, until a package that already depends on `wrangler` takes them; host itself carries neither `miniflare` nor `esbuild`.
7
+ `pnpm --dir packages/host test` runs every store against one conformance suite: sqlite, postgres over pglite, and the Durable Object store over a `node:sqlite` stand-in of its SQL storage (`test/do-sql-stub.ts`). The Worker's alarm `pass` and `NyteHost` cold-start tests live with the Worker in `packages/examples/cloudflare`. Deferred (Part 2 §43i): running the Worker and the Durable Object store inside workerd, and checking that the Worker's import graph reaches no `node:*` module, until a package that already depends on `wrangler` takes them; host itself carries neither `miniflare` nor `esbuild`.
@@ -45,39 +45,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
45
45
  SOFTWARE.
46
46
  ```
47
47
 
48
- ## pi-claude-code (`earendil-works/pi-claude-code`)
49
-
50
- - Repository: https://github.com/earendil-works/pi-claude-code
51
- - What: the Claude Code CLI provider, single-turn relay, transcript replay,
52
- process reuse, and billing guards in `packages/plugin/examples/claude-code`
53
- are adapted from commit `70abb65186592ca788b29b3db22c3160d629c41f`.
54
-
55
- License: MIT, with the following notice:
56
-
57
- ```text
58
- MIT License
59
-
60
- Copyright (c) 2026 Armin Ronacher
61
-
62
- Permission is hereby granted, free of charge, to any person obtaining a copy
63
- of this software and associated documentation files (the "Software"), to deal
64
- in the Software without restriction, including without limitation the rights
65
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
66
- copies of the Software, and to permit persons to whom the Software is
67
- furnished to do so, subject to the following conditions:
68
-
69
- The above copyright notice and this permission notice shall be included in all
70
- copies or substantial portions of the Software.
71
-
72
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
73
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
74
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
75
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
76
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
77
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
78
- SOFTWARE.
79
- ```
80
-
81
48
  ## pi (`earendil-works/pi`)
82
49
 
83
50
  - Repository: https://github.com/earendil-works/pi
@@ -345,8 +312,8 @@ Copyright 2025 OpenAI
345
312
  front of the queue (`packages/tui/src/model/interactions.ts`) is its
346
313
  `onEmptySubmit`. The rename
347
314
  plugin's context construction, prompt, model fallback, and output cleanup
348
- (`packages/plugin/examples/rename.ts`) port OpenCode v2. The web-search
349
- plugin set (`packages/plugin/examples/web-search/`) ports its Exa, Firecrawl,
315
+ (`packages/plugin/src/rename.ts`) port OpenCode v2. The web-search
316
+ plugin set (`packages/plugin/src/web-search.ts`) ports its Exa, Firecrawl,
350
317
  Parallel, and Tavily adapters, its stateless MCP `tools/call` transport and
351
318
  response bounds, its result and error vocabulary, and its arrangement of one
352
319
  plugin per provider from OpenCode v2.
@@ -429,9 +396,6 @@ SOFTWARE.
429
396
  bypass, and connection tuning in `packages/host/src/sqlite*.ts` are adapted
430
397
  from `bf8ffe81a63c82d3de5fbaa9991fd5f30034a452`.
431
398
  - Homepage: https://t3.codes
432
- - What: the demo desktop app (`packages/demo/desktop`) follows T3 Code's
433
- control-surface shape — agents in a sidebar, a conversation workspace, a
434
- shared composer, and settings behind a dialog.
435
399
 
436
400
  License: MIT, with the following notice:
437
401
 
@@ -39,9 +39,6 @@ import {
39
39
  storePath2,
40
40
  sqliteStore2
41
41
  } from "./canvas-preview-mstbvwz3.js";
42
- import {
43
- package_default
44
- } from "./canvas-preview-dsb5829c.js";
45
42
 
46
43
  // src/open.ts
47
44
  import { watch } from "node:fs";
@@ -70,6 +67,148 @@ import question from "@nyte-ai/plugin/core/question";
70
67
  import rename from "@nyte-ai/plugin/core/rename";
71
68
  import telemetry from "@nyte-ai/plugin/core/telemetry";
72
69
  import webSearch from "@nyte-ai/plugin/core/web-search";
70
+ // package.json
71
+ var package_default = {
72
+ name: "@nyte-ai/host",
73
+ version: "0.0.24",
74
+ private: false,
75
+ license: "MIT",
76
+ repository: {
77
+ type: "git",
78
+ url: "git+https://github.com/interfaces-lab/nyte.git",
79
+ directory: "packages/host"
80
+ },
81
+ files: [
82
+ "dist",
83
+ "src",
84
+ "LICENSE",
85
+ "THIRD-PARTY-NOTICES.md"
86
+ ],
87
+ type: "module",
88
+ exports: {
89
+ ".": "./src/index.ts",
90
+ "./canvas-preview": "./src/canvas-preview.ts",
91
+ "./credentials": "./src/credentials.ts",
92
+ "./durable-object": "./src/durable-object.ts",
93
+ "./identity": "./src/identity.ts",
94
+ "./images": "./src/images/node.ts",
95
+ "./image-worker": "./src/images/worker.ts",
96
+ "./listen-fetch": "./src/listen-fetch.ts",
97
+ "./providers": "./src/providers.ts",
98
+ "./secrets": "./src/secrets.ts",
99
+ "./shell-env": "./src/shell-env.ts",
100
+ "./usage": "./src/usage.ts",
101
+ "./store-usage": "./src/store-usage.ts",
102
+ "./usage-service": "./src/usage-service.ts",
103
+ "./usage-scan": "./src/usage-scan.ts",
104
+ "./usage-worker": "./src/usage-worker.ts"
105
+ },
106
+ publishConfig: {
107
+ exports: {
108
+ ".": {
109
+ types: "./dist/src/index.d.ts",
110
+ import: "./dist/src/index.js"
111
+ },
112
+ "./canvas-preview": {
113
+ types: "./dist/src/canvas-preview.d.ts",
114
+ import: "./dist/src/canvas-preview.js"
115
+ },
116
+ "./credentials": {
117
+ types: "./dist/src/credentials.d.ts",
118
+ import: "./dist/src/credentials.js"
119
+ },
120
+ "./durable-object": {
121
+ types: "./dist/src/durable-object.d.ts",
122
+ import: "./dist/src/durable-object.js"
123
+ },
124
+ "./identity": {
125
+ types: "./dist/src/identity.d.ts",
126
+ import: "./dist/src/identity.js"
127
+ },
128
+ "./images": {
129
+ types: "./dist/src/images/node.d.ts",
130
+ import: "./dist/src/images/node.js"
131
+ },
132
+ "./image-worker": {
133
+ types: "./dist/src/images/worker.d.ts",
134
+ import: "./dist/src/images/worker.js"
135
+ },
136
+ "./listen-fetch": {
137
+ types: "./dist/src/listen-fetch.d.ts",
138
+ import: "./dist/src/listen-fetch.js"
139
+ },
140
+ "./providers": {
141
+ types: "./dist/src/providers.d.ts",
142
+ import: "./dist/src/providers.js"
143
+ },
144
+ "./secrets": {
145
+ types: "./dist/src/secrets.d.ts",
146
+ import: "./dist/src/secrets.js"
147
+ },
148
+ "./shell-env": {
149
+ types: "./dist/src/shell-env.d.ts",
150
+ import: "./dist/src/shell-env.js"
151
+ },
152
+ "./usage": {
153
+ types: "./dist/src/usage.d.ts",
154
+ import: "./dist/src/usage.js"
155
+ },
156
+ "./store-usage": {
157
+ types: "./dist/src/store-usage.d.ts",
158
+ import: "./dist/src/store-usage.js"
159
+ },
160
+ "./usage-service": {
161
+ types: "./dist/src/usage-service.d.ts",
162
+ import: "./dist/src/usage-service.js"
163
+ },
164
+ "./usage-scan": {
165
+ types: "./dist/src/usage-scan.d.ts",
166
+ import: "./dist/src/usage-scan.js"
167
+ },
168
+ "./usage-worker": {
169
+ types: "./dist/src/usage-worker.d.ts",
170
+ import: "./dist/src/usage-worker.js"
171
+ }
172
+ },
173
+ access: "public",
174
+ provenance: true
175
+ },
176
+ scripts: {
177
+ clean: "rm -rf node_modules .turbo",
178
+ typecheck: "tsrs --noEmit",
179
+ test: "vitest --run",
180
+ "check:store": "node scripts/check-store.ts",
181
+ "build:package": "bun ../../scripts/sdk-packages.mjs build host"
182
+ },
183
+ dependencies: {
184
+ "@earendil-works/pi-mcp": "^1.3.0",
185
+ "@lydell/node-pty": "^1.2.0-beta.15",
186
+ "@nyte-ai/ai": "workspace:*",
187
+ "@nyte-ai/core": "workspace:*",
188
+ "@nyte-ai/plugin": "workspace:*",
189
+ "@nyte-ai/protocol": "workspace:*",
190
+ "@nyte-ai/schema": "workspace:*",
191
+ "@silvia-odwyer/photon": "^0.3.3",
192
+ fflate: "^0.8.3",
193
+ ignore: "^7.0.13",
194
+ pg: "^8.23.1",
195
+ typebox: "^1.4.2"
196
+ },
197
+ devDependencies: {
198
+ "@electric-sql/pglite": "^0.5.11",
199
+ "@nyte-ai/canvas": "workspace:*",
200
+ "@types/node": "^26.6.5",
201
+ "@types/pg": "^8.23.1",
202
+ "fast-check": "^4.10.2",
203
+ typescript: "6.0.3",
204
+ vitest: "^5.0.5"
205
+ },
206
+ engines: {
207
+ node: ">=26.4.0"
208
+ }
209
+ };
210
+
211
+ // src/open.ts
73
212
  var RELOAD_DEBOUNCE_MS = 250;
74
213
  var STORE_POLL_MS = 500;
75
214
  async function openHost2(options) {
@@ -343,7 +482,11 @@ async function settingsSeed(home) {
343
482
  return { seed: { settings, path }, issue: null };
344
483
  }
345
484
  function hostDescription() {
346
- return { name: hostname(), platform: process.platform, version: package_default.version };
485
+ return {
486
+ name: hostname(),
487
+ platform: process.platform,
488
+ version: typeof NYTE_BUILT_VERSION === "string" ? NYTE_BUILT_VERSION : package_default.version
489
+ };
347
490
  }
348
491
  function settingsPath(home) {
349
492
  return join(home, ".nyte", "settings.json");
@@ -10,5 +10,5 @@ export type DurableObjectSql = {
10
10
  };
11
11
  transactionSync<T>(closure: () => T): T;
12
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. */
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 `packages/examples/cloudflare/worker.ts` does), or `log`'s validation throws inside a request. */
14
14
  export declare function durableObjectStore(storage: DurableObjectSql): Store;
package/dist/src/index.js CHANGED
@@ -84,7 +84,7 @@ import {
84
84
  } from "../chunks/canvas-preview-mstbvwz3.js";
85
85
  import {
86
86
  openHost2
87
- } from "../chunks/canvas-preview-ayayyd43.js";
87
+ } from "../chunks/canvas-preview-w0mr5bkn.js";
88
88
  import {
89
89
  postgresStore2
90
90
  } from "../chunks/canvas-preview-4b6sayhg.js";
package/dist/src/open.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  openHost2
3
- } from "../chunks/canvas-preview-ayayyd43.js";
3
+ } from "../chunks/canvas-preview-w0mr5bkn.js";
4
4
  import"../chunks/canvas-preview-4e0pxa32.js";
5
5
  import"../chunks/canvas-preview-y5y6ghaw.js";
6
6
  import"../chunks/canvas-preview-ec2mt7es.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nyte-ai/host",
3
- "version": "0.0.23",
3
+ "version": "0.0.24",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -79,14 +79,6 @@
79
79
  "./usage-worker": {
80
80
  "types": "./dist/src/usage-worker.d.ts",
81
81
  "import": "./dist/src/usage-worker.js"
82
- },
83
- "./deploy/cloudflare": {
84
- "types": "./dist/src/deploy/cloudflare/worker.d.ts",
85
- "import": "./dist/src/deploy/cloudflare/worker.js"
86
- },
87
- "./deploy/vercel": {
88
- "types": "./dist/src/deploy/vercel/nitro.config.d.ts",
89
- "import": "./dist/src/deploy/vercel/nitro.config.js"
90
82
  }
91
83
  },
92
84
  "publishConfig": {
@@ -96,11 +88,11 @@
96
88
  "dependencies": {
97
89
  "@earendil-works/pi-mcp": "^1.3.0",
98
90
  "@lydell/node-pty": "^1.2.0-beta.15",
99
- "@nyte-ai/ai": "0.0.23",
100
- "@nyte-ai/core": "0.0.23",
101
- "@nyte-ai/plugin": "0.0.23",
102
- "@nyte-ai/protocol": "0.0.23",
103
- "@nyte-ai/schema": "0.0.23",
91
+ "@nyte-ai/ai": "0.0.24",
92
+ "@nyte-ai/core": "0.0.24",
93
+ "@nyte-ai/plugin": "0.0.24",
94
+ "@nyte-ai/protocol": "0.0.24",
95
+ "@nyte-ai/schema": "0.0.24",
104
96
  "@silvia-odwyer/photon": "^0.3.3",
105
97
  "fflate": "^0.8.3",
106
98
  "ignore": "^7.0.13",
@@ -113,29 +105,15 @@
113
105
  "@types/node": "^26.6.5",
114
106
  "@types/pg": "^8.23.1",
115
107
  "fast-check": "^4.10.2",
116
- "nitro": "^3.0.260903-beta",
117
108
  "typescript": "6.0.3",
118
- "vitest": "^5.0.5",
119
- "workflow": "^5.2.3"
120
- },
121
- "peerDependencies": {
122
- "nitro": "^3.0.260903-beta",
123
- "workflow": "^5.2.3"
124
- },
125
- "peerDependenciesMeta": {
126
- "nitro": {
127
- "optional": true
128
- },
129
- "workflow": {
130
- "optional": true
131
- }
109
+ "vitest": "^5.0.5"
132
110
  },
133
111
  "engines": {
134
112
  "node": ">=26.4.0"
135
113
  },
136
114
  "scripts": {
137
115
  "clean": "rm -rf node_modules .turbo",
138
- "typecheck": "tsrs --noEmit && tsrs --noEmit -p src/deploy/vercel",
116
+ "typecheck": "tsrs --noEmit",
139
117
  "test": "vitest --run",
140
118
  "check:store": "node scripts/check-store.ts",
141
119
  "build:package": "bun ../../scripts/sdk-packages.mjs build host"
@@ -44,7 +44,7 @@ const ROW_LIMIT = 2_000_000;
44
44
 
45
45
  const encoder = new TextEncoder();
46
46
 
47
- /** 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. */
47
+ /** 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 `packages/examples/cloudflare/worker.ts` does), or `log`'s validation throws inside a request. */
48
48
  export function durableObjectStore(storage: DurableObjectSql): Store {
49
49
  let connection: StoreConnection | null = null;
50
50
 
package/src/open.ts CHANGED
@@ -50,6 +50,8 @@ import { defaultSecrets } from "./secrets.ts";
50
50
  import type { SecretsSource } from "./secrets.ts";
51
51
  import { sqliteStore, storePath } from "./sqlite.ts";
52
52
 
53
+ declare const NYTE_BUILT_VERSION: string | undefined;
54
+
53
55
  const RELOAD_DEBOUNCE_MS = 250;
54
56
 
55
57
  const STORE_POLL_MS = 500;
@@ -441,7 +443,11 @@ async function settingsSeed(home: string): Promise<{
441
443
  }
442
444
 
443
445
  function hostDescription(): HostDescription {
444
- return { name: hostname(), platform: process.platform, version: manifest.version };
446
+ return {
447
+ name: hostname(),
448
+ platform: process.platform,
449
+ version: typeof NYTE_BUILT_VERSION === "string" ? NYTE_BUILT_VERSION : manifest.version,
450
+ };
445
451
  }
446
452
 
447
453
  function settingsPath(home: string): string {
@@ -159,7 +159,6 @@ async function* historyLines(path: string, start: number, signal: AbortSignal |
159
159
  const chunk = pending.length === 0 ? read : Buffer.concat([pending, read]);
160
160
  let from = 0;
161
161
 
162
- // oxlint-disable-next-line nyte-code/no-index-of -- a byte search keeps offsets exact, which decoded text cannot
163
162
  for (let newline = chunk.indexOf(0x0a); newline !== -1; newline = chunk.indexOf(0x0a, from)) {
164
163
  yield {
165
164
  text: chunk.toString("utf8", from, newline),
@@ -1,81 +0,0 @@
1
- import {
2
- answerRepair2
3
- } from "./canvas-preview-2zdyh9ny.js";
4
- import {
5
- package_default
6
- } from "./canvas-preview-dsb5829c.js";
7
-
8
- // src/deploy/vercel/server/utils/host.ts
9
- import process from "node:process";
10
- import { createModels } from "@nyte-ai/ai/models";
11
- import { SdkError } from "@nyte-ai/schema";
12
- import { composeHost } from "@nyte-ai/core/server";
13
- import { postgresStore } from "@nyte-ai/host";
14
- import { credentialStore } from "@nyte-ai/host/credentials";
15
- import { seedSigner } from "@nyte-ai/host/identity";
16
- import { listenFetch } from "@nyte-ai/host/listen-fetch";
17
- import { sandboxProvider } from "@nyte-ai/host/providers";
18
- var PAGE = 100;
19
- var boot = async () => {
20
- throw new SdkError("unavailable", "Supply a boot over your sandbox SDK in server/utils/host.ts.");
21
- };
22
- var building = null;
23
- function vercelHost2(dispatch) {
24
- const built = building ??= build(dispatch);
25
- built.catch(() => {
26
- if (building === built)
27
- building = null;
28
- });
29
- return built;
30
- }
31
- async function build(dispatch) {
32
- const connectionString = process.env.DATABASE_URL;
33
- if (connectionString === undefined || connectionString === "")
34
- throw new SdkError("unavailable", "Set DATABASE_URL to the Postgres database the host keeps.");
35
- const identityKey = process.env.NYTE_IDENTITY_KEY;
36
- const store = postgresStore({ connectionString });
37
- const secrets = secretsFrom(process.env.NYTE_SECRET_KEY);
38
- const description = { name: "nyte-host", platform: "vercel", version: package_default.version };
39
- const host = await composeHost({
40
- store,
41
- models: createModels({ credentials: credentialStore(store, secrets) }),
42
- plugins: [{ id: "sandbox", environment: sandboxProvider({ boot }) }],
43
- workspace: { kind: "sandbox", locator: { name: process.env.NYTE_SANDBOX ?? "nyte" } },
44
- execution: { kind: "dispatch", dispatch },
45
- poll: 1000,
46
- secrets,
47
- home: null,
48
- description
49
- });
50
- const repair = async () => {
51
- let cursor;
52
- do {
53
- const page = await host.execution.repair({ cursor, limit: PAGE });
54
- cursor = page.next ?? undefined;
55
- } while (cursor !== undefined);
56
- };
57
- const listener = await listenFetch(host, {
58
- transport: { kind: "fetch" },
59
- auth: { kind: "token", token: process.env.NYTE_TOKEN ?? "" },
60
- execution: { kind: "admit-only" },
61
- describe: () => description,
62
- ...identityKey === undefined || identityKey === "" ? {} : { identity: await seedSigner(host.hostId, Uint8Array.fromBase64(identityKey)) },
63
- before: (request) => answerRepair2(request, process.env.CRON_SECRET, repair)
64
- }).catch(async (error) => {
65
- await host.close();
66
- throw error;
67
- });
68
- return { host, listener };
69
- }
70
- function secretsFrom(key) {
71
- if (key === undefined || key === "")
72
- return {
73
- key: async () => {
74
- throw new SdkError("unavailable", "Set NYTE_SECRET_KEY to a base64 32-byte key.");
75
- }
76
- };
77
- const bytes = new Uint8Array(Buffer.from(key, "base64"));
78
- return { key: async () => bytes };
79
- }
80
-
81
- export { vercelHost2 };
@@ -1,26 +0,0 @@
1
- // src/deploy/vercel/server/utils/repair.ts
2
- import { createHash, timingSafeEqual } from "node:crypto";
3
- import { SdkError } from "@nyte-ai/schema";
4
- import { encodeError, errorStatus } from "@nyte-ai/protocol";
5
- async function answerRepair2(request, secret, repair) {
6
- if (request.method !== "GET" || new URL(request.url).pathname !== "/.nyte/repair")
7
- return;
8
- if (secret === undefined || secret === "")
9
- return failure(new SdkError("unknown", "This deployment sets no CRON_SECRET."));
10
- const given = /^Bearer\s+(\S+)\s*$/i.exec(request.headers.get("Authorization") ?? "")?.[1] ?? "";
11
- if (!timingSafeEqual(digest(given), digest(secret)))
12
- return failure(new SdkError("unauthenticated", "Send Authorization: Bearer <CRON_SECRET>."));
13
- await repair();
14
- return new Response(null, { status: 204 });
15
- }
16
- function digest(text) {
17
- return createHash("sha256").update(text).digest();
18
- }
19
- function failure(error) {
20
- return new Response(JSON.stringify(encodeError(error)), {
21
- status: errorStatus[error.code],
22
- headers: { "Content-Type": "application/json" }
23
- });
24
- }
25
-
26
- export { answerRepair2 };
@@ -1,20 +0,0 @@
1
- // src/deploy/vercel/server/utils/step.ts
2
- function stepFrom2(report, now) {
3
- switch (report.kind) {
4
- case "continue":
5
- return { kind: "advance" };
6
- case "waiting":
7
- return report.until === null ? { kind: "stop" } : untilStep(report.until, now);
8
- case "retry":
9
- return untilStep(report.until, now);
10
- case "busy":
11
- case "idle":
12
- case "fenced":
13
- return { kind: "stop" };
14
- }
15
- }
16
- function untilStep(until, now) {
17
- return until > now ? { kind: "sleep", ms: until - now } : { kind: "advance" };
18
- }
19
-
20
- export { stepFrom2 };