dotdo 0.0.1 → 0.0.2

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 (727) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +446 -315
  3. package/dist/ai/index.js +19 -0
  4. package/dist/ai/index.js.map +1 -0
  5. package/dist/ai/template-literals.js +852 -0
  6. package/dist/ai/template-literals.js.map +1 -0
  7. package/dist/api/analytics/router.js +601 -0
  8. package/dist/api/analytics/router.js.map +1 -0
  9. package/dist/api/index.js +158 -0
  10. package/dist/api/index.js.map +1 -0
  11. package/dist/api/middleware/auth-federation.js +573 -0
  12. package/dist/api/middleware/auth-federation.js.map +1 -0
  13. package/dist/api/middleware/auth.js +544 -0
  14. package/dist/api/middleware/auth.js.map +1 -0
  15. package/dist/api/middleware/error-handling.js +176 -0
  16. package/dist/api/middleware/error-handling.js.map +1 -0
  17. package/dist/api/middleware/request-id.js +21 -0
  18. package/dist/api/middleware/request-id.js.map +1 -0
  19. package/dist/api/pages.js +1180 -0
  20. package/dist/api/pages.js.map +1 -0
  21. package/dist/api/routes/api.js +612 -0
  22. package/dist/api/routes/api.js.map +1 -0
  23. package/dist/api/routes/browsers.js +471 -0
  24. package/dist/api/routes/browsers.js.map +1 -0
  25. package/dist/api/routes/do.js +188 -0
  26. package/dist/api/routes/do.js.map +1 -0
  27. package/dist/api/routes/mcp.js +459 -0
  28. package/dist/api/routes/mcp.js.map +1 -0
  29. package/dist/api/routes/obs.js +445 -0
  30. package/dist/api/routes/obs.js.map +1 -0
  31. package/dist/api/routes/openapi.js +794 -0
  32. package/dist/api/routes/openapi.js.map +1 -0
  33. package/dist/api/routes/rpc.js +1103 -0
  34. package/dist/api/routes/rpc.js.map +1 -0
  35. package/dist/api/routes/sandboxes.js +389 -0
  36. package/dist/api/routes/sandboxes.js.map +1 -0
  37. package/dist/api/test-do.js +38 -0
  38. package/dist/api/test-do.js.map +1 -0
  39. package/dist/api/types.js +11 -0
  40. package/dist/api/types.js.map +1 -0
  41. package/dist/cli/bin.js +2 -0
  42. package/dist/cli/main.js +52342 -0
  43. package/dist/db/actions.js +212 -0
  44. package/dist/db/actions.js.map +1 -0
  45. package/dist/db/auth.js +506 -0
  46. package/dist/db/auth.js.map +1 -0
  47. package/dist/db/branches.js +65 -0
  48. package/dist/db/branches.js.map +1 -0
  49. package/dist/db/clickhouse.js +1074 -0
  50. package/dist/db/clickhouse.js.map +1 -0
  51. package/dist/db/dlq.js +39 -0
  52. package/dist/db/dlq.js.map +1 -0
  53. package/dist/db/events.js +28 -0
  54. package/dist/db/events.js.map +1 -0
  55. package/dist/db/exec.js +64 -0
  56. package/dist/db/exec.js.map +1 -0
  57. package/dist/db/files.js +85 -0
  58. package/dist/db/files.js.map +1 -0
  59. package/dist/db/flags.js +24 -0
  60. package/dist/db/flags.js.map +1 -0
  61. package/dist/db/git.js +116 -0
  62. package/dist/db/git.js.map +1 -0
  63. package/dist/db/iceberg/inverted-index.js +862 -0
  64. package/dist/db/iceberg/inverted-index.js.map +1 -0
  65. package/dist/db/iceberg/puffin.js +878 -0
  66. package/dist/db/iceberg/puffin.js.map +1 -0
  67. package/dist/db/iceberg/search-manifest.js +422 -0
  68. package/dist/db/iceberg/search-manifest.js.map +1 -0
  69. package/dist/db/iceberg/types.js +8 -0
  70. package/dist/db/iceberg/types.js.map +1 -0
  71. package/dist/db/index.js +121 -0
  72. package/dist/db/index.js.map +1 -0
  73. package/dist/db/integrations.js +368 -0
  74. package/dist/db/integrations.js.map +1 -0
  75. package/dist/db/json-indexes.js +332 -0
  76. package/dist/db/json-indexes.js.map +1 -0
  77. package/dist/db/linked-accounts.js +287 -0
  78. package/dist/db/linked-accounts.js.map +1 -0
  79. package/dist/db/nouns.js +183 -0
  80. package/dist/db/nouns.js.map +1 -0
  81. package/dist/db/objects.js +170 -0
  82. package/dist/db/objects.js.map +1 -0
  83. package/dist/db/primitives/dag-scheduler/index.js +869 -0
  84. package/dist/db/primitives/dag-scheduler/index.js.map +1 -0
  85. package/dist/db/primitives/exactly-once-context.js +237 -0
  86. package/dist/db/primitives/exactly-once-context.js.map +1 -0
  87. package/dist/db/primitives/index.js +62 -0
  88. package/dist/db/primitives/index.js.map +1 -0
  89. package/dist/db/primitives/keyed-router.js +145 -0
  90. package/dist/db/primitives/keyed-router.js.map +1 -0
  91. package/dist/db/primitives/observability.js +162 -0
  92. package/dist/db/primitives/observability.js.map +1 -0
  93. package/dist/db/primitives/schema-evolution.js +643 -0
  94. package/dist/db/primitives/schema-evolution.js.map +1 -0
  95. package/dist/db/primitives/stateful-operator/index.js +770 -0
  96. package/dist/db/primitives/stateful-operator/index.js.map +1 -0
  97. package/dist/db/primitives/temporal-store.js +306 -0
  98. package/dist/db/primitives/temporal-store.js.map +1 -0
  99. package/dist/db/primitives/typed-column-store.js +1229 -0
  100. package/dist/db/primitives/typed-column-store.js.map +1 -0
  101. package/dist/db/primitives/utils/duration.js +162 -0
  102. package/dist/db/primitives/utils/duration.js.map +1 -0
  103. package/dist/db/primitives/utils/murmur3.js +118 -0
  104. package/dist/db/primitives/utils/murmur3.js.map +1 -0
  105. package/dist/db/primitives/watermark-service.js +136 -0
  106. package/dist/db/primitives/watermark-service.js.map +1 -0
  107. package/dist/db/primitives/window-manager.js +764 -0
  108. package/dist/db/primitives/window-manager.js.map +1 -0
  109. package/dist/db/relationships.js +66 -0
  110. package/dist/db/relationships.js.map +1 -0
  111. package/dist/db/schema-minimal.js +61 -0
  112. package/dist/db/schema-minimal.js.map +1 -0
  113. package/dist/db/search.js +28 -0
  114. package/dist/db/search.js.map +1 -0
  115. package/dist/db/stores.js +1665 -0
  116. package/dist/db/stores.js.map +1 -0
  117. package/dist/db/things.js +297 -0
  118. package/dist/db/things.js.map +1 -0
  119. package/dist/db/vault.js +171 -0
  120. package/dist/db/vault.js.map +1 -0
  121. package/dist/db/verbs.js +102 -0
  122. package/dist/db/verbs.js.map +1 -0
  123. package/dist/do/base.js +48 -0
  124. package/dist/do/base.js.map +1 -0
  125. package/dist/do/bash.js +35 -0
  126. package/dist/do/bash.js.map +1 -0
  127. package/dist/do/fs.js +25 -0
  128. package/dist/do/fs.js.map +1 -0
  129. package/dist/do/full.js +61 -0
  130. package/dist/do/full.js.map +1 -0
  131. package/dist/do/git.js +28 -0
  132. package/dist/do/git.js.map +1 -0
  133. package/dist/do/index.js +52 -0
  134. package/dist/do/index.js.map +1 -0
  135. package/dist/do/tiny.js +31 -0
  136. package/dist/do/tiny.js.map +1 -0
  137. package/dist/lib/DOAuth.js +261 -0
  138. package/dist/lib/DOAuth.js.map +1 -0
  139. package/dist/lib/DODispatcher.js +72 -0
  140. package/dist/lib/DODispatcher.js.map +1 -0
  141. package/dist/lib/Modifier.js +189 -0
  142. package/dist/lib/Modifier.js.map +1 -0
  143. package/dist/lib/StateStorage.js +403 -0
  144. package/dist/lib/StateStorage.js.map +1 -0
  145. package/dist/lib/TypeRegistry.js +122 -0
  146. package/dist/lib/TypeRegistry.js.map +1 -0
  147. package/dist/lib/agent/tools/bash.js +336 -0
  148. package/dist/lib/agent/tools/bash.js.map +1 -0
  149. package/dist/lib/agent/tools/edit.js +157 -0
  150. package/dist/lib/agent/tools/edit.js.map +1 -0
  151. package/dist/lib/agent/tools/glob.js +137 -0
  152. package/dist/lib/agent/tools/glob.js.map +1 -0
  153. package/dist/lib/agent/tools/grep.js +315 -0
  154. package/dist/lib/agent/tools/grep.js.map +1 -0
  155. package/dist/lib/agent/tools/index.js +71 -0
  156. package/dist/lib/agent/tools/index.js.map +1 -0
  157. package/dist/lib/agent/tools/read.js +212 -0
  158. package/dist/lib/agent/tools/read.js.map +1 -0
  159. package/dist/lib/agent/tools/types.js +197 -0
  160. package/dist/lib/agent/tools/types.js.map +1 -0
  161. package/dist/lib/agent/tools/write.js +159 -0
  162. package/dist/lib/agent/tools/write.js.map +1 -0
  163. package/dist/lib/ai/gateway.js +247 -0
  164. package/dist/lib/ai/gateway.js.map +1 -0
  165. package/dist/lib/ai/tool-loop-agent.js +591 -0
  166. package/dist/lib/ai/tool-loop-agent.js.map +1 -0
  167. package/dist/lib/auto-wiring.js +439 -0
  168. package/dist/lib/auto-wiring.js.map +1 -0
  169. package/dist/lib/browse/browserbase.js +163 -0
  170. package/dist/lib/browse/browserbase.js.map +1 -0
  171. package/dist/lib/browse/cloudflare.js +144 -0
  172. package/dist/lib/browse/cloudflare.js.map +1 -0
  173. package/dist/lib/browse/index.js +62 -0
  174. package/dist/lib/browse/index.js.map +1 -0
  175. package/dist/lib/browse/types.js +13 -0
  176. package/dist/lib/browse/types.js.map +1 -0
  177. package/dist/lib/cache/index.js +37 -0
  178. package/dist/lib/cache/index.js.map +1 -0
  179. package/dist/lib/cache/visibility.js +638 -0
  180. package/dist/lib/cache/visibility.js.map +1 -0
  181. package/dist/lib/capabilities.js +268 -0
  182. package/dist/lib/capabilities.js.map +1 -0
  183. package/dist/lib/channels/base.js +106 -0
  184. package/dist/lib/channels/base.js.map +1 -0
  185. package/dist/lib/channels/discord.js +94 -0
  186. package/dist/lib/channels/discord.js.map +1 -0
  187. package/dist/lib/channels/email.js +204 -0
  188. package/dist/lib/channels/email.js.map +1 -0
  189. package/dist/lib/channels/index.js +90 -0
  190. package/dist/lib/channels/index.js.map +1 -0
  191. package/dist/lib/channels/mdxui-chat.js +95 -0
  192. package/dist/lib/channels/mdxui-chat.js.map +1 -0
  193. package/dist/lib/channels/slack-blockkit.js +121 -0
  194. package/dist/lib/channels/slack-blockkit.js.map +1 -0
  195. package/dist/lib/channels/types.js +7 -0
  196. package/dist/lib/channels/types.js.map +1 -0
  197. package/dist/lib/cloudflare/ai.js +654 -0
  198. package/dist/lib/cloudflare/ai.js.map +1 -0
  199. package/dist/lib/cloudflare/index.js +88 -0
  200. package/dist/lib/cloudflare/index.js.map +1 -0
  201. package/dist/lib/cloudflare/kv.js +342 -0
  202. package/dist/lib/cloudflare/kv.js.map +1 -0
  203. package/dist/lib/cloudflare/queues.js +434 -0
  204. package/dist/lib/cloudflare/queues.js.map +1 -0
  205. package/dist/lib/cloudflare/r2.js +604 -0
  206. package/dist/lib/cloudflare/r2.js.map +1 -0
  207. package/dist/lib/cloudflare/vectorize.js +494 -0
  208. package/dist/lib/cloudflare/vectorize.js.map +1 -0
  209. package/dist/lib/cloudflare/workflows.js +569 -0
  210. package/dist/lib/cloudflare/workflows.js.map +1 -0
  211. package/dist/lib/colo/caching.js +196 -0
  212. package/dist/lib/colo/caching.js.map +1 -0
  213. package/dist/lib/colo/detection.js +194 -0
  214. package/dist/lib/colo/detection.js.map +1 -0
  215. package/dist/lib/colo/external-data.js +219 -0
  216. package/dist/lib/colo/external-data.js.map +1 -0
  217. package/dist/lib/colo/globe-data.js +179 -0
  218. package/dist/lib/colo/globe-data.js.map +1 -0
  219. package/dist/lib/colo/index.js +16 -0
  220. package/dist/lib/colo/index.js.map +1 -0
  221. package/dist/lib/decorators.js +37 -0
  222. package/dist/lib/decorators.js.map +1 -0
  223. package/dist/lib/discovery.js +81 -0
  224. package/dist/lib/discovery.js.map +1 -0
  225. package/dist/lib/executors/AgenticFunctionExecutor.js +619 -0
  226. package/dist/lib/executors/AgenticFunctionExecutor.js.map +1 -0
  227. package/dist/lib/executors/BaseFunctionExecutor.js +328 -0
  228. package/dist/lib/executors/BaseFunctionExecutor.js.map +1 -0
  229. package/dist/lib/executors/CascadeExecutor.js +418 -0
  230. package/dist/lib/executors/CascadeExecutor.js.map +1 -0
  231. package/dist/lib/executors/CodeFunctionExecutor.js +904 -0
  232. package/dist/lib/executors/CodeFunctionExecutor.js.map +1 -0
  233. package/dist/lib/executors/GenerativeFunctionExecutor.js +904 -0
  234. package/dist/lib/executors/GenerativeFunctionExecutor.js.map +1 -0
  235. package/dist/lib/executors/HumanFunctionExecutor.js +884 -0
  236. package/dist/lib/executors/HumanFunctionExecutor.js.map +1 -0
  237. package/dist/lib/executors/ParallelStepExecutor.js +308 -0
  238. package/dist/lib/executors/ParallelStepExecutor.js.map +1 -0
  239. package/dist/lib/executors/types.js +12 -0
  240. package/dist/lib/executors/types.js.map +1 -0
  241. package/dist/lib/experiments.js +89 -0
  242. package/dist/lib/experiments.js.map +1 -0
  243. package/dist/lib/flags/store.js +262 -0
  244. package/dist/lib/flags/store.js.map +1 -0
  245. package/dist/lib/functions/FunctionComposition.js +467 -0
  246. package/dist/lib/functions/FunctionComposition.js.map +1 -0
  247. package/dist/lib/functions/FunctionMiddleware.js +457 -0
  248. package/dist/lib/functions/FunctionMiddleware.js.map +1 -0
  249. package/dist/lib/functions/FunctionRegistry.js +426 -0
  250. package/dist/lib/functions/FunctionRegistry.js.map +1 -0
  251. package/dist/lib/functions/createFunction.js +1048 -0
  252. package/dist/lib/functions/createFunction.js.map +1 -0
  253. package/dist/lib/humans/index.js +68 -0
  254. package/dist/lib/humans/index.js.map +1 -0
  255. package/dist/lib/humans/templates.js +117 -0
  256. package/dist/lib/humans/templates.js.map +1 -0
  257. package/dist/lib/identity.js +98 -0
  258. package/dist/lib/identity.js.map +1 -0
  259. package/dist/lib/index.js +9 -0
  260. package/dist/lib/index.js.map +1 -0
  261. package/dist/lib/logging/error-logger.js +163 -0
  262. package/dist/lib/logging/error-logger.js.map +1 -0
  263. package/dist/lib/logging/index.js +160 -0
  264. package/dist/lib/logging/index.js.map +1 -0
  265. package/dist/lib/mixins/bash.js +825 -0
  266. package/dist/lib/mixins/bash.js.map +1 -0
  267. package/dist/lib/mixins/fs.js +648 -0
  268. package/dist/lib/mixins/fs.js.map +1 -0
  269. package/dist/lib/mixins/git.js +1011 -0
  270. package/dist/lib/mixins/git.js.map +1 -0
  271. package/dist/lib/mixins/index.js +29 -0
  272. package/dist/lib/mixins/index.js.map +1 -0
  273. package/dist/lib/mixins/npm.js +662 -0
  274. package/dist/lib/mixins/npm.js.map +1 -0
  275. package/dist/lib/noun-id.js +278 -0
  276. package/dist/lib/noun-id.js.map +1 -0
  277. package/dist/lib/rate-limit/sliding-window.js +148 -0
  278. package/dist/lib/rate-limit/sliding-window.js.map +1 -0
  279. package/dist/lib/rate-limit.js +110 -0
  280. package/dist/lib/rate-limit.js.map +1 -0
  281. package/dist/lib/rpc/bindings.js +548 -0
  282. package/dist/lib/rpc/bindings.js.map +1 -0
  283. package/dist/lib/rpc/index.js +64 -0
  284. package/dist/lib/rpc/index.js.map +1 -0
  285. package/dist/lib/safe-stringify.js +223 -0
  286. package/dist/lib/safe-stringify.js.map +1 -0
  287. package/dist/lib/sandbox/miniflare-sandbox.js +1007 -0
  288. package/dist/lib/sandbox/miniflare-sandbox.js.map +1 -0
  289. package/dist/lib/sqids.js +110 -0
  290. package/dist/lib/sqids.js.map +1 -0
  291. package/dist/lib/sql/adapters/index.js +10 -0
  292. package/dist/lib/sql/adapters/index.js.map +1 -0
  293. package/dist/lib/sql/adapters/node-sql-parser.js +552 -0
  294. package/dist/lib/sql/adapters/node-sql-parser.js.map +1 -0
  295. package/dist/lib/sql/adapters/pgsql-parser.js +1189 -0
  296. package/dist/lib/sql/adapters/pgsql-parser.js.map +1 -0
  297. package/dist/lib/sql/index.js +277 -0
  298. package/dist/lib/sql/index.js.map +1 -0
  299. package/dist/lib/sql/types.js +56 -0
  300. package/dist/lib/sql/types.js.map +1 -0
  301. package/dist/lib/type-classifier.js +126 -0
  302. package/dist/lib/type-classifier.js.map +1 -0
  303. package/dist/lib/utils/html.js +47 -0
  304. package/dist/lib/utils/html.js.map +1 -0
  305. package/dist/lib/validation.js +48 -0
  306. package/dist/lib/validation.js.map +1 -0
  307. package/dist/lib/vault/store.js +411 -0
  308. package/dist/lib/vault/store.js.map +1 -0
  309. package/dist/metrics/hunch.js +739 -0
  310. package/dist/metrics/hunch.js.map +1 -0
  311. package/dist/objects/API.js +302 -0
  312. package/dist/objects/API.js.map +1 -0
  313. package/dist/objects/Agent.js +179 -0
  314. package/dist/objects/Agent.js.map +1 -0
  315. package/dist/objects/AgenticFunctionExecutor.js +8 -0
  316. package/dist/objects/AgenticFunctionExecutor.js.map +1 -0
  317. package/dist/objects/App.js +83 -0
  318. package/dist/objects/App.js.map +1 -0
  319. package/dist/objects/Browser.js +884 -0
  320. package/dist/objects/Browser.js.map +1 -0
  321. package/dist/objects/Business.js +107 -0
  322. package/dist/objects/Business.js.map +1 -0
  323. package/dist/objects/CLI.js +221 -0
  324. package/dist/objects/CLI.js.map +1 -0
  325. package/dist/objects/CodeFunctionExecutor.js +8 -0
  326. package/dist/objects/CodeFunctionExecutor.js.map +1 -0
  327. package/dist/objects/Collection.js +161 -0
  328. package/dist/objects/Collection.js.map +1 -0
  329. package/dist/objects/DO.js +41 -0
  330. package/dist/objects/DO.js.map +1 -0
  331. package/dist/objects/DOBase.js +2309 -0
  332. package/dist/objects/DOBase.js.map +1 -0
  333. package/dist/objects/DOFull.js +1676 -0
  334. package/dist/objects/DOFull.js.map +1 -0
  335. package/dist/objects/DOTiny.js +207 -0
  336. package/dist/objects/DOTiny.js.map +1 -0
  337. package/dist/objects/Directory.js +199 -0
  338. package/dist/objects/Directory.js.map +1 -0
  339. package/dist/objects/Entity.js +413 -0
  340. package/dist/objects/Entity.js.map +1 -0
  341. package/dist/objects/Function.js +116 -0
  342. package/dist/objects/Function.js.map +1 -0
  343. package/dist/objects/Human.js +231 -0
  344. package/dist/objects/Human.js.map +1 -0
  345. package/dist/objects/HumanFunctionExecutor.js +8 -0
  346. package/dist/objects/HumanFunctionExecutor.js.map +1 -0
  347. package/dist/objects/IcebergMetadataDO.js +938 -0
  348. package/dist/objects/IcebergMetadataDO.js.map +1 -0
  349. package/dist/objects/IntegrationsDO.js +1174 -0
  350. package/dist/objects/IntegrationsDO.js.map +1 -0
  351. package/dist/objects/ObservabilityBroadcaster.js +149 -0
  352. package/dist/objects/ObservabilityBroadcaster.js.map +1 -0
  353. package/dist/objects/Package.js +154 -0
  354. package/dist/objects/Package.js.map +1 -0
  355. package/dist/objects/Product.js +193 -0
  356. package/dist/objects/Product.js.map +1 -0
  357. package/dist/objects/SDK.js +152 -0
  358. package/dist/objects/SDK.js.map +1 -0
  359. package/dist/objects/SaaS.js +235 -0
  360. package/dist/objects/SaaS.js.map +1 -0
  361. package/dist/objects/SandboxDO.js +759 -0
  362. package/dist/objects/SandboxDO.js.map +1 -0
  363. package/dist/objects/Service.js +337 -0
  364. package/dist/objects/Service.js.map +1 -0
  365. package/dist/objects/Site.js +80 -0
  366. package/dist/objects/Site.js.map +1 -0
  367. package/dist/objects/Startup.js +479 -0
  368. package/dist/objects/Startup.js.map +1 -0
  369. package/dist/objects/ThingsDO.js +170 -0
  370. package/dist/objects/ThingsDO.js.map +1 -0
  371. package/dist/objects/VectorShardDO.js +648 -0
  372. package/dist/objects/VectorShardDO.js.map +1 -0
  373. package/dist/objects/Worker.js +144 -0
  374. package/dist/objects/Worker.js.map +1 -0
  375. package/dist/objects/Workflow.js +196 -0
  376. package/dist/objects/Workflow.js.map +1 -0
  377. package/dist/objects/WorkflowFactory.js +313 -0
  378. package/dist/objects/WorkflowFactory.js.map +1 -0
  379. package/dist/objects/WorkflowRuntime.js +863 -0
  380. package/dist/objects/WorkflowRuntime.js.map +1 -0
  381. package/dist/objects/circuit-breaker-bulkhead.js +178 -0
  382. package/dist/objects/circuit-breaker-bulkhead.js.map +1 -0
  383. package/dist/objects/createFunction.js +934 -0
  384. package/dist/objects/createFunction.js.map +1 -0
  385. package/dist/objects/index.js +80 -0
  386. package/dist/objects/index.js.map +1 -0
  387. package/dist/objects/lifecycle/Branch.js +275 -0
  388. package/dist/objects/lifecycle/Branch.js.map +1 -0
  389. package/dist/objects/lifecycle/Clone.js +1499 -0
  390. package/dist/objects/lifecycle/Clone.js.map +1 -0
  391. package/dist/objects/lifecycle/Compact.js +237 -0
  392. package/dist/objects/lifecycle/Compact.js.map +1 -0
  393. package/dist/objects/lifecycle/Promote.js +476 -0
  394. package/dist/objects/lifecycle/Promote.js.map +1 -0
  395. package/dist/objects/lifecycle/Shard.js +560 -0
  396. package/dist/objects/lifecycle/Shard.js.map +1 -0
  397. package/dist/objects/lifecycle/index.js +15 -0
  398. package/dist/objects/lifecycle/index.js.map +1 -0
  399. package/dist/objects/lifecycle/types.js +33 -0
  400. package/dist/objects/lifecycle/types.js.map +1 -0
  401. package/dist/objects/mixins/infrastructure.js +171 -0
  402. package/dist/objects/mixins/infrastructure.js.map +1 -0
  403. package/dist/objects/modules/StoresModule.js +153 -0
  404. package/dist/objects/modules/StoresModule.js.map +1 -0
  405. package/dist/objects/persistence/checkpoint-manager.js +606 -0
  406. package/dist/objects/persistence/checkpoint-manager.js.map +1 -0
  407. package/dist/objects/persistence/index.js +72 -0
  408. package/dist/objects/persistence/index.js.map +1 -0
  409. package/dist/objects/persistence/migration-runner.js +562 -0
  410. package/dist/objects/persistence/migration-runner.js.map +1 -0
  411. package/dist/objects/persistence/replication-manager.js +501 -0
  412. package/dist/objects/persistence/replication-manager.js.map +1 -0
  413. package/dist/objects/persistence/tiered-storage-manager.js +595 -0
  414. package/dist/objects/persistence/tiered-storage-manager.js.map +1 -0
  415. package/dist/objects/persistence/types.js +14 -0
  416. package/dist/objects/persistence/types.js.map +1 -0
  417. package/dist/objects/persistence/wal-manager.js +653 -0
  418. package/dist/objects/persistence/wal-manager.js.map +1 -0
  419. package/dist/objects/presets/index.js +20 -0
  420. package/dist/objects/presets/index.js.map +1 -0
  421. package/dist/objects/presets/primitives.js +188 -0
  422. package/dist/objects/presets/primitives.js.map +1 -0
  423. package/dist/objects/primitives/alarm-adapter.js +141 -0
  424. package/dist/objects/primitives/alarm-adapter.js.map +1 -0
  425. package/dist/objects/primitives/index.js +337 -0
  426. package/dist/objects/primitives/index.js.map +1 -0
  427. package/dist/objects/primitives/storage-adapter.js +182 -0
  428. package/dist/objects/primitives/storage-adapter.js.map +1 -0
  429. package/dist/objects/primitives/with-primitives.js +102 -0
  430. package/dist/objects/primitives/with-primitives.js.map +1 -0
  431. package/dist/objects/services/StoreManager.js +227 -0
  432. package/dist/objects/services/StoreManager.js.map +1 -0
  433. package/dist/objects/services/index.js +13 -0
  434. package/dist/objects/services/index.js.map +1 -0
  435. package/dist/objects/transport/auth-layer.js +1451 -0
  436. package/dist/objects/transport/auth-layer.js.map +1 -0
  437. package/dist/objects/transport/capnweb-target.js +355 -0
  438. package/dist/objects/transport/capnweb-target.js.map +1 -0
  439. package/dist/objects/transport/chain.js +441 -0
  440. package/dist/objects/transport/chain.js.map +1 -0
  441. package/dist/objects/transport/handler.js +58 -0
  442. package/dist/objects/transport/handler.js.map +1 -0
  443. package/dist/objects/transport/index.js +53 -0
  444. package/dist/objects/transport/index.js.map +1 -0
  445. package/dist/objects/transport/mcp-server.js +690 -0
  446. package/dist/objects/transport/mcp-server.js.map +1 -0
  447. package/dist/objects/transport/rest-autowire.js +1507 -0
  448. package/dist/objects/transport/rest-autowire.js.map +1 -0
  449. package/dist/objects/transport/rest-router.js +440 -0
  450. package/dist/objects/transport/rest-router.js.map +1 -0
  451. package/dist/objects/transport/rpc-server.js +1536 -0
  452. package/dist/objects/transport/rpc-server.js.map +1 -0
  453. package/dist/objects/transport/shared.js +575 -0
  454. package/dist/objects/transport/shared.js.map +1 -0
  455. package/dist/objects/transport/sync-engine.js +291 -0
  456. package/dist/objects/transport/sync-engine.js.map +1 -0
  457. package/dist/objects/transport/types.js +8 -0
  458. package/dist/objects/transport/types.js.map +1 -0
  459. package/dist/primitives/bashx/src/ast/analyze.js +1472 -0
  460. package/dist/primitives/bashx/src/ast/analyze.js.map +1 -0
  461. package/dist/primitives/bashx/src/ast/parser.js +1488 -0
  462. package/dist/primitives/bashx/src/ast/parser.js.map +1 -0
  463. package/dist/primitives/bashx/src/do/commands/crypto.js +1954 -0
  464. package/dist/primitives/bashx/src/do/commands/crypto.js.map +1 -0
  465. package/dist/primitives/bashx/src/do/commands/data-processing.js +1812 -0
  466. package/dist/primitives/bashx/src/do/commands/data-processing.js.map +1 -0
  467. package/dist/primitives/bashx/src/do/commands/extended-utils.js +804 -0
  468. package/dist/primitives/bashx/src/do/commands/extended-utils.js.map +1 -0
  469. package/dist/primitives/bashx/src/do/commands/math-control.js +1122 -0
  470. package/dist/primitives/bashx/src/do/commands/math-control.js.map +1 -0
  471. package/dist/primitives/bashx/src/do/commands/posix-utils.js +1015 -0
  472. package/dist/primitives/bashx/src/do/commands/posix-utils.js.map +1 -0
  473. package/dist/primitives/bashx/src/do/commands/system-utils.js +687 -0
  474. package/dist/primitives/bashx/src/do/commands/system-utils.js.map +1 -0
  475. package/dist/primitives/bashx/src/do/commands/test-command.js +523 -0
  476. package/dist/primitives/bashx/src/do/commands/test-command.js.map +1 -0
  477. package/dist/primitives/bashx/src/do/commands/text-processing.js +1550 -0
  478. package/dist/primitives/bashx/src/do/commands/text-processing.js.map +1 -0
  479. package/dist/primitives/bashx/src/do/container-executor.js +429 -0
  480. package/dist/primitives/bashx/src/do/container-executor.js.map +1 -0
  481. package/dist/primitives/bashx/src/do/index.js +668 -0
  482. package/dist/primitives/bashx/src/do/index.js.map +1 -0
  483. package/dist/primitives/bashx/src/do/tiered-executor.js +2647 -0
  484. package/dist/primitives/bashx/src/do/tiered-executor.js.map +1 -0
  485. package/dist/primitives/bashx/src/do/worker.js +352 -0
  486. package/dist/primitives/bashx/src/do/worker.js.map +1 -0
  487. package/dist/primitives/bashx/src/types.js +10 -0
  488. package/dist/primitives/bashx/src/types.js.map +1 -0
  489. package/dist/primitives/fsx/core/backend.js +480 -0
  490. package/dist/primitives/fsx/core/backend.js.map +1 -0
  491. package/dist/primitives/fsx/core/constants.js +140 -0
  492. package/dist/primitives/fsx/core/constants.js.map +1 -0
  493. package/dist/primitives/fsx/core/fsx.js +1184 -0
  494. package/dist/primitives/fsx/core/fsx.js.map +1 -0
  495. package/dist/primitives/fsx/core/glob/glob.js +438 -0
  496. package/dist/primitives/fsx/core/glob/glob.js.map +1 -0
  497. package/dist/primitives/fsx/core/glob/index.js +8 -0
  498. package/dist/primitives/fsx/core/glob/index.js.map +1 -0
  499. package/dist/primitives/fsx/core/glob/match.js +392 -0
  500. package/dist/primitives/fsx/core/glob/match.js.map +1 -0
  501. package/dist/primitives/fsx/core/types.js +307 -0
  502. package/dist/primitives/fsx/core/types.js.map +1 -0
  503. package/dist/sandbox/index.js +258 -0
  504. package/dist/sandbox/index.js.map +1 -0
  505. package/dist/sdk/capnweb-compat.js +42 -0
  506. package/dist/sdk/capnweb-compat.js.map +1 -0
  507. package/dist/sdk/client.js +20 -0
  508. package/dist/sdk/client.js.map +1 -0
  509. package/dist/sdk/index.js +17 -0
  510. package/dist/sdk/index.js.map +1 -0
  511. package/dist/snippets/artifacts-config.js +241 -0
  512. package/dist/snippets/artifacts-config.js.map +1 -0
  513. package/dist/snippets/artifacts-ingest.js +832 -0
  514. package/dist/snippets/artifacts-ingest.js.map +1 -0
  515. package/dist/snippets/artifacts-serve.js +1035 -0
  516. package/dist/snippets/artifacts-serve.js.map +1 -0
  517. package/dist/snippets/artifacts-types.js +161 -0
  518. package/dist/snippets/artifacts-types.js.map +1 -0
  519. package/dist/snippets/cache-probe.js +376 -0
  520. package/dist/snippets/cache-probe.js.map +1 -0
  521. package/dist/snippets/cache.js +10 -0
  522. package/dist/snippets/cache.js.map +1 -0
  523. package/dist/snippets/events.js +469 -0
  524. package/dist/snippets/events.js.map +1 -0
  525. package/dist/snippets/index.js +7 -0
  526. package/dist/snippets/index.js.map +1 -0
  527. package/dist/snippets/proxy.js +495 -0
  528. package/dist/snippets/proxy.js.map +1 -0
  529. package/dist/snippets/search.js +1759 -0
  530. package/dist/snippets/search.js.map +1 -0
  531. package/dist/streams/index.js +30 -0
  532. package/dist/streams/index.js.map +1 -0
  533. package/dist/streams/observability.js +68 -0
  534. package/dist/streams/observability.js.map +1 -0
  535. package/dist/types/AI.js +92 -0
  536. package/dist/types/AI.js.map +1 -0
  537. package/dist/types/AIFunction.js +171 -0
  538. package/dist/types/AIFunction.js.map +1 -0
  539. package/dist/types/BrowseVerb.js +89 -0
  540. package/dist/types/BrowseVerb.js.map +1 -0
  541. package/dist/types/Browser.js +31 -0
  542. package/dist/types/Browser.js.map +1 -0
  543. package/dist/types/Chaos.js +15 -0
  544. package/dist/types/Chaos.js.map +1 -0
  545. package/dist/types/CloudflareBindings.js +109 -0
  546. package/dist/types/CloudflareBindings.js.map +1 -0
  547. package/dist/types/Collection.js +50 -0
  548. package/dist/types/Collection.js.map +1 -0
  549. package/dist/types/DO.js +2 -0
  550. package/dist/types/DO.js.map +1 -0
  551. package/dist/types/DOLocation.js +63 -0
  552. package/dist/types/DOLocation.js.map +1 -0
  553. package/dist/types/EventHandler.js +57 -0
  554. package/dist/types/EventHandler.js.map +1 -0
  555. package/dist/types/Experiment.js +33 -0
  556. package/dist/types/Experiment.js.map +1 -0
  557. package/dist/types/Flag.js +57 -0
  558. package/dist/types/Flag.js.map +1 -0
  559. package/dist/types/Lifecycle.js +13 -0
  560. package/dist/types/Lifecycle.js.map +1 -0
  561. package/dist/types/Location.js +169 -0
  562. package/dist/types/Location.js.map +1 -0
  563. package/dist/types/Noun.js +66 -0
  564. package/dist/types/Noun.js.map +1 -0
  565. package/dist/types/SessionEvent.js +194 -0
  566. package/dist/types/SessionEvent.js.map +1 -0
  567. package/dist/types/Thing.js +55 -0
  568. package/dist/types/Thing.js.map +1 -0
  569. package/dist/types/ThingDO.js +153 -0
  570. package/dist/types/ThingDO.js.map +1 -0
  571. package/dist/types/Things.js +2 -0
  572. package/dist/types/Things.js.map +1 -0
  573. package/dist/types/Verb.js +119 -0
  574. package/dist/types/Verb.js.map +1 -0
  575. package/dist/types/WorkflowContext.js +70 -0
  576. package/dist/types/WorkflowContext.js.map +1 -0
  577. package/dist/types/analytics-api.js +13 -0
  578. package/dist/types/analytics-api.js.map +1 -0
  579. package/dist/types/capabilities.js +135 -0
  580. package/dist/types/capabilities.js.map +1 -0
  581. package/dist/types/drizzle.js +12 -0
  582. package/dist/types/drizzle.js.map +1 -0
  583. package/dist/types/event.js +201 -0
  584. package/dist/types/event.js.map +1 -0
  585. package/dist/types/fn.js +12 -0
  586. package/dist/types/fn.js.map +1 -0
  587. package/dist/types/iceberg.js +48 -0
  588. package/dist/types/iceberg.js.map +1 -0
  589. package/dist/types/ids.js +170 -0
  590. package/dist/types/ids.js.map +1 -0
  591. package/dist/types/index.js +41 -0
  592. package/dist/types/index.js.map +1 -0
  593. package/dist/types/introspect.js +54 -0
  594. package/dist/types/introspect.js.map +1 -0
  595. package/dist/types/observability.js +124 -0
  596. package/dist/types/observability.js.map +1 -0
  597. package/dist/types/sync-protocol.js +175 -0
  598. package/dist/types/sync-protocol.js.map +1 -0
  599. package/dist/types/vector.js +13 -0
  600. package/dist/types/vector.js.map +1 -0
  601. package/dist/workflows/ScheduleManager.js +473 -0
  602. package/dist/workflows/ScheduleManager.js.map +1 -0
  603. package/dist/workflows/StepDOBridge.js +149 -0
  604. package/dist/workflows/StepDOBridge.js.map +1 -0
  605. package/dist/workflows/StepResultStorage.js +232 -0
  606. package/dist/workflows/StepResultStorage.js.map +1 -0
  607. package/dist/workflows/WaitForEventManager.js +461 -0
  608. package/dist/workflows/WaitForEventManager.js.map +1 -0
  609. package/dist/workflows/analyzer.js +332 -0
  610. package/dist/workflows/analyzer.js.map +1 -0
  611. package/dist/workflows/compat/activity-router.js +484 -0
  612. package/dist/workflows/compat/activity-router.js.map +1 -0
  613. package/dist/workflows/compat/backends/cloudflare-workflows.js +431 -0
  614. package/dist/workflows/compat/backends/cloudflare-workflows.js.map +1 -0
  615. package/dist/workflows/compat/backends/index.js +14 -0
  616. package/dist/workflows/compat/backends/index.js.map +1 -0
  617. package/dist/workflows/compat/errors/index.js +375 -0
  618. package/dist/workflows/compat/errors/index.js.map +1 -0
  619. package/dist/workflows/compat/index.js +79 -0
  620. package/dist/workflows/compat/index.js.map +1 -0
  621. package/dist/workflows/compat/inngest/index.js +989 -0
  622. package/dist/workflows/compat/inngest/index.js.map +1 -0
  623. package/dist/workflows/compat/qstash/index.js +1263 -0
  624. package/dist/workflows/compat/qstash/index.js.map +1 -0
  625. package/dist/workflows/compat/temporal/activities.js +739 -0
  626. package/dist/workflows/compat/temporal/activities.js.map +1 -0
  627. package/dist/workflows/compat/temporal/child-workflows.js +154 -0
  628. package/dist/workflows/compat/temporal/child-workflows.js.map +1 -0
  629. package/dist/workflows/compat/temporal/client.js +381 -0
  630. package/dist/workflows/compat/temporal/client.js.map +1 -0
  631. package/dist/workflows/compat/temporal/context.js +309 -0
  632. package/dist/workflows/compat/temporal/context.js.map +1 -0
  633. package/dist/workflows/compat/temporal/determinism.js +216 -0
  634. package/dist/workflows/compat/temporal/determinism.js.map +1 -0
  635. package/dist/workflows/compat/temporal/errors.js +128 -0
  636. package/dist/workflows/compat/temporal/errors.js.map +1 -0
  637. package/dist/workflows/compat/temporal/index.js +2464 -0
  638. package/dist/workflows/compat/temporal/index.js.map +1 -0
  639. package/dist/workflows/compat/temporal/saga.js +504 -0
  640. package/dist/workflows/compat/temporal/saga.js.map +1 -0
  641. package/dist/workflows/compat/temporal/signals.js +364 -0
  642. package/dist/workflows/compat/temporal/signals.js.map +1 -0
  643. package/dist/workflows/compat/temporal/storage.js +271 -0
  644. package/dist/workflows/compat/temporal/storage.js.map +1 -0
  645. package/dist/workflows/compat/temporal/timers.js +347 -0
  646. package/dist/workflows/compat/temporal/timers.js.map +1 -0
  647. package/dist/workflows/compat/temporal/types.js +7 -0
  648. package/dist/workflows/compat/temporal/types.js.map +1 -0
  649. package/dist/workflows/compat/temporal/unified-primitives.js +339 -0
  650. package/dist/workflows/compat/temporal/unified-primitives.js.map +1 -0
  651. package/dist/workflows/compat/trigger/index.js +468 -0
  652. package/dist/workflows/compat/trigger/index.js.map +1 -0
  653. package/dist/workflows/compat/utils/index.js +69 -0
  654. package/dist/workflows/compat/utils/index.js.map +1 -0
  655. package/dist/workflows/context/correlation-capability.js +266 -0
  656. package/dist/workflows/context/correlation-capability.js.map +1 -0
  657. package/dist/workflows/context/correlation.js +484 -0
  658. package/dist/workflows/context/correlation.js.map +1 -0
  659. package/dist/workflows/context/experiment.js +289 -0
  660. package/dist/workflows/context/experiment.js.map +1 -0
  661. package/dist/workflows/context/flag.js +244 -0
  662. package/dist/workflows/context/flag.js.map +1 -0
  663. package/dist/workflows/context/foundation.js +648 -0
  664. package/dist/workflows/context/foundation.js.map +1 -0
  665. package/dist/workflows/context/human-base.js +106 -0
  666. package/dist/workflows/context/human-base.js.map +1 -0
  667. package/dist/workflows/context/human.js +368 -0
  668. package/dist/workflows/context/human.js.map +1 -0
  669. package/dist/workflows/context/measure.js +354 -0
  670. package/dist/workflows/context/measure.js.map +1 -0
  671. package/dist/workflows/context/rate-limit.js +358 -0
  672. package/dist/workflows/context/rate-limit.js.map +1 -0
  673. package/dist/workflows/context/user.js +117 -0
  674. package/dist/workflows/context/user.js.map +1 -0
  675. package/dist/workflows/context/vault.js +360 -0
  676. package/dist/workflows/context/vault.js.map +1 -0
  677. package/dist/workflows/data/entity-events/entity-events.js +489 -0
  678. package/dist/workflows/data/entity-events/entity-events.js.map +1 -0
  679. package/dist/workflows/data/experiment/index.js +599 -0
  680. package/dist/workflows/data/experiment/index.js.map +1 -0
  681. package/dist/workflows/data/goal/context.js +558 -0
  682. package/dist/workflows/data/goal/context.js.map +1 -0
  683. package/dist/workflows/data/goal/index.js +32 -0
  684. package/dist/workflows/data/goal/index.js.map +1 -0
  685. package/dist/workflows/data/measure/index.js +840 -0
  686. package/dist/workflows/data/measure/index.js.map +1 -0
  687. package/dist/workflows/data/stream/index.js +1215 -0
  688. package/dist/workflows/data/stream/index.js.map +1 -0
  689. package/dist/workflows/data/track/context.js +883 -0
  690. package/dist/workflows/data/track/context.js.map +1 -0
  691. package/dist/workflows/data/track/index.js +15 -0
  692. package/dist/workflows/data/track/index.js.map +1 -0
  693. package/dist/workflows/data/view/context.js +864 -0
  694. package/dist/workflows/data/view/context.js.map +1 -0
  695. package/dist/workflows/domain.js +93 -0
  696. package/dist/workflows/domain.js.map +1 -0
  697. package/dist/workflows/flag.js +176 -0
  698. package/dist/workflows/flag.js.map +1 -0
  699. package/dist/workflows/flags.js +217 -0
  700. package/dist/workflows/flags.js.map +1 -0
  701. package/dist/workflows/hash.js +209 -0
  702. package/dist/workflows/hash.js.map +1 -0
  703. package/dist/workflows/index.js +50 -0
  704. package/dist/workflows/index.js.map +1 -0
  705. package/dist/workflows/on.js +378 -0
  706. package/dist/workflows/on.js.map +1 -0
  707. package/dist/workflows/pipeline-promise.js +481 -0
  708. package/dist/workflows/pipeline-promise.js.map +1 -0
  709. package/dist/workflows/pipeline-types.js +20 -0
  710. package/dist/workflows/pipeline-types.js.map +1 -0
  711. package/dist/workflows/proxy.js +76 -0
  712. package/dist/workflows/proxy.js.map +1 -0
  713. package/dist/workflows/runtime.js +310 -0
  714. package/dist/workflows/runtime.js.map +1 -0
  715. package/dist/workflows/schedule-builder.js +327 -0
  716. package/dist/workflows/schedule-builder.js.map +1 -0
  717. package/dist/workflows/visibility/index.js +148 -0
  718. package/dist/workflows/visibility/index.js.map +1 -0
  719. package/dist/workflows/visibility/query-parser.js +150 -0
  720. package/dist/workflows/visibility/query-parser.js.map +1 -0
  721. package/dist/workflows/visibility/store.js +223 -0
  722. package/dist/workflows/visibility/store.js.map +1 -0
  723. package/dist/workflows/visibility/types.js +30 -0
  724. package/dist/workflows/visibility/types.js.map +1 -0
  725. package/dist/workflows/workflow.js +53 -0
  726. package/dist/workflows/workflow.js.map +1 -0
  727. package/package.json +279 -46
