@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/cron.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- export { I as Cron } from './cron-Bse1MbaE.cjs';
2
1
  import './run-DrwUpFxZ.cjs';
2
+ export { I as Cron } from './cron-DFG9-W17.cjs';
package/dist/cron.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { I as Cron } from './cron-Ci_NUkUj.js';
2
1
  import './run-DrwUpFxZ.js';
2
+ export { I as Cron } from './cron-Bj8-Aq1O.js';
package/dist/cron.js CHANGED
@@ -1,8 +1,8 @@
1
- import { randomUUID, createHash, randomBytes } from 'crypto';
2
- import { stat, readFile, rename, mkdir, rm, readdir, open, unlink, appendFile, statfs, access } from 'fs/promises';
1
+ import { randomUUID, randomBytes, createHash } from 'crypto';
2
+ import { readFile, unlink, mkdir, open, rename, statfs, stat, rm, readdir, appendFile, access } from 'fs/promises';
3
3
  import { join, dirname, resolve, sep, relative, isAbsolute } from 'path';
4
4
  import { z, toJSONSchema } from 'zod';
5
- import { existsSync, realpathSync, lstatSync, readlinkSync, mkdirSync, readFileSync, readdirSync } from 'fs';
5
+ import { mkdirSync, readdirSync, existsSync, realpathSync, lstatSync, readlinkSync, readFileSync } from 'fs';
6
6
  import { AsyncLocalStorage } from 'async_hooks';
7
7
  import { createRequire } from 'module';
8
8
  import { homedir } from 'os';
@@ -583,7 +583,7 @@ var init_atomic_write = __esm({
583
583
  }
584
584
  });
585
585
 
