@theokit/agents 4.21.0 → 4.23.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.
- package/dist/{bridge-entry-BmPk3TPf.d.ts → bridge-entry-DMh--RZ5.d.ts} +58 -3
- package/dist/bridge.d.ts +1 -1
- package/dist/bridge.js +1 -1
- package/dist/{chunk-P6FAJGIU.js → chunk-IB7I44PO.js} +1 -1
- package/dist/chunk-IB7I44PO.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-P6FAJGIU.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ExecutionContext } from '@theokit/http';
|
|
2
|
-
import { SystemPromptResolver, InlineSkill, SettingSource, MemorySettings, SkillsSettings, ContextSettings, CustomTool, PluginsSettings, Plugin, ProviderRoutingSettings, AgentDefinition as AgentDefinition$1, BudgetTracker, ModelSelection } from '@theokit/sdk';
|
|
2
|
+
import { SystemPromptResolver, InlineSkill, SettingSource, MemorySettings, SkillsSettings, ContextSettings, CustomTool, PluginsSettings, Plugin, ProviderRoutingSettings, AgentDefinition as AgentDefinition$1, BudgetTracker, ModelSelection, PreToolCallContext, PreToolCallDecision, PostToolCallContext, ToolResultTransformContext, TransformContext, SessionLifecycleContext, PreUserSendContext, PreUserSendResult, PostAssistantReplyContext } from '@theokit/sdk';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { UIMessageChunk } from 'ai';
|
|
5
5
|
import { RetryOptions } from '@theokit/sdk/retry';
|
|
@@ -1058,6 +1058,61 @@ declare function presentUIMessageStream(events: AsyncIterable<AgentStreamEvent>,
|
|
|
1058
1058
|
textId: string;
|
|
1059
1059
|
}): AsyncGenerator<UIMessageChunk, void, unknown>;
|
|
1060
1060
|
|
|
1061
|
+
/**
|
|
1062
|
+
* M82 — the typed shape of `AgentBuilder.create().hooks({...})`.
|
|
1063
|
+
*
|
|
1064
|
+
* ## Por que este tipo mora aqui
|
|
1065
|
+
*
|
|
1066
|
+
* Até o M82 a assinatura era `Readonly<Record<string, unknown>>`: qualquer chave era aceita e todo
|
|
1067
|
+
* handler recebia `ctx: unknown`. O consumidor que quisesse tipo tinha de declarar o seu — e foi
|
|
1068
|
+
* exatamente o que o agent-builder fez, com um alias local de cinco handlers, quatro deles com
|
|
1069
|
+
* `ctx: unknown` porque não havia de onde importar os contextos.
|
|
1070
|
+
*
|
|
1071
|
+
* É a mesma classe que o M81 fechou com `discoverSubagents`: conhecimento do framework reimplementado
|
|
1072
|
+
* no app porque o framework não o publicava. O tipo nasce onde o conhecimento mora.
|
|
1073
|
+
*
|
|
1074
|
+
* ## Sobre `transform_tool_result`
|
|
1075
|
+
*
|
|
1076
|
+
* Este é o ÚNICO canal de estágio-de-tool cujo retorno o SDK aplica — `#runTransform` dobra o valor
|
|
1077
|
+
* devolvido; `#runFireAndForget`, usado por `post_tool_call`, descarta. Desde o M82 seu contexto
|
|
1078
|
+
* carrega `toolCalls`, de modo que uma política com escopo (por nome de tool) possa AGIR sobre o
|
|
1079
|
+
* resultado em vez de apenas observá-lo.
|
|
1080
|
+
*/
|
|
1081
|
+
|
|
1082
|
+
/**
|
|
1083
|
+
* Handlers de ciclo de vida chaveados por `HookName`.
|
|
1084
|
+
*
|
|
1085
|
+
* TYPE ALIAS, não interface: só aliases ganham index signature implícita, e é isso que mantém o
|
|
1086
|
+
* valor atribuível ao parâmetro solto de `.hooks()` sem cast no call site (ADR-4 do M82 — o
|
|
1087
|
+
* estreitamento é gradual, não uma quebra).
|
|
1088
|
+
*
|
|
1089
|
+
* Todo campo é opcional: um agente registra só os eventos que lhe interessam.
|
|
1090
|
+
*/
|
|
1091
|
+
type HookHandlers = {
|
|
1092
|
+
/**
|
|
1093
|
+
* Roda ANTES da tool. Devolver `{ block: true, message }` VETA a chamada — é o único hook com
|
|
1094
|
+
* poder de veto.
|
|
1095
|
+
*/
|
|
1096
|
+
pre_tool_call?: (ctx: PreToolCallContext) => Promise<PreToolCallDecision | undefined> | PreToolCallDecision | undefined;
|
|
1097
|
+
/**
|
|
1098
|
+
* Roda DEPOIS da tool, com `{name, args, result}`. Fire-and-forget: o retorno é **descartado**
|
|
1099
|
+
* pelo SDK. Para AGIR sobre o resultado use {@link transform_tool_result}.
|
|
1100
|
+
*/
|
|
1101
|
+
post_tool_call?: (ctx: PostToolCallContext) => Promise<void> | void;
|
|
1102
|
+
/**
|
|
1103
|
+
* Dobra os resultados de tool do turn antes de eles subirem ao modelo. Desde o M82 o contexto traz
|
|
1104
|
+
* `toolCalls` — plural, porque o seam recebe o LOTE do turn; correlacione por
|
|
1105
|
+
* `toolUseId === id`.
|
|
1106
|
+
*/
|
|
1107
|
+
transform_tool_result?: <T>(results: T, ctx: ToolResultTransformContext) => Promise<T> | T;
|
|
1108
|
+
/** Dobra o texto do modelo antes de ele ser consumido. Sem tool call envolvida. */
|
|
1109
|
+
transform_llm_output?: (output: string, ctx: TransformContext) => Promise<string> | string;
|
|
1110
|
+
on_session_start?: (ctx: SessionLifecycleContext) => Promise<void> | void;
|
|
1111
|
+
on_session_end?: (ctx: SessionLifecycleContext) => Promise<void> | void;
|
|
1112
|
+
pre_user_send?: (ctx: PreUserSendContext) => Promise<PreUserSendResult | undefined> | PreUserSendResult | undefined;
|
|
1113
|
+
post_assistant_reply?: (ctx: PostAssistantReplyContext) => Promise<void> | void;
|
|
1114
|
+
};
|
|
1115
|
+
|
|
1061
1116
|
/**
|
|
1062
1117
|
* M8 — `AgentBuilder.create()`, the fluent agent builder with accumulative **type-state**.
|
|
1063
1118
|
*
|
|
@@ -1196,7 +1251,7 @@ interface AgentBuilder<TInput extends z.ZodType | UnsetMarker = UnsetMarker, TMo
|
|
|
1196
1251
|
* assembling plumbing. Call once — a later call replaces the map. Composes with
|
|
1197
1252
|
* {@link AgentBuilder.plugins}: hooks and plugins are additive, not exclusive.
|
|
1198
1253
|
*/
|
|
1199
|
-
hooks(map: Readonly<Record<string, unknown>>): AgentBuilder<TInput, TModel, TContext, TTools>;
|
|
1254
|
+
hooks(map: HookHandlers | Readonly<Record<string, unknown>>): AgentBuilder<TInput, TModel, TContext, TTools>;
|
|
1200
1255
|
/**
|
|
1201
1256
|
* Register code `Plugin` objects for this agent — the builder-chain equivalent of
|
|
1202
1257
|
* `Agent.create({ plugins })`. A plugin is an EXTENSION UNIT: it can register tools and commands,
|
|
@@ -2056,4 +2111,4 @@ declare function agentsPlugin(opts: AgentsPluginOptions): {
|
|
|
2056
2111
|
register(app: PluginApp): void;
|
|
2057
2112
|
};
|
|
2058
2113
|
|
|
2059
|
-
export { type FileEditEvent as $, type ApprovalOptions as A, type ArtifactChunkEvent as B, type CompiledAgentOptions as C, type DelegationResult as D, type ArtifactStartEvent as E, type BackgroundDelegation as F, type Guardrail as G, type HumanInTheLoopOptions as H, type BeforeToolCallContext as I, BudgetExceededError as J, type BudgetOptions as K, type LoopStrategy as L, type MainLoopMeta as M, type CheckpointSavedEvent as N, type CompiledContextWindow as O, ContextualTool as P, CostBudgetExceededError as Q, type ReflectionStrategy as R, type StreamEvent as S, type ToolOptions as T, DEFAULT_MAX_ITERATIONS as U, type DefineAgentConfig as V, type DelegateFn as W, type DelegateOptions as X, DelegationError as Y, type DoneEvent as Z, type ErrorEvent as _, type CompiledTool as a,
|
|
2114
|
+
export { type FileEditEvent as $, type ApprovalOptions as A, type ArtifactChunkEvent as B, type CompiledAgentOptions as C, type DelegationResult as D, type ArtifactStartEvent as E, type BackgroundDelegation as F, type Guardrail as G, type HumanInTheLoopOptions as H, type BeforeToolCallContext as I, BudgetExceededError as J, type BudgetOptions as K, type LoopStrategy as L, type MainLoopMeta as M, type CheckpointSavedEvent as N, type CompiledContextWindow as O, ContextualTool as P, CostBudgetExceededError as Q, type ReflectionStrategy as R, type StreamEvent as S, type ToolOptions as T, DEFAULT_MAX_ITERATIONS as U, type DefineAgentConfig as V, type DelegateFn as W, type DelegateOptions as X, DelegationError as Y, type DoneEvent as Z, type ErrorEvent as _, type CompiledTool as a, generateAgentRoutes as a$, type GuardrailAction as a0, type GuardrailPhase as a1, type GuardrailResult as a2, GuardrailViolationError as a3, type HitlDecision as a4, type HookHandlers as a5, type InferAgentInput as a6, type InferAgentToolNames as a7, type IterationEvent as a8, type LLMCallContext as a9, type TimeoutAction as aA, type ToolCallEvent as aB, type ToolCallVeto as aC, type ToolHooks as aD, type ToolHooksPlugin as aE, type ToolResultEvent as aF, type ToolWalkResult as aG, type ToolboxOptions as aH, type ToolboxWalkResult as aI, agentsPlugin as aJ, buildModelSelection as aK, compileAgentDefinition as aL, compileAgentModule as aM, compileContextWindow as aN, compileProjectContext as aO, compileSkills as aP, compileTools as aQ, createAgentExecutionContext as aR, createApiErrorHandler as aS, createSdkAgentStream as aT, createThinkTagExtractor as aU, createToolHooksPlugin as aV, delegate as aW, delegateBackground as aX, delegateWithScoring as aY, extractThinkTagStream as aZ, generateAgentManifest as a_, type LoopFinishReason as aa, type LoopOutcome as ab, type LoopStrategyConfig as ac, type MainLoopOptions as ad, type McpApprovalSpec as ae, type McpRegistryConfig as af, type McpRequestContext as ag, type McpSelection as ah, type PartialToolCallEvent as ai, type PolicyHandler as aj, type ProcessInputContext as ak, type ReflectionContext as al, type ReflectionResult as am, type ReflectionStrategyConfig as an, type RunStartedEvent as ao, type ScoreVerdict as ap, type ScoredDelegation as aq, type Scorer as ar, type SdkAgentHandle as as, type SdkMessage as at, type Segment as au, type SkillsRequestContext as av, type SkillsSelection as aw, type StateUpdateEvent as ax, type TextDeltaEvent as ay, type ThinkingEvent as az, type ReasoningEffort as b, isAgentContext as b0, isAgentDefinition as b1, isApprovalRequired as b2, isDone as b3, isError as b4, isPartialToolCall as b5, isTextDelta as b6, isToolCall as b7, isToolResult as b8, ladderReflectionStrategy as b9, loopStrategyConfigSchema as ba, mcpRegistry as bb, mcpToolApprovals as bc, noopReflectionStrategy as bd, presentUIMessageStream as be, projectContextMetadataOnlyKnobs as bf, reflectionStrategyConfigSchema as bg, resolveEnabledSkills as bh, resolveLoopStrategy as bi, resolveMcpServers as bj, runWithApiErrorHandling as bk, streamAgentResponse as bl, streamAgentUIMessages as bm, toAgentFactory as bn, translateSdkEvent as bo, type RoundStreamFactory as c, type ContextWindowOptions as d, type SkillsOptions as e, type AgentManifestEntry as f, AGENT_BRAND as g, type AfterToolCallContext as h, AgentBuilder as i, type AgentDefinition as j, AgentDefinitionError as k, type AgentExecutionContext as l, type AgentManifest as m, type AgentManifestSource as n, type AgentManifestTool as o, type AgentOptions as p, type AgentRoute as q, type AgentRouteContext as r, type AgentRunInfo as s, type AgentStreamEvent as t, type AgentTurnMetadata as u, type AgentsPluginOptions as v, type ApiErrorContext as w, type ApiErrorDecision as x, type ApiErrorPolicy as y, type ApprovalRequiredEvent as z };
|
package/dist/bridge.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { g as AGENT_BRAND, h as AfterToolCallContext, i as AgentBuilder, j as AgentDefinition, k as AgentDefinitionError, l as AgentExecutionContext, m as AgentManifest, f as AgentManifestEntry, n as AgentManifestSource, o as AgentManifestTool, q as AgentRoute, r as AgentRouteContext, s as AgentRunInfo, t as AgentStreamEvent, u as AgentTurnMetadata, v as AgentsPluginOptions, w as ApiErrorContext, x as ApiErrorDecision, y as ApiErrorPolicy, z as ApprovalRequiredEvent, B as ArtifactChunkEvent, E as ArtifactStartEvent, F as BackgroundDelegation, I as BeforeToolCallContext, J as BudgetExceededError, N as CheckpointSavedEvent, C as CompiledAgentOptions, O as CompiledContextWindow, a as CompiledTool, P as ContextualTool, V as DefineAgentConfig, W as DelegateFn, X as DelegateOptions, Y as DelegationError, D as DelegationResult, Z as DoneEvent, _ as ErrorEvent, $ as FileEditEvent,
|
|
1
|
+
export { g as AGENT_BRAND, h as AfterToolCallContext, i as AgentBuilder, j as AgentDefinition, k as AgentDefinitionError, l as AgentExecutionContext, m as AgentManifest, f as AgentManifestEntry, n as AgentManifestSource, o as AgentManifestTool, q as AgentRoute, r as AgentRouteContext, s as AgentRunInfo, t as AgentStreamEvent, u as AgentTurnMetadata, v as AgentsPluginOptions, w as ApiErrorContext, x as ApiErrorDecision, y as ApiErrorPolicy, z as ApprovalRequiredEvent, B as ArtifactChunkEvent, E as ArtifactStartEvent, F as BackgroundDelegation, I as BeforeToolCallContext, J as BudgetExceededError, N as CheckpointSavedEvent, C as CompiledAgentOptions, O as CompiledContextWindow, a as CompiledTool, P as ContextualTool, V as DefineAgentConfig, W as DelegateFn, X as DelegateOptions, Y as DelegationError, D as DelegationResult, Z as DoneEvent, _ as ErrorEvent, $ as FileEditEvent, a6 as InferAgentInput, a7 as InferAgentToolNames, a8 as IterationEvent, a9 as LLMCallContext, ae as McpApprovalSpec, af as McpRegistryConfig, ag as McpRequestContext, ah as McpSelection, ai as PartialToolCallEvent, ak as ProcessInputContext, ao as RunStartedEvent, ap as ScoreVerdict, aq as ScoredDelegation, ar as Scorer, as as SdkAgentHandle, at as SdkMessage, au as Segment, ax as StateUpdateEvent, S as StreamEvent, ay as TextDeltaEvent, az as ThinkingEvent, aB as ToolCallEvent, aC as ToolCallVeto, aD as ToolHooks, aE as ToolHooksPlugin, aF as ToolResultEvent, aG as ToolWalkResult, aI as ToolboxWalkResult, aJ as agentsPlugin, aK as buildModelSelection, aL as compileAgentDefinition, aM as compileAgentModule, aN as compileContextWindow, aO as compileProjectContext, aP as compileSkills, aQ as compileTools, aR as createAgentExecutionContext, aS as createApiErrorHandler, aT as createSdkAgentStream, aU as createThinkTagExtractor, aV as createToolHooksPlugin, aW as delegate, aX as delegateBackground, aY as delegateWithScoring, aZ as extractThinkTagStream, a_ as generateAgentManifest, a$ as generateAgentRoutes, b0 as isAgentContext, b1 as isAgentDefinition, b2 as isApprovalRequired, b3 as isDone, b4 as isError, b5 as isPartialToolCall, b6 as isTextDelta, b7 as isToolCall, b8 as isToolResult, bb as mcpRegistry, bc as mcpToolApprovals, be as presentUIMessageStream, bf as projectContextMetadataOnlyKnobs, bj as resolveMcpServers, bk as runWithApiErrorHandling, bl as streamAgentResponse, bm as streamAgentUIMessages, bn as toAgentFactory, bo as translateSdkEvent } from './bridge-entry-DMh--RZ5.js';
|
|
2
2
|
import '@theokit/http';
|
|
3
3
|
import '@theokit/sdk';
|
|
4
4
|
import 'zod';
|
package/dist/bridge.js
CHANGED