orchajs 0.18.0 → 0.20.0

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 (286) hide show
  1. package/README.md +93 -9
  2. package/dist/amarsia/metadata.d.ts +0 -1
  3. package/dist/amarsia/metadata.js +0 -1
  4. package/dist/amarsia/sync.d.ts +0 -1
  5. package/dist/amarsia/sync.js +0 -1
  6. package/dist/cli-agents-template.d.ts +0 -1
  7. package/dist/cli-agents-template.js +0 -1
  8. package/dist/cli.d.ts +0 -1
  9. package/dist/cli.js +0 -1
  10. package/dist/compiler/build-project.d.ts +0 -1
  11. package/dist/compiler/build-project.js +0 -1
  12. package/dist/compiler/compile.d.ts +0 -1
  13. package/dist/compiler/compile.js +0 -1
  14. package/dist/env.d.ts +0 -1
  15. package/dist/env.js +0 -1
  16. package/dist/errors.d.ts +0 -1
  17. package/dist/errors.js +0 -1
  18. package/dist/file-content.d.ts +0 -1
  19. package/dist/file-content.js +0 -1
  20. package/dist/index.d.ts +0 -1
  21. package/dist/index.js +0 -1
  22. package/dist/integrations/esbuild.d.ts +0 -1
  23. package/dist/integrations/esbuild.js +0 -1
  24. package/dist/integrations/serverless.d.ts +27 -0
  25. package/dist/integrations/serverless.js +78 -0
  26. package/dist/orcha.d.ts +0 -1
  27. package/dist/orcha.js +0 -1
  28. package/dist/playground/public/app.css +0 -1
  29. package/dist/playground/public/app.js +0 -1
  30. package/dist/playground/server.d.ts +0 -1
  31. package/dist/playground/server.js +0 -1
  32. package/dist/playground/source.d.ts +0 -1
  33. package/dist/playground/source.js +0 -1
  34. package/dist/project-loader.d.ts +0 -1
  35. package/dist/project-loader.js +0 -1
  36. package/dist/providers/anthropic.d.ts +0 -1
  37. package/dist/providers/anthropic.js +0 -1
  38. package/dist/providers/bedrock.d.ts +0 -1
  39. package/dist/providers/bedrock.js +0 -1
  40. package/dist/providers/catalog.d.ts +0 -1
  41. package/dist/providers/catalog.js +0 -1
  42. package/dist/providers/deepseek.d.ts +0 -1
  43. package/dist/providers/deepseek.js +0 -1
  44. package/dist/providers/dispatcher.d.ts +0 -1
  45. package/dist/providers/dispatcher.js +0 -1
  46. package/dist/providers/google-gemini.d.ts +0 -1
  47. package/dist/providers/google-gemini.js +0 -1
  48. package/dist/providers/google-genai.d.ts +0 -1
  49. package/dist/providers/google-genai.js +0 -1
  50. package/dist/providers/index.d.ts +0 -1
  51. package/dist/providers/index.js +20 -5
  52. package/dist/providers/openai.d.ts +0 -1
  53. package/dist/providers/openai.js +0 -1
  54. package/dist/providers/sse.d.ts +0 -1
  55. package/dist/providers/sse.js +0 -1
  56. package/dist/providers/types.d.ts +0 -1
  57. package/dist/providers/types.js +0 -1
  58. package/dist/providers/vertex-ai.d.ts +0 -1
  59. package/dist/providers/vertex-ai.js +0 -1
  60. package/dist/runtime/actions/context.d.ts +0 -1
  61. package/dist/runtime/actions/context.js +0 -1
  62. package/dist/runtime/actions/execute.d.ts +0 -1
  63. package/dist/runtime/actions/execute.js +14 -2
  64. package/dist/runtime/actions/native.d.ts +0 -1
  65. package/dist/runtime/actions/native.js +0 -1
  66. package/dist/runtime/actions/sandbox.d.ts +0 -1
  67. package/dist/runtime/actions/sandbox.js +0 -1
  68. package/dist/runtime/agent.d.ts +0 -1
  69. package/dist/runtime/agent.js +0 -1
  70. package/dist/runtime/context.d.ts +0 -1
  71. package/dist/runtime/context.js +0 -1
  72. package/dist/runtime/create-orcha.d.ts +0 -1
  73. package/dist/runtime/create-orcha.js +0 -1
  74. package/dist/runtime/execution.d.ts +0 -1
  75. package/dist/runtime/execution.js +0 -1
  76. package/dist/runtime/session-events.d.ts +0 -1
  77. package/dist/runtime/session-events.js +0 -1
  78. package/dist/runtime/structured-output.d.ts +0 -1
  79. package/dist/runtime/structured-output.js +0 -1
  80. package/dist/storage/browser-indexeddb.d.ts +0 -1
  81. package/dist/storage/browser-indexeddb.js +0 -1
  82. package/dist/storage/create-store.d.ts +0 -1
  83. package/dist/storage/create-store.js +0 -1
  84. package/dist/storage/edge-store.d.ts +0 -1
  85. package/dist/storage/edge-store.js +0 -1
  86. package/dist/storage/migrate.d.ts +0 -1
  87. package/dist/storage/migrate.js +0 -1
  88. package/dist/storage/node-jsonl.d.ts +0 -1
  89. package/dist/storage/node-jsonl.js +0 -1
  90. package/dist/storage/node-sqlite.d.ts +0 -1
  91. package/dist/storage/node-sqlite.js +1 -2
  92. package/dist/storage/react-native-jsonl.d.ts +0 -1
  93. package/dist/storage/react-native-jsonl.js +0 -1
  94. package/dist/testing.d.ts +0 -1
  95. package/dist/testing.js +0 -1
  96. package/dist/types.d.ts +0 -1
  97. package/dist/types.js +0 -1
  98. package/dist-cjs/amarsia/metadata.js +0 -1
  99. package/dist-cjs/amarsia/sync.js +0 -1
  100. package/dist-cjs/cli-agents-template.js +0 -1
  101. package/dist-cjs/compiler/build-project.js +0 -1
  102. package/dist-cjs/compiler/compile.js +0 -1
  103. package/dist-cjs/env.js +0 -1
  104. package/dist-cjs/errors.js +0 -1
  105. package/dist-cjs/file-content.js +0 -1
  106. package/dist-cjs/index.js +0 -1
  107. package/dist-cjs/integrations/esbuild.js +0 -1
  108. package/dist-cjs/integrations/serverless.cjs +2 -0
  109. package/dist-cjs/integrations/serverless.js +125 -0
  110. package/dist-cjs/orcha.js +0 -1
  111. package/dist-cjs/playground/server.js +0 -1
  112. package/dist-cjs/playground/source.js +0 -1
  113. package/dist-cjs/project-loader.js +0 -1
  114. package/dist-cjs/providers/anthropic.js +0 -1
  115. package/dist-cjs/providers/bedrock.js +0 -1
  116. package/dist-cjs/providers/catalog.js +0 -1
  117. package/dist-cjs/providers/deepseek.js +0 -1
  118. package/dist-cjs/providers/dispatcher.js +0 -1
  119. package/dist-cjs/providers/google-gemini.js +0 -1
  120. package/dist-cjs/providers/google-genai.js +0 -1
  121. package/dist-cjs/providers/index.js +16 -3
  122. package/dist-cjs/providers/openai.js +0 -1
  123. package/dist-cjs/providers/sse.js +0 -1
  124. package/dist-cjs/providers/types.js +0 -1
  125. package/dist-cjs/providers/vertex-ai.js +0 -1
  126. package/dist-cjs/runtime/actions/context.js +0 -1
  127. package/dist-cjs/runtime/actions/execute.js +16 -2
  128. package/dist-cjs/runtime/actions/native.js +0 -1
  129. package/dist-cjs/runtime/actions/sandbox.js +0 -1
  130. package/dist-cjs/runtime/agent.js +0 -1
  131. package/dist-cjs/runtime/context.js +0 -1
  132. package/dist-cjs/runtime/create-orcha.js +0 -1
  133. package/dist-cjs/runtime/execution.js +0 -1
  134. package/dist-cjs/runtime/session-events.js +0 -1
  135. package/dist-cjs/runtime/structured-output.js +0 -1
  136. package/dist-cjs/storage/browser-indexeddb.js +0 -1
  137. package/dist-cjs/storage/create-store.js +0 -1
  138. package/dist-cjs/storage/edge-store.js +0 -1
  139. package/dist-cjs/storage/migrate.js +0 -1
  140. package/dist-cjs/storage/node-jsonl.js +0 -1
  141. package/dist-cjs/storage/node-sqlite.js +1 -2
  142. package/dist-cjs/storage/react-native-jsonl.js +0 -1
  143. package/dist-cjs/testing.js +0 -1
  144. package/dist-cjs/types/google-genai-sdk.d.js +0 -1
  145. package/dist-cjs/types.js +0 -1
  146. package/package.json +41 -9
  147. package/dist/amarsia/metadata.d.ts.map +0 -1
  148. package/dist/amarsia/metadata.js.map +0 -1
  149. package/dist/amarsia/sync.d.ts.map +0 -1
  150. package/dist/amarsia/sync.js.map +0 -1
  151. package/dist/cli-agents-template.d.ts.map +0 -1
  152. package/dist/cli-agents-template.js.map +0 -1
  153. package/dist/cli.d.ts.map +0 -1
  154. package/dist/cli.js.map +0 -1
  155. package/dist/compiler/build-project.d.ts.map +0 -1
  156. package/dist/compiler/build-project.js.map +0 -1
  157. package/dist/compiler/compile.d.ts.map +0 -1
  158. package/dist/compiler/compile.js.map +0 -1
  159. package/dist/env.d.ts.map +0 -1
  160. package/dist/env.js.map +0 -1
  161. package/dist/errors.d.ts.map +0 -1
  162. package/dist/errors.js.map +0 -1
  163. package/dist/file-content.d.ts.map +0 -1
  164. package/dist/file-content.js.map +0 -1
  165. package/dist/index.d.ts.map +0 -1
  166. package/dist/index.js.map +0 -1
  167. package/dist/integrations/esbuild.d.ts.map +0 -1
  168. package/dist/integrations/esbuild.js.map +0 -1
  169. package/dist/orcha.d.ts.map +0 -1
  170. package/dist/orcha.js.map +0 -1
  171. package/dist/playground/public/app.css.map +0 -7
  172. package/dist/playground/public/app.js.map +0 -7
  173. package/dist/playground/server.d.ts.map +0 -1
  174. package/dist/playground/server.js.map +0 -1
  175. package/dist/playground/source.d.ts.map +0 -1
  176. package/dist/playground/source.js.map +0 -1
  177. package/dist/project-loader.d.ts.map +0 -1
  178. package/dist/project-loader.js.map +0 -1
  179. package/dist/providers/anthropic.d.ts.map +0 -1
  180. package/dist/providers/anthropic.js.map +0 -1
  181. package/dist/providers/bedrock.d.ts.map +0 -1
  182. package/dist/providers/bedrock.js.map +0 -1
  183. package/dist/providers/catalog.d.ts.map +0 -1
  184. package/dist/providers/catalog.js.map +0 -1
  185. package/dist/providers/deepseek.d.ts.map +0 -1
  186. package/dist/providers/deepseek.js.map +0 -1
  187. package/dist/providers/dispatcher.d.ts.map +0 -1
  188. package/dist/providers/dispatcher.js.map +0 -1
  189. package/dist/providers/google-gemini.d.ts.map +0 -1
  190. package/dist/providers/google-gemini.js.map +0 -1
  191. package/dist/providers/google-genai.d.ts.map +0 -1
  192. package/dist/providers/google-genai.js.map +0 -1
  193. package/dist/providers/index.d.ts.map +0 -1
  194. package/dist/providers/index.js.map +0 -1
  195. package/dist/providers/openai.d.ts.map +0 -1
  196. package/dist/providers/openai.js.map +0 -1
  197. package/dist/providers/sse.d.ts.map +0 -1
  198. package/dist/providers/sse.js.map +0 -1
  199. package/dist/providers/types.d.ts.map +0 -1
  200. package/dist/providers/types.js.map +0 -1
  201. package/dist/providers/vertex-ai.d.ts.map +0 -1
  202. package/dist/providers/vertex-ai.js.map +0 -1
  203. package/dist/runtime/actions/context.d.ts.map +0 -1
  204. package/dist/runtime/actions/context.js.map +0 -1
  205. package/dist/runtime/actions/execute.d.ts.map +0 -1
  206. package/dist/runtime/actions/execute.js.map +0 -1
  207. package/dist/runtime/actions/native.d.ts.map +0 -1
  208. package/dist/runtime/actions/native.js.map +0 -1
  209. package/dist/runtime/actions/sandbox.d.ts.map +0 -1
  210. package/dist/runtime/actions/sandbox.js.map +0 -1
  211. package/dist/runtime/agent.d.ts.map +0 -1
  212. package/dist/runtime/agent.js.map +0 -1
  213. package/dist/runtime/context.d.ts.map +0 -1
  214. package/dist/runtime/context.js.map +0 -1
  215. package/dist/runtime/create-orcha.d.ts.map +0 -1
  216. package/dist/runtime/create-orcha.js.map +0 -1
  217. package/dist/runtime/execution.d.ts.map +0 -1
  218. package/dist/runtime/execution.js.map +0 -1
  219. package/dist/runtime/session-events.d.ts.map +0 -1
  220. package/dist/runtime/session-events.js.map +0 -1
  221. package/dist/runtime/structured-output.d.ts.map +0 -1
  222. package/dist/runtime/structured-output.js.map +0 -1
  223. package/dist/storage/browser-indexeddb.d.ts.map +0 -1
  224. package/dist/storage/browser-indexeddb.js.map +0 -1
  225. package/dist/storage/create-store.d.ts.map +0 -1
  226. package/dist/storage/create-store.js.map +0 -1
  227. package/dist/storage/edge-store.d.ts.map +0 -1
  228. package/dist/storage/edge-store.js.map +0 -1
  229. package/dist/storage/migrate.d.ts.map +0 -1
  230. package/dist/storage/migrate.js.map +0 -1
  231. package/dist/storage/node-jsonl.d.ts.map +0 -1
  232. package/dist/storage/node-jsonl.js.map +0 -1
  233. package/dist/storage/node-sqlite.d.ts.map +0 -1
  234. package/dist/storage/node-sqlite.js.map +0 -1
  235. package/dist/storage/react-native-jsonl.d.ts.map +0 -1
  236. package/dist/storage/react-native-jsonl.js.map +0 -1
  237. package/dist/testing.d.ts.map +0 -1
  238. package/dist/testing.js.map +0 -1
  239. package/dist/types.d.ts.map +0 -1
  240. package/dist/types.js.map +0 -1
  241. package/dist-cjs/amarsia/metadata.js.map +0 -7
  242. package/dist-cjs/amarsia/sync.js.map +0 -7
  243. package/dist-cjs/cli-agents-template.js.map +0 -7
  244. package/dist-cjs/compiler/build-project.js.map +0 -7
  245. package/dist-cjs/compiler/compile.js.map +0 -7
  246. package/dist-cjs/env.js.map +0 -7
  247. package/dist-cjs/errors.js.map +0 -7
  248. package/dist-cjs/file-content.js.map +0 -7
  249. package/dist-cjs/index.js.map +0 -7
  250. package/dist-cjs/integrations/esbuild.js.map +0 -7
  251. package/dist-cjs/orcha.js.map +0 -7
  252. package/dist-cjs/playground/server.js.map +0 -7
  253. package/dist-cjs/playground/source.js.map +0 -7
  254. package/dist-cjs/project-loader.js.map +0 -7
  255. package/dist-cjs/providers/anthropic.js.map +0 -7
  256. package/dist-cjs/providers/bedrock.js.map +0 -7
  257. package/dist-cjs/providers/catalog.js.map +0 -7
  258. package/dist-cjs/providers/deepseek.js.map +0 -7
  259. package/dist-cjs/providers/dispatcher.js.map +0 -7
  260. package/dist-cjs/providers/google-gemini.js.map +0 -7
  261. package/dist-cjs/providers/google-genai.js.map +0 -7
  262. package/dist-cjs/providers/index.js.map +0 -7
  263. package/dist-cjs/providers/openai.js.map +0 -7
  264. package/dist-cjs/providers/sse.js.map +0 -7
  265. package/dist-cjs/providers/types.js.map +0 -7
  266. package/dist-cjs/providers/vertex-ai.js.map +0 -7
  267. package/dist-cjs/runtime/actions/context.js.map +0 -7
  268. package/dist-cjs/runtime/actions/execute.js.map +0 -7
  269. package/dist-cjs/runtime/actions/native.js.map +0 -7
  270. package/dist-cjs/runtime/actions/sandbox.js.map +0 -7
  271. package/dist-cjs/runtime/agent.js.map +0 -7
  272. package/dist-cjs/runtime/context.js.map +0 -7
  273. package/dist-cjs/runtime/create-orcha.js.map +0 -7
  274. package/dist-cjs/runtime/execution.js.map +0 -7
  275. package/dist-cjs/runtime/session-events.js.map +0 -7
  276. package/dist-cjs/runtime/structured-output.js.map +0 -7
  277. package/dist-cjs/storage/browser-indexeddb.js.map +0 -7
  278. package/dist-cjs/storage/create-store.js.map +0 -7
  279. package/dist-cjs/storage/edge-store.js.map +0 -7
  280. package/dist-cjs/storage/migrate.js.map +0 -7
  281. package/dist-cjs/storage/node-jsonl.js.map +0 -7
  282. package/dist-cjs/storage/node-sqlite.js.map +0 -7
  283. package/dist-cjs/storage/react-native-jsonl.js.map +0 -7
  284. package/dist-cjs/testing.js.map +0 -7
  285. package/dist-cjs/types/google-genai-sdk.d.js.map +0 -7
  286. package/dist-cjs/types.js.map +0 -7