586
- // src/internal/runtime/yaml-frontmatter.ts
586
+ // src/internal/runtime/context/yaml-frontmatter.ts
587
587
  function parseSimpleYaml(text) {
588
588
  const fields = {};
589
589
  for (const line of text.split(/\r?\n/)) {
@@ -607,7 +607,7 @@ function coerce(raw) {
607
607
  return raw;
608
608
  }
609
609
  var init_yaml_frontmatter = __esm({
610
- "src/internal/runtime/yaml-frontmatter.ts"() {
610
+ "src/internal/runtime/context/yaml-frontmatter.ts"() {
611
611
  }
612
612
  });
613
613
  async function loadMarkdownEntities(opts) {
@@ -810,7 +810,7 @@ function checkToolWhitelist(toolName) {
810
810
  }
811
811
  var toolWhitelistStore;
812
812
  var init_async_local_storage = __esm({
813
- "src/internal/runtime/async-local-storage.ts"() {
813
+ "src/internal/runtime/concurrency/async-local-storage.ts"() {
814
814
  toolWhitelistStore = new AsyncLocalStorage();
815
815
  }
816
816
  });
@@ -1159,7 +1159,7 @@ var init_local_agent_plugins = __esm({
1159
1159
  }
1160
1160
  });
1161
1161
 
1162
- // src/internal/runtime/run-until.ts
1162
+ // src/internal/runtime/lifecycle/run-until.ts
1163
1163
  var run_until_exports = {};
1164
1164
  __export(run_until_exports, {
1165
1165
  composeContinuation: () => composeContinuation,
@@ -1252,7 +1252,7 @@ Your last response was:
1252
1252
  ${lastResponse.slice(0, 1e3)}`;
1253
1253
  }
1254
1254
  var init_run_until = __esm({
1255
- "src/internal/runtime/run-until.ts"() {
1255
+ "src/internal/runtime/lifecycle/run-until.ts"() {
1256
1256
  }
1257
1257
  });
1258
1258
 
@@ -1363,16 +1363,16 @@ var init_judge_call = __esm({
1363
1363
  // src/internal/runtime/registry/agent-factory-registry.ts
1364
1364
  var agent_factory_registry_exports = {};
1365
1365
  __export(agent_factory_registry_exports, {
1366
- getAgentCreate: () => getAgentCreate,
1367
- setAgentCreate: () => setAgentCreate
1366
+ getAgentFacade: () => getAgentFacade,
1367
+ setAgentFacade: () => setAgentFacade
1368
1368
  });
1369
- function setAgentCreate(fn) {
1370
- registered3 = fn;
1369
+ function setAgentFacade(facade) {
1370
+ registered3 = facade;
1371
1371
  }
1372
- function getAgentCreate() {
1372
+ function getAgentFacade() {
1373
1373
  if (registered3 === void 0) {
1374
1374
  throw new Error(
1375
- "internal: Agent.create not registered. The `agent.ts` module must be loaded before LocalAgent.runUntil/fork are invoked."
1375
+ "internal: Agent facade not registered. The `agent.ts` module must be loaded before internal subsystems (LocalAgent.runUntil/fork, eval, scorers, cron) invoke it."
1376
1376
  );
1377
1377
  }
1378
1378
  return registered3;
@@ -1383,7 +1383,7 @@ var init_agent_factory_registry = __esm({
1383
1383
  }
1384
1384
  });
1385
1385
 
1386
- // src/internal/runtime/fork-agent.ts
1386
+ // src/internal/runtime/lifecycle/fork-agent.ts
1387
1387
  var fork_agent_exports = {};
1388
1388
  __export(fork_agent_exports, {
1389
1389
  filterMemoryPlugins: () => filterMemoryPlugins,
@@ -1443,7 +1443,7 @@ function extractUsage(result) {
1443
1443
  };
1444
1444
  }
1445
1445
  var init_fork_agent = __esm({
1446
- "src/internal/runtime/fork-agent.ts"() {
1446
+ "src/internal/runtime/lifecycle/fork-agent.ts"() {
1447
1447
  init_async_local_storage();
1448
1448
  init_local_agent_plugins();
1449
1449
  }
@@ -1466,7 +1466,7 @@ var init_task = __esm({
1466
1466
  }
1467
1467
  });
1468
1468
 
1469
- // src/internal/runtime/async-semaphore.ts
1469
+ // src/internal/runtime/concurrency/async-semaphore.ts
1470
1470
  function createSemaphore(permits) {
1471
1471
  if (!Number.isInteger(permits) || permits < 1) {
1472
1472
  throw new ConfigurationError(
@@ -1504,7 +1504,7 @@ function createSemaphore(permits) {
1504
1504
  };
1505
1505
  }
1506
1506
  var init_async_semaphore = __esm({
1507
- "src/internal/runtime/async-semaphore.ts"() {
1507
+ "src/internal/runtime/concurrency/async-semaphore.ts"() {
1508
1508
  init_errors();
1509
1509
  }
1510
1510
  });
@@ -2588,9 +2588,6 @@ var init_batch = __esm({
2588
2588
  }
2589
2589
  });
2590
2590
 
2591
- // src/cron.ts
2592
- init_errors();
2593
-
2594
2591
  // src/agent-builder.ts
2595
2592
  var AgentBuilder = class {
2596
2593
  opts = {};
@@ -3088,7 +3085,7 @@ function sanitizeIdentifier(input, options) {
3088
3085
  return input.toLowerCase();
3089
3086
  }
3090
3087
 
3091
- // src/internal/runtime/default-model.ts
3088
+ // src/internal/runtime/config/default-model.ts
3092
3089
  var DEFAULT_AGENTIC_MODEL_ID = "google/gemini-2.0-flash-001";
3093
3090
 
3094
3091
  // src/internal/runtime/registry/agent-registry-store.ts
@@ -3409,7 +3406,7 @@ async function flushRegistrySaves(cwd) {
3409
3406
  }
3410
3407
  }
3411
3408
 
3412
- // src/internal/runtime/system-prompt.ts
3409
+ // src/internal/runtime/system-prompt/system-prompt.ts
3413
3410
  async function resolveSystemPrompt(agent, override, ctx) {
3414
3411
  if (override !== void 0) return override;
3415
3412
  if (agent === void 0) return void 0;
@@ -5792,28 +5789,6 @@ function parseDecisionFromStdout(stdout) {
5792
5789
  return { decision: "allow" };
5793
5790
  }
5794
5791
 
5795
- // src/internal/runtime/memory/memory-path-selector.ts
5796
- var PORT_MEMORY_PATH_ENV_VAR = "THEOKIT_PORT_MEMORY_PATH";
5797
- function shouldUsePortMemoryPath() {
5798
- const env = globalThis.process?.env;
5799
- if (env === void 0) return false;
5800
- const val = env[PORT_MEMORY_PATH_ENV_VAR];
5801
- return val === "1" || val === "true";
5802
- }
5803
- function resolveMemoryProviderForLoop(consumerSupplied, defaultAdapter, portPathEnabled) {
5804
- if (consumerSupplied !== void 0) return consumerSupplied;
5805
- if (portPathEnabled) return defaultAdapter;
5806
- return void 0;
5807
- }
5808
- function resolveMemoryToolsForLoop(legacyTools, portPathEnabled) {
5809
- if (portPathEnabled) return void 0;
5810
- return legacyTools;
5811
- }
5812
- function resolveActiveMemorySummaryForSend(legacySummary, portPathEnabled) {
5813
- if (portPathEnabled) return void 0;
5814
- return legacySummary;
5815
- }
5816
-
5817
5792
  // src/internal/memory/storage/session-summary-writer.ts
5818
5793
  init_atomic_write();
5819
5794
  var MAX_TURN_CHARS = 2e3;
@@ -5857,6 +5832,28 @@ async function writeSessionSummary(input) {
5857
5832
  await replaceFileAtomic(path, body);
5858
5833
  }
5859
5834
 
5835
+ // src/internal/runtime/memory/memory-path-selector.ts
5836
+ var PORT_MEMORY_PATH_ENV_VAR = "THEOKIT_PORT_MEMORY_PATH";
5837
+ function shouldUsePortMemoryPath() {
5838
+ const env = globalThis.process?.env;
5839
+ if (env === void 0) return false;
5840
+ const val = env[PORT_MEMORY_PATH_ENV_VAR];
5841
+ return val === "1" || val === "true";
5842
+ }
5843
+ function resolveMemoryProviderForLoop(consumerSupplied, defaultAdapter, portPathEnabled) {
5844
+ if (consumerSupplied !== void 0) return consumerSupplied;
5845
+ if (portPathEnabled) return defaultAdapter;
5846
+ return void 0;
5847
+ }
5848
+ function resolveMemoryToolsForLoop(legacyTools, portPathEnabled) {
5849
+ if (portPathEnabled) return void 0;
5850
+ return legacyTools;
5851
+ }
5852
+ function resolveActiveMemorySummaryForSend(legacySummary, portPathEnabled) {
5853
+ if (portPathEnabled) return void 0;
5854
+ return legacySummary;
5855
+ }
5856
+
5860
5857
  // src/internal/runtime/session/agent-session-store.ts
5861
5858
  init_atomic_write();
5862
5859
  var VALID_ROLES = /* @__PURE__ */ new Set([
@@ -6113,7 +6110,7 @@ function clearSession(agentId) {
6113
6110
  sessions.delete(agentId);
6114
6111
  }
6115
6112
 
6116
- // src/internal/runtime/post-run-lifecycle.ts
6113
+ // src/internal/runtime/lifecycle/post-run-lifecycle.ts
6117
6114
  async function runPostRunLifecycle(inputs) {
6118
6115
  const {
6119
6116
  run,
@@ -6345,7 +6342,7 @@ var liveAgentRegistry = new LiveAgentRegistry();
6345
6342
  // src/internal/runtime/skills/subagents-loader.ts
6346
6343
  init_errors();
6347
6344
 
6348
- // src/internal/runtime/workspace-dir.ts
6345
+ // src/internal/runtime/config/workspace-dir.ts
6349
6346
  init_errors();
6350
6347
  async function readWorkspaceDir(root, errorCode, describe) {
6351
6348
  try {
@@ -6631,7 +6628,7 @@ var SystemPromptPipeline = class _SystemPromptPipeline {
6631
6628
  }
6632
6629
  };
6633
6630
 
6634
- // src/internal/runtime/validate-agent-options.ts
6631
+ // src/internal/runtime/validation/validate-agent-options.ts
6635
6632
  init_errors();
6636
6633
  function validateAgentOptions(options) {
6637
6634
  rejectProgrammaticHooks(options);
@@ -6826,6 +6823,71 @@ function validateMemory(options) {
6826
6823
  }
6827
6824
  }
6828
6825
 
6826
+ // src/internal/runtime/config/providers-manager.ts
6827
+ var ProvidersManagerImpl = class {
6828
+ constructor(model, providers, plugins) {
6829
+ this.model = model;
6830
+ this.providers = providers;
6831
+ this.plugins = plugins;
6832
+ }
6833
+ model;
6834
+ providers;
6835
+ plugins;
6836
+ routes() {
6837
+ const resolved = [];
6838
+ const modelProvider = providerFromModel(this.model);
6839
+ const seen = /* @__PURE__ */ new Set();
6840
+ if (this.providers?.routes !== void 0) {
6841
+ for (const route of this.providers.routes) {
6842
+ const resolvedRoute = resolveRoute(route, modelProvider, this.plugins);
6843
+ if (!seen.has(route.capability)) {
6844
+ seen.add(route.capability);
6845
+ resolved.push(resolvedRoute);
6846
+ }
6847
+ }
6848
+ }
6849
+ return Promise.resolve(resolved);
6850
+ }
6851
+ };
6852
+ function providerFromModel(model) {
6853
+ if (model === void 0) return void 0;
6854
+ const id = model.id;
6855
+ if (id.includes(":")) return id.split(":")[0];
6856
+ return void 0;
6857
+ }
6858
+ function resolveRoute(route, modelProvider, plugins) {
6859
+ if (route.capability === "chat" && modelProvider === route.provider) {
6860
+ const modelName = extractModelName(modelProvider, route);
6861
+ const base = {
6862
+ capability: route.capability,
6863
+ provider: route.provider,
6864
+ reason: "explicit-model-provider"
6865
+ };
6866
+ if (modelName !== void 0) base.model = modelName;
6867
+ return base;
6868
+ }
6869
+ if (plugins?.enabled !== void 0 && plugins.enabled.length > 0) {
6870
+ return {
6871
+ capability: route.capability,
6872
+ provider: route.provider,
6873
+ reason: "first-available-plugin-provider"
6874
+ };
6875
+ }
6876
+ return {
6877
+ capability: route.capability,
6878
+ provider: route.provider,
6879
+ reason: "explicit-route"
6880
+ };
6881
+ }
6882
+ function extractModelName(prefix, route) {
6883
+ if (route.model !== void 0) return route.model;
6884
+ return prefix === route.provider ? defaultModelForProvider(prefix) : void 0;
6885
+ }
6886
+ function defaultModelForProvider(provider) {
6887
+ if (provider === "anthropic") return "claude-3-7-sonnet";
6888
+ return void 0;
6889
+ }
6890
+
6829
6891
  // src/internal/runtime/context/context-manager.ts
6830
6892
  init_errors();
6831
6893
  init_markdown_config_loader();
@@ -7622,71 +7684,6 @@ async function loadPluginManifestFromMarkdown(pluginsRoot, folderName) {
7622
7684
  return metadata;
7623
7685
  }
7624
7686
 
7625
- // src/internal/runtime/providers-manager.ts
7626
- var ProvidersManagerImpl = class {
7627
- constructor(model, providers, plugins) {
7628
- this.model = model;
7629
- this.providers = providers;
7630
- this.plugins = plugins;
7631
- }
7632
- model;
7633
- providers;
7634
- plugins;
7635
- routes() {
7636
- const resolved = [];
7637
- const modelProvider = providerFromModel(this.model);
7638
- const seen = /* @__PURE__ */ new Set();
7639
- if (this.providers?.routes !== void 0) {
7640
- for (const route of this.providers.routes) {
7641
- const resolvedRoute = resolveRoute(route, modelProvider, this.plugins);
7642
- if (!seen.has(route.capability)) {
7643
- seen.add(route.capability);
7644
- resolved.push(resolvedRoute);
7645
- }
7646
- }
7647
- }
7648
- return Promise.resolve(resolved);
7649
- }
7650
- };
7651
- function providerFromModel(model) {
7652
- if (model === void 0) return void 0;
7653
- const id = model.id;
7654
- if (id.includes(":")) return id.split(":")[0];
7655
- return void 0;
7656
- }
7657
- function resolveRoute(route, modelProvider, plugins) {
7658
- if (route.capability === "chat" && modelProvider === route.provider) {
7659
- const modelName = extractModelName(modelProvider, route);
7660
- const base = {
7661
- capability: route.capability,
7662
- provider: route.provider,
7663
- reason: "explicit-model-provider"
7664
- };
7665
- if (modelName !== void 0) base.model = modelName;
7666
- return base;
7667
- }
7668
- if (plugins?.enabled !== void 0 && plugins.enabled.length > 0) {
7669
- return {
7670
- capability: route.capability,
7671
- provider: route.provider,
7672
- reason: "first-available-plugin-provider"
7673
- };
7674
- }
7675
- return {
7676
- capability: route.capability,
7677
- provider: route.provider,
7678
- reason: "explicit-route"
7679
- };
7680
- }
7681
- function extractModelName(prefix, route) {
7682
- if (route.model !== void 0) return route.model;
7683
- return prefix === route.provider ? defaultModelForProvider(prefix) : void 0;
7684
- }
7685
- function defaultModelForProvider(provider) {
7686
- if (provider === "anthropic") return "claude-3-7-sonnet";
7687
- return void 0;
7688
- }
7689
-
7690
7687
  // src/internal/runtime/skills/skills-manager.ts
7691
7688
  init_errors();
7692
7689
 
@@ -8033,7 +8030,7 @@ var IterationBudget = class {
8033
8030
  }
8034
8031
  };
8035
8032
 
8036
- // src/internal/runtime/validate-response.ts
8033
+ // src/internal/runtime/validation/validate-response.ts
8037
8034
  function validateResponse(response) {
8038
8035
  const trimmed = response.content.trim();
8039
8036
  const toolCallsArr = Array.isArray(response.toolCalls) ? response.toolCalls : [];
@@ -8492,7 +8489,7 @@ function coerceArgsToSchema(args, schema) {
8492
8489
  return { value: out, changed };
8493
8490
  }
8494
8491
 
8495
- // src/internal/runtime/shell-tool.ts
8492
+ // src/internal/runtime/tools/shell-tool.ts
8496
8493
  async function runShell(options) {
8497
8494
  if (options.sandbox === true && isObviouslyUnsafe(options.command)) {
8498
8495
  return {
@@ -9693,10 +9690,10 @@ function registerBuiltins() {
9693
9690
  registerCatalogProviders();
9694
9691
  }
9695
9692
 
9696
- // src/internal/errors/mappers/anthropic.ts
9693
+ // src/internal/error-mappers/anthropic.ts
9697
9694
  init_errors();
9698
9695
 
9699
- // src/internal/errors/mappers/shared.ts
9696
+ // src/internal/error-mappers/shared.ts
9700
9697
  var RAW_MAX_BYTES = 2048;
9701
9698
  function parseRetryAfter(headers) {
9702
9699
  if (headers === void 0) return void 0;
@@ -9725,7 +9722,7 @@ function buildErrorMetadata(args) {
9725
9722
  };
9726
9723
  }
9727
9724
 
9728
- // src/internal/errors/mappers/anthropic.ts
9725
+ // src/internal/error-mappers/anthropic.ts
9729
9726
  function mapAnthropicError(args) {
9730
9727
  const { status, body, headers, endpoint } = args;
9731
9728
  const code = mapAnthropicStatusToCode(status, body);
@@ -10065,7 +10062,7 @@ function buildAnthropicBody(request) {
10065
10062
  // src/internal/llm/bedrock-anthropic.ts
10066
10063
  init_errors();
10067
10064
 
10068
- // src/internal/errors/mappers/bedrock.ts
10065
+ // src/internal/error-mappers/bedrock.ts
10069
10066
  init_errors();
10070
10067
  function classifyBedrockError(args, awsType, message) {
10071
10068
  if (args.status === 429 || awsType.includes("Throttling") || awsType.includes("TooManyRequests")) {
@@ -10202,7 +10199,7 @@ function buildBedrockBody(request) {
10202
10199
  init_credential_pool();
10203
10200
  init_credential_pool_context();
10204
10201
 
10205
- // src/internal/errors/mappers/openai-compatible.ts
10202
+ // src/internal/error-mappers/openai-compatible.ts
10206
10203
  init_errors();
10207
10204
  function mapOpenAICompatibleError(args) {
10208
10205
  const { providerId, status, body, headers, endpoint } = args;
@@ -10366,7 +10363,7 @@ function readOpenAiContent(body) {
10366
10363
  return void 0;
10367
10364
  }
10368
10365
 
10369
- // src/internal/errors/mappers/ollama.ts
10366
+ // src/internal/error-mappers/ollama.ts
10370
10367
  init_errors();
10371
10368
  function mapOllamaTransportError(args) {
10372
10369
  if (args.providerId !== "ollama") return void 0;
@@ -11016,7 +11013,7 @@ function abortError2(signal) {
11016
11013
  // src/internal/llm/vertex-anthropic.ts
11017
11014
  init_errors();
11018
11015
 
11019
- // src/internal/errors/mappers/vertex.ts
11016
+ // src/internal/error-mappers/vertex.ts
11020
11017
  init_errors();
11021
11018
  var VERTEX_RULES = [
11022
11019
  { test: (s, e) => s === 429 || e === "RESOURCE_EXHAUSTED", code: "rate_limit" },
@@ -14266,8 +14263,8 @@ function localAgentRunUntil(agent, goal, options) {
14266
14263
  async function* wrap() {
14267
14264
  const { runUntilImpl: runUntilImpl2 } = await Promise.resolve().then(() => (init_run_until(), run_until_exports));
14268
14265
  const { judgeCallImpl: judgeCallImpl2 } = await Promise.resolve().then(() => (init_judge_call(), judge_call_exports));
14269
- const { getAgentCreate: getAgentCreate2 } = await Promise.resolve().then(() => (init_agent_factory_registry(), agent_factory_registry_exports));
14270
- const create = getAgentCreate2();
14266
+ const { getAgentFacade: getAgentFacade2 } = await Promise.resolve().then(() => (init_agent_factory_registry(), agent_factory_registry_exports));
14267
+ const create = getAgentFacade2().create;
14271
14268
  const deps = {
14272
14269
  judge: async (ctx, opts) => judgeCallImpl2(ctx, opts, { create })
14273
14270
  };
@@ -14277,9 +14274,9 @@ function localAgentRunUntil(agent, goal, options) {
14277
14274
  }
14278
14275
  async function localAgentFork(parent, options) {
14279
14276
  const { forkAgentImpl: forkAgentImpl2 } = await Promise.resolve().then(() => (init_fork_agent(), fork_agent_exports));
14280
- const { getAgentCreate: getAgentCreate2 } = await Promise.resolve().then(() => (init_agent_factory_registry(), agent_factory_registry_exports));
14277
+ const { getAgentFacade: getAgentFacade2 } = await Promise.resolve().then(() => (init_agent_factory_registry(), agent_factory_registry_exports));
14281
14278
  const { withPersonalityContext: withPersonalityContext2 } = await Promise.resolve().then(() => (init_context(), context_exports));
14282
- const create = getAgentCreate2();
14279
+ const create = getAgentFacade2().create;
14283
14280
  return withPersonalityContext2(
14284
14281
  { slug: parent.personalitySlugSnapshot, isFork: true },
14285
14282
  () => forkAgentImpl2(parent, options, { create })
@@ -14300,7 +14297,7 @@ async function persistMemoryFactIfWritePrompt(workspaceCwd, memoryConfig, userTe
14300
14297
  // src/internal/runtime/local-agent/local-agent-send.ts
14301
14298
  init_errors();
14302
14299
 
14303
- // src/internal/runtime/abort-utils.ts
14300
+ // src/internal/runtime/concurrency/abort-utils.ts
14304
14301
  function anySignal(signals) {
14305
14302
  const filtered = signals.filter((s) => s !== void 0);
14306
14303
  if (filtered.length === 0) {
@@ -15329,10 +15326,20 @@ async function getOrCreateUncached(agentId, options) {
15329
15326
  throw err;
15330
15327
  }
15331
15328
  }
15332
- setAgentCreate((options) => Agent.create(options));
15329
+ setAgentFacade({
15330
+ create: (options) => Agent.create(options),
15331
+ prompt: (message, options) => Agent.prompt(message, options),
15332
+ get: (agentId) => Agent.get(agentId),
15333
+ resume: (agentId, options) => Agent.resume(agentId, options),
15334
+ batch: (prompts, options) => Agent.batch(prompts, options)
15335
+ });
15336
+
15337
+ // src/cron.ts
15338
+ init_errors();
15333
15339
 
15334
15340
  // src/internal/cron/run-job.ts
15335
15341
  init_errors();
15342
+ init_agent_factory_registry();
15336
15343
  async function runCronJob(job) {
15337
15344
  if (job.agent !== void 0) return runWithEphemeralAgent(job.agent, job.message);
15338
15345
  if (job.agentId !== void 0) return runWithExistingAgent(job.agentId, job.message);
@@ -15341,18 +15348,18 @@ async function runCronJob(job) {
15341
15348
  });
15342
15349
  }
15343
15350
  async function runWithExistingAgent(agentId, message) {
15344
- const info = await Agent.get(agentId).catch(() => void 0);
15351
+ const info = await getAgentFacade().get(agentId).catch(() => void 0);
15345
15352
  if (info === void 0) {
15346
15353
  throw new UnknownAgentError(
15347
15354
  `Cron job references agentId "${agentId}" but no such agent is registered. The agent may have been disposed or the process restarted without persisting the agent registry.`,
15348
15355
  { code: "agent_not_registered" }
15349
15356
  );
15350
15357
  }
15351
- const agent = await Agent.resume(agentId);
15358
+ const agent = await getAgentFacade().resume(agentId);
15352
15359
  return agent.send(message);
15353
15360
  }
15354
15361
  async function runWithEphemeralAgent(baseOptions, message) {
15355
- const agent = await Agent.create(baseOptions);
15362
+ const agent = await getAgentFacade().create(baseOptions);
15356
15363
  return agent.send(message);
15357
15364
  }
15358
15365