@nyte-ai/host 0.0.0-stage → 0.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (250) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +6 -2
  3. package/THIRD-PARTY-NOTICES.md +866 -0
  4. package/dist/chunks/canvas-preview-0cmbkp2j.js +65 -0
  5. package/dist/chunks/canvas-preview-0nq75h9k.js +7 -0
  6. package/dist/chunks/canvas-preview-11nadadc.js +241 -0
  7. package/dist/chunks/canvas-preview-1sq7z9jq.js +17 -0
  8. package/dist/chunks/canvas-preview-2jwbe14k.js +130 -0
  9. package/dist/chunks/canvas-preview-2zdyh9ny.js +26 -0
  10. package/dist/chunks/canvas-preview-31w7xm8z.js +34 -0
  11. package/dist/chunks/canvas-preview-4b6sayhg.js +295 -0
  12. package/dist/chunks/canvas-preview-4e0pxa32.js +63 -0
  13. package/dist/chunks/canvas-preview-518dh8by.js +169 -0
  14. package/dist/chunks/canvas-preview-55s0y68g.js +387 -0
  15. package/dist/chunks/canvas-preview-5ekjx6sw.js +613 -0
  16. package/dist/chunks/canvas-preview-5mex725c.js +14 -0
  17. package/dist/chunks/canvas-preview-5z63am63.js +295 -0
  18. package/dist/chunks/canvas-preview-65xqjw7f.js +20 -0
  19. package/dist/chunks/canvas-preview-69fkk9yn.js +95 -0
  20. package/dist/chunks/canvas-preview-8xc0vn7v.js +458 -0
  21. package/dist/chunks/canvas-preview-9aqczacs.js +73 -0
  22. package/dist/chunks/canvas-preview-af86jz8t.js +141 -0
  23. package/dist/chunks/canvas-preview-aq5j4p25.js +240 -0
  24. package/dist/chunks/canvas-preview-b2v8wfnz.js +36 -0
  25. package/dist/chunks/canvas-preview-befkjea2.js +60 -0
  26. package/dist/chunks/canvas-preview-bxnqt8cd.js +103 -0
  27. package/dist/chunks/canvas-preview-cawy6vbz.js +352 -0
  28. package/dist/chunks/canvas-preview-crmzxxt8.js +518 -0
  29. package/dist/chunks/canvas-preview-drctegz4.js +591 -0
  30. package/dist/chunks/canvas-preview-e3vnkkc5.js +134 -0
  31. package/dist/chunks/canvas-preview-ec2mt7es.js +108 -0
  32. package/dist/chunks/canvas-preview-fxa0rfb0.js +61 -0
  33. package/dist/chunks/canvas-preview-g5fkjs34.js +598 -0
  34. package/dist/chunks/canvas-preview-jeddjex8.js +166 -0
  35. package/dist/chunks/canvas-preview-k1yg4fgp.js +571 -0
  36. package/dist/chunks/canvas-preview-kdqgrstc.js +194 -0
  37. package/dist/chunks/canvas-preview-kn7kvbfj.js +12 -0
  38. package/dist/chunks/canvas-preview-kp75gb63.js +141 -0
  39. package/dist/chunks/canvas-preview-mgcx2b2p.js +271 -0
  40. package/dist/chunks/canvas-preview-n2a35zv5.js +81 -0
  41. package/dist/chunks/canvas-preview-pkzqg96v.js +63 -0
  42. package/dist/chunks/canvas-preview-rp4x6y1h.js +144 -0
  43. package/dist/chunks/canvas-preview-s94ebwf5.js +112 -0
  44. package/dist/chunks/canvas-preview-skzwvw4d.js +23 -0
  45. package/dist/chunks/canvas-preview-srgfpdmf.js +60 -0
  46. package/dist/chunks/canvas-preview-tjhabynd.js +252 -0
  47. package/dist/chunks/canvas-preview-tnqe7k0b.js +374 -0
  48. package/dist/chunks/canvas-preview-vaatfznm.js +189 -0
  49. package/dist/chunks/canvas-preview-vm9zdp2t.js +398 -0
  50. package/dist/chunks/canvas-preview-w54ymtb3.js +272 -0
  51. package/dist/chunks/canvas-preview-wg80rbc2.js +46 -0
  52. package/dist/chunks/canvas-preview-y5y6ghaw.js +125 -0
  53. package/dist/chunks/canvas-preview-ycepb05s.js +176 -0
  54. package/dist/chunks/canvas-preview-yjz0f7n4.js +50 -0
  55. package/dist/chunks/canvas-preview-zaaj99wd.js +244 -0
  56. package/dist/src/canvas-preview.d.ts +29 -0
  57. package/dist/src/canvas-preview.js +271 -0
  58. package/dist/src/credentials.d.ts +44 -0
  59. package/dist/src/credentials.js +10 -0
  60. package/dist/src/deploy/cloudflare/worker.d.ts +50 -0
  61. package/dist/src/deploy/cloudflare/worker.js +196 -0
  62. package/dist/src/deploy/vercel/nitro.config.d.ts +2 -0
  63. package/dist/src/deploy/vercel/nitro.config.js +30 -0
  64. package/dist/src/deploy/vercel/server/routes/[...].d.ts +2 -0
  65. package/dist/src/deploy/vercel/server/routes/[...].js +18 -0
  66. package/dist/src/deploy/vercel/server/utils/host.d.ts +13 -0
  67. package/dist/src/deploy/vercel/server/utils/host.js +7 -0
  68. package/dist/src/deploy/vercel/server/utils/repair.d.ts +1 -0
  69. package/dist/src/deploy/vercel/server/utils/repair.js +6 -0
  70. package/dist/src/deploy/vercel/server/utils/step.d.ts +10 -0
  71. package/dist/src/deploy/vercel/server/utils/step.js +6 -0
  72. package/dist/src/deploy/vercel/server/workflows/drive.d.ts +14 -0
  73. package/dist/src/deploy/vercel/server/workflows/drive.js +13 -0
  74. package/dist/src/durable-object.d.ts +14 -0
  75. package/dist/src/durable-object.js +231 -0
  76. package/dist/src/hash.d.ts +1 -0
  77. package/dist/src/hash.js +6 -0
  78. package/dist/src/identity-key.d.ts +11 -0
  79. package/dist/src/identity-key.js +9 -0
  80. package/dist/src/identity.d.ts +12 -0
  81. package/dist/src/identity.js +6 -0
  82. package/dist/src/images/exif.d.ts +1 -0
  83. package/dist/src/images/exif.js +6 -0
  84. package/dist/src/images/node.d.ts +37 -0
  85. package/dist/src/images/node.js +12 -0
  86. package/dist/src/images/photon.d.ts +3 -0
  87. package/dist/src/images/photon.js +7 -0
  88. package/dist/src/images/worker.d.ts +1 -0
  89. package/dist/src/images/worker.js +23 -0
  90. package/dist/src/index.d.ts +20 -0
  91. package/dist/src/index.js +121 -0
  92. package/dist/src/key-file.d.ts +1 -0
  93. package/dist/src/key-file.js +7 -0
  94. package/dist/src/listen-fetch.d.ts +8 -0
  95. package/dist/src/listen-fetch.js +9 -0
  96. package/dist/src/listen.d.ts +4 -0
  97. package/dist/src/listen.js +10 -0
  98. package/dist/src/local/command.d.ts +20 -0
  99. package/dist/src/local/command.js +12 -0
  100. package/dist/src/local/feed.d.ts +7 -0
  101. package/dist/src/local/feed.js +6 -0
  102. package/dist/src/local/files.d.ts +18 -0
  103. package/dist/src/local/files.js +13 -0
  104. package/dist/src/local/git-watch.d.ts +15 -0
  105. package/dist/src/local/git-watch.js +7 -0
  106. package/dist/src/local/git.d.ts +5 -0
  107. package/dist/src/local/git.js +13 -0
  108. package/dist/src/local/github.d.ts +30 -0
  109. package/dist/src/local/github.js +9 -0
  110. package/dist/src/local/identity.d.ts +3 -0
  111. package/dist/src/local/identity.js +7 -0
  112. package/dist/src/local/jobs.d.ts +7 -0
  113. package/dist/src/local/jobs.js +7 -0
  114. package/dist/src/local/legacy-trust.d.ts +10 -0
  115. package/dist/src/local/legacy-trust.js +6 -0
  116. package/dist/src/local/patch.d.ts +16 -0
  117. package/dist/src/local/patch.js +17 -0
  118. package/dist/src/local/provider.d.ts +11 -0
  119. package/dist/src/local/provider.js +20 -0
  120. package/dist/src/local/snapshots.d.ts +7 -0
  121. package/dist/src/local/snapshots.js +11 -0
  122. package/dist/src/local/text.d.ts +1 -0
  123. package/dist/src/local/text.js +6 -0
  124. package/dist/src/local/tree.d.ts +50 -0
  125. package/dist/src/local/tree.js +16 -0
  126. package/dist/src/local/workspace-migration.d.ts +2 -0
  127. package/dist/src/local/workspace-migration.js +7 -0
  128. package/dist/src/local/worktrees.d.ts +46 -0
  129. package/dist/src/local/worktrees.js +14 -0
  130. package/dist/src/mcp/config.d.ts +75 -0
  131. package/dist/src/mcp/config.js +12 -0
  132. package/dist/src/mcp/connect.d.ts +15 -0
  133. package/dist/src/mcp/connect.js +9 -0
  134. package/dist/src/mcp/hub.d.ts +19 -0
  135. package/dist/src/mcp/hub.js +11 -0
  136. package/dist/src/mcp/oauth.d.ts +46 -0
  137. package/dist/src/mcp/oauth.js +12 -0
  138. package/dist/src/mcp/tools.d.ts +29 -0
  139. package/dist/src/mcp/tools.js +12 -0
  140. package/dist/src/open.d.ts +14 -0
  141. package/dist/src/open.js +46 -0
  142. package/dist/src/plugins/loader.d.ts +21 -0
  143. package/dist/src/plugins/loader.js +11 -0
  144. package/dist/src/postgres.d.ts +19 -0
  145. package/dist/src/postgres.js +8 -0
  146. package/dist/src/providers.d.ts +16 -0
  147. package/dist/src/providers.js +112 -0
  148. package/dist/src/secrets.d.ts +12 -0
  149. package/dist/src/secrets.js +8 -0
  150. package/dist/src/serve/binding.d.ts +39 -0
  151. package/dist/src/serve/binding.js +6 -0
  152. package/dist/src/serve/handler.d.ts +15 -0
  153. package/dist/src/serve/handler.js +8 -0
  154. package/dist/src/serve/stream-server.d.ts +6 -0
  155. package/dist/src/serve/stream-server.js +6 -0
  156. package/dist/src/session-index.d.ts +11 -0
  157. package/dist/src/session-index.js +11 -0
  158. package/dist/src/shell-env.d.ts +14 -0
  159. package/dist/src/shell-env.js +108 -0
  160. package/dist/src/sqlite-workers.d.ts +6 -0
  161. package/dist/src/sqlite-workers.js +6 -0
  162. package/dist/src/sqlite.d.ts +8 -0
  163. package/dist/src/sqlite.js +11 -0
  164. package/dist/src/store-rows.d.ts +13 -0
  165. package/dist/src/store-rows.js +26 -0
  166. package/dist/src/store-usage.d.ts +25 -0
  167. package/dist/src/store-usage.js +19 -0
  168. package/dist/src/usage-history.d.ts +54 -0
  169. package/dist/src/usage-history.js +14 -0
  170. package/dist/src/usage-scan.d.ts +24 -0
  171. package/dist/src/usage-scan.js +65 -0
  172. package/dist/src/usage-service.d.ts +23 -0
  173. package/dist/src/usage-service.js +16 -0
  174. package/dist/src/usage-summary.d.ts +9 -0
  175. package/dist/src/usage-summary.js +16 -0
  176. package/dist/src/usage-types.d.ts +86 -0
  177. package/dist/src/usage-types.js +0 -0
  178. package/dist/src/usage-worker.d.ts +1 -0
  179. package/dist/src/usage-worker.js +29 -0
  180. package/dist/src/usage.d.ts +195 -0
  181. package/dist/src/usage.js +23 -0
  182. package/package.json +140 -3
  183. package/src/canvas-preview.ts +403 -0
  184. package/src/credentials.ts +294 -0
  185. package/src/deploy/cloudflare/README.md +3 -0
  186. package/src/deploy/cloudflare/worker.ts +306 -0
  187. package/src/deploy/cloudflare/wrangler.jsonc +12 -0
  188. package/src/deploy/vercel/README.md +3 -0
  189. package/src/deploy/vercel/nitro.config.ts +29 -0
  190. package/src/deploy/vercel/server/routes/[...].ts +10 -0
  191. package/src/deploy/vercel/server/utils/host.ts +104 -0
  192. package/src/deploy/vercel/server/utils/repair.ts +35 -0
  193. package/src/deploy/vercel/server/utils/step.ts +25 -0
  194. package/src/deploy/vercel/server/workflows/drive.ts +46 -0
  195. package/src/deploy/vercel/tsconfig.json +9 -0
  196. package/src/deploy/vercel/types/bun.d.ts +2 -0
  197. package/src/durable-object.ts +386 -0
  198. package/src/hash.ts +5 -0
  199. package/src/identity-key.ts +20 -0
  200. package/src/identity.ts +66 -0
  201. package/src/images/exif.ts +69 -0
  202. package/src/images/node.ts +163 -0
  203. package/src/images/photon.ts +141 -0
  204. package/src/images/worker.ts +29 -0
  205. package/src/index.ts +39 -0
  206. package/src/key-file.ts +53 -0
  207. package/src/listen-fetch.ts +409 -0
  208. package/src/listen.ts +228 -0
  209. package/src/local/command.ts +161 -0
  210. package/src/local/feed.ts +70 -0
  211. package/src/local/files.ts +817 -0
  212. package/src/local/git-watch.ts +199 -0
  213. package/src/local/git.ts +919 -0
  214. package/src/local/github.ts +691 -0
  215. package/src/local/identity.ts +21 -0
  216. package/src/local/jobs.ts +573 -0
  217. package/src/local/legacy-trust.ts +105 -0
  218. package/src/local/patch.ts +334 -0
  219. package/src/local/provider.ts +184 -0
  220. package/src/local/snapshots.ts +778 -0
  221. package/src/local/text.ts +9 -0
  222. package/src/local/tree.ts +398 -0
  223. package/src/local/workspace-migration.ts +95 -0
  224. package/src/local/worktrees.ts +239 -0
  225. package/src/mcp/config.ts +330 -0
  226. package/src/mcp/connect.ts +92 -0
  227. package/src/mcp/hub.ts +836 -0
  228. package/src/mcp/oauth.ts +436 -0
  229. package/src/mcp/tools.ts +333 -0
  230. package/src/open.ts +449 -0
  231. package/src/plugins/loader.ts +186 -0
  232. package/src/postgres.ts +492 -0
  233. package/src/providers.ts +135 -0
  234. package/src/secrets.ts +31 -0
  235. package/src/serve/binding.ts +629 -0
  236. package/src/serve/handler.ts +362 -0
  237. package/src/serve/stream-server.ts +176 -0
  238. package/src/session-index.ts +99 -0
  239. package/src/shell-env.ts +153 -0
  240. package/src/sqlite-workers.ts +283 -0
  241. package/src/sqlite.ts +553 -0
  242. package/src/store-rows.ts +110 -0
  243. package/src/store-usage.ts +347 -0
  244. package/src/usage-history.ts +219 -0
  245. package/src/usage-scan.ts +81 -0
  246. package/src/usage-service.ts +82 -0
  247. package/src/usage-summary.ts +79 -0
  248. package/src/usage-types.ts +87 -0
  249. package/src/usage-worker.ts +24 -0
  250. package/src/usage.ts +776 -0
