@theokit/agents 0.25.0 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import { ExecutionContext } from '@theokit/http';
2
- import { A as AgentOptions, T as ToolOptions, g as MainLoopMeta, a as ApprovalOptions, B as BudgetOptions, f as GatewayOptions, l as MemoryOptions, t as SkillsOptions, e as ContextWindowOptions, q as ProjectContextOptions, j as McpServersMap, b as CompactionDecoratorConfig, R as ReasoningEffort } from './skills-CLymniNy.js';
2
+ import { A as AgentOptions, T as ToolOptions, g as MainLoopMeta, a as ApprovalOptions, B as BudgetOptions, f as GatewayOptions, l as MemoryOptions, t as SkillsOptions, e as ContextWindowOptions, q as ProjectContextOptions, j as McpServersMap, b as CompactionDecoratorConfig, R as ReasoningEffort } from './skills-FcUdNDbn.js';
3
3
  import { SystemPromptResolver, SkillsSettings, ContextSettings, PluginsSettings, Plugin, ProviderRoutingSettings, AgentDefinition, BudgetTracker, ConversationStorageAdapter, CustomTool, ModelSelection } from '@theokit/sdk';
4
4
  import { RetryOptions } from '@theokit/sdk/retry';
5
5
  import { z } from 'zod';
@@ -140,6 +140,8 @@ interface CompiledAgentOptions {
140
140
  parseThinkTags?: boolean;
141
141
  /** Opt-in tool-dialect stripping declared via `@Agent({ stripToolDialect })` (theocode#32); strips leaked `<function=…></tool_call>` from text when true. */
142
142
  stripToolDialect?: boolean;
143
+ /** Opt-in leaked-dialect recovery declared via `@Agent({ recoverLeakedToolCalls })` (theokit#58); enables the SDK route's `extractToolCallsFromContent` so leaked tool calls EXECUTE when true. */
144
+ recoverLeakedToolCalls?: boolean;
143
145
  /** Static prompt OR a per-request {@link SystemPromptResolver} (V4-L.1, Axis-B). */
144
146
  systemPrompt?: string | SystemPromptResolver;
145
147
  tools: CompiledTool[];
@@ -434,6 +436,13 @@ interface RuntimeOverrides {
434
436
  * `<function=…></tool_call>` tool-call dialect out of the assistant text stream (theocode#32).
435
437
  */
436
438
  stripToolDialect?: boolean;
439
+ /**
440
+ * Per-run opt-in (`?? compiled.recoverLeakedToolCalls`): when true, enable the SDK chat route's
441
+ * `extractToolCallsFromContent` so a leaked Hermes `<function=…></tool_call>` dialect is recovered
442
+ * and EXECUTED (theokit#58). Sibling of {@link stripToolDialect}; has effect only when {@link providers}
443
+ * routes a provider.
444
+ */
445
+ recoverLeakedToolCalls?: boolean;
437
446
  /** Per-run cwd → `Agent.create({ local: { cwd } })` → `SystemPromptContext.cwd`. */
438
447
  cwd?: string;
439
448
  /**
package/dist/bridge.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export { A as AgentExecutionContext, b as AgentManifest, c as AgentManifestEntry, d as AgentManifestTool, e as AgentRoute, f as AgentRouteContext, g as AgentRunInfo, h as AgentStreamEvent, i as AgentWalkResult, j as AgentWarningCode, k as AgentsPluginOptions, l as ApprovalRequiredEvent, m as ArtifactChunkEvent, n as ArtifactStartEvent, B as BudgetExceededError, o as CheckpointSavedEvent, C as CompiledAgentOptions, p as CompiledContextWindow, a as CompiledTool, r as DelegateOptions, s as DelegationError, D as DelegationResult, t as DoneEvent, E as ErrorEvent, F as FileEditEvent, I as IterationEvent, G as RunStartedEvent, H as SdkMessage, J as Segment, K as StateUpdateEvent, S as StreamEvent, T as TextDeltaEvent, M as ThinkingEvent, N as ToolCallEvent, O as ToolResultEvent, P as ToolWalkResult, Q as ToolboxWalkResult, U as agentsPlugin, V as buildModelSelection, W as compileAgent, X as compileContextWindow, Y as compileProjectContext, Z as compileSkills, _ as compileTools, $ as createAgentExecutionContext, a0 as createSdkAgentStream, a1 as createThinkTagExtractor, a2 as delegate, a3 as extractThinkTagStream, a4 as generateAgentManifest, a5 as generateAgentRoutes, a6 as isAgentContext, a7 as isApprovalRequired, a8 as isDone, a9 as isError, aa as isTextDelta, ab as isToolCall, ac as isToolResult, ag as projectContextMetadataOnlyKnobs, aj as streamAgentResponse, ak as translateSdkEvent, al as validateUniqueRoutes, am as walkAgentMetadata } from './bridge-entry-DfwOnvUB.js';
1
+ export { A as AgentExecutionContext, b as AgentManifest, c as AgentManifestEntry, d as AgentManifestTool, e as AgentRoute, f as AgentRouteContext, g as AgentRunInfo, h as AgentStreamEvent, i as AgentWalkResult, j as AgentWarningCode, k as AgentsPluginOptions, l as ApprovalRequiredEvent, m as ArtifactChunkEvent, n as ArtifactStartEvent, B as BudgetExceededError, o as CheckpointSavedEvent, C as CompiledAgentOptions, p as CompiledContextWindow, a as CompiledTool, r as DelegateOptions, s as DelegationError, D as DelegationResult, t as DoneEvent, E as ErrorEvent, F as FileEditEvent, I as IterationEvent, G as RunStartedEvent, H as SdkMessage, J as Segment, K as StateUpdateEvent, S as StreamEvent, T as TextDeltaEvent, M as ThinkingEvent, N as ToolCallEvent, O as ToolResultEvent, P as ToolWalkResult, Q as ToolboxWalkResult, U as agentsPlugin, V as buildModelSelection, W as compileAgent, X as compileContextWindow, Y as compileProjectContext, Z as compileSkills, _ as compileTools, $ as createAgentExecutionContext, a0 as createSdkAgentStream, a1 as createThinkTagExtractor, a2 as delegate, a3 as extractThinkTagStream, a4 as generateAgentManifest, a5 as generateAgentRoutes, a6 as isAgentContext, a7 as isApprovalRequired, a8 as isDone, a9 as isError, aa as isTextDelta, ab as isToolCall, ac as isToolResult, ag as projectContextMetadataOnlyKnobs, aj as streamAgentResponse, ak as translateSdkEvent, al as validateUniqueRoutes, am as walkAgentMetadata } from './bridge-entry-SOr2jwm3.js';
2
2
  import '@theokit/http';
3
- import './skills-CLymniNy.js';
3
+ import './skills-FcUdNDbn.js';
4
4
  import '@theokit/sdk';
5
5
  import 'zod';
6
6
  import '@theokit/sdk/retry';
package/dist/bridge.js CHANGED
@@ -28,7 +28,7 @@ import {
28
28
  translateSdkEvent,
29
29
  validateUniqueRoutes,
30
30
  walkAgentMetadata
31
- } from "./chunk-DOEEZXSW.js";
31
+ } from "./chunk-R7LKDSBF.js";
32
32
  import "./chunk-GVPUUKKE.js";
33
33
  import "./chunk-7QVYU63E.js";
34
34
  export {
@@ -303,6 +303,7 @@ function compileAgent(walkResult, toolboxInstances = /* @__PURE__ */ new Map())
303
303
  reasoningEffort: walkResult.agentConfig.reasoningEffort,
304
304
  parseThinkTags: walkResult.agentConfig.parseThinkTags,
305
305
  stripToolDialect: walkResult.agentConfig.stripToolDialect,
306
+ recoverLeakedToolCalls: walkResult.agentConfig.recoverLeakedToolCalls,
306
307
  systemPrompt: walkResult.agentConfig.systemPrompt,
307
308
  tools,
308
309
  agents,
@@ -551,7 +552,7 @@ function translateToolCallEvent(msg) {
551
552
  type: "tool_call",
552
553
  callId,
553
554
  toolName,
554
- input: msg.input ?? msg.arguments ?? {}
555
+ input: msg.args ?? msg.input ?? msg.arguments ?? {}
555
556
  }
556
557
  ];
557
558
  }
