@nyte-ai/host 0.0.18 → 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 (102) hide show
  1. package/THIRD-PARTY-NOTICES.md +66 -0
  2. package/dist/chunks/{canvas-preview-5hxat7hh.js → canvas-preview-11nadadc.js} +8 -6
  3. package/dist/chunks/{canvas-preview-rp6fz0w5.js → canvas-preview-2jwbe14k.js} +5 -5
  4. package/dist/chunks/{canvas-preview-m02v4yy6.js → canvas-preview-55s0y68g.js} +3 -2
  5. package/dist/chunks/{canvas-preview-xn10d4f8.js → canvas-preview-5ekjx6sw.js} +9 -4
  6. package/dist/chunks/{canvas-preview-75db60xy.js → canvas-preview-8xc0vn7v.js} +5 -4
  7. package/dist/chunks/{canvas-preview-zn2d0k9d.js → canvas-preview-af86jz8t.js} +14 -6
  8. package/dist/chunks/{canvas-preview-d9wwhbtz.js → canvas-preview-aq5j4p25.js} +1 -1
  9. package/dist/chunks/{canvas-preview-j1tnf51w.js → canvas-preview-b2v8wfnz.js} +1 -1
  10. package/dist/chunks/canvas-preview-befkjea2.js +60 -0
  11. package/dist/chunks/canvas-preview-bxnqt8cd.js +103 -0
  12. package/dist/chunks/{canvas-preview-vax9ne4e.js → canvas-preview-cawy6vbz.js} +22 -11
  13. package/dist/chunks/{canvas-preview-senpjwep.js → canvas-preview-crmzxxt8.js} +3 -3
  14. package/dist/chunks/{canvas-preview-ymgz0937.js → canvas-preview-drctegz4.js} +8 -4
  15. package/dist/chunks/{canvas-preview-yrfz2ak6.js → canvas-preview-e3vnkkc5.js} +6 -6
  16. package/dist/chunks/canvas-preview-ec2mt7es.js +108 -0
  17. package/dist/chunks/{canvas-preview-1ta3avah.js → canvas-preview-fxa0rfb0.js} +10 -5
  18. package/dist/chunks/{canvas-preview-8xgt67ka.js → canvas-preview-g5fkjs34.js} +1 -1
  19. package/dist/chunks/{canvas-preview-g3qj3y3k.js → canvas-preview-jeddjex8.js} +13 -3
  20. package/dist/chunks/{canvas-preview-0nrnbt76.js → canvas-preview-k1yg4fgp.js} +199 -125
  21. package/dist/chunks/canvas-preview-kp75gb63.js +141 -0
  22. package/dist/chunks/{canvas-preview-ewgspmsd.js → canvas-preview-n2a35zv5.js} +1 -1
  23. package/dist/chunks/{canvas-preview-h8hshnff.js → canvas-preview-pkzqg96v.js} +1 -1
  24. package/dist/chunks/{canvas-preview-evh92ywd.js → canvas-preview-tnqe7k0b.js} +15 -10
  25. package/dist/chunks/{canvas-preview-ehf3vp31.js → canvas-preview-vm9zdp2t.js} +45 -58
  26. package/dist/chunks/{canvas-preview-76fwvd6e.js → canvas-preview-w54ymtb3.js} +1 -1
  27. package/dist/chunks/canvas-preview-y5y6ghaw.js +125 -0
  28. package/dist/chunks/{canvas-preview-98aj5p34.js → canvas-preview-ycepb05s.js} +1 -1
  29. package/dist/src/canvas-preview.js +7 -3
  30. package/dist/src/deploy/cloudflare/worker.js +1 -1
  31. package/dist/src/deploy/vercel/server/routes/[...].js +2 -2
  32. package/dist/src/deploy/vercel/server/utils/host.js +1 -1
  33. package/dist/src/deploy/vercel/server/workflows/drive.js +3 -3
  34. package/dist/src/images/exif.d.ts +1 -0
  35. package/dist/src/images/exif.js +6 -0
  36. package/dist/src/images/node.d.ts +37 -0
  37. package/dist/src/images/node.js +12 -0
  38. package/dist/src/images/photon.d.ts +3 -0
  39. package/dist/src/images/photon.js +7 -0
  40. package/dist/src/images/worker.d.ts +1 -0
  41. package/dist/src/images/worker.js +23 -0
  42. package/dist/src/index.d.ts +0 -1
  43. package/dist/src/index.js +23 -22
  44. package/dist/src/listen-fetch.js +3 -3
  45. package/dist/src/listen.js +4 -4
  46. package/dist/src/local/command.d.ts +5 -0
  47. package/dist/src/local/command.js +6 -2
  48. package/dist/src/local/files.js +2 -2
  49. package/dist/src/local/git-watch.d.ts +1 -1
  50. package/dist/src/local/git-watch.js +1 -1
  51. package/dist/src/local/git.js +3 -3
  52. package/dist/src/local/github.js +2 -2
  53. package/dist/src/local/jobs.d.ts +1 -1
  54. package/dist/src/local/jobs.js +2 -1
  55. package/dist/src/local/provider.js +9 -9
  56. package/dist/src/local/snapshots.js +2 -2
  57. package/dist/src/local/worktrees.js +2 -2
  58. package/dist/src/mcp/connect.d.ts +0 -13
  59. package/dist/src/mcp/connect.js +1 -1
  60. package/dist/src/mcp/hub.js +2 -2
  61. package/dist/src/open.d.ts +2 -30
  62. package/dist/src/open.js +20 -18
  63. package/dist/src/serve/binding.js +1 -1
  64. package/dist/src/serve/handler.js +2 -2
  65. package/dist/src/sqlite.d.ts +2 -1
  66. package/dist/src/sqlite.js +4 -3
  67. package/dist/src/store-usage.js +4 -1
  68. package/dist/src/usage-history.d.ts +54 -0
  69. package/dist/src/usage-history.js +14 -0
  70. package/dist/src/usage-service.d.ts +2 -1
  71. package/dist/src/usage-service.js +7 -3
  72. package/dist/src/usage-worker.js +8 -4
  73. package/dist/src/usage.d.ts +150 -27
  74. package/dist/src/usage.js +12 -2
  75. package/package.json +16 -8
  76. package/src/canvas-preview.ts +4 -3
  77. package/src/images/exif.ts +69 -0
  78. package/src/images/node.ts +163 -0
  79. package/src/images/photon.ts +141 -0
  80. package/src/images/worker.ts +29 -0
  81. package/src/index.ts +19 -1
  82. package/src/local/command.ts +64 -12
  83. package/src/local/files.ts +8 -3
  84. package/src/local/git-watch.ts +16 -6
  85. package/src/local/git.ts +7 -2
  86. package/src/local/github.ts +3 -4
  87. package/src/local/jobs.ts +55 -69
  88. package/src/local/snapshots.ts +4 -2
  89. package/src/local/worktrees.ts +4 -4
  90. package/src/mcp/connect.ts +1 -14
  91. package/src/open.ts +16 -36
  92. package/src/serve/binding.ts +4 -3
  93. package/src/sqlite.ts +33 -8
  94. package/src/store-usage.ts +5 -2
  95. package/src/usage-history.ts +219 -0
  96. package/src/usage-service.ts +12 -3
  97. package/src/usage.ts +251 -176
  98. package/dist/chunks/canvas-preview-a3yw0j70.js +0 -72
  99. package/dist/chunks/canvas-preview-azg56359.js +0 -68
  100. package/dist/src/store-owner.d.ts +0 -15
  101. package/dist/src/store-owner.js +0 -9
  102. package/src/store-owner.ts +0 -98
