@theokit/agents 0.35.2 → 0.37.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-B3_Vw4qc.d.ts → bridge-entry-C20NAna5.d.ts} +32 -6
- package/dist/bridge.d.ts +1 -1
- package/dist/bridge.js +1 -1
- package/dist/{chunk-7IGNIY3B.js → chunk-AG4WA4I4.js} +23 -7
- package/dist/chunk-AG4WA4I4.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-7IGNIY3B.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ExecutionContext } from '@theokit/http';
|
|
2
2
|
import { A as AgentOptions, g as ToolOptions, M as MainLoopMeta, a as ApprovalOptions, B as BudgetOptions, H as HumanInTheLoopOptions, t as GatewayOptions, z as MemoryOptions, O as SkillsOptions, r as ContextWindowOptions, K as ProjectContextOptions, x as McpServersMap, G as Guardrail, o as CompactionDecoratorConfig, j as CheckpointOptions, R as ReasoningEffort } from './types-DVA4LQsA.js';
|
|
3
|
-
import { SystemPromptResolver, SkillsSettings, ContextSettings, PluginsSettings, Plugin, ProviderRoutingSettings, AgentDefinition as AgentDefinition$1, BudgetTracker,
|
|
3
|
+
import { InlineSkill, SystemPromptResolver, ConversationStorageAdapter, SkillsSettings, ContextSettings, PluginsSettings, Plugin, ProviderRoutingSettings, AgentDefinition as AgentDefinition$1, BudgetTracker, CustomTool, ModelSelection } from '@theokit/sdk';
|
|
4
4
|
import { UIMessageChunk } from 'ai';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { RetryOptions } from '@theokit/sdk/retry';
|
|
@@ -112,17 +112,23 @@ declare function validateUniqueRoutes(results: AgentWalkResult[]): void;
|
|
|
112
112
|
* different users. A selection is either a static list or a function of the request context (the M7
|
|
113
113
|
* run-context). Discovery + injection stay in the SDK; this only CHOOSES the enabled set per call.
|
|
114
114
|
*/
|
|
115
|
+
|
|
115
116
|
/** The request context handed to a skills resolver (the M7 run-context — opaque per-request data). */
|
|
116
117
|
type SkillsRequestContext = Record<string, unknown>;
|
|
117
118
|
/**
|
|
118
|
-
* How the
|
|
119
|
-
* - `string
|
|
120
|
-
* -
|
|
119
|
+
* How the skill set is chosen:
|
|
120
|
+
* - a static array of `string` (filesystem skill NAMES → `skills.enabled`) and/or `InlineSkill`
|
|
121
|
+
* objects from `createSkill` (code-defined skills → `skills.inline`, injected into the `<skills>`
|
|
122
|
+
* block). A mixed list is split at compile time.
|
|
123
|
+
* - a function — resolved per request from the {@link SkillsRequestContext} (sync or async). The
|
|
124
|
+
* resolver returns filesystem skill NAMES (inline skills are static — declared on the agent).
|
|
121
125
|
*/
|
|
122
|
-
type SkillsSelection = readonly string[] | ((ctx: SkillsRequestContext) => readonly string[] | Promise<readonly string[]>);
|
|
126
|
+
type SkillsSelection = readonly (string | InlineSkill)[] | ((ctx: SkillsRequestContext) => readonly string[] | Promise<readonly string[]>);
|
|
123
127
|
/**
|
|
124
128
|
* Resolve the enabled skill names for a request. Returns `undefined` when no selection is given (the
|
|
125
|
-
* SDK then enables every discovered skill). Fails fast if a resolver returns a non-array.
|
|
129
|
+
* SDK then enables every discovered skill). Fails fast if a resolver returns a non-array. The static
|
|
130
|
+
* array is compiled ahead of time (see `compileSkillsSelection`), so this is exercised for the
|
|
131
|
+
* resolver form; a static array is defensively narrowed to its string (name) members.
|
|
126
132
|
*/
|
|
127
133
|
declare function resolveEnabledSkills(selection: SkillsSelection | undefined, ctx: SkillsRequestContext): Promise<string[] | undefined>;
|
|
128
134
|
|
|
@@ -184,6 +190,14 @@ interface CompiledAgentOptions {
|
|
|
184
190
|
recoverLeakedToolCalls?: boolean;
|
|
185
191
|
/** Static prompt OR a per-request {@link SystemPromptResolver} (V4-L.1, Axis-B). */
|
|
186
192
|
systemPrompt?: string | SystemPromptResolver;
|
|
193
|
+
/**
|
|
194
|
+
* Agent-level conversation memory: the `ConversationStorageAdapter` the SDK persists turns to
|
|
195
|
+
* (`Agent.getOrCreate({ conversationStorage })`). Populated by `defineAgent({ conversationStorage })`
|
|
196
|
+
* / `.conversationStorage(adapter)`. A per-run override (`RuntimeOverrides.conversationStorage`)
|
|
197
|
+
* wins over this; absent ⇒ the SDK default store is chosen lazily. Distinct from `@Checkpoint`,
|
|
198
|
+
* which only toggles filesystem-vs-memory for the built-in default.
|
|
199
|
+
*/
|
|
200
|
+
conversationStorage?: ConversationStorageAdapter;
|
|
187
201
|
tools: CompiledTool[];
|
|
188
202
|
agents: Record<string, CompiledSubAgent>;
|
|
189
203
|
memory?: MemoryOptions;
|
|
@@ -721,6 +735,13 @@ interface DefineAgentConfig<TInput extends z.ZodType = z.ZodType> {
|
|
|
721
735
|
* request path against the run-context). Absent ⇒ the SDK enables every discovered skill.
|
|
722
736
|
*/
|
|
723
737
|
skills?: SkillsSelection;
|
|
738
|
+
/**
|
|
739
|
+
* Conversation memory: the `ConversationStorageAdapter` the agent persists its turns to. Swap it to
|
|
740
|
+
* control WHERE memory lives — `InMemoryConversationStorage` (ephemeral, great for tests) vs
|
|
741
|
+
* `FileSystemConversationStorage` (durable) vs a custom adapter. Absent ⇒ the SDK picks its default
|
|
742
|
+
* store. A per-run override still wins over this agent-level default.
|
|
743
|
+
*/
|
|
744
|
+
conversationStorage?: ConversationStorageAdapter;
|
|
724
745
|
}
|
|
725
746
|
/**
|
|
726
747
|
* A branded agent definition — the value {@link defineAgent} returns.
|
|
@@ -842,6 +863,11 @@ interface AgentBuilder<TInput extends z.ZodType | UnsetMarker = UnsetMarker, TMo
|
|
|
842
863
|
approvals(map: Record<string, HumanInTheLoopOptions>): AgentBuilder<TInput, TModel, TContext, TTools>;
|
|
843
864
|
/** M13 — select skills: a static list OR a per-request resolver `(ctx) => string[]`. */
|
|
844
865
|
skills(selection: SkillsSelection): AgentBuilder<TInput, TModel, TContext, TTools>;
|
|
866
|
+
/**
|
|
867
|
+
* Set the agent's conversation memory — the `ConversationStorageAdapter` the SDK persists turns to.
|
|
868
|
+
* Swap in-memory ⇄ filesystem ⇄ custom without touching the runtime. A per-run override still wins.
|
|
869
|
+
*/
|
|
870
|
+
conversationStorage(adapter: ConversationStorageAdapter): AgentBuilder<TInput, TModel, TContext, TTools>;
|
|
845
871
|
/**
|
|
846
872
|
* Apply a reusable partial chain (Spring-Boot-style composition). `preset` receives the current
|
|
847
873
|
* builder and returns an advanced one; its accumulated type-state flows through.
|
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 AgentWalkResult, p as AgentWarningCode, q as AgentsPluginOptions, r as ApiErrorContext, s as ApiErrorDecision, t as ApiErrorPolicy, u as ApprovalRequiredEvent, v as ArtifactChunkEvent, w as ArtifactStartEvent, B as BackgroundDelegation, x as BeforeToolCallContext, y as BudgetExceededError, z as CheckpointSavedEvent, C as CompiledAgentOptions, E as CompiledContextWindow, a as CompiledTool, F as ContextualTool, H as DefineAgentConfig, I as DelegateFn, J as DelegateOptions, K as DelegationError, D as DelegationResult, M as DoneEvent, N as ErrorEvent, O as FileEditEvent, Q as InferAgentInput, T as InferAgentToolNames, U as IterationEvent, V as LLMCallContext, Z as McpApprovalSpec, _ as McpRegistryConfig, $ as McpRequestContext, a0 as McpSelection, a1 as PartialToolCallEvent, a2 as ProcessInputContext, a6 as RunStartedEvent, a7 as ScoreVerdict, a8 as ScoredDelegation, a9 as Scorer, aa as SdkMessage, ab as Segment, ae as StateUpdateEvent, S as StreamEvent, af as TextDeltaEvent, ag as ThinkingEvent, ah as ToolCallEvent, ai as ToolCallVeto, aj as ToolHooks, ak as ToolHooksPlugin, al as ToolResultEvent, am as ToolWalkResult, an as ToolboxWalkResult, ao as agent, ap as agentsPlugin, aq as buildModelSelection, ar as compileAgent, as as compileAgentDefinition, at as compileAgentModule, au as compileContextWindow, av as compileProjectContext, aw as compileSkills, ax as compileTools, ay as contextualTool, az as createAgentExecutionContext, aA as createApiErrorHandler, aB as createSdkAgentStream, aC as createThinkTagExtractor, aD as createToolHooksPlugin, aE as delegate, aF as delegateBackground, aG as delegateWithScoring, aH as extractThinkTagStream, aI as generateAgentManifest, aJ as generateAgentRoutes, aK as isAgentContext, aL as isAgentDefinition, aM as isApprovalRequired, aN as isDone, aO as isError, aP as isPartialToolCall, aQ as isTextDelta, aR as isToolCall, aS as isToolResult, aV as mcpRegistry, aW as mcpToolApprovals, aY as projectContextMetadataOnlyKnobs, b0 as resolveMcpServers, b1 as runWithApiErrorHandling, b2 as streamAgentResponse, b3 as streamAgentUIMessages, b4 as translateSdkEvent, b5 as translateToUIMessageStream, b6 as validateUniqueRoutes, b7 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 AgentWalkResult, p as AgentWarningCode, q as AgentsPluginOptions, r as ApiErrorContext, s as ApiErrorDecision, t as ApiErrorPolicy, u as ApprovalRequiredEvent, v as ArtifactChunkEvent, w as ArtifactStartEvent, B as BackgroundDelegation, x as BeforeToolCallContext, y as BudgetExceededError, z as CheckpointSavedEvent, C as CompiledAgentOptions, E as CompiledContextWindow, a as CompiledTool, F as ContextualTool, H as DefineAgentConfig, I as DelegateFn, J as DelegateOptions, K as DelegationError, D as DelegationResult, M as DoneEvent, N as ErrorEvent, O as FileEditEvent, Q as InferAgentInput, T as InferAgentToolNames, U as IterationEvent, V as LLMCallContext, Z as McpApprovalSpec, _ as McpRegistryConfig, $ as McpRequestContext, a0 as McpSelection, a1 as PartialToolCallEvent, a2 as ProcessInputContext, a6 as RunStartedEvent, a7 as ScoreVerdict, a8 as ScoredDelegation, a9 as Scorer, aa as SdkMessage, ab as Segment, ae as StateUpdateEvent, S as StreamEvent, af as TextDeltaEvent, ag as ThinkingEvent, ah as ToolCallEvent, ai as ToolCallVeto, aj as ToolHooks, ak as ToolHooksPlugin, al as ToolResultEvent, am as ToolWalkResult, an as ToolboxWalkResult, ao as agent, ap as agentsPlugin, aq as buildModelSelection, ar as compileAgent, as as compileAgentDefinition, at as compileAgentModule, au as compileContextWindow, av as compileProjectContext, aw as compileSkills, ax as compileTools, ay as contextualTool, az as createAgentExecutionContext, aA as createApiErrorHandler, aB as createSdkAgentStream, aC as createThinkTagExtractor, aD as createToolHooksPlugin, aE as delegate, aF as delegateBackground, aG as delegateWithScoring, aH as extractThinkTagStream, aI as generateAgentManifest, aJ as generateAgentRoutes, aK as isAgentContext, aL as isAgentDefinition, aM as isApprovalRequired, aN as isDone, aO as isError, aP as isPartialToolCall, aQ as isTextDelta, aR as isToolCall, aS as isToolResult, aV as mcpRegistry, aW as mcpToolApprovals, aY as projectContextMetadataOnlyKnobs, b0 as resolveMcpServers, b1 as runWithApiErrorHandling, b2 as streamAgentResponse, b3 as streamAgentUIMessages, b4 as translateSdkEvent, b5 as translateToUIMessageStream, b6 as validateUniqueRoutes, b7 as walkAgentMetadata } from './bridge-entry-C20NAna5.js';
|
|
2
2
|
import '@theokit/http';
|
|
3
3
|
import './types-DVA4LQsA.js';
|
|
4
4
|
import '@theokit/sdk';
|
package/dist/bridge.js
CHANGED
|
@@ -1180,7 +1180,7 @@ function createSdkAgentStream(compiled, compiledTools, apiKey, overrides = {}) {
|
|
|
1180
1180
|
const reasoningEffort = overrides.reasoningEffort ?? compiled.reasoningEffort;
|
|
1181
1181
|
const { parseThinkTags, stripToolDialect } = resolveTextTransformFlags(compiled, overrides);
|
|
1182
1182
|
const runContext = overrides.runContext ?? compiled.runContext;
|
|
1183
|
-
let storage = overrides.conversationStorage;
|
|
1183
|
+
let storage = overrides.conversationStorage ?? compiled.conversationStorage;
|
|
1184
1184
|
return (message, sessionId, factoryOpts) => ({
|
|
1185
1185
|
async *[Symbol.asyncIterator]() {
|
|
1186
1186
|
const runId = `run-${Date.now()}`;
|
|
@@ -1491,7 +1491,12 @@ function compileAgentDefinition(def) {
|
|
|
1491
1491
|
hitl: compileApprovals(def)
|
|
1492
1492
|
} : {},
|
|
1493
1493
|
// M13 — skills: a static list → SDK skills.enabled; a resolver → carried for the request path.
|
|
1494
|
-
...compileSkillsSelection(def.skills)
|
|
1494
|
+
...compileSkillsSelection(def.skills),
|
|
1495
|
+
// Conversation memory: the declared adapter flows to the run path, which hands it to
|
|
1496
|
+
// `Agent.getOrCreate({ conversationStorage })`; absent ⇒ the SDK default is chosen lazily.
|
|
1497
|
+
...def.conversationStorage !== void 0 ? {
|
|
1498
|
+
conversationStorage: def.conversationStorage
|
|
1499
|
+
} : {}
|
|
1495
1500
|
};
|
|
1496
1501
|
}
|
|
1497
1502
|
__name(compileAgentDefinition, "compileAgentDefinition");
|
|
@@ -1500,12 +1505,19 @@ function compileSkillsSelection(skills) {
|
|
|
1500
1505
|
if (typeof skills === "function") return {
|
|
1501
1506
|
skillsResolver: skills
|
|
1502
1507
|
};
|
|
1508
|
+
const enabled = [];
|
|
1509
|
+
const inline = [];
|
|
1510
|
+
for (const entry of skills) {
|
|
1511
|
+
if (typeof entry === "string") enabled.push(entry);
|
|
1512
|
+
else inline.push(entry);
|
|
1513
|
+
}
|
|
1503
1514
|
return {
|
|
1504
1515
|
skills: {
|
|
1505
|
-
enabled
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1516
|
+
enabled,
|
|
1517
|
+
autoInject: true,
|
|
1518
|
+
...inline.length > 0 ? {
|
|
1519
|
+
inline
|
|
1520
|
+
} : {}
|
|
1509
1521
|
}
|
|
1510
1522
|
};
|
|
1511
1523
|
}
|
|
@@ -1585,6 +1597,10 @@ function makeBuilder(config) {
|
|
|
1585
1597
|
...config,
|
|
1586
1598
|
skills: selection
|
|
1587
1599
|
}), "skills"),
|
|
1600
|
+
conversationStorage: /* @__PURE__ */ __name((adapter) => makeBuilder({
|
|
1601
|
+
...config,
|
|
1602
|
+
conversationStorage: adapter
|
|
1603
|
+
}), "conversationStorage"),
|
|
1588
1604
|
use: /* @__PURE__ */ __name((preset) => preset(runtime), "use"),
|
|
1589
1605
|
build: /* @__PURE__ */ __name(() => defineAgent(config), "build")
|
|
1590
1606
|
};
|
|
@@ -2960,4 +2976,4 @@ export {
|
|
|
2960
2976
|
generateAgentManifest,
|
|
2961
2977
|
agentsPlugin
|
|
2962
2978
|
};
|
|
2963
|
-
//# sourceMappingURL=chunk-
|
|
2979
|
+
//# sourceMappingURL=chunk-AG4WA4I4.js.map
|