@theokit/sdk 2.0.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 (57) hide show
  1. package/CHANGELOG.md +18 -0
  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 -2
  39. /package/dist/internal/{errors/mappers → error-mappers}/anthropic.d.ts +0 -0
  40. /package/dist/internal/{errors/mappers → error-mappers}/bedrock.d.ts +0 -0
  41. /package/dist/internal/{errors/mappers → error-mappers}/ollama.d.ts +0 -0
  42. /package/dist/internal/{errors/mappers → error-mappers}/openai-compatible.d.ts +0 -0
  43. /package/dist/internal/{errors/mappers → error-mappers}/shared.d.ts +0 -0
  44. /package/dist/internal/{errors/mappers → error-mappers}/vertex.d.ts +0 -0
  45. /package/dist/internal/runtime/{abort-utils.d.ts → concurrency/abort-utils.d.ts} +0 -0
  46. /package/dist/internal/runtime/{async-local-storage.d.ts → concurrency/async-local-storage.d.ts} +0 -0
  47. /package/dist/internal/runtime/{async-semaphore.d.ts → concurrency/async-semaphore.d.ts} +0 -0
  48. /package/dist/internal/runtime/{default-model.d.ts → config/default-model.d.ts} +0 -0
  49. /package/dist/internal/runtime/{providers-manager.d.ts → config/providers-manager.d.ts} +0 -0
  50. /package/dist/internal/runtime/{workspace-dir.d.ts → config/workspace-dir.d.ts} +0 -0
  51. /package/dist/internal/runtime/{yaml-frontmatter.d.ts → context/yaml-frontmatter.d.ts} +0 -0
  52. /package/dist/internal/runtime/{post-run-lifecycle.d.ts → lifecycle/post-run-lifecycle.d.ts} +0 -0
  53. /package/dist/internal/runtime/{spawn-collect.d.ts → lifecycle/spawn-collect.d.ts} +0 -0
  54. /package/dist/internal/runtime/{system-prompt.d.ts → system-prompt/system-prompt.d.ts} +0 -0
  55. /package/dist/internal/runtime/{shell-tool.d.ts → tools/shell-tool.d.ts} +0 -0
  56. /package/dist/internal/runtime/{validate-agent-options.d.ts → validation/validate-agent-options.d.ts} +0 -0
  57. /package/dist/internal/runtime/{validate-response.d.ts → validation/validate-response.d.ts} +0 -0