package/dist/src/index.js CHANGED
@@ -11,59 +11,62 @@ import"../chunks/canvas-preview-wg80rbc2.js";
11
11
  import {
12
12
  identitySigner2
13
13
  } from "../chunks/canvas-preview-5mex725c.js";
14
- import"../chunks/canvas-preview-m02v4yy6.js";
14
+ import"../chunks/canvas-preview-55s0y68g.js";
15
15
  import"../chunks/canvas-preview-rp4x6y1h.js";
16
- import"../chunks/canvas-preview-d9wwhbtz.js";
16
+ import"../chunks/canvas-preview-aq5j4p25.js";
17
17
  import {
18
18
  listenFetch2
19
- } from "../chunks/canvas-preview-76fwvd6e.js";
19
+ } from "../chunks/canvas-preview-w54ymtb3.js";
20
20
  import {
21
21
  listen2
22
- } from "../chunks/canvas-preview-98aj5p34.js";
22
+ } from "../chunks/canvas-preview-ycepb05s.js";
23
23
  import"../chunks/canvas-preview-0nq75h9k.js";
24
- import"../chunks/canvas-preview-azg56359.js";
24
+ import"../chunks/canvas-preview-bxnqt8cd.js";
25
25
  import"../chunks/canvas-preview-yjz0f7n4.js";
26
26
  import"../chunks/canvas-preview-kn7kvbfj.js";
27
27
  import {
28
28
  TEXT_LIMIT2,
29
29
  localFiles2
30
- } from "../chunks/canvas-preview-ymgz0937.js";
30
+ } from "../chunks/canvas-preview-drctegz4.js";
31
31
  import"../chunks/canvas-preview-tjhabynd.js";
32
- import"../chunks/canvas-preview-zn2d0k9d.js";
32
+ import"../chunks/canvas-preview-af86jz8t.js";
33
33
  import {
34
34
  localGit2
35
- } from "../chunks/canvas-preview-xn10d4f8.js";
35
+ } from "../chunks/canvas-preview-5ekjx6sw.js";
36
36
  import {
37
37
  localGitHubAccount2,
38
38
  localGitHub2
39
- } from "../chunks/canvas-preview-75db60xy.js";
39
+ } from "../chunks/canvas-preview-8xc0vn7v.js";
40
40
  import {
41
41
  folderIdentity2
42
42
  } from "../chunks/canvas-preview-1sq7z9jq.js";
43
43
  import {
44
44
  localExec2
45
- } from "../chunks/canvas-preview-ehf3vp31.js";
45
+ } from "../chunks/canvas-preview-vm9zdp2t.js";
46
46
  import {
47
47
  localSnapshots2
48
- } from "../chunks/canvas-preview-senpjwep.js";
48
+ } from "../chunks/canvas-preview-crmzxxt8.js";
49
49
  import {
50
50
  listWorktrees2,
51
51
  addWorktree2,
52
52
  hasBranch2,
53
53
  localWorktrees2
54
- } from "../chunks/canvas-preview-rp6fz0w5.js";
54
+ } from "../chunks/canvas-preview-2jwbe14k.js";
55
55
  import {
56
56
  localProvider2
57
- } from "../chunks/canvas-preview-yrfz2ak6.js";
57
+ } from "../chunks/canvas-preview-e3vnkkc5.js";
58
58
  import"../chunks/canvas-preview-kdqgrstc.js";
59
59
  import"../chunks/canvas-preview-5z63am63.js";
60
- import"../chunks/canvas-preview-h8hshnff.js";
60
+ import"../chunks/canvas-preview-pkzqg96v.js";
61
61
  import"../chunks/canvas-preview-vaatfznm.js";
62
62
  import {
63
63
  createMcpHub2
64
- } from "../chunks/canvas-preview-8xgt67ka.js";
64
+ } from "../chunks/canvas-preview-g5fkjs34.js";
65
65
  import"../chunks/canvas-preview-9aqczacs.js";