package/README.md CHANGED
@@ -47,8 +47,8 @@ require("./orcha");
47
47
  ```
48
48
 
49
49
  The Google GenAI and Vertex AI adapters use Google's current SDK and require
50
- Node.js 20 or newer. On Node.js 18, the optional Google SDK is skipped while
51
- the rest of Orcha—including Amazon Bedrock—remains available.
50
+ Node.js 20 or newer. On Node.js 18, the rest of Orcha—including Amazon
51
+ Bedrock—remains available.
52
52
 
53
53
  ---
54
54
 
@@ -207,7 +207,12 @@ privileges, including Node.js built-ins such as `node:fs`, the network, and
207
207
  interrupt a synchronous infinite loop.
208
208
 
209
209
  Use `"sandbox"` for isolated QuickJS execution. Declared environment and
210
- network permissions are only securely enforced by the sandbox runtime.
210
+ network permissions are only securely enforced by the sandbox runtime. Install
211
+ its runtime only when this mode is selected:
212
+
213
+ ```bash
214
+ npm install quickjs-emscripten-core @jitl/quickjs-singlefile-cjs-release-sync
215
+ ```
211
216
 
212
217
  ---
213
218
 
@@ -218,6 +223,24 @@ npm install orchajs
218
223
  npx orcha init
219
224
  ```
220
225
 
226
+ The default installation includes the compiler, CLI, native actions, JSONL
227
+ storage, and fetch-based Anthropic, DeepSeek, and OpenAI adapters. Install an
228
+ optional integration only in applications that use it:
229
+
230
+ ```bash
231
+ # Amazon Bedrock
232
+ npm install @aws-sdk/client-bedrock-runtime
233
+
234
+ # Google GenAI or Vertex AI (Node.js 20+)
235
+ npm install @google/genai
236
+
237
+ # SQLite session storage
238
+ npm install better-sqlite3
239
+ ```
240
+
241
+ Selecting an integration without its package produces an error that names the
242
+ dependency to install.
243
+
221
244
  Install the OrchaJS skill to give supported coding agents version-aware Orcha
222
245
  workflows:
223
246
 
@@ -260,8 +283,8 @@ Registered agents are exposed as `orcha.<agentName>`. Durable Node.js runs use
260
283
  JSONL by default at
261
284
  `.orcha/sessions/<agentName>/ses_<timestamp>_<uuid>.jsonl`. To opt into the
262
285
  shared `.orcha/sessions/orcha-sqlite.db` store, set
263
- `storage: { strategy: "sqlite" }` in `orcha.init()`. Orcha ships its native
264
- SQLite driver as an internal optional dependency.
286
+ `storage: { strategy: "sqlite" }` in `orcha.init()` and install
287
+ `better-sqlite3`.
265
288
  Client-action pause/resume, compiled local actions, and cumulative output
266
289
  streaming are supported.
267
290
  `run()` always starts a new session; `resume()` continues one with either a new
@@ -446,6 +469,11 @@ orcha.init({
446
469
  });
