@agentorg/cli 0.0.5 → 0.0.7

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 (260) hide show
  1. package/README.md +23 -104
  2. package/dist/node_modules/@agentorg/computer/LICENSE +201 -0
  3. package/dist/node_modules/@agentorg/computer/NOTICE +2 -0
  4. package/dist/node_modules/@agentorg/computer/dist/THIRD_PARTY_LICENSES.txt +1321 -0
  5. package/dist/node_modules/@agentorg/computer/dist/sdk.js +24909 -0
  6. package/dist/node_modules/@agentorg/computer/dist/types/generated/schema.d.ts +860 -0
  7. package/dist/node_modules/@agentorg/computer/dist/types/sdk.d.ts +242 -0
  8. package/dist/node_modules/@agentorg/computer/package.json +12 -0
  9. package/dist/node_modules/@agentorg/computer-connector/dist/src/index.d.ts +1 -0
  10. package/dist/node_modules/@agentorg/computer-connector/dist/src/index.js +1 -0
  11. package/dist/node_modules/@agentorg/computer-connector/dist/src/provider.d.ts +24 -0
  12. package/dist/node_modules/@agentorg/computer-connector/dist/src/provider.js +482 -0
  13. package/dist/node_modules/@agentorg/computer-connector/dist/src/unit.d.ts +19 -0
  14. package/dist/node_modules/@agentorg/computer-connector/dist/src/unit.js +149 -0
  15. package/dist/node_modules/@agentorg/computer-connector/package.json +33 -0
  16. package/dist/node_modules/@agentorg/computer-connector/skills/browser/SKILL.md +31 -0
  17. package/dist/node_modules/@agentorg/computer-connector/skills/computer/SKILL.md +30 -0
  18. package/dist/node_modules/@agentorg/computer-connector/skills/files/SKILL.md +28 -0
  19. package/dist/node_modules/@agentorg/computer-connector/skills/terminal/SKILL.md +39 -0
  20. package/dist/node_modules/@agentorg/computer-connector/skills/web-research/SKILL.md +29 -0
  21. package/dist/node_modules/@agentorg/hub/dist/src/hub-actor.d.ts +2 -7
  22. package/dist/node_modules/@agentorg/hub/dist/src/hub-actor.js +4 -144
  23. package/dist/node_modules/@agentorg/hub/dist/src/index.d.ts +1 -3
  24. package/dist/node_modules/@agentorg/hub/dist/src/index.js +1 -3
  25. package/dist/node_modules/@agentorg/hub/dist/src/router.d.ts +9 -58
  26. package/dist/node_modules/@agentorg/hub/dist/src/router.js +41 -414
  27. package/dist/node_modules/@agentorg/hub/dist/src/state.d.ts +17 -317
  28. package/dist/node_modules/@agentorg/hub/dist/src/state.js +42 -536
  29. package/dist/node_modules/@agentorg/hub/dist/src/validate.d.ts +1 -3
  30. package/dist/node_modules/@agentorg/hub/dist/src/validate.js +19 -17
  31. package/dist/node_modules/@agentorg/hub/package.json +0 -3
  32. package/dist/node_modules/@agentorg/interfaces/dist/src/agent-provider.d.ts +119 -0
  33. package/dist/node_modules/@agentorg/interfaces/dist/src/agent-provider.js +96 -0
  34. package/dist/node_modules/@agentorg/interfaces/dist/src/agent-settings.d.ts +42 -0
  35. package/dist/node_modules/@agentorg/interfaces/dist/src/agent-settings.js +53 -0
  36. package/dist/node_modules/@agentorg/interfaces/dist/src/chat.d.ts +93 -38
  37. package/dist/node_modules/@agentorg/interfaces/dist/src/chat.js +71 -22
  38. package/dist/node_modules/@agentorg/interfaces/dist/src/connection.d.ts +36 -0
  39. package/dist/node_modules/@agentorg/interfaces/dist/src/connection.js +31 -0
  40. package/dist/node_modules/@agentorg/interfaces/dist/src/folders.d.ts +19 -0
  41. package/dist/node_modules/@agentorg/interfaces/dist/src/folders.js +25 -0
  42. package/dist/node_modules/@agentorg/interfaces/dist/src/hub.d.ts +16 -286
  43. package/dist/node_modules/@agentorg/interfaces/dist/src/hub.js +17 -159
  44. package/dist/node_modules/@agentorg/interfaces/dist/src/index.d.ts +9 -9
  45. package/dist/node_modules/@agentorg/interfaces/dist/src/index.js +9 -9
  46. package/dist/node_modules/@agentorg/interfaces/dist/src/kv.d.ts +2 -2
  47. package/dist/node_modules/@agentorg/interfaces/dist/src/kv.js +2 -2
  48. package/dist/node_modules/@agentorg/interfaces/dist/src/llm-session.d.ts +2 -0
  49. package/dist/node_modules/@agentorg/interfaces/dist/src/llm-session.js +2 -1
  50. package/dist/node_modules/@agentorg/interfaces/dist/src/manager.d.ts +626 -0
  51. package/dist/node_modules/@agentorg/interfaces/dist/src/manager.js +349 -0
  52. package/dist/node_modules/@agentorg/interfaces/dist/src/tools.d.ts +39 -0
  53. package/dist/node_modules/@agentorg/interfaces/dist/src/tools.js +43 -0
  54. package/dist/node_modules/@agentorg/interfaces/dist/src/units.d.ts +460 -0
  55. package/dist/node_modules/@agentorg/interfaces/dist/src/units.js +204 -0
  56. package/dist/node_modules/@agentorg/looper/dist/src/index.d.ts +5 -0
  57. package/dist/node_modules/@agentorg/looper/dist/src/index.js +5 -0
  58. package/dist/node_modules/@agentorg/looper/dist/src/loop.d.ts +75 -0
  59. package/dist/node_modules/@agentorg/looper/dist/src/loop.js +332 -0
  60. package/dist/node_modules/@agentorg/looper/dist/src/looper.d.ts +71 -0
  61. package/dist/node_modules/@agentorg/looper/dist/src/looper.js +282 -0
  62. package/dist/node_modules/@agentorg/looper/dist/src/record.d.ts +99 -0
  63. package/dist/node_modules/@agentorg/looper/dist/src/record.js +278 -0
  64. package/dist/node_modules/@agentorg/looper/dist/src/tools.d.ts +11 -0
  65. package/dist/node_modules/@agentorg/looper/dist/src/tools.js +42 -0
  66. package/dist/node_modules/@agentorg/looper/dist/src/types.d.ts +147 -0
  67. package/dist/node_modules/@agentorg/looper/dist/src/types.js +32 -0
  68. package/dist/node_modules/@agentorg/looper/package.json +24 -0
  69. package/dist/node_modules/@agentorg/manager/dist/src/activity.d.ts +18 -0
  70. package/dist/node_modules/@agentorg/manager/dist/src/activity.js +65 -0
  71. package/dist/node_modules/@agentorg/manager/dist/src/control.d.ts +134 -0
  72. package/dist/node_modules/@agentorg/manager/dist/src/control.js +1115 -0
  73. package/dist/node_modules/@agentorg/manager/dist/src/form.d.ts +40 -0
  74. package/dist/node_modules/@agentorg/manager/dist/src/form.js +191 -0
  75. package/dist/node_modules/@agentorg/manager/dist/src/index.d.ts +1 -0
  76. package/dist/node_modules/@agentorg/manager/dist/src/index.js +1 -0
  77. package/dist/node_modules/@agentorg/manager/dist/src/manager.d.ts +25 -0
  78. package/dist/node_modules/@agentorg/manager/dist/src/manager.js +680 -0
  79. package/dist/node_modules/@agentorg/manager/dist/src/skills.d.ts +27 -0
  80. package/dist/node_modules/@agentorg/manager/dist/src/skills.js +152 -0
  81. package/dist/node_modules/@agentorg/manager/dist/src/stack.d.ts +454 -0
  82. package/dist/node_modules/@agentorg/manager/dist/src/stack.js +917 -0
  83. package/dist/node_modules/@agentorg/manager/package.json +30 -0
  84. package/dist/node_modules/@agentorg/mcp/dist/src/connection.d.ts +34 -0
  85. package/dist/node_modules/@agentorg/mcp/dist/src/connection.js +296 -0
  86. package/dist/node_modules/@agentorg/mcp/dist/src/index.d.ts +4 -0
  87. package/dist/node_modules/@agentorg/mcp/dist/src/index.js +4 -0
  88. package/dist/node_modules/@agentorg/mcp/dist/src/kinds.d.ts +158 -0
  89. package/dist/node_modules/@agentorg/mcp/dist/src/kinds.js +164 -0
  90. package/dist/node_modules/@agentorg/mcp/dist/src/provider.d.ts +22 -0
  91. package/dist/node_modules/@agentorg/mcp/dist/src/provider.js +197 -0
  92. package/dist/node_modules/@agentorg/mcp/dist/src/public.d.ts +6 -0
  93. package/dist/node_modules/@agentorg/mcp/dist/src/public.js +72 -0
  94. package/dist/node_modules/@agentorg/mcp/package.json +31 -0
  95. package/dist/node_modules/@agentorg/sdk/dist/src/cli.js +3 -23
  96. package/dist/node_modules/@agentorg/sdk/dist/src/client.d.ts +4 -25
  97. package/dist/node_modules/@agentorg/sdk/dist/src/client.js +5 -55
  98. package/dist/node_modules/@agentorg/sdk/dist/src/errors.d.ts +1 -1
  99. package/dist/node_modules/@agentorg/sdk/dist/src/errors.js +3 -3
  100. package/dist/node_modules/@agentorg/sdk/dist/src/filled.d.ts +21 -0
  101. package/dist/node_modules/@agentorg/sdk/dist/src/filled.js +24 -0
  102. package/dist/node_modules/@agentorg/sdk/dist/src/index.d.ts +3 -2
  103. package/dist/node_modules/@agentorg/sdk/dist/src/index.js +2 -1
  104. package/dist/node_modules/@agentorg/sdk/dist/src/interface.d.ts +6 -34
  105. package/dist/node_modules/@agentorg/sdk/dist/src/interface.js +3 -24
  106. package/dist/node_modules/@agentorg/sdk/dist/src/module-host.d.ts +8 -17
  107. package/dist/node_modules/@agentorg/sdk/dist/src/module-host.js +15 -87
  108. package/dist/node_modules/@agentorg/sdk/dist/src/module.d.ts +10 -76
  109. package/dist/node_modules/@agentorg/sdk/dist/src/module.js +3 -23
  110. package/dist/node_modules/@agentorg/sdk/dist/src/person-commands.js +0 -5
  111. package/dist/node_modules/@agentorg/sdk/dist/src/runtime.d.ts +3 -27
  112. package/dist/node_modules/@agentorg/sdk/dist/src/runtime.js +5 -100
  113. package/dist/node_modules/@agentorg/sdk/dist/src/testing.d.ts +7 -8
  114. package/dist/node_modules/@agentorg/sdk/dist/src/testing.js +12 -24
  115. package/dist/node_modules/@agentorg/sdk/package.json +4 -37
  116. package/dist/node_modules/@agentorg/shell/dist/app.css +4624 -739
  117. package/dist/node_modules/@agentorg/shell/dist/app.js +245 -202
  118. package/dist/node_modules/@agentorg/shell/package.json +23 -10
  119. package/dist/node_modules/@agentorg/wire/dist/src/frames.d.ts +2 -3
  120. package/dist/node_modules/@agentorg/wire/dist/src/frames.js +2 -3
  121. package/dist/node_modules/@agentorg/wire/dist/src/ops.d.ts +5 -34
  122. package/dist/node_modules/@agentorg/wire/dist/src/ops.js +2 -17
  123. package/dist/node_modules/assistant/dist/src/chats.d.ts +92 -0
  124. package/dist/node_modules/assistant/dist/src/chats.js +357 -0
  125. package/dist/node_modules/assistant/dist/src/engine.d.ts +42 -0
  126. package/dist/node_modules/assistant/dist/src/engine.js +160 -0
  127. package/dist/node_modules/assistant/dist/src/local-store.d.ts +3 -0
  128. package/dist/node_modules/assistant/dist/src/local-store.js +58 -0
  129. package/dist/node_modules/assistant/dist/src/provider.d.ts +21 -0
  130. package/dist/node_modules/assistant/dist/src/provider.js +259 -0
  131. package/dist/node_modules/assistant/dist/src/settings.d.ts +17 -0
  132. package/dist/node_modules/assistant/dist/src/settings.js +43 -0
  133. package/dist/node_modules/assistant/dist/src/tools.d.ts +57 -0
  134. package/dist/node_modules/assistant/dist/src/tools.js +102 -0
  135. package/dist/node_modules/assistant/package.json +30 -0
  136. package/dist/node_modules/chatgpt/dist/src/account.d.ts +52 -0
  137. package/dist/node_modules/chatgpt/dist/src/account.js +270 -0
  138. package/dist/node_modules/chatgpt/dist/src/encoding.d.ts +7 -0
  139. package/dist/node_modules/chatgpt/dist/src/encoding.js +20 -0
  140. package/dist/node_modules/chatgpt/dist/src/file-store.d.ts +9 -0
  141. package/dist/node_modules/chatgpt/dist/src/file-store.js +68 -0
  142. package/dist/node_modules/chatgpt/dist/src/index.d.ts +1 -0
  143. package/dist/node_modules/chatgpt/dist/src/index.js +1 -0
  144. package/dist/node_modules/chatgpt/dist/src/jwt.d.ts +15 -0
  145. package/dist/node_modules/chatgpt/dist/src/jwt.js +37 -0
  146. package/dist/node_modules/chatgpt/dist/src/oauth.d.ts +43 -0
  147. package/dist/node_modules/chatgpt/dist/src/oauth.js +104 -0
  148. package/dist/node_modules/chatgpt/dist/src/program.d.ts +23 -0
  149. package/dist/node_modules/chatgpt/dist/src/program.js +41 -0
  150. package/dist/node_modules/chatgpt/dist/src/responses.d.ts +54 -0
  151. package/dist/node_modules/chatgpt/dist/src/responses.js +300 -0
  152. package/dist/node_modules/chatgpt/dist/src/serve.d.ts +65 -0
  153. package/dist/node_modules/chatgpt/dist/src/serve.js +46 -0
  154. package/dist/node_modules/chatgpt/package.json +33 -0
  155. package/dist/src/api.d.ts +5 -34
  156. package/dist/src/api.js +10 -68
  157. package/dist/src/cli.js +3 -7
  158. package/dist/src/folders.d.ts +2 -0
  159. package/dist/src/folders.js +45 -0
  160. package/dist/src/gateway.d.ts +13 -8
  161. package/dist/src/gateway.js +119 -296
  162. package/dist/src/index.d.ts +4 -5
  163. package/dist/src/index.js +3 -4
  164. package/dist/src/live.d.ts +17 -0
  165. package/dist/src/live.js +109 -0
  166. package/dist/src/notes.d.ts +11 -0
  167. package/dist/src/notes.js +64 -0
  168. package/dist/src/oauth.d.ts +16 -0
  169. package/dist/src/oauth.js +46 -0
  170. package/dist/src/programs.d.ts +36 -0
  171. package/dist/src/programs.js +198 -0
  172. package/dist/src/signin.d.ts +12 -3
  173. package/dist/src/signin.js +30 -6
  174. package/package.json +4 -11
  175. package/dist/bundled/index.json +0 -6
  176. package/dist/bundled/sha256-0e91cc3d0e9762b81abc2427b5496b20f383abcd6fb97d928a8d50e956b54d1f.agentorg +0 -0
  177. package/dist/bundled/sha256-1f64ca62a0209d767d6aa6c4feb50b0653d60f10bebbc301f79bd3a37e0153c1.agentorg +0 -0
  178. package/dist/bundled/sha256-4055f8fddf6b90f3d356543f554b2a9e9a2c4a8827a8774f8f87952dc1692331.agentorg +0 -0
  179. package/dist/bundled/sha256-e356ea3c1899138a8494baf521556831006f38534fa9e92ae873e7e6956c3a46.agentorg +0 -0
  180. package/dist/node_modules/@agentorg/hub/dist/src/build.d.ts +0 -17
  181. package/dist/node_modules/@agentorg/hub/dist/src/build.js +0 -120
  182. package/dist/node_modules/@agentorg/hub/dist/src/logs.d.ts +0 -33
  183. package/dist/node_modules/@agentorg/hub/dist/src/logs.js +0 -162
  184. package/dist/node_modules/@agentorg/hub/dist/src/net.d.ts +0 -41
  185. package/dist/node_modules/@agentorg/hub/dist/src/net.js +0 -265
  186. package/dist/node_modules/@agentorg/hub/dist/src/processes.d.ts +0 -78
  187. package/dist/node_modules/@agentorg/hub/dist/src/processes.js +0 -485
  188. package/dist/node_modules/@agentorg/hub/dist/src/storage.d.ts +0 -38
  189. package/dist/node_modules/@agentorg/hub/dist/src/storage.js +0 -194
  190. package/dist/node_modules/@agentorg/interfaces/dist/src/http-egress.d.ts +0 -6
  191. package/dist/node_modules/@agentorg/interfaces/dist/src/http-egress.js +0 -7
  192. package/dist/node_modules/@agentorg/interfaces/dist/src/installer.d.ts +0 -191
  193. package/dist/node_modules/@agentorg/interfaces/dist/src/installer.js +0 -136
  194. package/dist/node_modules/@agentorg/interfaces/dist/src/layout.d.ts +0 -47
  195. package/dist/node_modules/@agentorg/interfaces/dist/src/layout.js +0 -52
  196. package/dist/node_modules/@agentorg/interfaces/dist/src/rules.d.ts +0 -35
  197. package/dist/node_modules/@agentorg/interfaces/dist/src/rules.js +0 -37
  198. package/dist/node_modules/@agentorg/interfaces/dist/src/storage-admin.d.ts +0 -23
  199. package/dist/node_modules/@agentorg/interfaces/dist/src/storage-admin.js +0 -31
  200. package/dist/node_modules/@agentorg/interfaces/dist/src/ui-shell.d.ts +0 -14
  201. package/dist/node_modules/@agentorg/interfaces/dist/src/ui-shell.js +0 -26
  202. package/dist/node_modules/@agentorg/interfaces/dist/src/ui-view.d.ts +0 -27
  203. package/dist/node_modules/@agentorg/interfaces/dist/src/ui-view.js +0 -26
  204. package/dist/node_modules/@agentorg/kit/dist/src/chat.d.ts +0 -37
  205. package/dist/node_modules/@agentorg/kit/dist/src/chat.js +0 -131
  206. package/dist/node_modules/@agentorg/kit/dist/src/components.d.ts +0 -94
  207. package/dist/node_modules/@agentorg/kit/dist/src/components.js +0 -66
  208. package/dist/node_modules/@agentorg/kit/dist/src/icons.d.ts +0 -17
  209. package/dist/node_modules/@agentorg/kit/dist/src/icons.js +0 -30
  210. package/dist/node_modules/@agentorg/kit/dist/src/index.d.ts +0 -6
  211. package/dist/node_modules/@agentorg/kit/dist/src/index.js +0 -10
  212. package/dist/node_modules/@agentorg/kit/dist/src/markdown.d.ts +0 -9
  213. package/dist/node_modules/@agentorg/kit/dist/src/markdown.js +0 -14
  214. package/dist/node_modules/@agentorg/kit/dist/src/resizable.d.ts +0 -5
  215. package/dist/node_modules/@agentorg/kit/dist/src/resizable.js +0 -8
  216. package/dist/node_modules/@agentorg/kit/dist/src/styles.d.ts +0 -11
  217. package/dist/node_modules/@agentorg/kit/dist/src/styles.js +0 -166
  218. package/dist/node_modules/@agentorg/kit/package.json +0 -44
  219. package/dist/node_modules/@agentorg/sdk/dist/frame/runtime.js +0 -753
  220. package/dist/node_modules/@agentorg/sdk/dist/host/runner.js +0 -21963
  221. package/dist/node_modules/@agentorg/sdk/dist/src/build.d.ts +0 -2
  222. package/dist/node_modules/@agentorg/sdk/dist/src/build.js +0 -2
  223. package/dist/node_modules/@agentorg/sdk/dist/src/client-http.d.ts +0 -24
  224. package/dist/node_modules/@agentorg/sdk/dist/src/client-http.js +0 -247
  225. package/dist/node_modules/@agentorg/sdk/dist/src/describe.d.ts +0 -13
  226. package/dist/node_modules/@agentorg/sdk/dist/src/describe.js +0 -16
  227. package/dist/node_modules/@agentorg/sdk/dist/src/frame-base.d.ts +0 -8
  228. package/dist/node_modules/@agentorg/sdk/dist/src/frame-base.js +0 -64
  229. package/dist/node_modules/@agentorg/sdk/dist/src/frame-entry.d.ts +0 -1
  230. package/dist/node_modules/@agentorg/sdk/dist/src/frame-entry.js +0 -35
  231. package/dist/node_modules/@agentorg/sdk/dist/src/frame-host.d.ts +0 -57
  232. package/dist/node_modules/@agentorg/sdk/dist/src/frame-host.js +0 -293
  233. package/dist/node_modules/@agentorg/sdk/dist/src/frame-protocol.d.ts +0 -124
  234. package/dist/node_modules/@agentorg/sdk/dist/src/frame-protocol.js +0 -16
  235. package/dist/node_modules/@agentorg/sdk/dist/src/frame.d.ts +0 -25
  236. package/dist/node_modules/@agentorg/sdk/dist/src/frame.js +0 -248
  237. package/dist/node_modules/@agentorg/sdk/dist/src/host-main.d.ts +0 -1
  238. package/dist/node_modules/@agentorg/sdk/dist/src/host-main.js +0 -60
  239. package/dist/node_modules/@agentorg/sdk/dist/src/host.d.ts +0 -25
  240. package/dist/node_modules/@agentorg/sdk/dist/src/host.js +0 -92
  241. package/dist/node_modules/@agentorg/sdk/dist/src/manifest-api.d.ts +0 -2
  242. package/dist/node_modules/@agentorg/sdk/dist/src/manifest-api.js +0 -2
  243. package/dist/node_modules/@agentorg/sdk/dist/src/manifest.d.ts +0 -56
  244. package/dist/node_modules/@agentorg/sdk/dist/src/manifest.js +0 -165
  245. package/dist/node_modules/@agentorg/sdk/dist/src/package.d.ts +0 -60
  246. package/dist/node_modules/@agentorg/sdk/dist/src/package.js +0 -538
  247. package/dist/node_modules/@agentorg/sdk/dist/src/tar.d.ts +0 -7
  248. package/dist/node_modules/@agentorg/sdk/dist/src/tar.js +0 -71
  249. package/dist/node_modules/@agentorg/shell/dist/agent-bindings.js +0 -59
  250. package/dist/node_modules/@agentorg/shell/src/agent-bindings.ts +0 -107
  251. package/dist/src/frames.d.ts +0 -23
  252. package/dist/src/frames.js +0 -78
  253. package/dist/src/layout.d.ts +0 -44
  254. package/dist/src/layout.js +0 -90
  255. package/dist/src/model.d.ts +0 -54
  256. package/dist/src/model.js +0 -299
  257. package/dist/src/rules.d.ts +0 -71
  258. package/dist/src/rules.js +0 -157
  259. package/dist/src/transfer.d.ts +0 -30
  260. package/dist/src/transfer.js +0 -110
