@theokit/agents 0.35.1 → 0.36.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-DYXCEzdJ.d.ts} +21 -1
- package/dist/bridge.d.ts +1 -1
- package/dist/bridge.js +1 -1
- package/dist/{chunk-IAE4FWBV.js → chunk-RJTRE6BD.js} +24 -6
- package/dist/chunk-RJTRE6BD.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-IAE4FWBV.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 { 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';
|
|
@@ -184,6 +184,14 @@ interface CompiledAgentOptions {
|
|
|
184
184
|
recoverLeakedToolCalls?: boolean;
|
|
185
185
|
/** Static prompt OR a per-request {@link SystemPromptResolver} (V4-L.1, Axis-B). */
|
|
186
186
|
systemPrompt?: string | SystemPromptResolver;
|
|
187
|
+
/**
|
|
188
|
+
* Agent-level conversation memory: the `ConversationStorageAdapter` the SDK persists turns to
|
|
189
|
+
* (`Agent.getOrCreate({ conversationStorage })`). Populated by `defineAgent({ conversationStorage })`
|
|
190
|
+
* / `.conversationStorage(adapter)`. A per-run override (`RuntimeOverrides.conversationStorage`)
|
|
191
|
+
* wins over this; absent ⇒ the SDK default store is chosen lazily. Distinct from `@Checkpoint`,
|
|
192
|
+
* which only toggles filesystem-vs-memory for the built-in default.
|
|
193
|
+
*/
|
|
194
|
+
conversationStorage?: ConversationStorageAdapter;
|
|
187
195
|
tools: CompiledTool[];
|
|
188
196
|
agents: Record<string, CompiledSubAgent>;
|
|
189
197
|
memory?: MemoryOptions;
|
|
@@ -721,6 +729,13 @@ interface DefineAgentConfig<TInput extends z.ZodType = z.ZodType> {
|
|
|
721
729
|
* request path against the run-context). Absent ⇒ the SDK enables every discovered skill.
|
|
722
730
|
*/
|
|
723
731
|
skills?: SkillsSelection;
|
|
732
|
+
/**
|
|
733
|
+
* Conversation memory: the `ConversationStorageAdapter` the agent persists its turns to. Swap it to
|
|
734
|
+
* control WHERE memory lives — `InMemoryConversationStorage` (ephemeral, great for tests) vs
|
|
735
|
+
* `FileSystemConversationStorage` (durable) vs a custom adapter. Absent ⇒ the SDK picks its default
|
|
736
|
+
* store. A per-run override still wins over this agent-level default.
|
|
737
|
+
*/
|
|
738
|
+
conversationStorage?: ConversationStorageAdapter;
|
|
724
739
|
}
|
|
725
740
|
/**
|
|
726
741
|
* A branded agent definition — the value {@link defineAgent} returns.
|
|
@@ -842,6 +857,11 @@ interface AgentBuilder<TInput extends z.ZodType | UnsetMarker = UnsetMarker, TMo
|
|
|
842
857
|
approvals(map: Record<string, HumanInTheLoopOptions>): AgentBuilder<TInput, TModel, TContext, TTools>;
|
|
843
858
|
/** M13 — select skills: a static list OR a per-request resolver `(ctx) => string[]`. */
|
|
844
859
|
skills(selection: SkillsSelection): AgentBuilder<TInput, TModel, TContext, TTools>;
|
|
860
|
+
/**
|
|
861
|
+
* Set the agent's conversation memory — the `ConversationStorageAdapter` the SDK persists turns to.
|
|
862
|
+
* Swap in-memory ⇄ filesystem ⇄ custom without touching the runtime. A per-run override still wins.
|
|
863
|
+
*/
|
|
864
|
+
conversationStorage(adapter: ConversationStorageAdapter): AgentBuilder<TInput, TModel, TContext, TTools>;
|
|
845
865
|
/**
|
|
846
866
|
* Apply a reusable partial chain (Spring-Boot-style composition). `preset` receives the current
|
|
847
867
|
* 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-DYXCEzdJ.js';
|
|
2
2
|
import '@theokit/http';
|
|
3
3
|
import './types-DVA4LQsA.js';
|
|
4
4
|
import '@theokit/sdk';
|
package/dist/bridge.js
CHANGED
|
@@ -804,6 +804,15 @@ async function* extractThinkTagStream(source) {
|
|
|
804
804
|
}
|
|
805
805
|
__name(extractThinkTagStream, "extractThinkTagStream");
|
|
806
806
|
|
|
807
|
+
// src/debug-log.ts
|
|
808
|
+
function debugLog(marker, data) {
|
|
809
|
+
const flag = process.env.THEOKIT_DEBUG;
|
|
810
|
+
if (flag !== void 0 && flag !== "" && flag !== "0" && flag !== "false") {
|
|
811
|
+
console.debug(marker, data);
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
__name(debugLog, "debugLog");
|
|
815
|
+
|
|
807
816
|
// src/bridge/sdk-adapter-create-options.ts
|
|
808
817
|
function assembleM8CreateOptions(compiled) {
|
|
809
818
|
const options = {};
|
|
@@ -1171,7 +1180,7 @@ function createSdkAgentStream(compiled, compiledTools, apiKey, overrides = {}) {
|
|
|
1171
1180
|
const reasoningEffort = overrides.reasoningEffort ?? compiled.reasoningEffort;
|
|
1172
1181
|
const { parseThinkTags, stripToolDialect } = resolveTextTransformFlags(compiled, overrides);
|
|
1173
1182
|
const runContext = overrides.runContext ?? compiled.runContext;
|
|
1174
|
-
let storage = overrides.conversationStorage;
|
|
1183
|
+
let storage = overrides.conversationStorage ?? compiled.conversationStorage;
|
|
1175
1184
|
return (message, sessionId, factoryOpts) => ({
|
|
1176
1185
|
async *[Symbol.asyncIterator]() {
|
|
1177
1186
|
const runId = `run-${Date.now()}`;
|
|
@@ -1196,7 +1205,7 @@ function createSdkAgentStream(compiled, compiledTools, apiKey, overrides = {}) {
|
|
|
1196
1205
|
} else {
|
|
1197
1206
|
runContextSource = "none";
|
|
1198
1207
|
}
|
|
1199
|
-
|
|
1208
|
+
debugLog("[THEO_AGENT_M7_RUN_CONTEXT]", {
|
|
1200
1209
|
source: runContextSource,
|
|
1201
1210
|
keys: runContext !== void 0 ? Object.keys(runContext) : []
|
|
1202
1211
|
});
|
|
@@ -1237,7 +1246,7 @@ async function* streamSdkAgent(rt, compiled, sdkTools, storage, opts) {
|
|
|
1237
1246
|
};
|
|
1238
1247
|
const extra = buildExtraCreateOptions(overrides, compiled);
|
|
1239
1248
|
if (applied.length > 0) {
|
|
1240
|
-
|
|
1249
|
+
debugLog("[THEO_AGENT_M8_RUNTIME_APPLIED]", {
|
|
1241
1250
|
skills: applied.includes("skills"),
|
|
1242
1251
|
contextWindow: applied.includes("context"),
|
|
1243
1252
|
projectContext: applied.includes("projectContext")
|
|
@@ -1482,7 +1491,12 @@ function compileAgentDefinition(def) {
|
|
|
1482
1491
|
hitl: compileApprovals(def)
|
|
1483
1492
|
} : {},
|
|
1484
1493
|
// M13 — skills: a static list → SDK skills.enabled; a resolver → carried for the request path.
|
|
1485
|
-
...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
|
+
} : {}
|
|
1486
1500
|
};
|
|
1487
1501
|
}
|
|
1488
1502
|
__name(compileAgentDefinition, "compileAgentDefinition");
|
|
@@ -1576,6 +1590,10 @@ function makeBuilder(config) {
|
|
|
1576
1590
|
...config,
|
|
1577
1591
|
skills: selection
|
|
1578
1592
|
}), "skills"),
|
|
1593
|
+
conversationStorage: /* @__PURE__ */ __name((adapter) => makeBuilder({
|
|
1594
|
+
...config,
|
|
1595
|
+
conversationStorage: adapter
|
|
1596
|
+
}), "conversationStorage"),
|
|
1579
1597
|
use: /* @__PURE__ */ __name((preset) => preset(runtime), "use"),
|
|
1580
1598
|
build: /* @__PURE__ */ __name(() => defineAgent(config), "build")
|
|
1581
1599
|
};
|
|
@@ -2152,7 +2170,7 @@ __name(accumulateUsage, "accumulateUsage");
|
|
|
2152
2170
|
function finalize(acc, round, reason, strategyName) {
|
|
2153
2171
|
acc.rounds = round;
|
|
2154
2172
|
acc.finishReason = reason;
|
|
2155
|
-
|
|
2173
|
+
debugLog(MAINLOOP_METRIC, {
|
|
2156
2174
|
strategy: strategyName,
|
|
2157
2175
|
rounds: round,
|
|
2158
2176
|
terminal: reason
|
|
@@ -2951,4 +2969,4 @@ export {
|
|
|
2951
2969
|
generateAgentManifest,
|
|
2952
2970
|
agentsPlugin
|
|
2953
2971
|
};
|
|
2954
|
-
//# sourceMappingURL=chunk-
|
|
2972
|
+
//# sourceMappingURL=chunk-RJTRE6BD.js.map
|