orchajs 0.24.0 → 0.26.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 (78) hide show
  1. package/README.md +50 -3
  2. package/dist/amarsia/analytics.js +12 -0
  3. package/dist/amarsia/inference.d.ts +6 -0
  4. package/dist/amarsia/inference.js +377 -0
  5. package/dist/browser.js +5 -0
  6. package/dist/cli-agents-template.d.ts +1 -1
  7. package/dist/cli-agents-template.js +44 -11
  8. package/dist/cli.js +22 -9
  9. package/dist/compiler/build-project.js +57 -14
  10. package/dist/compiler/node-esm-banner.d.ts +2 -0
  11. package/dist/compiler/node-esm-banner.js +5 -0
  12. package/dist/orcha.js +5 -0
  13. package/dist/playground/server.js +3 -0
  14. package/dist/project-loader.js +4 -2
  15. package/dist/providers/anthropic.js +67 -58
  16. package/dist/providers/bedrock.js +14 -8
  17. package/dist/providers/deepseek.js +9 -2
  18. package/dist/providers/google-gemini.js +20 -15
  19. package/dist/providers/openai.js +6 -0
  20. package/dist/providers/types.d.ts +5 -0
  21. package/dist/react-native.js +5 -0
  22. package/dist/runtime/agent.d.ts +3 -3
  23. package/dist/runtime/agent.js +278 -45
  24. package/dist/runtime/compiler-hook.d.ts +4 -0
  25. package/dist/runtime/compiler-hook.js +9 -0
  26. package/dist/runtime/create-orcha.d.ts +19 -0
  27. package/dist/runtime/create-orcha.js +109 -12
  28. package/dist/runtime/optional-features.d.ts +19 -0
  29. package/dist/runtime/optional-features.js +22 -0
  30. package/dist/runtime/platform-browser.js +16 -3
  31. package/dist/runtime/platform-node.js +16 -2
  32. package/dist/runtime/platform-react-native.js +16 -3
  33. package/dist/runtime/session-events.js +19 -0
  34. package/dist/storage/browser-indexeddb.d.ts +3 -0
  35. package/dist/storage/browser-indexeddb.js +72 -8
  36. package/dist/storage/cloud-outbox.d.ts +30 -0
  37. package/dist/storage/cloud-outbox.js +628 -0
  38. package/dist/storage/cloud.d.ts +1 -0
  39. package/dist/storage/cloud.js +1 -0
  40. package/dist/storage/node-jsonl.d.ts +3 -0
  41. package/dist/storage/node-jsonl.js +273 -4
  42. package/dist/storage/node-sqlite.d.ts +3 -0
  43. package/dist/storage/node-sqlite.js +66 -17
  44. package/dist/storage/react-native-jsonl.d.ts +3 -0
  45. package/dist/storage/react-native-jsonl.js +223 -0
  46. package/dist/testing.js +3 -0
  47. package/dist/types.d.ts +25 -4
  48. package/dist-cjs/amarsia/analytics.js +12 -0
  49. package/dist-cjs/amarsia/inference.js +372 -0
  50. package/dist-cjs/browser.js +5 -0
  51. package/dist-cjs/cli-agents-template.js +44 -11
  52. package/dist-cjs/compiler/build-project.js +68 -4
  53. package/dist-cjs/compiler/node-esm-banner.js +32 -0
  54. package/dist-cjs/orcha.js +5 -0
  55. package/dist-cjs/playground/server.js +1 -0
  56. package/dist-cjs/project-loader.js +7 -5
  57. package/dist-cjs/providers/anthropic.js +65 -60
  58. package/dist-cjs/providers/bedrock.js +17 -9
  59. package/dist-cjs/providers/deepseek.js +10 -2
  60. package/dist-cjs/providers/google-gemini.js +27 -20
  61. package/dist-cjs/providers/openai.js +8 -0
  62. package/dist-cjs/react-native.js +5 -0
  63. package/dist-cjs/runtime/agent.js +311 -61
  64. package/dist-cjs/runtime/compiler-hook.js +11 -0
  65. package/dist-cjs/runtime/create-orcha.js +117 -12
  66. package/dist-cjs/runtime/optional-features.js +58 -0
  67. package/dist-cjs/runtime/platform-browser.js +16 -3
  68. package/dist-cjs/runtime/platform-node.js +16 -2
  69. package/dist-cjs/runtime/platform-react-native.js +18 -3
  70. package/dist-cjs/runtime/session-events.js +14 -0
  71. package/dist-cjs/storage/browser-indexeddb.js +73 -8
  72. package/dist-cjs/storage/cloud-outbox.js +646 -0
  73. package/dist-cjs/storage/cloud.js +29 -0
  74. package/dist-cjs/storage/node-jsonl.js +246 -3
  75. package/dist-cjs/storage/node-sqlite.js +70 -19
  76. package/dist-cjs/storage/react-native-jsonl.js +207 -0
  77. package/dist-cjs/testing.js +1 -0
  78. package/package.json +1 -1
