@theokit/agents 0.7.0 → 0.9.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-CIwzw_3z.d.ts → bridge-entry-Dt3Fr6md.d.ts} +3 -2
- package/dist/bridge.d.ts +2 -2
- package/dist/bridge.js +2 -2
- package/dist/{chunk-2MYIZ4OT.js → chunk-5FZVMZPG.js} +130 -27
- package/dist/chunk-5FZVMZPG.js.map +1 -0
- package/dist/{chunk-MVEY7HEY.js → chunk-GVPUUKKE.js} +19 -1
- package/dist/chunk-GVPUUKKE.js.map +1 -0
- package/dist/{chunk-XWVZS2PQ.js → chunk-SKTJS4QQ.js} +2 -2
- package/dist/decorators.d.ts +2 -2
- package/dist/decorators.js +6 -2
- package/dist/index.d.ts +154 -23
- package/dist/index.js +15 -3
- package/dist/{skills-DnfvEUSg.d.ts → skills-BHnHPn7p.d.ts} +13 -1
- package/package.json +3 -3
- package/dist/chunk-2MYIZ4OT.js.map +0 -1
- package/dist/chunk-MVEY7HEY.js.map +0 -1
- /package/dist/{chunk-XWVZS2PQ.js.map → chunk-SKTJS4QQ.js.map} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ExecutionContext } from '@theokit/http';
|
|
2
|
-
import { A as AgentOptions, T as ToolOptions,
|
|
2
|
+
import { A as AgentOptions, T as ToolOptions, g as MainLoopMeta, a as ApprovalOptions, B as BudgetOptions, f as GatewayOptions, l as MemoryOptions, s as SkillsOptions, e as ContextWindowOptions, q as ProjectContextOptions, j as McpServersMap, b as CompactionDecoratorConfig } from './skills-BHnHPn7p.js';
|
|
3
3
|
import { SkillsSettings, ContextSettings, SystemPromptResolver } from '@theokit/sdk';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
|
|
@@ -63,6 +63,7 @@ interface AgentWalkResult {
|
|
|
63
63
|
contextWindow?: ContextWindowOptions;
|
|
64
64
|
projectContext?: ProjectContextOptions;
|
|
65
65
|
mcpServers?: McpServersMap;
|
|
66
|
+
compaction?: CompactionDecoratorConfig;
|
|
66
67
|
}
|
|
67
68
|
interface ToolboxWalkResult {
|
|
68
69
|
class: Function;
|
|
@@ -621,4 +622,4 @@ declare function agentsPlugin(opts: AgentsPluginOptions): {
|
|
|
621
622
|
register(app: PluginApp): void;
|
|
622
623
|
};
|
|
623
624
|
|
|
624
|
-
export { isApprovalRequired as $, type AgentExecutionContext as A, BudgetExceededError as B, type CompiledAgentOptions as C, type DelegationResult as D, type ErrorEvent as E, type FileEditEvent as F, type ToolCallEvent as G, type ToolResultEvent as H, type IterationEvent as I, type ToolWalkResult as J, type ToolboxWalkResult as K, type LoopOutcome as L, agentsPlugin as M, compileAgent as N, compileContextWindow as O, compileProjectContext as P, compileSkills as Q, type RunStartedEvent as R, type
|
|
625
|
+
export { isApprovalRequired as $, type AgentExecutionContext as A, BudgetExceededError as B, type CompiledAgentOptions as C, type DelegationResult as D, type ErrorEvent as E, type FileEditEvent as F, type ToolCallEvent as G, type ToolResultEvent as H, type IterationEvent as I, type ToolWalkResult as J, type ToolboxWalkResult as K, type LoopOutcome as L, agentsPlugin as M, compileAgent as N, compileContextWindow as O, compileProjectContext as P, compileSkills as Q, type RunStartedEvent as R, type StreamEvent as S, type TextDeltaEvent as T, compileTools as U, createAgentExecutionContext as V, createSdkAgentStream as W, delegate as X, generateAgentManifest as Y, generateAgentRoutes as Z, isAgentContext as _, type LoopStrategy as a, isDone as a0, isError as a1, isTextDelta as a2, isToolCall as a3, isToolResult as a4, loopStrategyConfigSchema as a5, projectContextMetadataOnlyKnobs as a6, resolveLoopStrategy as a7, streamAgentResponse as a8, translateSdkEvent as a9, validateUniqueRoutes as aa, walkAgentMetadata as ab, type CompiledTool as b, type AgentManifest as c, type AgentManifestEntry as d, type AgentManifestTool as e, type AgentRoute as f, type AgentRouteContext as g, type AgentRunInfo as h, type AgentStreamEvent as i, type AgentWalkResult as j, AgentWarningCode as k, type AgentsPluginOptions as l, type ApprovalRequiredEvent as m, type ArtifactChunkEvent as n, type ArtifactStartEvent as o, type CheckpointSavedEvent as p, type CompiledContextWindow as q, DEFAULT_MAX_ITERATIONS as r, type DelegateOptions as s, DelegationError as t, type DoneEvent as u, type LoopFinishReason as v, type LoopStrategyConfig as w, type SdkMessage as x, type StateUpdateEvent as y, type ThinkingEvent as z };
|
package/dist/bridge.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { A as AgentExecutionContext,
|
|
1
|
+
export { A as AgentExecutionContext, c as AgentManifest, d as AgentManifestEntry, e as AgentManifestTool, f as AgentRoute, g as AgentRouteContext, h as AgentRunInfo, i as AgentStreamEvent, j as AgentWalkResult, k as AgentWarningCode, l as AgentsPluginOptions, m as ApprovalRequiredEvent, n as ArtifactChunkEvent, o as ArtifactStartEvent, B as BudgetExceededError, p as CheckpointSavedEvent, C as CompiledAgentOptions, q as CompiledContextWindow, b as CompiledTool, s as DelegateOptions, t as DelegationError, D as DelegationResult, u as DoneEvent, E as ErrorEvent, F as FileEditEvent, I as IterationEvent, R as RunStartedEvent, x as SdkMessage, y as StateUpdateEvent, S as StreamEvent, T as TextDeltaEvent, z as ThinkingEvent, G as ToolCallEvent, H as ToolResultEvent, J as ToolWalkResult, K as ToolboxWalkResult, M as agentsPlugin, N as compileAgent, O as compileContextWindow, P as compileProjectContext, Q as compileSkills, U as compileTools, V as createAgentExecutionContext, W as createSdkAgentStream, X as delegate, Y as generateAgentManifest, Z as generateAgentRoutes, _ as isAgentContext, $ as isApprovalRequired, a0 as isDone, a1 as isError, a2 as isTextDelta, a3 as isToolCall, a4 as isToolResult, a6 as projectContextMetadataOnlyKnobs, a8 as streamAgentResponse, a9 as translateSdkEvent, aa as validateUniqueRoutes, ab as walkAgentMetadata } from './bridge-entry-Dt3Fr6md.js';
|
|
2
2
|
import '@theokit/http';
|
|
3
|
-
import './skills-
|
|
3
|
+
import './skills-BHnHPn7p.js';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import '@theokit/sdk';
|
package/dist/bridge.js
CHANGED
|
@@ -25,8 +25,8 @@ import {
|
|
|
25
25
|
translateSdkEvent,
|
|
26
26
|
validateUniqueRoutes,
|
|
27
27
|
walkAgentMetadata
|
|
28
|
-
} from "./chunk-
|
|
29
|
-
import "./chunk-
|
|
28
|
+
} from "./chunk-5FZVMZPG.js";
|
|
29
|
+
import "./chunk-GVPUUKKE.js";
|
|
30
30
|
import "./chunk-7QVYU63E.js";
|
|
31
31
|
export {
|
|
32
32
|
AgentWarningCode,
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
TOOL_METHODS,
|
|
10
10
|
Trace,
|
|
11
11
|
getAgentConfig,
|
|
12
|
+
getCompactionConfig,
|
|
12
13
|
getContextWindowConfig,
|
|
13
14
|
getGatewayConfig,
|
|
14
15
|
getMcpConfig,
|
|
@@ -18,7 +19,7 @@ import {
|
|
|
18
19
|
getProjectContextConfig,
|
|
19
20
|
getSkillsConfig,
|
|
20
21
|
getSubAgents
|
|
21
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-GVPUUKKE.js";
|
|
22
23
|
import {
|
|
23
24
|
__name
|
|
24
25
|
} from "./chunk-7QVYU63E.js";
|
|
@@ -205,6 +206,7 @@ function walkAgentMetadata(AgentClass, toolboxClasses = []) {
|
|
|
205
206
|
const contextWindow = getContextWindowConfig(AgentClass);
|
|
206
207
|
const projectContext = getProjectContextConfig(AgentClass);
|
|
207
208
|
warnUnmappedDecoratorKnobs(AgentClass.name, contextWindow, projectContext);
|
|
209
|
+
const compaction = getCompactionConfig(AgentClass);
|
|
208
210
|
const result = {
|
|
209
211
|
agentConfig,
|
|
210
212
|
mainLoop,
|
|
@@ -219,7 +221,8 @@ function walkAgentMetadata(AgentClass, toolboxClasses = []) {
|
|
|
219
221
|
skills,
|
|
220
222
|
contextWindow,
|
|
221
223
|
projectContext,
|
|
222
|
-
mcpServers
|
|
224
|
+
mcpServers,
|
|
225
|
+
compaction
|
|
223
226
|
};
|
|
224
227
|
if (toolboxClasses.length === 0) {
|
|
225
228
|
agentWalkCache.set(AgentClass, result);
|
|
@@ -694,16 +697,47 @@ function createSdkAgentStream(compiled, compiledTools, apiKey, envModel) {
|
|
|
694
697
|
}
|
|
695
698
|
__name(createSdkAgentStream, "createSdkAgentStream");
|
|
696
699
|
|
|
697
|
-
// src/loop/
|
|
700
|
+
// src/loop/compaction-strategy.ts
|
|
701
|
+
import { compactTranscript } from "@theokit/sdk/compaction";
|
|
698
702
|
import { z } from "zod";
|
|
703
|
+
var DEFAULT_KEEP_TOKENS = 8e3;
|
|
704
|
+
var compactionStrategyConfigSchema = z.object({
|
|
705
|
+
name: z.literal("token-budget"),
|
|
706
|
+
keepTokens: z.number().int().positive()
|
|
707
|
+
});
|
|
708
|
+
function resolveCompactionStrategy(name, config) {
|
|
709
|
+
const cfg = compactionStrategyConfigSchema.parse({
|
|
710
|
+
name,
|
|
711
|
+
keepTokens: config.keepTokens
|
|
712
|
+
});
|
|
713
|
+
return {
|
|
714
|
+
name: cfg.name,
|
|
715
|
+
keepTokens: cfg.keepTokens,
|
|
716
|
+
compact: /* @__PURE__ */ __name((messages, options) => compactTranscript(messages, {
|
|
717
|
+
keepTokens: options?.keepTokens ?? cfg.keepTokens,
|
|
718
|
+
summarize: options?.summarize,
|
|
719
|
+
marker: options?.marker,
|
|
720
|
+
summaryTemplate: options?.summaryTemplate,
|
|
721
|
+
// Default-safe: a thrown summarize keeps the transcript (app opts out via failSafe:false).
|
|
722
|
+
failSafe: options?.failSafe ?? true
|
|
723
|
+
}), "compact")
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
__name(resolveCompactionStrategy, "resolveCompactionStrategy");
|
|
727
|
+
var tokenBudgetCompactionStrategy = resolveCompactionStrategy("token-budget", {
|
|
728
|
+
keepTokens: DEFAULT_KEEP_TOKENS
|
|
729
|
+
});
|
|
730
|
+
|
|
731
|
+
// src/loop/loop-strategy.ts
|
|
732
|
+
import { z as z2 } from "zod";
|
|
699
733
|
var DEFAULT_MAX_ITERATIONS = 8;
|
|
700
|
-
var loopStrategyConfigSchema =
|
|
701
|
-
name:
|
|
734
|
+
var loopStrategyConfigSchema = z2.object({
|
|
735
|
+
name: z2.enum([
|
|
702
736
|
"simple-chat",
|
|
703
737
|
"plan-act-reflect",
|
|
704
738
|
"react"
|
|
705
739
|
]),
|
|
706
|
-
maxIterations:
|
|
740
|
+
maxIterations: z2.number().int().min(1)
|
|
707
741
|
});
|
|
708
742
|
function resolveLoopStrategy(strategy, maxIterations = DEFAULT_MAX_ITERATIONS) {
|
|
709
743
|
const cfg = loopStrategyConfigSchema.parse({
|
|
@@ -726,9 +760,9 @@ function resolveLoopStrategy(strategy, maxIterations = DEFAULT_MAX_ITERATIONS) {
|
|
|
726
760
|
__name(resolveLoopStrategy, "resolveLoopStrategy");
|
|
727
761
|
|
|
728
762
|
// src/loop/reflection-strategy.ts
|
|
729
|
-
import { z as
|
|
730
|
-
var reflectionStrategyConfigSchema =
|
|
731
|
-
name:
|
|
763
|
+
import { z as z3 } from "zod";
|
|
764
|
+
var reflectionStrategyConfigSchema = z3.object({
|
|
765
|
+
name: z3.string().min(1)
|
|
732
766
|
});
|
|
733
767
|
var ladderReflectionStrategy = {
|
|
734
768
|
name: "ladder",
|
|
@@ -821,9 +855,9 @@ function buildPrompt(round, maxIterations, message, feedback) {
|
|
|
821
855
|
return hint + body;
|
|
822
856
|
}
|
|
823
857
|
__name(buildPrompt, "buildPrompt");
|
|
824
|
-
async function consumeRoundOrThrow(factory, prompt, sessionId, signal, agentName) {
|
|
858
|
+
async function* consumeRoundOrThrow(factory, prompt, sessionId, signal, agentName) {
|
|
825
859
|
try {
|
|
826
|
-
return
|
|
860
|
+
return yield* consumeOneRound(factory, prompt, sessionId, signal);
|
|
827
861
|
} catch (err) {
|
|
828
862
|
if (err instanceof BudgetExceededError || err instanceof DelegationError) throw err;
|
|
829
863
|
throw new DelegationError(agentName, err);
|
|
@@ -848,7 +882,7 @@ function deriveFinishReason(signals) {
|
|
|
848
882
|
return "stop";
|
|
849
883
|
}
|
|
850
884
|
__name(deriveFinishReason, "deriveFinishReason");
|
|
851
|
-
async function consumeOneRound(factory, prompt, sessionId, signal) {
|
|
885
|
+
async function* consumeOneRound(factory, prompt, sessionId, signal) {
|
|
852
886
|
const r = {
|
|
853
887
|
responseText: "",
|
|
854
888
|
toolCalls: [],
|
|
@@ -865,6 +899,7 @@ async function consumeOneRound(factory, prompt, sessionId, signal) {
|
|
|
865
899
|
};
|
|
866
900
|
for await (const event of factory(prompt, sessionId)) {
|
|
867
901
|
if (signal?.aborted) break;
|
|
902
|
+
yield event;
|
|
868
903
|
if (event.type === "text_delta" && typeof event.content === "string") {
|
|
869
904
|
r.responseText += event.content;
|
|
870
905
|
} else if (event.type === "tool_result") {
|
|
@@ -888,7 +923,7 @@ async function consumeOneRound(factory, prompt, sessionId, signal) {
|
|
|
888
923
|
return r;
|
|
889
924
|
}
|
|
890
925
|
__name(consumeOneRound, "consumeOneRound");
|
|
891
|
-
async function
|
|
926
|
+
async function* runReflectiveLoopStream(factory, message, sessionId, config) {
|
|
892
927
|
const { loop, reflection, budget = Number.POSITIVE_INFINITY, signal, agentName = loop.name } = config;
|
|
893
928
|
const acc = {
|
|
894
929
|
response: "",
|
|
@@ -897,13 +932,14 @@ async function runReflectiveLoop(factory, message, sessionId, config) {
|
|
|
897
932
|
tokens: 0,
|
|
898
933
|
rounds: 0
|
|
899
934
|
};
|
|
935
|
+
const reflectionContext = {};
|
|
900
936
|
let round = 1;
|
|
901
937
|
let feedback;
|
|
902
938
|
let prevSig;
|
|
903
939
|
let stuck = 0;
|
|
904
940
|
while (!signal?.aborted) {
|
|
905
941
|
const prompt = buildPrompt(round, loop.maxIterations, message, feedback);
|
|
906
|
-
const r =
|
|
942
|
+
const r = yield* consumeRoundOrThrow(factory, prompt, sessionId, signal, agentName);
|
|
907
943
|
acc.response += r.responseText;
|
|
908
944
|
acc.toolCalls.push(...r.toolCalls);
|
|
909
945
|
acc.cost += r.cost;
|
|
@@ -924,7 +960,7 @@ async function runReflectiveLoop(factory, message, sessionId, config) {
|
|
|
924
960
|
toolCalls: r.toolCalls,
|
|
925
961
|
responseText: r.responseText
|
|
926
962
|
};
|
|
927
|
-
const reflectionResult = reflection.reflect(outcome);
|
|
963
|
+
const reflectionResult = reflection.reflect(outcome, reflectionContext);
|
|
928
964
|
if (!(reflectionResult.continue && loop.shouldContinue(outcome))) {
|
|
929
965
|
const reason = terminalReason(reflectionResult.continue, r.finishReason, round, loop.maxIterations);
|
|
930
966
|
return finalize(acc, round, reason, loop.name);
|
|
@@ -935,6 +971,13 @@ async function runReflectiveLoop(factory, message, sessionId, config) {
|
|
|
935
971
|
acc.rounds = round - 1;
|
|
936
972
|
return acc;
|
|
937
973
|
}
|
|
974
|
+
__name(runReflectiveLoopStream, "runReflectiveLoopStream");
|
|
975
|
+
async function runReflectiveLoop(factory, message, sessionId, config) {
|
|
976
|
+
const gen = runReflectiveLoopStream(factory, message, sessionId, config);
|
|
977
|
+
let res = await gen.next();
|
|
978
|
+
while (!res.done) res = await gen.next();
|
|
979
|
+
return res.value;
|
|
980
|
+
}
|
|
938
981
|
__name(runReflectiveLoop, "runReflectiveLoop");
|
|
939
982
|
|
|
940
983
|
// src/loop/agent-runner.ts
|
|
@@ -944,25 +987,50 @@ var AgentRunner = class {
|
|
|
944
987
|
}
|
|
945
988
|
compiled;
|
|
946
989
|
agentName;
|
|
990
|
+
/** The resolved terminal-decision strategy (parity with `delegate()`). */
|
|
947
991
|
loopStrategy;
|
|
992
|
+
/** The resolved between-round reflection (default or `.reflection(custom)` override). */
|
|
948
993
|
reflectionStrategy;
|
|
994
|
+
/**
|
|
995
|
+
* Recorded streaming preference. The reflective loop currently always streams via
|
|
996
|
+
* the SDK `Run.stream()`; a non-streaming collect mode is future work — the flag is
|
|
997
|
+
* captured + exposed here, not yet branched on (honest per G10: documented, not a
|
|
998
|
+
* silent no-op).
|
|
999
|
+
*/
|
|
949
1000
|
streamEnabled;
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
1001
|
+
/**
|
|
1002
|
+
* V4-F: the resolved compaction strategy (from `@Compaction` or `.compaction()`),
|
|
1003
|
+
* or `undefined` when neither is declared — compaction is opt-in (EC-4). CALLABLE
|
|
1004
|
+
* by the app (ADR D1: `runner.compaction?.compact(messages, { summarize })`); the
|
|
1005
|
+
* reflective loop does NOT auto-invoke it (the SDK owns per-turn context).
|
|
1006
|
+
*/
|
|
1007
|
+
compaction;
|
|
1008
|
+
constructor(state) {
|
|
1009
|
+
this.compiled = state.compiled;
|
|
1010
|
+
this.agentName = state.agentName;
|
|
1011
|
+
this.loopStrategy = state.loopStrategy;
|
|
1012
|
+
this.reflectionStrategy = state.reflectionStrategy;
|
|
1013
|
+
this.streamEnabled = state.streamEnabled;
|
|
1014
|
+
this.compaction = state.compaction;
|
|
956
1015
|
}
|
|
957
1016
|
/** Start a fluent builder for `AgentClass`. */
|
|
958
1017
|
static builder(AgentClass) {
|
|
959
1018
|
return new AgentRunnerBuilder(AgentClass);
|
|
960
1019
|
}
|
|
961
|
-
/**
|
|
962
|
-
|
|
963
|
-
|
|
1020
|
+
/**
|
|
1021
|
+
* V4-D-stream: stream the agent's events LIVE across the reflective loop, returning
|
|
1022
|
+
* the aggregated {@link DelegationResult} as the generator's return value. This is the
|
|
1023
|
+
* on-ramp for streaming-first apps (SSE) — `runReflectiveLoopStream` yields every
|
|
1024
|
+
* round's events before the loop terminates. `streamEnabled` is honored: when the
|
|
1025
|
+
* builder set `.stream(false)`, callers should use {@link run} instead.
|
|
1026
|
+
*/
|
|
1027
|
+
stream(message, opts) {
|
|
1028
|
+
const tools = opts.tools ? [
|
|
1029
|
+
...opts.tools
|
|
1030
|
+
] : this.compiled.tools;
|
|
1031
|
+
const streamFactory = createSdkAgentStream(this.compiled, tools, opts.apiKey, this.compiled.model);
|
|
964
1032
|
const sessionId = opts.sessionId ?? `runner-${crypto.randomUUID()}`;
|
|
965
|
-
return
|
|
1033
|
+
return runReflectiveLoopStream(streamFactory, message, sessionId, {
|
|
966
1034
|
loop: this.loopStrategy,
|
|
967
1035
|
reflection: this.reflectionStrategy,
|
|
968
1036
|
budget: opts.budget,
|
|
@@ -970,6 +1038,13 @@ var AgentRunner = class {
|
|
|
970
1038
|
signal: opts.signal
|
|
971
1039
|
});
|
|
972
1040
|
}
|
|
1041
|
+
/** Run the agent to a terminal result via the shared reflective loop (collect mode). */
|
|
1042
|
+
async run(message, opts) {
|
|
1043
|
+
const gen = this.stream(message, opts);
|
|
1044
|
+
let res = await gen.next();
|
|
1045
|
+
while (!res.done) res = await gen.next();
|
|
1046
|
+
return res.value;
|
|
1047
|
+
}
|
|
973
1048
|
};
|
|
974
1049
|
var AgentRunnerBuilder = class {
|
|
975
1050
|
static {
|
|
@@ -978,6 +1053,7 @@ var AgentRunnerBuilder = class {
|
|
|
978
1053
|
AgentClass;
|
|
979
1054
|
reflectionOverride;
|
|
980
1055
|
streamEnabled = true;
|
|
1056
|
+
compactionOverride;
|
|
981
1057
|
constructor(AgentClass) {
|
|
982
1058
|
this.AgentClass = AgentClass;
|
|
983
1059
|
}
|
|
@@ -991,6 +1067,18 @@ var AgentRunnerBuilder = class {
|
|
|
991
1067
|
this.streamEnabled = enabled;
|
|
992
1068
|
return this;
|
|
993
1069
|
}
|
|
1070
|
+
/**
|
|
1071
|
+
* V4-F: declare the compaction strategy (e.g. `.compaction('token-budget', { keepTokens: 8000 })`).
|
|
1072
|
+
* Resolved + validated at {@link build} (EC-5 — fail-fast there, not here). This builder
|
|
1073
|
+
* call WINS over a `@Compaction` decorator on the same agent (EC-1 — explicit override).
|
|
1074
|
+
*/
|
|
1075
|
+
compaction(name, options = {}) {
|
|
1076
|
+
this.compactionOverride = {
|
|
1077
|
+
name,
|
|
1078
|
+
keepTokens: options.keepTokens
|
|
1079
|
+
};
|
|
1080
|
+
return this;
|
|
1081
|
+
}
|
|
994
1082
|
/** Walk + compile + resolve strategies — the compile→execute boundary (no I/O). */
|
|
995
1083
|
build() {
|
|
996
1084
|
const walk = walkAgentMetadata(this.AgentClass, []);
|
|
@@ -1001,7 +1089,18 @@ var AgentRunnerBuilder = class {
|
|
|
1001
1089
|
const compiled = compileAgent(walk, toolboxInstances);
|
|
1002
1090
|
const loopStrategy = resolveLoopStrategy(walk.mainLoop.strategy, walk.mainLoop.maxIterations);
|
|
1003
1091
|
const reflectionStrategy = this.reflectionOverride ?? (walk.mainLoop.strategy === "plan-act-reflect" ? ladderReflectionStrategy : noopReflectionStrategy);
|
|
1004
|
-
|
|
1092
|
+
const compactionDecl = this.compactionOverride ?? walk.compaction;
|
|
1093
|
+
const compaction = compactionDecl ? resolveCompactionStrategy(compactionDecl.name, {
|
|
1094
|
+
keepTokens: compactionDecl.keepTokens
|
|
1095
|
+
}) : void 0;
|
|
1096
|
+
return new AgentRunner({
|
|
1097
|
+
compiled,
|
|
1098
|
+
agentName: walk.agentConfig.name,
|
|
1099
|
+
loopStrategy,
|
|
1100
|
+
reflectionStrategy,
|
|
1101
|
+
streamEnabled: this.streamEnabled,
|
|
1102
|
+
compaction
|
|
1103
|
+
});
|
|
1005
1104
|
}
|
|
1006
1105
|
};
|
|
1007
1106
|
|
|
@@ -1193,6 +1292,10 @@ export {
|
|
|
1193
1292
|
generateAgentRoutes,
|
|
1194
1293
|
translateSdkEvent,
|
|
1195
1294
|
createSdkAgentStream,
|
|
1295
|
+
DEFAULT_KEEP_TOKENS,
|
|
1296
|
+
compactionStrategyConfigSchema,
|
|
1297
|
+
resolveCompactionStrategy,
|
|
1298
|
+
tokenBudgetCompactionStrategy,
|
|
1196
1299
|
DEFAULT_MAX_ITERATIONS,
|
|
1197
1300
|
loopStrategyConfigSchema,
|
|
1198
1301
|
resolveLoopStrategy,
|
|
@@ -1207,4 +1310,4 @@ export {
|
|
|
1207
1310
|
generateAgentManifest,
|
|
1208
1311
|
agentsPlugin
|
|
1209
1312
|
};
|
|
1210
|
-
//# sourceMappingURL=chunk-
|
|
1313
|
+
//# sourceMappingURL=chunk-5FZVMZPG.js.map
|