66
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";
67
70
  import {
68
71
  loadPluginFiles2,
69
72
  loadPluginDirectory2,
@@ -76,19 +79,16 @@ import"../chunks/canvas-preview-69fkk9yn.js";
76
79
  import"../chunks/canvas-preview-zaaj99wd.js";
77
80
  import"../chunks/canvas-preview-0cmbkp2j.js";
78
81
  import {
79
- StoreOwned2
80
- } from "../chunks/canvas-preview-a3yw0j70.js";
81
- import {
82
+ storePath2,
82
83
  sqliteStore2
83
- } from "../chunks/canvas-preview-evh92ywd.js";
84
+ } from "../chunks/canvas-preview-tnqe7k0b.js";
84
85
  import {
85
86
  openHost2
86
- } from "../chunks/canvas-preview-vax9ne4e.js";
87
+ } from "../chunks/canvas-preview-cawy6vbz.js";
87
88
  import {
88
89
  postgresStore2
89
90
  } from "../chunks/canvas-preview-4b6sayhg.js";
90
91
  export {
91
- StoreOwned2 as StoreOwned,
92
92
  TEXT_LIMIT2 as TEXT_LIMIT,
93
93
  addWorktree2 as addWorktree,
94
94
  createMcpHub2 as createMcpHub,
@@ -116,5 +116,6 @@ export {
116
116
  postgresStore2 as postgresStore,
117
117
  sealSecret2 as sealSecret,
118
118
  seedSigner2 as seedSigner,
119
- sqliteStore2 as sqliteStore
119
+ sqliteStore2 as sqliteStore,
120
+ storePath2 as storePath
120
121
  };
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  listenFetch2
3
- } from "../chunks/canvas-preview-76fwvd6e.js";
4
- import"../chunks/canvas-preview-d9wwhbtz.js";
5
- import"../chunks/canvas-preview-m02v4yy6.js";
3
+ } from "../chunks/canvas-preview-w54ymtb3.js";
4
+ import"../chunks/canvas-preview-aq5j4p25.js";
5
+ import"../chunks/canvas-preview-55s0y68g.js";
6
6
  import"../chunks/canvas-preview-rp4x6y1h.js";
7
7
  export {
8
8
  listenFetch2 as listenFetch
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  listen2
3
- } from "../chunks/canvas-preview-98aj5p34.js";
4
- import"../chunks/canvas-preview-76fwvd6e.js";
5
- import"../chunks/canvas-preview-d9wwhbtz.js";
6
- import"../chunks/canvas-preview-m02v4yy6.js";
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
7
  import"../chunks/canvas-preview-rp4x6y1h.js";
8
8
  export {
9
9
  listen2 as listen
@@ -1,3 +1,4 @@
1
+ import type { ChildProcess, SpawnOptions } from "node:child_process";
1
2
  export type Ran = {
2
3
  readonly code: number | null;
3
4
  readonly stdout: Buffer;
@@ -12,4 +13,8 @@ export declare function run(file: string, args: readonly string[], options: {
12
13
  /** Kills the command after this long; it then ends with a null code. */
13
14
  readonly timeoutMs?: number;
14
15
  }): Promise<Ran>;
16
+ /** Spawns `file` as `spawn` does, except that on Windows a `.cmd` or `.bat` file runs through `cmd.exe` with its arguments escaped, as Node no longer starts batch files without a shell. */
17
+ export declare function spawnCommand(file: string, args: readonly string[], options: SpawnOptions): ChildProcess;
18
+ /** Ends `child` with `signal`; on Windows, which has no signals, it ends the child's whole process tree with `taskkill /T /F`, as `kill` alone would leave what a batch file or a shell started running. */
19
+ export declare function killTree(child: ChildProcess, signal: NodeJS.Signals): void;
15
20
  export declare function findExecutable(name: string, directories?: readonly string[]): Promise<string | null>;
@@ -1,8 +1,12 @@
1
1
  import {
2
2
  run2,
3
+ spawnCommand2,
4
+ killTree2,
3
5
  findExecutable2
4
- } from "../../chunks/canvas-preview-azg56359.js";
6
+ } from "../../chunks/canvas-preview-bxnqt8cd.js";
5
7
  export {
6
8
  findExecutable2 as findExecutable,
7
- run2 as run
9
+ killTree2 as killTree,
10
+ run2 as run,
11
+ spawnCommand2 as spawnCommand
8
12
  };
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  TEXT_LIMIT2,
3
3
  localFiles2
4
- } from "../../chunks/canvas-preview-ymgz0937.js";
4
+ } from "../../chunks/canvas-preview-drctegz4.js";
5
5
  import"../../chunks/canvas-preview-kn7kvbfj.js";
6
- import"../../chunks/canvas-preview-azg56359.js";
7
6
  import"../../chunks/canvas-preview-yjz0f7n4.js";
7
+ import"../../chunks/canvas-preview-bxnqt8cd.js";
8
8
  import"../../chunks/canvas-preview-0nq75h9k.js";
9
9
  import"../../chunks/canvas-preview-mgcx2b2p.js";
10
10
  export {
@@ -11,5 +11,5 @@ export type Repository = {
11
11
  export type GitWatcher = {
12
12
  subscribe(listener: (status: GitStatus) => void, fail: FeedSink<GitStatus>["fail"]): Disposer;
13
13
  };
14
- /** Returns the status watch `localGit` shares among its watchers: the first subscriber starts it and the last one stops it, and each gets the status at once, then again whenever a change could move it. A recursive `fs.watch` on the workspace hears worktree paths that `.gitignore` and `.git/info/exclude` do not ignore, and, in the git directory and the common directory, only HEAD, the index, branch and remote refs, `packed-refs`, `config` and the merge, cherry-pick, revert and rebase state, so object writes, logs and Nyte's snapshot refs read nothing; the `.git` entry itself appearing or going drops the remembered repository and starts over. Only where `fs.watch` is unavailable does it poll, every 2 s. */
14
+ /** Returns the status watch `localGit` shares among its watchers: the first subscriber starts it and the last one stops it, and each gets the status at once, then again whenever a change could move it. A recursive `fs.watch` on the workspace hears worktree paths that `.gitignore` and `.git/info/exclude` do not ignore, and, in the git directory and the common directory, only HEAD, the index, branch and remote refs, `packed-refs`, `config` and the merge, cherry-pick, revert and rebase state, so object writes, logs and Nyte's snapshot refs read nothing; the `.git` entry itself appearing or going (not a change inside it, which Windows also reports on the folder) drops the remembered repository and starts over. Only where `fs.watch` is unavailable does it poll, every 2 s. */
15
15
  export declare function createWatcher(cwd: string, read: () => Promise<GitStatus>, repository: () => Promise<Repository | null>, forget: () => void): GitWatcher;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createWatcher2
3
- } from "../../chunks/canvas-preview-zn2d0k9d.js";
3
+ } from "../../chunks/canvas-preview-af86jz8t.js";
4
4
  import"../../chunks/canvas-preview-mgcx2b2p.js";