@@ -0,0 +1,22 @@
1
+ import { type Log } from "@agentorg/sdk";
2
+ import { type Timing } from "./connection.js";
3
+ export interface McpProviderOptions {
4
+ hubUrl: string;
5
+ /** The provider's own Actor, bound to `hub.actors@1` at its slot `actors`. */
6
+ actorId: string;
7
+ credential: string;
8
+ /** A private folder of the provider's, which holds each connection's Hub credential. */
9
+ dir: string;
10
+ log?: Log;
11
+ /** How often a server is checked, and the first wait before trying one again. For tests. */
12
+ timing?: Timing;
13
+ }
14
+ export interface McpProvider {
15
+ /** Leave the Hub and let every server go. The connections stay, and resume at the next start. */
16
+ close(): Promise<void>;
17
+ }
18
+ /**
19
+ * Run the built-in MCP provider as an Actor exporting `unit.provider@1` as `provider`. It offers two
20
+ * units, `url` and `command`; a server it starts runs with this process's rights. Connections made earlier are joined again at the start.
21
+ */
22
+ export declare function startMcpProvider(options: McpProviderOptions): Promise<McpProvider>;
@@ -0,0 +1,197 @@
1
+ import { chmodSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { hubActors, unitProvider } from "@agentorg/interfaces";
4
+ import { Refused } from "@agentorg/sdk";
5
+ import { connect } from "@agentorg/sdk/client";
6
+ import { z } from "zod";
7
+ import { Connection } from "./connection.js";
8
+ import { namedSecrets, parseConnection, targetOf, UNITS, } from "./kinds.js";
9
+ import { notPublic } from "./public.js";
10
+ /** What is kept of a connection between runs, in the provider's private file. */
11
+ const Stored = z.object({
12
+ credential: z.string(),
13
+ kind: z.string(),
14
+ params: z.record(z.string(), z.unknown()),
15
+ secrets: z.record(z.string(), z.string()),
16
+ });
17
+ const FILE = "connections.json";
18
+ /** What a unit's values come to as a connection's parameters: its name isn't one. */
19
+ const paramsOf = ({ slot: _, ...params }) => params;
20
+ const quiet = { info() { }, warn() { }, error() { } };
21
+ /**
22
+ * Run the built-in MCP provider as an Actor exporting `unit.provider@1` as `provider`. It offers two
23
+ * units, `url` and `command`; a server it starts runs with this process's rights. Connections made earlier are joined again at the start.
24
+ */
25
+ export async function startMcpProvider(options) {
26
+ const log = options.log ?? quiet;
27
+ const { hubUrl, dir } = options;
28
+ mkdirSync(dir, { recursive: true, mode: 0o700 });
29
+ chmodSync(dir, 0o700);
30
+ const path = join(dir, FILE);
31
+ /** The file, entry by entry; one that can't be read is set aside and the rest still run. */
32
+ const read = () => {
33
+ let raw;
34
+ try {
35
+ raw = readFileSync(path, "utf8");
36
+ }
37
+ catch (error) {
38
+ if (error.code === "ENOENT")
39
+ return {};
40
+ throw error;
41
+ }
42
+ const entries = z.record(z.string(), z.unknown()).safeParse((() => {
43
+ try {
44
+ return JSON.parse(raw);
45
+ }
46
+ catch {
47
+ return undefined;
48
+ }
49
+ })());
50
+ if (!entries.success) {
51
+ renameSync(path, `${path}.unreadable-${Date.now()}`);
52
+ log.error("The connections file can't be read: it is set aside and starts empty.");
53
+ return {};
54
+ }
55
+ const kept = {};
56
+ for (const [id, entry] of Object.entries(entries.data)) {
57
+ const parsed = Stored.safeParse(entry);
58
+ if (parsed.success)
59
+ kept[id] = parsed.data;
60
+ else
61
+ log.error(`Connection ${id} can't be read, and is left out.`);
62
+ }
63
+ return kept;
64
+ };
65
+ const stored = read();
66
+ const save = () => {
67
+ writeFileSync(`${path}.tmp`, JSON.stringify(stored), { mode: 0o600, flush: true });
68
+ renameSync(`${path}.tmp`, path);
69
+ };
70
+ const connections = new Map();
71
+ const open = async (actorId, credential, spec, secrets) => {
72
+ const connection = new Connection(spec, secrets, log, options.timing);
73
+ await connection.join({ hubUrl, actorId, credential });
74
+ connections.set(actorId, connection);
75
+ return connection;
76
+ };
77
+ let closing = false;
78
+ const endAll = () => Promise.all([...connections.values()].map((c) => c.end()));
79
+ const held = (id) => {
80
+ const connection = connections.get(id);
81
+ if (!connection)
82
+ throw new Refused("unknown", `This provider holds no connection ${id}.`);
83
+ return connection;
84
+ };
85
+ for (const [actorId, { credential, kind, params, secrets }] of Object.entries(stored)) {
86
+ const { spec, secrets: hidden, why } = parseConnection(kind, params, secrets);
87
+ if (!spec) {
88
+ log.error(`Connection ${actorId} can't be read: ${why}`);
89
+ continue;
90
+ }
91
+ try {
92
+ (await open(actorId, credential, spec, hidden)).run();
93
+ }
94
+ catch (error) {
95
+ log.error(`Connection ${actorId} didn't rejoin the Hub: ${String(error)}`);
96
+ // The Hub no longer knows it: its Actor was closed while the provider was away.
97
+ if (error instanceof Refused && error.code === "forbidden") {
98
+ delete stored[actorId];
99
+ save();
100
+ }
101
+ }
102
+ }
103
+ const provider = await connect({
104
+ hubUrl,
105
+ actorId: options.actorId,
106
+ credential: options.credential,
107
+ slots: { actors: hubActors },
108
+ exports: { provider: unitProvider },
109
+ log,
110
+ start(ctx) {
111
+ ctx.exports.provider.implement({
112
+ units: () => ({ units: UNITS }),
113
+ skill: () => {
114
+ throw new Refused("unknown", "These units come with no skill.");
115
+ },
116
+ check({ unit, values, secrets }) {
117
+ // Only whether a token is there matters, and a check never holds its value.
118
+ const given = secrets.includes("token") ? { token: "given" } : {};
119
+ const { why } = parseConnection(unit, paramsOf(values), given);
120
+ return { problems: why ? [{ message: why }] : [] };
121
+ },
122
+ async apply({ unit: kind, values, secrets, name }) {
123
+ const params = paramsOf(values);
124
+ const named = namedSecrets(secrets);
125
+ if (!named.secrets)
126
+ throw new Refused("invalid", named.why ?? "Its secrets don't fit.");
127
+ const { spec, secrets: hidden, why } = parseConnection(kind, params, named.secrets);
128
+ if (!spec)
129
+ throw new Refused("invalid", why);
130
+ // Said now, as well as at each request.
131
+ const away = spec.kind === "url" && spec.public ? await notPublic(spec.url) : undefined;
132
+ if (away)
133
+ throw new Refused("invalid", away);
134
+ const { actorId, credential } = await ctx.slots.actors.call.create({ name });
135
+ let connection;
136
+ try {
137
+ connection = await open(actorId, credential, spec, hidden);
138
+ if (closing)
139
+ throw new Refused("unavailable", "This provider is stopping.");
140
+ stored[actorId] = { credential: credential, kind, params, secrets: hidden };
141
+ save();
142
+ connection.run();
143
+ }
144
+ catch (error) {
145
+ connections.delete(actorId);
146
+ delete stored[actorId];
147
+ await connection?.end();
148
+ await ctx.slots.actors.call.close({ actorId }).catch(() => { });
149
+ throw error;
150
+ }
151
+ // The instance is the connection: one made before units had no other id.
152
+ return {
153
+ instance: actorId,
154
+ connections: [
155
+ { slot: String(values.slot), connection: actorId, target: targetOf(spec) },
156
+ ],
157
+ results: [],
158
+ };
159
+ },
160
+ async status({ instance }) {
161
+ const status = await held(instance).status();
162
+ return {
163
+ state: status.state,
164
+ ...(status.detail ? { detail: status.detail } : {}),
165
+ connections: [{ ...status, connection: instance }],
166
+ };
167
+ },
168
+ live: () => {
169
+ throw new Refused("unknown", "A connection has nothing to open live.");
170
+ },
171
+ async remove({ instance: connection }) {
172
+ const found = held(connection);
173
+ await ctx.slots.actors.call.close({ actorId: connection });
174
+ connections.delete(connection);
175
+ delete stored[connection];
176
+ try {
177
+ save();
178
+ }
179
+ finally {
180
+ await found.end();
181
+ }
182
+ return {};
183
+ },
184
+ });
185
+ },
186
+ }).catch(async (error) => {
187
+ await endAll();
188
+ throw error;
189
+ });
190
+ return {
191
+ async close() {
192
+ closing = true;
193
+ await endAll();
194
+ provider.close();
195
+ },
196
+ };
197
+ }
@@ -0,0 +1,6 @@
1
+ /** Whether an IP address is one anyone on the internet could reach. */
2
+ export declare function isPublicAddress(address: string): boolean;
3
+ /** Why an address isn't a public https one, or nothing when it is. */
4
+ export declare function notPublic(url: string): Promise<string | undefined>;
5
+ /** A fetch for a public server: it checks where each request goes, and never follows a redirect. */
6
+ export declare const publicFetch: typeof fetch;
@@ -0,0 +1,72 @@
1
+ // An address on the public internet, and a fetch that reaches nothing else: not this machine, not
2
+ // its network, and no redirect, which could lead anywhere.
3
+ import { lookup } from "node:dns/promises";
4
+ import { BlockList, isIP } from "node:net";
5
+ const NOT_PUBLIC = new BlockList();
6
+ for (const [address, prefix] of [
7
+ ["0.0.0.0", 8],
8
+ ["10.0.0.0", 8],
9
+ ["100.64.0.0", 10],
10
+ ["127.0.0.0", 8],
11
+ ["169.254.0.0", 16],
12
+ ["172.16.0.0", 12],
13
+ ["192.0.0.0", 24],
14
+ ["192.0.2.0", 24],
15
+ ["192.168.0.0", 16],
16
+ ["198.18.0.0", 15],
17
+ ["198.51.100.0", 24],
18
+ ["203.0.113.0", 24],
19
+ ["224.0.0.0", 4],
20
+ ["240.0.0.0", 4],
21
+ ])
22
+ NOT_PUBLIC.addSubnet(address, prefix, "ipv4");
23
+ for (const [address, prefix] of [
24
+ ["::", 128],
25
+ ["::1", 128],
26
+ ["64:ff9b::", 96],
27
+ ["64:ff9b:1::", 48],
28
+ ["100::", 64],
29
+ ["2001:db8::", 32],
30
+ ["fc00::", 7],
31
+ ["fe80::", 10],
32
+ ["ff00::", 8],
33
+ ])
34
+ NOT_PUBLIC.addSubnet(address, prefix, "ipv6");
35
+ /** Whether an IP address is one anyone on the internet could reach. */
36
+ export function isPublicAddress(address) {
37
+ const family = isIP(address);
38
+ if (family === 0)
39
+ return false;
40
+ // An IPv4 address written as IPv6 is the IPv4 address.
41
+ const mapped = /^::ffff:(\d+\.\d+\.\d+\.\d+)$/i.exec(address)?.[1];
42
+ if (mapped)
43
+ return isPublicAddress(mapped);
44
+ return !NOT_PUBLIC.check(address, family === 4 ? "ipv4" : "ipv6");
45
+ }
46
+ /** Why an address isn't a public https one, or nothing when it is. */
47
+ export async function notPublic(url) {
48
+ if (!URL.canParse(url))
49
+ return "That isn't an address.";
50
+ const { protocol, hostname } = new URL(url);
51
+ if (protocol !== "https:")
52
+ return "Only an https address can be used.";
53
+ const host = hostname.replace(/^\[|\]$/g, "");
54
+ let addresses;
55
+ try {
56
+ addresses = isIP(host) ? [host] : (await lookup(host, { all: true })).map((one) => one.address);
57
+ }
58
+ catch {
59
+ return `${hostname} can't be found.`;
60
+ }
61
+ return addresses.length && addresses.every(isPublicAddress)
62
+ ? undefined
63
+ : `${hostname} isn't on the public internet.`;
64
+ }
65
+ /** A fetch for a public server: it checks where each request goes, and never follows a redirect. */
66
+ export const publicFetch = async (input, init) => {
67
+ const url = input instanceof Request ? input.url : String(input);
68
+ const why = await notPublic(url);
69
+ if (why)
70
+ throw new Error(why);
71
+ return fetch(input, { ...init, redirect: "error" });
72
+ };
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@agentorg/mcp",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "description": "The built-in MCP provider: each connection to an MCP server is an Actor offering tools@1",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/src/index.d.ts",
11
+ "default": "./dist/src/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist/src"
16
+ ],
17
+ "scripts": {
18
+ "build": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\" && tsc -p tsconfig.json",
19
+ "test": "node --test \"dist/test/**/*.test.js\""
20
+ },
21
+ "dependencies": {
22
+ "@agentorg/interfaces": "0.0.0",
23
+ "@agentorg/sdk": "0.0.0",
24
+ "@modelcontextprotocol/client": "2.4.0",
25
+ "zod": "^4.6.7"
26
+ },
27
+ "devDependencies": {
28
+ "@agentorg/hub": "0.0.0",
29
+ "@modelcontextprotocol/server": "2.4.0"
30
+ }
31
+ }
@@ -8,22 +8,19 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
8
8
  return path;