@@ -5,7 +5,7 @@ import { C as CustomTool, M as ModelSelection, D as SDKUserMessage, F as SendOpt
5
5
  *
6
6
  * Extracted into a leaf type module (arch-review ADR 0001) so the public
7
7
  * `types/agent.ts` barrel can reference `ForkOptions`/`ForkResult` without
8
- * importing the `internal/runtime/fork-agent.ts` implementation — which in
8
+ * importing the `internal/runtime/lifecycle/fork-agent.ts` implementation — which in
9
9
  * turn imports back from `types/agent.ts`. That mutual reference created a
10
10
  * type-only `madge` cycle. These interfaces are self-contained (no SDKAgent
11
11
  * / AgentOptions references), so co-locating them here breaks the cycle with
@@ -5,7 +5,7 @@ import { C as CustomTool, M as ModelSelection, D as SDKUserMessage, F as SendOpt
5
5
  *
6
6
  * Extracted into a leaf type module (arch-review ADR 0001) so the public
7
7
  * `types/agent.ts` barrel can reference `ForkOptions`/`ForkResult` without
8
- * importing the `internal/runtime/fork-agent.ts` implementation — which in
8
+ * importing the `internal/runtime/lifecycle/fork-agent.ts` implementation — which in
9
9
  * turn imports back from `types/agent.ts`. That mutual reference created a
10
10
  * type-only `madge` cycle. These interfaces are self-contained (no SDKAgent
11
11
  * / AgentOptions references), so co-locating them here breaks the cycle with
package/dist/cron.cjs CHANGED
@@ -586,7 +586,7 @@ var init_atomic_write = __esm({
586
586
  }
587
587
  });
588
588
 
589
- // src/internal/runtime/yaml-frontmatter.ts
589
+ // src/internal/runtime/context/yaml-frontmatter.ts
590
590
  function parseSimpleYaml(text) {
591
591
  const fields = {};
592
592
  for (const line of text.split(/\r?\n/)) {
@@ -610,7 +610,7 @@ function coerce(raw) {
610
610
  return raw;
611
611
  }
612
612
  var init_yaml_frontmatter = __esm({
613
- "src/internal/runtime/yaml-frontmatter.ts"() {
613
+ "src/internal/runtime/context/yaml-frontmatter.ts"() {
614
614
  }
615
615
  });
616
616
  async function loadMarkdownEntities(opts) {
@@ -813,7 +813,7 @@ function checkToolWhitelist(toolName) {
813
813
  }
814
814
  var toolWhitelistStore;
815
815
  var init_async_local_storage = __esm({
816
- "src/internal/runtime/async-local-storage.ts"() {
816
+ "src/internal/runtime/concurrency/async-local-storage.ts"() {
817
817
  toolWhitelistStore = new async_hooks.AsyncLocalStorage();
818
818
  }
819
819
  });
@@ -1162,7 +1162,7 @@ var init_local_agent_plugins = __esm({
1162
1162
  }
1163
1163
  });
1164
1164
 
1165
- // src/internal/runtime/run-until.ts
1165
+ // src/internal/runtime/lifecycle/run-until.ts
1166
1166
  var run_until_exports = {};
1167
1167
  __export(run_until_exports, {
1168
1168
  composeContinuation: () => composeContinuation,
@@ -1255,7 +1255,7 @@ Your last response was:
1255
1255
  ${lastResponse.slice(0, 1e3)}`;
1256
1256
  }
1257
1257
  var init_run_until = __esm({
1258
- "src/internal/runtime/run-until.ts"() {
1258
+ "src/internal/runtime/lifecycle/run-until.ts"() {
1259
1259
  }
1260
1260
  });
1261
1261
 
@@ -1366,16 +1366,16 @@ var init_judge_call = __esm({
1366
1366
  // src/internal/runtime/registry/agent-factory-registry.ts
1367
1367
  var agent_factory_registry_exports = {};
1368
1368
  __export(agent_factory_registry_exports, {
1369
- getAgentCreate: () => getAgentCreate,
1370
- setAgentCreate: () => setAgentCreate
1369
+ getAgentFacade: () => getAgentFacade,
1370
+ setAgentFacade: () => setAgentFacade
1371
1371
  });
1372
- function setAgentCreate(fn) {
1373
- registered3 = fn;
1372
+ function setAgentFacade(facade) {
1373
+ registered3 = facade;
1374
1374
  }
1375
- function getAgentCreate() {
1375
+ function getAgentFacade() {
1376
1376
  if (registered3 === void 0) {
1377
1377
  throw new Error(
1378
- "internal: Agent.create not registered. The `agent.ts` module must be loaded before LocalAgent.runUntil/fork are invoked."
1378
+ "internal: Agent facade not registered. The `agent.ts` module must be loaded before internal subsystems (LocalAgent.runUntil/fork, eval, scorers, cron) invoke it."
1379
1379
  );
1380
1380
  }
1381
1381
  return registered3;
@@ -1386,7 +1386,7 @@ var init_agent_factory_registry = __esm({
1386
1386
  }
1387
1387
  });
1388
1388
 
1389
- // src/internal/runtime/fork-agent.ts
1389
+ // src/internal/runtime/lifecycle/fork-agent.ts
1390
1390
  var fork_agent_exports = {};
1391
1391
  __export(fork_agent_exports, {
1392
1392
  filterMemoryPlugins: () => filterMemoryPlugins,
@@ -1446,7 +1446,7 @@ function extractUsage(result) {
1446
1446
  };
1447
1447
  }
1448
1448
  var init_fork_agent = __esm({
1449
- "src/internal/runtime/fork-agent.ts"() {
1449
+ "src/internal/runtime/lifecycle/fork-agent.ts"() {
1450
1450
  init_async_local_storage();
1451
1451
  init_local_agent_plugins();
1452
1452
  }
@@ -1469,7 +1469,7 @@ var init_task = __esm({
1469
1469
  }
1470
1470
  });
1471
1471
 
1472
- // src/internal/runtime/async-semaphore.ts
1472
+ // src/internal/runtime/concurrency/async-semaphore.ts
1473
1473
  function createSemaphore(permits) {
1474
1474
  if (!Number.isInteger(permits) || permits < 1) {
1475
1475
  throw new ConfigurationError(
@@ -1507,7 +1507,7 @@ function createSemaphore(permits) {
1507
1507
  };
1508
1508
  }
1509
1509
  var init_async_semaphore = __esm({
1510
- "src/internal/runtime/async-semaphore.ts"() {
1510
+ "src/internal/runtime/concurrency/async-semaphore.ts"() {
1511
1511
  init_errors();
1512
1512
  }
1513
1513
  });
@@ -2591,9 +2591,6 @@ var init_batch = __esm({
2591
2591
  }
2592
2592
  });
2593
2593
 
2594
- // src/cron.ts
2595
- init_errors();
2596
-
2597
2594
  // src/agent-builder.ts
2598
2595
  var AgentBuilder = class {
2599
2596
  opts = {};
@@ -3091,7 +3088,7 @@ function sanitizeIdentifier(input, options) {
3091
3088
  return input.toLowerCase();
3092
3089
  }
3093
3090
 
3094
- // src/internal/runtime/default-model.ts
3091
+ // src/internal/runtime/config/default-model.ts
3095
3092
  var DEFAULT_AGENTIC_MODEL_ID = "google/gemini-2.0-flash-001";
3096
3093
 
3097
3094
  // src/internal/runtime/registry/agent-registry-store.ts
@@ -3412,7 +3409,7 @@ async function flushRegistrySaves(cwd) {
3412
3409
  }
3413
3410
  }
3414
3411
 
3415
- // src/internal/runtime/system-prompt.ts
3412
+ // src/internal/runtime/system-prompt/system-prompt.ts
3416
3413
  async function resolveSystemPrompt(agent, override, ctx) {
3417
3414
  if (override !== void 0) return override;
3418
3415
  if (agent === void 0) return void 0;
@@ -5795,28 +5792,6 @@ function parseDecisionFromStdout(stdout) {
5795
5792
  return { decision: "allow" };
5796
5793
  }
5797
5794
 
5798
- // src/internal/runtime/memory/memory-path-selector.ts
5799
- var PORT_MEMORY_PATH_ENV_VAR = "THEOKIT_PORT_MEMORY_PATH";
5800
- function shouldUsePortMemoryPath() {
5801
- const env = globalThis.process?.env;
5802
- if (env === void 0) return false;
5803
- const val = env[PORT_MEMORY_PATH_ENV_VAR];
5804
- return val === "1" || val === "true";
5805
- }
5806
- function resolveMemoryProviderForLoop(consumerSupplied, defaultAdapter, portPathEnabled) {
5807
- if (consumerSupplied !== void 0) return consumerSupplied;
5808
- if (portPathEnabled) return defaultAdapter;
5809
- return void 0;
5810
- }
5811
- function resolveMemoryToolsForLoop(legacyTools, portPathEnabled) {
5812
- if (portPathEnabled) return void 0;
5813
- return legacyTools;
5814
- }
5815
- function resolveActiveMemorySummaryForSend(legacySummary, portPathEnabled) {
5816
- if (portPathEnabled) return void 0;
5817
- return legacySummary;
5818
- }
5819
-
5820
5795
  // src/internal/memory/storage/session-summary-writer.ts
5821
5796
  init_atomic_write();
5822
5797
  var MAX_TURN_CHARS = 2e3;
@@ -5860,6 +5835,28 @@ async function writeSessionSummary(input) {
5860
5835
  await replaceFileAtomic(path, body);
5861
5836
  }
5862
5837
 
5838
+ // src/internal/runtime/memory/memory-path-selector.ts
5839
+ var PORT_MEMORY_PATH_ENV_VAR = "THEOKIT_PORT_MEMORY_PATH";
5840
+ function shouldUsePortMemoryPath() {
5841
+ const env = globalThis.process?.env;
5842
+ if (env === void 0) return false;
5843
+ const val = env[PORT_MEMORY_PATH_ENV_VAR];
5844
+ return val === "1" || val === "true";
5845
+ }
5846
+ function resolveMemoryProviderForLoop(consumerSupplied, defaultAdapter, portPathEnabled) {
5847
+ if (consumerSupplied !== void 0) return consumerSupplied;
5848
+ if (portPathEnabled) return defaultAdapter;
5849
+ return void 0;
5850
+ }
5851
+ function resolveMemoryToolsForLoop(legacyTools, portPathEnabled) {
5852
+ if (portPathEnabled) return void 0;
5853
+ return legacyTools;
5854
+ }
5855
+ function resolveActiveMemorySummaryForSend(legacySummary, portPathEnabled) {
5856
+ if (portPathEnabled) return void 0;
5857
+ return legacySummary;
5858
+ }
5859
+
5863
5860
  // src/internal/runtime/session/agent-session-store.ts
5864
5861
  init_atomic_write();
5865
5862
  var VALID_ROLES = /* @__PURE__ */ new Set([
@@ -6116,7 +6113,7 @@ function clearSession(agentId) {
6116
6113
  sessions.delete(agentId);
6117
6114
  }
6118
6115
 
6119
- // src/internal/runtime/post-run-lifecycle.ts
6116
+ // src/internal/runtime/lifecycle/post-run-lifecycle.ts
6120
6117
  async function runPostRunLifecycle(inputs) {
6121
6118
  const {
6122
6119
  run,
@@ -6348,7 +6345,7 @@ var liveAgentRegistry = new LiveAgentRegistry();
6348
6345
  // src/internal/runtime/skills/subagents-loader.ts
6349
6346
  init_errors();
6350
6347
 
6351
- // src/internal/runtime/workspace-dir.ts
6348
+ // src/internal/runtime/config/workspace-dir.ts
6352
6349
  init_errors();
6353
6350
  async function readWorkspaceDir(root, errorCode, describe) {
6354
6351
  try {
@@ -6634,7 +6631,7 @@ var SystemPromptPipeline = class _SystemPromptPipeline {
6634
6631
  }
6635
6632
  };
6636
6633
 
6637
- // src/internal/runtime/validate-agent-options.ts
6634
+ // src/internal/runtime/validation/validate-agent-options.ts
6638
6635
  init_errors();
6639
6636
  function validateAgentOptions(options) {
6640
6637
  rejectProgrammaticHooks(options);
@@ -6829,6 +6826,71 @@ function validateMemory(options) {
6829
6826
  }
6830
6827
  }
6831
6828
 
6829
+ // src/internal/runtime/config/providers-manager.ts
6830
+ var ProvidersManagerImpl = class {
6831
+ constructor(model, providers, plugins) {
6832
+ this.model = model;
6833
+ this.providers = providers;
6834
+ this.plugins = plugins;
6835
+ }
6836
+ model;
6837
+ providers;
6838
+ plugins;
6839
+ routes() {
6840
+ const resolved = [];
6841
+ const modelProvider = providerFromModel(this.model);
6842
+ const seen = /* @__PURE__ */ new Set();
6843
+ if (this.providers?.routes !== void 0) {
6844
+ for (const route of this.providers.routes) {
6845
+ const resolvedRoute = resolveRoute(route, modelProvider, this.plugins);
6846
+ if (!seen.has(route.capability)) {
6847
+ seen.add(route.capability);
6848
+ resolved.push(resolvedRoute);
6849
+ }
6850
+ }
6851
+ }
6852
+ return Promise.resolve(resolved);
6853
+ }
6854
+ };
6855
+ function providerFromModel(model) {
6856
+ if (model === void 0) return void 0;
6857
+ const id = model.id;
6858
+ if (id.includes(":")) return id.split(":")[0];
6859
+ return void 0;
6860
+ }
6861
+ function resolveRoute(route, modelProvider, plugins) {
6862
+ if (route.capability === "chat" && modelProvider === route.provider) {
6863
+ const modelName = extractModelName(modelProvider, route);
6864
+ const base = {
6865
+ capability: route.capability,
6866
+ provider: route.provider,
6867
+ reason: "explicit-model-provider"
6868
+ };
6869
+ if (modelName !== void 0) base.model = modelName;
6870
+ return base;
6871
+ }
6872
+ if (plugins?.enabled !== void 0 && plugins.enabled.length > 0) {
6873
+ return {
6874
+ capability: route.capability,
6875
+ provider: route.provider,
6876
+ reason: "first-available-plugin-provider"
6877
+ };
6878
+ }
6879
+ return {
6880
+ capability: route.capability,
6881
+ provider: route.provider,
6882
+ reason: "explicit-route"
6883
+ };
6884
+ }
6885
+ function extractModelName(prefix, route) {
6886
+ if (route.model !== void 0) return route.model;
6887
+ return prefix === route.provider ? defaultModelForProvider(prefix) : void 0;
6888
+ }
6889
+ function defaultModelForProvider(provider) {
6890
+ if (provider === "anthropic") return "claude-3-7-sonnet";
6891
+ return void 0;
6892
+ }
6893
+
6832
6894
  // src/internal/runtime/context/context-manager.ts
6833
6895
  init_errors();
6834
6896
  init_markdown_config_loader();
@@ -7625,71 +7687,6 @@ async function loadPluginManifestFromMarkdown(pluginsRoot, folderName) {
7625
7687
  return metadata;
7626
7688
  }
7627
7689
 
7628
- // src/internal/runtime/providers-manager.ts
7629
- var ProvidersManagerImpl = class {
7630
- constructor(model, providers, plugins) {
7631
- this.model = model;
7632
- this.providers = providers;
7633
- this.plugins = plugins;
7634
- }
7635
- model;
7636
- providers;
7637
- plugins;
7638
- routes() {
7639
- const resolved = [];
7640
- const modelProvider = providerFromModel(this.model);
7641
- const seen = /* @__PURE__ */ new Set();
7642
- if (this.providers?.routes !== void 0) {
7643
- for (const route of this.providers.routes) {
7644
- const resolvedRoute = resolveRoute(route, modelProvider, this.plugins);
7645
- if (!seen.has(route.capability)) {
7646
- seen.add(route.capability);
7647
- resolved.push(resolvedRoute);
7648
- }
7649
- }
7650
- }
7651
- return Promise.resolve(resolved);
7652
- }
7653
- };
7654
- function providerFromModel(model) {
7655
- if (model === void 0) return void 0;
7656
- const id = model.id;
7657
- if (id.includes(":")) return id.split(":")[0];
7658
- return void 0;
7659
- }
7660
- function resolveRoute(route, modelProvider, plugins) {
7661
- if (route.capability === "chat" && modelProvider === route.provider) {
7662
- const modelName = extractModelName(modelProvider, route);
7663
- const base = {
7664
- capability: route.capability,
7665
- provider: route.provider,
7666
- reason: "explicit-model-provider"
7667
- };
7668
- if (modelName !== void 0) base.model = modelName;
7669
- return base;
7670
- }
7671
- if (plugins?.enabled !== void 0 && plugins.enabled.length > 0) {
7672
- return {
7673
- capability: route.capability,
7674
- provider: route.provider,
7675
- reason: "first-available-plugin-provider"
7676
- };
7677
- }
7678
- return {
7679
- capability: route.capability,
7680
- provider: route.provider,
7681
- reason: "explicit-route"
7682
- };
7683
- }
7684
- function extractModelName(prefix, route) {
7685
- if (route.model !== void 0) return route.model;
7686
- return prefix === route.provider ? defaultModelForProvider(prefix) : void 0;
7687
- }
7688
- function defaultModelForProvider(provider) {
7689
- if (provider === "anthropic") return "claude-3-7-sonnet";
7690
- return void 0;
7691
- }
7692
-
7693
7690
  // src/internal/runtime/skills/skills-manager.ts
7694
7691
  init_errors();
7695
7692
 
@@ -8036,7 +8033,7 @@ var IterationBudget = class {
8036
8033
  }
8037
8034
  };
8038
8035
 
8039
- // src/internal/runtime/validate-response.ts
8036
+ // src/internal/runtime/validation/validate-response.ts
8040
8037
  function validateResponse(response) {
8041
8038
  const trimmed = response.content.trim();
8042
8039
  const toolCallsArr = Array.isArray(response.toolCalls) ? response.toolCalls : [];
@@ -8495,7 +8492,7 @@ function coerceArgsToSchema(args, schema) {
8495
8492
  return { value: out, changed };
8496
8493
  }
8497
8494
 
8498
- // src/internal/runtime/shell-tool.ts
8495
+ // src/internal/runtime/tools/shell-tool.ts
8499
8496
  async function runShell(options) {
8500
8497
  if (options.sandbox === true && isObviouslyUnsafe(options.command)) {
8501
8498
  return {
@@ -9696,10 +9693,10 @@ function registerBuiltins() {
9696
9693
  registerCatalogProviders();
9697
9694
  }
9698
9695
 
9699
- // src/internal/errors/mappers/anthropic.ts
9696
+ // src/internal/error-mappers/anthropic.ts
9700
9697
  init_errors();
9701
9698
 
9702
- // src/internal/errors/mappers/shared.ts
9699
+ // src/internal/error-mappers/shared.ts
9703
9700
  var RAW_MAX_BYTES = 2048;
9704
9701
  function parseRetryAfter(headers) {
9705
9702
  if (headers === void 0) return void 0;
@@ -9728,7 +9725,7 @@ function buildErrorMetadata(args) {
9728
9725
  };
9729
9726
  }
9730
9727
 
9731
- // src/internal/errors/mappers/anthropic.ts
9728
+ // src/internal/error-mappers/anthropic.ts
9732
9729
  function mapAnthropicError(args) {
9733
9730
  const { status, body, headers, endpoint } = args;
9734
9731
  const code = mapAnthropicStatusToCode(status, body);
@@ -10068,7 +10065,7 @@ function buildAnthropicBody(request) {
10068
10065
  // src/internal/llm/bedrock-anthropic.ts
10069
10066
  init_errors();
10070
10067
 
10071
- // src/internal/errors/mappers/bedrock.ts
10068
+ // src/internal/error-mappers/bedrock.ts
10072
10069
  init_errors();
10073
10070
  function classifyBedrockError(args, awsType, message) {
10074
10071
  if (args.status === 429 || awsType.includes("Throttling") || awsType.includes("TooManyRequests")) {
@@ -10205,7 +10202,7 @@ function buildBedrockBody(request) {
10205
10202
  init_credential_pool();
10206
10203
  init_credential_pool_context();
10207
10204
 
10208
- // src/internal/errors/mappers/openai-compatible.ts
10205
+ // src/internal/error-mappers/openai-compatible.ts
10209
10206
  init_errors();
10210
10207
  function mapOpenAICompatibleError(args) {
10211
10208
  const { providerId, status, body, headers, endpoint } = args;
@@ -10369,7 +10366,7 @@ function readOpenAiContent(body) {
10369
10366
  return void 0;
10370
10367
  }
10371
10368
 
10372
- // src/internal/errors/mappers/ollama.ts
10369
+ // src/internal/error-mappers/ollama.ts
10373
10370
  init_errors();
10374
10371
  function mapOllamaTransportError(args) {
10375
10372
  if (args.providerId !== "ollama") return void 0;
@@ -11019,7 +11016,7 @@ function abortError2(signal) {
11019
11016
  // src/internal/llm/vertex-anthropic.ts
11020
11017
  init_errors();
11021
11018
 
11022
- // src/internal/errors/mappers/vertex.ts
11019
+ // src/internal/error-mappers/vertex.ts
11023
11020
  init_errors();
11024
11021
  var VERTEX_RULES = [
11025
11022
  { test: (s, e) => s === 429 || e === "RESOURCE_EXHAUSTED", code: "rate_limit" },
@@ -14269,8 +14266,8 @@ function localAgentRunUntil(agent, goal, options) {
14269
14266
  async function* wrap() {
14270
14267
  const { runUntilImpl: runUntilImpl2 } = await Promise.resolve().then(() => (init_run_until(), run_until_exports));
14271
14268
  const { judgeCallImpl: judgeCallImpl2 } = await Promise.resolve().then(() => (init_judge_call(), judge_call_exports));
14272
- const { getAgentCreate: getAgentCreate2 } = await Promise.resolve().then(() => (init_agent_factory_registry(), agent_factory_registry_exports));
14273
- const create = getAgentCreate2();
14269
+ const { getAgentFacade: getAgentFacade2 } = await Promise.resolve().then(() => (init_agent_factory_registry(), agent_factory_registry_exports));
14270
+ const create = getAgentFacade2().create;
14274
14271
  const deps = {
14275
14272
  judge: async (ctx, opts) => judgeCallImpl2(ctx, opts, { create })
14276
14273
  };
@@ -14280,9 +14277,9 @@ function localAgentRunUntil(agent, goal, options) {
14280
14277
  }
14281
14278
  async function localAgentFork(parent, options) {
14282
14279
  const { forkAgentImpl: forkAgentImpl2 } = await Promise.resolve().then(() => (init_fork_agent(), fork_agent_exports));
14283
- const { getAgentCreate: getAgentCreate2 } = await Promise.resolve().then(() => (init_agent_factory_registry(), agent_factory_registry_exports));
14280
+ const { getAgentFacade: getAgentFacade2 } = await Promise.resolve().then(() => (init_agent_factory_registry(), agent_factory_registry_exports));
14284
14281
  const { withPersonalityContext: withPersonalityContext2 } = await Promise.resolve().then(() => (init_context(), context_exports));
14285
- const create = getAgentCreate2();
14282
+ const create = getAgentFacade2().create;
14286
14283
  return withPersonalityContext2(
14287
14284
  { slug: parent.personalitySlugSnapshot, isFork: true },
14288
14285
  () => forkAgentImpl2(parent, options, { create })
@@ -14303,7 +14300,7 @@ async function persistMemoryFactIfWritePrompt(workspaceCwd, memoryConfig, userTe
14303
14300
  // src/internal/runtime/local-agent/local-agent-send.ts
14304
14301
  init_errors();
14305
14302
 
14306
- // src/internal/runtime/abort-utils.ts
14303
+ // src/internal/runtime/concurrency/abort-utils.ts
14307
14304
  function anySignal(signals) {
14308
14305
  const filtered = signals.filter((s) => s !== void 0);
14309
14306
  if (filtered.length === 0) {
@@ -15332,10 +15329,20 @@ async function getOrCreateUncached(agentId, options) {
15332
15329
  throw err;
15333
15330
  }
15334
15331
  }
15335
- setAgentCreate((options) => Agent.create(options));
15332
+ setAgentFacade({
15333
+ create: (options) => Agent.create(options),
15334
+ prompt: (message, options) => Agent.prompt(message, options),
15335
+ get: (agentId) => Agent.get(agentId),
15336
+ resume: (agentId, options) => Agent.resume(agentId, options),
15337
+ batch: (prompts, options) => Agent.batch(prompts, options)
15338
+ });
15339
+
15340
+ // src/cron.ts
15341
+ init_errors();
15336
15342
 
15337
15343
  // src/internal/cron/run-job.ts
15338
15344
  init_errors();
15345
+ init_agent_factory_registry();
15339
15346
  async function runCronJob(job) {
15340
15347
  if (job.agent !== void 0) return runWithEphemeralAgent(job.agent, job.message);
15341
15348
  if (job.agentId !== void 0) return runWithExistingAgent(job.agentId, job.message);
@@ -15344,18 +15351,18 @@ async function runCronJob(job) {
15344
15351
  });
15345
15352
  }
15346
15353
  async function runWithExistingAgent(agentId, message) {
15347
- const info = await Agent.get(agentId).catch(() => void 0);
15354
+ const info = await getAgentFacade().get(agentId).catch(() => void 0);
15348
15355
  if (info === void 0) {
15349
15356
  throw new UnknownAgentError(
15350
15357
  `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.`,
15351
15358
  { code: "agent_not_registered" }
15352
15359
  );
15353
15360
  }
15354
- const agent = await Agent.resume(agentId);
15361
+ const agent = await getAgentFacade().resume(agentId);
15355
15362
  return agent.send(message);
15356
15363
  }
15357
15364
  async function runWithEphemeralAgent(baseOptions, message) {
15358
- const agent = await Agent.create(baseOptions);
15365
+ const agent = await getAgentFacade().create(baseOptions);
15359
15366
  return agent.send(message);
15360
15367
  }
15361
15368