@theokit/agents 0.1.0-alpha.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.
@@ -0,0 +1,342 @@
1
+ import {
2
+ AGENT_MAIN_LOOP,
3
+ TOOLBOX_CONFIG,
4
+ TOOL_CONFIG,
5
+ TOOL_METHODS,
6
+ __name,
7
+ getMeta,
8
+ setMeta
9
+ } from "./chunk-3LCIXX3T.js";
10
+
11
+ // src/decorators/main-loop.ts
12
+ function MainLoop(options = {}) {
13
+ return (target, propertyKey) => {
14
+ const actualTarget = target.constructor;
15
+ const existing = getMeta(AGENT_MAIN_LOOP, actualTarget);
16
+ if (existing) {
17
+ console.warn(`[@theokit/agents] ${actualTarget.name}: @MainLoop() already declared on '${String(existing.propertyKey)}'. Overwriting with '${String(propertyKey)}'.`);
18
+ }
19
+ const meta = {
20
+ propertyKey,
21
+ strategy: options.strategy ?? "simple-chat",
22
+ maxIterations: options.maxIterations,
23
+ timeoutMs: options.timeoutMs
24
+ };
25
+ setMeta(AGENT_MAIN_LOOP, actualTarget, meta);
26
+ };
27
+ }
28
+ __name(MainLoop, "MainLoop");
29
+ function getMainLoop(target) {
30
+ return getMeta(AGENT_MAIN_LOOP, target);
31
+ }
32
+ __name(getMainLoop, "getMainLoop");
33
+
34
+ // src/decorators/tool.ts
35
+ function Toolbox(options = {}) {
36
+ return (target) => {
37
+ setMeta(TOOLBOX_CONFIG, target, options);
38
+ };
39
+ }
40
+ __name(Toolbox, "Toolbox");
41
+ function Tool(options) {
42
+ return (target, propertyKey) => {
43
+ const actualTarget = target.constructor;
44
+ setMeta(TOOL_CONFIG, actualTarget, options, propertyKey);
45
+ const existing = getMeta(TOOL_METHODS, actualTarget) ?? [];
46
+ setMeta(TOOL_METHODS, actualTarget, [
47
+ ...existing,
48
+ propertyKey
49
+ ]);
50
+ };
51
+ }
52
+ __name(Tool, "Tool");
53
+ function getToolboxConfig(target) {
54
+ return getMeta(TOOLBOX_CONFIG, target);
55
+ }
56
+ __name(getToolboxConfig, "getToolboxConfig");
57
+ function getToolMethods(target) {
58
+ return getMeta(TOOL_METHODS, target) ?? [];
59
+ }
60
+ __name(getToolMethods, "getToolMethods");
61
+ function getToolConfig(target, propertyKey) {
62
+ return getMeta(TOOL_CONFIG, target, propertyKey);
63
+ }
64
+ __name(getToolConfig, "getToolConfig");
65
+
66
+ // src/decorators/hook.ts
67
+ var HOOKS_CONFIG = /* @__PURE__ */ Symbol.for("theokit:agents:hooks");
68
+ function Hook(point) {
69
+ return (target, propertyKey) => {
70
+ const actualTarget = target.constructor;
71
+ const existing = getMeta(HOOKS_CONFIG, actualTarget) ?? [];
72
+ setMeta(HOOKS_CONFIG, actualTarget, [
73
+ ...existing,
74
+ {
75
+ point,
76
+ propertyKey
77
+ }
78
+ ]);
79
+ };
80
+ }
81
+ __name(Hook, "Hook");
82
+ function getHooks(target) {
83
+ return getMeta(HOOKS_CONFIG, target) ?? [];
84
+ }
85
+ __name(getHooks, "getHooks");
86
+ function getHooksByPoint(target, point) {
87
+ return getHooks(target).filter((h) => h.point === point);
88
+ }
89
+ __name(getHooksByPoint, "getHooksByPoint");
90
+
91
+ // src/decorators/conversation.ts
92
+ var CONVERSATION_CONFIG = /* @__PURE__ */ Symbol.for("theokit:agents:conversation");
93
+ function Conversation(options = {}) {
94
+ return (target) => {
95
+ setMeta(CONVERSATION_CONFIG, target, {
96
+ storage: "memory",
97
+ maxHistory: 0,
98
+ compaction: "truncate",
99
+ ttl: 0,
100
+ preserveLastN: 5,
101
+ ...options
102
+ });
103
+ };
104
+ }
105
+ __name(Conversation, "Conversation");
106
+ function getConversationConfig(target) {
107
+ return getMeta(CONVERSATION_CONFIG, target);
108
+ }
109
+ __name(getConversationConfig, "getConversationConfig");
110
+
111
+ // src/decorators/human-in-the-loop.ts
112
+ var HITL_CONFIG = /* @__PURE__ */ Symbol.for("theokit:agents:human-in-the-loop");
113
+ function HumanInTheLoop(options) {
114
+ return (target, propertyKey) => {
115
+ const actualTarget = target.constructor;
116
+ setMeta(HITL_CONFIG, actualTarget, {
117
+ timeout: 3e5,
118
+ onTimeout: "abort",
119
+ showInput: true,
120
+ ...options
121
+ }, propertyKey);
122
+ };
123
+ }
124
+ __name(HumanInTheLoop, "HumanInTheLoop");
125
+ function getHumanInTheLoopConfig(target, propertyKey) {
126
+ return getMeta(HITL_CONFIG, target, propertyKey);
127
+ }
128
+ __name(getHumanInTheLoopConfig, "getHumanInTheLoopConfig");
129
+
130
+ // src/decorators/context-window.ts
131
+ var CONTEXT_WINDOW_CONFIG = /* @__PURE__ */ Symbol.for("theokit:agents:context-window");
132
+ function ContextWindow(options = {}) {
133
+ return (target) => {
134
+ setMeta(CONTEXT_WINDOW_CONFIG, target, {
135
+ maxTokens: 1e5,
136
+ compactionStrategy: "summarize-oldest",
137
+ preserveSystemPrompt: true,
138
+ preserveLastN: 10,
139
+ preserveToolResults: true,
140
+ ...options
141
+ });
142
+ };
143
+ }
144
+ __name(ContextWindow, "ContextWindow");
145
+ function getContextWindowConfig(target) {
146
+ return getMeta(CONTEXT_WINDOW_CONFIG, target);
147
+ }
148
+ __name(getContextWindowConfig, "getContextWindowConfig");
149
+
150
+ // src/decorators/model.ts
151
+ import { createDecorator } from "@theokit/http-decorators";
152
+ var Model = createDecorator();
153
+
154
+ // src/decorators/artifact.ts
155
+ var ARTIFACT_CONFIG = /* @__PURE__ */ Symbol.for("theokit:agents:artifact");
156
+ function Artifact(options) {
157
+ return (target, propertyKey) => {
158
+ const actualTarget = target.constructor;
159
+ setMeta(ARTIFACT_CONFIG, actualTarget, {
160
+ streamable: true,
161
+ maxSize: 0,
162
+ ...options
163
+ }, propertyKey);
164
+ };
165
+ }
166
+ __name(Artifact, "Artifact");
167
+ function getArtifactConfig(target, propertyKey) {
168
+ return getMeta(ARTIFACT_CONFIG, target, propertyKey);
169
+ }
170
+ __name(getArtifactConfig, "getArtifactConfig");
171
+
172
+ // src/decorators/checkpoint.ts
173
+ var CHECKPOINT_CONFIG = /* @__PURE__ */ Symbol.for("theokit:agents:checkpoint");
174
+ function Checkpoint(options = {}) {
175
+ return (target) => {
176
+ setMeta(CHECKPOINT_CONFIG, target, {
177
+ storage: "memory",
178
+ strategy: "after-tool-call",
179
+ maxCheckpoints: 10,
180
+ ttl: 36e5,
181
+ ...options
182
+ });
183
+ };
184
+ }
185
+ __name(Checkpoint, "Checkpoint");
186
+ function getCheckpointConfig(target) {
187
+ return getMeta(CHECKPOINT_CONFIG, target);
188
+ }
189
+ __name(getCheckpointConfig, "getCheckpointConfig");
190
+
191
+ // src/decorators/observable.ts
192
+ var OBSERVABLE_CONFIG = /* @__PURE__ */ Symbol.for("theokit:agents:observable");
193
+ function Observable(channel) {
194
+ return (target, propertyKey) => {
195
+ const actualTarget = target.constructor;
196
+ const existing = getMeta(OBSERVABLE_CONFIG, actualTarget) ?? [];
197
+ setMeta(OBSERVABLE_CONFIG, actualTarget, [
198
+ ...existing,
199
+ {
200
+ channel,
201
+ propertyKey
202
+ }
203
+ ]);
204
+ };
205
+ }
206
+ __name(Observable, "Observable");
207
+ function getObservables(target) {
208
+ return getMeta(OBSERVABLE_CONFIG, target) ?? [];
209
+ }
210
+ __name(getObservables, "getObservables");
211
+ function getObservableByChannel(target, channel) {
212
+ return getObservables(target).find((o) => o.channel === channel);
213
+ }
214
+ __name(getObservableByChannel, "getObservableByChannel");
215
+
216
+ // src/decorators/sandbox.ts
217
+ var SANDBOX_CONFIG = /* @__PURE__ */ Symbol.for("theokit:agents:sandbox");
218
+ function Sandbox(options) {
219
+ return (target) => {
220
+ setMeta(SANDBOX_CONFIG, target, {
221
+ network: true,
222
+ commandTimeout: 12e4,
223
+ ...options
224
+ });
225
+ };
226
+ }
227
+ __name(Sandbox, "Sandbox");
228
+ function getSandboxConfig(target) {
229
+ return getMeta(SANDBOX_CONFIG, target);
230
+ }
231
+ __name(getSandboxConfig, "getSandboxConfig");
232
+ function isPathAllowed(sandbox, filePath, operation) {
233
+ const fs = sandbox.filesystem;
234
+ if (!fs) return true;
235
+ if (fs.deny?.some((pattern) => matchGlob(pattern, filePath))) return false;
236
+ const allowList = operation === "read" ? fs.read : fs.write;
237
+ if (!allowList) return true;
238
+ return allowList.some((pattern) => matchGlob(pattern, filePath));
239
+ }
240
+ __name(isPathAllowed, "isPathAllowed");
241
+ function isCommandAllowed(sandbox, command) {
242
+ const cmds = sandbox.commands;
243
+ if (!cmds) return true;
244
+ if (cmds.deny?.some((prefix) => command.startsWith(prefix))) return false;
245
+ if (!cmds.allow) return true;
246
+ return cmds.allow.some((prefix) => command.startsWith(prefix));
247
+ }
248
+ __name(isCommandAllowed, "isCommandAllowed");
249
+ function matchGlob(pattern, path) {
250
+ const regex = pattern.replace(/\./g, "\\.").replace(/\*\*/g, "{{GLOBSTAR}}").replace(/\*/g, "[^/]*").replace(/\{\{GLOBSTAR\}\}/g, ".*");
251
+ return new RegExp(`^${regex}$`).test(path);
252
+ }
253
+ __name(matchGlob, "matchGlob");
254
+
255
+ // src/decorators/edit-format.ts
256
+ import { createDecorator as createDecorator2 } from "@theokit/http-decorators";
257
+ var EditFormat = createDecorator2();
258
+
259
+ // src/decorators/project-context.ts
260
+ var PROJECT_CONTEXT_CONFIG = /* @__PURE__ */ Symbol.for("theokit:agents:project-context");
261
+ function ProjectContext(options = {}) {
262
+ return (target) => {
263
+ setMeta(PROJECT_CONTEXT_CONFIG, target, {
264
+ rootMarkers: [
265
+ "package.json",
266
+ "tsconfig.json",
267
+ "go.mod",
268
+ "Cargo.toml",
269
+ "pyproject.toml"
270
+ ],
271
+ indexStrategy: "regex",
272
+ maxFilesInContext: 20,
273
+ relevanceStrategy: "git-history",
274
+ ignorePatterns: [
275
+ "node_modules",
276
+ "dist",
277
+ "build",
278
+ ".git",
279
+ "coverage",
280
+ "__pycache__"
281
+ ],
282
+ ...options
283
+ });
284
+ };
285
+ }
286
+ __name(ProjectContext, "ProjectContext");
287
+ function getProjectContextConfig(target) {
288
+ return getMeta(PROJECT_CONTEXT_CONFIG, target);
289
+ }
290
+ __name(getProjectContextConfig, "getProjectContextConfig");
291
+
292
+ // src/decorators/apply-decorators.ts
293
+ function applyDecorators(...decorators) {
294
+ return (target, propertyKey, descriptor) => {
295
+ for (const decorator of decorators) {
296
+ if (propertyKey !== void 0 && descriptor !== void 0) {
297
+ ;
298
+ decorator(target, propertyKey, descriptor);
299
+ } else {
300
+ ;
301
+ decorator(target);
302
+ }
303
+ }
304
+ };
305
+ }
306
+ __name(applyDecorators, "applyDecorators");
307
+
308
+ export {
309
+ MainLoop,
310
+ getMainLoop,
311
+ Toolbox,
312
+ Tool,
313
+ getToolboxConfig,
314
+ getToolMethods,
315
+ getToolConfig,
316
+ Hook,
317
+ getHooks,
318
+ getHooksByPoint,
319
+ Conversation,
320
+ getConversationConfig,
321
+ HumanInTheLoop,
322
+ getHumanInTheLoopConfig,
323
+ ContextWindow,
324
+ getContextWindowConfig,
325
+ Model,
326
+ Artifact,
327
+ getArtifactConfig,
328
+ Checkpoint,
329
+ getCheckpointConfig,
330
+ Observable,
331
+ getObservables,
332
+ getObservableByChannel,
333
+ Sandbox,
334
+ getSandboxConfig,
335
+ isPathAllowed,
336
+ isCommandAllowed,
337
+ EditFormat,
338
+ ProjectContext,
339
+ getProjectContextConfig,
340
+ applyDecorators
341
+ };
342
+ //# sourceMappingURL=chunk-XUACDN32.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/decorators/main-loop.ts","../src/decorators/tool.ts","../src/decorators/hook.ts","../src/decorators/conversation.ts","../src/decorators/human-in-the-loop.ts","../src/decorators/context-window.ts","../src/decorators/model.ts","../src/decorators/artifact.ts","../src/decorators/checkpoint.ts","../src/decorators/observable.ts","../src/decorators/sandbox.ts","../src/decorators/edit-format.ts","../src/decorators/project-context.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\nexport function Toolbox(options: ToolboxOptions = {}): ClassDecorator {\n return (target: Function) => {\n setMeta(TOOLBOX_CONFIG, target, options)\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(target: Function, propertyKey: string | symbol): 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 * @HumanInTheLoop() — pause agent execution to request human approval.\n *\n * When applied to a @Tool method, the agent pauses before executing the tool\n * and emits an 'approval_required' SSE event. The client must POST to the\n * callback URL to approve or deny. If denied or timed out, the tool is skipped.\n *\n * @example\n * ```ts\n * @Toolbox({ namespace: 'ops' })\n * class OpsTools {\n * @Tool({ name: 'deploy', description: 'Deploy to prod', input: z.object({...}) })\n * @HumanInTheLoop({\n * question: 'Confirm deployment to production?',\n * timeout: 300_000,\n * onTimeout: 'abort',\n * })\n * async deploy(input: {...}) { ... }\n * }\n * ```\n *\n * SSE event emitted:\n * ```json\n * { \"type\": \"approval_required\", \"toolName\": \"ops.deploy\", \"question\": \"...\", \"callbackUrl\": \"/agents/x/approve/call-123\" }\n * ```\n */\nimport { setMeta, getMeta } from '../metadata/index.js'\n\nconst HITL_CONFIG = Symbol.for('theokit:agents:human-in-the-loop')\n\nexport type TimeoutAction = 'abort' | 'proceed' | 'retry'\n\nexport interface HumanInTheLoopOptions {\n /** Question shown to the human approver. */\n question: string\n /** Timeout in milliseconds before onTimeout fires (default: 300_000 = 5 min). */\n timeout?: number\n /** Action when timeout expires (default: 'abort'). */\n onTimeout?: TimeoutAction\n /** Show the tool input to the approver (default: true). */\n showInput?: boolean\n}\n\nexport function HumanInTheLoop(options: HumanInTheLoopOptions): MethodDecorator {\n return (target: object, propertyKey: string | symbol) => {\n const actualTarget = target.constructor\n setMeta(HITL_CONFIG, actualTarget, {\n timeout: 300_000,\n onTimeout: 'abort',\n showInput: true,\n ...options,\n }, propertyKey)\n }\n}\n\nexport function getHumanInTheLoopConfig(\n target: Function,\n propertyKey: string | symbol,\n): HumanInTheLoopOptions | undefined {\n return getMeta<HumanInTheLoopOptions>(HITL_CONFIG, target, propertyKey)\n}\n","/**\n * @ContextWindow() — declares context window management strategy.\n *\n * Controls how the agent handles context when conversation history grows\n * beyond the LLM's context window. Mirrors Claude Code's PreCompact behavior.\n *\n * @example\n * ```ts\n * @Agent({ name: 'research', route: '/research' })\n * @ContextWindow({\n * maxTokens: 100_000,\n * compactionStrategy: 'summarize-oldest',\n * preserveSystemPrompt: true,\n * preserveLastN: 10,\n * })\n * class ResearchAgent { ... }\n * ```\n */\nimport { setMeta, getMeta } from '../metadata/index.js'\n\nconst CONTEXT_WINDOW_CONFIG = Symbol.for('theokit:agents:context-window')\n\nexport type ContextCompactionStrategy =\n | 'truncate-oldest' // Drop oldest messages beyond limit\n | 'summarize-oldest' // LLM-summarize oldest messages into a single message\n | 'sliding-window' // Keep last N messages only\n | 'priority-based' // Keep tool results + recent; summarize reasoning\n\nexport interface ContextWindowOptions {\n /** Maximum tokens before compaction triggers. */\n maxTokens?: number\n /** How to compact when maxTokens is exceeded. */\n compactionStrategy?: ContextCompactionStrategy\n /** Always preserve the system prompt during compaction (default: true). */\n preserveSystemPrompt?: boolean\n /** Number of recent messages to always keep intact (default: 10). */\n preserveLastN?: number\n /** Keep all tool results even during compaction (default: true). */\n preserveToolResults?: boolean\n}\n\nexport function ContextWindow(options: ContextWindowOptions = {}): ClassDecorator {\n return (target: Function) => {\n setMeta(CONTEXT_WINDOW_CONFIG, target, {\n maxTokens: 100_000,\n compactionStrategy: 'summarize-oldest',\n preserveSystemPrompt: true,\n preserveLastN: 10,\n preserveToolResults: true,\n ...options,\n })\n }\n}\n\nexport function getContextWindowConfig(target: Function): ContextWindowOptions | undefined {\n return getMeta<ContextWindowOptions>(CONTEXT_WINDOW_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-decorators'\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 * @Checkpoint() — enables resumable agent execution from the last successful step.\n *\n * Long-running agents (research, code review, multi-step workflows) can fail\n * partway through. Without checkpointing, users restart from step 1 — wasting\n * tokens, time, and cost.\n *\n * Inspired by tRPC's tracked() + lastEventId pattern and Dapr's actor state\n * checkpointing. The agent persists a recovery point after each successful\n * tool call or iteration, and can resume from that point on retry.\n *\n * @example\n * ```ts\n * @Agent({ name: 'research', route: '/research' })\n * @Checkpoint({\n * storage: 'drizzle',\n * strategy: 'after-tool-call',\n * maxCheckpoints: 20,\n * ttl: 3_600_000, // 1h\n * })\n * class ResearchAgent {\n * @MainLoop({ strategy: 'plan-act-reflect', maxIterations: 15 })\n * async run() {}\n * }\n *\n * // Resume from checkpoint:\n * // POST /agents/research/chat { resumeToken: 'chk_abc123' }\n * ```\n */\nimport { setMeta, getMeta } from '../metadata/index.js'\n\nconst CHECKPOINT_CONFIG = Symbol.for('theokit:agents:checkpoint')\n\nexport type CheckpointStrategy =\n | 'after-tool-call' // checkpoint after every successful tool execution\n | 'after-iteration' // checkpoint after every loop iteration\n | 'manual' // only checkpoint when explicitly called via ctx.checkpoint()\n\nexport type CheckpointStorage = 'memory' | 'filesystem' | 'drizzle' | 'redis'\n\nexport interface CheckpointOptions {\n /** Where to persist checkpoints. */\n storage?: CheckpointStorage\n /** When to auto-checkpoint (default: 'after-tool-call'). */\n strategy?: CheckpointStrategy\n /** Maximum checkpoints to retain per run (rolling window). */\n maxCheckpoints?: number\n /** Time-to-live in ms before checkpoints expire (default: 3_600_000 = 1h). */\n ttl?: number\n}\n\n/** Serializable checkpoint state. */\nexport interface CheckpointState {\n id: string\n runId: string\n agentName: string\n step: number\n messages: unknown[]\n toolResults: unknown[]\n createdAt: number\n resumeToken: string\n}\n\nexport function Checkpoint(options: CheckpointOptions = {}): ClassDecorator {\n return (target: Function) => {\n setMeta(CHECKPOINT_CONFIG, target, {\n storage: 'memory',\n strategy: 'after-tool-call',\n maxCheckpoints: 10,\n ttl: 3_600_000,\n ...options,\n })\n }\n}\n\nexport function getCheckpointConfig(target: Function): CheckpointOptions | undefined {\n return getMeta<CheckpointOptions>(CHECKPOINT_CONFIG, target)\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 { 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 */\nexport function isPathAllowed(\n sandbox: SandboxOptions,\n filePath: string,\n operation: 'read' | 'write',\n): boolean {\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, filePath))) 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, filePath))\n}\n\n/**\n * Check if a command is allowed to execute.\n * Deny patterns always win over allow patterns.\n */\nexport function isCommandAllowed(sandbox: SandboxOptions, command: string): boolean {\n const cmds = sandbox.commands\n if (!cmds) return true\n\n // Deny always wins\n if (cmds.deny?.some((prefix) => command.startsWith(prefix))) return false\n\n if (!cmds.allow) return true // no explicit allow = allow all (minus deny)\n\n return cmds.allow.some((prefix) => command.startsWith(prefix))\n}\n\n/** Simple glob matcher (supports * and ** patterns). */\nfunction matchGlob(pattern: string, path: string): boolean {\n const regex = pattern\n .replace(/\\./g, '\\\\.')\n .replace(/\\*\\*/g, '{{GLOBSTAR}}')\n .replace(/\\*/g, '[^/]*')\n .replace(/\\{\\{GLOBSTAR\\}\\}/g, '.*')\n return new RegExp(`^${regex}$`).test(path)\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-decorators'\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 * @ProjectContext() — declares how the agent understands the codebase.\n *\n * A code assistant needs to know: what's the project root, which files\n * are relevant, how to parse code structure, what to ignore. This\n * metadata feeds the context window management and file discovery.\n *\n * @example\n * ```ts\n * @Agent({ name: 'coder', route: '/agents/coder' })\n * @ProjectContext({\n * rootMarkers: ['package.json', 'tsconfig.json'],\n * indexStrategy: 'tree-sitter',\n * maxFilesInContext: 20,\n * relevanceStrategy: 'git-history',\n * ignorePatterns: ['node_modules', 'dist', '.git'],\n * })\n * class CoderAgent { ... }\n * ```\n */\nimport { setMeta, getMeta } from '../metadata/index.js'\n\nconst PROJECT_CONTEXT_CONFIG = Symbol.for('theokit:agents:project-context')\n\nexport type IndexStrategy =\n | 'tree-sitter' // Parse AST for structural understanding\n | 'regex' // Simple regex-based symbol extraction\n | 'none' // No indexing — rely on grep/glob only\n\nexport type RelevanceStrategy =\n | 'git-history' // Prioritize recently-edited files\n | 'import-graph' // Follow import chains from entry points\n | 'semantic' // Embedding-based similarity search\n | 'manual' // Only files explicitly provided\n\nexport interface ProjectContextOptions {\n /** Files that mark the project root (searched upward from cwd). */\n rootMarkers?: string[]\n /** How to index the codebase for structural understanding. */\n indexStrategy?: IndexStrategy\n /** Maximum files to include in context per request. */\n maxFilesInContext?: number\n /** How to rank file relevance when selecting context. */\n relevanceStrategy?: RelevanceStrategy\n /** Glob patterns to exclude from indexing and context. */\n ignorePatterns?: string[]\n /** File extensions to include in indexing (default: all text files). */\n includeExtensions?: string[]\n}\n\nexport function ProjectContext(options: ProjectContextOptions = {}): ClassDecorator {\n return (target: Function) => {\n setMeta(PROJECT_CONTEXT_CONFIG, target, {\n rootMarkers: ['package.json', 'tsconfig.json', 'go.mod', 'Cargo.toml', 'pyproject.toml'],\n indexStrategy: 'regex',\n maxFilesInContext: 20,\n relevanceStrategy: 'git-history',\n ignorePatterns: ['node_modules', 'dist', 'build', '.git', 'coverage', '__pycache__'],\n ...options,\n })\n }\n}\n\nexport function getProjectContextConfig(target: Function): ProjectContextOptions | undefined {\n return getMeta<ProjectContextOptions>(PROJECT_CONTEXT_CONFIG, target)\n}\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,OAAO;AAC5B,UAAMG,WAAWC,QAAsBC,iBAAiBH,YAAAA;AACxD,QAAIC,UAAU;AACZG,cAAQC,KACN,qBAAqBL,aAAaM,IAAI,sCAAsCC,OAAON,SAASF,WAAW,CAAA,wBAAyBQ,OAAOR,WAAAA,CAAAA,IAAgB;IAE3J;AACA,UAAMS,OAAqB;MACzBT;MACAU,UAAUZ,QAAQY,YAAY;MAC9BC,eAAeb,QAAQa;MACvBC,WAAWd,QAAQc;IACrB;AACAC,YAAQT,iBAAiBH,cAAcQ,IAAAA;EACzC;AACF;AAjBgBZ;AAmBT,SA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U;QAAc;;MACvEC,eAAe;MACfC,mBAAmB;MACnBC,mBAAmB;MACnBC,gBAAgB;QAAC;QAAgB;QAAQ;QAAS;QAAQ;QAAY;;MACtE,GAAGP;IACL,CAAA;EACF;AACF;AAXgBD;AAaT,SAASS,wBAAwBP,QAAgB;AACtD,SAAOQ,QAA+Bb,wBAAwBK,MAAAA;AAChE;AAFgBO;;;AC/BT,SAASE,mBACXC,YAA0B;AAE7B,SAAO,CACLC,QACAC,aACAC,eAAAA;AAEA,eAAWC,aAAaJ,YAAY;AAClC,UAAIE,gBAAgBG,UAAaF,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","Toolbox","options","target","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","HITL_CONFIG","Symbol","for","HumanInTheLoop","options","target","propertyKey","actualTarget","setMeta","timeout","onTimeout","showInput","getHumanInTheLoopConfig","getMeta","CONTEXT_WINDOW_CONFIG","Symbol","for","ContextWindow","options","target","setMeta","maxTokens","compactionStrategy","preserveSystemPrompt","preserveLastN","preserveToolResults","getContextWindowConfig","getMeta","createDecorator","Model","ARTIFACT_CONFIG","Symbol","for","Artifact","options","target","propertyKey","actualTarget","setMeta","streamable","maxSize","getArtifactConfig","getMeta","CHECKPOINT_CONFIG","Symbol","for","Checkpoint","options","target","setMeta","storage","strategy","maxCheckpoints","ttl","getCheckpointConfig","getMeta","OBSERVABLE_CONFIG","Symbol","for","Observable","channel","target","propertyKey","actualTarget","existing","getMeta","setMeta","getObservables","getObservableByChannel","find","o","SANDBOX_CONFIG","Symbol","for","Sandbox","options","target","setMeta","network","commandTimeout","getSandboxConfig","getMeta","isPathAllowed","sandbox","filePath","operation","fs","filesystem","deny","some","pattern","matchGlob","allowList","read","write","isCommandAllowed","command","cmds","commands","prefix","startsWith","allow","path","regex","replace","RegExp","test","createDecorator","EditFormat","PROJECT_CONTEXT_CONFIG","Symbol","for","ProjectContext","options","target","setMeta","rootMarkers","indexStrategy","maxFilesInContext","relevanceStrategy","ignorePatterns","getProjectContextConfig","getMeta","applyDecorators","decorators","target","propertyKey","descriptor","decorator","undefined"]}