@theokit/sdk 1.9.0 → 2.0.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 (74) hide show
  1. package/CHANGELOG.md +32 -1
  2. package/dist/a2a/index.cjs +154 -148
  3. package/dist/a2a/index.cjs.map +1 -1
  4. package/dist/a2a/index.js +154 -148
  5. package/dist/a2a/index.js.map +1 -1
  6. package/dist/{cron-Ci_NUkUj.d.ts → cron-Bj8-Aq1O.d.ts} +1 -1
  7. package/dist/{cron-Bse1MbaE.d.cts → cron-DFG9-W17.d.cts} +1 -1
  8. package/dist/cron.cjs +135 -128
  9. package/dist/cron.cjs.map +1 -1
  10. package/dist/cron.d.cts +1 -1
  11. package/dist/cron.d.ts +1 -1
  12. package/dist/cron.js +138 -131
  13. package/dist/cron.js.map +1 -1
  14. package/dist/eval.cjs +134 -124
  15. package/dist/eval.cjs.map +1 -1
  16. package/dist/eval.d.cts +1 -0
  17. package/dist/eval.d.ts +1 -0
  18. package/dist/eval.js +137 -127
  19. package/dist/eval.js.map +1 -1
  20. package/dist/index.cjs +113 -106
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +2 -2
  23. package/dist/index.d.ts +2 -2
  24. package/dist/index.js +113 -106
  25. package/dist/index.js.map +1 -1
  26. package/dist/internal/runtime/{fork-agent.d.ts → lifecycle/fork-agent.d.ts} +1 -1
  27. package/dist/internal/runtime/{run-until.d.ts → lifecycle/run-until.d.ts} +3 -3
  28. package/dist/internal/runtime/local-agent/local-agent-bootstrap.d.ts +1 -1
  29. package/dist/internal/runtime/registry/agent-factory-registry.d.ts +12 -9
  30. package/dist/internal/scorers/llm-judge.d.ts +4 -4
  31. package/dist/internal/security/index.d.cts +1 -1
  32. package/dist/internal/security/index.d.ts +1 -1
  33. package/dist/types/fork.d.ts +1 -1
  34. package/dist/workflow.cjs +2 -2
  35. package/dist/workflow.cjs.map +1 -1
  36. package/dist/workflow.js +2 -2
  37. package/dist/workflow.js.map +1 -1
  38. package/package.json +6 -12
  39. package/dist/rag/index.cjs +0 -136
  40. package/dist/rag/index.cjs.map +0 -1
  41. package/dist/rag/index.d.cts +0 -11
  42. package/dist/rag/index.d.ts +0 -11
  43. package/dist/rag/index.js +0 -129
  44. package/dist/rag/index.js.map +0 -1
  45. package/dist/rag/reranker.d.cts +0 -26
  46. package/dist/rag/reranker.d.ts +0 -26
  47. package/dist/rag/retriever.d.cts +0 -25
  48. package/dist/rag/retriever.d.ts +0 -25
  49. package/dist/rag/text-splitter.d.cts +0 -12
  50. package/dist/rag/text-splitter.d.ts +0 -12
  51. package/dist/rag/types.d.cts +0 -37
  52. package/dist/rag/types.d.ts +0 -37
  53. package/dist/voice/index.d.ts +0 -7
  54. package/dist/voice/openai-realtime.d.ts +0 -21
  55. package/dist/voice/types.d.ts +0 -35
  56. /package/dist/internal/{errors/mappers → error-mappers}/anthropic.d.ts +0 -0
  57. /package/dist/internal/{errors/mappers → error-mappers}/bedrock.d.ts +0 -0
  58. /package/dist/internal/{errors/mappers → error-mappers}/ollama.d.ts +0 -0
  59. /package/dist/internal/{errors/mappers → error-mappers}/openai-compatible.d.ts +0 -0
  60. /package/dist/internal/{errors/mappers → error-mappers}/shared.d.ts +0 -0
  61. /package/dist/internal/{errors/mappers → error-mappers}/vertex.d.ts +0 -0
  62. /package/dist/internal/runtime/{abort-utils.d.ts → concurrency/abort-utils.d.ts} +0 -0
  63. /package/dist/internal/runtime/{async-local-storage.d.ts → concurrency/async-local-storage.d.ts} +0 -0
  64. /package/dist/internal/runtime/{async-semaphore.d.ts → concurrency/async-semaphore.d.ts} +0 -0
  65. /package/dist/internal/runtime/{default-model.d.ts → config/default-model.d.ts} +0 -0
  66. /package/dist/internal/runtime/{providers-manager.d.ts → config/providers-manager.d.ts} +0 -0
  67. /package/dist/internal/runtime/{workspace-dir.d.ts → config/workspace-dir.d.ts} +0 -0
  68. /package/dist/internal/runtime/{yaml-frontmatter.d.ts → context/yaml-frontmatter.d.ts} +0 -0
  69. /package/dist/internal/runtime/{post-run-lifecycle.d.ts → lifecycle/post-run-lifecycle.d.ts} +0 -0
  70. /package/dist/internal/runtime/{spawn-collect.d.ts → lifecycle/spawn-collect.d.ts} +0 -0
  71. /package/dist/internal/runtime/{system-prompt.d.ts → system-prompt/system-prompt.d.ts} +0 -0
  72. /package/dist/internal/runtime/{shell-tool.d.ts → tools/shell-tool.d.ts} +0 -0
  73. /package/dist/internal/runtime/{validate-agent-options.d.ts → validation/validate-agent-options.d.ts} +0 -0
  74. /package/dist/internal/runtime/{validate-response.d.ts → validation/validate-response.d.ts} +0 -0
