@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.
@@ -1,176 +0,0 @@
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
- import '@theokit/sdk';
4
- import 'zod';
5
-
6
- declare function Agent(options?: Partial<AgentOptions>): ClassDecorator;
7
- declare function getAgentConfig(target: Function): AgentOptions | undefined;
8
-
9
- declare function MainLoop(options?: MainLoopOptions): MethodDecorator;
10
- declare function getMainLoop(target: Function): MainLoopMeta | undefined;
11
-
12
- declare function Toolbox(options?: ToolboxOptions): ClassDecorator;
13
- declare function Tool(options: ToolOptions): MethodDecorator;
14
- declare function getToolboxConfig(target: Function): ToolboxOptions | undefined;
15
- declare function getToolMethods(target: Function): (string | symbol)[];
16
- declare function getToolConfig(target: Function, propertyKey: string | symbol): ToolOptions | undefined;
17
-
18
- /** Mark a tool as requiring human approval before execution. */
19
- declare const RequiresApproval: (value: ApprovalOptions) => MethodDecorator & ClassDecorator;
20
- /** Require specific capabilities (permissions) to execute a tool. */
21
- declare const RequiresCapability: (value: string[]) => MethodDecorator & ClassDecorator;
22
- /** Set a cost budget for an agent or tool scope. */
23
- declare const Budget: (value: BudgetOptions) => MethodDecorator & ClassDecorator;
24
- /** Attach policy handler functions (CASL-style authorization). */
25
- declare const Policy: (value: PolicyHandler[]) => MethodDecorator & ClassDecorator;
26
-
27
- /** Enable distributed tracing for a tool/toolbox/agent. */
28
- declare const Trace: (value: boolean) => MethodDecorator & ClassDecorator;
29
- /** Enable audit logging for a tool/toolbox/agent. */
30
- declare const Audit: (value: boolean) => MethodDecorator & ClassDecorator;
31
-
32
- declare function SubAgents(agentClasses: Function[]): ClassDecorator;
33
- declare function getSubAgents(target: Function): Function[];
34
-
35
- /**
36
- * `@Guardrails([...])` — M9 class-decorator surface for input/output guardrails.
37
- *
38
- * The functional `defineAgent({ guardrails: [...] })` path already applies guards at the framework
39
- * boundary (ADR-0040 § D2). This decorator gives the `@Agent` class path the SAME capability: the
40
- * declared guards compile into `compiled.guardrails` (via `walkAgentMetadata`), so `AgentRunner`
41
- * applies them identically. Metadata-only (like `@MCP`/`@Skills`) — it describes, the runner runs.
42
- *
43
- * @example
44
- * ```ts
45
- * @Agent({ name: 'support', route: '/api/agents/support' })
46
- * @Guardrails([promptInjectionDetector(), piiDetector({ redact: true })])
47
- * class SupportAgent {}
48
- * ```
49
- */
50
-
51
- declare function Guardrails(guardrails: readonly Guardrail[]): ClassDecorator;
52
- declare function getGuardrailsConfig(target: Function): readonly Guardrail[] | undefined;
53
-
54
- type HookPoint = 'before:llm-call' | 'after:llm-call' | 'before:tool-call' | 'after:tool-call' | 'on:iteration' | 'on:complete' | 'on:error';
55
- interface HookEntry {
56
- point: HookPoint;
57
- propertyKey: string | symbol;
58
- }
59
- declare function Hook(point: HookPoint): MethodDecorator;
60
- declare function getHooks(target: Function): HookEntry[];
61
- declare function getHooksByPoint(target: Function, point: HookPoint): HookEntry[];
62
-
63
- /** Override the LLM model for an agent class or a specific tool method. */
64
- declare const Model: (value: string) => MethodDecorator & ClassDecorator;
65
-
66
- interface ArtifactOptions {
67
- /** MIME type of the artifact output. */
68
- mimeType: string;
69
- /** Whether the artifact can be streamed in chunks (default: true). */
70
- streamable?: boolean;
71
- /** Maximum size in bytes (0 = no limit). */
72
- maxSize?: number;
73
- }
74
- /** Return type for tools decorated with @Artifact. */
75
- interface ArtifactResult {
76
- /** The artifact content (string for text, Buffer for binary). */
77
- content: string;
78
- /** Optional filename hint for the client. */
79
- filename?: string;
80
- /** Optional metadata attached to the artifact. */
81
- metadata?: Record<string, unknown>;
82
- }
83
- declare function Artifact(options: ArtifactOptions): MethodDecorator;
84
- declare function getArtifactConfig(target: Function, propertyKey: string | symbol): ArtifactOptions | undefined;
85
-
86
- interface ObservableEntry {
87
- channel: string;
88
- propertyKey: string | symbol;
89
- }
90
- declare function Observable(channel: string): MethodDecorator;
91
- declare function getObservables(target: Function): ObservableEntry[];
92
- declare function getObservableByChannel(target: Function, channel: string): ObservableEntry | undefined;
93
-
94
- interface FilesystemPermissions {
95
- /** Glob patterns for allowed read paths. */
96
- read?: string[];
97
- /** Glob patterns for allowed write paths. */
98
- write?: string[];
99
- /** Glob patterns for DENIED paths (overrides read/write). */
100
- deny?: string[];
101
- }
102
- interface CommandPermissions {
103
- /** Command prefixes allowed to execute. */
104
- allow?: string[];
105
- /** Command prefixes denied (overrides allow). */
106
- deny?: string[];
107
- }
108
- interface SandboxOptions {
109
- /** Filesystem read/write permissions. */
110
- filesystem?: FilesystemPermissions;
111
- /** Shell command execution permissions. */
112
- commands?: CommandPermissions;
113
- /** Allow outbound network from tools (default: true). */
114
- network?: boolean;
115
- /** Maximum execution time per command in ms (default: 120_000). */
116
- commandTimeout?: number;
117
- /** Working directory root (default: process.cwd()). */
118
- cwd?: string;
119
- }
120
- declare function Sandbox(options: SandboxOptions): ClassDecorator;
121
- declare function getSandboxConfig(target: Function): SandboxOptions | undefined;
122
- /**
123
- * Check if a file path is allowed for the given operation.
124
- * Deny patterns always win over allow patterns.
125
- *
126
- * Security: normalizes paths to prevent traversal (../) and rejects null bytes.
127
- */
128
- declare function isPathAllowed(sandbox: SandboxOptions, filePath: string, operation: 'read' | 'write'): boolean;
129
- /**
130
- * Check if a command is allowed to execute.
131
- * Deny patterns always win. Rejects shell metacharacters.
132
- *
133
- * Security: tokenizes command to match binary name, not arbitrary prefix.
134
- */
135
- declare function isCommandAllowed(sandbox: SandboxOptions, command: string): boolean;
136
-
137
- type EditFormatType = 'search-replace' | 'unified-diff' | 'full-file' | 'line-range';
138
- /** Declare the edit format a tool produces. */
139
- declare const EditFormat: (value: EditFormatType) => MethodDecorator & ClassDecorator;
140
-
141
- /**
142
- * applyDecorators() — compose multiple decorators into a single reusable decorator.
143
- *
144
- * NestJS-compatible utility. Enables creating "preset" decorators that bundle
145
- * common configurations (auth + throttle + trace + memory + ...) into one decorator.
146
- *
147
- * @example
148
- * ```ts
149
- * // Create a reusable preset
150
- * const ProductionAgent = (name: string, route: string) => applyDecorators(
151
- * Agent({ name, route, model: 'claude-sonnet-4-5-20250929' }),
152
- * UseGuards(AuthGuard, TenantGuard),
153
- * Throttle({ limit: 30, ttl: 60_000 }),
154
- * Budget({ maxCostUsd: 5.00 }),
155
- * Trace(true),
156
- * )
157
- *
158
- * // Apply preset to any agent
159
- * @ProductionAgent('support', '/api/agents/support')
160
- * class SupportAgent {
161
- * @MainLoop()
162
- * async run() {}
163
- * }
164
- * ```
165
- */
166
- type AnyDecorator = ClassDecorator | MethodDecorator | PropertyDecorator;
167
- /**
168
- * Compose multiple decorators into a single decorator.
169
- * Works for both class-level and method-level decorators.
170
- */
171
- declare function applyDecorators(...decorators: AnyDecorator[]): ClassDecorator & MethodDecorator;
172
-
173
- declare function Mixin(...mixinClasses: Function[]): ClassDecorator;
174
- declare function getMixins(target: Function): Function[];
175
-
176
- export { Agent, AgentOptions, ApprovalOptions, Artifact, type ArtifactOptions, type ArtifactResult, Audit, Budget, BudgetOptions, type CommandPermissions, EditFormat, type EditFormatType, type FilesystemPermissions, Guardrails, Hook, type HookEntry, type HookPoint, MainLoop, MainLoopMeta, MainLoopOptions, Mixin, Model, Observable, type ObservableEntry, Policy, PolicyHandler, RequiresApproval, RequiresCapability, Sandbox, type SandboxOptions, SubAgents, Tool, ToolOptions, Toolbox, ToolboxOptions, Trace, applyDecorators, getAgentConfig, getArtifactConfig, getGuardrailsConfig, getHooks, getHooksByPoint, getMainLoop, getMixins, getObservableByChannel, getObservables, getSandboxConfig, getSubAgents, getToolConfig, getToolMethods, getToolboxConfig, isCommandAllowed, isPathAllowed };
@@ -1,308 +0,0 @@
1
- import {
2
- AGENT_MAIN_LOOP,
3
- Agent,
4
- Audit,
5
- Budget,
6
- Checkpoint,
7
- Compaction,
8
- ContextWindow,
9
- Gateway,
10
- Guardrails,
11
- HumanInTheLoop,
12
- MCP,
13
- Memory,
14
- Mixin,
15
- Policy,
16
- ProjectContext,
17
- RequiresApproval,
18
- RequiresCapability,
19
- Skills,
20
- SubAgents,
21
- TOOLBOX_CONFIG,
22
- TOOL_CONFIG,
23
- TOOL_METHODS,
24
- Trace,
25
- getAgentConfig,
26
- getCheckpointConfig,
27
- getCompactionConfig,
28
- getContextWindowConfig,
29
- getGatewayConfig,
30
- getGuardrailsConfig,
31
- getHumanInTheLoopConfig,
32
- getMcpConfig,
33
- getMemoryConfig,
34
- getMeta,
35
- getMixins,
36
- getProjectContextConfig,
37
- getSkillsConfig,
38
- getSubAgents,
39
- resolveSessionId,
40
- setMeta
41
- } from "./chunk-NERDIS45.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/model.ts
136
- import { createDecorator } from "@theokit/http";
137
- var Model = createDecorator();
138
-
139
- // src/decorators/artifact.ts
140
- var ARTIFACT_CONFIG = /* @__PURE__ */ Symbol.for("theokit:agents:artifact");
141
- function Artifact(options) {
142
- return (target, propertyKey) => {
143
- const actualTarget = target.constructor;
144
- setMeta(ARTIFACT_CONFIG, actualTarget, {
145
- streamable: true,
146
- maxSize: 0,
147
- ...options
148
- }, propertyKey);
149
- };
150
- }
151
- __name(Artifact, "Artifact");
152
- function getArtifactConfig(target, propertyKey) {
153
- return getMeta(ARTIFACT_CONFIG, target, propertyKey);
154
- }
155
- __name(getArtifactConfig, "getArtifactConfig");
156
-
157
- // src/decorators/observable.ts
158
- var OBSERVABLE_CONFIG = /* @__PURE__ */ Symbol.for("theokit:agents:observable");
159
- function Observable(channel) {
160
- return (target, propertyKey) => {
161
- const actualTarget = target.constructor;
162
- const existing = getMeta(OBSERVABLE_CONFIG, actualTarget) ?? [];
163
- setMeta(OBSERVABLE_CONFIG, actualTarget, [
164
- ...existing,
165
- {
166
- channel,
167
- propertyKey
168
- }
169
- ]);
170
- };
171
- }
172
- __name(Observable, "Observable");
173
- function getObservables(target) {
174
- return getMeta(OBSERVABLE_CONFIG, target) ?? [];
175
- }
176
- __name(getObservables, "getObservables");
177
- function getObservableByChannel(target, channel) {
178
- return getObservables(target).find((o) => o.channel === channel);
179
- }
180
- __name(getObservableByChannel, "getObservableByChannel");
181
-
182
- // src/decorators/sandbox.ts
183
- import { resolve } from "path";
184
- var SANDBOX_CONFIG = /* @__PURE__ */ Symbol.for("theokit:agents:sandbox");
185
- function Sandbox(options) {
186
- return (target) => {
187
- setMeta(SANDBOX_CONFIG, target, {
188
- network: true,
189
- commandTimeout: 12e4,
190
- ...options
191
- });
192
- };
193
- }
194
- __name(Sandbox, "Sandbox");
195
- function getSandboxConfig(target) {
196
- return getMeta(SANDBOX_CONFIG, target);
197
- }
198
- __name(getSandboxConfig, "getSandboxConfig");
199
- function isPathAllowed(sandbox, filePath, operation) {
200
- if (filePath.includes("\0")) return false;
201
- const normalized = resolve("/", filePath).slice(1);
202
- const fs = sandbox.filesystem;
203
- if (!fs) return true;
204
- if (fs.deny?.some((pattern) => matchGlob(pattern, normalized))) return false;
205
- const allowList = operation === "read" ? fs.read : fs.write;
206
- if (!allowList) return true;
207
- return allowList.some((pattern) => matchGlob(pattern, normalized));
208
- }
209
- __name(isPathAllowed, "isPathAllowed");
210
- var SHELL_METACHARS = /[;|&$`(){}<>\n\r]/;
211
- function isCommandAllowed(sandbox, command) {
212
- const cmds = sandbox.commands;
213
- if (!cmds) return true;
214
- if (SHELL_METACHARS.test(command)) return false;
215
- const binary = command.split(/\s+/)[0];
216
- if (cmds.deny?.some((d) => binary === d || command.startsWith(d + " ") || command === d)) return false;
217
- if (!cmds.allow) return true;
218
- return cmds.allow.some((a) => binary === a || command.startsWith(a + " ") || command === a);
219
- }
220
- __name(isCommandAllowed, "isCommandAllowed");
221
- function matchGlob(pattern, filePath) {
222
- const escaped = pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*/g, "\0GLOBSTAR\0").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]").replace(/\0GLOBSTAR\0/g, ".*");
223
- const regex = buildGlobRegex(escaped);
224
- return regex.test(filePath);
225
- }
226
- __name(matchGlob, "matchGlob");
227
- function buildGlobRegex(escapedPattern) {
228
- return RegExp(`^${escapedPattern}$`);
229
- }
230
- __name(buildGlobRegex, "buildGlobRegex");
231
-
232
- // src/decorators/edit-format.ts
233
- import { createDecorator as createDecorator2 } from "@theokit/http";
234
- var EditFormat = createDecorator2();
235
-
236
- // src/decorators/apply-decorators.ts
237
- function applyDecorators(...decorators) {
238
- return (target, propertyKey, descriptor) => {
239
- for (const decorator of decorators) {
240
- if (propertyKey !== void 0 && descriptor !== void 0) {
241
- ;
242
- decorator(target, propertyKey, descriptor);
243
- } else {
244
- ;
245
- decorator(target);
246
- }
247
- }
248
- };
249
- }
250
- __name(applyDecorators, "applyDecorators");
251
- export {
252
- Agent,
253
- Artifact,
254
- Audit,
255
- Budget,
256
- Checkpoint,
257
- Compaction,
258
- ContextWindow,
259
- EditFormat,
260
- Gateway,
261
- Guardrails,
262
- Hook,
263
- HumanInTheLoop,
264
- MCP,
265
- MainLoop,
266
- Memory,
267
- Mixin,
268
- Model,
269
- Observable,
270
- Policy,
271
- ProjectContext,
272
- RequiresApproval,
273
- RequiresCapability,
274
- Sandbox,
275
- Skills,
276
- SubAgents,
277
- Tool,
278
- Toolbox,
279
- Trace,
280
- applyDecorators,
281
- getAgentConfig,
282
- getArtifactConfig,
283
- getCheckpointConfig,
284
- getCompactionConfig,
285
- getContextWindowConfig,
286
- getGatewayConfig,
287
- getGuardrailsConfig,
288
- getHooks,
289
- getHooksByPoint,
290
- getHumanInTheLoopConfig,
291
- getMainLoop,
292
- getMcpConfig,
293
- getMemoryConfig,
294
- getMixins,
295
- getObservableByChannel,
296
- getObservables,
297
- getProjectContextConfig,
298
- getSandboxConfig,
299
- getSkillsConfig,
300
- getSubAgents,
301
- getToolConfig,
302
- getToolMethods,
303
- getToolboxConfig,
304
- isCommandAllowed,
305
- isPathAllowed,
306
- resolveSessionId
307
- };
308
- //# sourceMappingURL=decorators.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/decorators/main-loop.ts","../src/decorators/tool.ts","../src/decorators/hook.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 * @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, propertyK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ACF;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","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"]}