@theokit/agents 0.33.0 → 0.34.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.
@@ -1,5 +1,5 @@
1
- import { A as AgentOptions, t as MainLoopOptions, s as MainLoopMeta, N as ToolOptions, O as ToolboxOptions, B as BudgetOptions, D as PolicyHandler, a as ApprovalOptions, G as Guardrail } from './types-S7k_lt1_.js';
2
- export { C as Checkpoint, b as CheckpointOptions, c as CheckpointState, d as CheckpointStorage, e as CheckpointStrategy, f as Compaction, g as CompactionDecoratorConfig, h as ContextCompactionStrategy, i as ContextWindow, j as ContextWindowOptions, l as Gateway, m as GatewayOptions, H as HumanInTheLoop, r as HumanInTheLoopOptions, I as IndexStrategy, M as MCP, u as McpServerConfig, v as McpServersMap, w as Memory, x as MemoryOptions, y as MemoryProvider, z as MemoryScope, P as PlatformName, E as ProjectContext, F as ProjectContextOptions, J as RelevanceStrategy, S as SessionStrategy, K as Skills, L as SkillsOptions, T as TimeoutAction, Q as getCheckpointConfig, U as getCompactionConfig, V as getContextWindowConfig, W as getGatewayConfig, X as getHumanInTheLoopConfig, Y as getMcpConfig, Z as getMemoryConfig, _ as getProjectContextConfig, $ as getSkillsConfig, a0 as resolveSessionId } from './types-S7k_lt1_.js';
1
+ import { A as AgentOptions, f as MainLoopOptions, M as MainLoopMeta, g as ToolOptions, h as ToolboxOptions, B as BudgetOptions, P as PolicyHandler, a as ApprovalOptions, G as Guardrail } from './types-DVA4LQsA.js';
2
+ export { i as Checkpoint, j as CheckpointOptions, k as CheckpointState, l as CheckpointStorage, m as CheckpointStrategy, n as Compaction, o as CompactionDecoratorConfig, p as ContextCompactionStrategy, q as ContextWindow, r as ContextWindowOptions, s as Gateway, t as GatewayOptions, u as HumanInTheLoop, H as HumanInTheLoopOptions, I as IndexStrategy, v as MCP, w as McpServerConfig, x as McpServersMap, y as Memory, z as MemoryOptions, D as MemoryProvider, E as MemoryScope, F as PlatformName, J as ProjectContext, K as ProjectContextOptions, L as RelevanceStrategy, S as SessionStrategy, N as Skills, O as SkillsOptions, T as TimeoutAction, Q as getCheckpointConfig, U as getCompactionConfig, V as getContextWindowConfig, W as getGatewayConfig, X as getHumanInTheLoopConfig, Y as getMcpConfig, Z as getMemoryConfig, _ as getProjectContextConfig, $ as getSkillsConfig, a0 as resolveSessionId } from './types-DVA4LQsA.js';
3
3
  import '@theokit/sdk';
4
4
  import 'zod';
5
5
 