447
470
  ```
448
471
 
472
+ Bedrock applications must install `@aws-sdk/client-bedrock-runtime`. Google
473
+ GenAI and Vertex AI applications must install `@google/genai` and use Node.js
474
+ 20 or newer. These SDKs are not installed for applications that do not select
475
+ those providers.
476
+
449
477
  Amazon Bedrock uses the standard AWS credential chain by default. Local AWS
450
478
  profiles, `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`, ECS/EKS credentials,
451
479
  and attached IAM roles work without copying credentials into Orcha
@@ -733,10 +761,66 @@ const evaluations = await execution.evaluations;
733
761
  Short-lived processes should await `execution.evaluations` before exiting if
734
762
  they need every judge result to finish and persist.
735
763
 
736
- For esbuild production applications, add `orchaPlugin()` from
737
- `orchajs/esbuild` to the existing build. It compiles the registry and replaces
738
- unchanged `orchajs` imports with the self-contained generated runtime. The
739
- application continues to use its normal `npm run build` command.
764
+ ### Production and Serverless builds
765
+
766
+ For Serverless Framework projects, install `serverless-esbuild` and register
767
+ the Orcha integration after it:
768
+
769
+ ```bash
770
+ npm install --save-dev serverless-esbuild
771
+ ```
772
+
773
+ ```yaml
774
+ plugins:
775
+ - serverless-esbuild
776
+ - orchajs/serverless
777
+ ```
778
+
779
+ Serverless Framework v4 users must opt out of its built-in builder before
780
+ loading `serverless-esbuild`:
781
+
782
+ ```yaml
783
+ build:
784
+ esbuild: false
785
+ ```
786
+
787
+ No separate `orcha build` command or deployment script is required. During
788
+ `serverless package` and `serverless deploy`, the integration adds Orcha to the
789
+ existing esbuild pipeline. It preserves other esbuild plugins, compiles the
790
+ registry, and replaces exact `orchajs` imports with the generated production
791
+ runtime. It rejects configurations that externalize `orchajs`, because those
792
+ would copy the full development package into the Lambda artifact.
793
+
794
+ `serverless-plugin-typescript` and plain `tsc` do not bundle dependencies.
795
+ Remove that build plugin when switching the service to `serverless-esbuild`.
796
+ Keep `serverless-esbuild` before `orchajs/serverless` and before
797
+ `serverless-offline`.
798
+
799
+ For non-Serverless esbuild applications, add `orchaPlugin()` from
800
+ `orchajs/esbuild` to the build that bundles the application:
801
+
802
+ ```js
803
+ const { orchaPlugin } = require("orchajs/esbuild");
804
+
805
+ module.exports = {
806
+ bundle: true,
807
+ plugins: [orchaPlugin()],
808
+ };
809
+ ```
810
+
811
+ Running `orcha build` separately is not enough: it creates
812
+ `.orcha/dist/bundle.js`, but does not rewrite imports in already-built
813
+ handlers.
814
+
815
+ Production CI should package the same way as deployment and verify that:
816
+
817
+ - the build generated `.orcha/dist/bundle.js`;
818
+ - bundled handlers contain no unresolved bare `orchajs` import or require;
819
+ - the deployment archive does not contain `node_modules/orchajs`.
820
+
821
+ Do not exclude `.orcha/**` when using a deployment path that copies the
822
+ generated runtime instead of inlining it. This integration keeps compiler,
823
+ playground, unused providers, and optional runtimes out of deployed handlers.
740
824
 
741
825
  ---
742
826
 
@@ -66,4 +66,3 @@ export interface AmarsiaTestMetadata {
66
66
  enabled?: boolean;
67
67
  }
68
68
  export declare function createAmarsiaProjectMetadata(bundle: CompiledBundle, projectRoot: string): AmarsiaProjectMetadata;
69
- //# sourceMappingURL=metadata.d.ts.map
@@ -184,4 +184,3 @@ function sortStable(value) {
184
184
  }
185
185
  return value;
186
186
  }
187
- //# sourceMappingURL=metadata.js.map
@@ -5,4 +5,3 @@ export declare function syncAmarsiaProject(options: {
5
5
  bundle: CompiledBundle;
6
6
  projectRoot: string;
7
7
  }): void;
8
- //# sourceMappingURL=sync.d.ts.map
@@ -35,4 +35,3 @@ async function postProjectMetadata(options) {
35
35
  throw new Error(`HTTP ${response.status} ${response.statusText || "sync failed"}`);
36
36
  }
37
37
  }
38
- //# sourceMappingURL=sync.js.map
@@ -1,2 +1 @@
1
1
  export declare const AGENTS_MD = "# Orcha project guide\n\nThis repository uses OrchaJS, a filesystem-convention framework for durable\nAI agents. Treat the `orcha/` directory as source code. Do not edit generated\nfiles under `.orcha/`.\n\n## Commands\n\n- `orcha init` creates the initial Orcha files without overwriting files.\n- `orcha dev` validates agent source and watches `orcha/**` for changes.\n- `orcha playground` opens the built-in local UI and hot reloads agent source.\n- `orcha run <agent> --input \"\u2026\"` executes one registered agent.\n- `orcha run <agent> --input-file request.json` accepts structured input.\n- `orcha run <agent> --session <id> --input \"\u2026\"` continues a session.\n- `orcha run <agent> --session <id> --tool-results results.json` submits\n pending client-action results.\n- `orcha test` runs every enabled discovered agent test.\n- `orcha test <agent>` or `orcha test <agent>/<case>` narrows the run.\n- `orcha migrate-storage --to sqlite|node-jsonl` copies all session histories\n between local stores without deleting the source.\n- `orcha export-session <agent> <sessionId> [--output <path>]` exports one\n session from the active store as JSONL.\n- `orcha build` creates the production Orcha bundle without calling models.\n- Add `--json` to `run` and `test` for machine-readable output.\n\n`run`, `test`, and playground executions use real providers and require\ncredentials. `dev` and `build` are offline. Sessions use JSONL by default\nunder `.orcha/sessions/<agentName>/`; opt-in SQLite stores all agents in\n`.orcha/sessions/orcha-sqlite.db`.\n\n## Registry\n\n`orcha/index.ts` initializes providers and explicitly registers agents:\n\n```ts\nimport { orcha } from \"orchajs\";\n\norcha.init({\n providers: {\n anthropic: process.env.ANTHROPIC_API_KEY ?? \"\",\n openai: process.env.OPENAI_API_KEY ?? \"\",\n },\n agents: {\n supportBot: \"./supportBot\",\n },\n});\n```\n\nOnly registered agents are compiled. Agent keys become runtime properties\nsuch as `orcha.supportBot`. Local actions use the native Node.js runtime by\ndefault. Set `actions.runtime: \"sandbox\"` only when isolated execution is\nrequired.\n\n`orcha.init()` fields:\n\n- `providers` (required): provider configurations keyed by built-in provider\n name.\n- `agents` (required): runtime property names mapped to folders relative to\n `orcha/`. At least one agent is required.\n- `amarsia.key` (optional): project connection key generated in Amarsia.\n When set, Orcha syncs structural project and agent metadata only. It never\n uploads provider credentials, environment values, prompts, instructions,\n test inputs, or action source.\n- `amarsia.endpoint` (optional): Amarsia API URL for project sync. Defaults to\n `AMARSIA_API_URL` and then `https://api.amarsia.com`.\n- `actions` (optional): overrides the native local-action runtime or configures\n its environment and sandbox settings.\n- `storage.strategy` (optional): `\"node-jsonl\"` (default) or `\"sqlite\"`.\n The SQLite driver ships as an internal optional Orcha dependency.\n- `storage.directory` (optional): session directory relative to project\n root; defaults to `.orcha/sessions`.\n- `root` (optional): absolute or working-directory-relative project root;\n defaults to `ORCHA_PROJECT_ROOT` and then `process.cwd()`.\n\nThe Orcha library reads the host application's existing `process.env`.\nStandalone Orcha CLI commands also load `.env` from the project root without\noverriding environment variables already in the process.\n\nProvider configuration shapes:\n\n```ts\nproviders: {\n anthropic: process.env.ANTHROPIC_API_KEY ?? \"\",\n deepseek: process.env.DEEPSEEK_API_KEY ?? \"\",\n googlegenai: process.env.GOOGLE_API_KEY ?? \"\",\n openai: {\n apiKey: process.env.OPENAI_API_KEY ?? \"\",\n baseUrl: \"https://api.openai.com/v1\", // optional override\n },\n vertexai: {\n project: process.env.GOOGLE_CLOUD_PROJECT ?? \"\",\n location: process.env.GOOGLE_CLOUD_LOCATION ?? \"us-central1\",\n // credentials is optional; omit it to use Google ADC.\n credentials: {\n clientEmail: process.env.GOOGLE_CLIENT_EMAIL ?? \"\",\n privateKey: process.env.GOOGLE_PRIVATE_KEY ?? \"\",\n },\n baseUrl: undefined, // optional override\n },\n bedrock: {\n region: process.env.AWS_REGION ?? \"us-east-1\",\n // credentials is optional; omit it to use the AWS credential chain.\n credentials: {\n accessKeyId: process.env.AWS_ACCESS_KEY_ID ?? \"\",\n secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY ?? \"\",\n sessionToken: process.env.AWS_SESSION_TOKEN,\n },\n baseUrl: undefined, // optional override\n },\n}\n```\n\nAPI-key providers accept either a string shorthand or\n`{ apiKey, baseUrl? }`. Vertex AI requires `project` and `location`;\nexplicit service-account credentials are optional. Bedrock requires `region`;\nexplicit AWS credentials are optional. Never place credentials in\n`index.json`, instructions, tests, session metadata, or committed files.\n\n## Agent folders\n\n```text\norcha/\n index.ts\n supportBot/\n index.json\n instructions.md\n actions/\n skills/\n tests/\n evaluations/\n```\n\n`index.json` selects the model:\n\n```json\n{\n \"name\": \"Support Agent\",\n \"description\": \"Resolve customer support questions using confirmed account data.\",\n \"provider\": \"anthropic\",\n \"model\": \"claude-sonnet-4-6\",\n \"region\": \"provider_managed\",\n \"maxTokens\": 10240,\n \"outputType\": \"text\"\n}\n```\n\nOptional fields include `reasoningLevel`, `outputType: \"json\"`, and an\n`outputSchema` JSON Schema. Provider-specific reasoning values are forwarded\nwithout translation. Put the agent's stable role, boundaries, and operating\ninstructions in `instructions.md`.\n\nAgent `index.json` fields:\n\n- `name` (required): concise human-readable agent name.\n- `description` (optional): what the agent does and when it should be used.\n- `provider` (required): `\"anthropic\"`, `\"bedrock\"`, `\"deepseek\"`,\n `\"openai\"`, `\"googlegenai\"`, or `\"vertexai\"`.\n- `model` (required): exact provider model identifier.\n- `region` (optional): provider/model routing hint; defaults in durable\n metadata to `\"provider_managed\"`.\n- `maxTokens` (optional): positive integer. If omitted, the provider adapter\n chooses its default.\n- `reasoningLevel` (optional): non-empty provider-native string. Orcha does\n not translate values between providers.\n- `outputType` (optional): `\"text\"` (default) or `\"json\"`. Image and\n audio are reserved but not implemented.\n- `outputSchema` (required for JSON output): JSON Schema used for provider\n structured output and final validation.\n\n`instructions.md` is required and cannot be empty. At compile time it becomes\nthe base system prompt. Orcha appends the compact available-skill catalog and\nthe full instructions for skills already loaded in this durable session.\n\n## Subagents\n\nRegister private subagents alongside a parent in `orcha/index.ts`:\n\n```js\nagents: {\n coordinator: {\n path: \"./coordinator\",\n subagents: {\n researcher: \"./researcher\",\n },\n },\n researcher: \"./researcher\",\n}\n```\n\nOnly top-level keys become `orcha.<agentName>`. In this example the\nresearcher is both directly accessible and available to the coordinator.\nRemove its top-level entry to make it private.\n\nA parent may configure delegation limits in its `index.json`:\n\n```json\n{\n \"subagents\": {\n \"maxPerRun\": 3\n }\n}\n```\n\n`maxPerRun` limits newly created child sessions in one parent run and\ndefaults to 10.\n\nThe parent receives a compact catalog containing each subagent's registered\nname and optional description. Internal `run_agent`, `resume_agent`,\n`inspect_agent` tools let it start, continue, and inspect only child sessions\ninitiated by its current session. A delegated agent cannot delegate again.\n\nSubagent calls are synchronous. The parent becomes\n`waiting_for_subagent` while the child runs, then receives the child's text,\npause state, client-action request, failure, or completion as a normal tool\nresult. The parent and child keep separate linked JSONL sessions.\n\n## Core execution model\n\nAn **agent** is the compiled definition: model settings, instructions, actions,\nskills, and evaluations. An agent can create many independent sessions.\n\nA **session** is one durable conversation owned by one agent. It has one\n`sessionId`, optional name and metadata, fixed prompt variables, and one\nappend-only JSONL timeline. Completing one response does not close the\nsession\u2014the application can resume it later. A session cannot be transferred\nto another registered agent, but later runs may use a different provider or\nmodel if that same agent's configuration changes.\n\nA **run** is one attempt to advance a session. `run()` creates a session and\nits first run. A conversational `resume(sessionId, { content })` creates the\nnext numbered run in that session. Each run accumulates its own model usage and\nends in exactly one of these states:\n\n- `completed`: the model produced final output.\n- `waiting_for_subagent`: the parent is waiting for a synchronous child\n response and continues automatically when it arrives.\n- `waiting_for_client_action`: the model requested work that only the\n application can perform. The run is paused, not completed.\n- `paused`: active provider work was aborted, streamed output was preserved,\n and a later `resume()` starts a new run.\n- `failed`: validation, provider, storage, or execution failed. The durable\n events remain available for diagnosis.\n\nAn **execution** is the in-process handle returned by one call to `run()` or\n`resume()`. It exposes a cumulative output stream, latest snapshot, final\nresult promise, and evaluation promise. An execution ends when that invocation\ncompletes, pauses, or fails; the durable session may continue through another\nexecution.\n\nA **model round** is one provider request inside a run. One run may contain\nseveral rounds:\n\n```text\nuser input\n \u2192 model round\n \u2192 tool calls\n \u2192 tool results\n \u2192 another model round\n \u2192 final answer\n```\n\nLocal actions and skill loads are handled automatically inside the same\nexecution. Their results are sent back to the model and the model loop\ncontinues without application involvement.\n\nA **client action** deliberately crosses the application boundary. Orcha can\ndescribe the tool to the model but cannot execute it because the operation\nbelongs to a browser, mobile app, approval system, or other caller-owned\nenvironment. The complete pause/continue flow is:\n\n```text\n1. Application calls agent.run(...) or agent.resume(...content).\n2. Model requests one or more client actions.\n3. Orcha stores client_action.requested and run.paused.\n4. execution.result resolves with:\n {\n status: \"waiting_for_client_action\",\n sessionId,\n clientToolCalls: [{ callId, name, arguments }]\n }\n5. Application executes every requested action.\n6. Application calls agent.resume(sessionId, {\n toolResults: [{ callId, output, isError? }]\n }).\n7. Orcha validates every callId and output, stores the results, and continues\n the same paused run from its prior model context.\n8. The resumed execution either completes, requests more client actions, or\n fails.\n```\n\nEvery pending call must be resolved exactly once in one resume operation.\n`callId` links the submitted result to the model's request; the action name\nmust not be substituted for it. Re-submitting the identical resolved result is\nidempotent and returns the prior completed result. Submitting different data\nfor an already-resolved call fails with `action_result_conflict`.\n\n`clientCapabilities` is supplied per invocation because different callers\nmay support different client actions. Orcha exposes only declared client\nactions to that model round. Local actions are always available when compiled.\n\nOnly one execution may mutate a session at a time. Concurrent calls for the\nsame `sessionId` return `session_busy`; different sessions can run\nindependently.\n\n## Running and resuming\n\n```ts\nconst execution = orcha.supportBot.run({\n content: \"Check subscription sub_123.\",\n name: \"Subscription check\",\n metadata: { accountId: \"acct_123\" },\n clientCapabilities: [\"request_human_approval\"],\n});\n\nfor await (const snapshot of execution.stream) {\n console.log(snapshot);\n}\n\nconst result = await execution.result;\nconst evaluations = await execution.evaluations;\n```\n\n`run()` input fields:\n\n- `content` (required): a non-empty string, one content item, or an array.\n Use `{ filePath: \"./document.pdf\" }` for a local file or\n `{ url: \"https://example.com/document.pdf\" }` for a remote file.\n `mimeType` is optional when it can be inferred from the extension. Durable\n events store local paths and MIME types, never encoded file bytes.\n- `name` (optional): trimmed session label from 1 through 200 characters.\n- `metadata` (optional): at most 50 fields with non-empty keys and finite\n string, number, boolean, or null values. Metadata is durable and available\n to local action context; never place secrets in it.\n- `variables` (optional): at most 50 string values whose keys are JavaScript\n identifiers. They replace `{{ variableName }}` placeholders in\n `instructions.md`, are fixed when the session is created, and are reused\n by later resumes. A missing referenced variable fails the run.\n- `clientCapabilities` (optional): action names the current caller can\n execute. Client actions not declared here are withheld from the model.\n\n`run()` always creates a new durable session. Continue one with:\n\n```ts\nconst execution = orcha.supportBot.resume(sessionId, {\n content: \"Continue with the confirmed account.\",\n});\n```\n\nIf a result has `status: \"waiting_for_client_action\"`, execute the requested\nclient actions in the application and submit every result:\n\n```ts\norcha.supportBot.resume(sessionId, {\n toolResults: [\n { callId: \"call_123\", output: { approved: true } }\n ],\n});\n```\n\nNever invent call IDs. Use the IDs returned in `clientToolCalls`.\n\n## Actions\n\nEach action has metadata and, for local actions, executable code:\n\n```text\nactions/\n lookupAccount/\n index.json\n index.js\n```\n\n```json\n{\n \"name\": \"lookup_account\",\n \"description\": \"Look up one account.\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"accountId\": { \"type\": \"string\" }\n },\n \"required\": [\"accountId\"],\n \"additionalProperties\": false\n },\n \"outputSchema\": {\n \"type\": \"object\",\n \"properties\": {\n \"status\": { \"type\": \"string\" }\n },\n \"required\": [\"status\"],\n \"additionalProperties\": false\n }\n}\n```\n\n```js\nexport default async function lookupAccount({ accountId }) {\n return { status: \"active\" };\n}\n```\n\nAction entrypoints can use ordinary relative project imports, TypeScript\nmodules, npm packages, transitive dependencies, and standard exports. Orcha\nbundles the complete import graph for development and production.\n\nClient actions use `\"execution\": \"client\"` and do not include executable\ncode. Orcha pauses until the caller submits their results. Keep action names,\ndescriptions, schemas, and implementations aligned.\n\nAction `index.json` fields:\n\n- `name` (required): model-facing tool name, 1\u201364 letters, numbers,\n underscores, or hyphens. `load_skill` is reserved.\n- `description` (required): tells the model when and why to call the action.\n- `enabled` (optional): defaults to `true`. Set to `false` to keep a WIP\n action inactive without deleting its folder.\n- `execution` (optional): defaults to `\"local\"`, which executes `index.js`.\n Set to `\"client\"` to pause and delegate execution to the application.\n- `parameters` (required): JSON Schema for model-generated arguments.\n- `outputSchema` (optional): JSON Schema validated against local or submitted\n client output before the model receives it.\n- `timeoutMs` (optional): integer from 1 through 120000; defaults to 10000.\n- `permissions.env` (optional): names copied from `orcha.init().actions.env`\n into the action context.\n- `permissions.network` (optional): exact hosts or wildcard subdomains such\n as `\"api.example.com\"` or `\"*.example.com\"` allowed through\n `context.fetch`. Redirects are rejected.\n- `sideEffect` (optional): descriptive metadata for whether the operation\n mutates external state. It does not currently change execution behavior.\n\n`orcha.init().actions.runtime` and an action's `execution` solve different\nproblems:\n\n- `execution: \"client\"`: Orcha never executes code for this action.\n- `execution: \"local\"` + `runtime: \"sandbox\"`: compiled code runs in a\n QuickJS isolate with JSON-only inputs/outputs, default 32 MB memory, default\n 512 KB stack, interruptible timeout, declared environment values, and\n allowlisted network access through the provided context.\n- `execution: \"local\"` + `runtime: \"native\"`: code runs in the host Node.js\n process. It can use host privileges directly. The timeout rejects slow\n asynchronous work but cannot interrupt synchronous blocking code.\n\nGlobal local-action configuration:\n\n```ts\nactions: {\n runtime: \"sandbox\", // optional; native is the default\n env: {\n BILLING_API_TOKEN: process.env.BILLING_API_TOKEN,\n },\n sandbox: {\n memoryLimitMb: 32,\n stackLimitKb: 512,\n },\n}\n```\n\nThe local action signature is\n`(parameters, context) => output | Promise<output>`. Context contains\n`sessionId`, immutable session `metadata`, a stable `idempotencyKey`,\nallowlisted `env`, guarded `fetch`, and prefixed `log`.\n\n## Skills\n\nSkills are lazy-loaded procedural instructions. Direct child folders under\n`skills/` are discovered automatically. Each folder contains `index.json`\nmetadata and `instructions.md`.\nThe model receives a compact catalog and can call the internal `load_skill`\ntool. Loaded instructions remain active for the durable session. Lifecycle\nevents are `skill.requested`, `skill.loaded`, and `skill.failed`.\n\nSkill `index.json` fields:\n\n- `name` (required): model-facing name, 1\u201364 letters, numbers, underscores,\n or hyphens; unique within the agent.\n- `description` (required): compact catalog description shown before loading.\n- `enabled` (optional): defaults to `true`. Set to `false` to keep a WIP\n skill inactive.\n- `triggers` (optional): non-empty array of non-empty situations describing\n when the model should load the skill.\n\n`instructions.md` is required and cannot be empty for enabled skills.\n`index.json.name` is the name used by the model and durable events.\n\n## Tests\n\nDirect child folders under `tests/` are discovered automatically. Each\ncase's `index.json` defines `input`, optional mocked action responses, and\n`expect`. Tests run the real compiled agent and provider. Actions listed\nunder `actions` are mocked; unlisted local actions execute live. Orcha reports\nlive action use in the terminal, test report, and session trace.\nClient actions must always be mocked because no application client is attached\nto the test runner.\n\n```json\n{\n \"input\": { \"content\": \"Check account acct_123.\" },\n \"actions\": {\n \"lookup_account\": {\n \"responses\": [\n { \"output\": { \"status\": \"active\" } }\n ]\n }\n },\n \"expect\": {\n \"status\": \"completed\",\n \"text\": { \"contains\": [\"active\"] },\n \"actions\": [\n {\n \"name\": \"lookup_account\",\n \"arguments\": { \"equals\": { \"accountId\": \"acct_123\" } }\n }\n ]\n }\n}\n```\n\nTest sessions use the `ses_test_<timestamp>_<uuid>` format and end with a `test.completed`\nevent. Prefer semantic output assertions; verify exact identifiers and values\nthrough action-argument assertions.\n\nTest `index.json` fields:\n\n- `name` (optional): friendly display name. The folder name remains the CLI\n selector.\n- `description` (optional): human-readable purpose.\n- `enabled` (optional): defaults to `true`. Set to `false` to keep a WIP test\n inactive.\n- `input` (required): an inline agent input object or a path to a JSON file\n containing that object. Relative paths resolve from the test case directory.\n- `input.content` (required for inline input): string or multimodal content\n array.\n- `input.variables` (optional): string map available to the session.\n- `input.metadata` (optional): string, number, boolean, or null values.\n- `actions` (optional): mocked actions keyed by compiled action name. Unlisted\n local actions execute live and may cause side effects. Unknown action names\n are rejected, and unlisted client actions are rejected. Every `responses`\n array is consumed in call order.\n- `responses[].output` (required): mocked action result.\n- `responses[].isError` (optional): marks the mocked result as an error.\n- `expect.status` (optional): `\"completed\"` or `\"failed\"`; defaults to\n `\"completed\"`.\n- `expect.output.equals` / `partial` (optional): exact or recursive partial\n comparison against structured output.\n- `expect.text.contains` / `excludes` (optional): case-sensitive semantic\n text checks.\n- `expect.actions` (optional): ordered expected calls. Each may assert\n `arguments.equals` or `arguments.partial`.\n\nThe test folder name is the selector used by `orcha test agent/testName`.\n\n## Evaluations\n\nEvaluations are asynchronous LLM judges discovered from direct child folders\nunder `evaluations/`. Each folder's `index.json` defines its provider, model,\nmetrics, and thresholds:\n\n```json\n{\n \"name\": \"response_quality\",\n \"description\": \"Grounding of agent responses.\",\n \"instructions\": \"Judge the complete response using only confirmed evidence recorded in the session.\",\n \"enabled\": true,\n \"provider\": \"openai\",\n \"model\": \"gpt-5-mini\",\n \"metrics\": [\n {\n \"name\": \"groundedness\",\n \"description\": \"The answer relies on confirmed session evidence.\",\n \"threshold\": 0.8\n }\n ]\n}\n```\n\n`execution.result` does not wait for judges. Await\n`execution.evaluations` when results must finish before process exit.\nEvaluations always finish during `orcha test`; judge errors and missed\nthresholds fail the test. Lifecycle events are `evaluation.requested`,\n`evaluation.completed`, and `evaluation.failed`.\n\nEvaluation `index.json` fields:\n\n- `name` (required): durable model-facing identifier, 1\u201364 letters, numbers,\n underscores, or hyphens; unique within the agent.\n- `description` (optional): short human-facing summary of the evaluator.\n- `instructions` (optional): detailed prompt supplied to the judge. When\n omitted, `description` is used for backward compatibility.\n- `enabled` (optional): defaults to `true`. Disabled evaluations are ignored\n by compilation and runtime.\n- `provider` and `model` (required): independently select the judge. The\n provider must also exist in `orcha.init().providers`.\n- `maxTokens` (optional): positive integer; defaults to 2000 for judges.\n- `reasoningLevel` (optional): non-empty provider-native string forwarded\n without translation.\n- `metrics` (required): non-empty array with unique metric names.\n- `metrics[].name`: 1\u201364 letters, numbers, underscores, or hyphens.\n- `metrics[].description`: exact criterion supplied to the judge.\n- `metrics[].threshold`: inclusive number from 0 to 1. A metric passes when\n the returned score is greater than or equal to this threshold.\n\nThe judge sees a sanitized transcript of user/assistant messages, action\nrequests and outcomes, client-action activity, and loaded skill names. It does\nnot receive internal reasoning blocks, replay metadata, previous evaluation\nresults, or test assertions. It must return exactly one score, reasoning\nstring, and non-empty evidence array for every configured metric.\n\n## Sessions and logs\n\nThe configured session store is the durable source of truth. JSONL stores one\ncomplete event object per line; SQLite stores one event per row. Events are\nappend-only and ordered by `sequence`.\n\nAll events use this envelope:\n\n```ts\ntype SessionEvent<T> = {\n sequence: number; // starts at 1 and increases across the whole session\n type: SessionEventType;\n timestamp: string; // ISO-8601 UTC timestamp\n run?: number; // present for run-scoped events\n data: T;\n};\n```\n\nSession-scoped events omit `run`. Optional properties whose values are\n`undefined` are omitted from serialized JSON.\n\nShared stored structures:\n\n```ts\ntype Usage = {\n inputTokens: number;\n outputTokens: number;\n reasoningTokens: number | null;\n cacheReadTokens: number;\n cacheWriteTokens: number;\n};\n\ntype ErrorData = {\n code: string;\n message: string;\n retryable?: boolean;\n};\n\ntype UserContent =\n | { type: \"text\"; text: string }\n | { type: \"file\"; filePath: string; mimeType: string }\n | {\n type: \"image\" | \"video\" | \"audio\" | \"url\";\n mimeType: string;\n fileUri: string;\n };\n\ntype AssistantContent =\n | { type: \"text\"; text: string }\n | {\n type: \"reasoning\";\n text: string;\n replay?: { providerId?: string; opaqueData?: string };\n }\n | {\n type: \"tool_call\";\n callId: string;\n name: string;\n arguments: Record<string, unknown>;\n replay?: { providerId?: string; opaqueData?: string };\n };\n\ntype ToolResult = {\n callId: string;\n output: unknown;\n isError?: boolean;\n};\n```\n\nExact event payloads:\n\n```ts\ntype SessionCreated = SessionEvent<{\n schemaVersion: 1;\n sessionId: string;\n agent: string;\n status: \"active\";\n name?: string;\n metadata: Record<string, string | number | boolean | null>;\n variables: Record<string, string>;\n lineage?: {\n origin: \"delegated\";\n parentAgent: string;\n parentSessionId: string;\n parentCallId: string;\n };\n}>; // type \"session.created\", no run\n\ntype SessionUpdated = SessionEvent<{\n name?: string;\n metadata?: Record<string, string | number | boolean | null>;\n}>; // type \"session.updated\", no run\n\ntype RunStarted = SessionEvent<{\n status: \"running\";\n agent: string;\n provider: string;\n model: string;\n region: string;\n reasoningLevel?: string;\n outputType: \"text\" | \"json\";\n clientCapabilities: string[];\n}>; // type \"run.started\"\n\ntype UserMessageCreated = SessionEvent<{\n role: \"user\";\n content: UserContent[];\n}>; // type \"message.created\"\n\ntype AssistantMessageCreated = SessionEvent<{\n status: \"completed\" | \"incomplete\";\n provider: string;\n model: string;\n responseId?: string;\n stopReason?: \"end_turn\" | \"tool_call\" | \"max_tokens\" |\n \"content_filter\" | \"unknown\";\n role: \"assistant\";\n content: AssistantContent[];\n parsedOutput?: unknown; // final JSON output only\n usage: Usage;\n durationMs: number;\n}>; // type \"message.created\"\n\ntype ToolMessageCreated = SessionEvent<{\n role: \"tool\";\n content: ToolResult[];\n}>; // type \"message.created\"\n\ntype ActionRequested = SessionEvent<{\n callId: string;\n name: string;\n arguments: Record<string, unknown>;\n sourceHash?: string;\n idempotencyKey: string; // sessionId:callId\n}>; // type \"action.requested\"\n\ntype ActionCompleted = SessionEvent<{\n callId: string;\n name: string;\n output: unknown;\n sourceHash?: string;\n durationMs: number;\n}>; // type \"action.completed\"\n\ntype ActionFailed = SessionEvent<{\n callId: string;\n name: string;\n sourceHash?: string;\n durationMs: number;\n error: {\n code: \"action_execution_failed\";\n message: string;\n };\n}>; // type \"action.failed\"\n\ntype ClientActionRequested = SessionEvent<{\n status: \"waiting\";\n calls: Array<{\n callId: string;\n name: string;\n arguments: Record<string, unknown>;\n }>;\n localResults: ToolResult[];\n toolCallOrder: string[];\n}>; // type \"client_action.requested\"\n\ntype ClientActionResolved = SessionEvent<{\n status: \"completed\";\n results: ToolResult[];\n}>; // type \"client_action.resolved\"\n\ntype SkillRequested = SessionEvent<{\n callId: string;\n name: unknown;\n}>; // type \"skill.requested\"\n\ntype SkillLoaded = SessionEvent<{\n callId: string;\n name: string;\n alreadyLoaded: boolean;\n}>; // type \"skill.loaded\", no run\n\ntype SkillFailed = SessionEvent<{\n callId: string;\n name: unknown;\n error: {\n code: \"skill_not_found\";\n message: string;\n };\n}>; // type \"skill.failed\"\n\ntype EvaluationRequested = SessionEvent<{\n name: string;\n provider: string;\n model: string;\n evaluatedThroughSequence: number;\n}>; // type \"evaluation.requested\"\n\ntype EvaluationMetric = {\n name: string;\n score: number;\n threshold: number;\n passed: boolean;\n reasoning: string;\n evidence: string[];\n};\n\ntype EvaluationCompleted = SessionEvent<{\n name: string;\n status: \"passed\" | \"failed\";\n metrics: EvaluationMetric[];\n usage?: Usage;\n durationMs: number;\n provider: string;\n model: string;\n evaluatedThroughSequence: number;\n}>; // type \"evaluation.completed\"\n\ntype EvaluationFailed = SessionEvent<{\n name: string;\n status: \"error\";\n metrics: [];\n durationMs: number;\n error: { message: string };\n provider: string;\n model: string;\n evaluatedThroughSequence: number;\n}>; // type \"evaluation.failed\"\n\ntype SubagentInitiated = SessionEvent<{\n callId: string;\n agent: string;\n sessionId: string;\n status: \"running\";\n}>; // type \"subagent.initiated\"\n\ntype SubagentResumed = SessionEvent<{\n callId: string;\n agent: string;\n sessionId: string;\n status: \"running\";\n}>; // type \"subagent.resumed\"\n\ntype SubagentCompletedOrPausedOrFailed = SessionEvent<{\n callId: string;\n agent: string;\n sessionId: string;\n status:\n | \"completed\"\n | \"waiting_for_client_action\"\n | \"paused\"\n | \"failed\";\n output?: unknown;\n usage?: Usage;\n clientToolCalls?: Array<{\n callId: string;\n name: string;\n arguments: Record<string, unknown>;\n }>;\n error?: ErrorData;\n}>; // type \"subagent.completed\" | \"subagent.paused\" | \"subagent.failed\"\n\ntype RunPaused = SessionEvent<{\n status: \"waiting_for_client_action\" | \"paused\";\n clientToolCalls?: Array<{\n callId: string;\n name: string;\n arguments: Record<string, unknown>;\n }>;\n usage?: Usage;\n output?: unknown;\n durationMs?: number;\n}>; // type \"run.paused\"\n\ntype RunCompleted = SessionEvent<{\n status: \"completed\";\n durationMs: number;\n usage: Usage;\n}>; // type \"run.completed\"\n\ntype RunFailed = SessionEvent<{\n status: \"failed\";\n durationMs: number;\n usage?: Usage;\n error: ErrorData;\n}>; // type \"run.failed\"\n\ntype SessionPaused = SessionEvent<{\n status: \"paused\";\n}>; // type \"session.paused\", no run\n\ntype SessionResumed = SessionEvent<{\n status: \"active\";\n}>; // type \"session.resumed\", no run\n\ntype TestCompleted = SessionEvent<{\n suiteId: string;\n agent: string;\n test: string;\n status: \"passed\" | \"failed\";\n durationMs: number;\n assertions: Array<{\n path: string;\n passed: boolean;\n message: string;\n expected?: unknown;\n actual?: unknown;\n }>;\n usage?: Usage;\n evaluations?: Array<{\n name: string;\n status: \"passed\" | \"failed\" | \"error\";\n metrics: EvaluationMetric[];\n usage?: Usage;\n durationMs: number;\n error?: { message: string };\n }>;\n warnings?: Array<{\n code: \"live_actions\";\n message: string;\n actions: string[];\n }>;\n error?: ErrorData;\n}>; // type \"test.completed\", no run\n\ntype TestWarning = SessionEvent<{\n code: \"live_actions\";\n message: string;\n actions: string[];\n}>; // type \"test.warning\", no run\n```\n\nTypical event order:\n\n```text\nsession.created\nrun.started\nmessage.created (user)\nmessage.created (assistant, possibly with tool_call)\naction.requested \u2192 action.completed|action.failed # local action\nsubagent.initiated\n...child session advances independently...\nsubagent.paused\nsubagent.resumed\n...child session advances independently...\nsubagent.completed|subagent.paused|subagent.failed\nmessage.created (tool)\n...additional model/action rounds...\nmessage.created (assistant final)\nrun.completed\nevaluation.requested\nevaluation.completed|evaluation.failed\n```\n\nFor client actions, `client_action.requested` and `run.paused` replace the\nimmediate tool message. A later `resume(...toolResults)` appends\n`client_action.resolved`, the tool message, and continues the same run\nnumber. A conversational `resume(...content)` starts a new run number.\n\n## How Orcha works behind the scenes\n\n### Compilation\n\n1. `orcha/index.ts` calls `orcha.init()` with explicit agent paths.\n2. The compiler reads each registered agent's `index.json` and\n `instructions.md`.\n3. Direct child folders under `actions/`, `skills/`, `tests/`, and\n `evaluations/` are discovered automatically. Items with `\"enabled\": false`\n remain inactive.\n4. Local action source is bundled and SHA-256 hashed. Production bundles keep\n only provider adapters required by agents and enabled evaluations.\n5. Invalid paths, duplicate model-facing names, missing files, unsupported\n configuration values, and missing schema objects fail before execution.\n Concrete action arguments and outputs are validated against their schemas\n when the action is used.\n\n`orcha dev` repeats validation when files change. `orcha build` performs\noffline production compilation. Neither command invokes a provider.\n\n### Run lifecycle\n\n1. `run()` creates a `ses_<timestamp>_<uuid>`, acquires the per-session execution lock,\n appends `session.created`, then starts run 1.\n2. `resume()` reads and validates the existing session. Message continuation\n starts a new run; submitted client results continue the paused run.\n3. The provider receives the base instructions, available-skill catalog,\n loaded skill instructions, normalized conversation messages, action\n schemas, model settings, and current client capabilities.\n4. Provider-specific responses are normalized into text, reasoning, and tool\n call blocks. Opaque replay metadata is stored only when a provider needs it\n to replay its own prior block correctly.\n5. Tool calls are checked against compiled actions and declared client\n capabilities. Arguments and outputs are validated against JSON Schema.\n6. `load_skill` updates durable session instructions. Local actions execute\n through the configured runtime. Client actions pause safely. Tool results\n are reordered to match the model's original call order.\n7. Internal agent tools start or continue linked child sessions. A\n `run_agent` input accepts the same text or multimodal content shape as a\n normal run. Local file paths resolve from the configured Orcha project root.\n The parent reports `waiting_for_subagent` until each synchronous child\n call returns.\n8. The model loop continues until final output, failure, a pause, or the\n maximum of 10 action rounds.\n9. Usage is normalized and aggregated across every model call in the run.\n10. After `run.completed`, enabled evaluations start in the background.\n `execution.result` is already available; `execution.evaluations` waits\n for judge completion and durable persistence.\n\nThe per-session lock prevents two model executions from mutating one session\nat once. Background evaluation writes queue behind active runs so they cannot\ncause `resume()` to fail spuriously or reuse sequence numbers.\n\n### Replay and context\n\nOrcha does not send raw stored events back to the model. It projects them\ninto provider-neutral conversation messages. Completed and explicitly paused\nconversational runs become user, assistant, and tool messages, so a new run\nsees incomplete assistant text preserved by `pause()`. Lifecycle bookkeeping\nsuch as durations, test assertions, and evaluation events is excluded from\nmodel context. Reasoning text and provider replay metadata are retained where\nneeded for faithful continuation but are omitted from evaluation transcripts.\n\n### Reading sessions\n\n- `agent.get(sessionId)` projects the latest status, pending client actions,\n last output, metadata, and aggregate usage.\n- `agent.history(sessionId, { page, pageSize })` returns a safe user-facing\n timeline rather than raw provider bookkeeping.\n- `agent.events(sessionId, { page, pageSize })` returns the canonical durable\n event records for observability, audit, and debugging tools. For subsequent\n pages of a changing session, pass the first response's `throughSequence`\n back in the options to keep pagination on a stable event boundary.\n- `agent.list({ page, pageSize, status, metadata })` lists projected session\n snapshots.\n- `agent.subagentHistory(childSessionId, { page, pageSize })` returns the\n projected history of a child owned by this parent agent. Lineage checks\n prevent access through unrelated agents.\n- `agent.subagentEvents(childSessionId, { page, pageSize })` returns that\n owned child's canonical events for full transcript and debugging interfaces.\n- `agent.pause(sessionId)` aborts active provider work for the session and\n active children, preserving streamed text as an incomplete assistant\n message. `agent.resume(sessionId)` starts a new run with `\"Continue.\"`;\n pass content to give different instructions. Pending client actions still\n require their exact tool results.\n- Never read storage files directly. Use these methods so applications remain\n compatible with JSONL, SQLite, IndexedDB, remote, and future storage adapters.\n\n## Change rules\n\n- Register every new agent and subagent explicitly. Agent-owned actions, skills,\n tests, and evaluations are auto-discovered; use `\"enabled\": false` for WIP.\n- Keep runtime behavior provider-neutral.\n- Mock actions when tests must avoid side effects; document intentional live\n action coverage.\n- Do not commit `.orcha/`; it contains generated output and session data.\n- Run `orcha dev` after filesystem changes and `orcha test` when behavior\n changes.\n- Do not weaken assertions to match incorrect behavior. Remove an assertion\n only when it is stricter than the documented agent contract.\n";
2
- //# sourceMappingURL=cli-agents-template.d.ts.map
@@ -1065,4 +1065,3 @@ needed for faithful continuation but are omitted from evaluation transcripts.
1065
1065
  - Do not weaken assertions to match incorrect behavior. Remove an assertion
1066
1066
  only when it is stricter than the documented agent contract.
1067
1067
  `;
1068
- //# sourceMappingURL=cli-agents-template.js.map
package/dist/cli.d.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  #!/usr/bin/env node
2
2
  export {};
3
- //# sourceMappingURL=cli.d.ts.map
package/dist/cli.js CHANGED
@@ -616,4 +616,3 @@ function printUsage() {
616
616
  "Run and test support --json for machine-readable output.",
617
617
  ].join("\n"));
618
618
  }
619
- //# sourceMappingURL=cli.js.map
@@ -2,4 +2,3 @@ export interface BuildProjectOptions {
2
2
  projectRoot?: string;
3
3
  }
4
4
  export declare function buildProject(options?: BuildProjectOptions): Promise<string>;
5
- //# sourceMappingURL=build-project.d.ts.map
@@ -133,4 +133,3 @@ function createProviderRuntimeSource(providerNames) {
133
133
  ].join("\n");
134
134
  return contents;
135
135
  }
136
- //# sourceMappingURL=build-project.js.map
@@ -1,4 +1,3 @@
1
1
  import type { AgentRegistration, CompiledBundle } from "../types.js";
2
2
  export declare function compileRegistry(registrations: Record<string, AgentRegistration>, registryRoot: string, actionRuntime?: "native" | "sandbox"): CompiledBundle;
3
3
  export declare function serializeBundle(bundle: CompiledBundle): string;
4
- //# sourceMappingURL=compile.d.ts.map
@@ -462,4 +462,3 @@ function validateNumber(agentName, field, value, constraints) {
462
462
  throw new Error(`Agent "${agentName}" has an invalid ${field}.`);
463
463
  }
464
464
  }
465
- //# sourceMappingURL=compile.js.map
package/dist/env.d.ts CHANGED
@@ -1,2 +1 @@
1
1
  export declare function loadProjectEnvironment(projectRoot: string): void;
2
- //# sourceMappingURL=env.d.ts.map
package/dist/env.js CHANGED
@@ -10,4 +10,3 @@ export function loadProjectEnvironment(projectRoot) {
10
10
  }
11
11
  }
12
12
  }
13
- //# sourceMappingURL=env.js.map
package/dist/errors.d.ts CHANGED
@@ -9,4 +9,3 @@ export declare class OrchaError extends Error {
9
9
  cause?: unknown;
10
10
  });
11
11
  }
12
- //# sourceMappingURL=errors.d.ts.map
package/dist/errors.js CHANGED
@@ -10,4 +10,3 @@ export class OrchaError extends Error {
10
10
  this.details = options.details;
11
11
  }
12
12
  }
13
- //# sourceMappingURL=errors.js.map
@@ -11,4 +11,3 @@ export declare function readLocalFileContent(content: LocalFileContent): Promise
11
11
  dataUri: string;
12
12
  fileName: string;
13
13
  }>;
14
- //# sourceMappingURL=file-content.d.ts.map
@@ -66,4 +66,3 @@ function normalizeMimeType(mimeType, source) {
66
66
  }
67
67
  return inferred;
68
68
  }
69
- //# sourceMappingURL=file-content.js.map
package/dist/index.d.ts CHANGED
@@ -6,4 +6,3 @@ export { NodeSqliteSessionStore } from "./storage/node-sqlite.js";
6
6
  export { exportSessionJsonl, migrateSessionStore, } from "./storage/migrate.js";
7
7
  export type { SessionStoreMigrationResult, } from "./storage/migrate.js";
8
8
  export type { ActionConfiguration, AgentTestActionConfiguration, AgentTestActionExpectation, AgentTestActionResponse, AgentTestAssertionResult, AgentTestCaseConfiguration, AgentTestCaseReport, AgentTestCaseSummary, AgentTestExpectation, AgentTestReport, AgentTestTextExpectation, AgentTestValueExpectation, AgentTestWarning, ApiKeyProviderConfiguration, AwsCredentials, AgentContinueInput, AgentConfiguration, AgentContentInput, AgentInput, AgentRegistration, AgentRuntime, ClientCapability, ClientToolCall, CompletedRunResult, CompiledActionManifest, CompiledAgentManifest, CompiledBundle, CompiledEvaluationManifest, CompiledSkillManifest, EvaluationConfiguration, EvaluationMetricConfiguration, EvaluationMetricResult, EvaluationResult, Execution, ExecutionSnapshot, FailedRunResult, FileContent, FilePathContentInput, LocalFileContent, LocalActionRuntimeConfiguration, MessageContent, MessageContentInput, MetadataValue, OrchaErrorCode, OrchaInitConfiguration, PausedRunResult, PaginationOptions, ProjectConfiguration, ProviderConfiguration, ProviderInitConfigurations, ProviderName, BedrockProviderConfiguration, RunError, RunStatus, RunTestsOptions, ResumeInput, RunResult, SessionEvent, SessionEventListOptions, SessionEvents, SessionEventType, SessionHistory, SessionHistoryItem, SessionList, SessionListOptions, SessionMetadata, SessionSnapshot, SessionStatus, SessionStore, SkillConfiguration, SessionUpdate, StreamingRunSnapshot, SubagentConfiguration, TextContent, ToolResult, ToolResumeInput, UrlContentInput, Usage, VertexAIProviderConfiguration, GoogleServiceAccountCredentials, WaitingRunResult, WaitingForSubagentSnapshot, } from "./types.js";
9
- //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -3,4 +3,3 @@ export { OrchaError } from "./errors.js";
3
3
  export { NodeJsonlSessionStore } from "./storage/node-jsonl.js";
4
4
  export { NodeSqliteSessionStore } from "./storage/node-sqlite.js";
5
5
  export { exportSessionJsonl, migrateSessionStore, } from "./storage/migrate.js";
6
- //# sourceMappingURL=index.js.map
@@ -7,4 +7,3 @@ export interface OrchaEsbuildPluginOptions {
7
7
  * application imports with the self-contained generated production runtime.
8
8
  */
