orchajs 0.14.0 → 0.15.1

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 (89) hide show
  1. package/README.md +9 -0
  2. package/dist-cjs/cli-agents-template.js +1090 -0
  3. package/dist-cjs/cli-agents-template.js.map +7 -0
  4. package/dist-cjs/compiler/build-project.js +180 -0
  5. package/dist-cjs/compiler/build-project.js.map +7 -0
  6. package/dist-cjs/compiler/compile.js +558 -0
  7. package/dist-cjs/compiler/compile.js.map +7 -0
  8. package/dist-cjs/env.js +38 -0
  9. package/dist-cjs/env.js.map +7 -0
  10. package/dist-cjs/errors.js +41 -0
  11. package/dist-cjs/errors.js.map +7 -0
  12. package/dist-cjs/file-content.js +102 -0
  13. package/dist-cjs/file-content.js.map +7 -0
  14. package/dist-cjs/index.js +44 -0
  15. package/dist-cjs/index.js.map +7 -0
  16. package/dist-cjs/integrations/esbuild.js +46 -0
  17. package/dist-cjs/integrations/esbuild.js.map +7 -0
  18. package/dist-cjs/orcha.js +52 -0
  19. package/dist-cjs/orcha.js.map +7 -0
  20. package/dist-cjs/package.json +3 -0
  21. package/dist-cjs/playground/server.js +685 -0
  22. package/dist-cjs/playground/server.js.map +7 -0
  23. package/dist-cjs/playground/source.js +155 -0
  24. package/dist-cjs/playground/source.js.map +7 -0
  25. package/dist-cjs/project-loader.js +86 -0
  26. package/dist-cjs/project-loader.js.map +7 -0
  27. package/dist-cjs/providers/anthropic.js +419 -0
  28. package/dist-cjs/providers/anthropic.js.map +7 -0
  29. package/dist-cjs/providers/bedrock.js +578 -0
  30. package/dist-cjs/providers/bedrock.js.map +7 -0
  31. package/dist-cjs/providers/catalog.js +60 -0
  32. package/dist-cjs/providers/catalog.js.map +7 -0
  33. package/dist-cjs/providers/deepseek.js +315 -0
  34. package/dist-cjs/providers/deepseek.js.map +7 -0
  35. package/dist-cjs/providers/dispatcher.js +42 -0
  36. package/dist-cjs/providers/dispatcher.js.map +7 -0
  37. package/dist-cjs/providers/google-gemini.js +366 -0
  38. package/dist-cjs/providers/google-gemini.js.map +7 -0
  39. package/dist-cjs/providers/google-genai.js +51 -0
  40. package/dist-cjs/providers/google-genai.js.map +7 -0
  41. package/dist-cjs/providers/index.js +66 -0
  42. package/dist-cjs/providers/index.js.map +7 -0
  43. package/dist-cjs/providers/openai.js +330 -0
  44. package/dist-cjs/providers/openai.js.map +7 -0
  45. package/dist-cjs/providers/sse.js +83 -0
  46. package/dist-cjs/providers/sse.js.map +7 -0
  47. package/dist-cjs/providers/types.js +18 -0
  48. package/dist-cjs/providers/types.js.map +7 -0
  49. package/dist-cjs/providers/vertex-ai.js +68 -0
  50. package/dist-cjs/providers/vertex-ai.js.map +7 -0
  51. package/dist-cjs/runtime/actions/context.js +82 -0
  52. package/dist-cjs/runtime/actions/context.js.map +7 -0
  53. package/dist-cjs/runtime/actions/execute.js +59 -0
  54. package/dist-cjs/runtime/actions/execute.js.map +7 -0
  55. package/dist-cjs/runtime/actions/native.js +68 -0
  56. package/dist-cjs/runtime/actions/native.js.map +7 -0
  57. package/dist-cjs/runtime/actions/sandbox.js +168 -0
  58. package/dist-cjs/runtime/actions/sandbox.js.map +7 -0
  59. package/dist-cjs/runtime/agent.js +2842 -0
  60. package/dist-cjs/runtime/agent.js.map +7 -0
  61. package/dist-cjs/runtime/context.js +44 -0
  62. package/dist-cjs/runtime/context.js.map +7 -0
  63. package/dist-cjs/runtime/create-orcha.js +155 -0
  64. package/dist-cjs/runtime/create-orcha.js.map +7 -0
  65. package/dist-cjs/runtime/execution.js +104 -0
  66. package/dist-cjs/runtime/execution.js.map +7 -0
  67. package/dist-cjs/runtime/session-events.js +235 -0
  68. package/dist-cjs/runtime/session-events.js.map +7 -0
  69. package/dist-cjs/runtime/structured-output.js +146 -0
  70. package/dist-cjs/runtime/structured-output.js.map +7 -0
  71. package/dist-cjs/storage/browser-indexeddb.js +40 -0
  72. package/dist-cjs/storage/browser-indexeddb.js.map +7 -0
  73. package/dist-cjs/storage/create-store.js +50 -0
  74. package/dist-cjs/storage/create-store.js.map +7 -0
  75. package/dist-cjs/storage/edge-store.js +40 -0
  76. package/dist-cjs/storage/edge-store.js.map +7 -0
  77. package/dist-cjs/storage/migrate.js +68 -0
  78. package/dist-cjs/storage/migrate.js.map +7 -0
  79. package/dist-cjs/storage/node-jsonl.js +278 -0
  80. package/dist-cjs/storage/node-jsonl.js.map +7 -0
  81. package/dist-cjs/storage/node-sqlite.js +198 -0
  82. package/dist-cjs/storage/node-sqlite.js.map +7 -0
  83. package/dist-cjs/storage/react-native-jsonl.js +40 -0
  84. package/dist-cjs/storage/react-native-jsonl.js.map +7 -0
  85. package/dist-cjs/testing.js +726 -0
  86. package/dist-cjs/testing.js.map +7 -0
  87. package/dist-cjs/types.js +18 -0
  88. package/dist-cjs/types.js.map +7 -0
  89. package/package.json +21 -6