5
5
  export {
6
6
  createWatcher2 as createWatcher
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  localGit2
3
- } from "../../chunks/canvas-preview-xn10d4f8.js";
3
+ } from "../../chunks/canvas-preview-5ekjx6sw.js";
4
4
  import"../../chunks/canvas-preview-tjhabynd.js";
5
5
  import"../../chunks/canvas-preview-kn7kvbfj.js";
6
- import"../../chunks/canvas-preview-azg56359.js";
7
6
  import"../../chunks/canvas-preview-yjz0f7n4.js";
8
- import"../../chunks/canvas-preview-zn2d0k9d.js";
7
+ import"../../chunks/canvas-preview-af86jz8t.js";
8
+ import"../../chunks/canvas-preview-bxnqt8cd.js";
9
9
  import"../../chunks/canvas-preview-0nq75h9k.js";
10
10
  import"../../chunks/canvas-preview-mgcx2b2p.js";
11
11
  export {
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  localGitHubAccount2,
3
3
  localGitHub2
4
- } from "../../chunks/canvas-preview-75db60xy.js";
5
- import"../../chunks/canvas-preview-azg56359.js";
4
+ } from "../../chunks/canvas-preview-8xc0vn7v.js";
5
+ import"../../chunks/canvas-preview-bxnqt8cd.js";
6
6
  export {
7
7
  localGitHub2 as localGitHub,
8
8
  localGitHubAccount2 as localGitHubAccount
@@ -1,5 +1,5 @@
1
1
  import type { ExecutionEnv } from "@nyte-ai/core";
2
- /** Returns `exec` for a folder: each call starts one process as a `Job` (a fresh id; `key` null, core keys pty jobs) in `cwd` resolved against `root` (default `root`), with `env` laid over `process.env`. A string command runs through the platform shell (`/bin/sh -c`, `cmd.exe /d /s /c` on Windows) and an argv directly; `[]` with `pty` runs the login shell (`shell()` read at each start, else `$SHELL`, else `/bin/sh`, as a login shell; §37h), a pty's environment carrying `TERM=xterm-256color`, `COLORTERM=truecolor` and `TERM_PROGRAM=Nyte` without Electron's `ELECTRON_RUN_AS_NODE` and `NODE_OPTIONS`, and `[]` without one throws `SdkError("invalid")`. A program that cannot start throws `SdkError("unavailable")`. Without `pty` the process is piped through `node:child_process` in its own process group, stdout and stderr interleaved in `output` (with `stdio: "protocol"`, stderr's frames tagged `stream: "stderr"` and the pipe paced like a pty, so a reader open from the start misses nothing) and stdin fed by `write`; with `pty` it runs under `@lydell/node-pty`, loaded on first use through `createRequire` (§41a; `loadPty`, given, loads it instead, on every pty start), at the given size, and a platform where it does not load throws `SdkError("unavailable")`. `output()` opens a reader over the last 1 MiB of output that yields `bytes`, a `gap` where the reader fell behind or opened after output was dropped, and `exit { code }` last; a merged pipe never stalls, and a pty or a protocol pipe pauses while its slowest open reader is 256 KiB behind, resuming once it is within 64 KiB. `resize` resizes a pty (`not-pty` for a pipe, `missing` once it ended); `idle` answers whether a pty's shell sits at a prompt: by its OSC 133 prompt markers once it sent one, else when it has printed nothing for 300 ms and the cursor's line holds text after the last newline, as a prompt does (false for a pipe); `stop` sends SIGTERM to a pipe's process group (SIGHUP to a pty), SIGKILL after 2 s, and answers `settled { outcome }` (also once it ended); `settled` resolves `exited { code, reason }` (`code` null after a signal), `reason` `exited` when the process ended on its own and `terminated` after `stop` or an aborted `signal`, and an aborted `settled` signal rejects with `SdkError("unavailable")`; `close` detaches this handle's readers. An aborted `signal` stops the process. `signal` on the options ends every reader of every job started here, leaving the processes running (what the provider's `close` does). */
2
+ /** Returns `exec` for a folder: each call starts one process as a `Job` (a fresh id; `key` null, core keys pty jobs) in `cwd` resolved against `root` (default `root`), with `env` laid over `process.env`. A string command runs through the platform shell (`/bin/sh -c`, `cmd.exe /d /s /c` on Windows) and an argv directly; `[]` with `pty` runs the login shell (`shell()` read at each start, else `$SHELL`, else `/bin/sh`, as a login shell; §37h), a pty's environment carrying `TERM=xterm-256color`, `COLORTERM=truecolor` and `TERM_PROGRAM=Nyte` without Electron's `ELECTRON_RUN_AS_NODE` and `NODE_OPTIONS`, and `[]` without one throws `SdkError("invalid")`. A program that cannot start throws `SdkError("unavailable")`. Without `pty` the process is piped through `node:child_process` in its own process group, stdout and stderr interleaved in `output` (with `stdio: "protocol"`, stderr's frames tagged `stream: "stderr"` and the pipe paced like a pty, so a reader open from the start misses nothing) and stdin fed by `write`; with `pty` it runs under `@lydell/node-pty`, loaded on first use through `createRequire` (§41a; `loadPty`, given, loads it instead, on every pty start), at the given size, and a platform where it does not load throws `SdkError("unavailable")`. `output()` opens a reader over the last 1 MiB of output that yields `bytes`, a `gap` where the reader fell behind or opened after output was dropped, and `exit { code }` last; a merged pipe never stalls, and a pty or a protocol pipe pauses while its slowest open reader is 256 KiB behind, resuming once it is within 64 KiB. `resize` resizes a pty (`not-pty` for a pipe, `missing` once it ended); `idle` checks the OS process table for a login shell with no live children (false for a pipe or explicit command, true once it ended); `stop` sends SIGTERM to a pipe's process group (SIGHUP to a pty), SIGKILL after 2 s (on Windows, which has no signals, it ends a pipe's process tree at once with `taskkill /T /F`), and answers `settled { outcome }` (also once it ended); `settled` resolves `exited { code, reason }` (`code` null after a signal), `reason` `exited` when the process ended on its own and `terminated` after `stop` or an aborted `signal`, and an aborted `settled` signal rejects with `SdkError("unavailable")`; `close` detaches this handle's readers. An aborted `signal` stops the process. `signal` on the options ends every reader of every job started here, leaving the processes running (what the provider's `close` does). */
3
3
  export declare function localExec(root: string, options?: {
4
4
  readonly shell?: () => string | null;
5
5
  readonly signal?: AbortSignal;
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  localExec2
3
- } from "../../chunks/canvas-preview-ehf3vp31.js";
3
+ } from "../../chunks/canvas-preview-vm9zdp2t.js";
4
+ import"../../chunks/canvas-preview-bxnqt8cd.js";
4
5
  export {
5
6
  localExec2 as localExec
6
7
  };
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  localProvider2
3
- } from "../../chunks/canvas-preview-yrfz2ak6.js";
4
- import"../../chunks/canvas-preview-rp6fz0w5.js";
5
- import"../../chunks/canvas-preview-xn10d4f8.js";
6
- import"../../chunks/canvas-preview-75db60xy.js";
3
+ } from "../../chunks/canvas-preview-e3vnkkc5.js";
4
+ import"../../chunks/canvas-preview-2jwbe14k.js";
5
+ import"../../chunks/canvas-preview-5ekjx6sw.js";
6
+ import"../../chunks/canvas-preview-8xc0vn7v.js";
7
7
  import"../../chunks/canvas-preview-1sq7z9jq.js";
