@theokit/agents 0.46.0 → 1.0.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-BQ6UUSLZ.d.ts → bridge-entry-F9kHGaIn.d.ts} +378 -106
- package/dist/bridge.d.ts +1 -2
- package/dist/bridge.js +3 -12
- package/dist/{chunk-YBNKD5UM.js → chunk-7KRJJX7W.js} +393 -492
- package/dist/chunk-7KRJJX7W.js.map +1 -0
- package/dist/index.d.ts +278 -16
- package/dist/index.js +453 -12
- package/dist/index.js.map +1 -1
- package/package.json +4 -5
- package/dist/chunk-NERDIS45.js +0 -329
- package/dist/chunk-NERDIS45.js.map +0 -1
- package/dist/chunk-YBNKD5UM.js.map +0 -1
- package/dist/decorators.d.ts +0 -176
- package/dist/decorators.js +0 -308
- package/dist/decorators.js.map +0 -1
- package/dist/types-DVA4LQsA.d.ts +0 -313
package/dist/types-DVA4LQsA.d.ts
DELETED
|
@@ -1,313 +0,0 @@
|
|
|
1
|
-
import { SystemPromptResolver } from '@theokit/sdk';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Provider-agnostic extended-thinking knob (M1 reasoning-visibility). The common set autocompletes;
|
|
6
|
-
* `(string & {})` accepts provider-specific values forward-compat (mirrors `AgentRunErrorCode`) — the
|
|
7
|
-
* SDK validates the value against the model's catalog. Defined in this leaf module so every layer
|
|
8
|
-
* (`@Agent` config, compiler, runner, sdk-adapter) imports it without an import cycle.
|
|
9
|
-
*/
|
|
10
|
-
type ReasoningEffort = 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | (string & {});
|
|
11
|
-
/** Configuration stored by @Agent() decorator. */
|
|
12
|
-
interface AgentOptions {
|
|
13
|
-
/** Unique agent name (kebab-case). */
|
|
14
|
-
name: string;
|
|
15
|
-
/** HTTP route prefix (e.g., '/api/agents/support'). */
|
|
16
|
-
route: string;
|
|
17
|
-
/** LLM model identifier (e.g., 'claude-sonnet-4-5-20250929'). */
|
|
18
|
-
model?: string;
|
|
19
|
-
/** Extended-thinking effort; mapped to the SDK `ModelSelection.params` so the provider reasons. */
|
|
20
|
-
reasoningEffort?: ReasoningEffort;
|
|
21
|
-
/**
|
|
22
|
-
* Opt-in (default false): convert inline `<think>…</think>` in the text stream into `thinking`
|
|
23
|
-
* events (M2) — for models that emit reasoning as inline tags (qwen/deepseek) rather than via a
|
|
24
|
-
* native reasoning param. Off by default since a code assistant may emit literal `<think>` in text.
|
|
25
|
-
*/
|
|
26
|
-
parseThinkTags?: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Opt-in (default false): strip a leaked Hermes `<function=…></tool_call>` tool-call dialect out of
|
|
29
|
-
* the visible text (theocode#32) — for models (qwen/qwen3-coder) that intermittently emit tool calls
|
|
30
|
-
* as text instead of native `tool_calls`. Off by default since a code assistant may emit a literal
|
|
31
|
-
* `<function=` in answer/code text. Sibling of {@link parseThinkTags}.
|
|
32
|
-
*/
|
|
33
|
-
stripToolDialect?: boolean;
|
|
34
|
-
/**
|
|
35
|
-
* Opt-in (default false): recover a leaked Hermes `<function=…></tool_call>` tool-call dialect so the
|
|
36
|
-
* call actually EXECUTES (theokit#58 follow-up). Where {@link stripToolDialect} only hides the leaked
|
|
37
|
-
* block from the visible text, this enables the SDK's `extractToolCallsFromContent` on the chat route,
|
|
38
|
-
* so a `chat_completions` finish with ZERO native `tool_calls` has its text scanned for the dialect and
|
|
39
|
-
* any recovered calls are dispatched by the loop. For models (qwen/qwen3-coder via OpenRouter) that
|
|
40
|
-
* leak tool calls as text. Off by default (a code assistant may print a literal `<function=`); fail-open.
|
|
41
|
-
* Has effect only when {@link AgentOptions} routes a provider via `providers.routes`. Sibling of
|
|
42
|
-
* {@link stripToolDialect} — typically enabled together.
|
|
43
|
-
*/
|
|
44
|
-
recoverLeakedToolCalls?: boolean;
|
|
45
|
-
/** Enable SSE streaming (default: true). */
|
|
46
|
-
stream?: boolean;
|
|
47
|
-
/** Maximum loop iterations before forcing a terminal response. */
|
|
48
|
-
maxIterations?: number;
|
|
49
|
-
/** Timeout in milliseconds for the entire agent run. */
|
|
50
|
-
timeoutMs?: number;
|
|
51
|
-
/**
|
|
52
|
-
* System prompt for the agent. Either a static string OR a
|
|
53
|
-
* {@link SystemPromptResolver} computed per request (V4-L.1, Axis-B) — the SDK
|
|
54
|
-
* invokes the resolver each send with the run's `SystemPromptContext` (cwd, etc.).
|
|
55
|
-
*/
|
|
56
|
-
systemPrompt?: string | SystemPromptResolver;
|
|
57
|
-
}
|
|
58
|
-
/** Configuration stored by @MainLoop() decorator. */
|
|
59
|
-
interface MainLoopOptions {
|
|
60
|
-
/** Execution strategy. */
|
|
61
|
-
strategy?: 'simple-chat' | 'plan-act-reflect' | 'react';
|
|
62
|
-
/** Maximum iterations for this loop. */
|
|
63
|
-
maxIterations?: number;
|
|
64
|
-
/** Timeout in milliseconds. */
|
|
65
|
-
timeoutMs?: number;
|
|
66
|
-
}
|
|
67
|
-
/** Internal representation of a resolved @MainLoop. */
|
|
68
|
-
interface MainLoopMeta {
|
|
69
|
-
propertyKey: string | symbol;
|
|
70
|
-
strategy: 'simple-chat' | 'plan-act-reflect' | 'react';
|
|
71
|
-
maxIterations?: number;
|
|
72
|
-
timeoutMs?: number;
|
|
73
|
-
}
|
|
74
|
-
/** Configuration stored by @Toolbox() decorator. */
|
|
75
|
-
interface ToolboxOptions {
|
|
76
|
-
/** Namespace prefix for all tools in this toolbox (e.g., 'support'). */
|
|
77
|
-
namespace?: string;
|
|
78
|
-
}
|
|
79
|
-
/** Configuration stored by @Tool() decorator. */
|
|
80
|
-
interface ToolOptions {
|
|
81
|
-
/** Tool name (surfaced to LLM). */
|
|
82
|
-
name: string;
|
|
83
|
-
/** LLM-facing description. */
|
|
84
|
-
description: string;
|
|
85
|
-
/** Zod input schema — compiled to JSON Schema via defineTool(). */
|
|
86
|
-
input: z.ZodType;
|
|
87
|
-
/** Risk level (informational — feeds manifest + UI). */
|
|
88
|
-
risk?: 'low' | 'medium' | 'high';
|
|
89
|
-
}
|
|
90
|
-
/** Budget configuration for @Budget() decorator. */
|
|
91
|
-
interface BudgetOptions {
|
|
92
|
-
/** Maximum cost in USD for this scope. */
|
|
93
|
-
maxCostUsd: number;
|
|
94
|
-
/** Rolling window for budget tracking. */
|
|
95
|
-
window?: 'daily' | 'monthly';
|
|
96
|
-
}
|
|
97
|
-
/** Approval configuration for @RequiresApproval() decorator. */
|
|
98
|
-
interface ApprovalOptions {
|
|
99
|
-
/** Reason shown to the approver. */
|
|
100
|
-
reason: string;
|
|
101
|
-
}
|
|
102
|
-
/** Policy handler function type. */
|
|
103
|
-
type PolicyHandler = (user: {
|
|
104
|
-
roles: string[];
|
|
105
|
-
}) => boolean;
|
|
106
|
-
|
|
107
|
-
type CheckpointStrategy = 'after-tool-call' | 'after-iteration' | 'manual';
|
|
108
|
-
type CheckpointStorage = 'memory' | 'filesystem' | 'drizzle' | 'redis';
|
|
109
|
-
interface CheckpointOptions {
|
|
110
|
-
/** Where to persist checkpoints. */
|
|
111
|
-
storage?: CheckpointStorage;
|
|
112
|
-
/** When to auto-checkpoint (default: 'after-tool-call'). */
|
|
113
|
-
strategy?: CheckpointStrategy;
|
|
114
|
-
/** Maximum checkpoints to retain per run (rolling window). */
|
|
115
|
-
maxCheckpoints?: number;
|
|
116
|
-
/** Time-to-live in ms before checkpoints expire (default: 3_600_000 = 1h). */
|
|
117
|
-
ttl?: number;
|
|
118
|
-
}
|
|
119
|
-
/** Serializable checkpoint state. */
|
|
120
|
-
interface CheckpointState {
|
|
121
|
-
id: string;
|
|
122
|
-
runId: string;
|
|
123
|
-
agentName: string;
|
|
124
|
-
step: number;
|
|
125
|
-
messages: unknown[];
|
|
126
|
-
toolResults: unknown[];
|
|
127
|
-
createdAt: number;
|
|
128
|
-
resumeToken: string;
|
|
129
|
-
}
|
|
130
|
-
declare function Checkpoint(options?: CheckpointOptions): ClassDecorator;
|
|
131
|
-
declare function getCheckpointConfig(target: Function): CheckpointOptions | undefined;
|
|
132
|
-
|
|
133
|
-
/** Stored `@Compaction` declaration (resolved + validated at `AgentRunner.build()`). */
|
|
134
|
-
interface CompactionDecoratorConfig {
|
|
135
|
-
/** Strategy name (e.g. `'token-budget'`). Validated at resolve time. */
|
|
136
|
-
name: string;
|
|
137
|
-
/** Token budget for `'token-budget'`. Required at resolve time (EC-2). */
|
|
138
|
-
keepTokens?: number;
|
|
139
|
-
}
|
|
140
|
-
declare function Compaction(name: string, options?: {
|
|
141
|
-
keepTokens?: number;
|
|
142
|
-
}): ClassDecorator;
|
|
143
|
-
declare function getCompactionConfig(target: Function): CompactionDecoratorConfig | undefined;
|
|
144
|
-
|
|
145
|
-
type ContextCompactionStrategy = 'truncate-oldest' | 'summarize-oldest' | 'sliding-window' | 'priority-based';
|
|
146
|
-
interface ContextWindowOptions {
|
|
147
|
-
/** Maximum tokens before compaction triggers. */
|
|
148
|
-
maxTokens?: number;
|
|
149
|
-
/** How to compact when maxTokens is exceeded. */
|
|
150
|
-
compactionStrategy?: ContextCompactionStrategy;
|
|
151
|
-
/** Always preserve the system prompt during compaction (default: true). */
|
|
152
|
-
preserveSystemPrompt?: boolean;
|
|
153
|
-
/** Number of recent messages to always keep intact (default: 10). */
|
|
154
|
-
preserveLastN?: number;
|
|
155
|
-
/** Keep all tool results even during compaction (default: true). */
|
|
156
|
-
preserveToolResults?: boolean;
|
|
157
|
-
}
|
|
158
|
-
declare function ContextWindow(options?: ContextWindowOptions): ClassDecorator;
|
|
159
|
-
declare function getContextWindowConfig(target: Function): ContextWindowOptions | undefined;
|
|
160
|
-
|
|
161
|
-
type PlatformName = 'telegram' | 'discord' | 'slack' | 'whatsapp' | 'teams' | 'email' | 'sms' | 'mattermost' | 'line' | 'matrix';
|
|
162
|
-
type SessionStrategy = 'per-user' | 'per-channel' | 'per-thread';
|
|
163
|
-
interface GatewayOptions {
|
|
164
|
-
/** Platform adapters this agent supports. */
|
|
165
|
-
platforms: PlatformName[];
|
|
166
|
-
/** How to resolve agentId from inbound events (default: 'per-user'). */
|
|
167
|
-
sessionStrategy?: SessionStrategy;
|
|
168
|
-
/** Auto-start typing indicator while agent processes (default: true). */
|
|
169
|
-
typing?: boolean;
|
|
170
|
-
}
|
|
171
|
-
declare function Gateway(options: GatewayOptions): ClassDecorator;
|
|
172
|
-
declare function getGatewayConfig(target: Function): GatewayOptions | undefined;
|
|
173
|
-
/**
|
|
174
|
-
* Resolve a stable agentId from a platform event based on the session strategy.
|
|
175
|
-
*
|
|
176
|
-
* Mirrors @theokit/gateway SessionRouter.defaultStrategy() but is configurable
|
|
177
|
-
* via the @Gateway decorator.
|
|
178
|
-
*/
|
|
179
|
-
declare function resolveSessionId(strategy: SessionStrategy, platform: string, sender: {
|
|
180
|
-
id: string;
|
|
181
|
-
}, channel: {
|
|
182
|
-
id: string;
|
|
183
|
-
type: 'dm' | 'group' | 'thread';
|
|
184
|
-
topicId?: string;
|
|
185
|
-
}): string;
|
|
186
|
-
|
|
187
|
-
type TimeoutAction = 'abort' | 'proceed' | 'retry';
|
|
188
|
-
interface HumanInTheLoopOptions {
|
|
189
|
-
/** Question shown to the human approver. */
|
|
190
|
-
question: string;
|
|
191
|
-
/** Timeout in milliseconds before onTimeout fires (default: 300_000 = 5 min). */
|
|
192
|
-
timeout?: number;
|
|
193
|
-
/** Action when timeout expires (default: 'abort'). */
|
|
194
|
-
onTimeout?: TimeoutAction;
|
|
195
|
-
/** Show the tool input to the approver (default: true). */
|
|
196
|
-
showInput?: boolean;
|
|
197
|
-
/**
|
|
198
|
-
* M20 — an optional JSON-schema descriptor of the custom payload the approver may attach (edited
|
|
199
|
-
* args, a review note). Carried into the `approval_required` event + `GET /approvals` so the UI
|
|
200
|
-
* knows what to collect. A plain JSON object, not a live Zod schema (keeps the wire serializable).
|
|
201
|
-
*/
|
|
202
|
-
payloadSchema?: Record<string, unknown>;
|
|
203
|
-
}
|
|
204
|
-
declare function HumanInTheLoop(options: HumanInTheLoopOptions): MethodDecorator;
|
|
205
|
-
declare function getHumanInTheLoopConfig(target: Function, propertyKey: string | symbol): HumanInTheLoopOptions | undefined;
|
|
206
|
-
|
|
207
|
-
interface McpServerConfig {
|
|
208
|
-
/** Command to start the MCP server. */
|
|
209
|
-
command: string;
|
|
210
|
-
/** Arguments passed to the command. */
|
|
211
|
-
args?: string[];
|
|
212
|
-
/** Environment variables for the server process. */
|
|
213
|
-
env?: Record<string, string>;
|
|
214
|
-
/** Working directory for the server process. */
|
|
215
|
-
cwd?: string;
|
|
216
|
-
}
|
|
217
|
-
type McpServersMap = Record<string, McpServerConfig>;
|
|
218
|
-
declare function MCP(servers: McpServersMap): ClassDecorator;
|
|
219
|
-
declare function getMcpConfig(target: Function): McpServersMap | undefined;
|
|
220
|
-
|
|
221
|
-
type MemoryProvider = 'built-in' | 'honcho' | 'supermemory' | 'mem0';
|
|
222
|
-
type MemoryScope = 'per-user' | 'per-agent' | 'per-tenant' | 'global';
|
|
223
|
-
interface MemoryOptions {
|
|
224
|
-
/** Memory provider backend. */
|
|
225
|
-
provider?: MemoryProvider;
|
|
226
|
-
/** Enable semantic search via embeddings. */
|
|
227
|
-
embeddings?: boolean;
|
|
228
|
-
/** Enable full-text search (FTS5). */
|
|
229
|
-
fts?: boolean;
|
|
230
|
-
/** Memory isolation scope (default: 'per-user'). */
|
|
231
|
-
scope?: MemoryScope;
|
|
232
|
-
/** Maximum facts to retain per scope (0 = unlimited). */
|
|
233
|
-
maxFacts?: number;
|
|
234
|
-
}
|
|
235
|
-
declare function Memory(options?: MemoryOptions): ClassDecorator;
|
|
236
|
-
declare function getMemoryConfig(target: Function): MemoryOptions | undefined;
|
|
237
|
-
|
|
238
|
-
type IndexStrategy = 'tree-sitter' | 'regex' | 'none';
|
|
239
|
-
type RelevanceStrategy = 'git-history' | 'import-graph' | 'semantic' | 'manual';
|
|
240
|
-
interface ProjectContextOptions {
|
|
241
|
-
/** Files that mark the project root (searched upward from cwd). */
|
|
242
|
-
rootMarkers?: string[];
|
|
243
|
-
/** How to index the codebase for structural understanding. */
|
|
244
|
-
indexStrategy?: IndexStrategy;
|
|
245
|
-
/** Maximum files to include in context per request. */
|
|
246
|
-
maxFilesInContext?: number;
|
|
247
|
-
/** How to rank file relevance when selecting context. */
|
|
248
|
-
relevanceStrategy?: RelevanceStrategy;
|
|
249
|
-
/** Glob patterns to exclude from indexing and context. */
|
|
250
|
-
ignorePatterns?: string[];
|
|
251
|
-
/** File extensions to include in indexing (default: all text files). */
|
|
252
|
-
includeExtensions?: string[];
|
|
253
|
-
}
|
|
254
|
-
declare function ProjectContext(options?: ProjectContextOptions): ClassDecorator;
|
|
255
|
-
declare function getProjectContextConfig(target: Function): ProjectContextOptions | undefined;
|
|
256
|
-
|
|
257
|
-
interface SkillsOptions {
|
|
258
|
-
/** Skill names to include (resolved from .theokit/skills/<name>/SKILL.md). */
|
|
259
|
-
include: string[];
|
|
260
|
-
/** Auto-discover all skills in .theokit/skills/ (default: false). */
|
|
261
|
-
autoDiscover?: boolean;
|
|
262
|
-
}
|
|
263
|
-
declare function Skills(namesOrOptions: string[] | SkillsOptions): ClassDecorator;
|
|
264
|
-
declare function getSkillsConfig(target: Function): SkillsOptions | undefined;
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* M9 (theokit-ai-first) — guardrail contract + typed errors.
|
|
268
|
-
*
|
|
269
|
-
* ADR-0040 § D2: guardrails are a HOME/BOUNDARY concern (filter user input before the SDK,
|
|
270
|
-
* filter model output before the client). They REUSE the SDK runtime — this module makes zero
|
|
271
|
-
* LLM calls. A guard reports one of three actions; the pipeline (`pipeline.ts`) enforces them.
|
|
272
|
-
*/
|
|
273
|
-
/** What a guard decided for a piece of text. */
|
|
274
|
-
type GuardrailAction = 'allow' | 'block' | 'redact';
|
|
275
|
-
/**
|
|
276
|
-
* The result of a single guard check.
|
|
277
|
-
* - `allow` — text passes untouched.
|
|
278
|
-
* - `block` — the pipeline throws {@link GuardrailViolationError}; the run stops fail-fast.
|
|
279
|
-
* - `redact` — the pipeline replaces the text with {@link GuardrailResult.text} and continues.
|
|
280
|
-
*/
|
|
281
|
-
interface GuardrailResult {
|
|
282
|
-
action: GuardrailAction;
|
|
283
|
-
/** Human-readable reason — required in spirit for `block`, surfaced in the thrown error. */
|
|
284
|
-
reason?: string;
|
|
285
|
-
/** The transformed text — present (and used) only when `action === 'redact'`. */
|
|
286
|
-
text?: string;
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* A guardrail. A guard MAY inspect input (before the model), output (after the model), or both.
|
|
290
|
-
* A guard that omits a phase hook is skipped for that phase.
|
|
291
|
-
*/
|
|
292
|
-
interface Guardrail {
|
|
293
|
-
readonly name: string;
|
|
294
|
-
checkInput?(text: string): GuardrailResult | Promise<GuardrailResult>;
|
|
295
|
-
checkOutput?(text: string): GuardrailResult | Promise<GuardrailResult>;
|
|
296
|
-
}
|
|
297
|
-
/** Which boundary phase a violation happened in. */
|
|
298
|
-
type GuardrailPhase = 'input' | 'output';
|
|
299
|
-
/** Thrown (fail-fast) when a guard returns `action: 'block'`. Typed per error-handling.md. */
|
|
300
|
-
declare class GuardrailViolationError extends Error {
|
|
301
|
-
readonly guardName: string;
|
|
302
|
-
readonly phase: GuardrailPhase;
|
|
303
|
-
readonly reason: string;
|
|
304
|
-
constructor(guardName: string, phase: GuardrailPhase, reason: string);
|
|
305
|
-
}
|
|
306
|
-
/** Thrown when {@link costGuard}'s cumulative token budget is exceeded. */
|
|
307
|
-
declare class CostBudgetExceededError extends Error {
|
|
308
|
-
readonly usedTokens: number;
|
|
309
|
-
readonly maxTokens: number;
|
|
310
|
-
constructor(usedTokens: number, maxTokens: number);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
export { getSkillsConfig as $, type AgentOptions as A, type BudgetOptions as B, CostBudgetExceededError as C, type MemoryProvider as D, type MemoryScope as E, type PlatformName as F, type Guardrail as G, type HumanInTheLoopOptions as H, type IndexStrategy as I, ProjectContext as J, type ProjectContextOptions as K, type RelevanceStrategy as L, type MainLoopMeta as M, Skills as N, type SkillsOptions as O, type PolicyHandler as P, getCheckpointConfig as Q, type ReasoningEffort as R, type SessionStrategy as S, type TimeoutAction as T, getCompactionConfig as U, getContextWindowConfig as V, getGatewayConfig as W, getHumanInTheLoopConfig as X, getMcpConfig as Y, getMemoryConfig as Z, getProjectContextConfig as _, type ApprovalOptions as a, resolveSessionId as a0, type GuardrailAction as b, type GuardrailPhase as c, type GuardrailResult as d, GuardrailViolationError as e, type MainLoopOptions as f, type ToolOptions as g, type ToolboxOptions as h, Checkpoint as i, type CheckpointOptions as j, type CheckpointState as k, type CheckpointStorage as l, type CheckpointStrategy as m, Compaction as n, type CompactionDecoratorConfig as o, type ContextCompactionStrategy as p, ContextWindow as q, type ContextWindowOptions as r, Gateway as s, type GatewayOptions as t, HumanInTheLoop as u, MCP as v, type McpServerConfig as w, type McpServersMap as x, Memory as y, type MemoryOptions as z };
|