@nyte-ai/host 0.0.0-stage → 0.0.18

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 (235) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +6 -2
  3. package/THIRD-PARTY-NOTICES.md +800 -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-0nrnbt76.js +497 -0
  7. package/dist/chunks/canvas-preview-1sq7z9jq.js +17 -0
  8. package/dist/chunks/canvas-preview-1ta3avah.js +56 -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-5hxat7hh.js +239 -0
  15. package/dist/chunks/canvas-preview-5mex725c.js +14 -0
  16. package/dist/chunks/canvas-preview-5z63am63.js +295 -0
  17. package/dist/chunks/canvas-preview-65xqjw7f.js +20 -0
  18. package/dist/chunks/canvas-preview-69fkk9yn.js +95 -0
  19. package/dist/chunks/canvas-preview-75db60xy.js +457 -0
  20. package/dist/chunks/canvas-preview-76fwvd6e.js +272 -0
  21. package/dist/chunks/canvas-preview-8xgt67ka.js +598 -0
  22. package/dist/chunks/canvas-preview-98aj5p34.js +176 -0
  23. package/dist/chunks/canvas-preview-9aqczacs.js +73 -0
  24. package/dist/chunks/canvas-preview-a3yw0j70.js +72 -0
  25. package/dist/chunks/canvas-preview-azg56359.js +68 -0
  26. package/dist/chunks/canvas-preview-d9wwhbtz.js +240 -0
  27. package/dist/chunks/canvas-preview-ehf3vp31.js +411 -0
  28. package/dist/chunks/canvas-preview-evh92ywd.js +369 -0
  29. package/dist/chunks/canvas-preview-ewgspmsd.js +81 -0
  30. package/dist/chunks/canvas-preview-g3qj3y3k.js +156 -0
  31. package/dist/chunks/canvas-preview-h8hshnff.js +63 -0
  32. package/dist/chunks/canvas-preview-j1tnf51w.js +36 -0
  33. package/dist/chunks/canvas-preview-kdqgrstc.js +194 -0
  34. package/dist/chunks/canvas-preview-kn7kvbfj.js +12 -0
  35. package/dist/chunks/canvas-preview-m02v4yy6.js +386 -0
  36. package/dist/chunks/canvas-preview-mgcx2b2p.js +271 -0
  37. package/dist/chunks/canvas-preview-rp4x6y1h.js +144 -0
  38. package/dist/chunks/canvas-preview-rp6fz0w5.js +130 -0
  39. package/dist/chunks/canvas-preview-s94ebwf5.js +112 -0
  40. package/dist/chunks/canvas-preview-senpjwep.js +518 -0
  41. package/dist/chunks/canvas-preview-skzwvw4d.js +23 -0
  42. package/dist/chunks/canvas-preview-srgfpdmf.js +60 -0
  43. package/dist/chunks/canvas-preview-tjhabynd.js +252 -0
  44. package/dist/chunks/canvas-preview-vaatfznm.js +189 -0
  45. package/dist/chunks/canvas-preview-vax9ne4e.js +341 -0
  46. package/dist/chunks/canvas-preview-wg80rbc2.js +46 -0
  47. package/dist/chunks/canvas-preview-xn10d4f8.js +608 -0
  48. package/dist/chunks/canvas-preview-yjz0f7n4.js +50 -0
  49. package/dist/chunks/canvas-preview-ymgz0937.js +587 -0
  50. package/dist/chunks/canvas-preview-yrfz2ak6.js +134 -0
  51. package/dist/chunks/canvas-preview-zaaj99wd.js +244 -0
  52. package/dist/chunks/canvas-preview-zn2d0k9d.js +133 -0
  53. package/dist/src/canvas-preview.d.ts +29 -0
  54. package/dist/src/canvas-preview.js +267 -0
  55. package/dist/src/credentials.d.ts +44 -0
  56. package/dist/src/credentials.js +10 -0
  57. package/dist/src/deploy/cloudflare/worker.d.ts +50 -0
  58. package/dist/src/deploy/cloudflare/worker.js +196 -0
  59. package/dist/src/deploy/vercel/nitro.config.d.ts +2 -0
  60. package/dist/src/deploy/vercel/nitro.config.js +30 -0
  61. package/dist/src/deploy/vercel/server/routes/[...].d.ts +2 -0
  62. package/dist/src/deploy/vercel/server/routes/[...].js +18 -0
  63. package/dist/src/deploy/vercel/server/utils/host.d.ts +13 -0
  64. package/dist/src/deploy/vercel/server/utils/host.js +7 -0
  65. package/dist/src/deploy/vercel/server/utils/repair.d.ts +1 -0
  66. package/dist/src/deploy/vercel/server/utils/repair.js +6 -0
  67. package/dist/src/deploy/vercel/server/utils/step.d.ts +10 -0
  68. package/dist/src/deploy/vercel/server/utils/step.js +6 -0
  69. package/dist/src/deploy/vercel/server/workflows/drive.d.ts +14 -0
  70. package/dist/src/deploy/vercel/server/workflows/drive.js +13 -0
  71. package/dist/src/durable-object.d.ts +14 -0
  72. package/dist/src/durable-object.js +231 -0
  73. package/dist/src/hash.d.ts +1 -0
  74. package/dist/src/hash.js +6 -0
  75. package/dist/src/identity-key.d.ts +11 -0
  76. package/dist/src/identity-key.js +9 -0
  77. package/dist/src/identity.d.ts +12 -0
  78. package/dist/src/identity.js +6 -0
  79. package/dist/src/index.d.ts +21 -0
  80. package/dist/src/index.js +120 -0
  81. package/dist/src/key-file.d.ts +1 -0
  82. package/dist/src/key-file.js +7 -0
  83. package/dist/src/listen-fetch.d.ts +8 -0
  84. package/dist/src/listen-fetch.js +9 -0
  85. package/dist/src/listen.d.ts +4 -0
  86. package/dist/src/listen.js +10 -0
  87. package/dist/src/local/command.d.ts +15 -0
  88. package/dist/src/local/command.js +8 -0
  89. package/dist/src/local/feed.d.ts +7 -0
  90. package/dist/src/local/feed.js +6 -0
  91. package/dist/src/local/files.d.ts +18 -0
  92. package/dist/src/local/files.js +13 -0
  93. package/dist/src/local/git-watch.d.ts +15 -0
  94. package/dist/src/local/git-watch.js +7 -0
  95. package/dist/src/local/git.d.ts +5 -0
  96. package/dist/src/local/git.js +13 -0
  97. package/dist/src/local/github.d.ts +30 -0
  98. package/dist/src/local/github.js +9 -0
  99. package/dist/src/local/identity.d.ts +3 -0
  100. package/dist/src/local/identity.js +7 -0
  101. package/dist/src/local/jobs.d.ts +7 -0
  102. package/dist/src/local/jobs.js +6 -0
  103. package/dist/src/local/legacy-trust.d.ts +10 -0
  104. package/dist/src/local/legacy-trust.js +6 -0
  105. package/dist/src/local/patch.d.ts +16 -0
  106. package/dist/src/local/patch.js +17 -0
  107. package/dist/src/local/provider.d.ts +11 -0
  108. package/dist/src/local/provider.js +20 -0
  109. package/dist/src/local/snapshots.d.ts +7 -0
  110. package/dist/src/local/snapshots.js +11 -0
  111. package/dist/src/local/text.d.ts +1 -0
  112. package/dist/src/local/text.js +6 -0
  113. package/dist/src/local/tree.d.ts +50 -0
  114. package/dist/src/local/tree.js +16 -0
  115. package/dist/src/local/workspace-migration.d.ts +2 -0
  116. package/dist/src/local/workspace-migration.js +7 -0
  117. package/dist/src/local/worktrees.d.ts +46 -0
  118. package/dist/src/local/worktrees.js +14 -0
  119. package/dist/src/mcp/config.d.ts +75 -0
  120. package/dist/src/mcp/config.js +12 -0
  121. package/dist/src/mcp/connect.d.ts +28 -0
  122. package/dist/src/mcp/connect.js +9 -0
  123. package/dist/src/mcp/hub.d.ts +19 -0
  124. package/dist/src/mcp/hub.js +11 -0
  125. package/dist/src/mcp/oauth.d.ts +46 -0
  126. package/dist/src/mcp/oauth.js +12 -0
  127. package/dist/src/mcp/tools.d.ts +29 -0
  128. package/dist/src/mcp/tools.js +12 -0
  129. package/dist/src/open.d.ts +42 -0
  130. package/dist/src/open.js +44 -0
  131. package/dist/src/plugins/loader.d.ts +21 -0
  132. package/dist/src/plugins/loader.js +11 -0
  133. package/dist/src/postgres.d.ts +19 -0
  134. package/dist/src/postgres.js +8 -0
  135. package/dist/src/providers.d.ts +16 -0
  136. package/dist/src/providers.js +112 -0
  137. package/dist/src/secrets.d.ts +12 -0
  138. package/dist/src/secrets.js +8 -0
  139. package/dist/src/serve/binding.d.ts +39 -0
  140. package/dist/src/serve/binding.js +6 -0
  141. package/dist/src/serve/handler.d.ts +15 -0
  142. package/dist/src/serve/handler.js +8 -0
  143. package/dist/src/serve/stream-server.d.ts +6 -0
  144. package/dist/src/serve/stream-server.js +6 -0
  145. package/dist/src/session-index.d.ts +11 -0
  146. package/dist/src/session-index.js +11 -0
  147. package/dist/src/shell-env.d.ts +14 -0
  148. package/dist/src/shell-env.js +108 -0
  149. package/dist/src/sqlite-workers.d.ts +6 -0
  150. package/dist/src/sqlite-workers.js +6 -0
  151. package/dist/src/sqlite.d.ts +7 -0
  152. package/dist/src/sqlite.js +10 -0
  153. package/dist/src/store-owner.d.ts +15 -0
  154. package/dist/src/store-owner.js +9 -0
  155. package/dist/src/store-rows.d.ts +13 -0
  156. package/dist/src/store-rows.js +26 -0
  157. package/dist/src/store-usage.d.ts +25 -0
  158. package/dist/src/store-usage.js +16 -0
  159. package/dist/src/usage-scan.d.ts +24 -0
  160. package/dist/src/usage-scan.js +65 -0
  161. package/dist/src/usage-service.d.ts +22 -0
  162. package/dist/src/usage-service.js +12 -0
  163. package/dist/src/usage-summary.d.ts +9 -0
  164. package/dist/src/usage-summary.js +16 -0
  165. package/dist/src/usage-types.d.ts +86 -0
  166. package/dist/src/usage-types.js +0 -0
  167. package/dist/src/usage-worker.d.ts +1 -0
  168. package/dist/src/usage-worker.js +25 -0
  169. package/dist/src/usage.d.ts +72 -0
  170. package/dist/src/usage.js +13 -0
  171. package/package.json +132 -3
  172. package/src/canvas-preview.ts +402 -0
  173. package/src/credentials.ts +294 -0
  174. package/src/deploy/cloudflare/README.md +3 -0
  175. package/src/deploy/cloudflare/worker.ts +306 -0
  176. package/src/deploy/cloudflare/wrangler.jsonc +12 -0
  177. package/src/deploy/vercel/README.md +3 -0
  178. package/src/deploy/vercel/nitro.config.ts +29 -0
  179. package/src/deploy/vercel/server/routes/[...].ts +10 -0
  180. package/src/deploy/vercel/server/utils/host.ts +104 -0
  181. package/src/deploy/vercel/server/utils/repair.ts +35 -0
  182. package/src/deploy/vercel/server/utils/step.ts +25 -0
  183. package/src/deploy/vercel/server/workflows/drive.ts +46 -0
  184. package/src/deploy/vercel/tsconfig.json +9 -0
  185. package/src/deploy/vercel/types/bun.d.ts +2 -0
  186. package/src/durable-object.ts +386 -0
  187. package/src/hash.ts +5 -0
  188. package/src/identity-key.ts +20 -0
  189. package/src/identity.ts +66 -0
  190. package/src/index.ts +21 -0
  191. package/src/key-file.ts +53 -0
  192. package/src/listen-fetch.ts +409 -0
  193. package/src/listen.ts +228 -0
  194. package/src/local/command.ts +109 -0
  195. package/src/local/feed.ts +70 -0
  196. package/src/local/files.ts +812 -0
  197. package/src/local/git-watch.ts +189 -0
  198. package/src/local/git.ts +914 -0
  199. package/src/local/github.ts +692 -0
  200. package/src/local/identity.ts +21 -0
  201. package/src/local/jobs.ts +587 -0
  202. package/src/local/legacy-trust.ts +105 -0
  203. package/src/local/patch.ts +334 -0
  204. package/src/local/provider.ts +184 -0
  205. package/src/local/snapshots.ts +776 -0
  206. package/src/local/text.ts +9 -0
  207. package/src/local/tree.ts +398 -0
  208. package/src/local/workspace-migration.ts +95 -0
  209. package/src/local/worktrees.ts +239 -0
  210. package/src/mcp/config.ts +330 -0
  211. package/src/mcp/connect.ts +105 -0
  212. package/src/mcp/hub.ts +836 -0
  213. package/src/mcp/oauth.ts +436 -0
  214. package/src/mcp/tools.ts +333 -0
  215. package/src/open.ts +469 -0
  216. package/src/plugins/loader.ts +186 -0
  217. package/src/postgres.ts +492 -0
  218. package/src/providers.ts +135 -0
  219. package/src/secrets.ts +31 -0
  220. package/src/serve/binding.ts +628 -0
  221. package/src/serve/handler.ts +362 -0
  222. package/src/serve/stream-server.ts +176 -0
  223. package/src/session-index.ts +99 -0
  224. package/src/shell-env.ts +153 -0
  225. package/src/sqlite-workers.ts +283 -0
  226. package/src/sqlite.ts +528 -0
  227. package/src/store-owner.ts +98 -0
  228. package/src/store-rows.ts +110 -0
  229. package/src/store-usage.ts +344 -0
  230. package/src/usage-scan.ts +81 -0
  231. package/src/usage-service.ts +73 -0
  232. package/src/usage-summary.ts +79 -0
  233. package/src/usage-types.ts +87 -0
  234. package/src/usage-worker.ts +24 -0
  235. package/src/usage.ts +701 -0
