@theokit/agents 0.44.5 → 0.45.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-CBq4_kja.d.ts → bridge-entry-DQJMvdRy.d.ts} +5 -52
- package/dist/bridge.d.ts +1 -1
- package/dist/bridge.js +1 -1
- package/dist/{chunk-6A7SXMKX.js → chunk-XRPFOFYF.js} +5 -42
- package/dist/{chunk-6A7SXMKX.js.map → chunk-XRPFOFYF.js.map} +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/package.json +9 -9
- package/LICENSE +0 -201
|
@@ -587,17 +587,8 @@ 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
|
-
/**
|
|
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
|
-
*/
|
|
590
|
+
/** Code `Plugin` objects forwarded to `Agent.create({ plugins })` (lifecycle-hook seam). */
|
|
594
591
|
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>>;
|
|
601
592
|
/**
|
|
602
593
|
* MCP servers available to the agent — the builder-chain equivalent of the `@MCP` class
|
|
603
594
|
* decorator. Each key is a server name; the value is the server configuration. Forwarded
|
|
@@ -648,25 +639,9 @@ declare function compileAgentDefinition(def: AgentDefinition): CompiledAgentOpti
|
|
|
648
639
|
* one object (rather than positional params) so the per-request surface can grow without
|
|
649
640
|
* a parameter explosion. Each field is Axis-A SWAP — a value the app holds at call time.
|
|
650
641
|
*/
|
|
651
|
-
/**
|
|
652
|
-
* A multimodal image for a send turn — the SDK's `SDKImage` shape, typed locally because `@theokit/sdk`
|
|
653
|
-
* is an optional peer (dynamic import). Either a URL or inline base64 `{ data, mimeType }`.
|
|
654
|
-
*/
|
|
655
|
-
type BridgeImage = {
|
|
656
|
-
url: string;
|
|
657
|
-
} | {
|
|
658
|
-
data: string;
|
|
659
|
-
mimeType: string;
|
|
660
|
-
};
|
|
661
642
|
interface RuntimeOverrides {
|
|
662
643
|
/** Overrides the model for this call (`?? compiled.model ?? default`). */
|
|
663
644
|
model?: string;
|
|
664
|
-
/**
|
|
665
|
-
* M35 (multimodal) — images to send alongside the text. When present, the SDK send switches from the
|
|
666
|
-
* plain-string form to the structured `{ text, images }` form (`SDKUserMessage`). Absent ⇒ the
|
|
667
|
-
* string path is byte-unchanged (back-compat).
|
|
668
|
-
*/
|
|
669
|
-
images?: readonly BridgeImage[];
|
|
670
645
|
/**
|
|
671
646
|
* Per-run extended-thinking effort (`?? compiled.reasoningEffort`). Mapped to the SDK
|
|
672
647
|
* `ModelSelection.params` so the provider produces reasoning (surfaced as `thinking` StreamEvents).
|
|
@@ -956,32 +931,12 @@ interface AgentBuilder<TInput extends z.ZodType | UnsetMarker = UnsetMarker, TMo
|
|
|
956
931
|
* shell-executing hooks from `.theokit/hooks.json` — opt-in because `.theokit/` is your own repo.
|
|
957
932
|
*/
|
|
958
933
|
settingSources(sources: readonly SettingSource[]): AgentBuilder<TInput, TModel, TContext, TTools>;
|
|
959
|
-
/**
|
|
960
|
-
* Attach LIFECYCLE HOOKS in code, keyed by `HookName` — the builder-chain seam for intercepting
|
|
961
|
-
* the agent loop. `pre_tool_call` may VETO a tool by returning `{ block: true, message }` before
|
|
962
|
-
* it runs; the other events are observational.
|
|
963
|
-
*
|
|
964
|
-
* ```ts
|
|
965
|
-
* agent().hooks({
|
|
966
|
-
* pre_tool_call: (c) => guard(c.name) ? undefined : { block: true, message: 'not allowed' },
|
|
967
|
-
* on_session_start: () => log('session up'),
|
|
968
|
-
* })
|
|
969
|
-
* ```
|
|
970
|
-
*
|
|
971
|
-
* A hook is delivered internally as a code plugin, but that is TRANSPORT, not the contract — use
|
|
972
|
-
* this instead of hand-wrapping a plugin, so the caller expresses interception rather than
|
|
973
|
-
* assembling plumbing. Call once — a later call replaces the map. Composes with
|
|
974
|
-
* {@link AgentBuilder.plugins}: hooks and plugins are additive, not exclusive.
|
|
975
|
-
*/
|
|
976
|
-
hooks(map: Readonly<Record<string, unknown>>): AgentBuilder<TInput, TModel, TContext, TTools>;
|
|
977
934
|
/**
|
|
978
935
|
* Register code `Plugin` objects for this agent — the builder-chain equivalent of
|
|
979
|
-
* `Agent.create({ plugins })`.
|
|
980
|
-
*
|
|
981
|
-
*
|
|
982
|
-
*
|
|
983
|
-
* transport, and `plugins()` makes the caller assemble that transport by hand. Reach for this when
|
|
984
|
-
* you genuinely have a plugin (a provider, a memory adapter, a tool-registering extension).
|
|
936
|
+
* `Agent.create({ plugins })`. This is how a fluent-built agent gets LIFECYCLE HOOKS in code:
|
|
937
|
+
* `plugins([createToolHooksPlugin({ beforeToolCall, afterToolCall })])` lets `beforeToolCall`
|
|
938
|
+
* VETO a tool call (`{ block, message }`) before it runs. Without this the fluent builder had no
|
|
939
|
+
* way to reach the SDK's plugin seam (file-based `.theokit/hooks.json` is the other path).
|
|
985
940
|
*/
|
|
986
941
|
plugins(list: readonly unknown[]): AgentBuilder<TInput, TModel, TContext, TTools>;
|
|
987
942
|
/**
|
|
@@ -1086,8 +1041,6 @@ interface StreamHitlOptions {
|
|
|
1086
1041
|
interface StreamAgentOptions {
|
|
1087
1042
|
message: string;
|
|
1088
1043
|
sessionId: string;
|
|
1089
|
-
/** M35 (multimodal) — images to send alongside the text. Absent ⇒ the string send path is unchanged. */
|
|
1090
|
-
images?: RuntimeOverrides['images'];
|
|
1091
1044
|
/** Enable human-in-the-loop tool approval (M4). Absent ⇒ the M2 non-HITL path, byte-unchanged. */
|
|
1092
1045
|
hitl?: StreamHitlOptions;
|
|
1093
1046
|
/**
|
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-DQJMvdRy.js';
|
|
2
2
|
import '@theokit/http';
|
|
3
3
|
import './types-DVA4LQsA.js';
|
|
4
4
|
import '@theokit/sdk';
|
package/dist/bridge.js
CHANGED
|
@@ -562,10 +562,9 @@ function compileAgentDefinition(def) {
|
|
|
562
562
|
...def.settingSources !== void 0 ? {
|
|
563
563
|
settingSources: def.settingSources
|
|
564
564
|
} : {},
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
...compileHooksAndPlugins(def),
|
|
565
|
+
...def.plugins !== void 0 ? {
|
|
566
|
+
plugins: def.plugins
|
|
567
|
+
} : {},
|
|
569
568
|
// MCP — builder/`defineAgent` servers converge on the same `mcpServers` field the `@MCP`
|
|
570
569
|
// decorator path populates; the SDK adapter forwards it to `Agent.create({ mcpServers })`.
|
|
571
570
|
...def.mcpServers !== void 0 ? {
|
|
@@ -574,33 +573,6 @@ function compileAgentDefinition(def) {
|
|
|
574
573
|
};
|
|
575
574
|
}
|
|
576
575
|
__name(compileAgentDefinition, "compileAgentDefinition");
|
|
577
|
-
function compileHooksAndPlugins(def) {
|
|
578
|
-
const map = def.hooks;
|
|
579
|
-
const entries = Object.entries(map ?? {}).filter(([, h]) => typeof h === "function");
|
|
580
|
-
const explicit = def.plugins ?? [];
|
|
581
|
-
if (entries.length === 0) {
|
|
582
|
-
return def.plugins !== void 0 ? {
|
|
583
|
-
plugins: def.plugins
|
|
584
|
-
} : {};
|
|
585
|
-
}
|
|
586
|
-
const plugin = {
|
|
587
|
-
name: "theokit-builder-hooks",
|
|
588
|
-
version: "1.0.0",
|
|
589
|
-
kind: "general",
|
|
590
|
-
register(ctx) {
|
|
591
|
-
for (const [hookName, handler] of entries) {
|
|
592
|
-
ctx.on(hookName, handler);
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
};
|
|
596
|
-
return {
|
|
597
|
-
plugins: [
|
|
598
|
-
...explicit,
|
|
599
|
-
plugin
|
|
600
|
-
]
|
|
601
|
-
};
|
|
602
|
-
}
|
|
603
|
-
__name(compileHooksAndPlugins, "compileHooksAndPlugins");
|
|
604
576
|
function compileSkillsSelection(skills) {
|
|
605
577
|
if (skills === void 0) return {};
|
|
606
578
|
if (typeof skills === "function") return {
|
|
@@ -1425,11 +1397,7 @@ async function* streamSdkAgent(rt, compiled, sdkTools, opts) {
|
|
|
1425
1397
|
onDelta
|
|
1426
1398
|
};
|
|
1427
1399
|
if (factoryOpts?.disableTools === true) sendOptions.toolChoice = "none";
|
|
1428
|
-
const
|
|
1429
|
-
text: message,
|
|
1430
|
-
images: overrides.images
|
|
1431
|
-
} : message;
|
|
1432
|
-
const sendPromise = agent2.send(sendInput, sendOptions);
|
|
1400
|
+
const sendPromise = agent2.send(message, sendOptions);
|
|
1433
1401
|
const openStream = /* @__PURE__ */ __name(async () => (await sendPromise).stream(), "openStream");
|
|
1434
1402
|
const merged = mergeDeltaStream(queue, openStream, runId, state);
|
|
1435
1403
|
for await (const event of applyTextTransforms(merged, {
|
|
@@ -1733,10 +1701,6 @@ function makeBuilder(config) {
|
|
|
1733
1701
|
...config,
|
|
1734
1702
|
settingSources: sources
|
|
1735
1703
|
}), "settingSources"),
|
|
1736
|
-
hooks: /* @__PURE__ */ __name((map) => makeBuilder({
|
|
1737
|
-
...config,
|
|
1738
|
-
hooks: map
|
|
1739
|
-
}), "hooks"),
|
|
1740
1704
|
plugins: /* @__PURE__ */ __name((list) => makeBuilder({
|
|
1741
1705
|
...config,
|
|
1742
1706
|
plugins: list
|
|
@@ -1898,7 +1862,6 @@ function streamAgentUIMessages(compiled, apiKey, input) {
|
|
|
1898
1862
|
const overrides = {};
|
|
1899
1863
|
if (input.cwd !== void 0) overrides.cwd = input.cwd;
|
|
1900
1864
|
if (input.baseDir !== void 0) overrides.baseDir = input.baseDir;
|
|
1901
|
-
if (input.images !== void 0) overrides.images = input.images;
|
|
1902
1865
|
let source;
|
|
1903
1866
|
if (!input.hitl || input.hitl.gated.size === 0) {
|
|
1904
1867
|
const events2 = createSdkAgentStream(compiled, compiled.tools, apiKey, overrides)(input.message, input.sessionId);
|
|
@@ -3122,4 +3085,4 @@ export {
|
|
|
3122
3085
|
generateAgentManifest,
|
|
3123
3086
|
agentsPlugin
|
|
3124
3087
|
};
|
|
3125
|
-
//# sourceMappingURL=chunk-
|
|
3088
|
+
//# sourceMappingURL=chunk-XRPFOFYF.js.map
|