package/README.md CHANGED
@@ -319,15 +319,41 @@ npm install quickjs-emscripten-core @jitl/quickjs-singlefile-cjs-release-sync
319
319
 
320
320
  ---
321
321
 
322
+ ## Amarsia inference
323
+
324
+ Set `amarsia.inference: true` to route every model round through Amarsia:
325
+
326
+ ```js
327
+ orcha.init({
328
+ amarsia: {
329
+ key: process.env.AMARSIA_PROJECT_KEY,
330
+ inference: true,
331
+ // endpoint: "https://api.amarsia.com",
332
+ },
333
+ agents: {
334
+ coordinator: "./coordinator",
335
+ },
336
+ });
337
+ ```
338
+
339
+ The provider and model remain in each agent or evaluation `index.json`.
340
+ Amarsia inference supports `openai`, `anthropic`, `googlegenai`, and
341
+ `deepseek`. Infrastructure-specific `bedrock` and `vertexai` providers remain
342
+ available only for direct inference. Inference uses
343
+ `POST /v3/model/v1/responses`, requires no local provider keys, and covers
344
+ normal runs, streaming, tool loops, MCP, subagents, tests, evaluations, replay,
345
+ structured output, and abort signals. Amarsia uses the workspace owner's
346
+ configured BYOK provider key first and falls back to managed credit billing.
347
+ When `inference` is absent or false, direct-provider behavior is unchanged.
348
+
349
+ ---
350
+
322
351
  ## MCP connections
323
352
 
324
353
  Assign named MCP connections directly to agents and subagents:
325
354
 