package/dist/a2a/index.js CHANGED
@@ -1040,10 +1040,10 @@ var init_path_guard = __esm({
1040
1040
  }
1041
1041
  });
1042
1042
 
1043
- // src/internal/runtime/default-model.ts
1043
+ // src/internal/runtime/config/default-model.ts
1044
1044
  var DEFAULT_AGENTIC_MODEL_ID;
1045
1045
  var init_default_model = __esm({
1046
- "src/internal/runtime/default-model.ts"() {
1046
+ "src/internal/runtime/config/default-model.ts"() {
1047
1047
  DEFAULT_AGENTIC_MODEL_ID = "google/gemini-2.0-flash-001";
1048
1048
  }
1049
1049
  });
@@ -1439,7 +1439,7 @@ var init_agent_registry = __esm({
1439
1439
  }
1440
1440
  });
1441
1441
 
1442
- // src/internal/runtime/system-prompt.ts
1442
+ // src/internal/runtime/system-prompt/system-prompt.ts
1443
1443
  async function resolveSystemPrompt(agent, override, ctx) {
1444
1444
  if (override !== void 0) return override;
1445
1445
  if (agent === void 0) return void 0;
@@ -1457,7 +1457,7 @@ async function resolveSystemPromptForSend(agent, override, buildCtx) {
1457
1457
  return resolveSystemPrompt(agent, override, ctx);
1458
1458
  }
1459
1459
  var init_system_prompt = __esm({
1460
- "src/internal/runtime/system-prompt.ts"() {
1460
+ "src/internal/runtime/system-prompt/system-prompt.ts"() {
1461
1461
  }
1462
1462
  });
1463
1463
 
@@ -3111,7 +3111,7 @@ var init_paths = __esm({
3111
3111
  }
3112
3112
  });
3113
3113
 
3114
- // src/internal/runtime/yaml-frontmatter.ts
3114
+ // src/internal/runtime/context/yaml-frontmatter.ts
3115
3115
  function parseSimpleYaml(text) {
3116
3116
  const fields = {};
3117
3117
  for (const line of text.split(/\r?\n/)) {
@@ -3135,7 +3135,7 @@ function coerce(raw) {
3135
3135
  return raw;
3136
3136
  }
3137
3137
  var init_yaml_frontmatter = __esm({
3138
- "src/internal/runtime/yaml-frontmatter.ts"() {
3138
+ "src/internal/runtime/context/yaml-frontmatter.ts"() {
3139
3139
  }
3140
3140
  });
3141
3141
  async function loadMarkdownEntities(opts) {
@@ -4139,7 +4139,7 @@ function spawnAndCollect(options) {
4139
4139
  });
4140
4140
  }
4141
4141
  var init_spawn_collect = __esm({
4142
- "src/internal/runtime/spawn-collect.ts"() {
4142
+ "src/internal/runtime/lifecycle/spawn-collect.ts"() {
4143
4143
  }
4144
4144
  });
4145
4145
 
@@ -4236,33 +4236,6 @@ var init_hooks_executor = __esm({
4236
4236
  };
4237
4237
  }
4238
4238
  });
4239
-
4240
- // src/internal/runtime/memory/memory-path-selector.ts
4241
- function shouldUsePortMemoryPath() {
4242
- const env = globalThis.process?.env;
4243
- if (env === void 0) return false;
4244
- const val = env[PORT_MEMORY_PATH_ENV_VAR];
4245
- return val === "1" || val === "true";
4246
- }
4247
- function resolveMemoryProviderForLoop(consumerSupplied, defaultAdapter, portPathEnabled) {
4248
- if (consumerSupplied !== void 0) return consumerSupplied;
4249
- if (portPathEnabled) return defaultAdapter;
4250
- return void 0;
4251
- }
4252
- function resolveMemoryToolsForLoop(legacyTools, portPathEnabled) {
4253
- if (portPathEnabled) return void 0;
4254
- return legacyTools;
4255
- }
4256
- function resolveActiveMemorySummaryForSend(legacySummary, portPathEnabled) {
4257
- if (portPathEnabled) return void 0;
4258
- return legacySummary;
4259
- }
4260
- var PORT_MEMORY_PATH_ENV_VAR;
4261
- var init_memory_path_selector = __esm({
4262
- "src/internal/runtime/memory/memory-path-selector.ts"() {
4263
- PORT_MEMORY_PATH_ENV_VAR = "THEOKIT_PORT_MEMORY_PATH";
4264
- }
4265
- });
4266
4239
  function sessionsDir(cwd) {
4267
4240
  return join(memoryDir(cwd), "sessions");
4268
4241
  }
@@ -4311,6 +4284,33 @@ var init_session_summary_writer = __esm({
4311
4284
  MAX_TURN_CHARS = 2e3;
4312
4285
  }
4313
4286
  });
4287
+
4288
+ // src/internal/runtime/memory/memory-path-selector.ts
4289
+ function shouldUsePortMemoryPath() {
4290
+ const env = globalThis.process?.env;
4291
+ if (env === void 0) return false;
4292
+ const val = env[PORT_MEMORY_PATH_ENV_VAR];
4293
+ return val === "1" || val === "true";
4294
+ }
4295
+ function resolveMemoryProviderForLoop(consumerSupplied, defaultAdapter, portPathEnabled) {
4296
+ if (consumerSupplied !== void 0) return consumerSupplied;
4297
+ if (portPathEnabled) return defaultAdapter;
4298
+ return void 0;
4299
+ }
4300
+ function resolveMemoryToolsForLoop(legacyTools, portPathEnabled) {
4301
+ if (portPathEnabled) return void 0;
4302
+ return legacyTools;
4303
+ }
4304
+ function resolveActiveMemorySummaryForSend(legacySummary, portPathEnabled) {
4305
+ if (portPathEnabled) return void 0;
4306
+ return legacySummary;
4307
+ }
4308
+ var PORT_MEMORY_PATH_ENV_VAR;
4309
+ var init_memory_path_selector = __esm({
4310
+ "src/internal/runtime/memory/memory-path-selector.ts"() {
4311
+ PORT_MEMORY_PATH_ENV_VAR = "THEOKIT_PORT_MEMORY_PATH";
4312
+ }
4313
+ });
4314
4314
  function sessionFilePath(cwd, agentId) {
4315
4315
  const safe2 = sanitizeIdentifier(agentId, { maxLen: 128 });
4316
4316
  return safePathJoin(cwd, ".theokit", "agents", safe2, "messages.jsonl");
@@ -4584,7 +4584,7 @@ var init_agent_session = __esm({
4584
4584
  }
4585
4585
  });
4586
4586
 
4587
- // src/internal/runtime/post-run-lifecycle.ts
4587
+ // src/internal/runtime/lifecycle/post-run-lifecycle.ts
4588
4588
  async function runPostRunLifecycle(inputs) {
4589
4589
  const {
4590
4590
  run,
@@ -4645,7 +4645,7 @@ async function runPostRunLifecycle(inputs) {
4645
4645
  await flushSessionWrites();
4646
4646
  }
4647
4647
  var init_post_run_lifecycle = __esm({
4648
- "src/internal/runtime/post-run-lifecycle.ts"() {
4648
+ "src/internal/runtime/lifecycle/post-run-lifecycle.ts"() {
4649
4649
  init_session_summary_writer();
4650
4650
  init_memory_path_selector();
4651
4651
  init_agent_session();
@@ -4837,7 +4837,7 @@ async function readWorkspaceDir(root, errorCode, describe) {
4837
4837
  }
4838
4838
  }
4839
4839
  var init_workspace_dir = __esm({
4840
- "src/internal/runtime/workspace-dir.ts"() {
4840
+ "src/internal/runtime/config/workspace-dir.ts"() {
4841
4841
  init_errors();
4842
4842
  }
4843
4843
  });
@@ -5168,7 +5168,7 @@ var init_pipeline = __esm({
5168
5168
  }
5169
5169
  });
5170
5170
 
5171
- // src/internal/runtime/validate-agent-options.ts
5171
+ // src/internal/runtime/validation/validate-agent-options.ts
5172
5172
  function validateAgentOptions(options) {
5173
5173
  rejectProgrammaticHooks(options);
5174
5174
  ensureRuntimeShape(options);
@@ -5361,12 +5361,82 @@ function validateMemory(options) {
5361
5361
  }
5362
5362
  var TOOL_NAME_PATTERN, RESERVED_TOOL_NAMES;
5363
5363
  var init_validate_agent_options = __esm({
5364
- "src/internal/runtime/validate-agent-options.ts"() {
5364
+ "src/internal/runtime/validation/validate-agent-options.ts"() {
5365
5365
  init_errors();
5366
5366
  TOOL_NAME_PATTERN = /^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/;
5367
5367
  RESERVED_TOOL_NAMES = /* @__PURE__ */ new Set(["shell", "memory_search", "memory_get"]);
5368
5368
  }
5369
5369
  });
5370
+
5371
+ // src/internal/runtime/config/providers-manager.ts
5372
+ function providerFromModel(model) {
5373
+ if (model === void 0) return void 0;
5374
+ const id = model.id;
5375
+ if (id.includes(":")) return id.split(":")[0];
5376
+ return void 0;
5377
+ }
5378
+ function resolveRoute(route, modelProvider, plugins) {
5379
+ if (route.capability === "chat" && modelProvider === route.provider) {
5380
+ const modelName = extractModelName(modelProvider, route);
5381
+ const base = {
5382
+ capability: route.capability,
5383
+ provider: route.provider,
5384
+ reason: "explicit-model-provider"
5385
+ };
5386
+ if (modelName !== void 0) base.model = modelName;
5387
+ return base;
5388
+ }
5389
+ if (plugins?.enabled !== void 0 && plugins.enabled.length > 0) {
5390
+ return {
5391
+ capability: route.capability,
5392
+ provider: route.provider,
5393
+ reason: "first-available-plugin-provider"
5394
+ };
5395
+ }
5396
+ return {
5397
+ capability: route.capability,
5398
+ provider: route.provider,
5399
+ reason: "explicit-route"
5400
+ };
5401
+ }
5402
+ function extractModelName(prefix, route) {
5403
+ if (route.model !== void 0) return route.model;
5404
+ return prefix === route.provider ? defaultModelForProvider(prefix) : void 0;
5405
+ }
5406
+ function defaultModelForProvider(provider) {
5407
+ if (provider === "anthropic") return "claude-3-7-sonnet";
5408
+ return void 0;
5409
+ }
5410
+ var ProvidersManagerImpl;
5411
+ var init_providers_manager = __esm({
5412
+ "src/internal/runtime/config/providers-manager.ts"() {
5413
+ ProvidersManagerImpl = class {
5414
+ constructor(model, providers, plugins) {
5415
+ this.model = model;
5416
+ this.providers = providers;
5417
+ this.plugins = plugins;
5418
+ }
5419
+ model;
5420
+ providers;
5421
+ plugins;
5422
+ routes() {
5423
+ const resolved = [];
5424
+ const modelProvider = providerFromModel(this.model);
5425
+ const seen = /* @__PURE__ */ new Set();
5426
+ if (this.providers?.routes !== void 0) {
5427
+ for (const route of this.providers.routes) {
5428
+ const resolvedRoute = resolveRoute(route, modelProvider, this.plugins);
5429
+ if (!seen.has(route.capability)) {
5430
+ seen.add(route.capability);
5431
+ resolved.push(resolvedRoute);
5432
+ }
5433
+ }
5434
+ }
5435
+ return Promise.resolve(resolved);
5436
+ }
5437
+ };
5438
+ }
5439
+ });
5370
5440
  function truncateWithMarker(content, max) {
5371
5441
  if (content.length <= max) {
5372
5442
  return { truncated: false, finalContent: content };
@@ -6132,8 +6202,8 @@ var init_plugins_manager = __esm({
6132
6202
  init_errors();
6133
6203
  init_markdown_config_loader();
6134
6204
  init_path_guard();
6135
- init_hooks_source();
6136
6205
  init_workspace_dir();
6206
+ init_hooks_source();
6137
6207
  init_plugin_frontmatter();
6138
6208
  PluginsManager = class {
6139
6209
  constructor(cwd, enabled, settingSourcesIncludePlugins, cloud, localPaths) {
@@ -6216,76 +6286,6 @@ var init_plugins_manager = __esm({
6216
6286
  }
6217
6287
  });
6218
6288
 
6219
- // src/internal/runtime/providers-manager.ts
6220
- function providerFromModel(model) {
6221
- if (model === void 0) return void 0;
6222
- const id = model.id;
6223
- if (id.includes(":")) return id.split(":")[0];
6224
- return void 0;
6225
- }
6226
- function resolveRoute(route, modelProvider, plugins) {
6227
- if (route.capability === "chat" && modelProvider === route.provider) {
6228
- const modelName = extractModelName(modelProvider, route);
6229
- const base = {
6230
- capability: route.capability,
6231
- provider: route.provider,
6232
- reason: "explicit-model-provider"
6233
- };
6234
- if (modelName !== void 0) base.model = modelName;
6235
- return base;
6236
- }
6237
- if (plugins?.enabled !== void 0 && plugins.enabled.length > 0) {
6238
- return {
6239
- capability: route.capability,
6240
- provider: route.provider,
6241
- reason: "first-available-plugin-provider"
6242
- };
6243
- }
6244
- return {
6245
- capability: route.capability,
6246
- provider: route.provider,
6247
- reason: "explicit-route"
6248
- };
6249
- }
6250
- function extractModelName(prefix, route) {
6251
- if (route.model !== void 0) return route.model;
6252
- return prefix === route.provider ? defaultModelForProvider(prefix) : void 0;
6253
- }
6254
- function defaultModelForProvider(provider) {
6255
- if (provider === "anthropic") return "claude-3-7-sonnet";
6256
- return void 0;
6257
- }
6258
- var ProvidersManagerImpl;
6259
- var init_providers_manager = __esm({
6260
- "src/internal/runtime/providers-manager.ts"() {
6261
- ProvidersManagerImpl = class {
6262
- constructor(model, providers, plugins) {
6263
- this.model = model;
6264
- this.providers = providers;
6265
- this.plugins = plugins;
6266
- }
6267
- model;
6268
- providers;
6269
- plugins;
6270
- routes() {
6271
- const resolved = [];
6272
- const modelProvider = providerFromModel(this.model);
6273
- const seen = /* @__PURE__ */ new Set();
6274
- if (this.providers?.routes !== void 0) {
6275
- for (const route of this.providers.routes) {
6276
- const resolvedRoute = resolveRoute(route, modelProvider, this.plugins);
6277
- if (!seen.has(route.capability)) {
6278
- seen.add(route.capability);
6279
- resolved.push(resolvedRoute);
6280
- }
6281
- }
6282
- }
6283
- return Promise.resolve(resolved);
6284
- }
6285
- };
6286
- }
6287
- });
6288
-
6289
6289
  // src/internal/runtime/skills/skill-frontmatter.ts
6290
6290
  function asString(v) {
6291
6291
  return typeof v === "string" ? v : void 0;
@@ -6492,9 +6492,9 @@ function bootstrapSubmanagers(args) {
6492
6492
  }
6493
6493
  var init_local_agent_bootstrap = __esm({
6494
6494
  "src/internal/runtime/local-agent/local-agent-bootstrap.ts"() {
6495
+ init_providers_manager();
6495
6496
  init_context_manager();
6496
6497
  init_plugins_manager();
6497
- init_providers_manager();
6498
6498
  init_agent_registry();
6499
6499
  init_skills_manager();
6500
6500
  }
@@ -6668,7 +6668,7 @@ var init_budget = __esm({
6668
6668
  }
6669
6669
  });
6670
6670
 
6671
- // src/internal/runtime/validate-response.ts
6671
+ // src/internal/runtime/validation/validate-response.ts
6672
6672
  function validateResponse(response) {
6673
6673
  const trimmed = response.content.trim();
6674
6674
  const toolCallsArr = Array.isArray(response.toolCalls) ? response.toolCalls : [];
@@ -6681,7 +6681,7 @@ function validateResponse(response) {
6681
6681
  return { ok: true };
6682
6682
  }
6683
6683
  var init_validate_response = __esm({
6684
- "src/internal/runtime/validate-response.ts"() {
6684
+ "src/internal/runtime/validation/validate-response.ts"() {
6685
6685
  }
6686
6686
  });
6687
6687
 
@@ -7104,7 +7104,7 @@ function checkToolWhitelist(toolName) {
7104
7104
  }
7105
7105
  var toolWhitelistStore;
7106
7106
  var init_async_local_storage = __esm({
7107
- "src/internal/runtime/async-local-storage.ts"() {
7107
+ "src/internal/runtime/concurrency/async-local-storage.ts"() {
7108
7108
  toolWhitelistStore = new AsyncLocalStorage();
7109
7109
  }
7110
7110
  });
@@ -7187,7 +7187,7 @@ var init_repair_middleware = __esm({
7187
7187
  }
7188
7188
  });
7189
7189
 
7190
- // src/internal/runtime/shell-tool.ts
7190
+ // src/internal/runtime/tools/shell-tool.ts
7191
7191
  async function runShell(options) {
7192
7192
  if (options.sandbox === true && isObviouslyUnsafe(options.command)) {
7193
7193
  return {
@@ -7218,7 +7218,7 @@ function isObviouslyUnsafe(command) {
7218
7218
  return false;
7219
7219
  }
7220
7220
  var init_shell_tool = __esm({
7221
- "src/internal/runtime/shell-tool.ts"() {
7221
+ "src/internal/runtime/tools/shell-tool.ts"() {
7222
7222
  init_spawn_collect();
7223
7223
  }
7224
7224
  });
@@ -8535,7 +8535,7 @@ var init_providers = __esm({
8535
8535
  }
8536
8536
  });
8537
8537
 
8538
- // src/internal/errors/mappers/shared.ts
8538
+ // src/internal/error-mappers/shared.ts
8539
8539
  function parseRetryAfter(headers) {
8540
8540
  if (headers === void 0) return void 0;
8541
8541
  const raw = headers.get("retry-after");
@@ -8564,13 +8564,13 @@ function buildErrorMetadata(args) {
8564
8564
  }
8565
8565
  var RAW_MAX_BYTES;
8566
8566
  var init_shared = __esm({
8567
- "src/internal/errors/mappers/shared.ts"() {
8567
+ "src/internal/error-mappers/shared.ts"() {
8568
8568
  init_security();
8569
8569
  RAW_MAX_BYTES = 2048;
8570
8570
  }
8571
8571
  });
8572
8572
 
8573
- // src/internal/errors/mappers/anthropic.ts
8573
+ // src/internal/error-mappers/anthropic.ts
8574
8574
  function mapAnthropicError(args) {
8575
8575
  const { status, body, headers, endpoint } = args;
8576
8576
  const code = mapAnthropicStatusToCode(status, body);
@@ -8624,7 +8624,7 @@ function formatMessage(status, code) {
8624
8624
  return `Anthropic API error: ${code} (HTTP ${status})`;
8625
8625
  }
8626
8626
  var init_anthropic2 = __esm({
8627
- "src/internal/errors/mappers/anthropic.ts"() {
8627
+ "src/internal/error-mappers/anthropic.ts"() {
8628
8628
  init_errors();
8629
8629
  init_shared();
8630
8630
  }
@@ -8931,7 +8931,7 @@ var init_anthropic3 = __esm({
8931
8931
  }
8932
8932
  });
8933
8933
 
8934
- // src/internal/errors/mappers/bedrock.ts
8934
+ // src/internal/error-mappers/bedrock.ts
8935
8935
  function classifyBedrockError(args, awsType, message) {
8936
8936
  if (args.status === 429 || awsType.includes("Throttling") || awsType.includes("TooManyRequests")) {
8937
8937
  return "rate_limit";
@@ -8991,7 +8991,7 @@ function parseBody(body) {
8991
8991
  return {};
8992
8992
  }
8993
8993
  var init_bedrock2 = __esm({
8994
- "src/internal/errors/mappers/bedrock.ts"() {
8994
+ "src/internal/error-mappers/bedrock.ts"() {
8995
8995
  init_errors();
8996
8996
  init_shared();
8997
8997
  }
@@ -9378,7 +9378,7 @@ var init_credential_pool_context = __esm({
9378
9378
  }
9379
9379
  });
9380
9380
 
9381
- // src/internal/errors/mappers/openai-compatible.ts
9381
+ // src/internal/error-mappers/openai-compatible.ts
9382
9382
  function mapOpenAICompatibleError(args) {
9383
9383
  const { providerId, status, body, headers, endpoint } = args;
9384
9384
  const code = mapOpenAiStatusToCode(status, body);
@@ -9441,7 +9441,7 @@ function formatMessage2(providerId, status, code) {
9441
9441
  return `${providerId} API error: ${code} (HTTP ${status})`;
9442
9442
  }
9443
9443
  var init_openai_compatible = __esm({
9444
- "src/internal/errors/mappers/openai-compatible.ts"() {
9444
+ "src/internal/error-mappers/openai-compatible.ts"() {
9445
9445
  init_errors();
9446
9446
  init_shared();
9447
9447
  }
@@ -9553,7 +9553,7 @@ var init_fault_injection = __esm({
9553
9553
  }
9554
9554
  });
9555
9555
 
9556
- // src/internal/errors/mappers/ollama.ts
9556
+ // src/internal/error-mappers/ollama.ts
9557
9557
  function mapOllamaTransportError(args) {
9558
9558
  if (args.providerId !== "ollama") return void 0;
9559
9559
  const causeCode = extractCauseCode(args.cause);
@@ -9626,7 +9626,7 @@ function extractModelName2(errString) {
9626
9626
  return match?.[1];
9627
9627
  }
9628
9628
  var init_ollama2 = __esm({
9629
- "src/internal/errors/mappers/ollama.ts"() {
9629
+ "src/internal/error-mappers/ollama.ts"() {
9630
9630
  init_errors();
9631
9631
  init_shared();
9632
9632
  }
@@ -10227,7 +10227,7 @@ var init_pool_aware_client = __esm({
10227
10227
  }
10228
10228
  });
10229
10229
 
10230
- // src/internal/errors/mappers/vertex.ts
10230
+ // src/internal/error-mappers/vertex.ts
10231
10231
  function classifyVertexError(args, errStatus) {
10232
10232
  for (const rule of VERTEX_RULES) {
10233
10233
  if (rule.test(args.status, errStatus)) return rule.code;
@@ -10264,7 +10264,7 @@ function parseBody2(body) {
10264
10264
  }
10265
10265
  var VERTEX_RULES, VERTEX_ERROR_BUILDERS;
10266
10266
  var init_vertex2 = __esm({
10267
- "src/internal/errors/mappers/vertex.ts"() {
10267
+ "src/internal/error-mappers/vertex.ts"() {
10268
10268
  init_errors();
10269
10269
  init_shared();
10270
10270
  VERTEX_RULES = [
@@ -13833,7 +13833,7 @@ var init_local_agent_plugins = __esm({
13833
13833
  }
13834
13834
  });
13835
13835
 
13836
- // src/internal/runtime/run-until.ts
13836
+ // src/internal/runtime/lifecycle/run-until.ts
13837
13837
  var run_until_exports = {};
13838
13838
  __export(run_until_exports, {
13839
13839
  composeContinuation: () => composeContinuation,
@@ -13926,7 +13926,7 @@ Your last response was:
13926
13926
  ${lastResponse.slice(0, 1e3)}`;
13927
13927
  }
13928
13928
  var init_run_until = __esm({
13929
- "src/internal/runtime/run-until.ts"() {
13929
+ "src/internal/runtime/lifecycle/run-until.ts"() {
13930
13930
  }
13931
13931
  });
13932
13932
 
@@ -14037,16 +14037,16 @@ var init_judge_call = __esm({
14037
14037
  // src/internal/runtime/registry/agent-factory-registry.ts
14038
14038
  var agent_factory_registry_exports = {};
14039
14039
  __export(agent_factory_registry_exports, {
14040
- getAgentCreate: () => getAgentCreate,
14041
- setAgentCreate: () => setAgentCreate
14040
+ getAgentFacade: () => getAgentFacade,
14041
+ setAgentFacade: () => setAgentFacade
14042
14042
  });
14043
- function setAgentCreate(fn) {
14044
- registered3 = fn;
14043
+ function setAgentFacade(facade) {
14044
+ registered3 = facade;
14045
14045
  }
14046
- function getAgentCreate() {
14046
+ function getAgentFacade() {
14047
14047
  if (registered3 === void 0) {
14048
14048
  throw new Error(
14049
- "internal: Agent.create not registered. The `agent.ts` module must be loaded before LocalAgent.runUntil/fork are invoked."
14049
+ "internal: Agent facade not registered. The `agent.ts` module must be loaded before internal subsystems (LocalAgent.runUntil/fork, eval, scorers, cron) invoke it."
14050
14050
  );
14051
14051
  }
14052
14052
  return registered3;
@@ -14057,7 +14057,7 @@ var init_agent_factory_registry = __esm({
14057
14057
  }
14058
14058
  });
14059
14059
 
14060
- // src/internal/runtime/fork-agent.ts
14060
+ // src/internal/runtime/lifecycle/fork-agent.ts
14061
14061
  var fork_agent_exports = {};
14062
14062
  __export(fork_agent_exports, {
14063
14063
  filterMemoryPlugins: () => filterMemoryPlugins,
@@ -14117,7 +14117,7 @@ function extractUsage(result) {
14117
14117
  };
14118
14118
  }
14119
14119
  var init_fork_agent = __esm({
14120
- "src/internal/runtime/fork-agent.ts"() {
14120
+ "src/internal/runtime/lifecycle/fork-agent.ts"() {
14121
14121
  init_async_local_storage();
14122
14122
  init_local_agent_plugins();
14123
14123
  }
@@ -14128,8 +14128,8 @@ function localAgentRunUntil(agent, goal, options) {
14128
14128
  async function* wrap() {
14129
14129
  const { runUntilImpl: runUntilImpl2 } = await Promise.resolve().then(() => (init_run_until(), run_until_exports));
14130
14130
  const { judgeCallImpl: judgeCallImpl2 } = await Promise.resolve().then(() => (init_judge_call(), judge_call_exports));
14131
- const { getAgentCreate: getAgentCreate2 } = await Promise.resolve().then(() => (init_agent_factory_registry(), agent_factory_registry_exports));
14132
- const create = getAgentCreate2();
14131
+ const { getAgentFacade: getAgentFacade2 } = await Promise.resolve().then(() => (init_agent_factory_registry(), agent_factory_registry_exports));
14132
+ const create = getAgentFacade2().create;
14133
14133
  const deps = {
14134
14134
  judge: async (ctx, opts) => judgeCallImpl2(ctx, opts, { create })
14135
14135
  };
@@ -14139,9 +14139,9 @@ function localAgentRunUntil(agent, goal, options) {
14139
14139
  }
14140
14140
  async function localAgentFork(parent, options) {
14141
14141
  const { forkAgentImpl: forkAgentImpl2 } = await Promise.resolve().then(() => (init_fork_agent(), fork_agent_exports));
14142
- const { getAgentCreate: getAgentCreate2 } = await Promise.resolve().then(() => (init_agent_factory_registry(), agent_factory_registry_exports));
14142
+ const { getAgentFacade: getAgentFacade2 } = await Promise.resolve().then(() => (init_agent_factory_registry(), agent_factory_registry_exports));
14143
14143
  const { withPersonalityContext: withPersonalityContext2 } = await Promise.resolve().then(() => (init_context2(), context_exports));
14144
- const create = getAgentCreate2();
14144
+ const create = getAgentFacade2().create;
14145
14145
  return withPersonalityContext2(
14146
14146
  { slug: parent.personalitySlugSnapshot, isFork: true },
14147
14147
  () => forkAgentImpl2(parent, options, { create })
@@ -14165,7 +14165,7 @@ var init_local_agent_runtime_extensions = __esm({
14165
14165
  }
14166
14166
  });
14167
14167
 
14168
- // src/internal/runtime/abort-utils.ts
14168
+ // src/internal/runtime/concurrency/abort-utils.ts
14169
14169
  function anySignal(signals) {
14170
14170
  const filtered = signals.filter((s) => s !== void 0);
14171
14171
  if (filtered.length === 0) {
@@ -14191,7 +14191,7 @@ function ponyfillAny(signals) {
14191
14191
  return ctrl.signal;
14192
14192
  }
14193
14193
  var init_abort_utils = __esm({
14194
- "src/internal/runtime/abort-utils.ts"() {
14194
+ "src/internal/runtime/concurrency/abort-utils.ts"() {
14195
14195
  }
14196
14196
  });
14197
14197
 
@@ -14344,7 +14344,7 @@ var init_task = __esm({
14344
14344
  }
14345
14345
  });
14346
14346
 
14347
- // src/internal/runtime/async-semaphore.ts
14347
+ // src/internal/runtime/concurrency/async-semaphore.ts
14348
14348
  function createSemaphore(permits) {
14349
14349
  if (!Number.isInteger(permits) || permits < 1) {
14350
14350
  throw new ConfigurationError(
@@ -14382,7 +14382,7 @@ function createSemaphore(permits) {
14382
14382
  };
14383
14383
  }
14384
14384
  var init_async_semaphore = __esm({
14385
- "src/internal/runtime/async-semaphore.ts"() {
14385
+ "src/internal/runtime/concurrency/async-semaphore.ts"() {
14386
14386
  init_errors();
14387
14387
  }
14388
14388
  });
@@ -14949,8 +14949,8 @@ var init_local_agent = __esm({
14949
14949
  init_span_names();
14950
14950
  init_tracer();
14951
14951
  init_hooks_executor();
14952
- init_memory_path_selector();
14953
14952
  init_post_run_lifecycle();
14953
+ init_memory_path_selector();
14954
14954
  init_agent_registry();
14955
14955
  init_live_agent_registry();
14956
14956
  init_agent_session();
@@ -16419,7 +16419,13 @@ var init_agent = __esm({
16419
16419
  await flushRegistrySaves();
16420
16420
  }
16421
16421
  };
16422
- setAgentCreate((options) => Agent.create(options));
16422
+ setAgentFacade({
16423
+ create: (options) => Agent.create(options),
16424
+ prompt: (message, options) => Agent.prompt(message, options),
16425
+ get: (agentId) => Agent.get(agentId),
16426
+ resume: (agentId, options) => Agent.resume(agentId, options),
16427
+ batch: (prompts, options) => Agent.batch(prompts, options)
16428
+ });
16423
16429
  }
16424
16430
  });
16425
16431