8
- import"../../chunks/canvas-preview-ehf3vp31.js";
9
- import"../../chunks/canvas-preview-senpjwep.js";
8
+ import"../../chunks/canvas-preview-vm9zdp2t.js";
9
+ import"../../chunks/canvas-preview-crmzxxt8.js";
10
10
  import"../../chunks/canvas-preview-tjhabynd.js";
11
- import"../../chunks/canvas-preview-ymgz0937.js";
11
+ import"../../chunks/canvas-preview-drctegz4.js";
12
12
  import"../../chunks/canvas-preview-kn7kvbfj.js";
13
- import"../../chunks/canvas-preview-azg56359.js";
14
13
  import"../../chunks/canvas-preview-yjz0f7n4.js";
15
- import"../../chunks/canvas-preview-zn2d0k9d.js";
14
+ import"../../chunks/canvas-preview-af86jz8t.js";
15
+ import"../../chunks/canvas-preview-bxnqt8cd.js";
16
16
  import"../../chunks/canvas-preview-0nq75h9k.js";
17
17
  import"../../chunks/canvas-preview-mgcx2b2p.js";
18
18
  export {
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  localSnapshots2
3
- } from "../../chunks/canvas-preview-senpjwep.js";
3
+ } from "../../chunks/canvas-preview-crmzxxt8.js";
4
4
  import"../../chunks/canvas-preview-tjhabynd.js";
5
5
  import"../../chunks/canvas-preview-kn7kvbfj.js";
6
- import"../../chunks/canvas-preview-azg56359.js";
6
+ import"../../chunks/canvas-preview-bxnqt8cd.js";
7
7
  import"../../chunks/canvas-preview-0nq75h9k.js";
8
8
  import"../../chunks/canvas-preview-mgcx2b2p.js";
9
9
  export {
@@ -3,8 +3,8 @@ import {
3
3
  addWorktree2,
4
4
  hasBranch2,
5
5
  localWorktrees2
6
- } from "../../chunks/canvas-preview-rp6fz0w5.js";
7
- import"../../chunks/canvas-preview-azg56359.js";
6
+ } from "../../chunks/canvas-preview-2jwbe14k.js";
7
+ import"../../chunks/canvas-preview-bxnqt8cd.js";
8
8
  import"../../chunks/canvas-preview-0nq75h9k.js";
9
9
  export {
10
10
  addWorktree2 as addWorktree,
@@ -5,24 +5,11 @@ import type { McpWorkspace } from "@nyte-ai/core/server";
5
5
  import type { McpOAuthConfig } from "@nyte-ai/schema";
6
6
  import type { McpServerEntry } from "./config.ts";
7
7
  import type { McpOAuthSettings } from "./oauth.ts";
8
- /**
9
- * Opens the transport to one server for one workspace. A url server that
10
- * needs OAuth sends its stored tokens; when it needs a new sign-in the
11
- * connection fails with `McpOAuthAuthorizationRequiredError`, after passing
12
- * the server's challenge to `challenged`. Throws when the entry cannot be
13
- * started, such as a missing `${VAR}`.
14
- */
15
8
  export type McpConnector = (entry: McpServerEntry, context: {
16
9
  readonly workspace: McpWorkspace;
17
10
  readonly home: string;
18
11
  readonly secrets: PluginStorage["secrets"];
19
12
  readonly challenged: (challenge: OAuthChallenge) => void;
20
13
  }) => McpTransport;
21
- /**
22
- * Runs stdio servers on this machine, in `cwd` resolved against the
23
- * workspace folder, and connects to url servers over streamable HTTP. A url
24
- * server without an `Authorization` header signs in with OAuth.
25
- */
26
14
  export declare const connectServer: McpConnector;
27
- /** A server's OAuth options with `${VAR}`s in `clientSecret` resolved. */
28
15
  export declare function oauthSettings(config: McpOAuthConfig, server: string): McpOAuthSettings;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  connectServer2,
3
3
  oauthSettings2
4
- } from "../../chunks/canvas-preview-h8hshnff.js";
4
+ } from "../../chunks/canvas-preview-pkzqg96v.js";
5
5
  import"../../chunks/canvas-preview-5z63am63.js";
