@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/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { T as TheokitAgentError, B as BudgetOptions, a as BudgetHandle, b as BudgetSnapshot } from './errors-ChqOmFH1.cjs';
2
2
  export { A as AgentDisposedError, c as AgentRunError, d as AgentRunErrorCode, e as AuthenticationError, f as BudgetExceedEvent, g as BudgetExceededError, h as BudgetLimit, i as BudgetMode, j as BudgetScope, k as BudgetThresholdEvent, l as BudgetWindow, C as ConfigurationError, E as ErrorCode, m as ErrorMetadata, I as IntegrationNotConnectedError, n as InvalidTaskIdError, M as MemoryAdapterError, o as MemoryAdapterErrorCode, N as NetworkError, R as RateLimitError, p as TaskNotFoundError, U as UnknownAgentError, q as UnsupportedBudgetOperationError, r as UnsupportedRunOperationError, s as UnsupportedTaskOperationError } from './errors-ChqOmFH1.cjs';
3
- import { A as AgentOptions, L as LocalOptions, P as ProviderRoutingSettings, S as SystemPromptResolver, C as CloudOptions, M as MemorySettings, a as AgentDefinition, b as ContextSettings, c as PluginsSettings, d as SkillsSettings, e as SDKAgent, f as ListAgentsOptions, g as ListResult, h as SDKAgentInfo, G as GetAgentOptions, i as ListRunsOptions, j as GetRunOptions, k as AgentOperationOptions, l as ConversationStorageAdapter, m as StoredMessage, n as MemoryContext, B as BudgetTracker, o as MemoryProvider, p as MemoryId, q as SDKProvider } from './cron-Bse1MbaE.cjs';
4
- export { r as ActiveMemoryPassArgs, s as ActiveMemoryPassResult, t as AgentMemory, u as BudgetCheck, v as BudgetTotal, w as BudgetUsageEvent, x as CloudEnv, y as CloudRepo, z as ContextBudget, D as ContextManagerKind, E as ContextSnapshot, F as ContextSource, H as ContextSourceStatus, I as Cron, J as CronCreateOptions, K as CronGetOptions, N as CronJob, O as CronJobStatus, Q as CronListOptions, R as CronOperationOptions, T as CronRunOptions, U as CronRuntime, V as CronSchedulerStatus, W as CronStartOptions, X as GoalEvent, Y as GoalOptions, Z as GoalResult, _ as InvalidateCacheOptions, $ as MemoryAdapter, a0 as MemoryAdapterCapabilities, a1 as MemoryFact, a2 as MemoryProviderHandle, a3 as MemoryProviderInitOptions, a4 as MemoryRevision, a5 as MemoryToolSchema, a6 as MemoryTurnMessage, a7 as PersonalityPreset, a8 as ProviderCapability, a9 as ProviderRoute, aa as RecordSessionSummaryArgs, ab as ResolvedProviderRoute, ac as RunUntilIterator, ad as SDKAgentPlugins, ae as SDKAgentSkills, af as SDKArtifact, ag as SDKContextManager, ah as SDKPluginMetadata, ai as SDKProvidersManager, aj as SettingSource, ak as SystemPromptContext, al as SystemPromptMemoryFact, am as SystemPromptSkillRef, an as TelemetrySettings } from './cron-Bse1MbaE.cjs';
3
+ import { A as AgentOptions, L as LocalOptions, P as ProviderRoutingSettings, S as SystemPromptResolver, C as CloudOptions, M as MemorySettings, a as AgentDefinition, b as ContextSettings, c as PluginsSettings, d as SkillsSettings, e as SDKAgent, f as ListAgentsOptions, g as ListResult, h as SDKAgentInfo, G as GetAgentOptions, i as ListRunsOptions, j as GetRunOptions, k as AgentOperationOptions, l as ConversationStorageAdapter, m as StoredMessage, n as MemoryContext, B as BudgetTracker, o as MemoryProvider, p as MemoryId, q as SDKProvider } from './cron-DFG9-W17.cjs';
4
+ export { r as ActiveMemoryPassArgs, s as ActiveMemoryPassResult, t as AgentMemory, u as BudgetCheck, v as BudgetTotal, w as BudgetUsageEvent, x as CloudEnv, y as CloudRepo, z as ContextBudget, D as ContextManagerKind, E as ContextSnapshot, F as ContextSource, H as ContextSourceStatus, I as Cron, J as CronCreateOptions, K as CronGetOptions, N as CronJob, O as CronJobStatus, Q as CronListOptions, R as CronOperationOptions, T as CronRunOptions, U as CronRuntime, V as CronSchedulerStatus, W as CronStartOptions, X as GoalEvent, Y as GoalOptions, Z as GoalResult, _ as InvalidateCacheOptions, $ as MemoryAdapter, a0 as MemoryAdapterCapabilities, a1 as MemoryFact, a2 as MemoryProviderHandle, a3 as MemoryProviderInitOptions, a4 as MemoryRevision, a5 as MemoryToolSchema, a6 as MemoryTurnMessage, a7 as PersonalityPreset, a8 as ProviderCapability, a9 as ProviderRoute, aa as RecordSessionSummaryArgs, ab as ResolvedProviderRoute, ac as RunUntilIterator, ad as SDKAgentPlugins, ae as SDKAgentSkills, af as SDKArtifact, ag as SDKContextManager, ah as SDKPluginMetadata, ai as SDKProvidersManager, aj as SettingSource, ak as SystemPromptContext, al as SystemPromptMemoryFact, am as SystemPromptSkillRef, an as TelemetrySettings } from './cron-DFG9-W17.cjs';
5
5
  import { R as RunResult, M as ModelSelection, C as CustomTool, a as McpServerConfig, b as Run, S as SDKMessage } from './run-DrwUpFxZ.cjs';