@@ -1,30 +1,5 @@
1
1
  import {
2
- Artifact,
3
- Conversation,
4
- EditFormat,
5
- Hook,
6
- MainLoop,
7
- Model,
8
- Observable,
9
- Sandbox,
10
- Tool,
11
- Toolbox,
12
- applyDecorators,
13
- getArtifactConfig,
14
- getConversationConfig,
15
- getHooks,
16
- getHooksByPoint,
17
- getMainLoop,
18
- getObservableByChannel,
19
- getObservables,
20
- getSandboxConfig,
21
- getToolConfig,
22
- getToolMethods,
23
- getToolboxConfig,
24
- isCommandAllowed,
25
- isPathAllowed
26
- } from "./chunk-GEV2EQW2.js";
27
- import {
2
+ AGENT_MAIN_LOOP,
28
3
  Agent,
29
4
  Audit,
30
5
  Budget,
@@ -43,6 +18,9 @@ import {
43
18
  RequiresCapability,
44
19
  Skills,
45
20
  SubAgents,
21
+ TOOLBOX_CONFIG,
22
+ TOOL_CONFIG,
23
+ TOOL_METHODS,
46
24
  Trace,
47
25
  getAgentConfig,
48
26
  getCheckpointConfig,
@@ -53,13 +31,243 @@ import {
53
31
  getHumanInTheLoopConfig,
54
32
  getMcpConfig,
55
33
  getMemoryConfig,
34
+ getMeta,
56
35
  getMixins,
57
36
  getProjectContextConfig,
58
37
  getSkillsConfig,
59
38
  getSubAgents,
60
- resolveSessionId
61
- } from "./chunk-MD35WBR4.js";
62
- import "./chunk-7QVYU63E.js";
39
+ resolveSessionId,
40
+ setMeta
41
+ } from "./chunk-B24BAVE6.js";
42
+ import {
43
+ __name
44
+ } from "./chunk-7QVYU63E.js";
45
+
46
+ // src/decorators/main-loop.ts
47
+ function MainLoop(options = {}) {
48
+ return (target, propertyKey) => {
49
+ const actualTarget = target.constructor;
50
+ const existing = getMeta(AGENT_MAIN_LOOP, actualTarget);
51
+ if (existing) {
52
+ console.warn(`[@theokit/agents] ${actualTarget.name}: @MainLoop() already declared on '${String(existing.propertyKey)}'. Overwriting with '${String(propertyKey)}'.`);
53
+ }
54
+ const meta = {
55
+ propertyKey,
56
+ strategy: options.strategy ?? "simple-chat",
57
+ maxIterations: options.maxIterations,
58
+ timeoutMs: options.timeoutMs
59
+ };
60
+ setMeta(AGENT_MAIN_LOOP, actualTarget, meta);
61
+ };
62
+ }
63
+ __name(MainLoop, "MainLoop");
64
+ function getMainLoop(target) {
65
+ return getMeta(AGENT_MAIN_LOOP, target);
66
+ }
67
+ __name(getMainLoop, "getMainLoop");
68
+
69
+ // src/decorators/tool.ts
70
+ function inferNamespace(className) {
71
+ const stripped = className.replace(/Tools$/, "");
72
+ return stripped.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/([A-Z])([A-Z][a-z])/g, "$1-$2").toLowerCase();
73
+ }
74
+ __name(inferNamespace, "inferNamespace");
75
+ function Toolbox(options = {}) {
76
+ return (target) => {
77
+ const ns = options.namespace ?? inferNamespace(target.name);
78
+ setMeta(TOOLBOX_CONFIG, target, {
79
+ ...options,
80
+ namespace: ns
81
+ });
82
+ };
83
+ }
84
+ __name(Toolbox, "Toolbox");
85
+ function Tool(options) {
86
+ return (target, propertyKey) => {
87
+ const actualTarget = target.constructor;
88
+ setMeta(TOOL_CONFIG, actualTarget, options, propertyKey);
89
+ const existing = getMeta(TOOL_METHODS, actualTarget) ?? [];
90
+ setMeta(TOOL_METHODS, actualTarget, [
91
+ ...existing,
92
+ propertyKey
93
+ ]);
94
+ };
95
+ }
96
+ __name(Tool, "Tool");
97
+ function getToolboxConfig(target) {
98
+ return getMeta(TOOLBOX_CONFIG, target);
99
+ }
100
+ __name(getToolboxConfig, "getToolboxConfig");
101
+ function getToolMethods(target) {
102
+ return getMeta(TOOL_METHODS, target) ?? [];
103
+ }
104
+ __name(getToolMethods, "getToolMethods");
105
+ function getToolConfig(target, propertyKey) {
106
+ return getMeta(TOOL_CONFIG, target, propertyKey);
107
+ }
108
+ __name(getToolConfig, "getToolConfig");
109
+
110
+ // src/decorators/hook.ts
111
+ var HOOKS_CONFIG = /* @__PURE__ */ Symbol.for("theokit:agents:hooks");
112
+ function Hook(point) {
113
+ return (target, propertyKey) => {
114
+ const actualTarget = target.constructor;
115
+ const existing = getMeta(HOOKS_CONFIG, actualTarget) ?? [];
116
+ setMeta(HOOKS_CONFIG, actualTarget, [
117
+ ...existing,
118
+ {
119
+ point,
120
+ propertyKey
121
+ }
122
+ ]);
123
+ };
124
+ }
125
+ __name(Hook, "Hook");
126
+ function getHooks(target) {
127
+ return getMeta(HOOKS_CONFIG, target) ?? [];
128
+ }
129
+ __name(getHooks, "getHooks");
130
+ function getHooksByPoint(target, point) {
131
+ return getHooks(target).filter((h) => h.point === point);
132
+ }
133
+ __name(getHooksByPoint, "getHooksByPoint");
134
+
135
+ // src/decorators/conversation.ts
136
+ var CONVERSATION_CONFIG = /* @__PURE__ */ Symbol.for("theokit:agents:conversation");
137
+ function Conversation(options = {}) {
138
+ return (target) => {
139
+ setMeta(CONVERSATION_CONFIG, target, {
140
+ storage: "memory",
141
+ maxHistory: 0,
142
+ compaction: "truncate",
143
+ ttl: 0,
144
+ preserveLastN: 5,
145
+ ...options
146
+ });
147
+ };
148
+ }
149
+ __name(Conversation, "Conversation");
150
+ function getConversationConfig(target) {
151
+ return getMeta(CONVERSATION_CONFIG, target);
152
+ }
153
+ __name(getConversationConfig, "getConversationConfig");
154
+
155
+ // src/decorators/model.ts
156
+ import { createDecorator } from "@theokit/http";
157
+ var Model = createDecorator();
158
+
159
+ // src/decorators/artifact.ts
160
+ var ARTIFACT_CONFIG = /* @__PURE__ */ Symbol.for("theokit:agents:artifact");
161
+ function Artifact(options) {
162
+ return (target, propertyKey) => {
163
+ const actualTarget = target.constructor;
164
+ setMeta(ARTIFACT_CONFIG, actualTarget, {
165
+ streamable: true,
166
+ maxSize: 0,
167
+ ...options
168
+ }, propertyKey);
169
+ };
170
+ }
171
+ __name(Artifact, "Artifact");
172
+ function getArtifactConfig(target, propertyKey) {
173
+ return getMeta(ARTIFACT_CONFIG, target, propertyKey);
174
+ }
175
+ __name(getArtifactConfig, "getArtifactConfig");
176
+
177
+ // src/decorators/observable.ts
178
+ var OBSERVABLE_CONFIG = /* @__PURE__ */ Symbol.for("theokit:agents:observable");
179
+ function Observable(channel) {
180
+ return (target, propertyKey) => {
181
+ const actualTarget = target.constructor;
182
+ const existing = getMeta(OBSERVABLE_CONFIG, actualTarget) ?? [];
183
+ setMeta(OBSERVABLE_CONFIG, actualTarget, [
184
+ ...existing,
185
+ {
186
+ channel,
187
+ propertyKey
188
+ }
189
+ ]);
190
+ };
191
+ }
192
+ __name(Observable, "Observable");
193
+ function getObservables(target) {
194
+ return getMeta(OBSERVABLE_CONFIG, target) ?? [];
195
+ }
196
+ __name(getObservables, "getObservables");
197
+ function getObservableByChannel(target, channel) {
198
+ return getObservables(target).find((o) => o.channel === channel);
199
+ }
200
+ __name(getObservableByChannel, "getObservableByChannel");
201
+
202
+ // src/decorators/sandbox.ts
203
+ import { resolve } from "path";
204
+ var SANDBOX_CONFIG = /* @__PURE__ */ Symbol.for("theokit:agents:sandbox");
205
+ function Sandbox(options) {
206
+ return (target) => {
207
+ setMeta(SANDBOX_CONFIG, target, {
208
+ network: true,
209
+ commandTimeout: 12e4,
210
+ ...options
211
+ });
212
+ };
213
+ }
214
+ __name(Sandbox, "Sandbox");
215
+ function getSandboxConfig(target) {
216
+ return getMeta(SANDBOX_CONFIG, target);
217
+ }
218
+ __name(getSandboxConfig, "getSandboxConfig");
219
+ function isPathAllowed(sandbox, filePath, operation) {
220
+ if (filePath.includes("\0")) return false;
221
+ const normalized = resolve("/", filePath).slice(1);
222
+ const fs = sandbox.filesystem;
223
+ if (!fs) return true;
224
+ if (fs.deny?.some((pattern) => matchGlob(pattern, normalized))) return false;
225
+ const allowList = operation === "read" ? fs.read : fs.write;
226
+ if (!allowList) return true;
227
+ return allowList.some((pattern) => matchGlob(pattern, normalized));
228
+ }
229
+ __name(isPathAllowed, "isPathAllowed");
230
+ var SHELL_METACHARS = /[;|&$`(){}<>\n\r]/;
231
+ function isCommandAllowed(sandbox, command) {
232
+ const cmds = sandbox.commands;
233
+ if (!cmds) return true;
234
+ if (SHELL_METACHARS.test(command)) return false;
235
+ const binary = command.split(/\s+/)[0];
236
+ if (cmds.deny?.some((d) => binary === d || command.startsWith(d + " ") || command === d)) return false;
237
+ if (!cmds.allow) return true;
238
+ return cmds.allow.some((a) => binary === a || command.startsWith(a + " ") || command === a);
239
+ }
240
+ __name(isCommandAllowed, "isCommandAllowed");
241
+ function matchGlob(pattern, filePath) {
242
+ const escaped = pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*/g, "\0GLOBSTAR\0").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]").replace(/\0GLOBSTAR\0/g, ".*");
243
+ const regex = buildGlobRegex(escaped);
244
+ return regex.test(filePath);
245
+ }
246
+ __name(matchGlob, "matchGlob");
247
+ function buildGlobRegex(escapedPattern) {
248
+ return RegExp(`^${escapedPattern}$`);
249
+ }
250
+ __name(buildGlobRegex, "buildGlobRegex");
251
+
252
+ // src/decorators/edit-format.ts
253
+ import { createDecorator as createDecorator2 } from "@theokit/http";
254
+ var EditFormat = createDecorator2();
255
+
256
+ // src/decorators/apply-decorators.ts
257
+ function applyDecorators(...decorators) {
258
+ return (target, propertyKey, descriptor) => {
259
+ for (const decorator of decorators) {
260
+ if (propertyKey !== void 0 && descriptor !== void 0) {
261
+ ;
262
+ decorator(target, propertyKey, descriptor);
263
+ } else {
264
+ ;
265
+ decorator(target);
266
+ }
267
+ }
268
+ };
269
+ }
270
+ __name(applyDecorators, "applyDecorators");
63
271
  export {
64
272
  Agent,
65
273
  Artifact,
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../src/decorators/main-loop.ts","../src/decorators/tool.ts","../src/decorators/hook.ts","../src/decorators/conversation.ts","../src/decorators/model.ts","../src/decorators/artifact.ts","../src/decorators/observable.ts","../src/decorators/sandbox.ts","../src/decorators/edit-format.ts","../src/decorators/apply-decorators.ts"],"sourcesContent":["/**\n * @MainLoop() — marks the execution entry point of an agent.\n *\n * Only one @MainLoop per agent class. Second application overwrites (last-wins, with warning).\n */\nimport { setMeta, getMeta, AGENT_MAIN_LOOP } from '../metadata/index.js'\nimport type { MainLoopOptions, MainLoopMeta } from '../types.js'\n\nexport function MainLoop(options: MainLoopOptions = {}): MethodDecorator {\n return (target: object, propertyKey: string | symbol) => {\n const actualTarget = target.constructor\n const existing = getMeta<MainLoopMeta>(AGENT_MAIN_LOOP, actualTarget)\n if (existing) {\n console.warn(\n `[@theokit/agents] ${actualTarget.name}: @MainLoop() already declared on '${String(existing.propertyKey)}'. Overwriting with '${String(propertyKey)}'.`,\n )\n }\n const meta: MainLoopMeta = {\n propertyKey,\n strategy: options.strategy ?? 'simple-chat',\n maxIterations: options.maxIterations,\n timeoutMs: options.timeoutMs,\n }\n setMeta(AGENT_MAIN_LOOP, actualTarget, meta)\n }\n}\n\nexport function getMainLoop(target: Function): MainLoopMeta | undefined {\n return getMeta<MainLoopMeta>(AGENT_MAIN_LOOP, target)\n}\n","/**\n * @Toolbox() + @Tool() — group and define agent tools.\n *\n * @Toolbox({ namespace }) is a class decorator that groups related tools.\n * @Tool({ name, description, input, risk }) is a method decorator compiled to defineTool().\n *\n * @UseGuards on @Toolbox applies to ALL tools (per ADR D7).\n */\nimport { setMeta, getMeta, TOOLBOX_CONFIG, TOOL_CONFIG, TOOL_METHODS } from '../metadata/index.js'\nimport type { ToolboxOptions, ToolOptions } from '../types.js'\n\n/**\n * Convention: TaskTools → namespace: 'tasks', ProjectTools → namespace: 'projects'\n * Strips \"Tools\" suffix, converts to kebab-case.\n */\nfunction inferNamespace(className: string): string {\n const stripped = className.replace(/Tools$/, '')\n return stripped\n .replace(/([a-z0-9])([A-Z])/g, '$1-$2')\n .replace(/([A-Z])([A-Z][a-z])/g, '$1-$2')\n .toLowerCase()\n}\n\nexport function Toolbox(options: ToolboxOptions = {}): ClassDecorator {\n return (target: Function) => {\n const ns = options.namespace ?? inferNamespace(target.name)\n setMeta(TOOLBOX_CONFIG, target, { ...options, namespace: ns })\n }\n}\n\nexport function Tool(options: ToolOptions): MethodDecorator {\n return (target: object, propertyKey: string | symbol) => {\n const actualTarget = target.constructor\n setMeta(TOOL_CONFIG, actualTarget, options, propertyKey)\n // Accumulate tool methods list\n const existing = getMeta<(string | symbol)[]>(TOOL_METHODS, actualTarget) ?? []\n setMeta(TOOL_METHODS, actualTarget, [...existing, propertyKey])\n }\n}\n\nexport function getToolboxConfig(target: Function): ToolboxOptions | undefined {\n return getMeta<ToolboxOptions>(TOOLBOX_CONFIG, target)\n}\n\nexport function getToolMethods(target: Function): (string | symbol)[] {\n return getMeta<(string | symbol)[]>(TOOL_METHODS, target) ?? []\n}\n\nexport function getToolConfig(\n target: Function,\n propertyKey: string | symbol,\n): ToolOptions | undefined {\n return getMeta<ToolOptions>(TOOL_CONFIG, target, propertyKey)\n}\n","/**\n * @Hook() — lifecycle hooks WITHIN the agent loop.\n *\n * Unlike HTTP interceptors (which wrap the entire handler), hooks fire at\n * specific points during the agent's reasoning → tool → response cycle.\n *\n * Hook points:\n * - 'before:llm-call' — before each LLM API call\n * - 'after:llm-call' — after each LLM response\n * - 'before:tool-call' — before each tool execution\n * - 'after:tool-call' — after each tool result\n * - 'on:iteration' — at each loop iteration\n * - 'on:complete' — when the agent produces a final answer\n * - 'on:error' — when the agent encounters an error\n *\n * @example\n * ```ts\n * @Agent({ name: 'support', route: '/support' })\n * class SupportAgent {\n * @MainLoop()\n * async run() {}\n *\n * @Hook('before:llm-call')\n * async injectContext(ctx: HookContext) {\n * ctx.appendSystemPrompt(`Time: ${new Date().toISOString()}`)\n * }\n *\n * @Hook('after:tool-call')\n * async trackCost(ctx: HookContext) {\n * await billing.track(ctx.toolCall!.name, ctx.toolCall!.durationMs)\n * }\n * }\n * ```\n */\nimport { setMeta, getMeta } from '../metadata/index.js'\n\nconst HOOKS_CONFIG = Symbol.for('theokit:agents:hooks')\n\nexport type HookPoint =\n | 'before:llm-call'\n | 'after:llm-call'\n | 'before:tool-call'\n | 'after:tool-call'\n | 'on:iteration'\n | 'on:complete'\n | 'on:error'\n\nexport interface HookEntry {\n point: HookPoint\n propertyKey: string | symbol\n}\n\nexport function Hook(point: HookPoint): MethodDecorator {\n return (target: object, propertyKey: string | symbol) => {\n const actualTarget = target.constructor\n const existing = getMeta<HookEntry[]>(HOOKS_CONFIG, actualTarget) ?? []\n setMeta(HOOKS_CONFIG, actualTarget, [...existing, { point, propertyKey }])\n }\n}\n\nexport function getHooks(target: Function): HookEntry[] {\n return getMeta<HookEntry[]>(HOOKS_CONFIG, target) ?? []\n}\n\nexport function getHooksByPoint(target: Function, point: HookPoint): HookEntry[] {\n return getHooks(target).filter((h) => h.point === point)\n}\n","/**\n * @Conversation() — declares conversation persistence strategy for an agent.\n *\n * Controls how the agent remembers message history across sessions.\n * Compiles to SDK's ConversationStorageAdapter configuration.\n *\n * @example\n * ```ts\n * @Agent({ name: 'support', route: '/support' })\n * @Conversation({\n * storage: 'drizzle',\n * maxHistory: 100,\n * compaction: 'summarize',\n * ttl: 24 * 60 * 60 * 1000,\n * })\n * class SupportAgent { ... }\n * ```\n */\nimport { setMeta, getMeta } from '../metadata/index.js'\n\nconst CONVERSATION_CONFIG = Symbol.for('theokit:agents:conversation')\n\nexport type ConversationStorage = 'memory' | 'filesystem' | 'drizzle' | 'redis'\nexport type CompactionStrategy = 'truncate' | 'summarize' | 'sliding-window'\n\nexport interface ConversationOptions {\n /** Storage backend for conversation history. */\n storage?: ConversationStorage\n /** Maximum messages before compaction triggers (0 = no limit). */\n maxHistory?: number\n /** How to compact when maxHistory is exceeded. */\n compaction?: CompactionStrategy\n /** Time-to-live in milliseconds before conversation expires (0 = never). */\n ttl?: number\n /** Number of recent messages to always preserve during compaction. */\n preserveLastN?: number\n}\n\nexport function Conversation(options: ConversationOptions = {}): ClassDecorator {\n return (target: Function) => {\n setMeta(CONVERSATION_CONFIG, target, {\n storage: 'memory',\n maxHistory: 0,\n compaction: 'truncate',\n ttl: 0,\n preserveLastN: 5,\n ...options,\n })\n }\n}\n\nexport function getConversationConfig(target: Function): ConversationOptions | undefined {\n return getMeta<ConversationOptions>(CONVERSATION_CONFIG, target)\n}\n","/**\n * @Model() — override the LLM model at agent or tool level.\n *\n * Hierarchical resolution via Reflector.getAllAndOverride:\n * tool @Model > agent @Model > @Agent({ model }) > config default\n *\n * This is a MODEL selector, not a PROVIDER selector. Provider routing\n * (which API key, which endpoint, fallback chains) lives in theo.config.ts\n * as runtime configuration — not in decorators.\n *\n * @example\n * ```ts\n * @Agent({ name: 'support', route: '/support' })\n * @Model('claude-sonnet-4-5-20250929') // default for all tools\n * class SupportAgent {\n * @MainLoop()\n * async run() {}\n * }\n *\n * @Toolbox({ namespace: 'code' })\n * class CodeTools {\n * @Tool({ name: 'generate', description: 'Generate code', input: z.object({...}) })\n * @Model('claude-opus-4-6') // this tool needs the most capable model\n * async generate() { ... }\n *\n * @Tool({ name: 'lint', description: 'Lint code', input: z.object({...}) })\n * // no @Model — inherits from agent level\n * async lint() { ... }\n * }\n * ```\n */\nimport { createDecorator } from '@theokit/http'\n\n/** Override the LLM model for an agent class or a specific tool method. */\nexport const Model = createDecorator<string>()\n","/**\n * @Artifact() — marks a tool as producing structured output artifacts.\n *\n * Artifacts are SEPARATE from text responses. When a tool produces an artifact\n * (code file, document, diagram, JSON data), the SSE stream emits artifact_start\n * + artifact_chunk events alongside text_delta events.\n *\n * Inspired by assistant-ui's A2AArtifact pattern where artifacts have their own\n * lifecycle (start → chunks → complete) independent of message content.\n *\n * @example\n * ```ts\n * @Toolbox({ namespace: 'code' })\n * class CodeTools {\n * @Tool({ name: 'generate', description: 'Generate code', input: z.object({...}) })\n * @Artifact({ mimeType: 'text/typescript', streamable: true })\n * async generate(input: { spec: string }): Promise<ArtifactResult> {\n * return {\n * content: generatedCode,\n * filename: 'component.tsx',\n * metadata: { language: 'typescript', loc: 42 },\n * }\n * }\n * }\n * ```\n */\nimport { setMeta, getMeta } from '../metadata/index.js'\n\nconst ARTIFACT_CONFIG = Symbol.for('theokit:agents:artifact')\n\nexport interface ArtifactOptions {\n /** MIME type of the artifact output. */\n mimeType: string\n /** Whether the artifact can be streamed in chunks (default: true). */\n streamable?: boolean\n /** Maximum size in bytes (0 = no limit). */\n maxSize?: number\n}\n\n/** Return type for tools decorated with @Artifact. */\nexport interface ArtifactResult {\n /** The artifact content (string for text, Buffer for binary). */\n content: string\n /** Optional filename hint for the client. */\n filename?: string\n /** Optional metadata attached to the artifact. */\n metadata?: Record<string, unknown>\n}\n\nexport function Artifact(options: ArtifactOptions): MethodDecorator {\n return (target: object, propertyKey: string | symbol) => {\n const actualTarget = target.constructor\n setMeta(ARTIFACT_CONFIG, actualTarget, { streamable: true, maxSize: 0, ...options }, propertyKey)\n }\n}\n\nexport function getArtifactConfig(\n target: Function,\n propertyKey: string | symbol,\n): ArtifactOptions | undefined {\n return getMeta<ArtifactOptions>(ARTIFACT_CONFIG, target, propertyKey)\n}\n","/**\n * @Observable() — exposes agent internal state as a real-time stream.\n *\n * Clients subscribe to named observables to monitor agent execution in real-time:\n * token usage, cost, iteration progress, pending approvals, retrieved facts.\n *\n * Inspired by Liveblocks' Presence pattern and tRPC subscriptions. The agent\n * pushes state updates via SSE alongside response events — clients are never\n * \"blind\" during long-running agent operations.\n *\n * @example\n * ```ts\n * @Agent({ name: 'research', route: '/research' })\n * class ResearchAgent {\n * @MainLoop()\n * async run() {}\n *\n * @Observable('metrics')\n * getMetrics(ctx: AgentContext): AgentMetrics {\n * return {\n * tokensUsed: ctx.tokenCount,\n * costUsd: ctx.costUsd,\n * iteration: ctx.iteration,\n * pendingApprovals: ctx.pendingApprovals.length,\n * }\n * }\n * }\n *\n * // SSE emits: { type: 'state_update', channel: 'metrics', data: {...} }\n * // Client: eventSource.addEventListener('state_update', handler)\n * ```\n */\nimport { setMeta, getMeta } from '../metadata/index.js'\n\nconst OBSERVABLE_CONFIG = Symbol.for('theokit:agents:observable')\n\nexport interface ObservableEntry {\n channel: string\n propertyKey: string | symbol\n}\n\nexport function Observable(channel: string): MethodDecorator {\n return (target: object, propertyKey: string | symbol) => {\n const actualTarget = target.constructor\n const existing = getMeta<ObservableEntry[]>(OBSERVABLE_CONFIG, actualTarget) ?? []\n setMeta(OBSERVABLE_CONFIG, actualTarget, [...existing, { channel, propertyKey }])\n }\n}\n\nexport function getObservables(target: Function): ObservableEntry[] {\n return getMeta<ObservableEntry[]>(OBSERVABLE_CONFIG, target) ?? []\n}\n\nexport function getObservableByChannel(target: Function, channel: string): ObservableEntry | undefined {\n return getObservables(target).find((o) => o.channel === channel)\n}\n","/**\n * @Sandbox() — declares file/command permission scope for code assistant agents.\n *\n * Controls what the agent can read, write, and execute. The runtime enforces\n * these permissions BEFORE tool execution — a tool that tries to write to a\n * denied path gets a typed error, not a crash.\n *\n * Inspired by Claude Code's permission system (allow/deny per tool + path).\n *\n * @example\n * ```ts\n * @Agent({ name: 'coder', route: '/agents/coder' })\n * @Sandbox({\n * filesystem: {\n * read: ['src/**', 'tests/**', 'package.json'],\n * write: ['src/**', 'tests/**'],\n * deny: ['node_modules/**', '.env', '*.key'],\n * },\n * commands: {\n * allow: ['npm test', 'tsc --noEmit', 'git diff'],\n * deny: ['rm -rf', 'git push --force', 'npm publish'],\n * },\n * network: false,\n * })\n * class CoderAgent { ... }\n * ```\n */\nimport { resolve } from 'node:path'\n\nimport { setMeta, getMeta } from '../metadata/index.js'\n\nconst SANDBOX_CONFIG = Symbol.for('theokit:agents:sandbox')\n\nexport interface FilesystemPermissions {\n /** Glob patterns for allowed read paths. */\n read?: string[]\n /** Glob patterns for allowed write paths. */\n write?: string[]\n /** Glob patterns for DENIED paths (overrides read/write). */\n deny?: string[]\n}\n\nexport interface CommandPermissions {\n /** Command prefixes allowed to execute. */\n allow?: string[]\n /** Command prefixes denied (overrides allow). */\n deny?: string[]\n}\n\nexport interface SandboxOptions {\n /** Filesystem read/write permissions. */\n filesystem?: FilesystemPermissions\n /** Shell command execution permissions. */\n commands?: CommandPermissions\n /** Allow outbound network from tools (default: true). */\n network?: boolean\n /** Maximum execution time per command in ms (default: 120_000). */\n commandTimeout?: number\n /** Working directory root (default: process.cwd()). */\n cwd?: string\n}\n\nexport function Sandbox(options: SandboxOptions): ClassDecorator {\n return (target: Function) => {\n setMeta(SANDBOX_CONFIG, target, {\n network: true,\n commandTimeout: 120_000,\n ...options,\n })\n }\n}\n\nexport function getSandboxConfig(target: Function): SandboxOptions | undefined {\n return getMeta<SandboxOptions>(SANDBOX_CONFIG, target)\n}\n\n/**\n * Check if a file path is allowed for the given operation.\n * Deny patterns always win over allow patterns.\n *\n * Security: normalizes paths to prevent traversal (../) and rejects null bytes.\n */\nexport function isPathAllowed(\n sandbox: SandboxOptions,\n filePath: string,\n operation: 'read' | 'write',\n): boolean {\n // EC-2: null byte injection — reject before any processing\n if (filePath.includes('\\x00')) return false\n\n // Path traversal fix: normalize to remove ../ sequences\n const normalized = resolve('/', filePath).slice(1)\n\n const fs = sandbox.filesystem\n if (!fs) return true // no filesystem restrictions\n\n // Deny always wins\n if (fs.deny?.some((pattern) => matchGlob(pattern, normalized))) return false\n\n const allowList = operation === 'read' ? fs.read : fs.write\n if (!allowList) return true // no explicit allow = allow all (minus deny)\n\n return allowList.some((pattern) => matchGlob(pattern, normalized))\n}\n\n/**\n * Shell metacharacters that indicate injection attempts.\n * EC-1: includes redirect operators (>, <) and newlines (\\n, \\r).\n */\nconst SHELL_METACHARS = /[;|&$`(){}<>\\n\\r]/\n\n/**\n * Check if a command is allowed to execute.\n * Deny patterns always win. Rejects shell metacharacters.\n *\n * Security: tokenizes command to match binary name, not arbitrary prefix.\n */\nexport function isCommandAllowed(sandbox: SandboxOptions, command: string): boolean {\n const cmds = sandbox.commands\n if (!cmds) return true\n\n // Reject any command with shell metacharacters (injection prevention)\n if (SHELL_METACHARS.test(command)) return false\n\n // Extract binary name (first whitespace-delimited token)\n const binary = command.split(/\\s+/)[0]\n\n // Deny always wins — check both exact binary match and full command prefix\n if (cmds.deny?.some((d) => binary === d || command.startsWith(d + ' ') || command === d))\n return false\n\n if (!cmds.allow) return true\n\n // Allow: match exact binary or full command prefix\n return cmds.allow.some((a) => binary === a || command.startsWith(a + ' ') || command === a)\n}\n\n/**\n * Glob matcher — converts glob pattern to regex at call time.\n * Uses a pre-built RegExp from a sanitized pattern string.\n * Supports *, **, and ? glob characters.\n */\nfunction matchGlob(pattern: string, filePath: string): boolean {\n // Escape all regex specials except glob chars (* and ?)\n const escaped = pattern\n .replace(/[.+^${}()|[\\]\\\\]/g, '\\\\$&')\n .replace(/\\*\\*/g, '\\0GLOBSTAR\\0')\n .replace(/\\*/g, '[^/]*')\n .replace(/\\?/g, '[^/]')\n .replace(/\\0GLOBSTAR\\0/g, '.*')\n // Pre-compile regex outside of hot path (pattern is controlled by developer, not user input)\n const regex = buildGlobRegex(escaped)\n return regex.test(filePath)\n}\n\n/** Build a regex from a pre-escaped glob pattern string. */\nfunction buildGlobRegex(escapedPattern: string): RegExp {\n return RegExp(`^${escapedPattern}$`)\n}\n","/**\n * @EditFormat() — declares how a tool outputs file edits.\n *\n * Code assistants show DIFFS, not entire files. This decorator tells the\n * runtime which format the tool produces so the SSE stream emits the\n * correct `file_edit` event type.\n *\n * @example\n * ```ts\n * @Toolbox({ namespace: 'editor' })\n * class EditorTools {\n * @Tool({ name: 'edit', description: 'Edit file', input: editSchema })\n * @EditFormat('search-replace')\n * async edit(input: { file: string; search: string; replace: string }) {\n * return { file: input.file, search: input.search, replace: input.replace }\n * }\n *\n * @Tool({ name: 'write', description: 'Write file', input: writeSchema })\n * @EditFormat('full-file')\n * async write(input: { file: string; content: string }) {\n * return { file: input.file, content: input.content }\n * }\n * }\n * ```\n */\nimport { createDecorator } from '@theokit/http'\n\nexport type EditFormatType =\n | 'search-replace' // { file, search, replace } — Claude Code Edit pattern\n | 'unified-diff' // Standard unified diff format\n | 'full-file' // Complete file content (Write pattern)\n | 'line-range' // { file, startLine, endLine, content }\n\n/** Declare the edit format a tool produces. */\nexport const EditFormat = createDecorator<EditFormatType>()\n","/**\n * applyDecorators() — compose multiple decorators into a single reusable decorator.\n *\n * NestJS-compatible utility. Enables creating \"preset\" decorators that bundle\n * common configurations (auth + throttle + trace + memory + ...) into one decorator.\n *\n * @example\n * ```ts\n * // Create a reusable preset\n * const ProductionAgent = (name: string, route: string) => applyDecorators(\n * Agent({ name, route, model: 'claude-sonnet-4-5-20250929' }),\n * UseGuards(AuthGuard, TenantGuard),\n * Throttle({ limit: 30, ttl: 60_000 }),\n * Budget({ maxCostUsd: 5.00 }),\n * Trace(true),\n * )\n *\n * // Apply preset to any agent\n * @ProductionAgent('support', '/api/agents/support')\n * class SupportAgent {\n * @MainLoop()\n * async run() {}\n * }\n * ```\n */\n\ntype AnyDecorator = ClassDecorator | MethodDecorator | PropertyDecorator\n\n/**\n * Compose multiple decorators into a single decorator.\n * Works for both class-level and method-level decorators.\n */\nexport function applyDecorators(\n ...decorators: AnyDecorator[]\n): ClassDecorator & MethodDecorator {\n return (\n target: object | Function,\n propertyKey?: string | symbol,\n descriptor?: PropertyDescriptor,\n ) => {\n for (const decorator of decorators) {\n if (propertyKey !== undefined && descriptor !== undefined) {\n // Method-level\n ;(decorator as MethodDecorator)(target, propertyKey, descriptor)\n } else {\n // Class-level\n ;(decorator as ClassDecorator)(target as Function)\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQO,SAASA,SAASC,UAA2B,CAAC,GAAC;AACpD,SAAO,CAACC,QAAgBC,gBAAAA;AACtB,UAAMC,eAAeF,OA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AAaF,eAAeE,QAAW;;AAEvDD,kBAA8BH,QAAQC,aAAaC,UAAAA;MACvD,OAAO;;AAEHC,kBAA6BH,MAAAA;MACjC;IACF;EACF;AACF;AAlBgBF;","names":["MainLoop","options","target","propertyKey","actualTarget","existing","getMeta","AGENT_MAIN_LOOP","console","warn","name","String","meta","strategy","maxIterations","timeoutMs","setMeta","getMainLoop","inferNamespace","className","stripped","replace","toLowerCase","Toolbox","options","target","ns","namespace","name","setMeta","TOOLBOX_CONFIG","Tool","propertyKey","actualTarget","TOOL_CONFIG","existing","getMeta","TOOL_METHODS","getToolboxConfig","getToolMethods","getToolConfig","HOOKS_CONFIG","Symbol","for","Hook","point","target","propertyKey","actualTarget","existing","getMeta","setMeta","getHooks","getHooksByPoint","filter","h","CONVERSATION_CONFIG","Symbol","for","Conversation","options","target","setMeta","storage","maxHistory","compaction","ttl","preserveLastN","getConversationConfig","getMeta","createDecorator","Model","ARTIFACT_CONFIG","Symbol","for","Artifact","options","target","propertyKey","actualTarget","setMeta","streamable","maxSize","getArtifactConfig","getMeta","OBSERVABLE_CONFIG","Symbol","for","Observable","channel","target","propertyKey","actualTarget","existing","getMeta","setMeta","getObservables","getObservableByChannel","find","o","resolve","SANDBOX_CONFIG","Symbol","for","Sandbox","options","target","setMeta","network","commandTimeout","getSandboxConfig","getMeta","isPathAllowed","sandbox","filePath","operation","includes","normalized","resolve","slice","fs","filesystem","deny","some","pattern","matchGlob","allowList","read","write","SHELL_METACHARS","isCommandAllowed","command","cmds","commands","test","binary","split","d","startsWith","allow","a","escaped","replace","regex","buildGlobRegex","escapedPattern","RegExp","createDecorator","EditFormat","applyDecorators","decorators","target","propertyKey","descriptor","decorator","undefined"]}
package/dist/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
- export { Agent, Artifact, ArtifactOptions, ArtifactResult, Audit, Budget, CommandPermissions, CompactionStrategy, Conversation, ConversationOptions, ConversationStorage, EditFormat, EditFormatType, FilesystemPermissions, Guardrails, Hook, HookEntry, HookPoint, MainLoop, Mixin, Model, Observable, ObservableEntry, Policy, RequiresApproval, RequiresCapability, Sandbox, SandboxOptions, SubAgents, Tool, Toolbox, Trace, applyDecorators, getAgentConfig, getArtifactConfig, getConversationConfig, getGuardrailsConfig, getHooks, getHooksByPoint, getMainLoop, getMixins, getObservableByChannel, getObservables, getSandboxConfig, getSubAgents, getToolConfig, getToolMethods, getToolboxConfig, isCommandAllowed, isPathAllowed } from './decorators.js';
2
- import { G as Guardrail, R as ReasoningEffort } from './types-S7k_lt1_.js';
3
- export { A as AgentOptions, a as ApprovalOptions, B as BudgetOptions, C as Checkpoint, b as CheckpointOptions, c as CheckpointState, d as CheckpointStorage, e as CheckpointStrategy, f as Compaction, g as CompactionDecoratorConfig, h as ContextCompactionStrategy, i as ContextWindow, j as ContextWindowOptions, k as CostBudgetExceededError, l as Gateway, m as GatewayOptions, n as GuardrailAction, o as GuardrailPhase, p as GuardrailResult, q as GuardrailViolationError, H as HumanInTheLoop, r as HumanInTheLoopOptions, I as IndexStrategy, M as MCP, s as MainLoopMeta, t as MainLoopOptions, u as McpServerConfig, v as McpServersMap, w as Memory, x as MemoryOptions, y as MemoryProvider, z as MemoryScope, P as PlatformName, D as PolicyHandler, E as ProjectContext, F as ProjectContextOptions, J as RelevanceStrategy, S as SessionStrategy, K as Skills, L as SkillsOptions, T as TimeoutAction, N as ToolOptions, O as ToolboxOptions, Q as getCheckpointConfig, U as getCompactionConfig, V as getContextWindowConfig, W as getGatewayConfig, X as getHumanInTheLoopConfig, Y as getMcpConfig, Z as getMemoryConfig, _ as getProjectContextConfig, $ as getSkillsConfig, a0 as resolveSessionId } from './types-S7k_lt1_.js';
4
- import { L as LoopStrategy, R as ReflectionStrategy, C as CompiledAgentOptions, a as CompiledTool, b as RoundStreamFactory, S as StreamEvent, D as DelegationResult, A as AgentManifestEntry } from './bridge-entry-BydskfrI.js';
5
- export { c as AGENT_BRAND, d as AfterToolCallContext, e as AgentBuilder, f as AgentDefinition, g as AgentDefinitionError, h as AgentExecutionContext, i as AgentManifest, 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, E as CompiledContextWindow, F as ContextualTool, G as DEFAULT_MAX_ITERATIONS, H as DefineAgentConfig, I as DelegateFn, J as DelegateOptions, K as DelegationError, M as DoneEvent, N as ErrorEvent, O as FileEditEvent, P as InferAgentInput, Q as InferAgentToolNames, T as IterationEvent, U as LLMCallContext, V as LoopFinishReason, W as LoopOutcome, X as LoopStrategyConfig, Y as McpApprovalSpec, Z as McpRegistryConfig, _ as McpRequestContext, $ as McpSelection, a0 as PartialToolCallEvent, a1 as ProcessInputContext, a2 as ReflectionContext, a3 as ReflectionResult, a4 as ReflectionStrategyConfig, a5 as RunStartedEvent, a6 as ScoreVerdict, a7 as ScoredDelegation, a8 as Scorer, a9 as SdkMessage, aa as Segment, ab as SkillsRequestContext, ac as SkillsSelection, ad as StateUpdateEvent, ae as TextDeltaEvent, af as ThinkingEvent, ag as ToolCallEvent, ah as ToolCallVeto, ai as ToolHooks, aj as ToolHooksPlugin, ak as ToolResultEvent, al as ToolWalkResult, am as ToolboxWalkResult, an as agent, ao as agentsPlugin, ap as buildModelSelection, aq as compileAgent, ar as compileAgentDefinition, as as compileAgentModule, at as compileContextWindow, au as compileProjectContext, av as compileSkills, aw as compileTools, ax as contextualTool, ay as createAgentExecutionContext, az as createApiErrorHandler, aA as createSdkAgentStream, aB as createThinkTagExtractor, aC as createToolHooksPlugin, aD as defineAgent, 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, aT as ladderReflectionStrategy, aU as loopStrategyConfigSchema, aV as mcpRegistry, aW as mcpToolApprovals, aX as noopReflectionStrategy, aY as projectContextMetadataOnlyKnobs, aZ as reflectionStrategyConfigSchema, a_ as resolveEnabledSkills, a$ as resolveLoopStrategy, 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-BydskfrI.js';
1
+ import { G as Guardrail, R as ReasoningEffort } from './types-DVA4LQsA.js';
2
+ export { A as AgentOptions, a as ApprovalOptions, B as BudgetOptions, C as CostBudgetExceededError, b as GuardrailAction, c as GuardrailPhase, d as GuardrailResult, e as GuardrailViolationError, H as HumanInTheLoopOptions, M as MainLoopMeta, f as MainLoopOptions, P as PolicyHandler, T as TimeoutAction, g as ToolOptions, h as ToolboxOptions } from './types-DVA4LQsA.js';
3
+ import { L as LoopStrategy, R as ReflectionStrategy, C as CompiledAgentOptions, a as CompiledTool, b as RoundStreamFactory, S as StreamEvent, D as DelegationResult, A as AgentManifestEntry } from './bridge-entry-DG3jbXjs.js';
4
+ export { c as AGENT_BRAND, d as AfterToolCallContext, e as AgentBuilder, f as AgentDefinition, g as AgentDefinitionError, h as AgentExecutionContext, i as AgentManifest, 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, E as CompiledContextWindow, F as ContextualTool, G as DEFAULT_MAX_ITERATIONS, H as DefineAgentConfig, I as DelegateFn, J as DelegateOptions, K as DelegationError, M as DoneEvent, N as ErrorEvent, O as FileEditEvent, P as InferAgentInput, Q as InferAgentToolNames, T as IterationEvent, U as LLMCallContext, V as LoopFinishReason, W as LoopOutcome, X as LoopStrategyConfig, Y as McpApprovalSpec, Z as McpRegistryConfig, _ as McpRequestContext, $ as McpSelection, a0 as PartialToolCallEvent, a1 as ProcessInputContext, a2 as ReflectionContext, a3 as ReflectionResult, a4 as ReflectionStrategyConfig, a5 as RunStartedEvent, a6 as ScoreVerdict, a7 as ScoredDelegation, a8 as Scorer, a9 as SdkMessage, aa as Segment, ab as SkillsRequestContext, ac as SkillsSelection, ad as StateUpdateEvent, ae as TextDeltaEvent, af as ThinkingEvent, ag as ToolCallEvent, ah as ToolCallVeto, ai as ToolHooks, aj as ToolHooksPlugin, ak as ToolResultEvent, al as ToolWalkResult, am as ToolboxWalkResult, an as agent, ao as agentsPlugin, ap as buildModelSelection, aq as compileAgent, ar as compileAgentDefinition, as as compileAgentModule, at as compileContextWindow, au as compileProjectContext, av as compileSkills, aw as compileTools, ax as contextualTool, ay as createAgentExecutionContext, az as createApiErrorHandler, aA as createSdkAgentStream, aB as createThinkTagExtractor, aC as createToolHooksPlugin, aD as delegate, aE as delegateBackground, aF as delegateWithScoring, aG as extractThinkTagStream, aH as generateAgentManifest, aI as generateAgentRoutes, aJ as isAgentContext, aK as isAgentDefinition, aL as isApprovalRequired, aM as isDone, aN as isError, aO as isPartialToolCall, aP as isTextDelta, aQ as isToolCall, aR as isToolResult, aS as ladderReflectionStrategy, aT as loopStrategyConfigSchema, aU as mcpRegistry, aV as mcpToolApprovals, aW as noopReflectionStrategy, aX as projectContextMetadataOnlyKnobs, aY as reflectionStrategyConfigSchema, aZ as resolveEnabledSkills, a_ as resolveLoopStrategy, a$ as resolveMcpServers, b0 as runWithApiErrorHandling, b1 as streamAgentResponse, b2 as streamAgentUIMessages, b3 as translateSdkEvent, b4 as translateToUIMessageStream, b5 as validateUniqueRoutes, b6 as walkAgentMetadata } from './bridge-entry-DG3jbXjs.js';
6
5
  import { PluginsSettings, Plugin, ProviderRoutingSettings, AgentDefinition, BudgetTracker, ConversationStorageAdapter, CustomTool } from '@theokit/sdk';
7
6
  import { RetryOptions } from '@theokit/sdk/retry';
8
7
  import { CompressibleMessage } from '@theokit/sdk/compaction';
package/dist/index.js CHANGED
@@ -1,29 +1,3 @@
1
- import {
2
- Artifact,
3
- Conversation,
4
- EditFormat,
5
- Hook,
6
- MainLoop,
7
- Model,
8
- Observable,
9
- Sandbox,
10
- Tool,
11
- Toolbox,
12
- applyDecorators,
13
- getArtifactConfig,
14
- getConversationConfig,
15
- getHooks,
16
- getHooksByPoint,
17
- getMainLoop,
18
- getObservableByChannel,
19
- getObservables,
20
- getSandboxConfig,
21
- getToolConfig,
22
- getToolMethods,
23
- getToolboxConfig,
24
- isCommandAllowed,
25
- isPathAllowed
26
- } from "./chunk-GEV2EQW2.js";
27
1
  import {
28
2
  AGENT_BRAND,
29
3
  AgentDefinitionError,
@@ -54,7 +28,6 @@ import {
54
28
  createSdkAgentStream,
55
29
  createThinkTagExtractor,
56
30
  createToolHooksPlugin,
57
- defineAgent,
58
31
  delegate,
59
32
  delegateBackground,
60
33
  delegateWithScoring,
@@ -96,42 +69,8 @@ import {
96
69
  unicodeNormalizer,
97
70
  validateUniqueRoutes,
98
71
  walkAgentMetadata
99
- } from "./chunk-TXEY3IUO.js";
100
- import {
101
- Agent,
102
- Audit,
103
- Budget,
104
- Checkpoint,
105
- Compaction,
106
- ContextWindow,
107
- Gateway,
108
- Guardrails,
109
- HumanInTheLoop,
110
- MCP,
111
- Memory,
112
- Mixin,
113
- Policy,
114
- ProjectContext,
115
- RequiresApproval,
116
- RequiresCapability,
117
- Skills,
118
- SubAgents,
119
- Trace,
120
- getAgentConfig,
121
- getCheckpointConfig,
122
- getCompactionConfig,
123
- getContextWindowConfig,
124
- getGatewayConfig,
125
- getGuardrailsConfig,
126
- getHumanInTheLoopConfig,
127
- getMcpConfig,
128
- getMemoryConfig,
129
- getMixins,
130
- getProjectContextConfig,
131
- getSkillsConfig,
132
- getSubAgents,
133
- resolveSessionId
134
- } from "./chunk-MD35WBR4.js";
72
+ } from "./chunk-IAE4FWBV.js";
73
+ import "./chunk-B24BAVE6.js";
135
74
  import {
136
75
  __name
137
76
  } from "./chunk-7QVYU63E.js";
@@ -407,49 +346,19 @@ export {
407
346
  AGENT_BRAND,
408
347
  AcpClient,
409
348
  AcpMessageDecoder,
410
- Agent,
411
349
  AgentDefinitionError,
412
350
  AgentRunner,
413
351
  AgentRunnerBuilder,
414
352
  AgentWarningCode,
415
- Artifact,
416
- Audit,
417
- Budget,
418
353
  BudgetExceededError,
419
- Checkpoint,
420
- Compaction,
421
- ContextWindow,
422
- Conversation,
423
354
  CostBudgetExceededError,
424
355
  DEFAULT_KEEP_TOKENS,
425
356
  DEFAULT_MAX_ITERATIONS,
426
357
  DelegationError,
427
- EditFormat,
428
- Gateway,
429
358
  GuardrailViolationError,
430
- Guardrails,
431
- Hook,
432
- HumanInTheLoop,
433
- MCP,
434
359
  MCP_PROTOCOL_VERSION,
435
- MainLoop,
436
- Memory,
437
- Mixin,
438
- Model,
439
- Observable,
440
- Policy,
441
- ProjectContext,
442
- RequiresApproval,
443
- RequiresCapability,
444
- Sandbox,
445
- Skills,
446
- SubAgents,
447
- Tool,
448
- Toolbox,
449
- Trace,
450
360
  agent,
451
361
  agentsPlugin,
452
- applyDecorators,
453
362
  buildAgentCard,
454
363
  buildMcpToolDescriptors,
455
364
  buildModelSelection,
@@ -469,7 +378,6 @@ export {
469
378
  createSdkAgentStream,
470
379
  createThinkTagExtractor,
471
380
  createToolHooksPlugin,
472
- defineAgent,
473
381
  delegate,
474
382
  delegateBackground,
475
383
  delegateWithScoring,
@@ -479,38 +387,12 @@ export {
479
387
  extractThinkTagStream,
480
388
  generateAgentManifest,
481
389
  generateAgentRoutes,
482
- getAgentConfig,
483
- getArtifactConfig,
484
- getCheckpointConfig,
485
- getCompactionConfig,
486
- getContextWindowConfig,
487
- getConversationConfig,
488
- getGatewayConfig,
489
- getGuardrailsConfig,
490
- getHooks,
491
- getHooksByPoint,
492
- getHumanInTheLoopConfig,
493
- getMainLoop,
494
- getMcpConfig,
495
- getMemoryConfig,
496
- getMixins,
497
- getObservableByChannel,
498
- getObservables,
499
- getProjectContextConfig,
500
- getSandboxConfig,
501
- getSkillsConfig,
502
- getSubAgents,
503
- getToolConfig,
504
- getToolMethods,
505
- getToolboxConfig,
506
390
  isAgentContext,
507
391
  isAgentDefinition,
508
392
  isApprovalRequired,
509
- isCommandAllowed,
510
393
  isDone,
511
394
  isError,
512
395
  isPartialToolCall,
513
- isPathAllowed,
514
396
  isTextDelta,
515
397
  isToolCall,
516
398
  isToolResult,
@@ -531,7 +413,6 @@ export {
531
413
  resolveEnabledSkills,
532
414
  resolveLoopStrategy,
533
415
  resolveMcpServers,
534
- resolveSessionId,
535
416
  runInputGuards,
536
417
  runOutputGuards,
537
418
  runWithApiErrorHandling,