@@ -0,0 +1,1090 @@
1
+ "use strict"; const __orchaImportMetaUrl = require("node:url").pathToFileURL(__filename).href;
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var cli_agents_template_exports = {};
21
+ __export(cli_agents_template_exports, {
22
+ AGENTS_MD: () => AGENTS_MD
23
+ });
24
+ module.exports = __toCommonJS(cli_agents_template_exports);
25
+ const AGENTS_MD = `# Orcha project guide
26
+
27
+ This repository uses OrchaJS, a filesystem-convention framework for durable
28
+ AI agents. Treat the \`orcha/\` directory as source code. Do not edit generated
29
+ files under \`.orcha/\`.
30
+
31
+ ## Commands
32
+
33
+ - \`orcha init\` creates the initial Orcha files without overwriting files.
34
+ - \`orcha dev\` validates agent source and watches \`orcha/**\` for changes.
35
+ - \`orcha playground\` opens the built-in local UI and hot reloads agent source.
36
+ - \`orcha run <agent> --input "\u2026"\` executes one registered agent.
37
+ - \`orcha run <agent> --input-file request.json\` accepts structured input.
38
+ - \`orcha run <agent> --session <id> --input "\u2026"\` continues a session.
39
+ - \`orcha run <agent> --session <id> --tool-results results.json\` submits
40
+ pending client-action results.
41
+ - \`orcha test\` runs every enabled discovered agent test.
42
+ - \`orcha test <agent>\` or \`orcha test <agent>/<case>\` narrows the run.
43
+ - \`orcha migrate-storage --to sqlite|node-jsonl\` copies all session histories
44
+ between local stores without deleting the source.
45
+ - \`orcha export-session <agent> <sessionId> [--output <path>]\` exports one
46
+ session from the active store as JSONL.
47
+ - \`orcha build\` creates the production Orcha bundle without calling models.
48
+ - Add \`--json\` to \`run\` and \`test\` for machine-readable output.
49
+
50
+ \`run\`, \`test\`, and playground executions use real providers and require
51
+ credentials. \`dev\` and \`build\` are offline. Sessions use JSONL by default
52
+ under \`.orcha/sessions/<agentName>/\`; opt-in SQLite stores all agents in
53
+ \`.orcha/sessions/orcha-sqlite.db\`.
54
+
55
+ ## Registry
56
+
57
+ \`orcha/index.ts\` initializes providers and explicitly registers agents:
58
+
59
+ \`\`\`ts
60
+ import { orcha } from "orchajs";
61
+
62
+ orcha.init({
63
+ providers: {
64
+ anthropic: process.env.ANTHROPIC_API_KEY ?? "",
65
+ openai: process.env.OPENAI_API_KEY ?? "",
66
+ },
67
+ agents: {
68
+ supportBot: "./supportBot",
69
+ },
70
+ });
71
+ \`\`\`
72
+
73
+ Only registered agents are compiled. Agent keys become runtime properties
74
+ such as \`orcha.supportBot\`. Local actions use the native Node.js runtime by
75
+ default. Set \`actions.runtime: "sandbox"\` only when isolated execution is
76
+ required.
77
+
78
+ \`orcha.init()\` fields:
79
+
80
+ - \`providers\` (required): provider configurations keyed by built-in provider
81
+ name.
82
+ - \`agents\` (required): runtime property names mapped to folders relative to
83
+ \`orcha/\`. At least one agent is required.
84
+ - \`actions\` (optional): overrides the native local-action runtime or configures
85
+ its environment and sandbox settings.
86
+ - \`storage.strategy\` (optional): \`"node-jsonl"\` (default) or \`"sqlite"\`.
87
+ The SQLite driver ships as an internal optional Orcha dependency.
88
+ - \`storage.directory\` (optional): session directory relative to project
89
+ root; defaults to \`.orcha/sessions\`.
90
+ - \`root\` (optional): absolute or working-directory-relative project root;
91
+ defaults to \`ORCHA_PROJECT_ROOT\` and then \`process.cwd()\`.
92
+
93
+ The Orcha library reads the host application's existing \`process.env\`.
94
+ Standalone Orcha CLI commands also load \`.env\` from the project root without
95
+ overriding environment variables already in the process.
96
+
97
+ Provider configuration shapes:
98
+
99
+ \`\`\`ts
100
+ providers: {
101
+ anthropic: process.env.ANTHROPIC_API_KEY ?? "",
102
+ deepseek: process.env.DEEPSEEK_API_KEY ?? "",
103
+ googlegenai: process.env.GOOGLE_API_KEY ?? "",
104
+ openai: {
105
+ apiKey: process.env.OPENAI_API_KEY ?? "",
106
+ baseUrl: "https://api.openai.com/v1", // optional override
107
+ },
108
+ vertexai: {
109
+ project: process.env.GOOGLE_CLOUD_PROJECT ?? "",
110
+ location: process.env.GOOGLE_CLOUD_LOCATION ?? "us-central1",
111
+ // credentials is optional; omit it to use Google ADC.
112
+ credentials: {
113
+ clientEmail: process.env.GOOGLE_CLIENT_EMAIL ?? "",
114
+ privateKey: process.env.GOOGLE_PRIVATE_KEY ?? "",
115
+ },
116
+ baseUrl: undefined, // optional override
117
+ },
118
+ bedrock: {
119
+ region: process.env.AWS_REGION ?? "us-east-1",
120
+ // credentials is optional; omit it to use the AWS credential chain.
121
+ credentials: {
122
+ accessKeyId: process.env.AWS_ACCESS_KEY_ID ?? "",
123
+ secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY ?? "",
124
+ sessionToken: process.env.AWS_SESSION_TOKEN,
125
+ },
126
+ baseUrl: undefined, // optional override
127
+ },
128
+ }
129
+ \`\`\`
130
+
131
+ API-key providers accept either a string shorthand or
132
+ \`{ apiKey, baseUrl? }\`. Vertex AI requires \`project\` and \`location\`;
133
+ explicit service-account credentials are optional. Bedrock requires \`region\`;
134
+ explicit AWS credentials are optional. Never place credentials in
135
+ \`index.json\`, instructions, tests, session metadata, or committed files.
136
+
137
+ ## Agent folders
138
+
139
+ \`\`\`text
140
+ orcha/
141
+ index.ts
142
+ supportBot/
143
+ index.json
144
+ instructions.md
145
+ actions/
146
+ skills/
147
+ tests/
148
+ evaluations/
149
+ \`\`\`
150
+
151
+ \`index.json\` selects the model:
152
+
153
+ \`\`\`json
154
+ {
155
+ "name": "Support Agent",
156
+ "description": "Resolve customer support questions using confirmed account data.",
157
+ "provider": "anthropic",
158
+ "model": "claude-sonnet-4-6",
159
+ "region": "provider_managed",
160
+ "maxTokens": 10240,
161
+ "outputType": "text"
162
+ }
163
+ \`\`\`
164
+
165
+ Optional fields include \`reasoningLevel\`, \`outputType: "json"\`, and an
166
+ \`outputSchema\` JSON Schema. Provider-specific reasoning values are forwarded
167
+ without translation. Put the agent's stable role, boundaries, and operating
168
+ instructions in \`instructions.md\`.
169
+
170
+ Agent \`index.json\` fields:
171
+
172
+ - \`name\` (required): concise human-readable agent name.
173
+ - \`description\` (optional): what the agent does and when it should be used.
174
+ - \`provider\` (required): \`"anthropic"\`, \`"bedrock"\`, \`"deepseek"\`,
175
+ \`"openai"\`, \`"googlegenai"\`, or \`"vertexai"\`.
176
+ - \`model\` (required): exact provider model identifier.
177
+ - \`region\` (optional): provider/model routing hint; defaults in durable
178
+ metadata to \`"provider_managed"\`.
179
+ - \`maxTokens\` (optional): positive integer. If omitted, the provider adapter
180
+ chooses its default.
181
+ - \`reasoningLevel\` (optional): non-empty provider-native string. Orcha does
182
+ not translate values between providers.
183
+ - \`outputType\` (optional): \`"text"\` (default) or \`"json"\`. Image and
184
+ audio are reserved but not implemented.
185
+ - \`outputSchema\` (required for JSON output): JSON Schema used for provider
186
+ structured output and final validation.
187
+
188
+ \`instructions.md\` is required and cannot be empty. At compile time it becomes
189
+ the base system prompt. Orcha appends the compact available-skill catalog and
190
+ the full instructions for skills already loaded in this durable session.
191
+
192
+ ## Subagents
193
+
194
+ Register private subagents alongside a parent in \`orcha/index.ts\`:
195
+
196
+ \`\`\`js
197
+ agents: {
198
+ coordinator: {
199
+ path: "./coordinator",
200
+ subagents: {
201
+ researcher: "./researcher",
202
+ },
203
+ },
204
+ researcher: "./researcher",
205
+ }
206
+ \`\`\`
207
+
208
+ Only top-level keys become \`orcha.<agentName>\`. In this example the
209
+ researcher is both directly accessible and available to the coordinator.
210
+ Remove its top-level entry to make it private.
211
+
212
+ A parent may configure delegation limits in its \`index.json\`:
213
+
214
+ \`\`\`json
215
+ {
216
+ "subagents": {
217
+ "maxPerRun": 3
218
+ }
219
+ }
220
+ \`\`\`
221
+
222
+ \`maxPerRun\` limits newly created child sessions in one parent run and
223
+ defaults to 10.
224
+
225
+ The parent receives a compact catalog containing each subagent's registered
226
+ name and optional description. Internal \`run_agent\`, \`resume_agent\`,
227
+ \`inspect_agent\` tools let it start, continue, and inspect only child sessions
228
+ initiated by its current session. A delegated agent cannot delegate again.
229
+
230
+ Subagent calls are synchronous. The parent becomes
231
+ \`waiting_for_subagent\` while the child runs, then receives the child's text,
232
+ pause state, client-action request, failure, or completion as a normal tool
233
+ result. The parent and child keep separate linked JSONL sessions.
234
+
235
+ ## Core execution model
236
+
237
+ An **agent** is the compiled definition: model settings, instructions, actions,
238
+ skills, and evaluations. An agent can create many independent sessions.
239
+
240
+ A **session** is one durable conversation owned by one agent. It has one
241
+ \`sessionId\`, optional name and metadata, fixed prompt variables, and one
242
+ append-only JSONL timeline. Completing one response does not close the
243
+ session\u2014the application can resume it later. A session cannot be transferred
244
+ to another registered agent, but later runs may use a different provider or
245
+ model if that same agent's configuration changes.
246
+
247
+ A **run** is one attempt to advance a session. \`run()\` creates a session and
248
+ its first run. A conversational \`resume(sessionId, { content })\` creates the
249
+ next numbered run in that session. Each run accumulates its own model usage and
250
+ ends in exactly one of these states:
251
+
252
+ - \`completed\`: the model produced final output.
253
+ - \`waiting_for_subagent\`: the parent is waiting for a synchronous child
254
+ response and continues automatically when it arrives.
255
+ - \`waiting_for_client_action\`: the model requested work that only the
256
+ application can perform. The run is paused, not completed.
257
+ - \`paused\`: active provider work was aborted, streamed output was preserved,
258
+ and a later \`resume()\` starts a new run.
259
+ - \`failed\`: validation, provider, storage, or execution failed. The durable
260
+ events remain available for diagnosis.
261
+
262
+ An **execution** is the in-process handle returned by one call to \`run()\` or
263
+ \`resume()\`. It exposes a cumulative output stream, latest snapshot, final
264
+ result promise, and evaluation promise. An execution ends when that invocation
265
+ completes, pauses, or fails; the durable session may continue through another
266
+ execution.
267
+
268
+ A **model round** is one provider request inside a run. One run may contain
269
+ several rounds:
270
+
271
+ \`\`\`text
272
+ user input
273
+ \u2192 model round
274
+ \u2192 tool calls
275
+ \u2192 tool results
276
+ \u2192 another model round
277
+ \u2192 final answer
278
+ \`\`\`
279
+
280
+ Local actions and skill loads are handled automatically inside the same
281
+ execution. Their results are sent back to the model and the model loop
282
+ continues without application involvement.
283
+
284
+ A **client action** deliberately crosses the application boundary. Orcha can
285
+ describe the tool to the model but cannot execute it because the operation
286
+ belongs to a browser, mobile app, approval system, or other caller-owned
287
+ environment. The complete pause/continue flow is:
288
+
289
+ \`\`\`text
290
+ 1. Application calls agent.run(...) or agent.resume(...content).
291
+ 2. Model requests one or more client actions.
292
+ 3. Orcha stores client_action.requested and run.paused.
293
+ 4. execution.result resolves with:
294
+ {
295
+ status: "waiting_for_client_action",
296
+ sessionId,
297
+ clientToolCalls: [{ callId, name, arguments }]
298
+ }
299
+ 5. Application executes every requested action.
300
+ 6. Application calls agent.resume(sessionId, {
301
+ toolResults: [{ callId, output, isError? }]
302
+ }).
303
+ 7. Orcha validates every callId and output, stores the results, and continues
304
+ the same paused run from its prior model context.
305
+ 8. The resumed execution either completes, requests more client actions, or
306
+ fails.
307
+ \`\`\`
308
+
309
+ Every pending call must be resolved exactly once in one resume operation.
310
+ \`callId\` links the submitted result to the model's request; the action name
311
+ must not be substituted for it. Re-submitting the identical resolved result is
312
+ idempotent and returns the prior completed result. Submitting different data
313
+ for an already-resolved call fails with \`action_result_conflict\`.
314
+
315
+ \`clientCapabilities\` is supplied per invocation because different callers
316
+ may support different client actions. Orcha exposes only declared client
317
+ actions to that model round. Local actions are always available when compiled.
318
+
319
+ Only one execution may mutate a session at a time. Concurrent calls for the
320
+ same \`sessionId\` return \`session_busy\`; different sessions can run
321
+ independently.
322
+
323
+ ## Running and resuming
324
+
325
+ \`\`\`ts
326
+ const execution = orcha.supportBot.run({
327
+ content: "Check subscription sub_123.",
328
+ name: "Subscription check",
329
+ metadata: { accountId: "acct_123" },
330
+ clientCapabilities: ["request_human_approval"],
331
+ });
332
+
333
+ for await (const snapshot of execution.stream) {
334
+ console.log(snapshot);
335
+ }
336
+
337
+ const result = await execution.result;
338
+ const evaluations = await execution.evaluations;
339
+ \`\`\`
340
+
341
+ \`run()\` input fields:
342
+
343
+ - \`content\` (required): a non-empty string, one content item, or an array.
344
+ Use \`{ filePath: "./document.pdf" }\` for a local file or
345
+ \`{ url: "https://example.com/document.pdf" }\` for a remote file.
346
+ \`mimeType\` is optional when it can be inferred from the extension. Durable
347
+ events store local paths and MIME types, never encoded file bytes.
348
+ - \`name\` (optional): trimmed session label from 1 through 200 characters.
349
+ - \`metadata\` (optional): at most 50 fields with non-empty keys and finite
350
+ string, number, boolean, or null values. Metadata is durable and available
351
+ to local action context; never place secrets in it.
352
+ - \`variables\` (optional): at most 50 string values whose keys are JavaScript
353
+ identifiers. They replace \`{{ variableName }}\` placeholders in
354
+ \`instructions.md\`, are fixed when the session is created, and are reused
355
+ by later resumes. A missing referenced variable fails the run.
356
+ - \`clientCapabilities\` (optional): action names the current caller can
357
+ execute. Client actions not declared here are withheld from the model.
358
+
359
+ \`run()\` always creates a new durable session. Continue one with:
360
+
361
+ \`\`\`ts
362
+ const execution = orcha.supportBot.resume(sessionId, {
363
+ content: "Continue with the confirmed account.",
364
+ });
365
+ \`\`\`
366
+
367
+ If a result has \`status: "waiting_for_client_action"\`, execute the requested
368
+ client actions in the application and submit every result:
369
+
370
+ \`\`\`ts
371
+ orcha.supportBot.resume(sessionId, {
372
+ toolResults: [
373
+ { callId: "call_123", output: { approved: true } }
374
+ ],
375
+ });
376
+ \`\`\`
377
+
378
+ Never invent call IDs. Use the IDs returned in \`clientToolCalls\`.
379
+
380
+ ## Actions
381
+
382
+ Each action has metadata and, for local actions, executable code:
383
+
384
+ \`\`\`text
385
+ actions/
386
+ lookupAccount/
387
+ index.json
388
+ index.js
389
+ \`\`\`
390
+
391
+ \`\`\`json
392
+ {
393
+ "name": "lookup_account",
394
+ "description": "Look up one account.",
395
+ "parameters": {
396
+ "type": "object",
397
+ "properties": {
398
+ "accountId": { "type": "string" }
399
+ },
400
+ "required": ["accountId"],
401
+ "additionalProperties": false
402
+ },
403
+ "outputSchema": {
404
+ "type": "object",
405
+ "properties": {
406
+ "status": { "type": "string" }
407
+ },
408
+ "required": ["status"],
409
+ "additionalProperties": false
410
+ }
411
+ }
412
+ \`\`\`
413
+
414
+ \`\`\`js
415
+ export default async function lookupAccount({ accountId }) {
416
+ return { status: "active" };
417
+ }
418
+ \`\`\`
419
+
420
+ Action entrypoints can use ordinary relative project imports, TypeScript
421
+ modules, npm packages, transitive dependencies, and standard exports. Orcha
422
+ bundles the complete import graph for development and production.
423
+
424
+ Client actions use \`"execution": "client"\` and do not include executable
425
+ code. Orcha pauses until the caller submits their results. Keep action names,
426
+ descriptions, schemas, and implementations aligned.
427
+
428
+ Action \`index.json\` fields:
429
+
430
+ - \`name\` (required): model-facing tool name, 1\u201364 letters, numbers,
431
+ underscores, or hyphens. \`load_skill\` is reserved.
432
+ - \`description\` (required): tells the model when and why to call the action.
433
+ - \`enabled\` (optional): defaults to \`true\`. Set to \`false\` to keep a WIP
434
+ action inactive without deleting its folder.
435
+ - \`execution\` (optional): defaults to \`"local"\`, which executes \`index.js\`.
436
+ Set to \`"client"\` to pause and delegate execution to the application.
437
+ - \`parameters\` (required): JSON Schema for model-generated arguments.
438
+ - \`outputSchema\` (optional): JSON Schema validated against local or submitted
439
+ client output before the model receives it.
440
+ - \`timeoutMs\` (optional): integer from 1 through 120000; defaults to 10000.
441
+ - \`permissions.env\` (optional): names copied from \`orcha.init().actions.env\`
442
+ into the action context.
443
+ - \`permissions.network\` (optional): exact hosts or wildcard subdomains such
444
+ as \`"api.example.com"\` or \`"*.example.com"\` allowed through
445
+ \`context.fetch\`. Redirects are rejected.
446
+ - \`sideEffect\` (optional): descriptive metadata for whether the operation
447
+ mutates external state. It does not currently change execution behavior.
448
+
449
+ \`orcha.init().actions.runtime\` and an action's \`execution\` solve different
450
+ problems:
451
+
452
+ - \`execution: "client"\`: Orcha never executes code for this action.
453
+ - \`execution: "local"\` + \`runtime: "sandbox"\`: compiled code runs in a
454
+ QuickJS isolate with JSON-only inputs/outputs, default 32 MB memory, default
455
+ 512 KB stack, interruptible timeout, declared environment values, and
456
+ allowlisted network access through the provided context.
457
+ - \`execution: "local"\` + \`runtime: "native"\`: code runs in the host Node.js
458
+ process. It can use host privileges directly. The timeout rejects slow
459
+ asynchronous work but cannot interrupt synchronous blocking code.
460
+
461
+ Global local-action configuration:
462
+
463
+ \`\`\`ts
464
+ actions: {
465
+ runtime: "sandbox", // optional; native is the default
466
+ env: {
467
+ BILLING_API_TOKEN: process.env.BILLING_API_TOKEN,
468
+ },
469
+ sandbox: {
470
+ memoryLimitMb: 32,
471
+ stackLimitKb: 512,
472
+ },
473
+ }
474
+ \`\`\`
475
+
476
+ The local action signature is
477
+ \`(parameters, context) => output | Promise<output>\`. Context contains
478
+ \`sessionId\`, immutable session \`metadata\`, a stable \`idempotencyKey\`,
479
+ allowlisted \`env\`, guarded \`fetch\`, and prefixed \`log\`.
480
+
481
+ ## Skills
482
+
483
+ Skills are lazy-loaded procedural instructions. Direct child folders under
484
+ \`skills/\` are discovered automatically. Each folder contains \`index.json\`
485
+ metadata and \`instructions.md\`.
486
+ The model receives a compact catalog and can call the internal \`load_skill\`
487
+ tool. Loaded instructions remain active for the durable session. Lifecycle
488
+ events are \`skill.requested\`, \`skill.loaded\`, and \`skill.failed\`.
489
+
490
+ Skill \`index.json\` fields:
491
+
492
+ - \`name\` (required): model-facing name, 1\u201364 letters, numbers, underscores,
493
+ or hyphens; unique within the agent.
494
+ - \`description\` (required): compact catalog description shown before loading.
495
+ - \`enabled\` (optional): defaults to \`true\`. Set to \`false\` to keep a WIP
496
+ skill inactive.
497
+ - \`triggers\` (optional): non-empty array of non-empty situations describing
498
+ when the model should load the skill.
499
+
500
+ \`instructions.md\` is required and cannot be empty for enabled skills.
501
+ \`index.json.name\` is the name used by the model and durable events.
502
+
503
+ ## Tests
504
+
505
+ Direct child folders under \`tests/\` are discovered automatically. Each
506
+ case's \`index.json\` defines \`input\`, optional mocked action responses, and
507
+ \`expect\`. Tests run the real compiled agent and provider. Actions listed
508
+ under \`actions\` are mocked; unlisted local actions execute live. Orcha reports
509
+ live action use in the terminal, test report, and session trace.
510
+ Client actions must always be mocked because no application client is attached
511
+ to the test runner.
512
+
513
+ \`\`\`json
514
+ {
515
+ "input": { "content": "Check account acct_123." },
516
+ "actions": {
517
+ "lookup_account": {
518
+ "responses": [
519
+ { "output": { "status": "active" } }
520
+ ]
521
+ }
522
+ },
523
+ "expect": {
524
+ "status": "completed",
525
+ "text": { "contains": ["active"] },
526
+ "actions": [
527
+ {
528
+ "name": "lookup_account",
529
+ "arguments": { "equals": { "accountId": "acct_123" } }
530
+ }
531
+ ]
532
+ }
533
+ }
534
+ \`\`\`
535
+
536
+ Test sessions use the \`ses_test_<timestamp>_<uuid>\` format and end with a \`test.completed\`
537
+ event. Prefer semantic output assertions; verify exact identifiers and values
538
+ through action-argument assertions.
539
+
540
+ Test \`index.json\` fields:
541
+
542
+ - \`name\` (optional): friendly display name. The folder name remains the CLI
543
+ selector.
544
+ - \`description\` (optional): human-readable purpose.
545
+ - \`enabled\` (optional): defaults to \`true\`. Set to \`false\` to keep a WIP test
546
+ inactive.
547
+ - \`input\` (required): an inline agent input object or a path to a JSON file
548
+ containing that object. Relative paths resolve from the test case directory.
549
+ - \`input.content\` (required for inline input): string or multimodal content
550
+ array.
551
+ - \`input.variables\` (optional): string map available to the session.
552
+ - \`input.metadata\` (optional): string, number, boolean, or null values.
553
+ - \`actions\` (optional): mocked actions keyed by compiled action name. Unlisted
554
+ local actions execute live and may cause side effects. Unknown action names
555
+ are rejected, and unlisted client actions are rejected. Every \`responses\`
556
+ array is consumed in call order.
557
+ - \`responses[].output\` (required): mocked action result.
558
+ - \`responses[].isError\` (optional): marks the mocked result as an error.
559
+ - \`expect.status\` (optional): \`"completed"\` or \`"failed"\`; defaults to
560
+ \`"completed"\`.
561
+ - \`expect.output.equals\` / \`partial\` (optional): exact or recursive partial
562
+ comparison against structured output.
563
+ - \`expect.text.contains\` / \`excludes\` (optional): case-sensitive semantic
564
+ text checks.
565
+ - \`expect.actions\` (optional): ordered expected calls. Each may assert
566
+ \`arguments.equals\` or \`arguments.partial\`.
567
+
568
+ The test folder name is the selector used by \`orcha test agent/testName\`.
569
+
570
+ ## Evaluations
571
+
572
+ Evaluations are asynchronous LLM judges discovered from direct child folders
573
+ under \`evaluations/\`. Each folder's \`index.json\` defines its provider, model,
574
+ metrics, and thresholds:
575
+
576
+ \`\`\`json
577
+ {
578
+ "name": "response_quality",
579
+ "description": "Grounding of agent responses.",
580
+ "instructions": "Judge the complete response using only confirmed evidence recorded in the session.",
581
+ "enabled": true,
582
+ "provider": "openai",
583
+ "model": "gpt-5-mini",
584
+ "metrics": [
585
+ {
586
+ "name": "groundedness",
587
+ "description": "The answer relies on confirmed session evidence.",
588
+ "threshold": 0.8
589
+ }
590
+ ]
591
+ }
592
+ \`\`\`
593
+
594
+ \`execution.result\` does not wait for judges. Await
595
+ \`execution.evaluations\` when results must finish before process exit.
596
+ Evaluations always finish during \`orcha test\`; judge errors and missed
597
+ thresholds fail the test. Lifecycle events are \`evaluation.requested\`,
598
+ \`evaluation.completed\`, and \`evaluation.failed\`.
599
+
600
+ Evaluation \`index.json\` fields:
601
+
602
+ - \`name\` (required): durable model-facing identifier, 1\u201364 letters, numbers,
603
+ underscores, or hyphens; unique within the agent.
604
+ - \`description\` (optional): short human-facing summary of the evaluator.
605
+ - \`instructions\` (optional): detailed prompt supplied to the judge. When
606
+ omitted, \`description\` is used for backward compatibility.
607
+ - \`enabled\` (optional): defaults to \`true\`. Disabled evaluations are ignored
608
+ by compilation and runtime.
609
+ - \`provider\` and \`model\` (required): independently select the judge. The
610
+ provider must also exist in \`orcha.init().providers\`.
611
+ - \`maxTokens\` (optional): positive integer; defaults to 2000 for judges.
612
+ - \`reasoningLevel\` (optional): non-empty provider-native string forwarded
613
+ without translation.
614
+ - \`metrics\` (required): non-empty array with unique metric names.
615
+ - \`metrics[].name\`: 1\u201364 letters, numbers, underscores, or hyphens.
616
+ - \`metrics[].description\`: exact criterion supplied to the judge.
617
+ - \`metrics[].threshold\`: inclusive number from 0 to 1. A metric passes when
618
+ the returned score is greater than or equal to this threshold.
619
+
620
+ The judge sees a sanitized transcript of user/assistant messages, action
621
+ requests and outcomes, client-action activity, and loaded skill names. It does
622
+ not receive internal reasoning blocks, replay metadata, previous evaluation
623
+ results, or test assertions. It must return exactly one score, reasoning
624
+ string, and non-empty evidence array for every configured metric.
625
+
626
+ ## Sessions and logs
627
+
628
+ The configured session store is the durable source of truth. JSONL stores one
629
+ complete event object per line; SQLite stores one event per row. Events are
630
+ append-only and ordered by \`sequence\`.
631
+
632
+ All events use this envelope:
633
+
634
+ \`\`\`ts
635
+ type SessionEvent<T> = {
636
+ sequence: number; // starts at 1 and increases across the whole session
637
+ type: SessionEventType;
638
+ timestamp: string; // ISO-8601 UTC timestamp
639
+ run?: number; // present for run-scoped events
640
+ data: T;
641
+ };
642
+ \`\`\`
643
+
644
+ Session-scoped events omit \`run\`. Optional properties whose values are
645
+ \`undefined\` are omitted from serialized JSON.
646
+
647
+ Shared stored structures:
648
+
649
+ \`\`\`ts
650
+ type Usage = {
651
+ inputTokens: number;
652
+ outputTokens: number;
653
+ reasoningTokens: number | null;
654
+ cacheReadTokens: number;
655
+ cacheWriteTokens: number;
656
+ };
657
+
658
+ type ErrorData = {
659
+ code: string;
660
+ message: string;
661
+ retryable?: boolean;
662
+ };
663
+
664
+ type UserContent =
665
+ | { type: "text"; text: string }
666
+ | { type: "file"; filePath: string; mimeType: string }
667
+ | {
668
+ type: "image" | "video" | "audio" | "url";
669
+ mimeType: string;
670
+ fileUri: string;
671
+ };
672
+
673
+ type AssistantContent =
674
+ | { type: "text"; text: string }
675
+ | {
676
+ type: "reasoning";
677
+ text: string;
678
+ replay?: { providerId?: string; opaqueData?: string };
679
+ }
680
+ | {
681
+ type: "tool_call";
682
+ callId: string;
683
+ name: string;
684
+ arguments: Record<string, unknown>;
685
+ replay?: { providerId?: string; opaqueData?: string };
686
+ };
687
+
688
+ type ToolResult = {
689
+ callId: string;
690
+ output: unknown;
691
+ isError?: boolean;
692
+ };
693
+ \`\`\`
694
+
695
+ Exact event payloads:
696
+
697
+ \`\`\`ts
698
+ type SessionCreated = SessionEvent<{
699
+ schemaVersion: 1;
700
+ sessionId: string;
701
+ agent: string;
702
+ status: "active";
703
+ name?: string;
704
+ metadata: Record<string, string | number | boolean | null>;
705
+ variables: Record<string, string>;
706
+ lineage?: {
707
+ origin: "delegated";
708
+ parentAgent: string;
709
+ parentSessionId: string;
710
+ parentCallId: string;
711
+ };
712
+ }>; // type "session.created", no run
713
+
714
+ type SessionUpdated = SessionEvent<{
715
+ name?: string;
716
+ metadata?: Record<string, string | number | boolean | null>;
717
+ }>; // type "session.updated", no run
718
+
719
+ type RunStarted = SessionEvent<{
720
+ status: "running";
721
+ agent: string;
722
+ provider: string;
723
+ model: string;
724
+ region: string;
725
+ reasoningLevel?: string;
726
+ outputType: "text" | "json";
727
+ clientCapabilities: string[];
728
+ }>; // type "run.started"
729
+
730
+ type UserMessageCreated = SessionEvent<{
731
+ role: "user";
732
+ content: UserContent[];
733
+ }>; // type "message.created"
734
+
735
+ type AssistantMessageCreated = SessionEvent<{
736
+ status: "completed" | "incomplete";
737
+ provider: string;
738
+ model: string;
739
+ responseId?: string;
740
+ stopReason?: "end_turn" | "tool_call" | "max_tokens" |
741
+ "content_filter" | "unknown";
742
+ role: "assistant";
743
+ content: AssistantContent[];
744
+ parsedOutput?: unknown; // final JSON output only
745
+ usage: Usage;
746
+ durationMs: number;
747
+ }>; // type "message.created"
748
+
749
+ type ToolMessageCreated = SessionEvent<{
750
+ role: "tool";
751
+ content: ToolResult[];
752
+ }>; // type "message.created"
753
+
754
+ type ActionRequested = SessionEvent<{
755
+ callId: string;
756
+ name: string;
757
+ arguments: Record<string, unknown>;
758
+ sourceHash?: string;
759
+ idempotencyKey: string; // sessionId:callId
760
+ }>; // type "action.requested"
761
+
762
+ type ActionCompleted = SessionEvent<{
763
+ callId: string;
764
+ name: string;
765
+ output: unknown;
766
+ sourceHash?: string;
767
+ durationMs: number;
768
+ }>; // type "action.completed"
769
+
770
+ type ActionFailed = SessionEvent<{
771
+ callId: string;
772
+ name: string;
773
+ sourceHash?: string;
774
+ durationMs: number;
775
+ error: {
776
+ code: "action_execution_failed";
777
+ message: string;
778
+ };
779
+ }>; // type "action.failed"
780
+
781
+ type ClientActionRequested = SessionEvent<{
782
+ status: "waiting";
783
+ calls: Array<{
784
+ callId: string;
785
+ name: string;
786
+ arguments: Record<string, unknown>;
787
+ }>;
788
+ localResults: ToolResult[];
789
+ toolCallOrder: string[];
790
+ }>; // type "client_action.requested"
791
+
792
+ type ClientActionResolved = SessionEvent<{
793
+ status: "completed";
794
+ results: ToolResult[];
795
+ }>; // type "client_action.resolved"
796
+
797
+ type SkillRequested = SessionEvent<{
798
+ callId: string;
799
+ name: unknown;
800
+ }>; // type "skill.requested"
801
+
802
+ type SkillLoaded = SessionEvent<{
803
+ callId: string;
804
+ name: string;
805
+ alreadyLoaded: boolean;
806
+ }>; // type "skill.loaded", no run
807
+
808
+ type SkillFailed = SessionEvent<{
809
+ callId: string;
810
+ name: unknown;
811
+ error: {
812
+ code: "skill_not_found";
813
+ message: string;
814
+ };
815
+ }>; // type "skill.failed"
816
+
817
+ type EvaluationRequested = SessionEvent<{
818
+ name: string;
819
+ provider: string;
820
+ model: string;
821
+ evaluatedThroughSequence: number;
822
+ }>; // type "evaluation.requested"
823
+
824
+ type EvaluationMetric = {
825
+ name: string;
826
+ score: number;
827
+ threshold: number;
828
+ passed: boolean;
829
+ reasoning: string;
830
+ evidence: string[];
831
+ };
832
+
833
+ type EvaluationCompleted = SessionEvent<{
834
+ name: string;
835
+ status: "passed" | "failed";
836
+ metrics: EvaluationMetric[];
837
+ usage?: Usage;
838
+ durationMs: number;
839
+ provider: string;
840
+ model: string;
841
+ evaluatedThroughSequence: number;
842
+ }>; // type "evaluation.completed"
843
+
844
+ type EvaluationFailed = SessionEvent<{
845
+ name: string;
846
+ status: "error";
847
+ metrics: [];
848
+ durationMs: number;
849
+ error: { message: string };
850
+ provider: string;
851
+ model: string;
852
+ evaluatedThroughSequence: number;
853
+ }>; // type "evaluation.failed"
854
+
855
+ type SubagentInitiated = SessionEvent<{
856
+ callId: string;
857
+ agent: string;
858
+ sessionId: string;
859
+ status: "running";
860
+ }>; // type "subagent.initiated"
861
+
862
+ type SubagentResumed = SessionEvent<{
863
+ callId: string;
864
+ agent: string;
865
+ sessionId: string;
866
+ status: "running";
867
+ }>; // type "subagent.resumed"
868
+
869
+ type SubagentCompletedOrPausedOrFailed = SessionEvent<{
870
+ callId: string;
871
+ agent: string;
872
+ sessionId: string;
873
+ status:
874
+ | "completed"
875
+ | "waiting_for_client_action"
876
+ | "paused"
877
+ | "failed";
878
+ output?: unknown;
879
+ usage?: Usage;
880
+ clientToolCalls?: Array<{
881
+ callId: string;
882
+ name: string;
883
+ arguments: Record<string, unknown>;
884
+ }>;
885
+ error?: ErrorData;
886
+ }>; // type "subagent.completed" | "subagent.paused" | "subagent.failed"
887
+
888
+ type RunPaused = SessionEvent<{
889
+ status: "waiting_for_client_action" | "paused";
890
+ clientToolCalls?: Array<{
891
+ callId: string;
892
+ name: string;
893
+ arguments: Record<string, unknown>;
894
+ }>;
895
+ usage?: Usage;
896
+ output?: unknown;
897
+ durationMs?: number;
898
+ }>; // type "run.paused"
899
+
900
+ type RunCompleted = SessionEvent<{
901
+ status: "completed";
902
+ durationMs: number;
903
+ usage: Usage;
904
+ }>; // type "run.completed"
905
+
906
+ type RunFailed = SessionEvent<{
907
+ status: "failed";
908
+ durationMs: number;
909
+ usage?: Usage;
910
+ error: ErrorData;
911
+ }>; // type "run.failed"
912
+
913
+ type SessionPaused = SessionEvent<{
914
+ status: "paused";
915
+ }>; // type "session.paused", no run
916
+
917
+ type SessionResumed = SessionEvent<{
918
+ status: "active";
919
+ }>; // type "session.resumed", no run
920
+
921
+ type TestCompleted = SessionEvent<{
922
+ suiteId: string;
923
+ agent: string;
924
+ test: string;
925
+ status: "passed" | "failed";
926
+ durationMs: number;
927
+ assertions: Array<{
928
+ path: string;
929
+ passed: boolean;
930
+ message: string;
931
+ expected?: unknown;
932
+ actual?: unknown;
933
+ }>;
934
+ usage?: Usage;
935
+ evaluations?: Array<{
936
+ name: string;
937
+ status: "passed" | "failed" | "error";
938
+ metrics: EvaluationMetric[];
939
+ usage?: Usage;
940
+ durationMs: number;
941
+ error?: { message: string };
942
+ }>;
943
+ warnings?: Array<{
944
+ code: "live_actions";
945
+ message: string;
946
+ actions: string[];
947
+ }>;
948
+ error?: ErrorData;
949
+ }>; // type "test.completed", no run
950
+
951
+ type TestWarning = SessionEvent<{
952
+ code: "live_actions";
953
+ message: string;
954
+ actions: string[];
955
+ }>; // type "test.warning", no run
956
+ \`\`\`
957
+
958
+ Typical event order:
959
+
960
+ \`\`\`text
961
+ session.created
962
+ run.started
963
+ message.created (user)
964
+ message.created (assistant, possibly with tool_call)
965
+ action.requested \u2192 action.completed|action.failed # local action
966
+ subagent.initiated
967
+ ...child session advances independently...
968
+ subagent.paused
969
+ subagent.resumed
970
+ ...child session advances independently...
971
+ subagent.completed|subagent.paused|subagent.failed
972
+ message.created (tool)
973
+ ...additional model/action rounds...
974
+ message.created (assistant final)
975
+ run.completed
976
+ evaluation.requested
977
+ evaluation.completed|evaluation.failed
978
+ \`\`\`
979
+
980
+ For client actions, \`client_action.requested\` and \`run.paused\` replace the
981
+ immediate tool message. A later \`resume(...toolResults)\` appends
982
+ \`client_action.resolved\`, the tool message, and continues the same run
983
+ number. A conversational \`resume(...content)\` starts a new run number.
984
+
985
+ ## How Orcha works behind the scenes
986
+
987
+ ### Compilation
988
+
989
+ 1. \`orcha/index.ts\` calls \`orcha.init()\` with explicit agent paths.
990
+ 2. The compiler reads each registered agent's \`index.json\` and
991
+ \`instructions.md\`.
992
+ 3. Direct child folders under \`actions/\`, \`skills/\`, \`tests/\`, and
993
+ \`evaluations/\` are discovered automatically. Items with \`"enabled": false\`
994
+ remain inactive.
995
+ 4. Local action source is bundled and SHA-256 hashed. Production bundles keep
996
+ only provider adapters required by agents and enabled evaluations.
997
+ 5. Invalid paths, duplicate model-facing names, missing files, unsupported
998
+ configuration values, and missing schema objects fail before execution.
999
+ Concrete action arguments and outputs are validated against their schemas
1000
+ when the action is used.
1001
+
1002
+ \`orcha dev\` repeats validation when files change. \`orcha build\` performs
1003
+ offline production compilation. Neither command invokes a provider.
1004
+
1005
+ ### Run lifecycle
1006
+
1007
+ 1. \`run()\` creates a \`ses_<timestamp>_<uuid>\`, acquires the per-session execution lock,
1008
+ appends \`session.created\`, then starts run 1.
1009
+ 2. \`resume()\` reads and validates the existing session. Message continuation
1010
+ starts a new run; submitted client results continue the paused run.
1011
+ 3. The provider receives the base instructions, available-skill catalog,
1012
+ loaded skill instructions, normalized conversation messages, action
1013
+ schemas, model settings, and current client capabilities.
1014
+ 4. Provider-specific responses are normalized into text, reasoning, and tool
1015
+ call blocks. Opaque replay metadata is stored only when a provider needs it
1016
+ to replay its own prior block correctly.
1017
+ 5. Tool calls are checked against compiled actions and declared client
1018
+ capabilities. Arguments and outputs are validated against JSON Schema.
1019
+ 6. \`load_skill\` updates durable session instructions. Local actions execute
1020
+ through the configured runtime. Client actions pause safely. Tool results
1021
+ are reordered to match the model's original call order.
1022
+ 7. Internal agent tools start or continue linked child sessions. A
1023
+ \`run_agent\` input accepts the same text or multimodal content shape as a
1024
+ normal run. Local file paths resolve from the configured Orcha project root.
1025
+ The parent reports \`waiting_for_subagent\` until each synchronous child
1026
+ call returns.
1027
+ 8. The model loop continues until final output, failure, a pause, or the
1028
+ maximum of 10 action rounds.
1029
+ 9. Usage is normalized and aggregated across every model call in the run.
1030
+ 10. After \`run.completed\`, enabled evaluations start in the background.
1031
+ \`execution.result\` is already available; \`execution.evaluations\` waits
1032
+ for judge completion and durable persistence.
1033
+
1034
+ The per-session lock prevents two model executions from mutating one session
1035
+ at once. Background evaluation writes queue behind active runs so they cannot
1036
+ cause \`resume()\` to fail spuriously or reuse sequence numbers.
1037
+
1038
+ ### Replay and context
1039
+
1040
+ Orcha does not send raw stored events back to the model. It projects them
1041
+ into provider-neutral conversation messages. Completed and explicitly paused
1042
+ conversational runs become user, assistant, and tool messages, so a new run
1043
+ sees incomplete assistant text preserved by \`pause()\`. Lifecycle bookkeeping
1044
+ such as durations, test assertions, and evaluation events is excluded from
1045
+ model context. Reasoning text and provider replay metadata are retained where
1046
+ needed for faithful continuation but are omitted from evaluation transcripts.
1047
+
1048
+ ### Reading sessions
1049
+
1050
+ - \`agent.get(sessionId)\` projects the latest status, pending client actions,
1051
+ last output, metadata, and aggregate usage.
1052
+ - \`agent.history(sessionId, { page, pageSize })\` returns a safe user-facing
1053
+ timeline rather than raw provider bookkeeping.
1054
+ - \`agent.events(sessionId, { page, pageSize })\` returns the canonical durable
1055
+ event records for observability, audit, and debugging tools. For subsequent
1056
+ pages of a changing session, pass the first response's \`throughSequence\`
1057
+ back in the options to keep pagination on a stable event boundary.
1058
+ - \`agent.list({ page, pageSize, status, metadata })\` lists projected session
1059
+ snapshots.
1060
+ - \`agent.subagentHistory(childSessionId, { page, pageSize })\` returns the
1061
+ projected history of a child owned by this parent agent. Lineage checks
1062
+ prevent access through unrelated agents.
1063
+ - \`agent.subagentEvents(childSessionId, { page, pageSize })\` returns that
1064
+ owned child's canonical events for full transcript and debugging interfaces.
1065
+ - \`agent.pause(sessionId)\` aborts active provider work for the session and
1066
+ active children, preserving streamed text as an incomplete assistant
1067
+ message. \`agent.resume(sessionId)\` starts a new run with \`"Continue."\`;
1068
+ pass content to give different instructions. Pending client actions still
1069
+ require their exact tool results.
1070
+ - Never read storage files directly. Use these methods so applications remain
1071
+ compatible with JSONL, SQLite, IndexedDB, remote, and future storage adapters.
1072
+
1073
+ ## Change rules
1074
+
1075
+ - Register every new agent and subagent explicitly. Agent-owned actions, skills,
1076
+ tests, and evaluations are auto-discovered; use \`"enabled": false\` for WIP.
1077
+ - Keep runtime behavior provider-neutral.
1078
+ - Mock actions when tests must avoid side effects; document intentional live
1079
+ action coverage.
1080
+ - Do not commit \`.orcha/\`; it contains generated output and session data.
1081
+ - Run \`orcha dev\` after filesystem changes and \`orcha test\` when behavior
1082
+ changes.
1083
+ - Do not weaken assertions to match incorrect behavior. Remove an assertion
1084
+ only when it is stricter than the documented agent contract.
1085
+ `;
1086
+ // Annotate the CommonJS export names for ESM import in node:
1087
+ 0 && (module.exports = {
1088
+ AGENTS_MD
1089
+ });
1090
+ //# sourceMappingURL=cli-agents-template.js.map