6
6
  export { A as AgentConversationTurn, c as AssistantMessage, d as ConversationStep, e as ConversationTurn, f as CostBreakdown, g as CostSource, h as CostStatus, I as InteractionUpdate, i as McpAuthConfig, j as McpHttpServerConfig, k as McpOAuthConfig, l as McpStdioServerConfig, m as ModelParameterValue, P as PartialToolCallUpdate, n as RunErrorDetail, o as RunGitInfo, p as RunOperation, q as RunStatus, r as SDKAssistantMessage, s as SDKImage, t as SDKImageDimension, u as SDKObjectDelta, v as SDKRequestMessage, w as SDKStatusMessage, x as SDKSystemMessage, y as SDKTaskMessage, z as SDKThinkingMessage, B as SDKToolUseMessage, D as SDKUserMessage, E as SDKUserMessageEvent, F as SendOptions, G as ShellCommand, H as ShellConversationTurn, J as ShellOutput, K as ShellOutputDeltaUpdate, L as StepCompletedUpdate, N as StepStartedUpdate, O as SummaryCompletedUpdate, Q as SummaryStartedUpdate, T as SummaryUpdate, U as TextBlock, V as TextDeltaUpdate, W as ThinkingCompletedUpdate, X as ThinkingDeltaUpdate, Y as ThinkingMessage, Z as TokenDeltaUpdate, _ as TokenUsage, $ as ToolCall, a0 as ToolCallCompletedUpdate, a1 as ToolCallStartedUpdate, a2 as ToolResult, a3 as ToolUseBlock, a4 as TurnEndedUpdate, a5 as UserMessage, a6 as UserMessageAppendedUpdate } from './run-DrwUpFxZ.cjs';
7
7
  import * as zod from 'zod';
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { T as TheokitAgentError, B as BudgetOptions, a as BudgetHandle, b as BudgetSnapshot } from './errors-DV9e0rcp.js';
2
2
  export { A as AgentDisposedError, c as AgentRunError, d as AgentRunErrorCode, e as AuthenticationError, f as BudgetExceedEvent, g as BudgetExceededError, h as BudgetLimit, i as BudgetMode, j as BudgetScope, k as BudgetThresholdEvent, l as BudgetWindow, C as ConfigurationError, E as ErrorCode, m as ErrorMetadata, I as IntegrationNotConnectedError, n as InvalidTaskIdError, M as MemoryAdapterError, o as MemoryAdapterErrorCode, N as NetworkError, R as RateLimitError, p as TaskNotFoundError, U as UnknownAgentError, q as UnsupportedBudgetOperationError, r as UnsupportedRunOperationError, s as UnsupportedTaskOperationError } from './errors-DV9e0rcp.js';