6
6
  export {
7
7
  connectServer2 as connectServer,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createMcpHub2
3
- } from "../../chunks/canvas-preview-8xgt67ka.js";
4
- import"../../chunks/canvas-preview-h8hshnff.js";
3
+ } from "../../chunks/canvas-preview-g5fkjs34.js";
4
+ import"../../chunks/canvas-preview-pkzqg96v.js";
5
5
  import"../../chunks/canvas-preview-5z63am63.js";
6
6
  import"../../chunks/canvas-preview-vaatfznm.js";
7
7
  import"../../chunks/canvas-preview-kdqgrstc.js";
@@ -1,42 +1,14 @@
1
1
  import type { Models } from "@nyte-ai/ai";
2
2
  import type { WorkspaceTarget } from "@nyte-ai/schema";
3
3
  import type { Host, OpenOptions, Plugin, Store } from "@nyte-ai/core";
4
- /**
5
- * Describes what `openHost` takes: `OpenOptions` with `store`, `workspace`,
6
- * `models` and `plugins` optional, `secrets` defaulting to this machine's key,
7
- * and the home directory holding `.nyte`. Every `OpenOptions` is one, so the
8
- * sdk's Node `open` passes its options straight through.
9
- */
10
4
  export type OpenHostOptions = Omit<OpenOptions, "store" | "workspace" | "models" | "plugins"> & {
11
- /** The host's store; absent, `sqliteStore` at `<home>/.nyte/nyte.db`, which the host then closes with itself (§51c). */
12
5
  readonly store?: Store;
13
- /** Where a root session acts when `create` names none; default the local folder `process.cwd()` (§51c). */
14
6
  readonly workspace?: WorkspaceTarget;
15
- /** The `@nyte-ai/ai` catalog; absent, `nyteModels` over this host's encrypted credential store (§42e). */
16
7
  readonly models?: Models;
17
- /** Core plugins loaded after the first-party built-ins and before the plugin files; default none. One with a built-in's id replaces that built-in, as a bundled client's `codemode` runtime does, and a `local` environment provider among them replaces the default one. */
18
8
  readonly plugins?: readonly Plugin<"core">[];
19
- /** The directory whose `.nyte` holds the store, settings, plugins, secrets key and identity key; default `os.homedir()`. */
20
9
  readonly home?: string;
21
- /** The login shell the default local provider's pty jobs run, read at each start; absent or null is `$SHELL`. */
22
10
  readonly shell?: () => string | null;
11
+ readonly label?: string;
12
+ readonly onRevoked?: () => void;
23
13
  };
24
- /**
25
- * Opens the Node host the sdk's Node `open` calls: `composeHost` with
26
- * `home` (default `os.homedir()`), `store` (default `<home>/.nyte/nyte.db`,
27
- * checked every 500 ms for another process's commits, which are then read so
28
- * a second process on the file sees the first one's runs live),
29
- * `workspace` (default the local folder `process.cwd()`), `secrets` (default
30
- * `defaultSecrets(home)`), `models` (default `nyteModels`), `localProvider`
31
- * unless a plugin provides the `local` environment, every first-party plugin
32
- * of `@nyte-ai/plugin` that `plugins` does not replace by id, then `plugins`
33
- * and `filePlugins`' files, `settingsSeed`'s seed and
34
- * `hostDescription()`; each file that did not load becomes a
35
- * `server.report` row. The host's `loadPlugins` is `pluginLoader` over
36
- * the plugin directories (§47l), which `watchPlugins` watches for hot reload
37
- * (§49a). `listen` defaults `identity` to `identitySigner(host.hostId, home)`
38
- * and `describe` to the description; nothing here reads the secrets key, even
39
- * with a credential stored (§50d, §55). `close()` stops the watch, closes the
40
- * open listeners, the host, then a store it opened.
41
- */
42
14
  export declare function openHost(options: OpenHostOptions): Promise<Host>;
package/dist/src/open.js CHANGED
@@ -1,36 +1,38 @@
1
1
  import {
2
2
  openHost2
3
- } from "../chunks/canvas-preview-vax9ne4e.js";
3
+ } from "../chunks/canvas-preview-cawy6vbz.js";
4
4
  import"../chunks/canvas-preview-4e0pxa32.js";
5
+ import"../chunks/canvas-preview-y5y6ghaw.js";
6
+ import"../chunks/canvas-preview-ec2mt7es.js";
7
+ import"../chunks/canvas-preview-befkjea2.js";
5
8
  import"../chunks/canvas-preview-9aqczacs.js";
6
- import"../chunks/canvas-preview-yrfz2ak6.js";
7
- import"../chunks/canvas-preview-rp6fz0w5.js";
8
- import"../chunks/canvas-preview-xn10d4f8.js";
9
- import"../chunks/canvas-preview-75db60xy.js";
9
+ import"../chunks/canvas-preview-e3vnkkc5.js";
10
+ import"../chunks/canvas-preview-2jwbe14k.js";
11
+ import"../chunks/canvas-preview-5ekjx6sw.js";
12
+ import"../chunks/canvas-preview-8xc0vn7v.js";
10
13
  import"../chunks/canvas-preview-1sq7z9jq.js";
11
- import"../chunks/canvas-preview-ehf3vp31.js";
12
- import"../chunks/canvas-preview-senpjwep.js";
14
+ import"../chunks/canvas-preview-vm9zdp2t.js";
15
+ import"../chunks/canvas-preview-crmzxxt8.js";
13
16
  import"../chunks/canvas-preview-tjhabynd.js";
14
- import"../chunks/canvas-preview-8xgt67ka.js";
15
- import"../chunks/canvas-preview-h8hshnff.js";
17
+ import"../chunks/canvas-preview-g5fkjs34.js";
18
+ import"../chunks/canvas-preview-pkzqg96v.js";
16
19
  import"../chunks/canvas-preview-5z63am63.js";