@@ -0,0 +1,5 @@
1
+ import type { ExecutionEnv, GitApi } from "@nyte-ai/core";
2
+ /** Returns git over the CLI (`git`, default `git` on the PATH) for the repository holding `env.cwd`; every path it takes and answers is relative to the workspace (`env.cwd`), as `FilesApi`'s and the snapshots' are (§41j): the commands run at the repository root, and where the workspace is a subdirectory of the repository its prefix is added to every path going into git (`stage`, `unstage`, `discard` and `commit` files, `patches`, `contents` and `blame` paths) and stripped from every path coming out (`status`, `changes`, `patches`), the listings limited to it by pathspec (a rename source outside it reads `../…`); `root` stays the repository root, and `log`, `refs`, `branch`, `push` and `commit` of `staged` or `all` are repository-wide. `status` reads `git status --porcelain=v2 --branch -z --untracked-files=all` (`none` outside a repository, `head` null when unborn) with the staged and unstaged line stats (`git diff --numstat`), its `revision` the SHA-256 of those outputs with HEAD and each dirty worktree file's size and modification time, so an edit to an already-modified file moves it; `watch` yields the status whenever that revision moves, re-reading only on fs events that can move it (`createWatcher`: worktree paths git does not ignore and the git directory's HEAD, index and refs, coalesced over 250 ms; a 2 s poll only where `fs.watch` is unavailable). The repository (`git rev-parse`) is looked up once and kept while its git directory holds a HEAD. `changes(scope)` reads statuses with `git diff --name-status -z -M` and line stats with `--numstat` (`--ignore-all-space` under `ignoreWhitespace`, for the stats and patches only, so a whitespace-only change stays listed; `worktree` HEAD to the worktree, `staged` HEAD to the index, `unstaged` the index to the worktree, `commit` its parent (or the empty tree) to it, `branch` the merge base with HEAD to HEAD; HEAD of an unborn repository is the empty tree), untracked files joining `worktree` and `unstaged` with status `untracked` and their line count as added; its `revision` the status revision; `watchChanges` re-reads it as that revision moves. `patches` reads `git diff -U3` for the requested paths the scope reports (paths it does not report are left out), at most 32 per command, one `PatchEntry` per path, a text one carrying the path's section of the unified text as its `patch` (`binary`; `empty` when the scope reports the path but the diff shows no text, as under `ignoreWhitespace`; `too-large` past 1 MiB; `failed` alone when one path's read fails), `digest` the SHA-256 of the path's section; an untracked file is diffed against nothing on the host (its digest that of its patch), `failed` when it is gone or cannot be read. It yields one full `PatchSet` per revision as it moves. `contents` reads both sides (`git cat-file blob <rev>:<path>`, the index, the worktree file, or absent; a rename's old side at its old path; text, `truncated { head }` past 1 MiB, or binary). `log` pages `git log` with the cursor holding the next skip (default 50 a page); `refs` reads `git symbolic-ref`, `git for-each-ref refs/heads` and `git remote`; `blame` reads `git blame --porcelain` of the worktree file. Every write answers `busy { runs: [] }` while `index.lock` exists for the writes that take it (all but `push` and `branch` without checkout; the run-based busy is core's), then compares `expect` with the current status revision (`stale { revision }`): `stage` (`git add -A`), `unstage` (`git restore --staged`, `git rm --cached` when unborn), `discard` (`git restore --worktree`, untracked paths removed with `git clean -f`), `commit` (`staged`, `all` as `-a`, or the listed paths added and committed alone), `branch` (`git switch -c` when `checkout`, else `git branch`), `push` (`--porcelain`, `--set-upstream origin <branch>` when asked; a detached HEAD cannot set one); each answers `applied { revision }`, `unchanged` (`stage`, `unstage`, `discard` and `commit` when the revision did not move or git had nothing to commit, `push` when every ref was already up to date; `branch` always applies), or `rejected { reason }` with git's message. Reads outside a repository throw `SdkError("unavailable")`. */
3
+ export declare function localGit(env: ExecutionEnv, options?: {
4
+ readonly git?: string;
5
+ }): GitApi;
@@ -0,0 +1,13 @@
1
+ import {
2
+ localGit2
3
+ } from "../../chunks/canvas-preview-xn10d4f8.js";
4
+ import"../../chunks/canvas-preview-tjhabynd.js";
5
+ import"../../chunks/canvas-preview-kn7kvbfj.js";
6
+ import"../../chunks/canvas-preview-azg56359.js";
7
+ import"../../chunks/canvas-preview-yjz0f7n4.js";
8
+ import"../../chunks/canvas-preview-zn2d0k9d.js";
9
+ import"../../chunks/canvas-preview-0nq75h9k.js";
10
+ import"../../chunks/canvas-preview-mgcx2b2p.js";
11
+ export {
12
+ localGit2 as localGit
13
+ };
@@ -0,0 +1,30 @@
1
+ import type { ExecutionEnv, GitHubAccountApi, GitHubApi } from "@nyte-ai/core";
2
+ /**
3
+ * Returns the machine's GitHub CLI login through `gh` (`gh`, default `gh` on
4
+ * the PATH), run in `home` (default `os.homedir()`). Nothing runs until it is
5
+ * asked for. `account` reads the github.com account (`gh auth status`, then
6
+ * `gh api user`); while a sign-in runs, it answers its code until it ends,
7
+ * then what the login became. `signIn` starts at most one `gh auth login`
8
+ * for the whole machine and `signOut` cancels it or runs `gh auth logout`.
9
+ */
10
+ export declare function localGitHubAccount(options?: {
11
+ readonly gh?: string;
12
+ readonly home?: string;
13
+ }): GitHubAccountApi;
14
+ /**
15
+ * Returns GitHub for each local workspace through the machine's `gh` (`gh`,
16
+ * default `gh` on the PATH) and `git`. Nothing runs until a state is asked
17
+ * for. `state` reads the repository from the remotes in gh's
18
+ * base-repository order (`upstream`, `github`, `origin`, then the rest; only
19
+ * github.com remotes) and, while gh has a login, the checked-out branch's
20
+ * pull request with its check rollup (`gh pr view <branch> --json`, the
21
+ * branch as `<owner>:<branch>` when it tracks a fork); without one the pull
22
+ * request is `unavailable`. `createPullRequest` answers each precondition, an
23
+ * open pull request as `exists`, and otherwise runs
24
+ * `gh pr create --head <branch>` with the title as an argument, the body on
25
+ * stdin, and `--fill` for whichever of the two is missing.
26
+ */
27
+ export declare function localGitHub(options?: {
28
+ readonly gh?: string;
29
+ readonly git?: string;
30
+ }): (env: ExecutionEnv) => GitHubApi;
@@ -0,0 +1,9 @@
1
+ import {
2
+ localGitHubAccount2,
3
+ localGitHub2
4
+ } from "../../chunks/canvas-preview-75db60xy.js";
5
+ import"../../chunks/canvas-preview-azg56359.js";
6
+ export {
7
+ localGitHub2 as localGitHub,
8
+ localGitHubAccount2 as localGitHubAccount
9
+ };
@@ -0,0 +1,3 @@
1
+ import type { EnvironmentIdentity } from "@nyte-ai/schema";
2
+ /** Returns a folder's identity from its inode and nanosecond creation time, independent of boot-assigned device numbers and its path. A rename keeps it; a replacement folder gets another identity. Without an inode or creation time, hashes the real path. An unresolved path hashes its absolute form so inspection can report it unavailable. */
3
+ export declare function folderIdentity(path: string): Promise<EnvironmentIdentity>;
@@ -0,0 +1,7 @@
1
+ import {
2
+ folderIdentity2
3
+ } from "../../chunks/canvas-preview-1sq7z9jq.js";
4
+ import"../../chunks/canvas-preview-0nq75h9k.js";
5
+ export {
6
+ folderIdentity2 as folderIdentity
7
+ };
@@ -0,0 +1,7 @@
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). */
3
+ export declare function localExec(root: string, options?: {
4
+ readonly shell?: () => string | null;
5
+ readonly signal?: AbortSignal;
6
+ readonly loadPty?: () => unknown;
7
+ }): ExecutionEnv["exec"];
@@ -0,0 +1,6 @@
1
+ import {
2
+ localExec2
3
+ } from "../../chunks/canvas-preview-ehf3vp31.js";
4
+ export {
5
+ localExec2 as localExec
6
+ };
@@ -0,0 +1,10 @@
1
+ import type { StoreConnection } from "@nyte-ai/core";
2
+ /**
3
+ * Carries the folders an older Nyte, or uji before it, was told to trust into
4
+ * the store, once per store: the grants in `~/.nyte/workspaces.json`,
5
+ * `~/.nyte/trust.json` and `~/.uji/trust.json` become folder trust decisions
6
+ * where the store saved none. A folder that is gone, the home folder and the
7
+ * folders above it are skipped: home holds the user's own files, and a grant
8
+ * there trusted every project under it. The files are left as they are.
9
+ */
10
+ export declare function importLegacyTrust(connection: StoreConnection, home: string): Promise<void>;
@@ -0,0 +1,6 @@
1
+ import {
2
+ importLegacyTrust2
3
+ } from "../../chunks/canvas-preview-9aqczacs.js";
4
+ export {
5
+ importLegacyTrust2 as importLegacyTrust
6
+ };
@@ -0,0 +1,16 @@
1
+ import type { FileStatus, LineStat, PatchEntry } from "@nyte-ai/schema";
2
+ import type { Ran } from "./command.ts";
3
+ export declare const PATCH_LIMIT: number;
4
+ export type Changed = {
5
+ readonly path: string;
6
+ readonly status: FileStatus;
7
+ readonly from?: string;
8
+ };
9
+ /** The entry for two texts diffed on the host: a text entry's digest is its patch's, so it moves with the whitespace mode; an empty one digests both sides and the mode. */
10
+ export declare function textEntry(path: string, status: FileStatus, before: string | null, after: string | null, options?: {
11
+ readonly ignoreWhitespace?: boolean;
12
+ }): PatchEntry;
13
+ export declare function readPatches(files: readonly Changed[], read: (files: readonly Changed[], limit: number) => Promise<Ran>, emptyDigest: (file: Changed) => string): Promise<readonly PatchEntry[]>;
14
+ export declare function lineStat(before: string, after: string): LineStat;
15
+ export declare function parseNumstat(output: string): ReadonlyMap<string, LineStat>;
16
+ export declare function parseNameStatus(output: string): readonly Changed[];
@@ -0,0 +1,17 @@
1
+ import {
2
+ PATCH_LIMIT2,
3
+ textEntry2,
4
+ readPatches2,
5
+ lineStat2,
6
+ parseNumstat2,
7
+ parseNameStatus2
8
+ } from "../../chunks/canvas-preview-tjhabynd.js";
9
+ import"../../chunks/canvas-preview-0nq75h9k.js";
10
+ export {
11
+ PATCH_LIMIT2 as PATCH_LIMIT,
12
+ lineStat2 as lineStat,
13
+ parseNameStatus2 as parseNameStatus,
14
+ parseNumstat2 as parseNumstat,
15
+ readPatches2 as readPatches,
16
+ textEntry2 as textEntry
17
+ };
@@ -0,0 +1,11 @@
1
+ import type { EnvironmentProvider } from "@nyte-ai/core";
2
+ /** Returns the local environment provider (`kind: "local"`): a folder on this machine. `inspect` answers a `{ kind: "local", path }` target's `folderIdentity` (§41d), `available` when the path is a readable directory (else `unavailable { unreachable }`; a target without a path `unavailable { unsupported }`, identified by the hash of its locator), and the project sources present under it, relative to it, in this order: the plugin files `.nyte/plugins/<name>.{ts,mts,js,mjs}` and `.nyte/plugins/<name>/index.<ext>`, the skills `.nyte/skills/<name>/SKILL.md` and `.agents/skills/<name>/SKILL.md`, the prompts `.nyte/prompts/<name>.md`, then `.nyte/SYSTEM.md`, `.nyte/APPEND_SYSTEM.md` and `.nyte/mcp.json`: the files project trust gates. Context files such as `AGENTS.md` load without trust and are not listed. `attach` resolves the real path (a target that is not a directory throws `SdkError("unavailable")`) and returns an `ExecutionEnv` with that identity, `cwd` the real path, `files` from `localFiles` (with `ripgrep` and `formatter`), `exec` from `localExec`, and a `close` that ends its file watches and the jobs' readers, leaving running jobs alone. `git` is `localGit` (with `git`), `github` is `localGitHub` (with `gh` and `git`; the login is the machine's, `localGitHubAccount`), `snapshots` is `localSnapshots` storing tree walks under `<home>/.nyte/snapshots` (`home` default `os.homedir()`), and absent for a folder that contains `<home>/.nyte` or lies inside it outside `<home>/.nyte/worktrees` (the home folder itself, its ancestors, Nyte's own state): there a snapshot would walk or stage everything under home, the store and secrets included, to report changes in the store it just wrote; `worktrees` is `localWorktrees` (with `home` and `git`); no `browser` (the desktop wraps one in); `destroy` rejects with `SdkError("unavailable")`: a local folder is never torn down. */
3
+ export declare function localProvider(options?: {
4
+ readonly home?: string;
5
+ readonly git?: string;
6
+ readonly gh?: string;
7
+ readonly ripgrep?: string;
8
+ readonly formatter?: string;
9
+ /** The login shell a pty job without a command runs, read at each start; null or absent is `$SHELL`. */
10
+ readonly shell?: () => string | null;
11
+ }): EnvironmentProvider;
@@ -0,0 +1,20 @@
1
+ import {
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";
7
+ import"../../chunks/canvas-preview-1sq7z9jq.js";
8
+ import"../../chunks/canvas-preview-ehf3vp31.js";
9
+ import"../../chunks/canvas-preview-senpjwep.js";
10
+ import"../../chunks/canvas-preview-tjhabynd.js";
11
+ import"../../chunks/canvas-preview-ymgz0937.js";
12
+ import"../../chunks/canvas-preview-kn7kvbfj.js";
13
+ import"../../chunks/canvas-preview-azg56359.js";
14
+ import"../../chunks/canvas-preview-yjz0f7n4.js";
15
+ import"../../chunks/canvas-preview-zn2d0k9d.js";
16
+ import"../../chunks/canvas-preview-0nq75h9k.js";
17
+ import"../../chunks/canvas-preview-mgcx2b2p.js";
18
+ export {
19
+ localProvider2 as localProvider
20
+ };
@@ -0,0 +1,7 @@
1
+ import type { ExecutionEnv, SnapshotsApi } from "@nyte-ai/core";
2
+ /** Returns content-addressed snapshots of an environment's tree, so equal trees are equal ids whichever run took them. `before(run)` is taken once per run in this process and answered again after; `after(run)` is taken on every call. In a repository (`git`, default `git` on the PATH), a snapshot writes the environment's part of the worktree, tracked and untracked files that are not ignored, into a temporary index seeded from the real one (`GIT_INDEX_FILE`, `git add -A`, `git write-tree --prefix` for a workspace below the root; the real index is never touched) and keeps the tree reachable for good from the hidden ref `refs/nyte/kept`, a tree of generation trees `g000000`, `g000001`, ... that each hold up to 1,000 snapshot trees named by their hash (only the newest generation and the root are rewritten, in the background after a snapshot of a tree this process has not kept, so a snapshot costs two git spawns: `add` and `write-tree`; the per-tree refs `refs/nyte/snapshots/<tree>` of earlier versions all fold into it and go); the id is `git:<tree>`. The repository is looked up once. Without a repository it walks the tree as `localFiles.scan` does (up to `limit` entries, default 50 000), stores each file's bytes up to 1 MiB once under `<store>/objects/<sha256>` (a larger file is hashed, not stored; a file whose size, mtime and inode did not move is not re-read) and the tree, `{ incomplete, files }` (whether the walk stopped short, at its limit or at an unreadable directory, and the manifest of paths to content hashes), under `<store>/trees/<sha256 of it>.json`; the id is `tree:<hash>`. `diff(from, to)` answers the `ChangeSet` between two snapshots of one kind (empty, without running git, when they are equal; `git diff-tree -r -M --name-status`/`--numstat`, or the two manifests compared, an exact-content move a rename; the empty id `""` is the empty tree), its `revision` `to`; a path only an incomplete side lacks is neither added nor deleted but `modified` with an `unknown` stat; `patches(from, to, paths, options)` answers one `PatchEntry` per path the comparison reports, a text one carrying its unified diff as `localGit`'s do (`git diff` between the trees, read as `localGit.patches` reads: a path past 1 MiB `too-large`, one whose read fails `failed`, the others fine), or, between manifests, from the stored contents with the line diff, a text entry's digest its patch's so it moves with `ignoreWhitespace` (`too-large` for a file not stored, `binary` for one not text, `failed { reason: "incomplete" }` for a path only an incomplete side lacks). Snapshots of two kinds do not compare: `SdkError("invalid")`. */
3
+ export declare function localSnapshots(env: ExecutionEnv, options: {
4
+ readonly store: string;
5
+ readonly git?: string;
6
+ readonly limit?: number;
7
+ }): SnapshotsApi;
@@ -0,0 +1,11 @@
1
+ import {
2
+ localSnapshots2
3
+ } from "../../chunks/canvas-preview-senpjwep.js";
4
+ import"../../chunks/canvas-preview-tjhabynd.js";
5
+ import"../../chunks/canvas-preview-kn7kvbfj.js";
6
+ import"../../chunks/canvas-preview-azg56359.js";
7
+ import"../../chunks/canvas-preview-0nq75h9k.js";
8
+ import"../../chunks/canvas-preview-mgcx2b2p.js";
9
+ export {
10
+ localSnapshots2 as localSnapshots
11
+ };
@@ -0,0 +1 @@
1
+ export declare function decodeText(bytes: Uint8Array): string | null;
@@ -0,0 +1,6 @@
1
+ import {
2
+ decodeText2
3
+ } from "../../chunks/canvas-preview-kn7kvbfj.js";
4
+ export {
5
+ decodeText2 as decodeText
6
+ };
@@ -0,0 +1,50 @@
1
+ import type { Disposer } from "@nyte-ai/schema";
2
+ type TreeEntry = {
3
+ readonly path: string;
4
+ readonly kind: "file" | "directory" | "symlink";
5
+ readonly size: number | null;
6
+ };
7
+ export type WalkFrame = {
8
+ readonly kind: "entries";
9
+ readonly entries: readonly TreeEntry[];
10
+ } | {
11
+ readonly kind: "complete";
12
+ } | {
13
+ readonly kind: "incomplete";
14
+ readonly reason: "limit" | "permission";
15
+ };
16
+ export type Ignores = {
17
+ matches(path: string, directory: boolean): Promise<boolean>;
18
+ ignored(path: string, directory: boolean): Promise<boolean>;
19
+ forget(directory: string): void;
20
+ };
21
+ export declare const WALK_LIMIT = 50000;
22
+ export declare function createIgnores(root: string): Ignores;
23
+ export declare function walkTree(root: string, options: {
24
+ readonly directory?: string;
25
+ readonly ignored: "exclude" | "include";
26
+ readonly ignores?: Ignores;
27
+ readonly limit?: number;
28
+ readonly page?: number;
29
+ }): AsyncGenerator<WalkFrame>;
30
+ /** Calls `changed` with the paths below `root` that moved, coalesced over `delay`, from a recursive `fs.watch`; where that is unavailable it walks the tree every `poll` ms when one is given, and calls `unwatched` once either way. */
31
+ export declare function watchTree(root: string, options: {
32
+ readonly delay: number;
33
+ readonly poll: number | null;
34
+ readonly unwatched?: () => void;
35
+ }, changed: (paths: ReadonlySet<string>) => void): Disposer;
36
+ /**
37
+ * Calls `changed` when what is at the absolute `target` moves, coalesced over
38
+ * `delay`: with `""` for the target itself (created, removed, replaced or, for
39
+ * a file, written) and the path below it for a change inside a directory,
40
+ * which is watched recursively. A file is watched itself and re-watched when
41
+ * it is replaced, a directory beside a watch on its parent for its own name;
42
+ * while the target is missing, the nearest directory above it that exists is
43
+ * watched for the next missing name, and the watch moves down as they appear.
44
+ * Nothing polls.
45
+ */
46
+ export declare function watchPath(target: string, options: {
47
+ readonly delay: number;
48
+ }, changed: (paths: ReadonlySet<string>) => void): Disposer;
49
+ export declare function readErrorCode(error: unknown): string | null;
50
+ export {};
@@ -0,0 +1,16 @@
1
+ import {
2
+ WALK_LIMIT2,
3
+ createIgnores2,
4
+ walkTree2,
5
+ watchTree2,
6
+ watchPath2,
7
+ readErrorCode2
8
+ } from "../../chunks/canvas-preview-mgcx2b2p.js";
9
+ export {
10
+ WALK_LIMIT2 as WALK_LIMIT,
11
+ createIgnores2 as createIgnores,
12
+ readErrorCode2 as readErrorCode,
13
+ walkTree2 as walkTree,
14
+ watchPath2 as watchPath,
15
+ watchTree2 as watchTree
16
+ };
@@ -0,0 +1,2 @@
1
+ import type { StoreConnection } from "@nyte-ai/core";
2
+ export declare function migrateLocalWorkspaceIdentities(connection: StoreConnection): Promise<void>;
@@ -0,0 +1,7 @@
1
+ import {
2
+ migrateLocalWorkspaceIdentities2
3
+ } from "../../chunks/canvas-preview-4e0pxa32.js";
4
+ import"../../chunks/canvas-preview-0nq75h9k.js";
5
+ export {
6
+ migrateLocalWorkspaceIdentities2 as migrateLocalWorkspaceIdentities
7
+ };
@@ -0,0 +1,46 @@
1
+ import type { WorktreeProvider } from "@nyte-ai/core";
2
+ /** One checkout of a repository: its folder and the branch it has out, null when HEAD is detached. */
3
+ export interface ListedWorktree {
4
+ readonly path: string;
5
+ readonly branch: string | null;
6
+ }
7
+ /** Lists every worktree of the repository holding `cwd` (`git worktree list --porcelain -z`), the main checkout first. */
8
+ export declare function listWorktrees(cwd: string, options?: {
9
+ readonly git?: string;
10
+ }): Promise<readonly ListedWorktree[]>;
11
+ /** Checks `branch` out in a new worktree at `path` (`git worktree add`), creating the branch at `from` when given. */
12
+ export declare function addWorktree(cwd: string, input: {
13
+ readonly path: string;
14
+ readonly branch: string;
15
+ readonly from?: string;
16
+ }, options?: {
17
+ readonly git?: string;
18
+ }): Promise<void>;
19
+ /** Whether `name` is a local branch of the repository holding `cwd`. */
20
+ export declare function hasBranch(cwd: string, name: string, options?: {
21
+ readonly git?: string;
22
+ }): Promise<boolean>;
23
+ /**
24
+ * Returns git worktrees for local workspaces (`git`, default `git` on the
25
+ * PATH), each under `<home>/.nyte/worktrees/<repository>/<slug>` on the branch
26
+ * `nyte/<slug>`, the slug the title's words and a hash of the name.
27
+ *
28
+ * `create` refuses a folder outside a repository or one without a commit, then
29
+ * answers the worktree already on that branch, or adds one from HEAD and
30
+ * copies the workspace's uncommitted changes in: the worktree's tracked and
31
+ * untracked files, ignored ones aside, are written to a tree through a
32
+ * temporary index seeded from the real one (which is never touched), and the
33
+ * new checkout moves to that tree with its index left at HEAD, so the changes
34
+ * show as uncommitted there too. A workspace below the repository's root gets
35
+ * the same folder below the worktree's.
36
+ *
37
+ * `remove` keeps a worktree, folder and branch, while it holds uncommitted
38
+ * changes or ignored files, since none were copied in and one may be a
39
+ * `.env` or a local database (a wholly ignored folder such as `node_modules`
40
+ * or a build's output aside); otherwise it removes the folder
41
+ * (`git worktree remove`) and deletes the branch unless it moved past `base`.
42
+ */
43
+ export declare function localWorktrees(options?: {
44
+ readonly home?: string;
45
+ readonly git?: string;
46
+ }): WorktreeProvider;
@@ -0,0 +1,14 @@
1
+ import {
2
+ listWorktrees2,
3
+ addWorktree2,
4
+ hasBranch2,
5
+ localWorktrees2
6
+ } from "../../chunks/canvas-preview-rp6fz0w5.js";
7
+ import"../../chunks/canvas-preview-azg56359.js";
8
+ import"../../chunks/canvas-preview-0nq75h9k.js";
9
+ export {
10
+ addWorktree2 as addWorktree,
11
+ hasBranch2 as hasBranch,
12
+ listWorktrees2 as listWorktrees,
13
+ localWorktrees2 as localWorktrees
14
+ };
@@ -0,0 +1,75 @@
1
+ import type { Json, McpChange, McpExposure, McpOAuthConfig, McpScope, ValidationIssue } from "@nyte-ai/schema";
2
+ type McpTransportConfig = {
3
+ readonly kind: "stdio";
4
+ readonly command: string;
5
+ readonly args: readonly string[];
6
+ readonly env: Readonly<Record<string, string>>;
7
+ readonly cwd: string | null;
8
+ } | {
9
+ readonly kind: "http";
10
+ readonly url: string;
11
+ readonly headers: Readonly<Record<string, string>>;
12
+ readonly oauth: McpOAuthConfig;
13
+ };
14
+ export type McpServerEntry = {
15
+ readonly name: string;
16
+ readonly scope: McpScope;
17
+ readonly path: string;
18
+ readonly override: string | null;
19
+ readonly transport: McpTransportConfig;
20
+ readonly enabled: boolean;
21
+ readonly timeoutMs: number;
22
+ readonly description: string | null;
23
+ readonly exposure: McpExposure;
24
+ /** Patterns in file order; `*` matches any characters. */
25
+ readonly toolExposure: readonly (readonly [pattern: string, exposure: McpExposure])[];
26
+ };
27
+ export type McpFileContents = {
28
+ readonly kind: "missing";
29
+ } | {
30
+ readonly kind: "text";
31
+ readonly text: string;
32
+ } | {
33
+ readonly kind: "unreadable";
34
+ readonly message: string;
35
+ };
36
+ export type McpFile = {
37
+ readonly path: string;
38
+ readonly scope: McpScope;
39
+ readonly contents: McpFileContents;
40
+ };
41
+ export type McpConfig = {
42
+ readonly servers: ReadonlyMap<string, McpServerEntry>;
43
+ readonly issues: readonly ValidationIssue[];
44
+ };
45
+ /** Reads one `mcp.json`; a file that cannot be read is `unreadable`, not missing. */
46
+ export declare function readMcpFile(path: string): Promise<McpFileContents>;
47
+ /**
48
+ * Merges the user file and then the project file into one server list. A
49
+ * project entry replaces the user entry of the same name; one with only
50
+ * `enabled`, `exposure` or `toolExposure` overrides those fields instead.
51
+ * An invalid entry becomes an issue and is left out.
52
+ */
53
+ export declare function parseMcpConfig(files: readonly McpFile[]): McpConfig;
54
+ /**
55
+ * Plans a change to the `mcpServers` of one `mcp.json`, keeping the rest of
56
+ * the file: `change` returns the new servers, or `null` when it has nothing
57
+ * to change. A missing file starts empty; one that is not a JSON object is
58
+ * refused. Nothing is written; pass the text to {@link writeMcpFile}.
59
+ */
60
+ export declare function planMcpEdit(path: string, change: (servers: {
61
+ readonly [name: string]: Json;
62
+ }) => {
63
+ readonly [name: string]: Json;
64
+ } | null): Promise<{
65
+ readonly kind: "planned";
66
+ readonly text: string;
67
+ } | Exclude<McpChange, {
68
+ kind: "updated";
69
+ }>>;
70
+ /**
71
+ * Replaces one `mcp.json` whole, readable only by the user as it may hold
72
+ * secrets. A symlinked file is written through the link.
73
+ */
74
+ export declare function writeMcpFile(path: string, text: string): Promise<void>;
75
+ export {};
@@ -0,0 +1,12 @@
1
+ import {
2
+ readMcpFile2,
3
+ parseMcpConfig2,
4
+ planMcpEdit2,
5
+ writeMcpFile2
6
+ } from "../../chunks/canvas-preview-kdqgrstc.js";
7
+ export {
8
+ parseMcpConfig2 as parseMcpConfig,
9
+ planMcpEdit2 as planMcpEdit,
10
+ readMcpFile2 as readMcpFile,
11
+ writeMcpFile2 as writeMcpFile
12
+ };
@@ -0,0 +1,28 @@
1
+ import type { McpTransport } from "@earendil-works/pi-mcp";
2
+ import type { OAuthChallenge } from "@earendil-works/pi-mcp/oauth";
3
+ import type { PluginStorage } from "@nyte-ai/core";
4
+ import type { McpWorkspace } from "@nyte-ai/core/server";
5
+ import type { McpOAuthConfig } from "@nyte-ai/schema";
6
+ import type { McpServerEntry } from "./config.ts";
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
+ export type McpConnector = (entry: McpServerEntry, context: {
16
+ readonly workspace: McpWorkspace;
17
+ readonly home: string;
18
+ readonly secrets: PluginStorage["secrets"];
19
+ readonly challenged: (challenge: OAuthChallenge) => void;
20
+ }) => 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
+ export declare const connectServer: McpConnector;
27
+ /** A server's OAuth options with `${VAR}`s in `clientSecret` resolved. */
28
+ export declare function oauthSettings(config: McpOAuthConfig, server: string): McpOAuthSettings;
@@ -0,0 +1,9 @@
1
+ import {
2
+ connectServer2,
3
+ oauthSettings2
4
+ } from "../../chunks/canvas-preview-h8hshnff.js";
5
+ import"../../chunks/canvas-preview-5z63am63.js";
6
+ export {
7
+ connectServer2 as connectServer,
8
+ oauthSettings2 as oauthSettings
9
+ };
@@ -0,0 +1,19 @@
1
+ import type { McpHubFactory } from "@nyte-ai/core/server";
2
+ import type { McpConnector } from "./connect.ts";
3
+ /**
4
+ * Serves the servers in `<home>/.nyte/mcp.json`, and in a trusted local
5
+ * workspace's `.nyte/mcp.json`, to the host's sessions. Each file is watched
6
+ * (created, edited, replaced or removed) without polling, and an edit applies
7
+ * once the file system reports it: a changed server reconnects, an unchanged
8
+ * one keeps its connection. A workspace's connections close 30 seconds after its last
9
+ * watcher stops.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const host = await openHost({ ...options, mcp: createMcpHub({ home: homedir() }) });
14
+ * ```
15
+ */
16
+ export declare function createMcpHub(input: {
17
+ readonly home: string;
18
+ readonly connect?: McpConnector;
19
+ }): McpHubFactory;
@@ -0,0 +1,11 @@
1
+ import {
2
+ createMcpHub2
3
+ } from "../../chunks/canvas-preview-8xgt67ka.js";
4
+ import"../../chunks/canvas-preview-h8hshnff.js";
5
+ import"../../chunks/canvas-preview-5z63am63.js";
6
+ import"../../chunks/canvas-preview-vaatfznm.js";
7
+ import"../../chunks/canvas-preview-kdqgrstc.js";
8
+ import"../../chunks/canvas-preview-mgcx2b2p.js";
9
+ export {
10
+ createMcpHub2 as createMcpHub
11
+ };
@@ -0,0 +1,46 @@
1
+ import type { AuthProvider } from "@earendil-works/pi-mcp";
2
+ import type { McpOAuthStateStore, OAuthChallenge } from "@earendil-works/pi-mcp/oauth";
3
+ import type { Login, PluginStorage } from "@nyte-ai/core";
4
+ /** A server's OAuth options with `${VAR}`s resolved. */
5
+ export type McpOAuthSettings = {
6
+ readonly clientId?: string;
7
+ readonly clientSecret?: string;
8
+ readonly callbackPort?: number;
9
+ readonly callbackUrl?: string;
10
+ readonly clientName?: string;
11
+ readonly scope?: string;
12
+ readonly authServerMetadataUrl?: URL;
13
+ };
14
+ /** The secret a server's OAuth state lives under: by name and URL, so one URL under two names signs in twice. */
15
+ export declare function oauthKey(server: string, url: string): string;
16
+ /** Keeps one server's OAuth state in the host's sealed secrets. */
17
+ export declare function oauthStore(secrets: PluginStorage["secrets"], key: string): McpOAuthStateStore;
18
+ /**
19
+ * Sends a connection's stored access token and refreshes it before it
20
+ * expires or after a 401, one refresh at a time. It never opens a browser:
21
+ * when only a new sign-in helps, including a server asking for more scope,
22
+ * it throws `McpOAuthAuthorizationRequiredError`. `onChallenge` keeps the
23
+ * server's `WWW-Authenticate` challenge for the sign-in.
24
+ */
25
+ export declare function createAuthProvider(input: {
26
+ readonly serverUrl: string;
27
+ readonly store: McpOAuthStateStore;
28
+ readonly settings: () => McpOAuthSettings;
29
+ onChallenge(challenge: OAuthChallenge): void;
30
+ }): AuthProvider;
31
+ /**
32
+ * Signs in to a server: refreshes stored tokens when that is enough, or
33
+ * runs the browser authorization code flow against a loopback callback.
34
+ * The returned login's steps are `open` (the authorization page), `paste`
35
+ * (answer with the redirect URL when the browser cannot reach this
36
+ * machine), then `done` or `failed`. Ending the steps cancels the sign-in.
37
+ */
38
+ export declare function signIn(input: {
39
+ readonly server: string;
40
+ readonly serverUrl: string;
41
+ readonly store: McpOAuthStateStore;
42
+ readonly settings: McpOAuthSettings;
43
+ readonly challenge: OAuthChallenge | null;
44
+ signedIn(): void;
45
+ ended(): void;
46
+ }): Login;
@@ -0,0 +1,12 @@
1
+ import {
2
+ oauthKey2,
3
+ oauthStore2,
4
+ createAuthProvider2,
5
+ signIn2
6
+ } from "../../chunks/canvas-preview-5z63am63.js";
7
+ export {
8
+ createAuthProvider2 as createAuthProvider,
9
+ oauthKey2 as oauthKey,
10
+ oauthStore2 as oauthStore,
11
+ signIn2 as signIn
12
+ };
@@ -0,0 +1,29 @@
1
+ import { McpClient } from "@earendil-works/pi-mcp";
2
+ import type { CallToolResult, McpRequestOptions, Tool } from "@earendil-works/pi-mcp";
3
+ import type { ToolDefinition } from "@nyte-ai/core";
4
+ import type { McpExposure, ValidationIssue } from "@nyte-ai/schema";
5
+ import type { McpServerEntry } from "./config.ts";
6
+ /** The exposure `entry` gives `tool`: an exact `toolExposure` key, else the first matching pattern, else the server's. */
7
+ export declare function toolExposure(entry: McpServerEntry, tool: string): McpExposure;
8
+ /** A server's listed tools that sessions get, and why each of the others is left out. */
9
+ export type CheckedTools = {
10
+ readonly usable: readonly Tool[];
11
+ readonly issues: readonly ValidationIssue[];
12
+ };
13
+ /**
14
+ * Splits a server's listed tools into those whose input schema is JSON Schema
15
+ * for an object, which providers accept, and an issue for each of the rest.
16
+ * A tool with a bad schema would fail every request that declares it, so no
17
+ * session gets it.
18
+ */
19
+ export declare function checkToolSchemas(server: string, tools: readonly Tool[]): CheckedTools;
20
+ /** Calls one of the server's tools over its live connection, its `traceparent` carried to the server; throws when the server is not connected. */
21
+ export type McpCall = (name: string, args: Record<string, unknown>, options: McpRequestOptions & {
22
+ readonly traceparent?: string;
23
+ }) => Promise<CallToolResult>;
24
+ /** An `McpClient` whose requests carry a `traceparent` given in their options to the server in `params._meta`, where MCP's trace-context convention puts it. */
25
+ export declare class TracingMcpClient extends McpClient {
26
+ request<Result = unknown>(method: string, params?: Record<string, unknown>, options?: McpRequestOptions): Promise<Result>;
27
+ }
28
+ /** Turns a server's listed tools into session tools named `mcp__<server>__<tool>`. */
29
+ export declare function bridgeTools(entry: McpServerEntry, tools: readonly Tool[], call: McpCall): ToolDefinition[];