@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
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,96 @@
|
|
|
1
1
|
export { Agent, Artifact, ArtifactOptions, ArtifactResult, Audit, Budget, Checkpoint, CheckpointOptions, CheckpointState, CheckpointStorage, CheckpointStrategy, CommandPermissions, CompactionStrategy, Conversation, ConversationOptions, ConversationStorage, EditFormat, EditFormatType, FilesystemPermissions, Hook, HookEntry, HookPoint, HumanInTheLoop, HumanInTheLoopOptions, MainLoop, Mixin, Model, Observable, ObservableEntry, Policy, RequiresApproval, RequiresCapability, Sandbox, SandboxOptions, SubAgents, TimeoutAction, Tool, Toolbox, Trace, applyDecorators, getAgentConfig, getArtifactConfig, getCheckpointConfig, getConversationConfig, getHooks, getHooksByPoint, getHumanInTheLoopConfig, getMainLoop, getMixins, getObservableByChannel, getObservables, getSandboxConfig, getSubAgents, getToolConfig, getToolMethods, getToolboxConfig, isCommandAllowed, isPathAllowed } from './decorators.js';
|
|
2
|
-
export { A as AgentOptions, a as ApprovalOptions, B as BudgetOptions, C as
|
|
3
|
-
import { L as LoopOutcome, a as LoopStrategy, C as CompiledAgentOptions, D as DelegationResult } from './bridge-entry-
|
|
4
|
-
export { A as AgentExecutionContext,
|
|
2
|
+
export { A as AgentOptions, a as ApprovalOptions, B as BudgetOptions, C as Compaction, b as CompactionDecoratorConfig, c as ContextCompactionStrategy, d as ContextWindow, e as ContextWindowOptions, G as Gateway, f as GatewayOptions, I as IndexStrategy, M as MCP, g as MainLoopMeta, h as MainLoopOptions, i as McpServerConfig, j as McpServersMap, k as Memory, l as MemoryOptions, m as MemoryProvider, n as MemoryScope, P as PlatformName, o as PolicyHandler, p as ProjectContext, q as ProjectContextOptions, R as RelevanceStrategy, S as SessionStrategy, r as Skills, s as SkillsOptions, T as ToolOptions, t as ToolboxOptions, u as getCompactionConfig, v as getContextWindowConfig, w as getGatewayConfig, x as getMcpConfig, y as getMemoryConfig, z as getProjectContextConfig, D as getSkillsConfig, E as resolveSessionId } from './skills-BHnHPn7p.js';
|
|
3
|
+
import { L as LoopOutcome, a as LoopStrategy, C as CompiledAgentOptions, b as CompiledTool, S as StreamEvent, D as DelegationResult } from './bridge-entry-Dt3Fr6md.js';
|
|
4
|
+
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, q as CompiledContextWindow, r as DEFAULT_MAX_ITERATIONS, s as DelegateOptions, t as DelegationError, u as DoneEvent, E as ErrorEvent, F as FileEditEvent, I as IterationEvent, v as LoopFinishReason, w as LoopStrategyConfig, R as RunStartedEvent, x as SdkMessage, y as StateUpdateEvent, 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, a5 as loopStrategyConfigSchema, a6 as projectContextMetadataOnlyKnobs, a7 as resolveLoopStrategy, a8 as streamAgentResponse, a9 as translateSdkEvent, aa as validateUniqueRoutes, ab as walkAgentMetadata } from './bridge-entry-Dt3Fr6md.js';
|
|
5
|
+
import { CompressibleMessage } from '@theokit/sdk/compaction';
|
|
6
|
+
export { CompressibleMessage } from '@theokit/sdk/compaction';
|
|
5
7
|
import { z } from 'zod';
|
|
6
8
|
import '@theokit/http';
|
|
7
9
|
import '@theokit/sdk';
|
|
8
10
|
|
|
11
|
+
/**
|
|
12
|
+
* TranscriptCompactionStrategy — a named, callable transcript-compaction authoring layer
|
|
13
|
+
* (Strategy pattern, V4-F). Mirrors `ReflectionStrategy`/`LoopStrategy`: interface
|
|
14
|
+
* + zod config schema + a `'token-budget'` default + `resolveCompactionStrategy`.
|
|
15
|
+
*
|
|
16
|
+
* The `'token-budget'` strategy DELEGATES to the SDK's `compactTranscript` (ADR D2 /
|
|
17
|
+
* G2 / sdk-runtime.md — the SDK owns the algorithm; agents owns the named interface;
|
|
18
|
+
* no reimplementation). Per ADR D1 it is CALLABLE by the app (exposed as
|
|
19
|
+
* `AgentRunner.compaction`), NOT auto-invoked by the reflective loop — the SDK owns
|
|
20
|
+
* per-turn context, so the app decides WHEN to compact and supplies the `summarize`
|
|
21
|
+
* callback (its own LLM). EC-6: consumers whose transcript rows carry roles outside
|
|
22
|
+
* the SDK's `CompressibleMessage` union (e.g. `'tool'`) cast at the call site, exactly
|
|
23
|
+
* as the SDK's own type contract requires.
|
|
24
|
+
*
|
|
25
|
+
* referencia: knowledge-base/references/mastra compaction (named strategy over a budget).
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/** Token budget mirrored from theocode's proven `DEFAULT_KEEP_TOKENS` (server/lib/compaction.ts). */
|
|
29
|
+
declare const DEFAULT_KEEP_TOKENS = 8000;
|
|
30
|
+
/**
|
|
31
|
+
* App-supplied summarizer: collapse the older window into one turn (the app's LLM).
|
|
32
|
+
* Signature matches the SDK `compactTranscript` contract — receives the older window
|
|
33
|
+
* AND the (optionally overridden) summary template.
|
|
34
|
+
*/
|
|
35
|
+
type Summarize = (older: CompressibleMessage[], template: string) => Promise<CompressibleMessage>;
|
|
36
|
+
/**
|
|
37
|
+
* Per-call options for {@link TranscriptCompactionStrategy.compact} — a faithful
|
|
38
|
+
* pass-through of the SDK `CompactTranscriptOptions` knobs the app controls. Defaults
|
|
39
|
+
* are the SDK's, EXCEPT `failSafe` which defaults `true` here: a thrown `summarize`
|
|
40
|
+
* returns the ORIGINAL transcript + a structured warn instead of losing it — compaction
|
|
41
|
+
* is an optimization, never a cause of data loss (error-handling discipline). The app
|
|
42
|
+
* passes `failSafe: false` to opt into fail-fast propagation.
|
|
43
|
+
*/
|
|
44
|
+
interface CompactionCallOptions {
|
|
45
|
+
/** Override the strategy's configured `keepTokens` for this call. */
|
|
46
|
+
readonly keepTokens?: number;
|
|
47
|
+
/** Summarize the older window; if omitted, the SDK drops it (its documented contract). */
|
|
48
|
+
readonly summarize?: Summarize;
|
|
49
|
+
/** Checkpoint marker (SDK default when omitted). */
|
|
50
|
+
readonly marker?: string;
|
|
51
|
+
/** Summary template passed to `summarize` (SDK default when omitted). */
|
|
52
|
+
readonly summaryTemplate?: string;
|
|
53
|
+
/** When true (DEFAULT here), a thrown `summarize` returns the original transcript + a warn. */
|
|
54
|
+
readonly failSafe?: boolean;
|
|
55
|
+
}
|
|
56
|
+
/** A named, callable compaction strategy. Pure of I/O except the delegated SDK call. */
|
|
57
|
+
interface TranscriptCompactionStrategy {
|
|
58
|
+
/** Strategy identifier (e.g. `'token-budget'`). */
|
|
59
|
+
readonly name: string;
|
|
60
|
+
/** The configured token budget (from `@Compaction` / `.compaction()` / default). */
|
|
61
|
+
readonly keepTokens: number;
|
|
62
|
+
/**
|
|
63
|
+
* Compact `messages` to the (optionally overridden) token budget via the SDK's
|
|
64
|
+
* `compactTranscript`. Returns the compacted transcript; never mutates the input.
|
|
65
|
+
*/
|
|
66
|
+
compact(messages: CompressibleMessage[], options?: CompactionCallOptions): Promise<CompressibleMessage[]>;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Serializable config for a TranscriptCompactionStrategy (SSoT per type-safety.md / G3).
|
|
70
|
+
* `keepTokens` is REQUIRED for `'token-budget'` (EC-2 / G10 — no silent degradation
|
|
71
|
+
* to the SDK's turn-count `keepRecent` default; the strategy is named for token budget).
|
|
72
|
+
*/
|
|
73
|
+
declare const compactionStrategyConfigSchema: z.ZodObject<{
|
|
74
|
+
name: z.ZodLiteral<"token-budget">;
|
|
75
|
+
keepTokens: z.ZodNumber;
|
|
76
|
+
}, z.core.$strip>;
|
|
77
|
+
type CompactionStrategyConfig = z.infer<typeof compactionStrategyConfigSchema>;
|
|
78
|
+
/**
|
|
79
|
+
* Resolve a `@Compaction` / `.compaction()` declaration to a concrete strategy.
|
|
80
|
+
* Throws (Zod) on an unknown name or a missing/invalid `keepTokens` (EC-2/EC-5 —
|
|
81
|
+
* fail-fast, mirrors `resolveLoopStrategy`). The returned strategy's `compact`
|
|
82
|
+
* delegates to `compactTranscript`, defaulting `keepTokens` to the configured value.
|
|
83
|
+
*/
|
|
84
|
+
declare function resolveCompactionStrategy(name: string, config: {
|
|
85
|
+
keepTokens?: number;
|
|
86
|
+
}): TranscriptCompactionStrategy;
|
|
87
|
+
/**
|
|
88
|
+
* The default `'token-budget'` strategy (what `@Compaction('token-budget')` without
|
|
89
|
+
* an explicit budget resolves to). Carries {@link DEFAULT_KEEP_TOKENS}; the app may
|
|
90
|
+
* override per call via `compact(messages, { keepTokens })`.
|
|
91
|
+
*/
|
|
92
|
+
declare const tokenBudgetCompactionStrategy: TranscriptCompactionStrategy;
|
|
93
|
+
|
|
9
94
|
/**
|
|
10
95
|
* ReflectionStrategy — composes INTO the loop between rounds (the loop calls
|
|
11
96
|
* `reflect()` then `LoopStrategy.shouldContinue()`).
|
|
@@ -26,12 +111,25 @@ interface ReflectionResult {
|
|
|
26
111
|
/** Hint: should the loop reflect-and-continue? (the ceiling still bounds it) */
|
|
27
112
|
readonly continue: boolean;
|
|
28
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* V4-K: a per-run mutable scratch bag threaded to every `reflect()` call within one
|
|
116
|
+
* `runReflectiveLoopStream` run, so a STATEFUL strategy can accumulate cumulative state
|
|
117
|
+
* (counters, one-shot flags) across rounds. The framework owns the lifecycle (creates
|
|
118
|
+
* one per run, passes the SAME ref each round) but writes NOTHING into it — the strategy
|
|
119
|
+
* owns the contents. Generic by design: the framework cannot know app semantics (e.g.
|
|
120
|
+
* what an "edit" is). A consumer narrows it locally (`ctx as MyState`).
|
|
121
|
+
*/
|
|
122
|
+
type ReflectionContext = Record<string, unknown>;
|
|
29
123
|
/** Pluggable between-round reflection. Pure — never performs I/O. */
|
|
30
124
|
interface ReflectionStrategy {
|
|
31
125
|
/** Strategy identifier (e.g. `'ladder'`). */
|
|
32
126
|
readonly name: string;
|
|
33
|
-
/**
|
|
34
|
-
|
|
127
|
+
/**
|
|
128
|
+
* Inspect the round outcome; return feedback + continue hint. `ctx` (V4-K) is the
|
|
129
|
+
* per-run mutable scratch — optional for backward compatibility (shipped strategies
|
|
130
|
+
* ignore it; stateful custom strategies accumulate in it across rounds).
|
|
131
|
+
*/
|
|
132
|
+
reflect(outcome: LoopOutcome, ctx?: ReflectionContext): ReflectionResult;
|
|
35
133
|
}
|
|
36
134
|
/** Serializable config for a ReflectionStrategy. SSoT per type-safety.md (ADR D3). */
|
|
37
135
|
declare const reflectionStrategyConfigSchema: z.ZodObject<{
|
|
@@ -67,8 +165,9 @@ declare const noopReflectionStrategy: ReflectionStrategy;
|
|
|
67
165
|
* compiles the agent and resolves the SAME `{ compiled, loopStrategy }` that
|
|
68
166
|
* `delegate()` resolves for the decorator path (two on-ramps, one runtime).
|
|
69
167
|
* `build()` is the compile boundary (no I/O, no IoC — standalone, mirrors
|
|
70
|
-
* Spring's `ChatClient.builder(...).build()`); `run()`
|
|
71
|
-
* `
|
|
168
|
+
* Spring's `ChatClient.builder(...).build()`); `stream()`/`run()` do the I/O via
|
|
169
|
+
* `runReflectiveLoopStream` (the SAME loop `delegate()` drains — DRY, ADR 0031).
|
|
170
|
+
* V4-D-stream: `stream()` yields events live (SSE-first); `run()` drains it to a result.
|
|
72
171
|
*
|
|
73
172
|
* referencia: knowledge-base/references/spring-ai DefaultChatClientBuilder.java (build() returns standalone).
|
|
74
173
|
*/
|
|
@@ -83,11 +182,30 @@ interface AgentRunnerRunOptions {
|
|
|
83
182
|
readonly budget?: number;
|
|
84
183
|
/** Cancellation — aborts stop the reflective loop from re-entering. */
|
|
85
184
|
readonly signal?: AbortSignal;
|
|
185
|
+
/**
|
|
186
|
+
* V4-J: per-run tool override. When provided, REPLACES the build-time
|
|
187
|
+
* `compiled.tools` for this call only (e.g. a consumer that selects tools by
|
|
188
|
+
* request mode/permission). Absent ⇒ the agent's compiled tools (unchanged).
|
|
189
|
+
*/
|
|
190
|
+
readonly tools?: readonly CompiledTool[];
|
|
86
191
|
}
|
|
87
192
|
/**
|
|
88
193
|
* A built, runnable agent. Construct via {@link AgentRunner.builder} — the
|
|
89
194
|
* constructor takes already-resolved state and is an internal detail.
|
|
90
195
|
*/
|
|
196
|
+
/** Already-resolved state handed to the {@link AgentRunner} constructor (internal). */
|
|
197
|
+
interface AgentRunnerState {
|
|
198
|
+
readonly compiled: CompiledAgentOptions;
|
|
199
|
+
readonly agentName: string;
|
|
200
|
+
/** The resolved terminal-decision strategy (parity with `delegate()`). */
|
|
201
|
+
readonly loopStrategy: LoopStrategy;
|
|
202
|
+
/** The resolved between-round reflection (default or `.reflection(custom)` override). */
|
|
203
|
+
readonly reflectionStrategy: ReflectionStrategy;
|
|
204
|
+
/** Recorded streaming preference (see {@link AgentRunner.streamEnabled}). */
|
|
205
|
+
readonly streamEnabled: boolean;
|
|
206
|
+
/** The resolved compaction strategy, or `undefined` when none is declared (EC-4). */
|
|
207
|
+
readonly compaction?: TranscriptCompactionStrategy;
|
|
208
|
+
}
|
|
91
209
|
declare class AgentRunner {
|
|
92
210
|
private readonly compiled;
|
|
93
211
|
private readonly agentName;
|
|
@@ -96,27 +214,31 @@ declare class AgentRunner {
|
|
|
96
214
|
/** The resolved between-round reflection (default or `.reflection(custom)` override). */
|
|
97
215
|
readonly reflectionStrategy: ReflectionStrategy;
|
|
98
216
|
/**
|
|
99
|
-
* Recorded streaming preference. The reflective loop currently always
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
217
|
+
* Recorded streaming preference. The reflective loop currently always streams via
|
|
218
|
+
* the SDK `Run.stream()`; a non-streaming collect mode is future work — the flag is
|
|
219
|
+
* captured + exposed here, not yet branched on (honest per G10: documented, not a
|
|
220
|
+
* silent no-op).
|
|
103
221
|
*/
|
|
104
222
|
readonly streamEnabled: boolean;
|
|
105
|
-
constructor(compiled: CompiledAgentOptions, agentName: string,
|
|
106
|
-
/** The resolved terminal-decision strategy (parity with `delegate()`). */
|
|
107
|
-
loopStrategy: LoopStrategy,
|
|
108
|
-
/** The resolved between-round reflection (default or `.reflection(custom)` override). */
|
|
109
|
-
reflectionStrategy: ReflectionStrategy,
|
|
110
223
|
/**
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
224
|
+
* V4-F: the resolved compaction strategy (from `@Compaction` or `.compaction()`),
|
|
225
|
+
* or `undefined` when neither is declared — compaction is opt-in (EC-4). CALLABLE
|
|
226
|
+
* by the app (ADR D1: `runner.compaction?.compact(messages, { summarize })`); the
|
|
227
|
+
* reflective loop does NOT auto-invoke it (the SDK owns per-turn context).
|
|
115
228
|
*/
|
|
116
|
-
|
|
229
|
+
readonly compaction?: TranscriptCompactionStrategy;
|
|
230
|
+
constructor(state: AgentRunnerState);
|
|
117
231
|
/** Start a fluent builder for `AgentClass`. */
|
|
118
232
|
static builder(AgentClass: Function): AgentRunnerBuilder;
|
|
119
|
-
/**
|
|
233
|
+
/**
|
|
234
|
+
* V4-D-stream: stream the agent's events LIVE across the reflective loop, returning
|
|
235
|
+
* the aggregated {@link DelegationResult} as the generator's return value. This is the
|
|
236
|
+
* on-ramp for streaming-first apps (SSE) — `runReflectiveLoopStream` yields every
|
|
237
|
+
* round's events before the loop terminates. `streamEnabled` is honored: when the
|
|
238
|
+
* builder set `.stream(false)`, callers should use {@link run} instead.
|
|
239
|
+
*/
|
|
240
|
+
stream(message: string, opts: AgentRunnerRunOptions): AsyncGenerator<StreamEvent, DelegationResult>;
|
|
241
|
+
/** Run the agent to a terminal result via the shared reflective loop (collect mode). */
|
|
120
242
|
run(message: string, opts: AgentRunnerRunOptions): Promise<DelegationResult>;
|
|
121
243
|
}
|
|
122
244
|
/** Fluent builder — accumulates config; `build()` is the compile boundary. */
|
|
@@ -124,13 +246,22 @@ declare class AgentRunnerBuilder {
|
|
|
124
246
|
private readonly AgentClass;
|
|
125
247
|
private reflectionOverride?;
|
|
126
248
|
private streamEnabled;
|
|
249
|
+
private compactionOverride?;
|
|
127
250
|
constructor(AgentClass: Function);
|
|
128
251
|
/** Override the default reflection strategy (OCP — plan Drawback #2). No arg ⇒ keep default. */
|
|
129
252
|
reflection(strategy?: ReflectionStrategy): this;
|
|
130
253
|
/** Record the streaming preference (see {@link AgentRunner.streamEnabled}). */
|
|
131
254
|
stream(enabled?: boolean): this;
|
|
255
|
+
/**
|
|
256
|
+
* V4-F: declare the compaction strategy (e.g. `.compaction('token-budget', { keepTokens: 8000 })`).
|
|
257
|
+
* Resolved + validated at {@link build} (EC-5 — fail-fast there, not here). This builder
|
|
258
|
+
* call WINS over a `@Compaction` decorator on the same agent (EC-1 — explicit override).
|
|
259
|
+
*/
|
|
260
|
+
compaction(name: string, options?: {
|
|
261
|
+
keepTokens?: number;
|
|
262
|
+
}): this;
|
|
132
263
|
/** Walk + compile + resolve strategies — the compile→execute boundary (no I/O). */
|
|
133
264
|
build(): AgentRunner;
|
|
134
265
|
}
|
|
135
266
|
|
|
136
|
-
export { AgentRunner, AgentRunnerBuilder, type AgentRunnerRunOptions, CompiledAgentOptions, DelegationResult, LoopOutcome, LoopStrategy, type ReflectionResult, type ReflectionStrategy, type ReflectionStrategyConfig, ladderReflectionStrategy, noopReflectionStrategy, reflectionStrategyConfigSchema };
|
|
267
|
+
export { AgentRunner, AgentRunnerBuilder, type AgentRunnerRunOptions, type CompactionCallOptions, type CompactionStrategyConfig, CompiledAgentOptions, CompiledTool, DEFAULT_KEEP_TOKENS, DelegationResult, LoopOutcome, LoopStrategy, type ReflectionContext, type ReflectionResult, type ReflectionStrategy, type ReflectionStrategyConfig, StreamEvent, type Summarize, type TranscriptCompactionStrategy, compactionStrategyConfigSchema, ladderReflectionStrategy, noopReflectionStrategy, reflectionStrategyConfigSchema, resolveCompactionStrategy, tokenBudgetCompactionStrategy };
|
package/dist/index.js
CHANGED
|
@@ -27,15 +27,17 @@ import {
|
|
|
27
27
|
getToolboxConfig,
|
|
28
28
|
isCommandAllowed,
|
|
29
29
|
isPathAllowed
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-SKTJS4QQ.js";
|
|
31
31
|
import {
|
|
32
32
|
AgentRunner,
|
|
33
33
|
AgentRunnerBuilder,
|
|
34
34
|
AgentWarningCode,
|
|
35
35
|
BudgetExceededError,
|
|
36
|
+
DEFAULT_KEEP_TOKENS,
|
|
36
37
|
DEFAULT_MAX_ITERATIONS,
|
|
37
38
|
DelegationError,
|
|
38
39
|
agentsPlugin,
|
|
40
|
+
compactionStrategyConfigSchema,
|
|
39
41
|
compileAgent,
|
|
40
42
|
compileContextWindow,
|
|
41
43
|
compileProjectContext,
|
|
@@ -58,16 +60,19 @@ import {
|
|
|
58
60
|
noopReflectionStrategy,
|
|
59
61
|
projectContextMetadataOnlyKnobs,
|
|
60
62
|
reflectionStrategyConfigSchema,
|
|
63
|
+
resolveCompactionStrategy,
|
|
61
64
|
resolveLoopStrategy,
|
|
62
65
|
streamAgentResponse,
|
|
66
|
+
tokenBudgetCompactionStrategy,
|
|
63
67
|
translateSdkEvent,
|
|
64
68
|
validateUniqueRoutes,
|
|
65
69
|
walkAgentMetadata
|
|
66
|
-
} from "./chunk-
|
|
70
|
+
} from "./chunk-5FZVMZPG.js";
|
|
67
71
|
import {
|
|
68
72
|
Agent,
|
|
69
73
|
Audit,
|
|
70
74
|
Budget,
|
|
75
|
+
Compaction,
|
|
71
76
|
ContextWindow,
|
|
72
77
|
Gateway,
|
|
73
78
|
MCP,
|
|
@@ -81,6 +86,7 @@ import {
|
|
|
81
86
|
SubAgents,
|
|
82
87
|
Trace,
|
|
83
88
|
getAgentConfig,
|
|
89
|
+
getCompactionConfig,
|
|
84
90
|
getContextWindowConfig,
|
|
85
91
|
getGatewayConfig,
|
|
86
92
|
getMcpConfig,
|
|
@@ -90,7 +96,7 @@ import {
|
|
|
90
96
|
getSkillsConfig,
|
|
91
97
|
getSubAgents,
|
|
92
98
|
resolveSessionId
|
|
93
|
-
} from "./chunk-
|
|
99
|
+
} from "./chunk-GVPUUKKE.js";
|
|
94
100
|
import "./chunk-7QVYU63E.js";
|
|
95
101
|
export {
|
|
96
102
|
Agent,
|
|
@@ -102,8 +108,10 @@ export {
|
|
|
102
108
|
Budget,
|
|
103
109
|
BudgetExceededError,
|
|
104
110
|
Checkpoint,
|
|
111
|
+
Compaction,
|
|
105
112
|
ContextWindow,
|
|
106
113
|
Conversation,
|
|
114
|
+
DEFAULT_KEEP_TOKENS,
|
|
107
115
|
DEFAULT_MAX_ITERATIONS,
|
|
108
116
|
DelegationError,
|
|
109
117
|
EditFormat,
|
|
@@ -128,6 +136,7 @@ export {
|
|
|
128
136
|
Trace,
|
|
129
137
|
agentsPlugin,
|
|
130
138
|
applyDecorators,
|
|
139
|
+
compactionStrategyConfigSchema,
|
|
131
140
|
compileAgent,
|
|
132
141
|
compileContextWindow,
|
|
133
142
|
compileProjectContext,
|
|
@@ -141,6 +150,7 @@ export {
|
|
|
141
150
|
getAgentConfig,
|
|
142
151
|
getArtifactConfig,
|
|
143
152
|
getCheckpointConfig,
|
|
153
|
+
getCompactionConfig,
|
|
144
154
|
getContextWindowConfig,
|
|
145
155
|
getConversationConfig,
|
|
146
156
|
getGatewayConfig,
|
|
@@ -174,9 +184,11 @@ export {
|
|
|
174
184
|
noopReflectionStrategy,
|
|
175
185
|
projectContextMetadataOnlyKnobs,
|
|
176
186
|
reflectionStrategyConfigSchema,
|
|
187
|
+
resolveCompactionStrategy,
|
|
177
188
|
resolveLoopStrategy,
|
|
178
189
|
resolveSessionId,
|
|
179
190
|
streamAgentResponse,
|
|
191
|
+
tokenBudgetCompactionStrategy,
|
|
180
192
|
translateSdkEvent,
|
|
181
193
|
validateUniqueRoutes,
|
|
182
194
|
walkAgentMetadata
|
|
@@ -66,6 +66,18 @@ type PolicyHandler = (user: {
|
|
|
66
66
|
roles: string[];
|
|
67
67
|
}) => boolean;
|
|
68
68
|
|
|
69
|
+
/** Stored `@Compaction` declaration (resolved + validated at `AgentRunner.build()`). */
|
|
70
|
+
interface CompactionDecoratorConfig {
|
|
71
|
+
/** Strategy name (e.g. `'token-budget'`). Validated at resolve time. */
|
|
72
|
+
name: string;
|
|
73
|
+
/** Token budget for `'token-budget'`. Required at resolve time (EC-2). */
|
|
74
|
+
keepTokens?: number;
|
|
75
|
+
}
|
|
76
|
+
declare function Compaction(name: string, options?: {
|
|
77
|
+
keepTokens?: number;
|
|
78
|
+
}): ClassDecorator;
|
|
79
|
+
declare function getCompactionConfig(target: Function): CompactionDecoratorConfig | undefined;
|
|
80
|
+
|
|
69
81
|
type ContextCompactionStrategy = 'truncate-oldest' | 'summarize-oldest' | 'sliding-window' | 'priority-based';
|
|
70
82
|
interface ContextWindowOptions {
|
|
71
83
|
/** Maximum tokens before compaction triggers. */
|
|
@@ -167,4 +179,4 @@ interface SkillsOptions {
|
|
|
167
179
|
declare function Skills(namesOrOptions: string[] | SkillsOptions): ClassDecorator;
|
|
168
180
|
declare function getSkillsConfig(target: Function): SkillsOptions | undefined;
|
|
169
181
|
|
|
170
|
-
export { type AgentOptions as A, type BudgetOptions as B,
|
|
182
|
+
export { type AgentOptions as A, type BudgetOptions as B, Compaction as C, getSkillsConfig as D, resolveSessionId as E, Gateway as G, type IndexStrategy as I, MCP as M, type PlatformName as P, type RelevanceStrategy as R, type SessionStrategy as S, type ToolOptions as T, type ApprovalOptions as a, type CompactionDecoratorConfig as b, type ContextCompactionStrategy as c, ContextWindow as d, type ContextWindowOptions as e, type GatewayOptions as f, type MainLoopMeta as g, type MainLoopOptions as h, type McpServerConfig as i, type McpServersMap as j, Memory as k, type MemoryOptions as l, type MemoryProvider as m, type MemoryScope as n, type PolicyHandler as o, ProjectContext as p, type ProjectContextOptions as q, Skills as r, type SkillsOptions as s, type ToolboxOptions as t, getCompactionConfig as u, getContextWindowConfig as v, getGatewayConfig as w, getMcpConfig as x, getMemoryConfig as y, getProjectContextConfig as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theokit/agents",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Unified decorator runtime — AI agents as first-class citizens of the TheoKit pipeline. @Agent() compiles to SDK Agent.create(), @Tool() compiles to defineTool().",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@theokit/http": ">=0.1.0-alpha.0",
|
|
39
|
-
"@theokit/sdk": ">=2.
|
|
39
|
+
"@theokit/sdk": ">=2.9.0",
|
|
40
40
|
"@theokit/sdk-tools": ">=0.2.0",
|
|
41
41
|
"reflect-metadata": ">=0.2.0",
|
|
42
42
|
"zod": "^4.0.0"
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@theokit/http": "workspace:*",
|
|
51
|
-
"@theokit/sdk": "^2.
|
|
51
|
+
"@theokit/sdk": "^2.9.0",
|
|
52
52
|
"@theokit/sdk-tools": "^0.2.0",
|
|
53
53
|
"reflect-metadata": "^0.2.2",
|
|
54
54
|
"tsup": "^8.5.1",
|