17
20
  import"../chunks/canvas-preview-vaatfznm.js";
18
- import"../chunks/canvas-preview-ymgz0937.js";
21
+ import"../chunks/canvas-preview-drctegz4.js";
19
22
  import"../chunks/canvas-preview-kn7kvbfj.js";
20
- import"../chunks/canvas-preview-azg56359.js";
21
23
  import"../chunks/canvas-preview-yjz0f7n4.js";
22
- import"../chunks/canvas-preview-zn2d0k9d.js";
24
+ import"../chunks/canvas-preview-af86jz8t.js";
23
25
  import"../chunks/canvas-preview-s94ebwf5.js";
24
26
  import"../chunks/canvas-preview-kdqgrstc.js";
25
- import"../chunks/canvas-preview-evh92ywd.js";
27
+ import"../chunks/canvas-preview-tnqe7k0b.js";
26
28
  import"../chunks/canvas-preview-zaaj99wd.js";
27
- import"../chunks/canvas-preview-a3yw0j70.js";
28
- import"../chunks/canvas-preview-98aj5p34.js";
29
- import"../chunks/canvas-preview-76fwvd6e.js";
30
- import"../chunks/canvas-preview-d9wwhbtz.js";
31
- import"../chunks/canvas-preview-m02v4yy6.js";
29
+ import"../chunks/canvas-preview-ycepb05s.js";
30
+ import"../chunks/canvas-preview-w54ymtb3.js";
31
+ import"../chunks/canvas-preview-aq5j4p25.js";
32
+ import"../chunks/canvas-preview-55s0y68g.js";
32
33
  import"../chunks/canvas-preview-rp4x6y1h.js";
33
34
  import"../chunks/canvas-preview-skzwvw4d.js";
35
+ import"../chunks/canvas-preview-bxnqt8cd.js";
34
36
  import"../chunks/canvas-preview-518dh8by.js";
35
37
  import"../chunks/canvas-preview-0cmbkp2j.js";
36
38
  import"../chunks/canvas-preview-69fkk9yn.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  bindConnection2
3
- } from "../../chunks/canvas-preview-m02v4yy6.js";
3
+ } from "../../chunks/canvas-preview-55s0y68g.js";
4
4
  export {
5
5
  bindConnection2 as bindConnection
6
6
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createHandler2
3
- } from "../../chunks/canvas-preview-d9wwhbtz.js";
4
- import"../../chunks/canvas-preview-m02v4yy6.js";
3
+ } from "../../chunks/canvas-preview-aq5j4p25.js";
4
+ import"../../chunks/canvas-preview-55s0y68g.js";
5
5
  import"../../chunks/canvas-preview-rp4x6y1h.js";
