@theokit/agents 4.25.1 → 4.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.
@@ -900,6 +900,16 @@ declare function isAgentDefinition(value: unknown): value is AgentDefinition;
900
900
  */
901
901
  declare function compileAgentDefinition(def: AgentDefinition): CompiledAgentOptions;
902
902
 
903
+ /**
904
+ * Uma definição, ou um THUNK que a produz por sessão.
905
+ *
906
+ * M91 — a linha do `apiKey` logo abaixo já aceitava thunk desde o M74, adicionada por **exatamente**
907
+ * esta razão. A assimetria tinha uma linha de largura e custava caro: com a forma objeto, trust, hooks,
908
+ * skills e MCP ficam congelados no load do módulo. Num processo `theokit acp` que uma IDE mantém aberto
909
+ * por horas, isso reintroduz a obsolescência que o M67 removeu ao mover a construção para o entry point.
910
+ */
911
+ type DefinicaoOuThunk = AgentDefinition | ((sessionId: string) => AgentDefinition | Promise<AgentDefinition>);
912
+
903
913
  /**
904
914
  * SDK Adapter — bridges @theokit/agents decorators → @theokit/sdk runtime.
905
915
  *
@@ -1001,9 +1011,30 @@ declare function createSdkAgentStream(compiled: CompiledAgentOptions, compiledTo
1001
1011
  * `Agent.getOrCreate` returns the real SDK agent — this alias just types what {@link toAgentFactory}
1002
1012
  * hands back without re-exporting the full `@theokit/sdk` `Agent` type.
1003
1013
  */
1014
+ /**
1015
+ * O mínimo que um turno devolve. Estrutural de propósito (ADR-2 do M91).
1016
+ *
1017
+ * Re-exportar o tipo do SDK amarraria a assinatura pública desta camada à dele — o oposto do que a
1018
+ * fronteira existe para fazer, e a mesma razão pela qual `SdkAgentHandle` já era um alias em vez de um
1019
+ * re-export.
1020
+ */
1021
+ interface SdkTurnHandle {
1022
+ wait: () => Promise<unknown>;
1023
+ }
1024
+ /** Opções por turno. Aberto por ora — o SDK aceita mais do que a camada precisa declarar. */
1025
+ type SdkSendOptions = Record<string, unknown>;
1004
1026
  interface SdkAgentHandle {
1005
1027
  readonly agentId: string;
1006
- send: (msg: string, opts?: unknown) => unknown;
1028
+ /**
1029
+ * M91 — era `(msg: string, opts?: unknown) => unknown`.
1030
+ *
1031
+ * O `unknown` de retorno custava ao consumidor um módulo inteiro: `agents/lib/goal/runner-facade.ts`,
1032
+ * 38 linhas cujo único trabalho era re-estreitar este retorno para o contrato `send → wait` que o
1033
+ * loop de goal exige. O docstring daquele módulo registra que, antes dele, o chamador escrevia
1034
+ * `as never` — e que **foi sob essa capa que a superfície goal divergiu do agente real por vários
1035
+ * milestones**. A camada sempre soube a forma; ela só não a declarava.
1036
+ */
1037
+ send: (msg: string, opts?: SdkSendOptions) => SdkTurnHandle;
1007
1038
  dispose: () => Promise<void>;
1008
1039
  }
1009
1040
  /**
@@ -1019,7 +1050,7 @@ interface SdkAgentHandle {
1019
1050
  * `Agent.create`; a raw `SDKAgent` from this factory does not auto-pause gated tools — the serving
1020
1051
  * surface (e.g. the ACP client) owns approval. Tools still execute; they are simply not HITL-gated here.
1021
1052
  */
