@theokit/agents 0.44.2 → 0.44.3
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-DQJMvdRy.d.ts → bridge-entry-BtFJdaCe.d.ts} +34 -5
- package/dist/bridge.d.ts +1 -1
- package/dist/bridge.js +1 -1
- package/dist/{chunk-XRPFOFYF.js → chunk-KWQWD277.js} +32 -2
- package/dist/chunk-KWQWD277.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-XRPFOFYF.js.map +0 -1
|
@@ -587,8 +587,17 @@ interface DefineAgentConfig<TInput extends z.ZodType = z.ZodType> {
|
|
|
587
587
|
* + execution (G2 / ADR-0040); theokit only wires this into `Agent.create({ local.settingSources })`.
|
|
588
588
|
*/
|
|
589
589
|
settingSources?: readonly SettingSource[];
|
|
590
|
-
/**
|
|
590
|
+
/**
|
|
591
|
+
* Code `Plugin` objects forwarded to `Agent.create({ plugins })` — EXTENSION units (tools,
|
|
592
|
+
* commands, model providers, memory adapters). For lifecycle interception use {@link hooks}.
|
|
593
|
+
*/
|
|
591
594
|
plugins?: readonly unknown[];
|
|
595
|
+
/**
|
|
596
|
+
* Lifecycle hooks keyed by `HookName` (`pre_tool_call` may veto via `{ block, message }`). Set by
|
|
597
|
+
* the builder's `hooks()`; converted into a code plugin at `build()` and never reaching the SDK
|
|
598
|
+
* under this name — the plugin is the TRANSPORT, this is the contract callers write against.
|
|
599
|
+
*/
|
|
600
|
+
hooks?: Readonly<Record<string, unknown>>;
|
|
592
601
|
/**
|
|
593
602
|
* MCP servers available to the agent — the builder-chain equivalent of the `@MCP` class
|
|
594
603
|
* decorator. Each key is a server name; the value is the server configuration. Forwarded
|
|
@@ -931,12 +940,32 @@ interface AgentBuilder<TInput extends z.ZodType | UnsetMarker = UnsetMarker, TMo
|
|
|
931
940
|
* shell-executing hooks from `.theokit/hooks.json` — opt-in because `.theokit/` is your own repo.
|
|
932
941
|
*/
|
|
933
942
|
settingSources(sources: readonly SettingSource[]): AgentBuilder<TInput, TModel, TContext, TTools>;
|
|
943
|
+
/**
|
|
944
|
+
* Attach LIFECYCLE HOOKS in code, keyed by `HookName` — the builder-chain seam for intercepting
|
|
945
|
+
* the agent loop. `pre_tool_call` may VETO a tool by returning `{ block: true, message }` before
|
|
946
|
+
* it runs; the other events are observational.
|
|
947
|
+
*
|
|
948
|
+
* ```ts
|
|
949
|
+
* agent().hooks({
|
|
950
|
+
* pre_tool_call: (c) => guard(c.name) ? undefined : { block: true, message: 'not allowed' },
|
|
951
|
+
* on_session_start: () => log('session up'),
|
|
952
|
+
* })
|
|
953
|
+
* ```
|
|
954
|
+
*
|
|
955
|
+
* A hook is delivered internally as a code plugin, but that is TRANSPORT, not the contract — use
|
|
956
|
+
* this instead of hand-wrapping a plugin, so the caller expresses interception rather than
|
|
957
|
+
* assembling plumbing. Call once — a later call replaces the map. Composes with
|
|
958
|
+
* {@link AgentBuilder.plugins}: hooks and plugins are additive, not exclusive.
|
|
959
|
+
*/
|
|
960
|
+
hooks(map: Readonly<Record<string, unknown>>): AgentBuilder<TInput, TModel, TContext, TTools>;
|
|
934
961
|
/**
|
|
935
962
|
* Register code `Plugin` objects for this agent — the builder-chain equivalent of
|
|
936
|
-
* `Agent.create({ plugins })`.
|
|
937
|
-
*
|
|
938
|
-
*
|
|
939
|
-
*
|
|
963
|
+
* `Agent.create({ plugins })`. A plugin is an EXTENSION UNIT: it can register tools and commands,
|
|
964
|
+
* or supply a model provider / memory adapter (`kind: 'general' | 'model-provider' | 'memory'`).
|
|
965
|
+
*
|
|
966
|
+
* For lifecycle interception prefer {@link AgentBuilder.hooks} — a hook needs a plugin only as its
|
|
967
|
+
* transport, and `plugins()` makes the caller assemble that transport by hand. Reach for this when
|
|
968
|
+
* you genuinely have a plugin (a provider, a memory adapter, a tool-registering extension).
|
|
940
969
|
*/
|
|
941
970
|
plugins(list: readonly unknown[]): AgentBuilder<TInput, TModel, TContext, TTools>;
|
|
942
971
|
/**
|
package/dist/bridge.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { c as AGENT_BRAND, d as AfterToolCallContext, e as AgentBuilder, f as AgentDefinition, g as AgentDefinitionError, h as AgentExecutionContext, i as AgentManifest, A as AgentManifestEntry, j as AgentManifestTool, k as AgentRoute, l as AgentRouteContext, m as AgentRunInfo, n as AgentStreamEvent, o as AgentTurnMetadata, p as AgentWalkResult, q as AgentWarningCode, r as AgentsPluginOptions, s as ApiErrorContext, t as ApiErrorDecision, u as ApiErrorPolicy, v as ApprovalRequiredEvent, w as ArtifactChunkEvent, x as ArtifactStartEvent, B as BackgroundDelegation, y as BeforeToolCallContext, z as BudgetExceededError, E as CheckpointSavedEvent, C as CompiledAgentOptions, F as CompiledContextWindow, a as CompiledTool, G as ContextualTool, I as DefineAgentConfig, J as DelegateFn, K as DelegateOptions, M as DelegationError, D as DelegationResult, N as DoneEvent, O as ErrorEvent, P as FileEditEvent, T as InferAgentInput, U as InferAgentToolNames, V as IterationEvent, W as LLMCallContext, _ as McpApprovalSpec, $ as McpRegistryConfig, a0 as McpRequestContext, a1 as McpSelection, a2 as PartialToolCallEvent, a3 as ProcessInputContext, a7 as RunStartedEvent, a8 as ScoreVerdict, a9 as ScoredDelegation, aa as Scorer, ab as SdkAgentHandle, ac as SdkMessage, ad as Segment, ag as StateUpdateEvent, S as StreamEvent, ah as TextDeltaEvent, ai as ThinkingEvent, aj as ToolCallEvent, ak as ToolCallVeto, al as ToolHooks, am as ToolHooksPlugin, an as ToolResultEvent, ao as ToolWalkResult, ap as ToolboxWalkResult, aq as agent, ar as agentsPlugin, as as buildModelSelection, at as compileAgent, au as compileAgentDefinition, av as compileAgentModule, aw as compileContextWindow, ax as compileProjectContext, ay as compileSkills, az as compileTools, aA as contextualTool, aB as createAgentExecutionContext, aC as createApiErrorHandler, aD as createSdkAgentStream, aE as createThinkTagExtractor, aF as createToolHooksPlugin, aG as delegate, aH as delegateBackground, aI as delegateWithScoring, aJ as extractThinkTagStream, aK as generateAgentManifest, aL as generateAgentRoutes, aM as isAgentContext, aN as isAgentDefinition, aO as isApprovalRequired, aP as isDone, aQ as isError, aR as isPartialToolCall, aS as isTextDelta, aT as isToolCall, aU as isToolResult, aX as mcpRegistry, aY as mcpToolApprovals, a_ as projectContextMetadataOnlyKnobs, b2 as resolveMcpServers, b3 as runWithApiErrorHandling, b4 as streamAgentResponse, b5 as streamAgentUIMessages, b6 as toAgentFactory, b7 as translateSdkEvent, b8 as translateToUIMessageStream, b9 as validateUniqueRoutes, ba as walkAgentMetadata } from './bridge-entry-
|
|
1
|
+
export { c as AGENT_BRAND, d as AfterToolCallContext, e as AgentBuilder, f as AgentDefinition, g as AgentDefinitionError, h as AgentExecutionContext, i as AgentManifest, A as AgentManifestEntry, j as AgentManifestTool, k as AgentRoute, l as AgentRouteContext, m as AgentRunInfo, n as AgentStreamEvent, o as AgentTurnMetadata, p as AgentWalkResult, q as AgentWarningCode, r as AgentsPluginOptions, s as ApiErrorContext, t as ApiErrorDecision, u as ApiErrorPolicy, v as ApprovalRequiredEvent, w as ArtifactChunkEvent, x as ArtifactStartEvent, B as BackgroundDelegation, y as BeforeToolCallContext, z as BudgetExceededError, E as CheckpointSavedEvent, C as CompiledAgentOptions, F as CompiledContextWindow, a as CompiledTool, G as ContextualTool, I as DefineAgentConfig, J as DelegateFn, K as DelegateOptions, M as DelegationError, D as DelegationResult, N as DoneEvent, O as ErrorEvent, P as FileEditEvent, T as InferAgentInput, U as InferAgentToolNames, V as IterationEvent, W as LLMCallContext, _ as McpApprovalSpec, $ as McpRegistryConfig, a0 as McpRequestContext, a1 as McpSelection, a2 as PartialToolCallEvent, a3 as ProcessInputContext, a7 as RunStartedEvent, a8 as ScoreVerdict, a9 as ScoredDelegation, aa as Scorer, ab as SdkAgentHandle, ac as SdkMessage, ad as Segment, ag as StateUpdateEvent, S as StreamEvent, ah as TextDeltaEvent, ai as ThinkingEvent, aj as ToolCallEvent, ak as ToolCallVeto, al as ToolHooks, am as ToolHooksPlugin, an as ToolResultEvent, ao as ToolWalkResult, ap as ToolboxWalkResult, aq as agent, ar as agentsPlugin, as as buildModelSelection, at as compileAgent, au as compileAgentDefinition, av as compileAgentModule, aw as compileContextWindow, ax as compileProjectContext, ay as compileSkills, az as compileTools, aA as contextualTool, aB as createAgentExecutionContext, aC as createApiErrorHandler, aD as createSdkAgentStream, aE as createThinkTagExtractor, aF as createToolHooksPlugin, aG as delegate, aH as delegateBackground, aI as delegateWithScoring, aJ as extractThinkTagStream, aK as generateAgentManifest, aL as generateAgentRoutes, aM as isAgentContext, aN as isAgentDefinition, aO as isApprovalRequired, aP as isDone, aQ as isError, aR as isPartialToolCall, aS as isTextDelta, aT as isToolCall, aU as isToolResult, aX as mcpRegistry, aY as mcpToolApprovals, a_ as projectContextMetadataOnlyKnobs, b2 as resolveMcpServers, b3 as runWithApiErrorHandling, b4 as streamAgentResponse, b5 as streamAgentUIMessages, b6 as toAgentFactory, b7 as translateSdkEvent, b8 as translateToUIMessageStream, b9 as validateUniqueRoutes, ba as walkAgentMetadata } from './bridge-entry-BtFJdaCe.js';
|
|
2
2
|
import '@theokit/http';
|
|
3
3
|
import './types-DVA4LQsA.js';
|
|
4
4
|
import '@theokit/sdk';
|
package/dist/bridge.js
CHANGED
|
@@ -1642,6 +1642,32 @@ function contextualTool(tool, _requiredContext) {
|
|
|
1642
1642
|
return tool;
|
|
1643
1643
|
}
|
|
1644
1644
|
__name(contextualTool, "contextualTool");
|
|
1645
|
+
function withHooksPlugin(config) {
|
|
1646
|
+
const map = config.hooks;
|
|
1647
|
+
if (map === void 0) return config;
|
|
1648
|
+
const entries = Object.entries(map).filter(([, h]) => typeof h === "function");
|
|
1649
|
+
const { hooks: _dropped, ...rest } = config;
|
|
1650
|
+
if (entries.length === 0) return rest;
|
|
1651
|
+
const plugin = {
|
|
1652
|
+
name: "theokit-builder-hooks",
|
|
1653
|
+
version: "1.0.0",
|
|
1654
|
+
kind: "general",
|
|
1655
|
+
register(ctx) {
|
|
1656
|
+
for (const [hookName, handler] of entries) {
|
|
1657
|
+
ctx.on(hookName, handler);
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
};
|
|
1661
|
+
const existing = rest.plugins ?? [];
|
|
1662
|
+
return {
|
|
1663
|
+
...rest,
|
|
1664
|
+
plugins: [
|
|
1665
|
+
...existing,
|
|
1666
|
+
plugin
|
|
1667
|
+
]
|
|
1668
|
+
};
|
|
1669
|
+
}
|
|
1670
|
+
__name(withHooksPlugin, "withHooksPlugin");
|
|
1645
1671
|
function makeBuilder(config) {
|
|
1646
1672
|
const runtime = {
|
|
1647
1673
|
input: /* @__PURE__ */ __name((schema) => makeBuilder({
|
|
@@ -1701,6 +1727,10 @@ function makeBuilder(config) {
|
|
|
1701
1727
|
...config,
|
|
1702
1728
|
settingSources: sources
|
|
1703
1729
|
}), "settingSources"),
|
|
1730
|
+
hooks: /* @__PURE__ */ __name((map) => makeBuilder({
|
|
1731
|
+
...config,
|
|
1732
|
+
hooks: map
|
|
1733
|
+
}), "hooks"),
|
|
1704
1734
|
plugins: /* @__PURE__ */ __name((list) => makeBuilder({
|
|
1705
1735
|
...config,
|
|
1706
1736
|
plugins: list
|
|
@@ -1710,7 +1740,7 @@ function makeBuilder(config) {
|
|
|
1710
1740
|
mcpServers: servers
|
|
1711
1741
|
}), "mcp"),
|
|
1712
1742
|
use: /* @__PURE__ */ __name((preset) => preset(runtime), "use"),
|
|
1713
|
-
build: /* @__PURE__ */ __name(() => defineAgent(config), "build")
|
|
1743
|
+
build: /* @__PURE__ */ __name(() => defineAgent(withHooksPlugin(config)), "build")
|
|
1714
1744
|
};
|
|
1715
1745
|
return runtime;
|
|
1716
1746
|
}
|
|
@@ -3085,4 +3115,4 @@ export {
|
|
|
3085
3115
|
generateAgentManifest,
|
|
3086
3116
|
agentsPlugin
|
|
3087
3117
|
};
|
|
3088
|
-
//# sourceMappingURL=chunk-
|
|
3118
|
+
//# sourceMappingURL=chunk-KWQWD277.js.map
|