@@ -904,10 +905,23 @@ function realUsageDone(result, t0) {
904
905
  };
905
906
  }
906
907
  __name(realUsageDone, "realUsageDone");
907
- function buildExtraCreateOptions(overrides) {
908
+ function withLeakedDialectRecovery(providers) {
909
+ return {
910
+ ...providers,
911
+ routes: providers.routes.map((route) => ({
912
+ ...route,
913
+ extractToolCallsFromContent: true
914
+ }))
915
+ };
916
+ }
917
+ __name(withLeakedDialectRecovery, "withLeakedDialectRecovery");
918
+ function buildExtraCreateOptions(overrides, compiled) {
919
+ const recoverLeakedToolCalls = overrides.recoverLeakedToolCalls ?? compiled.recoverLeakedToolCalls ?? false;
908
920
  const extra = {};
909
921
  if (overrides.plugins !== void 0) extra.plugins = overrides.plugins;
910
- if (overrides.providers !== void 0) extra.providers = overrides.providers;
922
+ if (overrides.providers !== void 0) {
923
+ extra.providers = recoverLeakedToolCalls ? withLeakedDialectRecovery(overrides.providers) : overrides.providers;
924
+ }
911
925
  if (overrides.agents !== void 0) extra.agents = overrides.agents;
912
926
  if (overrides.budgetTracker !== void 0) extra.budgetTracker = overrides.budgetTracker;
913
927
  return extra;
@@ -1088,7 +1102,7 @@ function createSdkAgentStream(compiled, compiledTools, apiKey, overrides = {}) {
1088
1102
  ...m8.local,
1089
1103
  cwd: overrides.cwd
1090
1104
  };
1091
- const extra = buildExtraCreateOptions(overrides);
1105
+ const extra = buildExtraCreateOptions(overrides, compiled);
1092
1106
  storage ??= new InMemoryConversationStorage();
1093
1107
  if (applied.length > 0) {
1094
1108
  console.debug("[THEO_AGENT_M8_RUNTIME_APPLIED]", {
@@ -1571,6 +1585,7 @@ var AgentRunner = class {
1571
1585
  reasoningEffort: opts.reasoningEffort,
1572
1586
  parseThinkTags: opts.parseThinkTags,
1573
1587
  stripToolDialect: opts.stripToolDialect,
1588
+ recoverLeakedToolCalls: opts.recoverLeakedToolCalls,
1574
1589
  cwd: opts.cwd,
1575
1590
  plugins: opts.plugins,
1576
1591
  providers: opts.providers,
@@ -1874,4 +1889,4 @@ export {
1874
1889
  generateAgentManifest,
1875
1890
  agentsPlugin
1876
1891
  };
1877
- //# sourceMappingURL=chunk-DOEEZXSW.js.map
1892
+ //# sourceMappingURL=chunk-R7LKDSBF.js.map