@@ -0,0 +1,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-g5fkjs34.js";
4
+ import"../../chunks/canvas-preview-pkzqg96v.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[];
@@ -0,0 +1,12 @@
1
+ import {
2
+ toolExposure2,
3
+ checkToolSchemas2,
4
+ TracingMcpClient2,
5
+ bridgeTools2
6
+ } from "../../chunks/canvas-preview-vaatfznm.js";
7
+ export {
8
+ TracingMcpClient2 as TracingMcpClient,
9
+ bridgeTools2 as bridgeTools,
10
+ checkToolSchemas2 as checkToolSchemas,
11
+ toolExposure2 as toolExposure
12
+ };
@@ -0,0 +1,14 @@
1
+ import type { Models } from "@nyte-ai/ai";
2
+ import type { WorkspaceTarget } from "@nyte-ai/schema";
3
+ import type { Host, OpenOptions, Plugin, Store } from "@nyte-ai/core";
4
+ export type OpenHostOptions = Omit<OpenOptions, "store" | "workspace" | "models" | "plugins"> & {
5
+ readonly store?: Store;
6
+ readonly workspace?: WorkspaceTarget;
7
+ readonly models?: Models;
8
+ readonly plugins?: readonly Plugin<"core">[];
9
+ readonly home?: string;
10
+ readonly shell?: () => string | null;
11
+ readonly label?: string;
12
+ readonly onRevoked?: () => void;
13
+ };
14
+ export declare function openHost(options: OpenHostOptions): Promise<Host>;
@@ -0,0 +1,46 @@
1
+ import {
2
+ openHost2
3
+ } from "../chunks/canvas-preview-cawy6vbz.js";
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";
8
+ import"../chunks/canvas-preview-9aqczacs.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";
13
+ import"../chunks/canvas-preview-1sq7z9jq.js";
14
+ import"../chunks/canvas-preview-vm9zdp2t.js";
15
+ import"../chunks/canvas-preview-crmzxxt8.js";
16
+ import"../chunks/canvas-preview-tjhabynd.js";
17
+ import"../chunks/canvas-preview-g5fkjs34.js";
18
+ import"../chunks/canvas-preview-pkzqg96v.js";
19
+ import"../chunks/canvas-preview-5z63am63.js";
20
+ import"../chunks/canvas-preview-vaatfznm.js";
21
+ import"../chunks/canvas-preview-drctegz4.js";
22
+ import"../chunks/canvas-preview-kn7kvbfj.js";
23
+ import"../chunks/canvas-preview-yjz0f7n4.js";
24
+ import"../chunks/canvas-preview-af86jz8t.js";
25
+ import"../chunks/canvas-preview-s94ebwf5.js";
26
+ import"../chunks/canvas-preview-kdqgrstc.js";
27
+ import"../chunks/canvas-preview-tnqe7k0b.js";
28
+ import"../chunks/canvas-preview-zaaj99wd.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";
33
+ import"../chunks/canvas-preview-rp4x6y1h.js";
34
+ import"../chunks/canvas-preview-skzwvw4d.js";
35
+ import"../chunks/canvas-preview-bxnqt8cd.js";
36
+ import"../chunks/canvas-preview-518dh8by.js";
37
+ import"../chunks/canvas-preview-0cmbkp2j.js";
38
+ import"../chunks/canvas-preview-69fkk9yn.js";
39
+ import"../chunks/canvas-preview-0nq75h9k.js";
40
+ import"../chunks/canvas-preview-5mex725c.js";
41
+ import"../chunks/canvas-preview-31w7xm8z.js";
42
+ import"../chunks/canvas-preview-wg80rbc2.js";
43
+ import"../chunks/canvas-preview-mgcx2b2p.js";
44
+ export {
45
+ openHost2 as openHost
46
+ };
@@ -0,0 +1,21 @@
1
+ import type { ValidationIssue } from "@nyte-ai/schema";
2
+ import type { Plugin } from "@nyte-ai/core";
3
+ import type { ComposeOptions } from "@nyte-ai/core/server";
4
+ /** Returns the core plugins in a plugin directory (`~/.nyte/plugins`, a workspace's `.nyte/plugins`), by file name: each `.ts`, `.mts`, `.js` or `.mjs` file directly in it and each subdirectory's `index` of those, loaded with a dynamic `import()` of its file URL. That `import()` is one of the two dynamic loads the rewrite allows (§41a), host-only, because a plugin file is code the owner placed there and its path is known only at run time; Node strips `.ts` types natively (erasable syntax only). The URL carries the file's modification time and size as a query, so a replaced file loads fresh instead of from the module cache. The default export must be a core plugin (an object with a string `id`, and, where present, `contribute` and `hooks` objects, an `activate` function and an `environment` with a string `kind` and `inspect` and `attach` functions); every file that does not load or export one is reported, together, as `SdkError("invalid")` with an issue per file naming it. A missing directory has none. */
5
+ export declare function loadPluginFiles(dir: string): Promise<readonly {
6
+ readonly plugin: Plugin<"core">;
7
+ readonly path: string;
8
+ }[]>;
9
+ /** Returns a plugin directory's plugins as `loadPluginFiles` finds and imports them, but file by file: every file that loads, with its path, and every file that does not, with its path and one `error` issue (its `path` the file, `source.file` the file, the message `loadPluginFiles` would have put in its `invalid`), never rejecting for a bad file; a missing directory has neither. What `openHost` loads `~/.nyte/plugins` and a local workspace's `.nyte/plugins` through, so one bad file is reported on `HostView.plugins` instead of failing the open (§41j); `loadPluginFiles` becomes this, throwing its one `invalid` when anything failed. */
10
+ export declare function loadPluginDirectory(dir: string): Promise<{
11
+ readonly loaded: readonly {
12
+ readonly plugin: Plugin<"core">;
13
+ readonly path: string;
14
+ }[];
15
+ readonly failed: readonly {
16
+ readonly path: string;
17
+ readonly issue: ValidationIssue;
18
+ }[];
19
+ }>;
20
+ /** Returns the host's `loadPlugins` (`composeHost({ loadPlugins })`), which `plugins.replace` and `plugins.check` load their files through (§40b, §47m): each path, resolved to its real path, must lie inside one of `dirs` (else `SdkError("denied")`) and is imported as `loadPluginFiles` imports a file; the plugins come back in path order. */
21
+ export declare function pluginLoader(dirs: readonly string[]): NonNullable<ComposeOptions["loadPlugins"]>;
@@ -0,0 +1,11 @@
1
+ import {
2
+ loadPluginFiles2,
3
+ loadPluginDirectory2,
4
+ pluginLoader2
5
+ } from "../../chunks/canvas-preview-s94ebwf5.js";
6
+ import"../../chunks/canvas-preview-mgcx2b2p.js";
7
+ export {
8
+ loadPluginDirectory2 as loadPluginDirectory,
9
+ loadPluginFiles2 as loadPluginFiles,
10
+ pluginLoader2 as pluginLoader
11
+ };
@@ -0,0 +1,19 @@
1
+ import type { Store } from "@nyte-ai/core";
2
+ /** Returns one pooled client: what `PostgresPool.connect` lends, a query at a time, released once. */
3
+ export type PostgresClient = {
4
+ query(text: string, values?: readonly unknown[]): Promise<{
5
+ readonly rows: readonly Record<string, unknown>[];
6
+ }>;
7
+ release(): void;
8
+ };
9
+ /** Returns the pool `postgresStore` queries through, structurally, so `pg.Pool` and a pglite adapter both fit (§41c). */
10
+ export type PostgresPool = {
11
+ connect(): Promise<PostgresClient>;
12
+ end(): Promise<void>;
13
+ };
14
+ /** Returns a `Store` over Postgres: a `pg` `Pool` of its own from `connectionString`, ended by `close()`, or the caller's `pool` (any `PostgresPool`, §41c), left open. The first `open()` brings it to core's `STORE_VERSION` with `migrateStore`, the sqlite store's tables with `bytes` as `BYTEA`, `seq`/`at` as `BIGINT` and `refs.name` collated `"C"` so `list` ranges and orders by code point as the other stores do; each commit is one transaction under an exclusive advisory lock, so instances opening at once serialize, and the open rejects with `SdkError("unavailable")` for a store a newer Nyte migrated. There is no backup. Semantics are the sqlite store's (§41f); each `refs.set` is one transaction on one pooled client that shares the migration's advisory lock, rejects with `SdkError("unavailable")` when a newer Nyte has migrated the store, then takes `pg_advisory_xact_lock` on every ref name and session it touches, in sorted order (a row lock cannot hold an absent ref or a session's next seq), then reads those refs and applies `RefStore.set`, rolling back on any error. Every `open()` returns a connection whose reads go through the pool. */
15
+ export declare function postgresStore(input: {
16
+ readonly connectionString: string;
17
+ } | {
18
+ readonly pool: PostgresPool;
19
+ }): Store;
@@ -0,0 +1,8 @@
1
+ import {
2
+ postgresStore2
3
+ } from "../chunks/canvas-preview-4b6sayhg.js";
4
+ import"../chunks/canvas-preview-0cmbkp2j.js";
5
+ import"../chunks/canvas-preview-69fkk9yn.js";
6
+ export {
7
+ postgresStore2 as postgresStore
8
+ };
@@ -0,0 +1,16 @@
1
+ import type { WorkspaceTarget } from "@nyte-ai/schema";
2
+ import type { EnvironmentProvider, ExecutionEnv, GitApi, SnapshotsApi } from "@nyte-ai/core";
3
+ /** Returns one booted or joined sandbox, what `sandboxProvider`'s `boot` answers: its identity (the one the provider's `inspect` answers for its target), its working directory, its files over the remote `FilesApi` contract (paths relative to `cwd`, §41j), its processes as jobs, `destroy`, which tears the sandbox down with its files and processes, and the optional `git` and `snapshots` seams of a sandbox that can serve them (§42c, §42n; paths relative to `cwd` too). */
4
+ export type SandboxHandle = Pick<ExecutionEnv, "identity" | "cwd" | "files" | "exec"> & {
5
+ readonly git?: GitApi;
6
+ readonly snapshots?: SnapshotsApi;
7
+ destroy(): Promise<void>;
8
+ };
9
+ /** Returns the chat-only environment provider (`kind: "chat-only"`), node-free: a workspace with no files and no processes, for a host that only chats (a Durable Object). `inspect` answers any target with identity `"chat-only"`, `available` and no project sources; `attach` answers an `ExecutionEnv` with that identity and `cwd` `/` whose `files` see nothing — `read` answers `missing`, `stat` null, `bytes` throws `SdkError("unknown")`, `scan` and `search` answer `complete` alone, `find` no entries, `watch` yields nothing until its caller returns, `format` answers `unavailable { reason: "unsupported" }` — and refuse every change (`write`, `remove`, `upload` and a batch's `apply` throw `SdkError("unavailable")`), whose `exec` throws `SdkError("unavailable")`, and whose `close` resolves. No `git`, `snapshots`, `browser` or `destroy`. */
10
+ export declare function chatOnlyProvider(): EnvironmentProvider;
11
+ /** Returns an environment provider over remote sandboxes (`kind` default `"sandbox"`), node-free. `inspect` is `options.inspect`, else it answers the content hash of the target (core's `objectId`) as its identity, `available` and no project sources, booting nothing. `attach(target)` joins the sandbox this provider already booted for the target or boots it with `boot(target)` (one boot in flight per target, keyed by that hash; a failed boot is forgotten so the next attach boots again) and answers an `ExecutionEnv` with the handle's `identity`, `cwd`, `files` and `exec`, whose `close` detaches and leaves the sandbox running. `git` and `snapshots` are on the provider, `(env) => handle.git` and `(env) => handle.snapshots` for the handle behind an environment it attached, found by the environment's identity, which core's wraps pass through (§42c, §42o): a handle that has a seam serves it (`git` `available` to the workspace, snapshots taken around each run), and one without answers `undefined`, which the workspace sees as `git` `unsupported` and no snapshots — the baseline's "required for local and sandbox" unmet for that sandbox. `destroy(target)` calls the handle's `destroy` (joining the sandbox through `boot` first when this provider holds none for the target) and forgets it. No `browser`. */
12
+ export declare function sandboxProvider(options: {
13
+ readonly kind?: string;
14
+ boot(target: WorkspaceTarget): Promise<SandboxHandle>;
15
+ readonly inspect?: EnvironmentProvider["inspect"];
16
+ }): EnvironmentProvider;
@@ -0,0 +1,112 @@
1
+ // src/providers.ts
2
+ import { asId, SdkError } from "@nyte-ai/schema";
3
+ import { closable } from "@nyte-ai/core";
4
+ import { objectId } from "@nyte-ai/core/store";
5
+ var CHAT_ONLY = asId("chat-only");
6
+ function chatOnlyProvider() {
7
+ const env = {
8
+ identity: CHAT_ONLY,
9
+ cwd: "/",
10
+ files: chatOnlyFiles(),
11
+ async exec() {
12
+ throw new SdkError("unavailable", "A chat-only workspace runs no processes.");
13
+ },
14
+ close: async () => {
15
+ return;
16
+ }
17
+ };
18
+ return {
19
+ kind: "chat-only",
20
+ inspect: async () => ({
21
+ identity: CHAT_ONLY,
22
+ availability: { kind: "available" },
23
+ projectSources: []
24
+ }),
25
+ attach: async () => env
26
+ };
27
+ }
28
+ function sandboxProvider(options) {
29
+ const booted = new Map;
30
+ const attached = new Map;
31
+ const boot = async (target) => {
32
+ const key = await objectId(target);
33
+ const known = booted.get(key);
34
+ if (known !== undefined)
35
+ return known;
36
+ const booting = options.boot(target);
37
+ booted.set(key, booting);
38
+ booting.catch(() => {
39
+ if (booted.get(key) === booting)
40
+ booted.delete(key);
41
+ });
42
+ return booting;
43
+ };
44
+ return {
45
+ kind: options.kind ?? "sandbox",
46
+ inspect: options.inspect ?? (async (target) => ({
47
+ identity: asId(await objectId(target)),
48
+ availability: { kind: "available" },
49
+ projectSources: []
50
+ })),
51
+ async attach(target) {
52
+ const handle = await boot(target);
53
+ attached.set(handle.identity, handle);
54
+ return {
55
+ identity: handle.identity,
56
+ cwd: handle.cwd,
57
+ files: handle.files,
58
+ exec: (command, run) => handle.exec(command, run),
59
+ close: async () => {
60
+ return;
61
+ }
62
+ };
63
+ },
64
+ git: (env) => attached.get(env.identity)?.git,
65
+ snapshots: (env) => attached.get(env.identity)?.snapshots,
66
+ async destroy(target) {
67
+ const key = await objectId(target);
68
+ const handle = await (booted.get(key) ?? options.boot(target));
69
+ booted.delete(key);
70
+ if (attached.get(handle.identity) === handle)
71
+ attached.delete(handle.identity);
72
+ await handle.destroy();
73
+ }
74
+ };
75
+ }
76
+ function chatOnlyFiles() {
77
+ const refuse = async () => {
78
+ throw new SdkError("unavailable", "A chat-only workspace has no files to change.");
79
+ };
80
+ const plan = { put: () => plan, remove: () => plan, apply: refuse };
81
+ return {
82
+ read: async (path) => ({ kind: "missing", path }),
83
+ async bytes(path) {
84
+ throw new SdkError("unknown", `No file is at ${path}.`);
85
+ },
86
+ stat: async () => null,
87
+ write: refuse,
88
+ remove: refuse,
89
+ batch: () => plan,
90
+ format: async () => ({ kind: "unavailable", reason: "unsupported" }),
91
+ async* scan() {
92
+ yield { kind: "complete" };
93
+ },
94
+ find: async () => [],
95
+ async* search() {
96
+ yield { kind: "complete" };
97
+ },
98
+ watch: () => closable(() => ({
99
+ pull: () => new Promise(() => {
100
+ return;
101
+ }),
102
+ close: () => {
103
+ return;
104
+ }
105
+ })),
106
+ upload: refuse
107
+ };
108
+ }
109
+ export {
110
+ chatOnlyProvider,
111
+ sandboxProvider
112
+ };
@@ -0,0 +1,12 @@
1
+ import type { OpenOptions } from "@nyte-ai/core";
2
+ /** Returns where a host gets the 32-byte key core encrypts secrets with: `OpenOptions.secrets` (decision 10). */
3
+ export type SecretsSource = NonNullable<OpenOptions["secrets"]>;
4
+ /**
5
+ * Returns the Node host's default secrets key: `<home>/.nyte/secret.key`, 32
6
+ * raw bytes read or minted by `readKeyFile` (decision 10; §43d as amended by
7
+ * §43i). The source memoises a resolved answer itself; a rejected one is not
8
+ * kept, so the next call reads again (§43k). The key is for secrets only: the
9
+ * host's identity has its own file (§50a). There is no keychain here, and
10
+ * the desktop uses this file as the tui and cli do (§55).
11
+ */
12
+ export declare function defaultSecrets(home: string): SecretsSource;
@@ -0,0 +1,8 @@
1
+ import {
2
+ defaultSecrets2
3
+ } from "../chunks/canvas-preview-skzwvw4d.js";
4
+ import"../chunks/canvas-preview-wg80rbc2.js";
5
+ import"../chunks/canvas-preview-mgcx2b2p.js";
6
+ export {
7
+ defaultSecrets2 as defaultSecrets
8
+ };
@@ -0,0 +1,39 @@
1
+ import type { ByteReader, OutputFrame } from "@nyte-ai/schema";
2
+ import type { Connection } from "@nyte-ai/core";
3
+ import type { ServerHost } from "@nyte-ai/core/server";
4
+ import type { ByteName, CallName, FrameName, OperationInput, OperationOutput } from "@nyte-ai/protocol";
5
+ /** Returns what a row's binding receives besides its input: the request's body (the bytes of `files.write`, `job.write` and `files.upload`) and the client's abort signal. */
6
+ export type BindingRequest = {
7
+ readonly body: ReadableStream<Uint8Array> | null;
8
+ readonly signal: AbortSignal;
9
+ };
10
+ /** Returns a byte row's answer: the reader and the headers the response adds (`X-Nyte-Version` for `files.bytes`, §40p). */
11
+ type ByteBody = {
12
+ readonly reader: ByteReader;
13
+ readonly headers?: Readonly<Record<string, string>>;
14
+ };
15
+ /** Returns the bindings of the rows answered once. */
16
+ export type CallBinding = {
17
+ readonly [N in CallName]: (input: OperationInput<N>, request: BindingRequest) => Promise<OperationOutput<N>>;
18
+ };
19
+ /** Returns the bindings of the rows answered with JSON frames. */
20
+ export type FrameBinding = {
21
+ readonly [N in FrameName]: (input: OperationInput<N>, request: BindingRequest) => Promise<AsyncIterable<OperationOutput<N>>>;
22
+ };
23
+ /** Returns the bindings of the rows answered with bytes. */
24
+ export type ByteBinding = {
25
+ readonly [N in ByteName]: (input: OperationInput<N>, request: BindingRequest) => Promise<ByteBody>;
26
+ };
27
+ /** Returns the binding of `job.output`, whose frames are framed bytes and control frames (§40h). */
28
+ type OutputBinding = {
29
+ readonly "job.output": (input: OperationInput<"job.output">, request: BindingRequest) => Promise<AsyncIterable<OutputFrame>>;
30
+ };
31
+ /** Returns the server side of the table for one connection: each row takes its decoded input and the request's body and abort signal, and answers its output, its frames, or a byte reader; setup failures (authority, capability, unknown ids) reject before any frame. */
32
+ export type Binding = CallBinding & FrameBinding & ByteBinding & OutputBinding;
33
+ /** Describes what a binding needs beyond the connection: the server port, for the rows that carry a wire-only id (§40o) and `parts.create`. */
34
+ export type BindingOptions = {
35
+ readonly server: ServerHost;
36
+ };
37
+ /** Returns each row bound to the call it names: ids bind handles on the connection, handles returned become ids, `Set`s and `Map`s become their wire forms; `head.move`, `files.batch` and `browser.open` go through the server port's wire operations with their wire id (§40o, §40x). `head.watch` sends the head's view from the host's fold whole, then each later view as its changes (`viewFrames`), the core watch marking the principal's seen tip (§40a, §54a). Authority is the caller's gate: the server checks each row's before binding. */
38
+ export declare function bindConnection(connection: Connection, options: BindingOptions): Binding;
39
+ export {};
@@ -0,0 +1,6 @@
1
+ import {
2
+ bindConnection2
3
+ } from "../../chunks/canvas-preview-55s0y68g.js";
4
+ export {
5
+ bindConnection2 as bindConnection
6
+ };
@@ -0,0 +1,15 @@
1
+ import type { Authority } from "@nyte-ai/schema";
2
+ import type { Connection } from "@nyte-ai/core";
3
+ import type { BindingOptions } from "./binding.ts";
4
+ /** Describes the handler: how a request authenticates to a connection (with the headers its answer carries, such as a pairing's `X-Nyte-Credential`, §40j), what the binding needs, the body limit and the allowed origins. */
5
+ export type HandlerOptions = BindingOptions & {
6
+ connection(request: Request): Promise<{
7
+ readonly connection: Connection;
8
+ readonly authority: ReadonlySet<Authority>;
9
+ readonly headers?: Readonly<Record<string, string>>;
10
+ }>;
11
+ readonly maxBodyBytes?: number;
12
+ readonly origins?: readonly string[];
13
+ };
14
+ /** Returns the whole protocol as one fetch handler: `POST /<name>` per row (anything else `unknown`), CORS for `origins`, the row's authority over the connection the request authenticates to, and the body limit (413). Calls answer JSON, watches and JSON streams server-sent events, byte rows an octet stream and `job.output` framed octets (§40h, §40w); the request's abort ends every stream. An error answers its encoded `SdkError` at the status `errorStatus` gives its code. */
15
+ export declare function createHandler(options: HandlerOptions): (request: Request) => Promise<Response>;
@@ -0,0 +1,8 @@
1
+ import {
2
+ createHandler2
3
+ } from "../../chunks/canvas-preview-aq5j4p25.js";
4
+ import"../../chunks/canvas-preview-55s0y68g.js";
5
+ import"../../chunks/canvas-preview-rp4x6y1h.js";
6
+ export {
7
+ createHandler2 as createHandler
8
+ };
@@ -0,0 +1,6 @@
1
+ import type { Connection } from "@nyte-ai/core";
2
+ export declare function createStreamChannels(): {
3
+ open(connection: Connection, signal: AbortSignal, deflate: boolean): Response;
4
+ start(connection: Connection, channelId: string, streamId: string, request: AbortSignal, serve: (signal: AbortSignal) => Promise<Response>): Promise<Response>;
5
+ cancel(connection: Connection, channelId: string, streamId: string): void;
6
+ };
@@ -0,0 +1,6 @@
1
+ import {
2
+ createStreamChannels2
3
+ } from "../../chunks/canvas-preview-rp4x6y1h.js";
4
+ export {
5
+ createStreamChannels2 as createStreamChannels
6
+ };
@@ -0,0 +1,11 @@
1
+ import type { SessionIndex } from "@nyte-ai/core";
2
+ import type { Json, Revision } from "@nyte-ai/schema";
3
+ type Binding = string | number | null;
4
+ interface Statement {
5
+ readonly text: string;
6
+ readonly values: readonly Binding[];
7
+ }
8
+ export declare function sessionIndexChanges(name: string, object: Json | null, revision: Revision): readonly Statement[];
9
+ export declare function sqlSessionIndex(read: (text: string, values: readonly Binding[]) => Promise<readonly Record<string, unknown>[]>): SessionIndex;
10
+ export declare function postgresSessionIndexQuery(text: string): string;
11
+ export {};
@@ -0,0 +1,11 @@
1
+ import {
2
+ sessionIndexChanges2,
3
+ sqlSessionIndex2,
4
+ postgresSessionIndexQuery2
5
+ } from "../chunks/canvas-preview-0cmbkp2j.js";
6
+ import"../chunks/canvas-preview-69fkk9yn.js";
7
+ export {
8
+ postgresSessionIndexQuery2 as postgresSessionIndexQuery,
9
+ sessionIndexChanges2 as sessionIndexChanges,
10
+ sqlSessionIndex2 as sqlSessionIndex
11
+ };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Starts reading the login shell's environment into `process.env`, once per process, and holds
3
+ * every child spawn and provider auth env read (`processEnvironment()`) until it lands. The
4
+ * process itself goes on: a desktop app opened from the Dock inherits launchd's bare PATH and
5
+ * none of the rc files' API keys, and only what it spawns and what auth reads need the shell's.
6
+ * The read gives up after 10 s and keeps the inherited environment.
7
+ */
8
+ export declare function completeShellEnvironment(): Promise<void>;
9
+ /** Returns a repair that merges the login shell's environment into `env` on its first call; later calls share that attempt. */
10
+ export declare function createShellEnvironmentRepair({ env, platform, timeoutMs, }?: {
11
+ env?: NodeJS.ProcessEnv;
12
+ platform?: NodeJS.Platform;
13
+ timeoutMs?: number;
14
+ }): () => Promise<void>;