@@ -0,0 +1,687 @@
1
+ /**
2
+ * System Utilities Commands
3
+ *
4
+ * Native implementations for system utility commands:
5
+ * - sleep: Delay execution for a specified duration
6
+ * - yes: Output a string repeatedly
7
+ * - seq: Generate number sequences
8
+ * - pwd: Print working directory
9
+ * - whoami: Print current username
10
+ * - hostname: Print system hostname
11
+ * - printenv: Print environment variables
12
+ *
13
+ * @module bashx/do/commands/system-utils
14
+ */
15
+ // ============================================================================
16
+ // SET OF COMMANDS
17
+ // ============================================================================
18
+ /**
19
+ * Set of system utility commands handled by this module
20
+ */
21
+ export const SYSTEM_UTILS_COMMANDS = new Set([
22
+ 'sleep',
23
+ 'yes',
24
+ 'seq',
25
+ 'pwd',
26
+ 'whoami',
27
+ 'hostname',
28
+ 'printenv',
29
+ ]);
30
+ /**
31
+ * Check if a command is a system utility command
32
+ */
33
+ export function isSystemUtilsCommand(cmd) {
34
+ return SYSTEM_UTILS_COMMANDS.has(cmd);
35
+ }
36
+ // ============================================================================
37
+ // TIMING UTILITIES
38
+ // ============================================================================
39
+ /**
40
+ * Time unit multipliers in milliseconds
41
+ */
42
+ const TIME_UNIT_MS = {
43
+ s: 1000,
44
+ m: 60 * 1000,
45
+ h: 60 * 60 * 1000,
46
+ d: 24 * 60 * 60 * 1000,
47
+ };
48
+ /**
49
+ * Parse a duration string into milliseconds
50
+ *
51
+ * @param duration - Duration string with optional unit suffix (s, m, h, d)
52
+ * @returns Duration in milliseconds
53
+ * @throws Error if duration format is invalid
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * parseDuration('5') // 5000 (seconds)
58
+ * parseDuration('1.5s') // 1500
59
+ * parseDuration('2m') // 120000
60
+ * parseDuration('1h') // 3600000
61
+ * parseDuration('1d') // 86400000
62
+ * ```
63
+ */
64
+ export function parseDuration(duration) {
65
+ // Handle 'infinity' case
66
+ if (duration.toLowerCase() === 'infinity') {
67
+ return Infinity;
68
+ }
69
+ const match = duration.match(/^(\d+(?:\.\d+)?)(s|m|h|d)?$/i);
70
+ if (!match) {
71
+ throw new Error(`Invalid duration: ${duration}`);
72
+ }
73
+ const value = parseFloat(match[1]);
74
+ const unit = match[2]?.toLowerCase() || 's';
75
+ return value * (TIME_UNIT_MS[unit] ?? 1000);
76
+ }
77
+ /**
78
+ * Create a delay promise
79
+ */
80
+ function delay(ms) {
81
+ return new Promise(resolve => setTimeout(resolve, ms));
82
+ }
83
+ // ============================================================================
84
+ // SLEEP COMMAND
85
+ // ============================================================================
86
+ /**
87
+ * Execute sleep command - delay for a specified duration
88
+ *
89
+ * Supports multiple duration arguments which are summed together.
90
+ * Durations can have suffixes: s (seconds, default), m (minutes),
91
+ * h (hours), d (days).
92
+ *
93
+ * @param args - Duration arguments
94
+ * @param options - Sleep options
95
+ * @returns Promise resolving to command result
96
+ *
97
+ * @example
98
+ * ```typescript
99
+ * await executeSleep(['1']) // Sleep 1 second
100
+ * await executeSleep(['0.5']) // Sleep 500ms
101
+ * await executeSleep(['1m']) // Sleep 1 minute
102
+ * await executeSleep(['1', '2']) // Sleep 3 seconds total
103
+ * ```
104
+ */
105
+ export async function executeSleep(args, options = {}) {
106
+ if (args.length === 0) {
107
+ return {
108
+ stdout: '',
109
+ stderr: 'sleep: missing operand',
110
+ exitCode: 1,
111
+ };
112
+ }
113
+ const maxDuration = options.maxDuration ?? 600000; // 10 minutes default max
114
+ try {
115
+ let totalMs = 0;
116
+ for (const duration of args) {
117
+ const ms = parseDuration(duration);
118
+ if (ms < 0) {
119
+ return {
120
+ stdout: '',
121
+ stderr: `sleep: invalid time interval '${duration}'`,
122
+ exitCode: 1,
123
+ };
124
+ }
125
+ if (!isFinite(ms)) {
126
+ // Infinity - would sleep forever, but we'll cap it
127
+ return {
128
+ stdout: '',
129
+ stderr: 'sleep: cannot sleep indefinitely in this environment',
130
+ exitCode: 1,
131
+ };
132
+ }
133
+ totalMs += ms;
134
+ }
135
+ // Apply safety limit
136
+ const actualDuration = Math.min(totalMs, maxDuration);
137
+ await delay(actualDuration);
138
+ return {
139
+ stdout: '',
140
+ stderr: '',
141
+ exitCode: 0,
142
+ };
143
+ }
144
+ catch (error) {
145
+ const message = error instanceof Error ? error.message : String(error);
146
+ return {
147
+ stdout: '',
148
+ stderr: `sleep: ${message}`,
149
+ exitCode: 1,
150
+ };
151
+ }
152
+ }
153
+ // ============================================================================
154
+ // YES COMMAND
155
+ // ============================================================================
156
+ /**
157
+ * Execute yes command - output string repeatedly
158
+ *
159
+ * Outputs "y" (or the specified string) repeatedly, one per line.
160
+ * Limited to maxLines for safety in non-streaming environments.
161
+ *
162
+ * @param args - Optional string to repeat (default: "y")
163
+ * @param options - Yes options
164
+ * @returns Command result
165
+ *
166
+ * @example
167
+ * ```typescript
168
+ * executeYes([]) // "y\ny\ny\n..." (1000 times)
169
+ * executeYes(['hello']) // "hello\nhello\nhello\n..." (1000 times)
170
+ * executeYes(['a', 'b']) // "a b\na b\na b\n..." (arguments joined)
171
+ * ```
172
+ */
173
+ export function executeYes(args, options = {}) {
174
+ const maxLines = options.maxLines ?? 1000;
175
+ const output = args.length > 0 ? args.join(' ') : 'y';
176
+ const lines = [];
177
+ for (let i = 0; i < maxLines; i++) {
178
+ lines.push(output);
179
+ }
180
+ return {
181
+ stdout: lines.join('\n') + '\n',
182
+ stderr: '',
183
+ exitCode: 0,
184
+ };
185
+ }
186
+ // ============================================================================
187
+ // SEQ COMMAND
188
+ // ============================================================================
189
+ /**
190
+ * Execute seq command - generate number sequence
191
+ *
192
+ * Generates a sequence of numbers from first to last with given increment.
193
+ *
194
+ * @param args - Number arguments: [last], [first, last], or [first, incr, last]
195
+ * @param options - Seq options
196
+ * @returns Command result
197
+ *
198
+ * @example
199
+ * ```typescript
200
+ * executeSeq(['5']) // "1\n2\n3\n4\n5\n"
201
+ * executeSeq(['2', '5']) // "2\n3\n4\n5\n"
202
+ * executeSeq(['1', '2', '10']) // "1\n3\n5\n7\n9\n"
203
+ * executeSeq(['5', '-1', '1']) // "5\n4\n3\n2\n1\n"
204
+ * ```
205
+ */
206
+ export function executeSeq(args, options = {}) {
207
+ if (args.length === 0) {
208
+ return {
209
+ stdout: '',
210
+ stderr: 'seq: missing operand',
211
+ exitCode: 1,
212
+ };
213
+ }
214
+ // Parse numeric arguments
215
+ const numArgs = [];
216
+ for (const arg of args) {
217
+ const num = parseFloat(arg);
218
+ if (isNaN(num)) {
219
+ return {
220
+ stdout: '',
221
+ stderr: `seq: invalid floating point argument: '${arg}'`,
222
+ exitCode: 1,
223
+ };
224
+ }
225
+ numArgs.push(num);
226
+ }
227
+ // Determine first, increment, last
228
+ let first = 1;
229
+ let increment = 1;
230
+ let last;
231
+ if (numArgs.length === 1) {
232
+ last = numArgs[0];
233
+ }
234
+ else if (numArgs.length === 2) {
235
+ first = numArgs[0];
236
+ last = numArgs[1];
237
+ }
238
+ else if (numArgs.length >= 3) {
239
+ first = numArgs[0];
240
+ increment = numArgs[1];
241
+ last = numArgs[2];
242
+ }
243
+ else {
244
+ return {
245
+ stdout: '',
246
+ stderr: 'seq: missing operand',
247
+ exitCode: 1,
248
+ };
249
+ }
250
+ // Handle impossible ranges
251
+ if (increment === 0) {
252
+ return {
253
+ stdout: '',
254
+ stderr: 'seq: invalid Zero increment value',
255
+ exitCode: 1,
256
+ };
257
+ }
258
+ // Handle backwards sequences
259
+ if ((increment > 0 && first > last) || (increment < 0 && first < last)) {
260
+ return {
261
+ stdout: '',
262
+ stderr: '',
263
+ exitCode: 0,
264
+ };
265
+ }
266
+ const results = [];
267
+ const separator = options.separator ?? '\n';
268
+ // Calculate width for equal-width option
269
+ const firstStr = String(first);
270
+ const lastStr = String(last);
271
+ const maxWidth = Math.max(firstStr.length, lastStr.length);
272
+ // Determine decimal places
273
+ const firstDecimals = (firstStr.split('.')[1] || '').length;
274
+ const incrementDecimals = (String(increment).split('.')[1] || '').length;
275
+ const lastDecimals = (lastStr.split('.')[1] || '').length;
276
+ const decimalPlaces = Math.max(firstDecimals, incrementDecimals, lastDecimals);
277
+ // Safety limit
278
+ const maxIterations = 100000;
279
+ let iterations = 0;
280
+ if (increment > 0) {
281
+ for (let i = first; i <= last && iterations < maxIterations; i += increment) {
282
+ let numStr;
283
+ if (options.format) {
284
+ // Simple format support
285
+ numStr = formatNumber(i, options.format);
286
+ }
287
+ else if (decimalPlaces > 0) {
288
+ numStr = i.toFixed(decimalPlaces);
289
+ }
290
+ else {
291
+ numStr = String(Math.round(i));
292
+ }
293
+ if (options.equalWidth && !options.format) {
294
+ numStr = numStr.padStart(maxWidth, '0');
295
+ }
296
+ results.push(numStr);
297
+ iterations++;
298
+ }
299
+ }
300
+ else {
301
+ for (let i = first; i >= last && iterations < maxIterations; i += increment) {
302
+ let numStr;
303
+ if (options.format) {
304
+ numStr = formatNumber(i, options.format);
305
+ }
306
+ else if (decimalPlaces > 0) {
307
+ numStr = i.toFixed(decimalPlaces);
308
+ }
309
+ else {
310
+ numStr = String(Math.round(i));
311
+ }
312
+ if (options.equalWidth && !options.format) {
313
+ numStr = numStr.padStart(maxWidth, '0');
314
+ }
315
+ results.push(numStr);
316
+ iterations++;
317
+ }
318
+ }
319
+ return {
320
+ stdout: results.join(separator) + (results.length > 0 ? '\n' : ''),
321
+ stderr: '',
322
+ exitCode: 0,
323
+ };
324
+ }
325
+ /**
326
+ * Format a number using a printf-style format string
327
+ */
328
+ function formatNumber(value, format) {
329
+ // Support %g, %f, %e formats
330
+ const match = format.match(/%(\d+)?(?:\.(\d+))?([gfeE])/);
331
+ if (!match) {
332
+ return String(value);
333
+ }
334
+ const width = match[1] ? parseInt(match[1], 10) : 0;
335
+ const precision = match[2] ? parseInt(match[2], 10) : undefined;
336
+ const type = match[3];
337
+ let result;
338
+ switch (type) {
339
+ case 'f':
340
+ result = precision !== undefined ? value.toFixed(precision) : value.toFixed(6);
341
+ break;
342
+ case 'e':
343
+ result = precision !== undefined ? value.toExponential(precision) : value.toExponential();
344
+ break;
345
+ case 'E':
346
+ result = (precision !== undefined ? value.toExponential(precision) : value.toExponential()).toUpperCase();
347
+ break;
348
+ case 'g':
349
+ default:
350
+ result = precision !== undefined ? value.toPrecision(precision) : String(value);
351
+ break;
352
+ }
353
+ if (width > result.length) {
354
+ result = result.padStart(width, ' ');
355
+ }
356
+ return result;
357
+ }
358
+ // ============================================================================
359
+ // PWD COMMAND
360
+ // ============================================================================
361
+ /**
362
+ * Execute pwd command - print working directory
363
+ *
364
+ * Returns the current working directory. With -L flag (default), returns
365
+ * the logical path (may include symlinks). With -P flag, returns the
366
+ * physical path (symlinks resolved).
367
+ *
368
+ * @param args - Command arguments (-L or -P)
369
+ * @param context - Execution context with cwd
370
+ * @returns Command result
371
+ *
372
+ * @example
373
+ * ```typescript
374
+ * executePwd([], { cwd: '/home/user' })
375
+ * // => { stdout: '/home/user\n', ... }
376
+ *
377
+ * executePwd(['-P'], { cwd: '/home/user' })
378
+ * // => { stdout: '/home/user\n', ... } (symlinks resolved if any)
379
+ * ```
380
+ */
381
+ export function executePwd(args, context = {}) {
382
+ // Parse flags
383
+ let usePhysical = false;
384
+ for (const arg of args) {
385
+ if (arg === '-P') {
386
+ usePhysical = true;
387
+ }
388
+ else if (arg === '-L') {
389
+ usePhysical = false;
390
+ }
391
+ else if (arg.startsWith('-') && arg !== '-') {
392
+ return {
393
+ stdout: '',
394
+ stderr: `pwd: invalid option -- '${arg.slice(1)}'`,
395
+ exitCode: 1,
396
+ };
397
+ }
398
+ }
399
+ // Get current working directory
400
+ let cwd = context.cwd || '/';
401
+ // In Workers environment, we don't have real symlink resolution,
402
+ // but we support the -P flag for compatibility
403
+ if (usePhysical) {
404
+ // Normalize path by removing . and .. components
405
+ cwd = normalizePath(cwd);
406
+ }
407
+ return {
408
+ stdout: cwd + '\n',
409
+ stderr: '',
410
+ exitCode: 0,
411
+ };
412
+ }
413
+ /**
414
+ * Normalize a path by resolving . and .. components
415
+ */
416
+ function normalizePath(path) {
417
+ const isAbsolute = path.startsWith('/');
418
+ const parts = path.split('/').filter(p => p && p !== '.');
419
+ const result = [];
420
+ for (const part of parts) {
421
+ if (part === '..') {
422
+ if (result.length > 0 && result[result.length - 1] !== '..') {
423
+ result.pop();
424
+ }
425
+ else if (!isAbsolute) {
426
+ result.push('..');
427
+ }
428
+ }
429
+ else {
430
+ result.push(part);
431
+ }
432
+ }
433
+ const normalized = result.join('/');
434
+ return isAbsolute ? '/' + normalized : normalized || '.';
435
+ }
436
+ // ============================================================================
437
+ // WHOAMI COMMAND
438
+ // ============================================================================
439
+ /**
440
+ * Execute whoami command - print current username
441
+ *
442
+ * Returns the username from context or environment variables.
443
+ * Checks in order: context.user, env.USER, env.LOGNAME, then defaults.
444
+ *
445
+ * @param _args - Command arguments (unused, for interface consistency)
446
+ * @param context - Execution context with user or env
447
+ * @returns Command result
448
+ *
449
+ * @example
450
+ * ```typescript
451
+ * executeWhoami([], { user: 'alice' })
452
+ * // => { stdout: 'alice\n', ... }
453
+ *
454
+ * executeWhoami([], { env: { USER: 'bob' } })
455
+ * // => { stdout: 'bob\n', ... }
456
+ * ```
457
+ */
458
+ export function executeWhoami(_args, context = {}) {
459
+ // Check context.user first
460
+ if (context.user) {
461
+ return {
462
+ stdout: context.user + '\n',
463
+ stderr: '',
464
+ exitCode: 0,
465
+ };
466
+ }
467
+ // Check environment variables
468
+ const env = context.env || {};
469
+ const user = env.USER || env.LOGNAME || env.USERNAME;
470
+ if (user) {
471
+ return {
472
+ stdout: user + '\n',
473
+ stderr: '',
474
+ exitCode: 0,
475
+ };
476
+ }
477
+ // Default for Workers environment
478
+ return {
479
+ stdout: 'worker\n',
480
+ stderr: '',
481
+ exitCode: 0,
482
+ };
483
+ }
484
+ // ============================================================================
485
+ // HOSTNAME COMMAND
486
+ // ============================================================================
487
+ /**
488
+ * Execute hostname command - print system hostname
489
+ *
490
+ * Returns the hostname from context or environment variables.
491
+ * In Workers environment, defaults to 'worker.local'.
492
+ *
493
+ * @param args - Command arguments (supports -s for short hostname)
494
+ * @param context - Execution context with hostname
495
+ * @returns Command result
496
+ *
497
+ * @example
498
+ * ```typescript
499
+ * executeHostname([], { hostname: 'server.example.com.ai' })
500
+ * // => { stdout: 'server.example.com.ai\n', ... }
501
+ *
502
+ * executeHostname(['-s'], { hostname: 'server.example.com.ai' })
503
+ * // => { stdout: 'server\n', ... }
504
+ * ```
505
+ */
506
+ export function executeHostname(args, context = {}) {
507
+ // Parse flags
508
+ let shortName = false;
509
+ for (const arg of args) {
510
+ if (arg === '-s' || arg === '--short') {
511
+ shortName = true;
512
+ }
513
+ else if (arg === '-f' || arg === '--fqdn' || arg === '--long') {
514
+ shortName = false;
515
+ }
516
+ else if (arg.startsWith('-') && arg !== '-') {
517
+ return {
518
+ stdout: '',
519
+ stderr: `hostname: invalid option -- '${arg.slice(1)}'`,
520
+ exitCode: 1,
521
+ };
522
+ }
523
+ }
524
+ // Get hostname from context or environment
525
+ let hostname = context.hostname;
526
+ if (!hostname) {
527
+ const env = context.env || {};
528
+ hostname = env.HOSTNAME || env.HOST || 'worker.local';
529
+ }
530
+ // Return short name if requested
531
+ if (shortName && hostname.includes('.')) {
532
+ hostname = hostname.split('.')[0];
533
+ }
534
+ return {
535
+ stdout: hostname + '\n',
536
+ stderr: '',
537
+ exitCode: 0,
538
+ };
539
+ }
540
+ // ============================================================================
541
+ // PRINTENV COMMAND
542
+ // ============================================================================
543
+ /**
544
+ * Execute printenv command - print environment variables
545
+ *
546
+ * With no arguments, prints all environment variables.
547
+ * With variable names as arguments, prints only those variables.
548
+ *
549
+ * @param args - Variable names to print (empty for all)
550
+ * @param context - Execution context with env
551
+ * @param options - Printenv options
552
+ * @returns Command result
553
+ *
554
+ * @example
555
+ * ```typescript
556
+ * executePrintenv([], { env: { FOO: 'bar', BAZ: 'qux' } })
557
+ * // => { stdout: 'FOO=bar\nBAZ=qux\n', ... }
558
+ *
559
+ * executePrintenv(['FOO'], { env: { FOO: 'bar', BAZ: 'qux' } })
560
+ * // => { stdout: 'bar\n', ... }
561
+ *
562
+ * executePrintenv(['MISSING'], { env: { FOO: 'bar' } })
563
+ * // => { exitCode: 1, ... }
564
+ * ```
565
+ */
566
+ export function executePrintenv(args, context = {}, options = {}) {
567
+ const env = context.env || {};
568
+ const separator = options.null ? '\0' : '\n';
569
+ // Parse flags and collect variable names
570
+ const varNames = [];
571
+ for (const arg of args) {
572
+ if (arg === '-0' || arg === '--null') {
573
+ options.null = true;
574
+ }
575
+ else if (arg.startsWith('-') && arg !== '-') {
576
+ // Unknown flag - ignore (printenv is lenient)
577
+ varNames.push(arg);
578
+ }
579
+ else {
580
+ varNames.push(arg);
581
+ }
582
+ }
583
+ if (varNames.length === 0) {
584
+ // Print all environment variables
585
+ const lines = [];
586
+ for (const [key, value] of Object.entries(env)) {
587
+ if (value !== undefined) {
588
+ lines.push(`${key}=${value}`);
589
+ }
590
+ }
591
+ // Sort for consistent output
592
+ lines.sort();
593
+ return {
594
+ stdout: lines.join(separator) + (lines.length > 0 ? separator : ''),
595
+ stderr: '',
596
+ exitCode: 0,
597
+ };
598
+ }
599
+ // Print specific variables
600
+ const outputs = [];
601
+ let allFound = true;
602
+ for (const name of varNames) {
603
+ const value = env[name];
604
+ if (value !== undefined) {
605
+ outputs.push(value);
606
+ }
607
+ else {
608
+ allFound = false;
609
+ }
610
+ }
611
+ return {
612
+ stdout: outputs.join(separator) + (outputs.length > 0 ? separator : ''),
613
+ stderr: '',
614
+ exitCode: allFound ? 0 : 1,
615
+ };
616
+ }
617
+ // ============================================================================
618
+ // UNIFIED EXECUTOR
619
+ // ============================================================================
620
+ /**
621
+ * Execute a system utility command
622
+ *
623
+ * Routes to the appropriate command implementation based on command name.
624
+ *
625
+ * @param command - Command name
626
+ * @param args - Command arguments
627
+ * @param context - Execution context
628
+ * @returns Command result or null if command not supported
629
+ *
630
+ * @example
631
+ * ```typescript
632
+ * const result = await executeSystemUtils('pwd', [], { cwd: '/home/user' })
633
+ * // => { stdout: '/home/user\n', stderr: '', exitCode: 0 }
634
+ * ```
635
+ */
636
+ export async function executeSystemUtils(command, args, context = {}) {
637
+ if (!SYSTEM_UTILS_COMMANDS.has(command)) {
638
+ return null;
639
+ }
640
+ switch (command) {
641
+ case 'sleep':
642
+ return executeSleep(args);
643
+ case 'yes':
644
+ return executeYes(args);
645
+ case 'seq': {
646
+ // Parse seq-specific options
647
+ const seqOptions = {};
648
+ const numArgs = [];
649
+ for (let i = 0; i < args.length; i++) {
650
+ const arg = args[i];
651
+ if (arg === '-s' && args[i + 1] !== undefined) {
652
+ seqOptions.separator = args[++i]
653
+ .replace(/\\t/g, '\t')
654
+ .replace(/\\n/g, '\n');
655
+ }
656
+ else if (arg === '-w') {
657
+ seqOptions.equalWidth = true;
658
+ }
659
+ else if (arg === '-f' && args[i + 1] !== undefined) {
660
+ seqOptions.format = args[++i];
661
+ }
662
+ else if (!arg.startsWith('-')) {
663
+ numArgs.push(arg);
664
+ }
665
+ }
666
+ return executeSeq(numArgs, seqOptions);
667
+ }
668
+ case 'pwd': {
669
+ const pwdArgs = args.filter(a => a === '-L' || a === '-P');
670
+ return executePwd(pwdArgs, context);
671
+ }
672
+ case 'whoami':
673
+ return executeWhoami(args, context);
674
+ case 'hostname':
675
+ return executeHostname(args, context);
676
+ case 'printenv': {
677
+ const printenvOptions = {
678
+ null: args.includes('-0') || args.includes('--null'),
679
+ };
680
+ const varArgs = args.filter(a => a !== '-0' && a !== '--null');
681
+ return executePrintenv(varArgs, context, printenvOptions);
682
+ }
683
+ default:
684
+ return null;
685
+ }
686
+ }
687
+ //# sourceMappingURL=system-utils.js.map