6
6
  export {
7
7
  createHandler2 as createHandler
@@ -1,5 +1,6 @@
1
1
  import type { Store } from "@nyte-ai/core";
2
- /** Returns a `Store` over one `node:sqlite` `DatabaseSync`: a file at `path` (WAL mode, opened only by the process that `claimStore` makes its owner, so a second process rejects with `SdkError("unavailable")` before it reads or migrates the file) or an in-memory database. The first `open()` brings it to core's `STORE_VERSION` with `migrateStore` (core's `objects`, `refs`, `log` and `store_meta` tables; each commit one `BEGIN IMMEDIATE`), a file store whose migration rewrites records first saving those refs' rows (name, target, revision; objects are never deleted, so the rows restore them) to `backups/store-<time>-<pid>-<uuid>-v<from>-v<to>.json` beside it, keeping the newest three backups, and rejects with `SdkError("unavailable")` for a store a newer Nyte migrated; a `migrations` table an older Nyte left is kept and ignored. `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; an object and a blob that share an id share the row, each column filled once (§41f); `blob` reads the bytes back with their size and a null mime. `refs.set` is one `BEGIN IMMEDIATE` transaction with `RefStore.set`'s semantics, each revision a random UUID, that first rejects with `SdkError("unavailable")` when a newer Nyte has migrated the store since it opened. `list(prefix)` reads the name range from `prefix` in name order (BINARY, by code point); `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; `commitMark` is the writer connection's `PRAGMA data_version`, which moves only for another connection's commit. `checkpoints` keeps one fold checkpoint per session in `fold_checkpoints`, a write at a lower seq leaving the kept one, and `gap` counts a session's events past a seq and sums their UTF-8 bytes. File stores run `list` and `log` on a read-only worker and WAL checkpoints on a separate worker, checking at 1,000 frames and after 100 ms idle with a 10,000-frame writer backstop; unavailable workers warn and fall back to the main connection. Checkpoints use fullfsync on macOS, WAL reuse retains at most 32 MiB, and opening refreshes planner statistics. Writes binding more than 64 KiB use uncached statements. Every `open()` returns a connection over the one writer; `close()` waits for opening and worker shutdown before closing it, and an open during close waits to reopen. */
2
+ /** The local store's file: `NYTE_DB` when set, so a source run keeps its own chats, else `.nyte/nyte.db` under `home`. */
3
+ export declare function storePath(home: string): string;
3
4
  export declare function sqliteStore(input: {
4
5
  readonly path: string;
5
6
  } | {
@@ -1,10 +1,11 @@
1
1
  import {
2
+ storePath2,
2
3
  sqliteStore2
3
- } from "../chunks/canvas-preview-evh92ywd.js";
4
+ } from "../chunks/canvas-preview-tnqe7k0b.js";
4
5
  import"../chunks/canvas-preview-zaaj99wd.js";
5
- import"../chunks/canvas-preview-a3yw0j70.js";
6
6
  import"../chunks/canvas-preview-0cmbkp2j.js";
7
7
  import"../chunks/canvas-preview-69fkk9yn.js";
8
8
  export {
9
- sqliteStore2 as sqliteStore
9
+ sqliteStore2 as sqliteStore,
10
+ storePath2 as storePath
10
11
  };
@@ -4,8 +4,11 @@ import {
4
4
  shiftDay2,
5
5
  projectUsageReport2,
6
6
  readNyteUsage2
7
- } from "../chunks/canvas-preview-5hxat7hh.js";
7
+ } from "../chunks/canvas-preview-11nadadc.js";
8
8
  import"../chunks/canvas-preview-srgfpdmf.js";
9
+ import"../chunks/canvas-preview-tnqe7k0b.js";
10
+ import"../chunks/canvas-preview-zaaj99wd.js";
11
+ import"../chunks/canvas-preview-0cmbkp2j.js";
9
12
  import"../chunks/canvas-preview-69fkk9yn.js";
10
13
  export {
11
14
  USAGE_EVENTS2 as USAGE_EVENTS,
@@ -0,0 +1,54 @@
1
+ import type { Stats } from "node:fs";
2
+ import { Type, type TSchema } from "typebox";
3
+ export interface HistoryLine {
4
+ readonly text: string;
5
+ /** False for a last line without its newline: its writer may still be appending it. */
6
+ readonly terminated: boolean;
7
+ }
8
+ export interface HistoryFold<Scan> {
9
+ line(line: HistoryLine): void;
10
+ scan(): Scan;
11
+ }
12
+ /** Folds a history file's lines into a scan. `scan()` returns a copy, so folding goes on without changing it. */
13
+ export type HistoryParser<Scan> = (from: Scan | undefined) => HistoryFold<Scan>;
14
+ export interface FileScan<Scan> {
15
+ readonly size: number;
16
+ readonly mtimeMs: number;
17
+ /** The byte after the last newline, where a grown file resumes. */
18
+ readonly position: number;
19
+ /** The scan of every line up to `position`. */
20
+ readonly committed: Scan;
21
+ }
22
+ export declare function fileScanSchema<Scan extends TSchema>(scan: Scan): Type.TObject<{
23
+ size: Type.TNumber;
24
+ mtimeMs: Type.TNumber;
25
+ position: Type.TNumber;
26
+ committed: Scan;
27
+ }>;
28
+ /** Scans keyed by path. A scan answers while its file keeps the size and mtime it was read at. */
29
+ export declare class UsageScanCache<Scan> {
30
+ #private;
31
+ constructor(files?: Iterable<readonly [string, FileScan<Scan>]>);
32
+ keys(): IterableIterator<string>;
33
+ entries(): IterableIterator<[string, FileScan<Scan>]>;
34
+ get(path: string): FileScan<Scan> | undefined;
35
+ set(path: string, scan: FileScan<Scan>): void;
36
+ /** Forgets every file a read did not reach. */
37
+ keepOnly(seen: ReadonlySet<string>): void;
38
+ /** Whether a scan was added or forgotten since the last {@link markSaved}. */
39
+ get changed(): boolean;
40
+ markSaved(): void;
41
+ }
42
+ /**
43
+ * Reads a history file through `cache`. An unchanged file answers from the cache without being
44
+ * opened, and a file that only grew is read from its last newline on; any other change rereads it.
45
+ * A last line without its newline is folded into the answer but not the cache, since its writer may
46
+ * still be appending it: the next read starts from that line again.
47
+ */
48
+ export declare function readHistory<Scan>(path: string, info: Stats, parser: HistoryParser<Scan>, cache: UsageScanCache<Scan> | undefined, signal: AbortSignal | undefined): Promise<Scan>;
49
+ /** Reads a cache document written by {@link writeCacheDocument}; a missing, torn or outdated one reads as `undefined`. */
50
+ export declare function readCacheDocument<Document>(path: string, validator: {
51
+ Check(value: unknown): value is Document;
52
+ }): Promise<Document | undefined>;
53
+ /** Replaces the cache document whole, so a reader never sees half of one. Resolves whether the write landed. */
54
+ export declare function writeCacheDocument<Document>(path: string, document: Document): Promise<boolean>;
@@ -0,0 +1,14 @@
1
+ import {
2
+ fileScanSchema2,
3
+ UsageScanCache2,
4
+ readHistory2,
5
+ readCacheDocument2,
6
+ writeCacheDocument2
7
+ } from "../chunks/canvas-preview-kp75gb63.js";
8
+ export {
9
+ UsageScanCache2 as UsageScanCache,
10
+ fileScanSchema2 as fileScanSchema,
11
+ readCacheDocument2 as readCacheDocument,
12
+ readHistory2 as readHistory,
13
+ writeCacheDocument2 as writeCacheDocument
14
+ };
@@ -13,7 +13,8 @@ export interface UsageScanReader {
13
13
  export declare function catalogForUsage(models: Pick<Models, "getModels">): readonly Model<Api>[];
14
14
  export declare class UsageScanner implements UsageScanReader {
15
15
  private readonly home;
16
- private readonly caches;
16
+ private readonly cachePath;
17
+ private caches;
17
18
  private readonly models;
18
19
  private readonly scans;
19
20
  constructor(home: string);
@@ -1,10 +1,14 @@
1
1
  import {
2
2
  catalogForUsage2,
3
3
  UsageScanner2
4
- } from "../chunks/canvas-preview-1ta3avah.js";
5
- import"../chunks/canvas-preview-0nrnbt76.js";
6
- import"../chunks/canvas-preview-5hxat7hh.js";
4
+ } from "../chunks/canvas-preview-fxa0rfb0.js";
5
+ import"../chunks/canvas-preview-k1yg4fgp.js";
6
+ import"../chunks/canvas-preview-11nadadc.js";
7
+ import"../chunks/canvas-preview-kp75gb63.js";
7
8
  import"../chunks/canvas-preview-srgfpdmf.js";
9
+ import"../chunks/canvas-preview-tnqe7k0b.js";
10
+ import"../chunks/canvas-preview-zaaj99wd.js";
11
+ import"../chunks/canvas-preview-0cmbkp2j.js";
8
12
  import"../chunks/canvas-preview-69fkk9yn.js";
9
13
  export {
10
14
  UsageScanner2 as UsageScanner,