@theokit/agents 4.23.0 → 4.23.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.
- package/dist/{bridge-entry-DMh--RZ5.d.ts → bridge-entry-_RN_53jC.d.ts} +55 -57
- package/dist/bridge.d.ts +1 -1
- package/dist/bridge.js +1 -1
- package/dist/{chunk-IB7I44PO.js → chunk-SDJLIKOH.js} +1 -1
- package/dist/chunk-SDJLIKOH.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-IB7I44PO.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ExecutionContext } from '@theokit/http';
|
|
2
|
-
import { SystemPromptResolver, InlineSkill, SettingSource, MemorySettings, SkillsSettings, ContextSettings,
|
|
2
|
+
import { SystemPromptResolver, InlineSkill, SettingSource, MemorySettings, SkillsSettings, ContextSettings, PreToolCallContext, PreToolCallDecision, PostToolCallContext, ToolResultTransformContext, TransformContext, SessionLifecycleContext, PreUserSendContext, PreUserSendResult, PostAssistantReplyContext, CustomTool, PluginsSettings, Plugin, ProviderRoutingSettings, AgentDefinition as AgentDefinition$1, BudgetTracker, ModelSelection } from '@theokit/sdk';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { UIMessageChunk } from 'ai';
|
|
5
5
|
import { RetryOptions } from '@theokit/sdk/retry';
|
|
@@ -721,6 +721,59 @@ interface AgentRouteContext {
|
|
|
721
721
|
/** Generate HTTP routes for a single agent. Returns Web Standard handlers. */
|
|
722
722
|
declare function generateAgentRoutes(ctx: AgentRouteContext): AgentRoute[];
|
|
723
723
|
|
|
724
|
+
/**
|
|
725
|
+
* M82 — the typed shape of `AgentBuilder.create().hooks({...})`.
|
|
726
|
+
*
|
|
727
|
+
* ## Por que este tipo mora aqui
|
|
728
|
+
*
|
|
729
|
+
* Até o M82 a assinatura era `Readonly<Record<string, unknown>>`: qualquer chave era aceita e cada
|
|
730
|
+
* handler recebia `ctx: unknown`. O consumidor que quisesse tipo tinha de declarar o seu — e foi
|
|
731
|
+
* exatamente o que o agent-builder fez, com um alias local de cinco handlers, quatro deles com
|
|
732
|
+
* `ctx: unknown` porque não havia de onde importar os contextos.
|
|
733
|
+
*
|
|
734
|
+
* É a mesma classe que o M81 fechou com `discoverSubagents`: conhecimento do framework reimplementado
|
|
735
|
+
* no app porque o framework não o publicava. O tipo nasce onde o conhecimento mora.
|
|
736
|
+
*
|
|
737
|
+
* ## Sobre `transform_tool_result`
|
|
738
|
+
*
|
|
739
|
+
* Este é o ÚNICO canal de estágio-de-tool cujo retorno o SDK aplica — `#runTransform` dobra o valor
|
|
740
|
+
* devolvido; `#runFireAndForget`, usado por `post_tool_call`, descarta. Desde o M82 seu contexto
|
|
741
|
+
* carrega `toolCalls`, de modo que uma política com escopo (por nome de tool) possa AGIR sobre o
|
|
742
|
+
* resultado em vez de apenas observá-lo.
|
|
743
|
+
*/
|
|
744
|
+
|
|
745
|
+
/**
|
|
746
|
+
* Handlers de ciclo de vida chaveados por `HookName`.
|
|
747
|
+
*
|
|
748
|
+
* Cada campo é opcional: um agente registra só os eventos que lhe interessam. `.hooks()` aceita a
|
|
749
|
+
* UNIÃO deste tipo com o shape solto de antes (ADR-4 do M82), então não é preciso index signature
|
|
750
|
+
* implícita para o valor passar no call site — o estreitamento é gradual, não uma quebra.
|
|
751
|
+
*/
|
|
752
|
+
interface HookHandlers {
|
|
753
|
+
/**
|
|
754
|
+
* Roda ANTES da tool. Devolver `{ block: true, message }` VETA a chamada — é o único hook com
|
|
755
|
+
* poder de veto.
|
|
756
|
+
*/
|
|
757
|
+
pre_tool_call?: (ctx: PreToolCallContext) => Promise<PreToolCallDecision | undefined> | PreToolCallDecision | undefined;
|
|
758
|
+
/**
|
|
759
|
+
* Roda DEPOIS da tool, com `{name, args, result}`. Fire-and-forget: o retorno é **descartado**
|
|
760
|
+
* pelo SDK. Para AGIR sobre o resultado use {@link transform_tool_result}.
|
|
761
|
+
*/
|
|
762
|
+
post_tool_call?: (ctx: PostToolCallContext) => Promise<void> | void;
|
|
763
|
+
/**
|
|
764
|
+
* Dobra os resultados de tool do turn antes de eles subirem ao modelo. Desde o M82 o contexto traz
|
|
765
|
+
* `toolCalls` — plural, porque o seam recebe o LOTE do turn; correlacione por
|
|
766
|
+
* `toolUseId === id`.
|
|
767
|
+
*/
|
|
768
|
+
transform_tool_result?: <T>(results: T, ctx: ToolResultTransformContext) => Promise<T> | T;
|
|
769
|
+
/** Dobra o texto do modelo antes de ele ser consumido. Sem tool call envolvida. */
|
|
770
|
+
transform_llm_output?: (output: string, ctx: TransformContext) => Promise<string> | string;
|
|
771
|
+
on_session_start?: (ctx: SessionLifecycleContext) => Promise<void> | void;
|
|
772
|
+
on_session_end?: (ctx: SessionLifecycleContext) => Promise<void> | void;
|
|
773
|
+
pre_user_send?: (ctx: PreUserSendContext) => Promise<PreUserSendResult | undefined> | PreUserSendResult | undefined;
|
|
774
|
+
post_assistant_reply?: (ctx: PostAssistantReplyContext) => Promise<void> | void;
|
|
775
|
+
}
|
|
776
|
+
|
|
724
777
|
/**
|
|
725
778
|
* M2 (theokit-ai-first) — `defineAgent`, the zero-config imperative agent surface.
|
|
726
779
|
*
|
|
@@ -810,7 +863,7 @@ interface DefineAgentConfig<TInput extends z.ZodType = z.ZodType> {
|
|
|
810
863
|
* the builder's `hooks()`; converted into a code plugin at `build()` and never reaching the SDK
|
|
811
864
|
* under this name — the plugin is the TRANSPORT, this is the contract callers write against.
|
|
812
865
|
*/
|
|
813
|
-
hooks?: Readonly<Record<string, unknown>>;
|
|
866
|
+
hooks?: HookHandlers | Readonly<Record<string, unknown>>;
|
|
814
867
|
/**
|
|
815
868
|
* MCP servers available to the agent — the builder-chain equivalent of the `@MCP` class
|
|
816
869
|
* decorator. Each key is a server name; the value is the server configuration. Forwarded
|
|
@@ -1058,61 +1111,6 @@ declare function presentUIMessageStream(events: AsyncIterable<AgentStreamEvent>,
|
|
|
1058
1111
|
textId: string;
|
|
1059
1112
|
}): AsyncGenerator<UIMessageChunk, void, unknown>;
|
|
1060
1113
|
|
|
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
|
-
|
|
1116
1114
|
/**
|
|
1117
1115
|
* M8 — `AgentBuilder.create()`, the fluent agent builder with accumulative **type-state**.
|
|
1118
1116
|
*
|
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, 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-
|
|
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-_RN_53jC.js';
|
|
2
2
|
import '@theokit/http';
|
|
3
3
|
import '@theokit/sdk';
|
|
4
4
|
import 'zod';
|
package/dist/bridge.js
CHANGED