326
355
  ```js
327
356
  orcha.init({
328
- providers: {
329
- anthropic: process.env.ANTHROPIC_API_KEY,
330
- },
331
357
  mcp: {
332
358
  credentials: {
333
359
  GITHUB_MCP_TOKEN: process.env.GITHUB_MCP_TOKEN,
@@ -454,6 +480,27 @@ JSONL by default at
454
480
  shared `.orcha/sessions/orcha-sqlite.db` store, set
455
481
  `storage: { strategy: "sqlite" }` in `orcha.init()` and install
456
482
  `better-sqlite3`.
483
+ Use `storage: { strategy: "cloud" }` with `amarsia.key` for local-first cloud
484
+ storage. Node.js keeps JSONL locally, browsers use IndexedDB, and React
485
+ Native/Expo use AsyncStorage. Existing `list`, `get`, `history`, `events`, and
486
+ `resume` calls remain unchanged. Every append commits locally first and returns
487
+ without waiting for cloud latency. Delivery continues in bounded background
488
+ batches and is recovered from the durable local acknowledgement after restart.
489
+ Warm local reads return immediately and safely refresh an already-synchronized
490
+ tail in the background; unsent local tails are never overwritten. Permanent
491
+ delivery failures are parked to avoid retry loops and are retried by a new
492
+ append or an explicit `orcha.flushCloudStorage()`.
493
+
494
+ `flushCloudStorage({ timeoutMs })` resolves only when every outbox is empty and
495
+ throws if data remains pending. `orcha.close({ timeoutMs })` flushes, aborts and
496
+ joins in-flight cloud requests, and likewise throws on an incomplete flush.
497
+ Close establishes a storage lifecycle barrier: appends already writing locally
498
+ are included in the final outbox scan, while later appends are rejected.
499
+ Local events remain durable in either case. JSONL-backed cloud stores maintain
500
+ recoverable tail indexes so bounded delivery batches do not repeatedly parse
501
+ the full session history. Immutable-prefix conflicts preserve both sides and
502
+ surface as `storage_error`. Call and await `orcha.close()` before calling
503
+ synchronous `orcha.init()` again; overlapping initialized runtimes are rejected.
457
504
  Client-action pause/resume, compiled local actions, and cumulative output
458
505
  streaming are supported.
459
506
  `run()` always starts a new session; `resume()` continues one with either a new
@@ -195,8 +195,20 @@ export function withAmarsiaTelemetry(options) {
195
195
  const projections = new Map();
196
196
  const pending = new Map();
197
197
  return {
198
+ get cloudStoragePendingCount() {
199
+ return store.cloudStoragePendingCount;
200
+ },
201
+ get cloudStorageLastError() {
202
+ return store.cloudStorageLastError;
203
+ },
198
204
  read: (sessionId) => store.read(sessionId),
205
+ readAfterSequence: store.readAfterSequence?.bind(store),
199
206
  listSessionIds: () => store.listSessionIds(),
207
+ getCloudAcknowledgement: store.getCloudAcknowledgement?.bind(store),
208
+ setCloudAcknowledgement: store.setCloudAcknowledgement?.bind(store),
209
+ refreshCloudSession: store.refreshCloudSession?.bind(store),
210
+ flushCloudStorage: store.flushCloudStorage?.bind(store),
211
+ closeCloudStorage: store.closeCloudStorage?.bind(store),
200
212
  describeLocation: store.describeLocation?.bind(store),
201
213
  subscribe: store.subscribe?.bind(store),
202
214
  subscribeAll: store.subscribeAll?.bind(store),
@@ -0,0 +1,6 @@
1
+ import type { ProviderResponseGenerator } from "../providers/types.js";
2
+ export interface AmarsiaInferenceConfiguration {
3
+ key: string;
4
+ endpoint?: string;
5
+ }
6
+ export declare function createAmarsiaInferenceGenerator(configuration: AmarsiaInferenceConfiguration): ProviderResponseGenerator;
@@ -0,0 +1,377 @@
1
+ import { OrchaError } from "../errors.js";
2
+ import { readLocalFileContent } from "../file-content.js";
3
+ import { readServerSentEvents } from "../providers/sse.js";
4
+ import { parseStructuredOutput } from "../runtime/structured-output.js";
5
+ import { resolveAmarsiaEndpoint } from "./endpoint.js";
6
+ const SUPPORTED_AMARSIA_PROVIDERS = new Set([
7
+ "openai",
8
+ "anthropic",
9
+ "googlegenai",
10
+ "vertexai",
11
+ "deepseek",
12
+ ]);
13
+ const TEXT_ONLY_AMARSIA_PROVIDERS = new Set(["deepseek"]);
14
+ export function createAmarsiaInferenceGenerator(configuration) {
15
+ const endpoint = resolveAmarsiaEndpoint(configuration.endpoint);
16
+ return (provider, _providerConfiguration, request) => generateThroughAmarsia(endpoint, configuration.key, provider, request);
17
+ }
18
+ async function generateThroughAmarsia(endpoint, key, provider, request) {
19
+ if (!key.trim()) {
20
+ throw new Error("Amarsia inference requires a non-empty amarsia.key.");
21
+ }
22
+ if (!SUPPORTED_AMARSIA_PROVIDERS.has(provider)) {
23
+ throw new OrchaError("unsupported_provider_capability", `Amarsia inference supports only OpenAI, Anthropic, Google GenAI, Vertex AI, and DeepSeek; received "${provider}".`);
24
+ }
25
+ if (request.outputType === "image" || request.outputType === "audio") {
26
+ throw new OrchaError("unsupported_provider_capability", `Amarsia Responses does not support "${request.outputType}" as a direct agent output.`);
27
+ }
28
+ assertProviderSupportsMessageContent(provider, request.messages);
29
+ const gatewayProvider = provider === "vertexai" ? "googlegenai" : provider;
30
+ const body = {
31
+ provider: gatewayProvider,
32
+ model: request.model,
33
+ instructions: request.systemPrompt,
34
+ input: await toResponsesInput(request.messages),
35
+ ...(provider === "vertexai"
36
+ ? { region: "global" }
37
+ : request.region && request.region !== "provider_managed"
38
+ ? { region: request.region }
39
+ : {}),
40
+ ...(request.maxTokens
41
+ ? { max_output_tokens: request.maxTokens }
42
+ : {}),
43
+ ...(request.publishOutput ? { stream: true } : {}),
44
+ };
45
+ if (request.tools.length > 0) {
46
+ body.tools = request.tools.map((tool) => ({
47
+ type: "function",
48
+ name: tool.name,
49
+ description: tool.description,
50
+ parameters: tool.parameters,
51
+ }));
52
+ }
53
+ if (request.outputType === "json") {
54
+ body.text = {
55
+ format: {
56
+ type: "json_schema",
57
+ name: "orcha_output",
58
+ schema: request.outputSchema ?? {},
59
+ strict: true,
60
+ },
61
+ };
62
+ }
63
+ body.reasoning = {
64
+ summary: "auto",
65
+ ...(request.reasoningLevel ? { effort: request.reasoningLevel } : {}),
66
+ };
67
+ body.include = ["reasoning.encrypted_content"];
68
+ if (request.trace) {
69
+ body.metadata = {
70
+ agent_external_id: request.trace.agentExternalId,
71
+ session_id: request.trace.sessionId,
72
+ };
73
+ }
74
+ const response = await fetch(`${endpoint}/v3/model/v1/responses`, {
75
+ method: "POST",
76
+ headers: {
77
+ "content-type": "application/json",
78
+ authorization: `Bearer ${key}`,
79
+ },
80
+ body: JSON.stringify(body),
81
+ signal: request.signal,
82
+ });
83
+ if (!response.ok) {
84
+ const message = await responseError(response);
85
+ throw gatewayRequestError(message, response.status);
86
+ }
87
+ const responseBody = response.headers
88
+ .get("content-type")
89
+ ?.includes("text/event-stream")
90
+ ? await readGatewayStream(response, request.publishOutput)
91
+ : (await response.json());
92
+ return toProviderResponse(request, responseBody);
93
+ }
94
+ function assertProviderSupportsMessageContent(provider, messages) {
95
+ if (!TEXT_ONLY_AMARSIA_PROVIDERS.has(provider)) {
96
+ return;
97
+ }
98
+ for (const message of messages) {
99
+ if (message.role === "user" && Array.isArray(message.content)) {
100
+ for (const block of message.content) {
101
+ if (block.type !== "text") {
102
+ throw deepSeekMultimodalError(block.type);
103
+ }
104
+ }
105
+ }
106
+ if (message.role === "tool") {
107
+ for (const result of message.results) {
108
+ for (const block of result.contents ?? []) {
109
+ if (block.type !== "text") {
110
+ throw deepSeekMultimodalError(block.type);
111
+ }
112
+ }
113
+ }
114
+ }
115
+ }
116
+ }
117
+ function deepSeekMultimodalError(contentType) {
118
+ return new OrchaError("unsupported_content_type", `DeepSeek does not support multimodal content (received "${contentType}"). DeepSeek is text-only and cannot accept images, PDFs, or other file attachments.`);
119
+ }
120
+ function gatewayRequestError(message, statusCode) {
121
+ const detail = message?.trim() ||
122
+ `Amarsia inference request failed with HTTP ${statusCode}.`;
123
+ if (/does not support multimodal|text-only/i.test(detail)) {
124
+ return new OrchaError("unsupported_content_type", detail);
125
+ }
126
+ return new Error(detail);
127
+ }
128
+ async function toResponsesInput(messages) {
129
+ const input = [];
130
+ for (const message of messages) {
131
+ if (message.role === "user") {
132
+ input.push({
133
+ role: "user",
134
+ content: typeof message.content === "string"
135
+ ? message.content
136
+ : await Promise.all(message.content.map(toResponsesUserContent)),
137
+ });
138
+ continue;
139
+ }
140
+ if (message.role === "tool") {
141
+ for (const result of message.results) {
142
+ const contents = result.contents?.length
143
+ ? await Promise.all(result.contents.map(toResponsesUserContent))
144
+ : undefined;
145
+ input.push({
146
+ type: "function_call_output",
147
+ call_id: result.callId,
148
+ output: JSON.stringify(result.output ?? null),
149
+ ...(contents ? { contents } : {}),
150
+ ...(result.isError ? { is_error: true } : {}),
151
+ });
152
+ }
153
+ continue;
154
+ }
155
+ for (const block of message.content) {
156
+ if (block.type === "text") {
157
+ input.push({
158
+ role: "assistant",
159
+ content: [{ type: "output_text", text: block.text }],
160
+ });
161
+ }
162
+ else if (block.type === "tool_call") {
163
+ input.push({
164
+ type: "function_call",
165
+ call_id: block.callId,
166
+ name: block.name,
167
+ arguments: JSON.stringify(block.arguments),
168
+ ...(block.replay?.providerId
169
+ ? { id: block.replay.providerId }
170
+ : {}),
171
+ ...(block.replay?.opaqueData
172
+ ? { encrypted_content: block.replay.opaqueData }
173
+ : {}),
174
+ });
175
+ }
176
+ else {
177
+ input.push({
178
+ type: "reasoning",
179
+ ...(block.replay?.providerId
180
+ ? { id: block.replay.providerId }
181
+ : {}),
182
+ summary: block.text
183
+ ? [{ type: "summary_text", text: block.text }]
184
+ : [],
185
+ ...(block.replay?.opaqueData
186
+ ? { encrypted_content: block.replay.opaqueData }
187
+ : {}),
188
+ });
189
+ }
190
+ }
191
+ }
192
+ return input;
193
+ }
194
+ async function toResponsesUserContent(content) {
195
+ if (content.type === "text") {
196
+ return { type: "input_text", text: content.text };
197
+ }
198
+ if (content.type === "file") {
199
+ const file = await readLocalFileContent(content);
200
+ return content.mimeType.startsWith("image/")
201
+ ? {
202
+ type: "input_image",
203
+ image_url: file.dataUri,
204
+ detail: "auto",
205
+ }
206
+ : {
207
+ type: "input_file",
208
+ file_data: file.dataUri,
209
+ filename: file.fileName,
210
+ };
211
+ }
212
+ if (content.type === "image") {
213
+ return {
214
+ type: "input_image",
215
+ image_url: content.fileUri,
216
+ detail: "auto",
217
+ };
218
+ }
219
+ if (content.type === "url") {
220
+ return { type: "input_file", file_url: content.fileUri };
221
+ }
222
+ throw new OrchaError("unsupported_content_type", `Amarsia Responses does not support ${content.type} content from a URI.`);
223
+ }
224
+ async function readGatewayStream(response, publishOutput) {
225
+ let text = "";
226
+ let terminal;
227
+ for await (const event of readServerSentEvents(response)) {
228
+ if (event.type === "response.output_text.delta" &&
229
+ typeof event.delta === "string") {
230
+ text += event.delta;
231
+ publishOutput?.(text);
232
+ }
233
+ else if (event.type === "response.completed" ||
234
+ event.type === "response.incomplete") {
235
+ if (!isRecord(event.response)) {
236
+ throw new Error("Amarsia returned an invalid terminal stream event.");
237
+ }
238
+ terminal = event.response;
239
+ }
240
+ else if (event.type === "response.failed" ||
241
+ event.type === "error") {
242
+ const error = isRecord(event.error) ? event.error : event;
243
+ const message = typeof error.message === "string"
244
+ ? error.message
245
+ : "Amarsia inference streaming request failed.";
246
+ throw gatewayRequestError(message, 500);
247
+ }
248
+ }
249
+ if (!terminal) {
250
+ throw new Error("Amarsia inference stream ended without a terminal response.");
251
+ }
252
+ return terminal;
253
+ }
254
+ function toProviderResponse(request, response) {
255
+ if (response.status === "failed") {
256
+ throw new Error(response.error?.message ?? "Amarsia failed to generate a response.");
257
+ }
258
+ if (response.status === "incomplete" &&
259
+ response.incomplete_details?.reason !== "max_output_tokens") {
260
+ throw new Error(`Amarsia returned an incomplete response: ${response.incomplete_details?.reason ?? "unknown reason"}.`);
261
+ }
262
+ const content = [];
263
+ let refused = false;
264
+ for (const item of response.output ?? []) {
265
+ if (item.type === "message") {
266
+ for (const part of item.content ?? []) {
267
+ if (part.type === "output_text" &&
268
+ typeof part.text === "string") {
269
+ content.push({ type: "text", text: part.text });
270
+ }
271
+ else if (part.type === "refusal" &&
272
+ typeof part.refusal === "string") {
273
+ refused = true;
274
+ content.push({ type: "text", text: part.refusal });
275
+ }
276
+ }
277
+ }
278
+ else if (item.type === "function_call" &&
279
+ typeof item.call_id === "string" &&
280
+ typeof item.name === "string") {
281
+ content.push({
282
+ type: "tool_call",
283
+ callId: item.call_id,
284
+ name: item.name,
285
+ arguments: parseArguments(item.arguments, item.name),
286
+ replay: replay(item),
287
+ });
288
+ }
289
+ else if (item.type === "reasoning") {
290
+ content.push({
291
+ type: "reasoning",
292
+ text: [...(item.content ?? []), ...(item.summary ?? [])]
293
+ .filter((part) => (part.type === "reasoning_text" ||
294
+ part.type === "summary_text") &&
295
+ typeof part.text === "string")
296
+ .map((part) => part.text)
297
+ .join(""),
298
+ replay: replay(item),
299
+ });
300
+ }
301
+ else {
302
+ throw new Error(`Amarsia returned unsupported output item "${String(item.type)}".`);
303
+ }
304
+ }
305
+ const toolCalls = content.filter((block) => block.type === "tool_call");
306
+ const textOutput = response.output_text ??
307
+ content
308
+ .filter((block) => block.type === "text")
309
+ .map((block) => block.text)
310
+ .join("");
311
+ const stopReason = normalizeStopReason(response, toolCalls, refused);
312
+ const output = request.outputType === "json" &&
313
+ toolCalls.length === 0 &&
314
+ stopReason !== "max_tokens"
315
+ ? parseStructuredOutput(textOutput, request.outputSchema ?? {})
316
+ : textOutput;
317
+ if (textOutput) {
318
+ request.publishOutput?.(textOutput);
319
+ }
320
+ return {
321
+ output,
322
+ responseId: response.id,
323
+ stopReason,
324
+ content,
325
+ toolCalls,
326
+ usage: normalizeUsage(response.usage),
327
+ };
328
+ }
329
+ function replay(item) {
330
+ const value = {
331
+ ...(typeof item.id === "string" ? { providerId: item.id } : {}),
332
+ ...(typeof item.encrypted_content === "string"
333
+ ? { opaqueData: item.encrypted_content }
334
+ : {}),
335
+ };
336
+ return Object.keys(value).length > 0 ? value : undefined;
337
+ }
338
+ function parseArguments(value, name) {
339
+ const parsed = typeof value === "string" ? JSON.parse(value) : value;
340
+ if (!isRecord(parsed)) {
341
+ throw new Error(`Amarsia returned non-object arguments for tool "${name}".`);
342
+ }
343
+ return parsed;
344
+ }
345
+ function normalizeStopReason(response, toolCalls, refused) {
346
+ if (refused)
347
+ return "content_filter";
348
+ if (toolCalls.length > 0)
349
+ return "tool_call";
350
+ if (response.status === "incomplete") {
351
+ return response.incomplete_details?.reason === "max_output_tokens"
352
+ ? "max_tokens"
353
+ : "unknown";
354
+ }
355
+ return response.status === "completed" ? "end_turn" : "unknown";
356
+ }
357
+ function normalizeUsage(usage) {
358
+ return {
359
+ inputTokens: usage?.input_tokens ?? 0,
360
+ outputTokens: usage?.output_tokens ?? 0,
361
+ reasoningTokens: usage?.output_tokens_details?.reasoning_tokens ?? null,
362
+ cacheReadTokens: usage?.input_tokens_details?.cached_tokens ?? 0,
363
+ cacheWriteTokens: usage?.cache_write_tokens ?? 0,
364
+ };
365
+ }
366
+ async function responseError(response) {
367
+ try {
368
+ const body = (await response.json());
369
+ return body.error?.message ?? body.message ?? (typeof body.detail === "string" ? body.detail : undefined);
370
+ }
371
+ catch {
372
+ return undefined;
373
+ }
374
+ }
375
+ function isRecord(value) {
376
+ return typeof value === "object" && value !== null && !Array.isArray(value);
377
+ }
package/dist/browser.js CHANGED
@@ -1,11 +1,16 @@
1
+ import { createAmarsiaInferenceGenerator } from "./amarsia/inference.js";
1
2
  import { generateBrowserProviderResponse } from "./providers/browser.js";
2
3
  import { setNativeRuntimeLoader } from "./runtime/actions/execute.js";
3
4
  import { createOrcha } from "./runtime/create-orcha.js";
5
+ import { setCloudSessionStoreFactory, setInferenceGeneratorFactory, } from "./runtime/optional-features.js";
4
6
  import { browserRuntimePlatform } from "./runtime/platform-browser.js";
7
+ import { CloudSessionStore } from "./storage/cloud.js";
5
8
  setNativeRuntimeLoader(async () => {
6
9
  const modulePath = "./runtime/actions/browser-native.js";
7
10
  return import(modulePath);
8
11
  });
12
+ setInferenceGeneratorFactory(createAmarsiaInferenceGenerator);
13
+ setCloudSessionStoreFactory((options) => new CloudSessionStore(options));
9
14
  export const orcha = createOrcha(() => {
10
15
  throw new Error("The browser runtime requires a precompiled Orcha bundle. Configure the Orcha integration for your application bundler.");
11
16
  }, generateBrowserProviderResponse, browserRuntimePlatform);