9
9
  };
10
10
  import { chmodSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
11
- import { join, relative } from "node:path";
11
+ import { join } from "node:path";
12
12
  import { parseArgs } from "node:util";
13
13
  import { openChannel } from "./client.js";
14
14
  import { NotConnected, OutcomeUnknown, Refused } from "./errors.js";
15
- import { BuildError, buildPackage } from "./package.js";
16
15
  import { hubHome, personCall, UsageError } from "./person-commands.js";
17
16
  const USAGE = `Usage: agentorg <command> [--home DIR]
18
17
 
19
- build [package-dir] build a package into a .agentorg archive
20
18
  hub [--port N] run a Hub, serving on loopback
21
- add <file.agentorg> hub.packages.add
22
19
  actors | bindings | exports | audit each one's list
23
20
  bind <consumer.slot> <provider.export> hub.grants.bind
24
21
  call <slot> <method> [json] call one of the person's slots
25
22
 
26
- Commands other than build and hub act as the person, with the Hub home's person-credential.
23
+ Commands other than hub act as the person, with the Hub home's person-credential.
27
24
  The home is --home, else $AGENTORG_HUB_HOME, else
28
25
  $XDG_DATA_HOME/agentorg, else ~/.local/share/agentorg.
29
26
  `;
@@ -56,21 +53,6 @@ if (values.help) {
56
53
  process.exit(0);
57
54
  }
58
55
  const home = hubHome(values.home);
59
- async function build() {
60
- try {
61
- const built = await buildPackage(rest[0] ?? ".");
62
- write(process.stdout, `${built.manifest.name}@${built.manifest.version} ${built.hash}\n${relative(process.cwd(), built.file)}`);
63
- }
64
- catch (error) {
65
- // A BuildError says what to fix; anything else is a bug, so its stack is shown.
66
- write(process.stderr, error instanceof BuildError
67
- ? error.message
68
- : error instanceof Error
69
- ? (error.stack ?? error.message)
70
- : String(error));
71
- process.exit(1);
72
- }
73
- }
74
56
  /** Run a Hub in the home, and leave its address in `<home>/url` for the other commands. */
75
57
  async function hub() {
76
58
  if (values.port !== undefined && !/^\d{1,5}$/.test(values.port))
@@ -178,9 +160,7 @@ catch (error) {
178
160
  throw error;
179
161
  usage(error.message);
180
162
  }
181
- if (command === "build")
182
- await build();
183
- else if (command === "hub")
163
+ if (command === "hub")
184
164
  await hub();
185
165
  else if (call)
186
166
  await asPerson(call.slot, call.method, call.input);
@@ -1,6 +1,6 @@
1
1
  import { type Header, type WireError } from "@agentorg/wire";
2
2
  import { type DescribedInterface, type Interface } from "./interface.js";
3
- import { type Context, type Duplex, type ExportMap, type InterfaceMap, type Log } from "./module.js";
3
+ import { type Context, type ExportMap, type InterfaceMap, type Log } from "./module.js";
4
4
  /** A stream the Hub opens toward this Actor's exports, naming the export and who is calling. */
5
5
  export type Serve = Extract<Header, {
6
6
  op: "serve";
@@ -10,25 +10,11 @@ export interface ServeHandlers {
10
10
  call(serve: Serve, input: unknown): Promise<unknown>;
11
11
  /** Start sending an export's events; `end` stops them from this side. Returns how to stop. */
12
12
  subscribe(serve: Serve, send: (payload: unknown) => void, end: (error?: unknown) => void): () => void;
13
- /** Check that the export takes the stream (throwing a refusal if not), then return what runs it. */
14
- accept(serve: Serve): (stream: Duplex) => Promise<void>;
15
- /** The same for an `http` export: the stream carries HTTP/1.1 once accepted. */
16
- serveHttp(serve: Serve): (stream: Duplex) => Promise<void>;
17
13
  }
18
- /**
19
- * Where the channel goes: the Hub's WebSocket address with the Actor's credential, or a pipe the
20
- * Hub made for this Actor's process, whose hello needs no credential.
21
- */
22
- export type ChannelOptions = ChannelBase & ({
14
+ export interface ChannelOptions {
15
+ /** The Hub's WebSocket address. */
23
16
  hubUrl: string;
24
17
  credential: string;
25
- channel?: never;
26
- } | {
27
- channel: Duplex;
28
- hubUrl?: never;
29
- credential?: never;
30
- });
31
- interface ChannelBase {
32
18
  actorId: string;
33
19
  /**
34
20
  * Whether this channel may replace one the Actor already has (the default). With `false`, a
@@ -76,12 +62,6 @@ export interface Channel {
76
62
  call(slot: string, method: string, value: unknown): Promise<unknown>;
77
63
  /** Events from a slot's provider until it ends (`onEnd`) or is stopped; returns how to stop. */
78
64
  subscribe(slot: string, event: string, onEvent: (payload: unknown) => void, onEnd?: (error?: Error) => void): () => void;
79
- open(slot: string, params: unknown): Promise<Duplex>;
80
- /** A stream to an `http` slot's provider, carrying HTTP/1.1 once it accepts. */
81
- http(slot: string): Promise<Duplex>;
82
- /** Offer and withdraw run-time exports; they reach the Hub in the order they were made. */
83
- offer(name: string, iface: DescribedInterface): Promise<void>;
84
- withdraw(name: string): Promise<void>;
85
65
  close(): void;
86
66
  /** Settles when the channel ends. */
87
67
  readonly closed: Promise<void>;
@@ -128,8 +108,7 @@ type None = Record<never, Interface>;
128
108
  * `start`, and use slots from `onBind`. `start` runs before the channel opens, so the Hub never
129
109
  * reaches an export before it is implemented. A slot is bound when the Hub says so; `onBind` runs
130
110
  * when it becomes usable (bound, or its provider back), and `on` handlers subscribe while it is
131
- * usable. `exports.add` and `withdraw()` offer and withdraw over the channel. `http` slots and
132
- * exports speak HTTP/1.1 over the Hub's stream, one request per stream, with `node:http`.
111
+ * usable.
133
112
  */
134
113
  export declare function connect<const S extends InterfaceMap = None, const X extends ExportMap = None>(options: ConnectOptions<S, X>): Promise<Client<S, X>>;
135
114
  export {};
@@ -57,9 +57,7 @@ export async function openChannel(options) {
57
57
  ready = resolve;
58
58
  });
59
59
  try {
60
- const bytes = options.channel !== undefined
61
- ? options.channel
62
- : await webSocketChannel(new WebSocket(options.hubUrl));
60
+ const bytes = await webSocketChannel(new WebSocket(options.hubUrl));
63
61
  session = new Session(bytes, {
64
62
  client: true,
65
63
  onStream(stream) {
@@ -73,7 +71,7 @@ export async function openChannel(options) {
73
71
  });
74
72
  }
75
73
  catch {
76
- throw new NotConnected(`the Hub at ${options.hubUrl ?? "its pipe"}`);
74
+ throw new NotConnected(`the Hub at ${options.hubUrl}`);
77
75
  }
78
76
  async function serveStream(header, stream, reader) {
79
77
  if (header.op === "slot") {
@@ -119,14 +117,6 @@ export async function openChannel(options) {
119
117
  }
120
118
  if (header.kind === "subscribe")
121
119
  return subscribeStream(handlers, header, stream);
122
- if (header.kind === "open" || header.kind === "http") {
123
- const run = header.kind === "open" ? handlers.accept(header) : handlers.serveHttp(header);
124
- const writer = stream.writable.getWriter();
125
- await writer.write(encodeFrame(result({})));
126
- writer.releaseLock();
127
- // Accepted: from here the stream is raw bytes, so a failing handler can only reset it.
128
- return await run({ readable: reader.rest(), writable: stream.writable }).catch(() => stream.reset());
129
- }
130
120
  return stream.reset();
131
121
  }
132
122
  catch (error) {
@@ -195,7 +185,7 @@ export async function openChannel(options) {
195
185
  const hello = await exchange({
196
186
  op: "hello",
197
187
  actorId: options.actorId,
198
- ...(options.credential === undefined ? {} : { credential: options.credential }),
188
+ credential: options.credential,
199
189
  ...(options.declares ? { declares: options.declares } : {}),
200
190
  ...(options.replace === false ? { replace: false } : {}),
201
191
  }, "the Hub");
@@ -213,13 +203,6 @@ export async function openChannel(options) {
213
203
  throw new Refused("bad_output", "The Hub's answer isn't a result.");
214
204
  return body.result;
215
205
  };
216
- // Offers and withdrawals go one at a time, so the Hub sees them in the order they were made.
217
- let changes = Promise.resolve();
218
- const inOrder = (work) => {
219
- const next = changes.then(work, work);
220
- changes = next.catch(() => { });
221
- return next;
222
- };
223
206
  const closed = session.closed.then(() => {
224
207
  ended = true;
225
208
  bound.clear();
@@ -274,41 +257,9 @@ export async function openChannel(options) {
274
257
  stream.reset();
275
258
  };
276
259
  },
277
- open: (slot, params) => splice({ op: "open", slot, params }, slot),
278
- http: (slot) => splice({ op: "http", slot }, slot),
279
- offer: (name, iface) => inOrder(async () => {
280
- answered(await exchange({ op: "offer", name, interface: iface }, name), name);
281
- }),
282
- withdraw: (name) => inOrder(async () => {
283
- answered(await exchange({ op: "withdraw", name }, name), name);
284
- }),
285
260
  close: () => session.close(),
286
261
  closed,
287
262
  };
288
- /** Open a raw stream: send its header, read the one body that answers, then hand over the bytes. */
289
- async function splice(header, slot) {
290
- let stream;
291
- try {
292
- stream = session.open();
293
- const writer = stream.writable.getWriter();
294
- await writer.write(encodeFrame(header));
295
- writer.releaseLock();
296
- const reader = new FrameReader(stream.readable);
297
- const first = await reader.next();
298
- if (first === undefined)
299
- throw new NotConnected(slot);
300
- answered(parseBody(first), slot);
301
- return { readable: reader.rest(), writable: stream.writable };
302
- }
303
- catch (error) {
304
- stream?.reset();
305
- if (error instanceof Refused ||
306
- error instanceof NotConnected ||
307
- error instanceof OutcomeUnknown)
308
- throw error;
309
- throw new NotConnected(slot);
310
- }
311
- }
312
263
  }
313
264
  const quiet = { info() { }, warn() { }, error() { } };
314
265
  /**
@@ -317,8 +268,7 @@ const quiet = { info() { }, warn() { }, error() { } };
317
268
  * `start`, and use slots from `onBind`. `start` runs before the channel opens, so the Hub never
318
269
  * reaches an export before it is implemented. A slot is bound when the Hub says so; `onBind` runs
319
270
  * when it becomes usable (bound, or its provider back), and `on` handlers subscribe while it is
320
- * usable. `exports.add` and `withdraw()` offer and withdraw over the channel. `http` slots and
321
- * exports speak HTTP/1.1 over the Hub's stream, one request per stream, with `node:http`.
271
+ * usable.
322
272
  */
323
273
  export async function connect(options) {
324
274
  const slots = (options.slots ?? {});
@@ -326,7 +276,7 @@ export async function connect(options) {
326
276
  const log = options.log ?? quiet;
327
277
  // defineActor checks the names, as it does for a module.
328
278
  const definition = defineActor({ slots, exports, start: options.start ?? (() => { }) });
329
- const host = new ModuleHost("", slots, log);
279
+ const host = new ModuleHost(slots, log);
330
280
  const runtime = createRuntime(definition, {
331
281
  self: { actorId: options.actorId, module: "client" },
332
282
  log,
@@ -1,4 +1,4 @@
1
- /** A call on a slot that no export is bound to, or on an export that was withdrawn. */
1
+ /** A call on a slot that no export is bound to. */
2
2
  export declare class NotConnected extends Error {
3
3
  static [Symbol.hasInstance](value: unknown): boolean;
4
4
  readonly name = "NotConnected";
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Marks an SDK error class's prototype with its name. A package's bundles and the runner each carry
3
- * their own copy of the SDK, so `instanceof` on these three classes checks this mark rather than
2
+ * Marks an SDK error class's prototype with its name. Programs may carry their own copy of the SDK,
3
+ * so `instanceof` on these three classes checks this mark rather than
4
4
  * the class, and an error made by one copy is the same error to the other. A subclass is checked
5
5
  * as usual.
6
6
  */
@@ -12,7 +12,7 @@ const instanceOf = (asked, base, name, value) =>
12
12
  asked === base
13
13
  ? isBranded(value, name)
14
14
  : Function.prototype[Symbol.hasInstance].call(asked, value);
15
- /** A call on a slot that no export is bound to, or on an export that was withdrawn. */
15
+ /** A call on a slot that no export is bound to. */
16
16
  export class NotConnected extends Error {
17
17
  static [Symbol.hasInstance](value) {
18
18
  // biome-ignore lint/complexity/noThisInStatic: `this` is the class instanceof was asked about, a subclass included.
@@ -0,0 +1,21 @@
1
+ /** One field of a unit's form, as far as the reader needs it. */
2
+ interface FormField {
3
+ id: string;
4
+ value: "string" | "number" | "boolean" | "strings" | "secret";
5
+ }
6
+ type Value = string | number | boolean | string[];
7
+ /**
8
+ * What a unit's logic reads of what was filled in, by field id, one method per value kind. It has
9
+ * already been settled: checked against the form, defaults applied, a field not shown absent. The
10
+ * logic can't tell who filled it. Asking for a field the form doesn't have, or as the wrong kind,
11
+ * throws at once: that is a mistake in the unit, not in what was filled.
12
+ */
13
+ export declare function filled(form: readonly FormField[], values: Readonly<Record<string, Value>>, secrets?: Readonly<Record<string, string>>): {
14
+ string: (id: string) => string | undefined;
15
+ number: (id: string) => number | undefined;
16
+ boolean: (id: string) => boolean | undefined;
17
+ strings: (id: string) => string[] | undefined;
18
+ /** Read the same way, and kept apart: only `apply` has them. */
19
+ secret: (id: string) => string | undefined;
20
+ };
21
+ export {};
@@ -0,0 +1,24 @@
1
+ /**
2
+ * What a unit's logic reads of what was filled in, by field id, one method per value kind. It has
3
+ * already been settled: checked against the form, defaults applied, a field not shown absent. The
4
+ * logic can't tell who filled it. Asking for a field the form doesn't have, or as the wrong kind,
5
+ * throws at once: that is a mistake in the unit, not in what was filled.
6
+ */
7
+ export function filled(form, values, secrets = {}) {
8
+ const read = (id, kind) => {
9
+ const field = form.find((one) => one.id === id);
10
+ if (!field)
11
+ throw new TypeError(`This unit's form has no field ${id}.`);
12
+ if (field.value !== kind)
13
+ throw new TypeError(`${id} holds a ${field.value}, not a ${kind}.`);
14
+ return (kind === "secret" ? secrets[id] : values[id]);
15
+ };
16
+ return {
17
+ string: (id) => read(id, "string"),
18
+ number: (id) => read(id, "number"),
19
+ boolean: (id) => read(id, "boolean"),
20
+ strings: (id) => read(id, "strings"),
21
+ /** Read the same way, and kept apart: only `apply` has them. */
22
+ secret: (id) => read(id, "secret"),
23
+ };
24
+ }
@@ -1,4 +1,5 @@
1
1
  export { canonicalJson, hashOf, sha256 } from "./canonical.js";
2
2
  export { NotConnected, OutcomeUnknown, Refused, type RefusedCode } from "./errors.js";
3
- export { compareInterfaces, type DescribedInterface, defineInterface, describeInterface, type EventSpec, type Events, event, type HttpInterface, hashInterface, type Interface, type InterfaceSchemas, interfaceId, type JsonSchema, type MethodSpec, type Methods, method, normalizeSchema, type RpcInterface, type StreamInterface, } from "./interface.js";
4
- export { type CallInfo, type Context, type Duplex, defineActor, defineWidget, type EmitOptions, type Export, type ExportMap, type ExposedSlot, type FrameRoot, type Handlers, type HttpExport, type HttpSlot, type InterfaceMap, isFrameInterface, isModuleDefinition, type Log, MODULE, type ModuleDefinition, type ModuleSpec, type Placement, type RpcExport, type RpcSlot, type Slot, type StreamExport, type StreamSlot, type ViewExport, } from "./module.js";
3
+ export { filled } from "./filled.js";
4
+ export { compareInterfaces, type DescribedInterface, defineInterface, describeInterface, type EventSpec, type Events, event, hashInterface, type Interface, type InterfaceSchemas, interfaceId, type JsonSchema, type MethodSpec, type Methods, method, normalizeSchema, type RpcInterface, } from "./interface.js";
5
+ export { type CallInfo, type Context, defineActor, type EmitOptions, type Export, type ExportMap, type ExposedSlot, type Handlers, type InterfaceMap, type Log, type ModuleDefinition, type ModuleSpec, type RpcExport, type RpcSlot, type Slot, } from "./module.js";
@@ -1,4 +1,5 @@
1
1
  export { canonicalJson, hashOf, sha256 } from "./canonical.js";
2
2
  export { NotConnected, OutcomeUnknown, Refused } from "./errors.js";
3
+ export { filled } from "./filled.js";
3
4
  export { compareInterfaces, defineInterface, describeInterface, event, hashInterface, interfaceId, method, normalizeSchema, } from "./interface.js";
4
- export { defineActor, defineWidget, isFrameInterface, isModuleDefinition, MODULE, } from "./module.js";
5
+ export { defineActor, } from "./module.js";