@theokit/agents 4.22.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-BmPk3TPf.d.ts → bridge-entry-_RN_53jC.d.ts} +57 -4
- package/dist/bridge.d.ts +1 -1
- package/dist/bridge.js +1 -1
- package/dist/{chunk-P6FAJGIU.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/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, 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
|
|
@@ -1196,7 +1249,7 @@ interface AgentBuilder<TInput extends z.ZodType | UnsetMarker = UnsetMarker, TMo
|
|
|
1196
1249
|
* assembling plumbing. Call once — a later call replaces the map. Composes with
|
|
1197
1250
|
* {@link AgentBuilder.plugins}: hooks and plugins are additive, not exclusive.
|
|
1198
1251
|
*/
|
|
1199
|
-
hooks(map: Readonly<Record<string, unknown>>): AgentBuilder<TInput, TModel, TContext, TTools>;
|
|
1252
|
+
hooks(map: HookHandlers | Readonly<Record<string, unknown>>): AgentBuilder<TInput, TModel, TContext, TTools>;
|
|
1200
1253
|
/**
|
|
1201
1254
|
* Register code `Plugin` objects for this agent — the builder-chain equivalent of
|
|
1202
1255
|
* `Agent.create({ plugins })`. A plugin is an EXTENSION UNIT: it can register tools and commands,
|
|
@@ -2056,4 +2109,4 @@ declare function agentsPlugin(opts: AgentsPluginOptions): {
|
|
|
2056
2109
|
register(app: PluginApp): void;
|
|
2057
2110
|
};
|
|
2058
2111
|
|
|
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,
|
|
2112
|
+
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-_RN_53jC.js';
|
|
2
2
|
import '@theokit/http';
|
|
3
3
|
import '@theokit/sdk';
|
|
4
4
|
import 'zod';
|
package/dist/bridge.js
CHANGED