9
9
  export declare function orchaPlugin(options?: OrchaEsbuildPluginOptions): Plugin;
10
- //# sourceMappingURL=esbuild.d.ts.map
@@ -19,4 +19,3 @@ export function orchaPlugin(options = {}) {
19
19
  },
20
20
  };
21
21
  }
22
- //# sourceMappingURL=esbuild.js.map
@@ -0,0 +1,27 @@
1
+ import type { Plugin } from "esbuild";
2
+ type ServerlessEsbuildOptions = {
3
+ config?: string;
4
+ exclude?: string[];
5
+ external?: string[];
6
+ plugins?: Plugin[] | string;
7
+ [key: string]: unknown;
8
+ };
9
+ type ServerlessLike = {
10
+ config?: {
11
+ servicePath?: string;
12
+ };
13
+ service: {
14
+ custom?: {
15
+ esbuild?: ServerlessEsbuildOptions;
16
+ [key: string]: unknown;
17
+ };
18
+ plugins?: string[];
19
+ };
20
+ };
21
+ export declare class OrchaServerlessPlugin {
22
+ private readonly serverless;
23
+ readonly hooks: Record<string, () => void>;
24
+ constructor(serverless: ServerlessLike);
25
+ private configureEsbuild;
26
+ }
27
+ export default OrchaServerlessPlugin;
@@ -0,0 +1,78 @@
1
+ import { createRequire } from "node:module";
2
+ import { resolve } from "node:path";
3
+ import { orchaPlugin } from "./esbuild.js";
4
+ export class OrchaServerlessPlugin {
5
+ serverless;
6
+ hooks;
7
+ constructor(serverless) {
8
+ this.serverless = serverless;
9
+ this.hooks = {
10
+ initialize: () => this.configureEsbuild(),
11
+ };
12
+ }
13
+ configureEsbuild() {
14
+ const servicePath = resolve(this.serverless.config?.servicePath ?? process.cwd());
15
+ const configuredPlugins = this.serverless.service.plugins ?? [];
16
+ if (!configuredPlugins.includes("serverless-esbuild")) {
17
+ throw new Error('The "orchajs/serverless" plugin requires "serverless-esbuild". Add "serverless-esbuild" before "orchajs/serverless" in the Serverless plugins list.');
18
+ }
19
+ const custom = this.serverless.service.custom ?? {};
20
+ const configuredEsbuild = custom.esbuild ?? {};
21
+ const esbuild = configuredEsbuild.config
22
+ ? loadEsbuildConfig(configuredEsbuild.config, servicePath, this.serverless)
23
+ : { ...configuredEsbuild };
24
+ assertOrchaIsBundled(esbuild);
25
+ const existingPlugins = loadEsbuildPlugins(esbuild.plugins, servicePath, this.serverless);
26
+ if (!existingPlugins.some((plugin) => plugin.name === "orchajs")) {
27
+ existingPlugins.push(orchaPlugin({ projectRoot: servicePath }));
28
+ }
29
+ delete esbuild.config;
30
+ esbuild.plugins = existingPlugins;
31
+ custom.esbuild = esbuild;
32
+ this.serverless.service.custom = custom;
33
+ }
34
+ }
35
+ function loadEsbuildConfig(configPath, servicePath, serverless) {
36
+ const loaded = loadProjectModule(configPath, servicePath);
37
+ const config = unwrapDefault(loaded);
38
+ if (typeof config !== "function") {
39
+ throw new Error(`Serverless esbuild config "${configPath}" must export a function.`);
40
+ }
41
+ return config(serverless);
42
+ }
43
+ function loadEsbuildPlugins(plugins, servicePath, serverless) {
44
+ if (!plugins) {
45
+ return [];
46
+ }
47
+ if (Array.isArray(plugins)) {
48
+ return [...plugins];
49
+ }
50
+ const loaded = unwrapDefault(loadProjectModule(plugins, servicePath));
51
+ const resolved = typeof loaded === "function"
52
+ ? loaded(serverless)
53
+ : loaded;
54
+ if (!Array.isArray(resolved)) {
55
+ throw new Error(`Serverless esbuild plugins file "${plugins}" must export an array or a function that returns one.`);
56
+ }
57
+ return [...resolved];
58
+ }
59
+ function loadProjectModule(path, servicePath) {
60
+ const requireFromProject = createRequire(resolve(servicePath, "package.json"));
61
+ return requireFromProject(resolve(servicePath, path));
62
+ }
63
+ function unwrapDefault(value) {
64
+ if (typeof value === "object" &&
65
+ value !== null &&
66
+ "default" in value) {
67
+ return value.default;
68
+ }
69
+ return value;
70
+ }
71
+ function assertOrchaIsBundled(options) {
72
+ for (const key of ["exclude", "external"]) {
73
+ if (options[key]?.includes("orchajs")) {
74
+ throw new Error(`Remove "orchajs" from custom.esbuild.${key}. Orcha must be replaced during bundling, not copied into the Lambda package.`);
75
+ }
76
+ }
77
+ }
78
+ export default OrchaServerlessPlugin;
package/dist/orcha.d.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  export type { Orcha, OrchaClient } from "./runtime/create-orcha.js";
2
2
  export declare const orcha: import("./runtime/create-orcha.js").OrchaClient;