3
- import { A as AgentOptions, L as LocalOptions, P as ProviderRoutingSettings, S as SystemPromptResolver, C as CloudOptions, M as MemorySettings, a as AgentDefinition, b as ContextSettings, c as PluginsSettings, d as SkillsSettings, e as SDKAgent, f as ListAgentsOptions, g as ListResult, h as SDKAgentInfo, G as GetAgentOptions, i as ListRunsOptions, j as GetRunOptions, k as AgentOperationOptions, l as ConversationStorageAdapter, m as StoredMessage, n as MemoryContext, B as BudgetTracker, o as MemoryProvider, p as MemoryId, q as SDKProvider } from './cron-Ci_NUkUj.js';
4
- export { r as ActiveMemoryPassArgs, s as ActiveMemoryPassResult, t as AgentMemory, u as BudgetCheck, v as BudgetTotal, w as BudgetUsageEvent, x as CloudEnv, y as CloudRepo, z as ContextBudget, D as ContextManagerKind, E as ContextSnapshot, F as ContextSource, H as ContextSourceStatus, I as Cron, J as CronCreateOptions, K as CronGetOptions, N as CronJob, O as CronJobStatus, Q as CronListOptions, R as CronOperationOptions, T as CronRunOptions, U as CronRuntime, V as CronSchedulerStatus, W as CronStartOptions, X as GoalEvent, Y as GoalOptions, Z as GoalResult, _ as InvalidateCacheOptions, $ as MemoryAdapter, a0 as MemoryAdapterCapabilities, a1 as MemoryFact, a2 as MemoryProviderHandle, a3 as MemoryProviderInitOptions, a4 as MemoryRevision, a5 as MemoryToolSchema, a6 as MemoryTurnMessage, a7 as PersonalityPreset, a8 as ProviderCapability, a9 as ProviderRoute, aa as RecordSessionSummaryArgs, ab as ResolvedProviderRoute, ac as RunUntilIterator, ad as SDKAgentPlugins, ae as SDKAgentSkills, af as SDKArtifact, ag as SDKContextManager, ah as SDKPluginMetadata, ai as SDKProvidersManager, aj as SettingSource, ak as SystemPromptContext, al as SystemPromptMemoryFact, am as SystemPromptSkillRef, an as TelemetrySettings } from './cron-Ci_NUkUj.js';
3
+ import { A as AgentOptions, L as LocalOptions, P as ProviderRoutingSettings, S as SystemPromptResolver, C as CloudOptions, M as MemorySettings, a as AgentDefinition, b as ContextSettings, c as PluginsSettings, d as SkillsSettings, e as SDKAgent, f as ListAgentsOptions, g as ListResult, h as SDKAgentInfo, G as GetAgentOptions, i as ListRunsOptions, j as GetRunOptions, k as AgentOperationOptions, l as ConversationStorageAdapter, m as StoredMessage, n as MemoryContext, B as BudgetTracker, o as MemoryProvider, p as MemoryId, q as SDKProvider } from './cron-Bj8-Aq1O.js';
4
+ export { r as ActiveMemoryPassArgs, s as ActiveMemoryPassResult, t as AgentMemory, u as BudgetCheck, v as BudgetTotal, w as BudgetUsageEvent, x as CloudEnv, y as CloudRepo, z as ContextBudget, D as ContextManagerKind, E as ContextSnapshot, F as ContextSource, H as ContextSourceStatus, I as Cron, J as CronCreateOptions, K as CronGetOptions, N as CronJob, O as CronJobStatus, Q as CronListOptions, R as CronOperationOptions, T as CronRunOptions, U as CronRuntime, V as CronSchedulerStatus, W as CronStartOptions, X as GoalEvent, Y as GoalOptions, Z as GoalResult, _ as InvalidateCacheOptions, $ as MemoryAdapter, a0 as MemoryAdapterCapabilities, a1 as MemoryFact, a2 as MemoryProviderHandle, a3 as MemoryProviderInitOptions, a4 as MemoryRevision, a5 as MemoryToolSchema, a6 as MemoryTurnMessage, a7 as PersonalityPreset, a8 as ProviderCapability, a9 as ProviderRoute, aa as RecordSessionSummaryArgs, ab as ResolvedProviderRoute, ac as RunUntilIterator, ad as SDKAgentPlugins, ae as SDKAgentSkills, af as SDKArtifact, ag as SDKContextManager, ah as SDKPluginMetadata, ai as SDKProvidersManager, aj as SettingSource, ak as SystemPromptContext, al as SystemPromptMemoryFact, am as SystemPromptSkillRef, an as TelemetrySettings } from './cron-Bj8-Aq1O.js';
5
5
  import { R as RunResult, M as ModelSelection, C as CustomTool, a as McpServerConfig, b as Run, S as SDKMessage } from './run-DrwUpFxZ.js';
6
6
  export { A as AgentConversationTurn, c as AssistantMessage, d as ConversationStep, e as ConversationTurn, f as CostBreakdown, g as CostSource, h as CostStatus, I as InteractionUpdate, i as McpAuthConfig, j as McpHttpServerConfig, k as McpOAuthConfig, l as McpStdioServerConfig, m as ModelParameterValue, P as PartialToolCallUpdate, n as RunErrorDetail, o as RunGitInfo, p as RunOperation, q as RunStatus, r as SDKAssistantMessage, s as SDKImage, t as SDKImageDimension, u as SDKObjectDelta, v as SDKRequestMessage, w as SDKStatusMessage, x as SDKSystemMessage, y as SDKTaskMessage, z as SDKThinkingMessage, B as SDKToolUseMessage, D as SDKUserMessage, E as SDKUserMessageEvent, F as SendOptions, G as ShellCommand, H as ShellConversationTurn, J as ShellOutput, K as ShellOutputDeltaUpdate, L as StepCompletedUpdate, N as StepStartedUpdate, O as SummaryCompletedUpdate, Q as SummaryStartedUpdate, T as SummaryUpdate, U as TextBlock, V as TextDeltaUpdate, W as ThinkingCompletedUpdate, X as ThinkingDeltaUpdate, Y as ThinkingMessage, Z as TokenDeltaUpdate, _ as TokenUsage, $ as ToolCall, a0 as ToolCallCompletedUpdate, a1 as ToolCallStartedUpdate, a2 as ToolResult, a3 as ToolUseBlock, a4 as TurnEndedUpdate, a5 as UserMessage, a6 as UserMessageAppendedUpdate } from './run-DrwUpFxZ.js';
