@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
@@ -1,78 +0,0 @@
1
- import type { Duplex } from "@agentorg/sdk";
2
- import type { ChannelHandle } from "./router.js";
3
- import type { HubState } from "./state.js";
4
- /** Whether this machine can run host processes now, and if not, why and what to do. */
5
- export interface HostStatus {
6
- available: boolean;
7
- reason?: string;
8
- }
9
- export interface ProcessOptions {
10
- /**
11
- * The sandbox a host process runs in: the command and arguments put before `node …`. By default,
12
- * `sandbox-exec` on macOS and `unshare` on Linux; tests may give another (one that fails, say).
13
- */
14
- sandbox?: string[];
15
- /** Heap limit of each process, in MB. */
16
- memoryMb?: number;
17
- /** How long a process has to say hello. */
18
- helloMs?: number;
19
- /** How long `stop` waits after SIGTERM before SIGKILL. */
20
- stopMs?: number;
21
- /** The first restart's delay after a crash; each next one doubles, up to `maxBackoffMs`. */
22
- backoffMs?: number;
23
- maxBackoffMs?: number;
24
- /** Up this long, a process's next crash starts the backoff over. */
25
- resetAfterMs?: number;
26
- }
27
- /**
28
- * The sandbox command for a process that may read `paths`: on macOS, sandbox-exec with the
29
- * profile; on Linux, a user, network, PID and mount namespace (no network or DNS, no other process
30
- * to signal) with the minimal root above, built on `rootDir`. Root inside the namespace is nobody
31
- * outside it (--map-root-user: util-linux before 2.38 lacks --map-current-user).
32
- */
33
- export declare function defaultSandbox(rootDir: string, paths: string[]): string[] | undefined;
34
- /**
35
- * This user's root folder for the Linux sandbox, made if missing (0700). Only one that is a real
36
- * folder, owned by this user and closed to others, is used: another user could make the path
37
- * first.
38
- */
39
- export declare function rootFolder(): {
40
- path: string;
41
- } | {
42
- problem: string;
43
- };
44
- /**
45
- * The Hub's host processes: one per running package Actor, spawned under Node's permission model
46
- * inside the OS sandbox, with an empty environment and the channel on fd 3. A process that exits
47
- * without `stop` asking is a crash: it is restarted after a backoff while its Actor is `running`.
48
- */
49
- export declare class Processes {
50
- #private;
51
- constructor(state: HubState, accept: (channel: Duplex, admitted: {
52
- actorId: string;
53
- }) => ChannelHandle, options?: ProcessOptions);
54
- /** The last probe's answer; none before the first. */
55
- get status(): HostStatus | undefined;
56
- /**
57
- * Run the sandbox once, around `node -e 0`, and keep what it says. A change is audited, and once
58
- * the host is available, Actors recorded as `running` without a process are started.
59
- */
60
- /** The sandbox command for a process that may read `paths`; none where there is no sandbox. */
61
- /**
62
- * The OS sandbox command for a process that may read `paths`, as host processes run: for the
63
- * Hub's build too, which runs untrusted source to read its modules' definitions.
64
- */
65
- sandboxCommand(paths: string[]): string[] | undefined;
66
- probe(): Promise<HostStatus>;
67
- /**
68
- * Spawn an Actor's process, unless it has one (or one restarting). One still stopping is let go
69
- * first; then a process is spawned if the Actor is still `running`.
70
- */
71
- start(actorId: string): void;
72
- /** Stop an Actor's process: SIGTERM, then SIGKILL after the grace; a waiting restart is dropped. */
73
- stop(actorId: string): Promise<void>;
74
- /** Refused unless host processes can start here: the probe runs again first. */
75
- ready(): Promise<void>;
76
- /** The Hub is closing: every process is killed, stops in flight are settled, nothing restarts. */
77
- close(): void;
78
- }
@@ -1,485 +0,0 @@
1
- import { execFile, spawn } from "node:child_process";
2
- import { lstatSync, mkdirSync, realpathSync } from "node:fs";
3
- import { tmpdir } from "node:os";
4
- import { join } from "node:path";
5
- import { Duplex as NodeDuplex } from "node:stream";
6
- import { fileURLToPath } from "node:url";
7
- import { Refused } from "@agentorg/sdk";
8
- import { appendLogs, outputEntry } from "./logs.js";
9
- /**
10
- * No network (DNS included) and no signals to other processes. Files, child processes and workers
11
- * are closed by Node's permission model inside it.
12
- */
13
- const MAC_PROFILE = `(version 1)
14
- (allow default)
15
- (deny network*)
16
- (deny mach-lookup (global-name "com.apple.mDNSResponder") (global-name "com.apple.dnssd.service"))
17
- (deny signal)
18
- (allow signal (target self))`;
19
- /**
20
- * Run inside the Linux namespaces, before node: build a root that holds only the command (node),
21
- * its libraries, the given paths, four devices and a fresh /proc, all read-only; pivot into it,
22
- * and detach the host's root, so no host path is visible at all. Its arguments: the empty
23
- * directory to build the root on, the paths to bind, `--`, then the command. It starts with an
24
- * empty environment, and the command gets one too.
25
- */
26
- const LINUX_ROOT = `set -e
27
- PATH=/usr/sbin:/usr/bin:/sbin:/bin
28
- root="$1"; shift
29
- mount -t tmpfs -o mode=0755 sandbox "$root"
30
- # One host path into the root, at its own place, read-only; a path already there is skipped.
31
- bind() {
32
- [ -e "$root$1" ] && return 0
33
- if [ -d "$1" ]; then mkdir -p "$root$1"; else mkdir -p "$root\${1%/*}"; : > "$root$1"; fi
34
- mount --bind "$1" "$root$1"
35
- mount -o remount,bind,ro "$root$1"
36
- }
37
- while [ "$1" != "--" ]; do bind "$1"; shift; done
38
- shift
39
- # The command and what it loads: its loader by its own path, its libraries after "=>".
40
- bind "$1"
41
- ldd "$1" 2>/dev/null | awk '/=>/ && index($3, "/") == 1 {print $3} !/=>/ && index($1, "/") == 1 {print $1}' |
42
- while IFS= read -r lib; do bind "$lib"; done
43
- for device in null zero random urandom; do bind "/dev/$device"; done
44
- mkdir "$root/proc" "$root/.old"
45
- mount -t proc -o ro proc "$root/proc"
46
- # umount runs once more after the pivot, from the old root, through its own loader and libraries.
47
- umount_bin=$(readlink -f "$(command -v umount)")
48
- umount_loader=$(ldd "$umount_bin" 2>/dev/null | awk '!/=>/ && index($1, "/") == 1 {print $1}')
49
- if [ -n "$umount_loader" ]; then umount_loader=$(readlink -f "$umount_loader"); fi
50
- umount_libs=$(ldd "$umount_bin" 2>/dev/null | awk '/=>/ && index($3, "/") == 1 {print $3}' |
51
- while IFS= read -r lib; do lib=$(readlink -f "$lib"); printf '/.old%s:' "\${lib%/*}"; done)
52
- # Read-only as a mount (a superblock remount is refused in some kernels' user namespaces).
53
- mount -o remount,bind,ro "$root"
54
- cd "$root"
55
- pivot_root . .old
56
- if [ -n "$umount_loader" ]; then
57
- "/.old$umount_loader" --library-path "$umount_libs" "/.old$umount_bin" -l /.old
58
- else
59
- "/.old$umount_bin" -l /.old
60
- fi
61
- cd /
62
- unset PATH PWD OLDPWD SHLVL
63
- # bash (/bin/sh on some distributions) puts SHLVL back on exec unless told to clear everything.
64
- if [ -n "$BASH_VERSION" ]; then exec -c "$@"; fi
65
- exec "$@"`;
66
- /**
67
- * The sandbox command for a process that may read `paths`: on macOS, sandbox-exec with the
68
- * profile; on Linux, a user, network, PID and mount namespace (no network or DNS, no other process
69
- * to signal) with the minimal root above, built on `rootDir`. Root inside the namespace is nobody
70
- * outside it (--map-root-user: util-linux before 2.38 lacks --map-current-user).
71
- */
72
- export function defaultSandbox(rootDir, paths) {
73
- if (process.platform === "darwin")
74
- return ["sandbox-exec", "-p", MAC_PROFILE];
75
- if (process.platform === "linux")
76
- return [
77
- "unshare",
78
- "--user",
79
- "--map-root-user",
80
- "--net",
81
- "--pid",
82
- "--fork",
83
- "--kill-child",
84
- "--mount",
85
- "--propagation",
86
- "private",
87
- "/bin/sh",
88
- "-c",
89
- LINUX_ROOT,
90
- "sandbox",
91
- rootDir,
92
- ...paths,
93
- "--",
94
- ];
95
- return undefined;
96
- }
97
- /** Why host processes can't start on this machine, said so the person knows what to do. */
98
- function unavailable(detail) {
99
- const what = detail ? ` (${detail})` : "";
100
- if (process.platform === "linux")
101
- return /uid_map|setgroups/i.test(detail)
102
- ? `Host Actors can't start on this machine: it doesn't let an unprivileged process make the user namespace their sandbox needs${what}. On Ubuntu, AppArmor restricts this; allow it with \`sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0\` (and in /etc/sysctl.d to keep it).`
103
- : `Host Actors can't start on this machine: their sandbox (unshare, and a minimal root built with mount and pivot_root) didn't run${what}.`;
104
- if (process.platform === "darwin")
105
- return `Host Actors can't start on this machine: their sandbox, sandbox-exec, didn't run${what}.`;
106
- return `Host Actors can't start on this machine: there's no sandbox for host processes on ${process.platform} yet.`;
107
- }
108
- /** Lines one Actor's process may write per window; past them, the rest of the window is dropped. */
109
- const MAX_LINES = 500;
110
- const LINE_WINDOW_MS = 10_000;
111
- /** A line longer than this is cut, and the rest of it dropped. */
112
- const MAX_LINE = 64 * 1024;
113
- /**
114
- * This user's root folder for the Linux sandbox, made if missing (0700). Only one that is a real
115
- * folder, owned by this user and closed to others, is used: another user could make the path
116
- * first.
117
- */
118
- export function rootFolder() {
119
- const path = join(realpathSync(tmpdir()), `agentorg-root-${process.getuid?.() ?? "user"}`);
120
- try {
121
- mkdirSync(path, { mode: 0o700 });
122
- }
123
- catch (error) {
124
- if (error.code !== "EEXIST")
125
- return { problem: `its root folder ${path} couldn't be made: ${error.message}` };
126
- }
127
- const stat = lstatSync(path);
128
- if (!stat.isDirectory() || stat.uid !== process.getuid?.() || (stat.mode & 0o077) !== 0)
129
- return {
130
- problem: `its root folder ${path} isn't a folder of this user's, closed to others; remove it`,
131
- };
132
- return { path };
133
- }
134
- /**
135
- * The Hub's host processes: one per running package Actor, spawned under Node's permission model
136
- * inside the OS sandbox, with an empty environment and the channel on fd 3. A process that exits
137
- * without `stop` asking is a crash: it is restarted after a backoff while its Actor is `running`.
138
- */
139
- export class Processes {
140
- #state;
141
- #accept;
142
- #options;
143
- /**
144
- * Where the Linux sandbox builds each process's root, inside its own mount namespace: one empty
145
- * folder per user in the system's temporary folder, never removed. Outside the home, so a
146
- * namespace still ending, which holds it as a mount point, never keeps the home from being
147
- * removed. Linux only; `undefined` with the reason when it can't be trusted.
148
- */
149
- #rootDir;
150
- /** Probes still running, killed when the Hub closes. */
151
- #probes = new Set();
152
- /** The runner, as a real path: Node's permission model matches resolved paths. */
153
- #runner = realpathSync(fileURLToPath(import.meta.resolve("@agentorg/sdk/host/runner.js")));
154
- #entries = new Map();
155
- #status;
156
- #closed = false;
157
- constructor(state, accept, options = {}) {
158
- this.#state = state;
159
- this.#accept = accept;
160
- this.#rootDir = process.platform === "linux" && !options.sandbox ? rootFolder() : undefined;
161
- this.#options = {
162
- ...(options.sandbox ? { sandbox: options.sandbox } : {}),
163
- memoryMb: options.memoryMb ?? 256,
164
- helloMs: options.helloMs ?? 30_000,
165
- stopMs: options.stopMs ?? 5_000,
166
- backoffMs: options.backoffMs ?? 1_000,
167
- maxBackoffMs: options.maxBackoffMs ?? 60_000,
168
- resetAfterMs: options.resetAfterMs ?? 600_000,
169
- };
170
- }
171
- /** The last probe's answer; none before the first. */
172
- get status() {
173
- return this.#status;
174
- }
175
- /**
176
- * Run the sandbox once, around `node -e 0`, and keep what it says. A change is audited, and once
177
- * the host is available, Actors recorded as `running` without a process are started.
178
- */
179
- /** The sandbox command for a process that may read `paths`; none where there is no sandbox. */
180
- /**
181
- * The OS sandbox command for a process that may read `paths`, as host processes run: for the
182
- * Hub's build too, which runs untrusted source to read its modules' definitions.
183
- */
184
- sandboxCommand(paths) {
185
- return this.#sandbox(paths);
186
- }
187
- #sandbox(paths) {
188
- if (this.#options.sandbox)
189
- return this.#options.sandbox;
190
- if (this.#rootDir && "problem" in this.#rootDir)
191
- return undefined;
192
- return defaultSandbox(this.#rootDir?.path ?? "", paths);
193
- }
194
- async probe() {
195
- // The runner is bound as every process's is, so the probe proves the binds work too.
196
- const sandbox = this.#sandbox([this.#runner]);
197
- const status = sandbox
198
- ? await new Promise((resolve) => {
199
- const probe = execFile(sandbox[0], [...sandbox.slice(1), process.execPath, "-e", "0"], { env: {}, timeout: 10_000, killSignal: "SIGKILL" }, (error, _stdout, stderr) => resolve(error
200
- ? {
201
- available: false,
202
- reason: unavailable(error.killed
203
- ? "it didn't finish within 10 s"
204
- : String(stderr).trim().slice(0, 300) || error.message),
205
- }
206
- : { available: true }));
207
- this.#probes.add(probe);
208
- probe.once("exit", () => this.#probes.delete(probe));
209
- })
210
- : {
211
- available: false,
212
- reason: unavailable(this.#rootDir && "problem" in this.#rootDir ? this.#rootDir.problem : ""),
213
- };
214
- if (this.#closed)
215
- return status;
216
- const changed = this.#status?.available !== status.available;
217
- // Any difference, a reason's included, is in every package Actor's record (its `host`).
218
- const differs = JSON.stringify(this.#status) !== JSON.stringify(status);
219
- this.#status = status;
220
- if (changed) {
221
- this.#state.auditHub("host.status", { ...status });
222
- if (status.available)
223
- this.#resume();
224
- }
225
- if (differs)
226
- this.#state.hostChanged();
227
- return status;
228
- }
229
- /** Start every Actor recorded as `running` that has no process. */
230
- #resume() {
231
- for (const actor of this.#state.actors())
232
- if (actor.state === "running" &&
233
- actor.package !== "external" &&
234
- actor.package !== "builtin" &&
235
- !this.#entries.has(actor.actorId))
236
- this.start(actor.actorId);
237
- }
238
- /**
239
- * Spawn an Actor's process, unless it has one (or one restarting). One still stopping is let go
240
- * first; then a process is spawned if the Actor is still `running`.
241
- */
242
- start(actorId) {
243
- if (this.#closed)
244
- return;
245
- const current = this.#entries.get(actorId);
246
- if (current?.stopping) {
247
- void current.stopping.stopped.then(() => {
248
- if (this.#isRunning(actorId))
249
- this.start(actorId);
250
- });
251
- return;
252
- }
253
- if (current)
254
- return;
255
- const entry = { crashes: 0, startedAt: Date.now(), lines: { start: 0, count: 0 } };
256
- this.#entries.set(actorId, entry);
257
- this.#spawn(actorId, entry);
258
- }
259
- #isRunning(actorId) {
260
- try {
261
- return this.#state.actor(actorId).state === "running";
262
- }
263
- catch {
264
- return false; // The state is closed.
265
- }
266
- }
267
- /**
268
- * Spawn the process and take its channel. Whatever goes wrong on the way (the sandbox missing,
269
- * no file descriptors left, the channel refused) ends as an exit, so it is a crash like any
270
- * other and never a throw.
271
- */
272
- #spawn(actorId, entry) {
273
- entry.restart = undefined;
274
- entry.startedAt = Date.now();
275
- let child;
276
- let hello;
277
- let channel;
278
- let ended = false;
279
- const end = (code, signal) => {
280
- if (ended)
281
- return;
282
- ended = true;
283
- clearTimeout(hello);
284
- channel?.close();
285
- this.#exited(actorId, entry, { code, signal, at: new Date().toISOString() });
286
- };
287
- try {
288
- const actor = this.#state.actor(actorId);
289
- const packageDir = realpathSync(join(this.#state.home, "packages", actor.package));
290
- const node = [
291
- process.execPath,
292
- "--permission",
293
- `--allow-fs-read=${this.#runner}`,
294
- `--allow-fs-read=${packageDir}/`,
295
- `--max-old-space-size=${this.#options.memoryMb}`,
296
- this.#runner,
297
- packageDir,
298
- actorId,
299
- ];
300
- const sandbox = this.#sandbox([this.#runner, packageDir]);
301
- if (!sandbox)
302
- throw new Error("There is no sandbox here.");
303
- const [command, ...args] = [...sandbox, ...node];
304
- // Its own process group, so stop's signals reach the sandboxed node too.
305
- const spawned = spawn(command, args, {
306
- stdio: ["ignore", "pipe", "pipe", "pipe"],
307
- env: {},
308
- detached: true,
309
- });
310
- child = spawned;
311
- entry.child = spawned;
312
- spawned.once("exit", (code, signal) => end(code, signal));
313
- // A process that never started (no such sandbox, no resources) has no exit to come.
314
- spawned.once("error", () => {
315
- if (spawned.pid === undefined)
316
- end(null, null);
317
- });
318
- if (spawned.pid === undefined)
319
- return;
320
- const pipe = spawned.stdio[3];
321
- if (!pipe)
322
- throw new Error("The process has no channel.");
323
- this.#capture(actorId, entry, "stdout", spawned.stdout);
324
- this.#capture(actorId, entry, "stderr", spawned.stderr);
325
- const accepted = this.#accept(NodeDuplex.toWeb(pipe), {
326
- actorId,
327
- });
328
- channel = accepted;
329
- // No hello in time is a crash; so is the channel going while the process lives on (unless
330
- // it is stopping: stop's own grace applies).
331
- hello = setTimeout(() => this.#kill(spawned, "SIGKILL"), this.#options.helloMs);
332
- void accepted.admitted.then(() => clearTimeout(hello));
333
- void accepted.closed.then(() => {
334
- clearTimeout(hello);
335
- if (!entry.stopping)
336
- this.#kill(spawned, "SIGKILL");
337
- });
338
- }
339
- catch {
340
- if (child)
341
- this.#kill(child, "SIGKILL");
342
- else
343
- end(null, null);
344
- }
345
- }
346
- #exited(actorId, entry, exit) {
347
- const stopping = entry.stopping?.done;
348
- if (this.#closed)
349
- return stopping?.();
350
- const crashed = !stopping && this.#isRunning(actorId);
351
- try {
352
- this.#state.recordExit(actorId, exit, crashed);
353
- }
354
- catch {
355
- // The state is closed.
356
- }
357
- if (!crashed) {
358
- this.#entries.delete(actorId);
359
- stopping?.();
360
- return;
361
- }
362
- // Up long enough, the backoff starts over.
363
- if (Date.now() - entry.startedAt >= this.#options.resetAfterMs)
364
- entry.crashes = 0;
365
- const delay = Math.min(this.#options.backoffMs * 2 ** entry.crashes, this.#options.maxBackoffMs);
366
- entry.crashes++;
367
- entry.child = undefined;
368
- entry.restart = setTimeout(() => this.#spawn(actorId, entry), delay);
369
- }
370
- /** Stop an Actor's process: SIGTERM, then SIGKILL after the grace; a waiting restart is dropped. */
371
- stop(actorId) {
372
- const entry = this.#entries.get(actorId);
373
- if (!entry)
374
- return Promise.resolve();
375
- if (entry.stopping)
376
- return entry.stopping.stopped;
377
- if (entry.restart || !entry.child) {
378
- clearTimeout(entry.restart);
379
- this.#entries.delete(actorId);
380
- return Promise.resolve();
381
- }
382
- const child = entry.child;
383
- let done;
384
- const stopped = new Promise((resolve) => {
385
- done = resolve;
386
- });
387
- const kill = setTimeout(() => this.#kill(child, "SIGKILL"), this.#options.stopMs);
388
- entry.stopping = {
389
- done: () => {
390
- clearTimeout(kill);
391
- done();
392
- },
393
- stopped,
394
- };
395
- this.#kill(child, "SIGTERM");
396
- return stopped;
397
- }
398
- /** Signal a live process's whole group: the sandbox and the node it runs. */
399
- #kill(child, signal) {
400
- if (child.pid === undefined || child.exitCode !== null || child.signalCode !== null)
401
- return;
402
- try {
403
- process.kill(-child.pid, signal);
404
- }
405
- catch {
406
- // Already gone.
407
- }
408
- }
409
- /**
410
- * A process's output, into its Actor's log, one append per chunk. A line is cut at 64 KiB and
411
- * the rest of it dropped; past 500 lines in 10 s, the window's remaining lines are dropped, and
412
- * one entry says so.
413
- */
414
- #capture(actorId, entry, stream, from) {
415
- let pending = "";
416
- /** Inside a line already cut: dropped until its end. */
417
- let skipping = false;
418
- const take = (lines) => {
419
- if (this.#closed)
420
- return;
421
- const entries = [];
422
- const now = Date.now();
423
- for (const line of lines) {
424
- if (!line)
425
- continue;
426
- if (now - entry.lines.start > LINE_WINDOW_MS)
427
- entry.lines = { start: now, count: 0 };
428
- const count = ++entry.lines.count;
429
- if (count <= MAX_LINES)
430
- entries.push(outputEntry(stream, line));
431
- else if (count === MAX_LINES + 1)
432
- entries.push(outputEntry("stdout", `The process wrote more than ${MAX_LINES} lines in ${LINE_WINDOW_MS / 1000} s; the rest are dropped for now.`));
433
- }
434
- try {
435
- appendLogs(this.#state.home, actorId, entries);
436
- }
437
- catch {
438
- // The disk's trouble: the lines are lost, nothing else.
439
- }
440
- };
441
- from?.setEncoding("utf8");
442
- from?.on("data", (chunk) => {
443
- let text = chunk;
444
- if (skipping) {
445
- const newline = text.indexOf("\n");
446
- if (newline < 0)
447
- return;
448
- skipping = false;
449
- text = text.slice(newline + 1);
450
- }
451
- pending += text;
452
- const lines = pending.split("\n");
453
- pending = lines.pop() ?? "";
454
- if (pending.length > MAX_LINE) {
455
- lines.push(pending.slice(0, MAX_LINE));
456
- pending = "";
457
- skipping = true;
458
- }
459
- take(lines);
460
- });
461
- from?.on("end", () => take([pending]));
462
- }
463
- /** Refused unless host processes can start here: the probe runs again first. */
464
- async ready() {
465
- const status = await this.probe();
466
- if (!status.available)
467
- throw new Refused("unsupported", status.reason ?? "Host Actors can't start here.");
468
- }
469
- /** The Hub is closing: every process is killed, stops in flight are settled, nothing restarts. */
470
- close() {
471
- this.#closed = true;
472
- for (const entry of this.#entries.values()) {
473
- if (entry.restart)
474
- clearTimeout(entry.restart);
475
- if (entry.child)
476
- this.#kill(entry.child, "SIGKILL");
477
- entry.stopping?.done();
478
- }
479
- this.#entries.clear();
480
- // A probe's namespace ends with it; the root's folder goes if nothing holds it any more.
481
- // unshare --kill-child takes its child down with it.
482
- for (const probe of this.#probes)
483
- probe.kill("SIGKILL");
484
- }
485
- }
@@ -1,38 +0,0 @@
1
- /** How much a store may hold. */
2
- export interface StorageLimits {
3
- /** Bytes of one value, as JSON. */
4
- maxValue: number;
5
- /** Bytes of keys and values across all of one consumer's stores. */
6
- maxPerConsumer: number;
7
- }
8
- export declare const STORAGE_LIMITS: StorageLimits;
9
- type Input = Record<string, unknown>;
10
- /**
11
- * The built-in `storage` Actor's `kv@1`: one store per consumer slot, kept in `<home>/storage.db`
12
- * (0600), apart from the Hub's own database. The store is chosen by the consumer and slot the
13
- * router names, never by the caller. Stores outlive unbinding; a closed Actor's go with it.
14
- */
15
- export declare class Storage {
16
- #private;
17
- constructor(home: string, limits?: StorageLimits);
18
- /** One `kv@1` call on the store of (consumer, slot). Inputs were already checked. */
19
- call(consumer: string, slot: string, method: string, input: Input): unknown;
20
- /**
21
- * Seed the store of (consumer, slot), all or none, if it holds nothing: `storage.admin@1`'s
22
- * `seed`. Each entry has kv@1's limits, and together they count toward the consumer's quota.
23
- */
24
- /** `named` is the consumer as a refusal names it: "Name (id)". */
25
- seed(consumer: string, slot: string, entries: {
26
- key: string;
27
- value: unknown;
28
- }[], named?: string): void;
29
- /** Every store of an Actor, gone: it was closed for good. */
30
- deleteConsumer(consumer: string): void;
31
- /**
32
- * Keep only the stores of these Actors. Run when the Hub opens, it catches up on deletes a crash
33
- * or a lock kept from happening when an Actor was closed.
34
- */
35
- keepOnly(live: ReadonlySet<string>): void;
36
- close(): void;
37
- }
38
- export {};