3
- //# sourceMappingURL=orcha.d.ts.map
package/dist/orcha.js CHANGED
@@ -13,4 +13,3 @@ export const orcha = createOrcha((configuration) => {
13
13
  const registryRoot = resolve(projectRoot, "orcha");
14
14
  return compileRegistry(configuration.agents, registryRoot, configuration.actions?.runtime ?? "native");
15
15
  }, generateProviderResponse);
16
- //# sourceMappingURL=orcha.js.map
@@ -1,2 +1 @@
1
1
  .react-flow{direction:ltr;--xy-edge-stroke-default: #b1b1b7;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #555;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(255, 255, 255, .5);--xy-minimap-background-color-default: #fff;--xy-minimap-mask-background-color-default: rgba(240, 240, 240, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #e2e2e2;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: transparent;--xy-background-pattern-dots-color-default: #91919a;--xy-background-pattern-lines-color-default: #eee;--xy-background-pattern-cross-color-default: #e2e2e2;background-color:var(--xy-background-color, var(--xy-background-color-default));--xy-node-color-default: inherit;--xy-node-border-default: 1px solid #1a192b;--xy-node-background-color-default: #fff;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(0, 0, 0, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #1a192b;--xy-node-border-radius-default: 3px;--xy-handle-background-color-default: #1a192b;--xy-handle-border-color-default: #fff;--xy-selection-background-color-default: rgba(0, 89, 220, .08);--xy-selection-border-default: 1px dotted rgba(0, 89, 220, .8);--xy-controls-button-background-color-default: #fefefe;--xy-controls-button-background-color-hover-default: #f4f4f4;--xy-controls-button-color-default: inherit;--xy-controls-button-color-hover-default: inherit;--xy-controls-button-border-color-default: #eee;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #ffffff;--xy-edge-label-color-default: inherit;--xy-resize-background-color-default: #3367d9}.react-flow.dark{--xy-edge-stroke-default: #3e3e3e;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #727272;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(150, 150, 150, .25);--xy-minimap-background-color-default: #141414;--xy-minimap-mask-background-color-default: rgba(60, 60, 60, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #2b2b2b;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: #141414;--xy-background-pattern-dots-color-default: #555;--xy-background-pattern-lines-color-default: #333;--xy-background-pattern-cross-color-default: #333;--xy-node-color-default: #f8f8f8;--xy-node-border-default: 1px solid #3c3c3c;--xy-node-background-color-default: #1e1e1e;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(255, 255, 255, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #999;--xy-handle-background-color-default: #bebebe;--xy-handle-border-color-default: #1e1e1e;--xy-selection-background-color-default: rgba(200, 200, 220, .08);--xy-selection-border-default: 1px dotted rgba(200, 200, 220, .8);--xy-controls-button-background-color-default: #2b2b2b;--xy-controls-button-background-color-hover-default: #3e3e3e;--xy-controls-button-color-default: #f8f8f8;--xy-controls-button-color-hover-default: #fff;--xy-controls-button-border-color-default: #5b5b5b;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #141414;--xy-edge-label-color-default: #f8f8f8}.react-flow__background{background-color:var(--xy-background-color-props, var(--xy-background-color, var(--xy-background-color-default)));pointer-events:none;z-index:-1}.react-flow__container{position:absolute;width:100%;height:100%;top:0;left:0}.react-flow__pane{z-index:1;touch-action:none}.react-flow__pane.draggable{cursor:grab}.react-flow__pane.dragging{cursor:grabbing}.react-flow__pane.selection{cursor:pointer}.react-flow__viewport{transform-origin:0 0;z-index:2;pointer-events:none}.react-flow__renderer{z-index:4}.react-flow__selection{z-index:6}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible{outline:none}.react-flow__edge-path{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default));stroke-width:var(--xy-edge-stroke-width, var(--xy-edge-stroke-width-default));fill:none}.react-flow__connection-path{stroke:var(--xy-connectionline-stroke, var(--xy-connectionline-stroke-default));stroke-width:var(--xy-connectionline-stroke-width, var(--xy-connectionline-stroke-width-default));fill:none}.react-flow .react-flow__edges{position:absolute}.react-flow .react-flow__edges svg{overflow:visible;position:absolute;pointer-events:none}.react-flow__edge{pointer-events:visibleStroke}.react-flow__edge.selectable{cursor:pointer}.react-flow__edge.animated path{stroke-dasharray:5;animation:dashdraw .5s linear infinite}.react-flow__edge.animated path.react-flow__edge-interaction{stroke-dasharray:none;animation:none}.react-flow__edge.inactive{pointer-events:none}.react-flow__edge.selected,.react-flow__edge:focus,.react-flow__edge:focus-visible{outline:none}.react-flow__edge.selected .react-flow__edge-path,.react-flow__edge.selectable:focus .react-flow__edge-path,.react-flow__edge.selectable:focus-visible .react-flow__edge-path{stroke:var(--xy-edge-stroke-selected, var(--xy-edge-stroke-selected-default))}.react-flow__edge-textwrapper{pointer-events:all}.react-flow__edge .react-flow__edge-text{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__arrowhead polyline{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__arrowhead polyline.arrowclosed{fill:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__connection{pointer-events:none}.react-flow__connection .animated{stroke-dasharray:5;animation:dashdraw .5s linear infinite}svg.react-flow__connectionline{z-index:1001;overflow:visible;position:absolute}.react-flow__nodes{pointer-events:none;transform-origin:0 0}.react-flow__node{position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none;pointer-events:all;transform-origin:0 0;box-sizing:border-box;cursor:default}.react-flow__node.selectable{cursor:pointer}.react-flow__node.draggable{cursor:grab;pointer-events:all}.react-flow__node.draggable.dragging{cursor:grabbing}.react-flow__nodesselection{z-index:3;transform-origin:left top;pointer-events:none}.react-flow__nodesselection-rect{position:absolute;pointer-events:all;cursor:grab}.react-flow__handle{position:absolute;pointer-events:none;min-width:5px;min-height:5px;width:6px;height:6px;background-color:var(--xy-handle-background-color, var(--xy-handle-background-color-default));border:1px solid var(--xy-handle-border-color, var(--xy-handle-border-color-default));border-radius:100%}.react-flow__handle.connectingfrom{pointer-events:all}.react-flow__handle.connectionindicator{pointer-events:all;cursor:crosshair}.react-flow__handle-bottom{top:auto;left:50%;bottom:0;transform:translate(-50%,50%)}.react-flow__handle-top{top:0;left:50%;transform:translate(-50%,-50%)}.react-flow__handle-left{top:50%;left:0;transform:translate(-50%,-50%)}.react-flow__handle-right{top:50%;right:0;transform:translate(50%,-50%)}.react-flow__edgeupdater{cursor:move;pointer-events:all}.react-flow__pane.selection .react-flow__panel{pointer-events:none}.react-flow__panel{position:absolute;z-index:5;margin:15px}.react-flow__panel.top{top:0}.react-flow__panel.bottom{bottom:0}.react-flow__panel.top.center,.react-flow__panel.bottom.center{left:50%;transform:translate(-15px) translate(-50%)}.react-flow__panel.left{left:0}.react-flow__panel.right{right:0}.react-flow__panel.left.center,.react-flow__panel.right.center{top:50%;transform:translateY(-15px) translateY(-50%)}.react-flow__attribution{font-size:10px;background:var(--xy-attribution-background-color, var(--xy-attribution-background-color-default));padding:2px 3px;margin:0}.react-flow__attribution a{text-decoration:none;color:#999}@keyframes dashdraw{0%{stroke-dashoffset:10}}.react-flow__edgelabel-renderer{position:absolute;width:100%;height:100%;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;left:0;top:0}.react-flow__viewport-portal{position:absolute;width:100%;height:100%;left:0;top:0;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__minimap{background:var( --xy-minimap-background-color-props, var(--xy-minimap-background-color, var(--xy-minimap-background-color-default)) )}.react-flow__minimap-svg{display:block}.react-flow__minimap-mask{fill:var( --xy-minimap-mask-background-color-props, var(--xy-minimap-mask-background-color, var(--xy-minimap-mask-background-color-default)) );stroke:var( --xy-minimap-mask-stroke-color-props, var(--xy-minimap-mask-stroke-color, var(--xy-minimap-mask-stroke-color-default)) );stroke-width:var( --xy-minimap-mask-stroke-width-props, var(--xy-minimap-mask-stroke-width, var(--xy-minimap-mask-stroke-width-default)) )}.react-flow__minimap-node{fill:var( --xy-minimap-node-background-color-props, var(--xy-minimap-node-background-color, var(--xy-minimap-node-background-color-default)) );stroke:var( --xy-minimap-node-stroke-color-props, var(--xy-minimap-node-stroke-color, var(--xy-minimap-node-stroke-color-default)) );stroke-width:var( --xy-minimap-node-stroke-width-props, var(--xy-minimap-node-stroke-width, var(--xy-minimap-node-stroke-width-default)) )}.react-flow__background-pattern.dots{fill:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-dots-color-default)) )}.react-flow__background-pattern.lines{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-lines-color-default)) )}.react-flow__background-pattern.cross{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-cross-color-default)) )}.react-flow__controls{display:flex;flex-direction:column;box-shadow:var(--xy-controls-box-shadow, var(--xy-controls-box-shadow-default))}.react-flow__controls.horizontal{flex-direction:row}.react-flow__controls-button{display:flex;justify-content:center;align-items:center;height:26px;width:26px;padding:4px;border:none;background:var(--xy-controls-button-background-color, var(--xy-controls-button-background-color-default));border-bottom:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) );color:var( --xy-controls-button-color-props, var(--xy-controls-button-color, var(--xy-controls-button-color-default)) );cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__controls-button svg{width:100%;max-width:12px;max-height:12px;fill:currentColor}.react-flow__edge.updating .react-flow__edge-path{stroke:#777}.react-flow__edge-text{font-size:10px}.react-flow__node.selectable:focus,.react-flow__node.selectable:focus-visible{outline:none}.react-flow__node-input,.react-flow__node-default,.react-flow__node-output,.react-flow__node-group{padding:10px;border-radius:var(--xy-node-border-radius, var(--xy-node-border-radius-default));width:150px;font-size:12px;color:var(--xy-node-color, var(--xy-node-color-default));text-align:center;border:var(--xy-node-border, var(--xy-node-border-default));background-color:var(--xy-node-background-color, var(--xy-node-background-color-default))}.react-flow__node-input.selectable:hover,.react-flow__node-default.selectable:hover,.react-flow__node-output.selectable:hover,.react-flow__node-group.selectable:hover{box-shadow:var(--xy-node-boxshadow-hover, var(--xy-node-boxshadow-hover-default))}.react-flow__node-input.selectable.selected,.react-flow__node-input.selectable:focus,.react-flow__node-input.selectable:focus-visible,.react-flow__node-default.selectable.selected,.react-flow__node-default.selectable:focus,.react-flow__node-default.selectable:focus-visible,.react-flow__node-output.selectable.selected,.react-flow__node-output.selectable:focus,.react-flow__node-output.selectable:focus-visible,.react-flow__node-group.selectable.selected,.react-flow__node-group.selectable:focus,.react-flow__node-group.selectable:focus-visible{box-shadow:var(--xy-node-boxshadow-selected, var(--xy-node-boxshadow-selected-default))}.react-flow__node-group{background-color:var(--xy-node-group-background-color, var(--xy-node-group-background-color-default))}.react-flow__nodesselection-rect,.react-flow__selection{background:var(--xy-selection-background-color, var(--xy-selection-background-color-default));border:var(--xy-selection-border, var(--xy-selection-border-default))}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible,.react-flow__selection:focus,.react-flow__selection:focus-visible{outline:none}.react-flow__controls-button:hover{background:var( --xy-controls-button-background-color-hover-props, var(--xy-controls-button-background-color-hover, var(--xy-controls-button-background-color-hover-default)) );color:var( --xy-controls-button-color-hover-props, var(--xy-controls-button-color-hover, var(--xy-controls-button-color-hover-default)) )}.react-flow__controls-button:disabled{pointer-events:none}.react-flow__controls-button:disabled svg{fill-opacity:.4}.react-flow__controls-button:last-child{border-bottom:none}.react-flow__controls.horizontal .react-flow__controls-button{border-bottom:none;border-right:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) )}.react-flow__controls.horizontal .react-flow__controls-button:last-child{border-right:none}.react-flow__resize-control{position:absolute}.react-flow__resize-control.left,.react-flow__resize-control.right{cursor:ew-resize}.react-flow__resize-control.top,.react-flow__resize-control.bottom{cursor:ns-resize}.react-flow__resize-control.top.left,.react-flow__resize-control.bottom.right{cursor:nwse-resize}.react-flow__resize-control.bottom.left,.react-flow__resize-control.top.right{cursor:nesw-resize}.react-flow__resize-control.handle{width:5px;height:5px;border:1px solid #fff;border-radius:1px;background-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));translate:-50% -50%}.react-flow__resize-control.handle.left{left:0;top:50%}.react-flow__resize-control.handle.right{left:100%;top:50%}.react-flow__resize-control.handle.top{left:50%;top:0}.react-flow__resize-control.handle.bottom{left:50%;top:100%}.react-flow__resize-control.handle.top.left,.react-flow__resize-control.handle.bottom.left{left:0}.react-flow__resize-control.handle.top.right,.react-flow__resize-control.handle.bottom.right{left:100%}.react-flow__resize-control.line{border-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));border-width:0;border-style:solid}.react-flow__resize-control.line.left,.react-flow__resize-control.line.right{width:1px;transform:translate(-50%);top:0;height:100%}.react-flow__resize-control.line.left{left:0;border-left-width:1px}.react-flow__resize-control.line.right{left:100%;border-right-width:1px}.react-flow__resize-control.line.top,.react-flow__resize-control.line.bottom{height:1px;transform:translateY(-50%);left:0;width:100%}.react-flow__resize-control.line.top{top:0;border-top-width:1px}.react-flow__resize-control.line.bottom{border-bottom-width:1px;top:100%}.react-flow__edge-textbg{fill:var(--xy-edge-label-background-color, var(--xy-edge-label-background-color-default))}.react-flow__edge-text{fill:var(--xy-edge-label-color, var(--xy-edge-label-color-default))}
2
- /*# sourceMappingURL=app.css.map */
@@ -29,4 +29,3 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
29
29
  `}),r}function L6(e){let t=0,r=e.charCodeAt(t);for(;r===9||r===32;)t++,r=e.charCodeAt(t);return e.slice(t)}function xv(e,t){let r=B6(e,t),n=r.one(e,void 0),o=R6(r),i=Array.isArray(n)?{type:"root",children:n}:n||{type:"root",children:[]};return o&&("children"in i,i.children.push({type:"text",value:`
30
30
  `},o)),i}function Sv(e,t){return e&&"run"in e?async function(r,n){let o=xv(r,{file:n,...t});await e.run(o,n)}:function(r,n){return xv(r,{file:n,...e||t})}}function IE(e){if(e)throw e}var _v=Pe(K6(),1);function qf(e){if(typeof e!="object"||e===null)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function ME(){let e=[],t={run:r,use:n};return t;function r(...o){let i=-1,a=o.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);l(null,...o);function l(s,...u){let c=e[++i],d=-1;if(s){a(s);return}for(;++d<o.length;)(u[d]===null||u[d]===void 0)&&(u[d]=o[d]);o=u,c?Y6(c,l)(...u):a(null,...u)}}function n(o){if(typeof o!="function")throw new TypeError("Expected `middelware` to be a function, not "+o);return e.push(o),t}}function Y6(e,t){let r;return n;function n(...a){let l=e.length>a.length,s;l&&a.push(o);try{s=e.apply(this,a)}catch(u){let c=u;if(l&&r)throw c;return o(c)}l||(s&&s.then&&typeof s.then=="function"?s.then(i,o):s instanceof Error?o(s):i(s))}function o(a,...l){r||(r=!0,t(a,...l))}function i(a){o(null,a)}}var po={basename:Wde,dirname:Ude,extname:Vde,join:$de,sep:"/"};function Wde(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Wf(e);let r=0,n=-1,o=e.length,i;if(t===void 0||t.length===0||t.length>e.length){for(;o--;)if(e.codePointAt(o)===47){if(i){r=o+1;break}}else n<0&&(i=!0,n=o+1);return n<0?"":e.slice(r,n)}if(t===e)return"";let a=-1,l=t.length-1;for(;o--;)if(e.codePointAt(o)===47){if(i){r=o+1;break}}else a<0&&(i=!0,a=o+1),l>-1&&(e.codePointAt(o)===t.codePointAt(l--)?l<0&&(n=o):(l=-1,n=a));return r===n?n=a:n<0&&(n=e.length),e.slice(r,n)}function Ude(e){if(Wf(e),e.length===0)return".";let t=-1,r=e.length,n;for(;--r;)if(e.codePointAt(r)===47){if(n){t=r;break}}else n||(n=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function Vde(e){Wf(e);let t=e.length,r=-1,n=0,o=-1,i=0,a;for(;t--;){let l=e.codePointAt(t);if(l===47){if(a){n=t+1;break}continue}r<0&&(a=!0,r=t+1),l===46?o<0?o=t:i!==1&&(i=1):o>-1&&(i=-1)}return o<0||r<0||i===0||i===1&&o===r-1&&o===n+1?"":e.slice(o,r)}function $de(...e){let t=-1,r;for(;++t<e.length;)Wf(e[t]),e[t]&&(r=r===void 0?e[t]:r+"/"+e[t]);return r===void 0?".":Kde(r)}function Kde(e){Wf(e);let t=e.codePointAt(0)===47,r=Yde(e,!t);return r.length===0&&!t&&(r="."),r.length>0&&e.codePointAt(e.length-1)===47&&(r+="/"),t?"/"+r:r}function Yde(e,t){let r="",n=0,o=-1,i=0,a=-1,l,s;for(;++a<=e.length;){if(a<e.length)l=e.codePointAt(a);else{if(l===47)break;l=47}if(l===47){if(!(o===a-1||i===1))if(o!==a-1&&i===2){if(r.length<2||n!==2||r.codePointAt(r.length-1)!==46||r.codePointAt(r.length-2)!==46){if(r.length>2){if(s=r.lastIndexOf("/"),s!==r.length-1){s<0?(r="",n=0):(r=r.slice(0,s),n=r.length-1-r.lastIndexOf("/")),o=a,i=0;continue}}else if(r.length>0){r="",n=0,o=a,i=0;continue}}t&&(r=r.length>0?r+"/..":"..",n=2)}else r.length>0?r+="/"+e.slice(o+1,a):r=e.slice(o+1,a),n=a-o-1;o=a,i=0}else l===46&&i>-1?i++:i=-1}return r}function Wf(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}var Z6={cwd:Zde};function Zde(){return"/"}function Ou(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function G6(e){if(typeof e=="string")e=new URL(e);else if(!Ou(e)){let t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){let t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return Gde(e)}function Gde(e){if(e.hostname!==""){let n=new TypeError('File URL host must be "localhost" or empty on darwin');throw n.code="ERR_INVALID_FILE_URL_HOST",n}let t=e.pathname,r=-1;for(;++r<t.length;)if(t.codePointAt(r)===37&&t.codePointAt(r+1)===50){let n=t.codePointAt(r+2);if(n===70||n===102){let o=new TypeError("File URL path must not include encoded / characters");throw o.code="ERR_INVALID_FILE_URL_PATH",o}}return decodeURIComponent(t)}var NE=["history","path","basename","stem","extname","dirname"],Ml=class{constructor(t){let r;t?Ou(t)?r={path:t}:typeof t=="string"||Xde(t)?r={value:t}:r=t:r={},this.cwd="cwd"in r?"":Z6.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<NE.length;){let i=NE[n];i in r&&r[i]!==void 0&&r[i]!==null&&(this[i]=i==="history"?[...r[i]]:r[i])}let o;for(o in r)NE.includes(o)||(this[o]=r[o])}get basename(){return typeof this.path=="string"?po.basename(this.path):void 0}set basename(t){RE(t,"basename"),FE(t,"basename"),this.path=po.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?po.dirname(this.path):void 0}set dirname(t){X6(this.basename,"dirname"),this.path=po.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?po.extname(this.path):void 0}set extname(t){if(FE(t,"extname"),X6(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=po.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Ou(t)&&(t=G6(t)),RE(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?po.basename(this.path,this.extname):void 0}set stem(t){RE(t,"stem"),FE(t,"stem"),this.path=po.join(this.dirname||"",t+(this.extname||""))}fail(t,r,n){let o=this.message(t,r,n);throw o.fatal=!0,o}info(t,r,n){let o=this.message(t,r,n);return o.fatal=void 0,o}message(t,r,n){let o=new It(t,r,n);return this.path&&(o.name=this.path+":"+o.name,o.file=this.path),o.fatal=!1,this.messages.push(o),o}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}};function FE(e,t){if(e&&e.includes(po.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+po.sep+"`")}function RE(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function X6(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function Xde(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var Q6=(function(e){let n=this.constructor.prototype,o=n[e],i=function(){return o.apply(i,arguments)};return Object.setPrototypeOf(i,n),i});var Qde={}.hasOwnProperty,zE=class e extends Q6{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=ME()}copy(){let t=new e,r=-1;for(;++r<this.attachers.length;){let n=this.attachers[r];t.use(...n)}return t.data((0,_v.default)(!0,{},this.namespace)),t}data(t,r){return typeof t=="string"?arguments.length===2?(BE("data",this.frozen),this.namespace[t]=r,this):Qde.call(this.namespace,t)&&this.namespace[t]||void 0:t?(BE("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;let t=this;for(;++this.freezeIndex<this.attachers.length;){let[r,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let o=r.call(t,...n);typeof o=="function"&&this.transformers.use(o)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();let r=kv(t),n=this.parser||this.Parser;return AE("parse",n),n(String(r),r)}process(t,r){let n=this;return this.freeze(),AE("process",this.parser||this.Parser),LE("process",this.compiler||this.Compiler),r?o(void 0,r):new Promise(o);function o(i,a){let l=kv(t),s=n.parse(l);n.run(s,l,function(c,d,f){if(c||!d||!f)return u(c);let p=d,g=n.stringify(p,f);efe(g)?f.value=g:f.result=g,u(c,f)});function u(c,d){c||!d?a(c):i?i(d):r(void 0,d)}}}processSync(t){let r=!1,n;return this.freeze(),AE("processSync",this.parser||this.Parser),LE("processSync",this.compiler||this.Compiler),this.process(t,o),eq("processSync","process",r),n;function o(i,a){r=!0,IE(i),n=a}}run(t,r,n){J6(t),this.freeze();let o=this.transformers;return!n&&typeof r=="function"&&(n=r,r=void 0),n?i(void 0,n):new Promise(i);function i(a,l){let s=kv(r);o.run(t,s,u);function u(c,d,f){let p=d||t;c?l(c):a?a(p):n(void 0,p,f)}}}runSync(t,r){let n=!1,o;return this.run(t,r,i),eq("runSync","run",n),o;function i(a,l){IE(a),o=l,n=!0}}stringify(t,r){this.freeze();let n=kv(r),o=this.compiler||this.Compiler;return LE("stringify",o),J6(t),o(t,n)}use(t,...r){let n=this.attachers,o=this.namespace;if(BE("use",this.frozen),t!=null)if(typeof t=="function")s(t,r);else if(typeof t=="object")Array.isArray(t)?l(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function i(u){if(typeof u=="function")s(u,[]);else if(typeof u=="object")if(Array.isArray(u)){let[c,...d]=u;s(c,d)}else a(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function a(u){if(!("plugins"in u)&&!("settings"in u))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");l(u.plugins),u.settings&&(o.settings=(0,_v.default)(!0,o.settings,u.settings))}function l(u){let c=-1;if(u!=null)if(Array.isArray(u))for(;++c<u.length;){let d=u[c];i(d)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function s(u,c){let d=-1,f=-1;for(;++d<n.length;)if(n[d][0]===u){f=d;break}if(f===-1)n.push([u,...c]);else if(c.length>0){let[p,...g]=c,y=n[f][1];qf(y)&&qf(p)&&(p=(0,_v.default)(!0,y,p)),n[f]=[u,p,...g]}}}},jE=new zE().freeze();function AE(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function LE(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function BE(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function J6(e){if(!qf(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function eq(e,t,r){if(!r)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function kv(e){return Jde(e)?e:new Ml(e)}function Jde(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function efe(e){return typeof e=="string"||tfe(e)}function tfe(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}var rfe="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",tq=[],rq={allowDangerousHtml:!0},nfe=/^(https?|ircs?|mailto|xmpp)$/i,ofe=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function HE(e){let t=ife(e),r=afe(e);return lfe(t.runSync(t.parse(r),r),e)}function ife(e){let t=e.rehypePlugins||tq,r=e.remarkPlugins||tq,n=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...rq}:rq;return jE().use(fv).use(r).use(Sv,n).use(t)}function afe(e){let t=e.children||"",r=new Ml;return typeof t=="string"?r.value=t:(""+t,void 0),r}function lfe(e,t){let r=t.allowedElements,n=t.allowElement,o=t.components,i=t.disallowedElements,a=t.skipHtml,l=t.unwrapDisallowed,s=t.urlTransform||oq;for(let c of ofe)Object.hasOwn(t,c.from)&&(""+c.from+(c.to?"use `"+c.to+"` instead":"remove it")+rfe+c.id,void 0);return r&&i&&void 0,Hf(e,u),rE(e,{Fragment:Du.Fragment,components:o,ignoreInvalidStyle:!0,jsx:Du.jsx,jsxs:Du.jsxs,passKeys:!0,passNode:!0});function u(c,d,f){if(c.type==="raw"&&f&&typeof d=="number")return a?f.children.splice(d,1):f.children[d]={type:"text",value:c.value},d;if(c.type==="element"){let p;for(p in Nf)if(Object.hasOwn(Nf,p)&&Object.hasOwn(c.properties,p)){let g=c.properties[p],y=Nf[p];(y===null||y.includes(c.tagName))&&(c.properties[p]=s(String(g||""),p,c))}}if(c.type==="element"){let p=r?!r.includes(c.tagName):i?i.includes(c.tagName):!1;if(!p&&n&&typeof d=="number"&&(p=!n(c,d,f)),p&&f&&typeof d=="number")return l&&c.children?f.children.splice(d,1,...c.children):f.children.splice(d,1),d}}}function oq(e){let t=e.indexOf(":"),r=e.indexOf("?"),n=e.indexOf("#"),o=e.indexOf("/");return t===-1||o!==-1&&t>o||r!==-1&&t>r||n!==-1&&t>n||nfe.test(e.slice(0,t))?e:""}var ne=Pe(Nr(),1);function aq({tabs:e,activeTabId:t,events:r,streamingOutput:n,busy:o,onSelectTab:i,onCloseTab:a,onClose:l,onOpenSubagent:s,onSend:u,onResolve:c}){let d=e.find(z=>z.id===t)??e[0],f=d?r[d.id]??[]:[],p=(0,qn.useMemo)(()=>cfe(f),[f]),[g,y]=(0,qn.useState)({}),[b,m]=(0,qn.useState)({}),[v,h]=(0,qn.useState)({}),[x,k]=(0,qn.useState)({}),S=(0,qn.useRef)(null);if((0,qn.useEffect)(()=>{let z=S.current;if(!z)return;let F=requestAnimationFrame(()=>{z.scrollTop=z.scrollHeight});return()=>{cancelAnimationFrame(F)}},[d?.id,f.length,d?n[d.id]:void 0]),!d)return null;let P=g[d.id]??"",T=b[d.id]??"text",M=v[d.id]??{},B=x[d.id],j=ffe(f);return(0,ne.jsxs)(Cv.Modal,{isOpen:!0,onClose:l,closeable:!1,animate:!0,overrides:{Dialog:{style:{width:"min(1180px, calc(100vw - 48px))",height:"min(860px, calc(100vh - 48px))",maxWidth:"none",margin:0,borderRadius:"10px",overflow:"hidden",display:"flex",flexDirection:"column"}},DialogContainer:{style:{alignItems:"center",justifyContent:"center"}}},children:[(0,ne.jsxs)(aA,{children:[e.map(z=>(0,ne.jsxs)(lA,{$active:z.id===d.id,onClick:()=>i(z.id),children:[(0,ne.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:z.label}),(0,ne.jsx)("span",{role:"button",tabIndex:0,"aria-label":`Close ${z.label}`,onClick:F=>{F.stopPropagation(),a(z.id)},onKeyDown:F=>{F.key==="Enter"&&(F.stopPropagation(),a(z.id))},children:"\xD7"})]},z.id)),(0,ne.jsx)("button",{type:"button","aria-label":"Close session workspace",onClick:l,style:{marginLeft:"auto",alignSelf:"center",border:0,background:"transparent",cursor:"pointer",fontSize:18,padding:"8px 14px"},children:"\xD7"})]}),(0,ne.jsx)(In,{style:{minHeight:38,padding:"0 16px",borderBottom:"1px solid #e7e7e7"},children:(0,ne.jsxs)(et,{children:[d.kind==="subagent"?"Subagent":"Session"," \xB7"," ",d.sessionId||"New session",j.status?` \xB7 ${j.status}`:"",j.status==="Running"?(0,ne.jsx)("span",{style:{display:"inline-flex",marginLeft:5,verticalAlign:"-1px"},children:(0,ne.jsx)(iq.Spinner,{$size:9,$borderWidth:1,$color:"currentColor"})}):null,j.timestamp?` \xB7 ${j.timestamp}`:"",j.tokens!==void 0?` \xB7 ${j.tokens.toLocaleString()} tokens`:""]})}),(0,ne.jsx)(Cv.ModalBody,{ref:S,$style:{margin:0,minHeight:0,flex:1,overflowY:"auto"},children:(0,ne.jsx)(iA,{children:f.length===0&&!n[d.id]?(0,ne.jsx)(Mn,{children:d.sessionId?"Loading session transcript\u2026":"Send a message to start this agent."}):(0,ne.jsxs)(ne.Fragment,{children:[(0,ne.jsx)(sfe,{events:f,parentAgent:d.kind==="subagent"?d.parentAgent??d.agent:d.agent,onOpenSubagent:s}),n[d.id]?(0,ne.jsx)(jh,{$role:"assistant",children:(0,ne.jsx)(WE,{children:n[d.id]})}):null]})})}),d.kind==="parent"?(0,ne.jsx)("div",{style:{borderTop:"1px solid #e7e7e7",padding:12,background:"#fff"},children:p.length>0?(0,ne.jsxs)(ne.Fragment,{children:[(0,ne.jsxs)(et,{style:{marginBottom:8},children:[p.map(z=>z.name).join(", ")," requires a result. Enter JSON output."]}),B?(0,ne.jsx)(et,{style:{color:"#b42318",marginBottom:8},children:B}):null,p.map(z=>(0,ne.jsxs)("div",{style:{marginBottom:10},children:[(0,ne.jsx)(et,{style:{marginBottom:6},children:z.name}),(0,ne.jsx)(qE.Textarea,{value:M[z.callId]??"{}",onChange:F=>h(E=>({...E,[d.id]:{...E[d.id]??{},[z.callId]:F.currentTarget.value}})),size:fr.SIZE.compact})]},z.callId)),(0,ne.jsx)(In,{style:{justifyContent:"flex-end"},children:(0,ne.jsx)(fr.Button,{size:fr.SIZE.compact,disabled:o,onClick:()=>{try{let z=p.map(F=>({callId:F.callId,output:JSON.parse(M[F.callId]??"{}")}));k(F=>{let E={...F};return delete E[d.id],E}),c(d,z)}catch{k(z=>({...z,[d.id]:"Enter valid JSON output."}))}},children:"Continue"})})]}):(0,ne.jsxs)(ne.Fragment,{children:[(0,ne.jsxs)(In,{style:{marginBottom:8},children:[(0,ne.jsx)(fr.Button,{size:fr.SIZE.mini,kind:T==="text"?fr.KIND.primary:fr.KIND.tertiary,onClick:()=>m(z=>({...z,[d.id]:"text"})),children:"Text"}),(0,ne.jsx)(fr.Button,{size:fr.SIZE.mini,kind:T==="json"?fr.KIND.primary:fr.KIND.tertiary,onClick:()=>m(z=>({...z,[d.id]:"json"})),children:"JSON content"}),B?(0,ne.jsx)(et,{style:{color:"#b42318"},children:B}):null]}),(0,ne.jsxs)(In,{children:[(0,ne.jsx)("div",{style:{flex:1},children:(0,ne.jsx)(qE.Textarea,{value:P,placeholder:T==="text"?"Message this agent\u2026":'[{"type":"text","text":"Review this"},{"filePath":"./document.pdf"}]',onChange:z=>y(F=>({...F,[d.id]:z.currentTarget.value})),size:fr.SIZE.compact})}),(0,ne.jsx)(fr.Button,{size:fr.SIZE.compact,disabled:o||!P.trim(),onClick:()=>{try{let z=T==="json"?JSON.parse(P):P.trim();k(F=>{let E={...F};return delete E[d.id],E}),y(F=>({...F,[d.id]:""})),u(d,z)}catch{k(z=>({...z,[d.id]:"Enter valid JSON content."}))}},children:"Send"})]})]})}):null]})}function sfe({events:e,parentAgent:t,onOpenSubagent:r}){let n=new Map(e.filter(a=>["subagent.completed","subagent.paused","subagent.failed"].includes(a.type)).map(a=>[String(a.data.sessionId),a])),o=new Map(e.filter(a=>a.type==="action.requested").map(a=>[String(a.data.callId),a])),i=new Set(e.filter(a=>a.type==="action.completed"||a.type==="action.failed").map(a=>String(a.data.callId)));return(0,ne.jsx)(ne.Fragment,{children:e.map(a=>{if(a.type==="message.created"){let l=String(a.data.role??"assistant"),s=l==="user"?"user":"assistant",u=l==="user"?"User":l==="tool"?"Tool response":"Model",c=Array.isArray(a.data.content)?a.data.content:[],d=c.filter(g=>Nl(g)&&g.type==="text"&&typeof g.text=="string").map(g=>g.text).join(""),f=c.filter(g=>Nl(g)&&g.type==="reasoning"&&typeof g.text=="string").map(g=>g.text).join(""),p=c.filter(g=>Nl(g)&&!["text","reasoning","tool_call"].includes(String(g.type)));return(0,ne.jsxs)("div",{children:[f?(0,ne.jsx)(xa,{title:"Thought",children:(0,ne.jsx)(WE,{children:f})}):null,d&&a.data.parsedOutput===void 0?(0,ne.jsxs)(ne.Fragment,{children:[(0,ne.jsx)(P_,{children:u}),(0,ne.jsx)(jh,{$role:s,children:l==="assistant"?(0,ne.jsx)(WE,{children:d}):d})]}):null,a.data.parsedOutput!==void 0?(0,ne.jsxs)(ne.Fragment,{children:[(0,ne.jsx)(P_,{children:u}),(0,ne.jsx)(jh,{$role:s,children:(0,ne.jsx)(ur,{children:JSON.stringify(a.data.parsedOutput,null,2)})})]}):null,p.length>0?(0,ne.jsx)(xa,{title:u,children:(0,ne.jsx)(ur,{children:JSON.stringify(p,null,2)})}):null]},a.sequence)}if(a.type==="action.completed"||a.type==="action.failed"){let l=o.get(String(a.data.callId));return(0,ne.jsx)(xa,{title:`Tool \xB7 ${String(a.data.name??"unknown")}`,status:a.type==="action.completed"?"completed":"failed",children:(0,ne.jsx)(ur,{children:JSON.stringify({arguments:l?.data.arguments,output:a.data.output,error:a.data.error,durationMs:a.data.durationMs},null,2)})},a.sequence)}if(a.type==="action.requested"&&!i.has(String(a.data.callId)))return(0,ne.jsx)(xa,{title:`Tool \xB7 ${String(a.data.name??"unknown")}`,status:"running",children:(0,ne.jsx)(ur,{children:JSON.stringify(a.data.arguments,null,2)})},a.sequence);if(a.type==="skill.loaded")return(0,ne.jsx)(xa,{title:`Skill \xB7 ${String(a.data.name??"unknown")}`,status:a.data.alreadyLoaded?"already loaded":"loaded",children:(0,ne.jsx)(ur,{children:JSON.stringify(a.data,null,2)})},a.sequence);if(a.type==="subagent.initiated"){let l=String(a.data.sessionId),s=String(a.data.agent),u=n.get(l);return(0,ne.jsx)(__,{children:(0,ne.jsxs)(C_,{onClick:()=>r(t,l,s),children:[(0,ne.jsx)(E_,{children:"\u203A"}),(0,ne.jsxs)("span",{children:["Subagent \xB7 ",s]}),(0,ne.jsxs)(et,{style:{marginLeft:"auto"},children:[u?.data.status?.toString()??"running"," \u2192"]})]})},a.sequence)}if(a.type==="evaluation.completed"||a.type==="evaluation.failed")return(0,ne.jsx)(xa,{title:`Evaluation \xB7 ${String(a.data.name??"unknown")}`,status:a.type==="evaluation.failed"?"failed":a.data.status==="passed"?"passed":"failed",children:(0,ne.jsx)(ur,{children:JSON.stringify(a.data,null,2)})},a.sequence);if(a.type==="client_action.requested")return(0,ne.jsx)(xa,{title:"Client action",status:"waiting",children:(0,ne.jsx)(ur,{children:JSON.stringify(a.data.calls,null,2)})},a.sequence);if(a.type==="test.warning")return(0,ne.jsx)(xa,{title:"Test warning",status:"live actions",children:(0,ne.jsx)(et,{children:String(a.data.message??"")})},a.sequence);if(a.type==="run.started")return(0,ne.jsxs)(et,{style:{marginBottom:12},children:["Run ",a.run," started \xB7 ",String(a.data.provider)," /"," ",String(a.data.model)]},a.sequence);if(a.type==="run.completed"||a.type==="run.failed"||a.type==="run.paused"){let l=Nl(a.data.error)?a.data.error.message:void 0;return(0,ne.jsxs)("div",{style:{marginBottom:12},children:[(0,ne.jsxs)(et,{children:[a.type.replace("."," ")," \xB7"," ",String(a.data.status??"")]}),typeof l=="string"?(0,ne.jsx)(et,{style:{marginTop:4},children:l}):null]},a.sequence)}return null})})}function xa({title:e,status:t,children:r}){let[n,o]=(0,qn.useState)(!1);return(0,ne.jsxs)(__,{children:[(0,ne.jsxs)(C_,{onClick:()=>o(i=>!i),children:[(0,ne.jsx)(E_,{$open:n,children:"\u203A"}),(0,ne.jsx)("span",{children:e}),t?(0,ne.jsx)(et,{style:{marginLeft:"auto"},children:t}):null]}),n?(0,ne.jsx)(V2,{children:r}):null]})}var ufe={p:({children:e})=>(0,ne.jsx)(K2,{children:e}),h1:({children:e})=>(0,ne.jsx)(Cd,{children:e}),h2:({children:e})=>(0,ne.jsx)(Cd,{children:e}),h3:({children:e})=>(0,ne.jsx)(Cd,{children:e}),h4:({children:e})=>(0,ne.jsx)(Cd,{children:e}),ul:({children:e})=>(0,ne.jsx)(Y2,{children:e}),ol:({children:e})=>(0,ne.jsx)(Z2,{children:e}),li:({children:e})=>(0,ne.jsx)(G2,{children:e}),blockquote:({children:e})=>(0,ne.jsx)(Q2,{children:e}),a:({children:e,href:t})=>(0,ne.jsx)(J2,{href:t,target:"_blank",rel:"noreferrer",children:e}),pre:({children:e})=>(0,ne.jsx)(ne.Fragment,{children:e}),code:({children:e,className:t})=>{let r=String(e).replace(/\n$/,"");return t||r.includes(`
31
31
  `)?(0,ne.jsx)(ur,{children:r}):(0,ne.jsx)(X2,{children:e})}};function WE({children:e}){return(0,ne.jsx)($2,{children:(0,ne.jsx)(HE,{components:ufe,children:e})})}function cfe(e){let t=[];for(let r of e)r.type==="client_action.requested"&&Array.isArray(r.data.calls)&&(t=r.data.calls.filter(dfe)),r.type==="client_action.resolved"&&(t=[]);return t}function dfe(e){return Nl(e)&&typeof e.callId=="string"&&typeof e.name=="string"&&Nl(e.arguments)}function Nl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ffe(e){let t=[...e].reverse().find(o=>["run.completed","run.failed","run.paused"].includes(o.type)),r=t&&Nl(t.data.usage)?t.data.usage:void 0,n=r?["inputTokens","outputTokens","reasoningTokens"].map(o=>r[o]).filter(o=>typeof o=="number").reduce((o,i)=>o+i,0):void 0;return{status:t?.type==="run.completed"?"Completed":t?.type==="run.failed"?"Failed":t?.type==="run.paused"?String(t.data.status??"Paused"):e.length>0?"Running":void 0,timestamp:e[0]?new Date(e[0].timestamp).toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):void 0,tokens:n}}var We=Pe(Nr(),1);function sq(){let[e,t]=(0,Je.useState)([]),[r,n]=(0,Je.useState)(),[o,i]=(0,Je.useState)(),[a,l]=(0,Je.useState)([]),[s,u]=(0,Je.useState)(""),[c,d]=(0,Je.useState)(0),[f,p]=(0,Je.useState)(),[g,y]=(0,Je.useState)(!0),[b,m]=(0,Je.useState)(!1),[v,h]=(0,Je.useState)([]),[x,k]=(0,Je.useState)(),[S,P]=(0,Je.useState)({}),[T,M]=(0,Je.useState)({}),B=(0,Je.useRef)(new Map),j=(0,Je.useRef)(new Map),z=(0,Je.useRef)(0),F=(0,Je.useCallback)(async()=>{let D=await mR();t(D),n(_=>_&&D.some(U=>U.key===_)?_:D[0]?.key),y(!1)},[]);(0,Je.useEffect)(()=>{F().catch(_=>{p(_ instanceof Error?_.message:String(_)),y(!1)});let D=new EventSource("/api/project/events");return D.onmessage=_=>{let U=JSON.parse(_.data);U.type==="project.updated"?(p(void 0),d(re=>re+1),F()):U.type==="project.error"&&p(U.error??"Project reload failed.")},()=>D.close()},[F]),(0,Je.useEffect)(()=>()=>{for(let D of B.current.values())D.close();B.current.clear();for(let D of j.current.values())D.close();j.current.clear()},[]);let E=(0,Je.useCallback)(async()=>{if(!r)return;let D=++z.current,[_,U]=await Promise.all([hR(r),yR(r)]);D===z.current&&(i(_),l(U))},[r]);(0,Je.useEffect)(()=>{i(void 0),l([]),E().catch(D=>p(D instanceof Error?D.message:String(D)))},[E,c]),(0,Je.useEffect)(()=>{if(!r)return;let D=wR(r,_=>{l(U=>mfe(U,_))});return()=>D.close()},[r,c]);let N=(0,Je.useMemo)(()=>{let D=s.trim().toLowerCase();return D?e.filter(_=>_.name.toLowerCase().includes(D)||_.key.toLowerCase().includes(D)):e},[e,s]),R=(0,Je.useCallback)((D,_,U)=>{if(j.current.has(U))return;let re=SR(D,_,ie=>{P(ce=>({...ce,[U]:Ev(ce[U]??[],ie)}))});j.current.set(U,re)},[]),L=async D=>{if(!r)return;let _=`session:${D.sessionId}`;if(h(U=>U.some(re=>re.id===_)?U:[...U,{id:_,agent:r,sessionId:D.sessionId,label:D.name??r,kind:"parent"}]),k(_),R(r,D.sessionId,_),!S[_])try{let U=await vR(r,D.sessionId);P(re=>({...re,[_]:U}))}catch(U){p(U instanceof Error?U.message:String(U))}},q=()=>{if(!r||!o)return;let D=`new:${r}:${Date.now()}`;h(_=>[..._,{id:D,agent:r,sessionId:"",label:o.name,kind:"parent"}]),P(_=>({..._,[D]:[]})),k(D)},W=async(D,_,U)=>{let re=`subagent:${_}`;if(h(ie=>ie.some(ce=>ce.id===re)?ie:[...ie,{id:re,agent:U,parentAgent:D,sessionId:_,label:U,kind:"subagent"}]),k(re),!B.current.has(re)){let ie=xR(D,_,ce=>{P(K=>({...K,[re]:Ev(K[re]??[],ce)})),ce.some(K=>["run.completed","run.failed"].includes(K.type))&&(ie.close(),B.current.delete(re))});B.current.set(re,ie)}if(!S[re])try{let ie=await Uk(D,_);P(ce=>({...ce,[re]:Ev(ce[re]??[],ie)}))}catch(ie){p(ie instanceof Error?ie.message:String(ie))}},C=async(D,_)=>{m(!0),p(void 0);try{await bR(D.agent,_,U=>{if(U.type==="snapshot"&&gfe(U.snapshot)&&U.snapshot.status==="streaming"){let re=U.snapshot.output;M(ie=>({...ie,[D.id]:typeof re=="string"?re:JSON.stringify(re,null,2)??String(re)}))}if(U.type==="execution.started"&&typeof U.sessionId=="string"){let re=U.sessionId;R(D.agent,re,D.id),h(ie=>ie.map(ce=>ce.id===D.id?{...ce,sessionId:re}:ce))}if(U.type==="events.appended"&&Array.isArray(U.events)){let re=U.events;re.some(ie=>ie.type==="message.created"&&ie.data.role==="assistant")&&M(ie=>({...ie,[D.id]:""})),P(ie=>({...ie,[D.id]:Ev(ie[D.id]??[],re)}));for(let ie of re)if(["subagent.completed","subagent.paused","subagent.failed"].includes(ie.type)&&typeof ie.data.sessionId=="string"){let ce=`subagent:${ie.data.sessionId}`;Uk(D.agent,ie.data.sessionId).then(K=>P(pe=>({...pe,[ce]:K}))).catch(()=>{})}}U.type==="events"&&Array.isArray(U.events)&&(M(re=>({...re,[D.id]:""})),P(re=>({...re,[D.id]:U.events}))),U.type==="error"&&p(String(U.error))}),await E()}catch(U){p(U instanceof Error?U.message:String(U))}finally{m(!1)}},J=D=>{B.current.get(D)?.close(),B.current.delete(D),j.current.get(D)?.close(),j.current.delete(D),h(_=>{let U=_.findIndex(ie=>ie.id===D),re=_.filter(ie=>ie.id!==D);return D===x&&k(re[Math.max(0,U-1)]?.id),re}),P(_=>{let U={..._};return delete U[D],U}),M(_=>{let U={..._};return delete U[D],U})};return(0,We.jsxs)(A2,{children:[(0,We.jsxs)(L2,{children:[(0,We.jsxs)(B2,{children:[(0,We.jsx)(z2,{src:"/orcha-logo.svg",alt:""}),(0,We.jsxs)("div",{children:[(0,We.jsx)(kr,{children:"Orcha Playground"}),(0,We.jsx)(et,{children:"Local agent workspace"})]})]}),(0,We.jsxs)(et,{children:[e.length," agents"]})]}),f?(0,We.jsx)(Ov.Notification,{kind:Ov.KIND.negative,overrides:{Body:{style:{margin:0,width:"auto"}}},children:f}):null,(0,We.jsxs)(j2,{children:[(0,We.jsxs)(S_,{children:[(0,We.jsx)(_d,{children:(0,We.jsx)(kr,{children:"Agents"})}),(0,We.jsx)("div",{style:{padding:8},children:(0,We.jsx)(Pv.Input,{value:s,onChange:D=>u(D.currentTarget.value),placeholder:"Search agents",size:Pv.SIZE.mini,clearable:!0,overrides:{Root:{style:({$theme:D})=>({borderTopColor:D.colors.contentPrimary,borderRightColor:D.colors.contentPrimary,borderBottomColor:D.colors.contentPrimary,borderLeftColor:D.colors.contentPrimary,backgroundColor:D.colors.backgroundPrimary})},InputContainer:{style:({$theme:D})=>({backgroundColor:D.colors.backgroundPrimary})},Input:{style:({$theme:D})=>({color:D.colors.contentPrimary,backgroundColor:D.colors.backgroundPrimary,"::placeholder":{color:D.colors.contentSecondary,opacity:1}})}}})}),(0,We.jsx)(w_,{children:N.map(D=>(0,We.jsxs)(k_,{$active:D.key===r,onClick:()=>{z.current+=1,n(D.key)},children:[(0,We.jsx)(kr,{children:D.name}),(0,We.jsxs)(et,{children:[D.provider," \xB7 ",D.model]})]},D.key))})]}),(0,We.jsx)(H2,{children:g||r&&!o?(0,We.jsx)(Mn,{children:(0,We.jsx)(lq.Spinner,{$size:20})}):o?(0,We.jsx)(xz,{agent:o,revision:c,onTry:q},o.key):(0,We.jsx)(Mn,{children:"No registered agents."})}),(0,We.jsxs)(S_,{$right:!0,children:[(0,We.jsxs)(_d,{children:[(0,We.jsx)(kr,{children:"Sessions"}),(0,We.jsx)(Tu.Button,{kind:Tu.KIND.tertiary,size:Tu.SIZE.mini,onClick:()=>void E(),children:"Refresh"})]}),(0,We.jsx)(w_,{children:a.length===0?(0,We.jsx)(Mn,{children:"No sessions yet."}):a.map(D=>(0,We.jsxs)(k_,{onClick:()=>void L(D),children:[(0,We.jsx)(kr,{children:D.name??"Untitled session"}),(0,We.jsxs)(et,{children:[D.runStatus??D.status," \xB7"," ",pfe(D.updatedAt)]})]},D.sessionId))})]})]}),(0,We.jsx)(aq,{tabs:v,activeTabId:x,events:S,streamingOutput:T,busy:b,onSelectTab:k,onCloseTab:J,onClose:()=>{for(let D of B.current.values())D.close();B.current.clear();for(let D of j.current.values())D.close();j.current.clear(),h([]),k(void 0),P({}),M({})},onOpenSubagent:(D,_,U)=>void W(D,_,U),onSend:async(D,_)=>{await C(D,{content:_,...D.sessionId?{sessionId:D.sessionId}:{}})},onResolve:async(D,_)=>{await C(D,{sessionId:D.sessionId,toolResults:_})}})]})}function pfe(e){return new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function gfe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ev(e,t){return[...new Map([...e,...t].map(n=>[n.sequence,n])).values()].sort((n,o)=>n.sequence-o.sequence)}function mfe(e,t){return[t,...e.filter(r=>r.sessionId!==t.sessionId)].sort((r,n)=>new Date(n.updatedAt).getTime()-new Date(r.updatedAt).getTime())}var Uf=Pe(Nr(),1),fq=document.getElementById("root");if(!fq)throw new Error("Playground root element was not found.");var hfe=new Gw;(0,cq.createRoot)(fq).render((0,Uf.jsx)(uq.StrictMode,{children:(0,Uf.jsx)(dq.Provider,{value:hfe,children:(0,Uf.jsx)(Dv.BaseProvider,{theme:Dv.LightTheme,children:(0,Uf.jsx)(sq,{})})})}));
32
- //# sourceMappingURL=app.js.map
@@ -5,4 +5,3 @@ export interface PlaygroundOptions {
5
5
  open?: boolean;
6
6
  }
7
7
  export declare function startPlayground(options?: PlaygroundOptions): Promise<void>;
8
- //# sourceMappingURL=server.d.ts.map