7
7
  import * as zod from 'zod';
package/dist/index.js CHANGED
@@ -836,7 +836,7 @@ var init_markdown_store = __esm({
836
836
  }
837
837
  });
838
838
 
839
- // src/internal/runtime/yaml-frontmatter.ts
839
+ // src/internal/runtime/context/yaml-frontmatter.ts
840
840
  function parseSimpleYaml(text) {
841
841
  const fields = {};
842
842
  for (const line of text.split(/\r?\n/)) {
@@ -860,7 +860,7 @@ function coerce(raw) {
860
860
  return raw;
861
861
  }
862
862
  var init_yaml_frontmatter = __esm({
863
- "src/internal/runtime/yaml-frontmatter.ts"() {
863
+ "src/internal/runtime/context/yaml-frontmatter.ts"() {
864
864
  }
865
865
  });
866
866
  async function loadMarkdownEntities(opts) {
@@ -1111,7 +1111,7 @@ function checkToolWhitelist(toolName) {
1111
1111
  }
1112
1112
  var toolWhitelistStore;
1113
1113
  var init_async_local_storage = __esm({
1114
- "src/internal/runtime/async-local-storage.ts"() {
1114
+ "src/internal/runtime/concurrency/async-local-storage.ts"() {
1115
1115
  toolWhitelistStore = new AsyncLocalStorage();
1116
1116
  }
1117
1117
  });
@@ -2490,7 +2490,7 @@ var init_local_agent_plugins = __esm({
2490
2490
  }
2491
2491
  });
2492
2492
 
2493
- // src/internal/runtime/run-until.ts
2493
+ // src/internal/runtime/lifecycle/run-until.ts
2494
2494
  var run_until_exports = {};
2495
2495
  __export(run_until_exports, {
2496
2496
  composeContinuation: () => composeContinuation,
@@ -2583,7 +2583,7 @@ Your last response was:
2583
2583
  ${lastResponse.slice(0, 1e3)}`;
2584
2584
  }
2585
2585
  var init_run_until = __esm({
2586
- "src/internal/runtime/run-until.ts"() {
2586
+ "src/internal/runtime/lifecycle/run-until.ts"() {
2587
2587
  }
2588
2588
  });
2589
2589
 
@@ -2694,16 +2694,16 @@ var init_judge_call = __esm({
2694
2694
  // src/internal/runtime/registry/agent-factory-registry.ts
2695
2695
  var agent_factory_registry_exports = {};
2696
2696
  __export(agent_factory_registry_exports, {
2697
- getAgentCreate: () => getAgentCreate,
2698
- setAgentCreate: () => setAgentCreate
2697
+ getAgentFacade: () => getAgentFacade,
2698
+ setAgentFacade: () => setAgentFacade
2699
2699
  });
2700
- function setAgentCreate(fn) {
2701
- registered3 = fn;
2700
+ function setAgentFacade(facade) {
2701
+ registered3 = facade;
2702
2702
  }
2703
- function getAgentCreate() {
2703
+ function getAgentFacade() {
2704
2704
  if (registered3 === void 0) {
2705
2705
  throw new Error(
2706
- "internal: Agent.create not registered. The `agent.ts` module must be loaded before LocalAgent.runUntil/fork are invoked."
2706
+ "internal: Agent facade not registered. The `agent.ts` module must be loaded before internal subsystems (LocalAgent.runUntil/fork, eval, scorers, cron) invoke it."
2707
2707
  );
2708
2708
  }
2709
2709
  return registered3;
@@ -2714,7 +2714,7 @@ var init_agent_factory_registry = __esm({
2714
2714
  }
2715
2715
  });
2716
2716
 
2717
- // src/internal/runtime/fork-agent.ts
2717
+ // src/internal/runtime/lifecycle/fork-agent.ts
2718
2718
  var fork_agent_exports = {};
2719
2719
  __export(fork_agent_exports, {
2720
2720
  filterMemoryPlugins: () => filterMemoryPlugins,
@@ -2774,7 +2774,7 @@ function extractUsage(result) {
2774
2774
  };
2775
2775
  }
2776
2776
  var init_fork_agent = __esm({
2777
- "src/internal/runtime/fork-agent.ts"() {
2777
+ "src/internal/runtime/lifecycle/fork-agent.ts"() {
2778
2778
  init_async_local_storage();
2779
2779
  init_local_agent_plugins();
2780
2780
  }
@@ -2797,7 +2797,7 @@ var init_task = __esm({
2797
2797
  }
2798
2798
  });
2799
2799
 
2800
- // src/internal/runtime/async-semaphore.ts
2800
+ // src/internal/runtime/concurrency/async-semaphore.ts
2801
2801
  function createSemaphore(permits) {
2802
2802
  if (!Number.isInteger(permits) || permits < 1) {
2803
2803
  throw new ConfigurationError(
@@ -2835,7 +2835,7 @@ function createSemaphore(permits) {
2835
2835
  };
2836
2836
  }
2837
2837
  var init_async_semaphore = __esm({
2838
- "src/internal/runtime/async-semaphore.ts"() {
2838
+ "src/internal/runtime/concurrency/async-semaphore.ts"() {
2839
2839
  init_errors();
2840
2840
  }
2841
2841
  });
@@ -5648,7 +5648,7 @@ init_errors();
5648
5648
  init_cwd_mutex();
5649
5649
  init_path_guard();
5650
5650
 
5651
- // src/internal/runtime/default-model.ts
5651
+ // src/internal/runtime/config/default-model.ts
5652
5652
  var DEFAULT_AGENTIC_MODEL_ID = "google/gemini-2.0-flash-001";
5653
5653
 
5654
5654
  // src/internal/runtime/registry/agent-registry-store.ts
@@ -5969,7 +5969,7 @@ async function flushRegistrySaves(cwd) {
5969
5969
  }
5970
5970
  }
5971
5971
 
5972
- // src/internal/runtime/system-prompt.ts
5972
+ // src/internal/runtime/system-prompt/system-prompt.ts
5973
5973
  async function resolveSystemPrompt(agent, override, ctx) {
5974
5974
  if (override !== void 0) return override;
5975
5975
  if (agent === void 0) return void 0;
@@ -8264,6 +8264,9 @@ function parseDecisionFromStdout(stdout) {
8264
8264
  return { decision: "allow" };
8265
8265
  }
8266
8266
 
8267
+ // src/internal/runtime/lifecycle/post-run-lifecycle.ts
8268
+ init_session_summary_writer();
8269
+
8267
8270
  // src/internal/runtime/memory/memory-path-selector.ts
8268
8271
  var PORT_MEMORY_PATH_ENV_VAR = "THEOKIT_PORT_MEMORY_PATH";
8269
8272
  function shouldUsePortMemoryPath() {
@@ -8286,9 +8289,6 @@ function resolveActiveMemorySummaryForSend(legacySummary, portPathEnabled) {
8286
8289
  return legacySummary;
8287
8290
  }
8288
8291
 
8289
- // src/internal/runtime/post-run-lifecycle.ts
8290
- init_session_summary_writer();
8291
-
8292
8292
  // src/internal/runtime/session/agent-session-store.ts
8293
8293
  init_atomic_write();
8294
8294
  init_security();
@@ -8547,7 +8547,7 @@ function clearSession(agentId) {
8547
8547
  sessions.delete(agentId);
8548
8548
  }
8549
8549
 
8550
- // src/internal/runtime/post-run-lifecycle.ts
8550
+ // src/internal/runtime/lifecycle/post-run-lifecycle.ts
8551
8551
  async function runPostRunLifecycle(inputs) {
8552
8552
  const {
8553
8553
  run,
@@ -8779,7 +8779,7 @@ var liveAgentRegistry = new LiveAgentRegistry();
8779
8779
  // src/internal/runtime/skills/subagents-loader.ts
8780
8780
  init_errors();
8781
8781
 
8782
- // src/internal/runtime/workspace-dir.ts
8782
+ // src/internal/runtime/config/workspace-dir.ts
8783
8783
  init_errors();
8784
8784
  async function readWorkspaceDir(root, errorCode, describe) {
8785
8785
  try {
@@ -9065,7 +9065,7 @@ var SystemPromptPipeline = class _SystemPromptPipeline {
9065
9065
  }
9066
9066
  };
9067
9067
 
9068
- // src/internal/runtime/validate-agent-options.ts
9068
+ // src/internal/runtime/validation/validate-agent-options.ts
9069
9069
  init_errors();
9070
9070
  function validateAgentOptions(options) {
9071
9071
  rejectProgrammaticHooks(options);
@@ -9260,6 +9260,71 @@ function validateMemory(options) {
9260
9260
  }
9261
9261
  }
9262
9262
 
9263
+ // src/internal/runtime/config/providers-manager.ts
9264
+ var ProvidersManagerImpl = class {
9265
+ constructor(model, providers, plugins) {
9266
+ this.model = model;
9267
+ this.providers = providers;
9268
+ this.plugins = plugins;
9269
+ }
9270
+ model;
9271
+ providers;
9272
+ plugins;
9273
+ routes() {
9274
+ const resolved = [];
9275
+ const modelProvider = providerFromModel(this.model);
9276
+ const seen = /* @__PURE__ */ new Set();
9277
+ if (this.providers?.routes !== void 0) {
9278
+ for (const route of this.providers.routes) {
9279
+ const resolvedRoute = resolveRoute(route, modelProvider, this.plugins);
9280
+ if (!seen.has(route.capability)) {
9281
+ seen.add(route.capability);
9282
+ resolved.push(resolvedRoute);
9283
+ }
9284
+ }
9285
+ }
9286
+ return Promise.resolve(resolved);
9287
+ }
9288
+ };
9289
+ function providerFromModel(model) {
9290
+ if (model === void 0) return void 0;
9291
+ const id = model.id;
9292
+ if (id.includes(":")) return id.split(":")[0];
9293
+ return void 0;
9294
+ }
9295
+ function resolveRoute(route, modelProvider, plugins) {
9296
+ if (route.capability === "chat" && modelProvider === route.provider) {
9297
+ const modelName = extractModelName(modelProvider, route);
9298
+ const base = {
9299
+ capability: route.capability,
9300
+ provider: route.provider,
9301
+ reason: "explicit-model-provider"
9302
+ };
9303
+ if (modelName !== void 0) base.model = modelName;
9304
+ return base;
9305
+ }
9306
+ if (plugins?.enabled !== void 0 && plugins.enabled.length > 0) {
9307
+ return {
9308
+ capability: route.capability,
9309
+ provider: route.provider,
9310
+ reason: "first-available-plugin-provider"
9311
+ };
9312
+ }
9313
+ return {
9314
+ capability: route.capability,
9315
+ provider: route.provider,
9316
+ reason: "explicit-route"
9317
+ };
9318
+ }
9319
+ function extractModelName(prefix, route) {
9320
+ if (route.model !== void 0) return route.model;
9321
+ return prefix === route.provider ? defaultModelForProvider(prefix) : void 0;
9322
+ }
9323
+ function defaultModelForProvider(provider) {
9324
+ if (provider === "anthropic") return "claude-3-7-sonnet";
9325
+ return void 0;
9326
+ }
9327
+
9263
9328
  // src/internal/runtime/context/context-manager.ts
9264
9329
  init_errors();
9265
9330
  init_markdown_config_loader();
@@ -10057,71 +10122,6 @@ async function loadPluginManifestFromMarkdown(pluginsRoot, folderName) {
10057
10122
  return metadata;
10058
10123
  }
10059
10124
 
10060
- // src/internal/runtime/providers-manager.ts
10061
- var ProvidersManagerImpl = class {
10062
- constructor(model, providers, plugins) {
10063
- this.model = model;
10064
- this.providers = providers;
10065
- this.plugins = plugins;
10066
- }
10067
- model;
10068
- providers;
10069
- plugins;
10070
- routes() {
10071
- const resolved = [];
10072
- const modelProvider = providerFromModel(this.model);
10073
- const seen = /* @__PURE__ */ new Set();
10074
- if (this.providers?.routes !== void 0) {
10075
- for (const route of this.providers.routes) {
10076
- const resolvedRoute = resolveRoute(route, modelProvider, this.plugins);
10077
- if (!seen.has(route.capability)) {
10078
- seen.add(route.capability);
10079
- resolved.push(resolvedRoute);
10080
- }
10081
- }
10082
- }
10083
- return Promise.resolve(resolved);
10084
- }
10085
- };
10086
- function providerFromModel(model) {
10087
- if (model === void 0) return void 0;
10088
- const id = model.id;
10089
- if (id.includes(":")) return id.split(":")[0];
10090
- return void 0;
10091
- }
10092
- function resolveRoute(route, modelProvider, plugins) {
10093
- if (route.capability === "chat" && modelProvider === route.provider) {
10094
- const modelName = extractModelName(modelProvider, route);
10095
- const base = {
10096
- capability: route.capability,
10097
- provider: route.provider,
10098
- reason: "explicit-model-provider"
10099
- };
10100
- if (modelName !== void 0) base.model = modelName;
10101
- return base;
10102
- }
10103
- if (plugins?.enabled !== void 0 && plugins.enabled.length > 0) {
10104
- return {
10105
- capability: route.capability,
10106
- provider: route.provider,
10107
- reason: "first-available-plugin-provider"
10108
- };
10109
- }
10110
- return {
10111
- capability: route.capability,
10112
- provider: route.provider,
10113
- reason: "explicit-route"
10114
- };
10115
- }
10116
- function extractModelName(prefix, route) {
10117
- if (route.model !== void 0) return route.model;
10118
- return prefix === route.provider ? defaultModelForProvider(prefix) : void 0;
10119
- }
10120
- function defaultModelForProvider(provider) {
10121
- if (provider === "anthropic") return "claude-3-7-sonnet";
10122
- return void 0;
10123
- }
10124
-
10125
10125
  // src/internal/runtime/skills/skills-manager.ts
10126
10126
  init_errors();
10127
10127
  init_path_guard();
@@ -10469,7 +10469,7 @@ var IterationBudget = class {
10469
10469
  }
10470
10470
  };
10471
10471
 
10472
- // src/internal/runtime/validate-response.ts
10472
+ // src/internal/runtime/validation/validate-response.ts
10473
10473
  function validateResponse(response) {
10474
10474
  const trimmed = response.content.trim();
10475
10475
  const toolCallsArr = Array.isArray(response.toolCalls) ? response.toolCalls : [];
@@ -10928,7 +10928,7 @@ function coerceArgsToSchema(args, schema) {
10928
10928
  return { value: out, changed };
10929
10929
  }
10930
10930
 
10931
- // src/internal/runtime/shell-tool.ts
10931
+ // src/internal/runtime/tools/shell-tool.ts
10932
10932
  async function runShell(options) {
10933
10933
  if (options.sandbox === true && isObviouslyUnsafe(options.command)) {
10934
10934
  return {
@@ -12143,10 +12143,10 @@ function registerBuiltins() {
12143
12143
  registerCatalogProviders();
12144
12144
  }
12145
12145
 
12146
- // src/internal/errors/mappers/anthropic.ts
12146
+ // src/internal/error-mappers/anthropic.ts
12147
12147
  init_errors();
12148
12148
 
12149
- // src/internal/errors/mappers/shared.ts
12149
+ // src/internal/error-mappers/shared.ts
12150
12150
  init_security();
12151
12151
  var RAW_MAX_BYTES = 2048;
12152
12152
  function parseRetryAfter(headers) {
@@ -12176,7 +12176,7 @@ function buildErrorMetadata(args) {
12176
12176
  };
12177
12177
  }
12178
12178
 
12179
- // src/internal/errors/mappers/anthropic.ts
12179
+ // src/internal/error-mappers/anthropic.ts
12180
12180
  function mapAnthropicError(args) {
12181
12181
  const { status, body, headers, endpoint } = args;
12182
12182
  const code = mapAnthropicStatusToCode(status, body);
@@ -12516,7 +12516,7 @@ function buildAnthropicBody(request) {
12516
12516
  // src/internal/llm/bedrock-anthropic.ts
12517
12517
  init_errors();
12518
12518
 
12519
- // src/internal/errors/mappers/bedrock.ts
12519
+ // src/internal/error-mappers/bedrock.ts
12520
12520
  init_errors();
12521
12521
  function classifyBedrockError(args, awsType, message) {
12522
12522
  if (args.status === 429 || awsType.includes("Throttling") || awsType.includes("TooManyRequests")) {
@@ -12653,7 +12653,7 @@ function buildBedrockBody(request) {
12653
12653
  init_credential_pool();
12654
12654
  init_credential_pool_context();
12655
12655
 
12656
- // src/internal/errors/mappers/openai-compatible.ts
12656
+ // src/internal/error-mappers/openai-compatible.ts
12657
12657
  init_errors();
12658
12658
  function mapOpenAICompatibleError(args) {
12659
12659
  const { providerId, status, body, headers, endpoint } = args;
@@ -12817,7 +12817,7 @@ function readOpenAiContent(body) {
12817
12817
  return void 0;
12818
12818
  }
12819
12819
 
12820
- // src/internal/errors/mappers/ollama.ts
12820
+ // src/internal/error-mappers/ollama.ts
12821
12821
  init_errors();
12822
12822
  function mapOllamaTransportError(args) {
12823
12823
  if (args.providerId !== "ollama") return void 0;
@@ -13467,7 +13467,7 @@ function abortError2(signal) {
13467
13467
  // src/internal/llm/vertex-anthropic.ts
13468
13468
  init_errors();
13469
13469
 
13470
- // src/internal/errors/mappers/vertex.ts
13470
+ // src/internal/error-mappers/vertex.ts
13471
13471
  init_errors();
13472
13472
  var VERTEX_RULES = [
13473
13473
  { test: (s, e) => s === 429 || e === "RESOURCE_EXHAUSTED", code: "rate_limit" },
@@ -15784,8 +15784,8 @@ function localAgentRunUntil(agent, goal, options) {
15784
15784
  async function* wrap() {
15785
15785
  const { runUntilImpl: runUntilImpl2 } = await Promise.resolve().then(() => (init_run_until(), run_until_exports));
15786
15786
  const { judgeCallImpl: judgeCallImpl2 } = await Promise.resolve().then(() => (init_judge_call(), judge_call_exports));
15787
- const { getAgentCreate: getAgentCreate2 } = await Promise.resolve().then(() => (init_agent_factory_registry(), agent_factory_registry_exports));
15788
- const create = getAgentCreate2();
15787
+ const { getAgentFacade: getAgentFacade2 } = await Promise.resolve().then(() => (init_agent_factory_registry(), agent_factory_registry_exports));
15788
+ const create = getAgentFacade2().create;
15789
15789
  const deps = {
15790
15790
  judge: async (ctx, opts) => judgeCallImpl2(ctx, opts, { create })
15791
15791
  };
@@ -15795,9 +15795,9 @@ function localAgentRunUntil(agent, goal, options) {
15795
15795
  }
15796
15796
  async function localAgentFork(parent, options) {
15797
15797
  const { forkAgentImpl: forkAgentImpl2 } = await Promise.resolve().then(() => (init_fork_agent(), fork_agent_exports));
15798
- const { getAgentCreate: getAgentCreate2 } = await Promise.resolve().then(() => (init_agent_factory_registry(), agent_factory_registry_exports));
15798
+ const { getAgentFacade: getAgentFacade2 } = await Promise.resolve().then(() => (init_agent_factory_registry(), agent_factory_registry_exports));
15799
15799
  const { withPersonalityContext: withPersonalityContext2 } = await Promise.resolve().then(() => (init_context(), context_exports));
15800
- const create = getAgentCreate2();
15800
+ const create = getAgentFacade2().create;
15801
15801
  return withPersonalityContext2(
15802
15802
  { slug: parent.personalitySlugSnapshot, isFork: true },
15803
15803
  () => forkAgentImpl2(parent, options, { create })
@@ -15818,7 +15818,7 @@ async function persistMemoryFactIfWritePrompt(workspaceCwd, memoryConfig, userTe
15818
15818
  // src/internal/runtime/local-agent/local-agent-send.ts
15819
15819
  init_errors();
15820
15820
 
15821
- // src/internal/runtime/abort-utils.ts
15821
+ // src/internal/runtime/concurrency/abort-utils.ts
15822
15822
  function anySignal(signals) {
15823
15823
  const filtered = signals.filter((s) => s !== void 0);
15824
15824
  if (filtered.length === 0) {
@@ -16847,7 +16847,13 @@ async function getOrCreateUncached(agentId, options) {
16847
16847
  throw err;
16848
16848
  }
16849
16849
  }
16850
- setAgentCreate((options) => Agent.create(options));
16850
+ setAgentFacade({
16851
+ create: (options) => Agent.create(options),
16852
+ prompt: (message, options) => Agent.prompt(message, options),
16853
+ get: (agentId) => Agent.get(agentId),
16854
+ resume: (agentId, options) => Agent.resume(agentId, options),
16855
+ batch: (prompts, options) => Agent.batch(prompts, options)
16856
+ });
16851
16857
 
16852
16858
  // src/agent-factory.ts
16853
16859
  function createAgentFactory(common) {
@@ -17285,6 +17291,7 @@ init_errors();
17285
17291
 
17286
17292
  // src/internal/cron/run-job.ts
17287
17293
  init_errors();
17294
+ init_agent_factory_registry();
17288
17295
  async function runCronJob(job) {
17289
17296
  if (job.agent !== void 0) return runWithEphemeralAgent(job.agent, job.message);
17290
17297
  if (job.agentId !== void 0) return runWithExistingAgent(job.agentId, job.message);
@@ -17293,18 +17300,18 @@ async function runCronJob(job) {
17293
17300
  });
17294
17301
  }
17295
17302
  async function runWithExistingAgent(agentId, message) {
17296
- const info = await Agent.get(agentId).catch(() => void 0);
17303
+ const info = await getAgentFacade().get(agentId).catch(() => void 0);
17297
17304
  if (info === void 0) {
17298
17305
  throw new UnknownAgentError(
17299
17306
  `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.`,
17300
17307
  { code: "agent_not_registered" }
17301
17308
  );
17302
17309
  }
17303
- const agent = await Agent.resume(agentId);
17310
+ const agent = await getAgentFacade().resume(agentId);
17304
17311
  return agent.send(message);
17305
17312
  }
17306
17313
  async function runWithEphemeralAgent(baseOptions, message) {
17307
- const agent = await Agent.create(baseOptions);
17314
+ const agent = await getAgentFacade().create(baseOptions);
17308
17315
  return agent.send(message);
17309
17316
  }
17310
17317