1022
- declare function toAgentFactory(def: AgentDefinition, opts: {
1053
+ declare function toAgentFactory(def: DefinicaoOuThunk, opts: {
1023
1054
  apiKey: string | (() => string | Promise<string>);
1024
1055
  overrides?: RuntimeOverrides;
1025
1056
  }): (sessionId: string) => Promise<SdkAgentHandle>;
@@ -1505,12 +1536,37 @@ interface DelegationResult {
1505
1536
  */
1506
1537
  finishReason?: LoopFinishReason;
1507
1538
  }
1508
- declare class BudgetExceededError extends Error {
1539
+ /**
1540
+ * Orçamento de DELEGAÇÃO estourado — custo em dólares de um agente delegado.
1541
+ *
1542
+ * ## Por que o nome mudou no M91
1543
+ *
1544
+ * Chamava-se `BudgetExceededError` e **sombreava** a classe homônima do SDK, que é de outro domínio:
1545
+ * orçamento de JANELA de contexto (`budgetName`/`window`/`mode`) contra orçamento de DELEGAÇÃO
1546
+ * (`agentName`/`actualCost`). Como o consumidor tem regra inquebrável de nunca importar `@theokit/sdk`
1547
+ * direto, ele **nunca conseguia alcançar a do SDK** — e um `instanceof` contra este barril casava
1548
+ * silenciosamente com o domínio errado.
1549
+ *
1550
+ * É o modo de falha que o M73 documentou em `auth-parity.test.ts`: quando duas classes competem pelo
1551
+ * mesmo nome, nenhum teste de comportamento fica vermelho — só o `toBe` de identidade pega.
1552
+ *
1553
+ * `subpath-coverage.test.ts` registrava a colisão como `lacuna` de `./errors`, com a razão escrita e o
1554
+ * reconhecimento de que renomear era breaking e estava fora do escopo do M78. O M91 pagou a conta.
1555
+ */
1556
+ declare class DelegationBudgetExceededError extends Error {
1509
1557
  readonly agentName: string;
1510
1558
  readonly actualCost: number;
1511
1559
  readonly budgetLimit: number;
1512
1560
  constructor(agentName: string, actualCost: number, budgetLimit: number);
1513
1561
  }
1562
+ /**
1563
+ * @deprecated Use {@link DelegationBudgetExceededError}. Alias mantido por uma major para não quebrar
1564
+ * quem captura pelo nome antigo; é a **mesma** classe, não uma cópia — `instanceof` continua valendo
1565
+ * nos dois sentidos, e um teste de identidade referencial (`toBe`) trava isso.
1566
+ */
1567
+ declare const BudgetExceededError: typeof DelegationBudgetExceededError;
1568
+ /** @deprecated Use {@link DelegationBudgetExceededError}. */
1569
+ type BudgetExceededError = DelegationBudgetExceededError;
1514
1570
  declare class DelegationError extends Error {
1515
1571
  readonly agentName: string;
1516
1572
  readonly cause: unknown;
@@ -2109,4 +2165,4 @@ declare function agentsPlugin(opts: AgentsPluginOptions): {
2109
2165
  register(app: PluginApp): void;
2110
2166
  };
2111
2167
 
2112
- export { type DoneEvent as $, type ApprovalOptions as A, type ApiErrorPolicy as B, type CompiledAgentOptions as C, type DelegationResult as D, type ApprovalRequiredEvent as E, type ArtifactChunkEvent as F, type Guardrail as G, type HumanInTheLoopOptions as H, type ArtifactStartEvent as I, type BackgroundDelegation as J, type BeforeToolCallContext as K, type LoopStrategy as L, type MainLoopMeta as M, BudgetExceededError as N, type BudgetOptions as O, type CheckpointSavedEvent as P, type CompiledContextWindow as Q, type ReflectionStrategy as R, type StreamEvent as S, type ToolOptions as T, ContextualTool as U, CostBudgetExceededError as V, DEFAULT_MAX_ITERATIONS as W, type DefineAgentConfig as X, type DelegateFn as Y, type DelegateOptions as Z, DelegationError as _, type CompiledTool as a, generateAgentManifest as a$, type ErrorEvent as a0, type FileEditEvent as a1, type GuardrailAction as a2, type GuardrailPhase as a3, type GuardrailResult as a4, GuardrailViolationError as a5, type HookHandlers as a6, type InferAgentInput as a7, type InferAgentToolNames as a8, type IterationEvent as a9, type ThinkingEvent as aA, type TimeoutAction as aB, type ToolCallEvent as aC, type ToolCallVeto as aD, type ToolHooks as aE, type ToolHooksPlugin as aF, type ToolResultEvent as aG, type ToolWalkResult as aH, type ToolboxOptions as aI, type ToolboxWalkResult as aJ, agentsPlugin as aK, buildModelSelection as aL, compileAgentDefinition as aM, compileAgentModule as aN, compileContextWindow as aO, compileProjectContext as aP, compileSkills as aQ, compileTools as aR, createAgentExecutionContext as aS, createApiErrorHandler as aT, createSdkAgentStream as aU, createThinkTagExtractor as aV, createToolHooksPlugin as aW, delegate as aX, delegateBackground as aY, delegateWithScoring as aZ, extractThinkTagStream as a_, type LLMCallContext as aa, type LoopFinishReason as ab, type LoopOutcome as ac, type LoopStrategyConfig as ad, type MainLoopOptions as ae, type McpApprovalSpec as af, type McpRegistryConfig as ag, type McpRequestContext as ah, type McpSelection as ai, type PartialToolCallEvent as aj, type PolicyHandler as ak, type ProcessInputContext as al, type ReflectionContext as am, type ReflectionResult as an, type ReflectionStrategyConfig as ao, type RunStartedEvent as ap, type ScoreVerdict as aq, type ScoredDelegation as ar, type Scorer as as, type SdkAgentHandle as at, type SdkMessage as au, type Segment as av, type SkillsRequestContext as aw, type SkillsSelection as ax, type StateUpdateEvent as ay, type TextDeltaEvent as az, type ReasoningEffort as b, generateAgentRoutes as b0, isAgentContext as b1, isAgentDefinition as b2, isApprovalRequired as b3, isDone as b4, isError as b5, isPartialToolCall as b6, isTextDelta as b7, isToolCall as b8, isToolResult as b9, ladderReflectionStrategy as ba, loopStrategyConfigSchema as bb, mcpRegistry as bc, mcpToolApprovals as bd, noopReflectionStrategy as be, presentUIMessageStream as bf, projectContextMetadataOnlyKnobs as bg, reflectionStrategyConfigSchema as bh, resolveEnabledSkills as bi, resolveLoopStrategy as bj, resolveMcpServers as bk, runWithApiErrorHandling as bl, streamAgentResponse as bm, toAgentFactory as bn, translateSdkEvent as bo, type RoundStreamFactory as c, type ContextWindowOptions as d, type SkillsOptions as e, type AgentManifestEntry as f, type HitlDecision as g, AGENT_BRAND as h, type AfterToolCallContext as i, AgentBuilder as j, type AgentDefinition as k, AgentDefinitionError as l, type AgentExecutionContext as m, type AgentManifest as n, type AgentManifestSource as o, type AgentManifestTool as p, type AgentOptions as q, type AgentRoute as r, streamAgentUIMessages as s, type AgentRouteContext as t, type AgentRunInfo as u, type AgentStreamEvent as v, type AgentTurnMetadata as w, type AgentsPluginOptions as x, type ApiErrorContext as y, type ApiErrorDecision as z };
2168
+ export { BudgetExceededError as $, type ApprovalOptions as A, type ApiErrorPolicy as B, type CompiledAgentOptions as C, type DelegationResult as D, type ApprovalRequiredEvent as E, type ArtifactChunkEvent as F, type Guardrail as G, type HumanInTheLoopOptions as H, type ArtifactStartEvent as I, type BackgroundDelegation as J, type BeforeToolCallContext as K, type LoopStrategy as L, type MainLoopMeta as M, type BudgetOptions as N, type CheckpointSavedEvent as O, type CompiledContextWindow as P, ContextualTool as Q, type ReflectionStrategy as R, type StreamEvent as S, type ToolOptions as T, CostBudgetExceededError as U, DEFAULT_MAX_ITERATIONS as V, type DefineAgentConfig as W, type DefinicaoOuThunk as X, type DelegateFn as Y, type DelegateOptions as Z, DelegationBudgetExceededError as _, type CompiledTool as a, delegate as a$, DelegationError as a0, type DoneEvent as a1, type ErrorEvent as a2, type FileEditEvent as a3, type GuardrailAction as a4, type GuardrailPhase as a5, type GuardrailResult as a6, GuardrailViolationError as a7, type HookHandlers as a8, type InferAgentInput as a9, type SkillsRequestContext as aA, type SkillsSelection as aB, type StateUpdateEvent as aC, type TextDeltaEvent as aD, type ThinkingEvent as aE, type TimeoutAction as aF, type ToolCallEvent as aG, type ToolCallVeto as aH, type ToolHooks as aI, type ToolHooksPlugin as aJ, type ToolResultEvent as aK, type ToolWalkResult as aL, type ToolboxOptions as aM, type ToolboxWalkResult as aN, agentsPlugin as aO, buildModelSelection as aP, compileAgentDefinition as aQ, compileAgentModule as aR, compileContextWindow as aS, compileProjectContext as aT, compileSkills as aU, compileTools as aV, createAgentExecutionContext as aW, createApiErrorHandler as aX, createSdkAgentStream as aY, createThinkTagExtractor as aZ, createToolHooksPlugin as a_, type InferAgentToolNames as aa, type IterationEvent as ab, type LLMCallContext as ac, type LoopFinishReason as ad, type LoopOutcome as ae, type LoopStrategyConfig as af, type MainLoopOptions as ag, type McpApprovalSpec as ah, type McpRegistryConfig as ai, type McpRequestContext as aj, type McpSelection as ak, type PartialToolCallEvent as al, type PolicyHandler as am, type ProcessInputContext as an, type ReflectionContext as ao, type ReflectionResult as ap, type ReflectionStrategyConfig as aq, type RunStartedEvent as ar, type ScoreVerdict as as, type ScoredDelegation as at, type Scorer as au, type SdkAgentHandle as av, type SdkMessage as aw, type SdkSendOptions as ax, type SdkTurnHandle as ay, type Segment as az, type ReasoningEffort as b, delegateBackground as b0, delegateWithScoring as b1, extractThinkTagStream as b2, generateAgentManifest as b3, generateAgentRoutes as b4, isAgentContext as b5, isAgentDefinition as b6, isApprovalRequired as b7, isDone as b8, isError as b9, isPartialToolCall as ba, isTextDelta as bb, isToolCall as bc, isToolResult as bd, ladderReflectionStrategy as be, loopStrategyConfigSchema as bf, mcpRegistry as bg, mcpToolApprovals as bh, noopReflectionStrategy as bi, presentUIMessageStream as bj, projectContextMetadataOnlyKnobs as bk, reflectionStrategyConfigSchema as bl, resolveEnabledSkills as bm, resolveLoopStrategy as bn, resolveMcpServers as bo, runWithApiErrorHandling as bp, streamAgentResponse as bq, toAgentFactory as br, translateSdkEvent as bs, type RoundStreamFactory as c, type ContextWindowOptions as d, type SkillsOptions as e, type AgentManifestEntry as f, type HitlDecision as g, AGENT_BRAND as h, type AfterToolCallContext as i, AgentBuilder as j, type AgentDefinition as k, AgentDefinitionError as l, type AgentExecutionContext as m, type AgentManifest as n, type AgentManifestSource as o, type AgentManifestTool as p, type AgentOptions as q, type AgentRoute as r, streamAgentUIMessages as s, type AgentRouteContext as t, type AgentRunInfo as u, type AgentStreamEvent as v, type AgentTurnMetadata as w, type AgentsPluginOptions as x, type ApiErrorContext as y, type ApiErrorDecision as z };
package/dist/bridge.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { h as AGENT_BRAND, i as AfterToolCallContext, j as AgentBuilder, k as AgentDefinition, l as AgentDefinitionError, m as AgentExecutionContext, n as AgentManifest, f as AgentManifestEntry, o as AgentManifestSource, p as AgentManifestTool, r as AgentRoute, t as AgentRouteContext, u as AgentRunInfo, v as AgentStreamEvent, w as AgentTurnMetadata, x as AgentsPluginOptions, y as ApiErrorContext, z as ApiErrorDecision, B as ApiErrorPolicy, E as ApprovalRequiredEvent, F as ArtifactChunkEvent, I as ArtifactStartEvent, J as BackgroundDelegation, K as BeforeToolCallContext, N as BudgetExceededError, P as CheckpointSavedEvent, C as CompiledAgentOptions, Q as CompiledContextWindow, a as CompiledTool, U as ContextualTool, X as DefineAgentConfig, Y as DelegateFn, Z as DelegateOptions, _ as DelegationError, D as DelegationResult, $ as DoneEvent, a0 as ErrorEvent, a1 as FileEditEvent, a7 as InferAgentInput, a8 as InferAgentToolNames, a9 as IterationEvent, aa as LLMCallContext, af as McpApprovalSpec, ag as McpRegistryConfig, ah as McpRequestContext, ai as McpSelection, aj as PartialToolCallEvent, al as ProcessInputContext, ap as RunStartedEvent, aq as ScoreVerdict, ar as ScoredDelegation, as as Scorer, at as SdkAgentHandle, au as SdkMessage, av as Segment, ay as StateUpdateEvent, S as StreamEvent, az as TextDeltaEvent, aA as ThinkingEvent, aC as ToolCallEvent, aD as ToolCallVeto, aE as ToolHooks, aF as ToolHooksPlugin, aG as ToolResultEvent, aH as ToolWalkResult, aJ as ToolboxWalkResult, aK as agentsPlugin, aL as buildModelSelection, aM as compileAgentDefinition, aN as compileAgentModule, aO as compileContextWindow, aP as compileProjectContext, aQ as compileSkills, aR as compileTools, aS as createAgentExecutionContext, aT as createApiErrorHandler, aU as createSdkAgentStream, aV as createThinkTagExtractor, aW as createToolHooksPlugin, aX as delegate, aY as delegateBackground, aZ as delegateWithScoring, a_ as extractThinkTagStream, a$ as generateAgentManifest, b0 as generateAgentRoutes, b1 as isAgentContext, b2 as isAgentDefinition, b3 as isApprovalRequired, b4 as isDone, b5 as isError, b6 as isPartialToolCall, b7 as isTextDelta, b8 as isToolCall, b9 as isToolResult, bc as mcpRegistry, bd as mcpToolApprovals, bf as presentUIMessageStream, bg as projectContextMetadataOnlyKnobs, bk as resolveMcpServers, bl as runWithApiErrorHandling, bm as streamAgentResponse, s as streamAgentUIMessages, bn as toAgentFactory, bo as translateSdkEvent } from './bridge-entry-Cq1aVJ_c.js';
1
+ export { h as AGENT_BRAND, i as AfterToolCallContext, j as AgentBuilder, k as AgentDefinition, l as AgentDefinitionError, m as AgentExecutionContext, n as AgentManifest, f as AgentManifestEntry, o as AgentManifestSource, p as AgentManifestTool, r as AgentRoute, t as AgentRouteContext, u as AgentRunInfo, v as AgentStreamEvent, w as AgentTurnMetadata, x as AgentsPluginOptions, y as ApiErrorContext, z as ApiErrorDecision, B as ApiErrorPolicy, E as ApprovalRequiredEvent, F as ArtifactChunkEvent, I as ArtifactStartEvent, J as BackgroundDelegation, K as BeforeToolCallContext, $ as BudgetExceededError, O as CheckpointSavedEvent, C as CompiledAgentOptions, P as CompiledContextWindow, a as CompiledTool, Q as ContextualTool, W as DefineAgentConfig, X as DefinicaoOuThunk, Y as DelegateFn, Z as DelegateOptions, _ as DelegationBudgetExceededError, a0 as DelegationError, D as DelegationResult, a1 as DoneEvent, a2 as ErrorEvent, a3 as FileEditEvent, a9 as InferAgentInput, aa as InferAgentToolNames, ab as IterationEvent, ac as LLMCallContext, ah as McpApprovalSpec, ai as McpRegistryConfig, aj as McpRequestContext, ak as McpSelection, al as PartialToolCallEvent, an as ProcessInputContext, ar as RunStartedEvent, as as ScoreVerdict, at as ScoredDelegation, au as Scorer, av as SdkAgentHandle, aw as SdkMessage, ax as SdkSendOptions, ay as SdkTurnHandle, az as Segment, aC as StateUpdateEvent, S as StreamEvent, aD as TextDeltaEvent, aE as ThinkingEvent, aG as ToolCallEvent, aH as ToolCallVeto, aI as ToolHooks, aJ as ToolHooksPlugin, aK as ToolResultEvent, aL as ToolWalkResult, aN as ToolboxWalkResult, aO as agentsPlugin, aP as buildModelSelection, aQ as compileAgentDefinition, aR as compileAgentModule, aS as compileContextWindow, aT as compileProjectContext, aU as compileSkills, aV as compileTools, aW as createAgentExecutionContext, aX as createApiErrorHandler, aY as createSdkAgentStream, aZ as createThinkTagExtractor, a_ as createToolHooksPlugin, a$ as delegate, b0 as delegateBackground, b1 as delegateWithScoring, b2 as extractThinkTagStream, b3 as generateAgentManifest, b4 as generateAgentRoutes, b5 as isAgentContext, b6 as isAgentDefinition, b7 as isApprovalRequired, b8 as isDone, b9 as isError, ba as isPartialToolCall, bb as isTextDelta, bc as isToolCall, bd as isToolResult, bg as mcpRegistry, bh as mcpToolApprovals, bj as presentUIMessageStream, bk as projectContextMetadataOnlyKnobs, bo as resolveMcpServers, bp as runWithApiErrorHandling, bq as streamAgentResponse, s as streamAgentUIMessages, br as toAgentFactory, bs as translateSdkEvent } from './bridge-entry-DMlHq9gR.js';
2
2
  import '@theokit/http';
3
3
  import '@theokit/sdk';
4
4
  import 'zod';
package/dist/bridge.js CHANGED
@@ -4,6 +4,7 @@ import {
4
4
  AgentDefinitionError,
5
5
  BudgetExceededError,
6
6
  ContextualTool,
7
+ DelegationBudgetExceededError,
7
8
  DelegationError,
8
9
  agentsPlugin,
9
10
  buildModelSelection,
@@ -43,7 +44,7 @@ import {
43
44
  streamAgentUIMessages,
44
45
  toAgentFactory,
45
46
  translateSdkEvent
46
- } from "./chunk-2L5DI75P.js";
47
+ } from "./chunk-QEWP7GRM.js";
47
48
  import "./chunk-7QVYU63E.js";
48
49
  export {
49
50
  AGENT_BRAND,
@@ -51,6 +52,7 @@ export {
51
52
  AgentDefinitionError,
52
53
  BudgetExceededError,
53
54
  ContextualTool,
55
+ DelegationBudgetExceededError,
54
56
  DelegationError,
55
57
  agentsPlugin,
56
58
  buildModelSelection,
@@ -762,6 +762,26 @@ function debugLog(marker, data) {
762
762
  }
763
763
  __name(debugLog, "debugLog");
764
764
 
765
+ // src/bridge/definicao-ou-thunk.ts
766
+ function projetar(def, overrides) {
767
+ const compiled = compileAgentDefinition(def);
768
+ return {
769
+ compiled,
770
+ model: overrides.model ?? compiled.model ?? "openai/gpt-4o-mini",
771
+ reasoningEffort: overrides.reasoningEffort ?? compiled.reasoningEffort,
772
+ runContext: overrides.runContext ?? compiled.runContext
773
+ };
774
+ }
775
+ __name(projetar, "projetar");
776
+ function resolverProjecao(def, overrides) {
777
+ if (typeof def === "function") {
778
+ return async (sessionId) => projetar(await def(sessionId), overrides);
779
+ }
780
+ const eager = projetar(def, overrides);
781
+ return () => Promise.resolve(eager);
782
+ }
783
+ __name(resolverProjecao, "resolverProjecao");
784
+
765
785
  // src/bridge/sdk-adapter-create-options.ts
766
786
  function assembleM8CreateOptions(compiled) {
767
787
  const options = {};
@@ -1286,12 +1306,10 @@ async function* streamSdkAgent(rt, compiled, sdkTools, opts) {
1286
1306
  }
1287
1307
  __name(streamSdkAgent, "streamSdkAgent");
1288
1308
  function toAgentFactory(def, opts) {
1289
- const compiled = compileAgentDefinition(def);
1290
1309
  const overrides = opts.overrides ?? {};
1291
- const model = overrides.model ?? compiled.model ?? "openai/gpt-4o-mini";
1292
- const reasoningEffort = overrides.reasoningEffort ?? compiled.reasoningEffort;
1293
- const runContext = overrides.runContext ?? compiled.runContext;
1310
+ const projetarPorSessao = resolverProjecao(def, overrides);
1294
1311
  return async (sessionId) => {
1312
+ const { compiled, model, reasoningEffort, runContext } = await projetarPorSessao(sessionId);
1295
1313
  const rt = await loadSdkRuntime();
1296
1314
  if (!rt) {
1297
1315
  throw new Error("[@theokit/agents] @theokit/sdk is not installed \u2014 run: pnpm add @theokit/sdk");
@@ -2549,18 +2567,19 @@ var noopReflectionStrategy = {
2549
2567
  };
2550
2568
 
2551
2569
  // src/bridge/delegation-types.ts
2552
- var BudgetExceededError = class extends Error {
2570
+ var DelegationBudgetExceededError = class extends Error {
2553
2571
  static {
2554
- __name(this, "BudgetExceededError");
2572
+ __name(this, "DelegationBudgetExceededError");
2555
2573
  }
2556
2574
  agentName;
2557
2575
  actualCost;
2558
2576
  budgetLimit;
2559
2577
  constructor(agentName, actualCost, budgetLimit) {
2560
2578
  super(`Agent "${agentName}" exceeded budget: $${actualCost.toFixed(4)} > $${budgetLimit.toFixed(4)}`), this.agentName = agentName, this.actualCost = actualCost, this.budgetLimit = budgetLimit;
2561
- this.name = "BudgetExceededError";
2579
+ this.name = "DelegationBudgetExceededError";
2562
2580
  }
2563
2581
  };
2582
+ var BudgetExceededError = DelegationBudgetExceededError;
2564
2583
  var DelegationError = class extends Error {
2565
2584
  static {
2566
2585
  __name(this, "DelegationError");
@@ -2619,7 +2638,7 @@ async function* consumeRoundOrThrow(inputs, agentName) {
2619
2638
  try {
2620
2639
  return yield* consumeOneRound(inputs.factory, inputs.prompt, inputs.sessionId, inputs.signal, inputs.retry);
2621
2640
  } catch (err) {
2622
- if (err instanceof BudgetExceededError || err instanceof DelegationError) throw err;
2641
+ if (err instanceof DelegationBudgetExceededError || err instanceof DelegationError) throw err;
2623
2642
  throw new DelegationError(agentName, err);
2624
2643
  }
2625
2644
  }
@@ -2795,7 +2814,7 @@ async function* runReflectiveLoopStream(factory, message, sessionId, config) {
2795
2814
  accumulateUsage(acc, r);
2796
2815
  if (r.finishReason === "error") throw new DelegationError(agentName, r.errorMessage);
2797
2816
  if (Number.isFinite(budget) && acc.cost > budget) {
2798
- throw new BudgetExceededError(agentName, acc.cost, budget);
2817
+ throw new DelegationBudgetExceededError(agentName, acc.cost, budget);
2799
2818
  }
2800
2819
  if (r.finishReason === TOOL_CALLS && r.toolCalls.length > 0) {
2801
2820
  const sig = roundSignature(r.toolCalls);
@@ -3490,6 +3509,7 @@ export {
3490
3509
  reflectionStrategyConfigSchema,
3491
3510
  ladderReflectionStrategy,
3492
3511
  noopReflectionStrategy,
3512
+ DelegationBudgetExceededError,
3493
3513
  BudgetExceededError,
3494
3514
  DelegationError,
3495
3515
  AgentRunner,
@@ -3508,4 +3528,4 @@ export {
3508
3528
  generateAgentManifest,
3509
3529
  agentsPlugin
3510
3530
  };
3511
- //# sourceMappingURL=chunk-2L5DI75P.js.map
3531
+ //# sourceMappingURL=chunk-QEWP7GRM.js.map