@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.
- package/LICENSE +201 -0
- package/dist/{bridge-entry-BydskfrI.d.ts → bridge-entry-DG3jbXjs.d.ts} +13 -8
- package/dist/bridge.d.ts +2 -2
- package/dist/bridge.js +2 -4
- package/dist/{chunk-MD35WBR4.js → chunk-B24BAVE6.js} +164 -164
- package/dist/chunk-B24BAVE6.js.map +1 -0
- package/dist/{chunk-TXEY3IUO.js → chunk-IAE4FWBV.js} +28 -3
- package/dist/chunk-IAE4FWBV.js.map +1 -0
- package/dist/decorators.d.ts +2 -2
- package/dist/decorators.js +237 -29
- package/dist/decorators.js.map +1 -1
- package/dist/index.d.ts +4 -5
- package/dist/index.js +2 -121
- package/dist/index.js.map +1 -1
- package/dist/{types-S7k_lt1_.d.ts → types-DVA4LQsA.d.ts} +1 -1
- package/package.json +10 -14
- package/dist/chunk-GEV2EQW2.js +0 -265
- package/dist/chunk-GEV2EQW2.js.map +0 -1
- package/dist/chunk-MD35WBR4.js.map +0 -1
- package/dist/chunk-TXEY3IUO.js.map +0 -1
|
@@ -12,44 +12,60 @@ var TOOLBOX_CONFIG = /* @__PURE__ */ Symbol.for("theokit:agents:toolbox");
|
|
|
12
12
|
var TOOL_CONFIG = /* @__PURE__ */ Symbol.for("theokit:agents:tool");
|
|
13
13
|
var TOOL_METHODS = /* @__PURE__ */ Symbol.for("theokit:agents:tool-methods");
|
|
14
14
|
|
|
15
|
-
// src/decorators/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const kebab = stripped.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/([A-Z])([A-Z][a-z])/g, "$1-$2").toLowerCase();
|
|
19
|
-
return {
|
|
20
|
-
name: kebab,
|
|
21
|
-
route: `/api/agents/${kebab}`
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
__name(inferAgentMeta, "inferAgentMeta");
|
|
25
|
-
function Agent(options) {
|
|
15
|
+
// src/decorators/checkpoint.ts
|
|
16
|
+
var CHECKPOINT_CONFIG = /* @__PURE__ */ Symbol.for("theokit:agents:checkpoint");
|
|
17
|
+
function Checkpoint(options = {}) {
|
|
26
18
|
return (target) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
19
|
+
setMeta(CHECKPOINT_CONFIG, target, {
|
|
20
|
+
storage: "memory",
|
|
21
|
+
strategy: "after-tool-call",
|
|
22
|
+
maxCheckpoints: 10,
|
|
23
|
+
ttl: 36e5,
|
|
32
24
|
...options
|
|
33
25
|
});
|
|
34
26
|
};
|
|
35
27
|
}
|
|
36
|
-
__name(
|
|
37
|
-
function
|
|
38
|
-
return getMeta(
|
|
28
|
+
__name(Checkpoint, "Checkpoint");
|
|
29
|
+
function getCheckpointConfig(target) {
|
|
30
|
+
return getMeta(CHECKPOINT_CONFIG, target);
|
|
39
31
|
}
|
|
40
|
-
__name(
|
|
32
|
+
__name(getCheckpointConfig, "getCheckpointConfig");
|
|
41
33
|
|
|
42
|
-
// src/decorators/
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
34
|
+
// src/decorators/compaction.ts
|
|
35
|
+
var COMPACTION_CONFIG = /* @__PURE__ */ Symbol.for("theokit:agents:compaction");
|
|
36
|
+
function Compaction(name, options = {}) {
|
|
37
|
+
return (target) => {
|
|
38
|
+
setMeta(COMPACTION_CONFIG, target, {
|
|
39
|
+
name,
|
|
40
|
+
keepTokens: options.keepTokens
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
__name(Compaction, "Compaction");
|
|
45
|
+
function getCompactionConfig(target) {
|
|
46
|
+
return getMeta(COMPACTION_CONFIG, target);
|
|
47
|
+
}
|
|
48
|
+
__name(getCompactionConfig, "getCompactionConfig");
|
|
48
49
|
|
|
49
|
-
// src/decorators/
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
// src/decorators/context-window.ts
|
|
51
|
+
var CONTEXT_WINDOW_CONFIG = /* @__PURE__ */ Symbol.for("theokit:agents:context-window");
|
|
52
|
+
function ContextWindow(options = {}) {
|
|
53
|
+
return (target) => {
|
|
54
|
+
setMeta(CONTEXT_WINDOW_CONFIG, target, {
|
|
55
|
+
maxTokens: 1e5,
|
|
56
|
+
compactionStrategy: "summarize-oldest",
|
|
57
|
+
preserveSystemPrompt: true,
|
|
58
|
+
preserveLastN: 10,
|
|
59
|
+
preserveToolResults: true,
|
|
60
|
+
...options
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
__name(ContextWindow, "ContextWindow");
|
|
65
|
+
function getContextWindowConfig(target) {
|
|
66
|
+
return getMeta(CONTEXT_WINDOW_CONFIG, target);
|
|
67
|
+
}
|
|
68
|
+
__name(getContextWindowConfig, "getContextWindowConfig");
|
|
53
69
|
|
|
54
70
|
// src/decorators/gateway.ts
|
|
55
71
|
var GATEWAY_CONFIG = /* @__PURE__ */ Symbol.for("theokit:agents:gateway");
|
|
@@ -79,61 +95,6 @@ function resolveSessionId(strategy, platform, sender, channel) {
|
|
|
79
95
|
}
|
|
80
96
|
__name(resolveSessionId, "resolveSessionId");
|
|
81
97
|
|
|
82
|
-
// src/decorators/sub-agents.ts
|
|
83
|
-
var SUB_AGENTS = /* @__PURE__ */ Symbol.for("theokit:agents:sub-agents");
|
|
84
|
-
function SubAgents(agentClasses) {
|
|
85
|
-
return (target) => {
|
|
86
|
-
for (const cls of agentClasses) {
|
|
87
|
-
const config = getAgentConfig(cls);
|
|
88
|
-
if (!config) {
|
|
89
|
-
throw new Error(`[@theokit/agents] @SubAgents on ${target.name}: class ${cls.name} is missing @Agent() decorator.`);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
setMeta(SUB_AGENTS, target, agentClasses);
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
__name(SubAgents, "SubAgents");
|
|
96
|
-
function getSubAgents(target) {
|
|
97
|
-
return getMeta(SUB_AGENTS, target) ?? [];
|
|
98
|
-
}
|
|
99
|
-
__name(getSubAgents, "getSubAgents");
|
|
100
|
-
|
|
101
|
-
// src/decorators/memory.ts
|
|
102
|
-
var MEMORY_CONFIG = /* @__PURE__ */ Symbol.for("theokit:agents:memory");
|
|
103
|
-
function Memory(options = {}) {
|
|
104
|
-
return (target) => {
|
|
105
|
-
setMeta(MEMORY_CONFIG, target, {
|
|
106
|
-
provider: "built-in",
|
|
107
|
-
embeddings: false,
|
|
108
|
-
fts: false,
|
|
109
|
-
scope: "per-user",
|
|
110
|
-
...options
|
|
111
|
-
});
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
__name(Memory, "Memory");
|
|
115
|
-
function getMemoryConfig(target) {
|
|
116
|
-
return getMeta(MEMORY_CONFIG, target);
|
|
117
|
-
}
|
|
118
|
-
__name(getMemoryConfig, "getMemoryConfig");
|
|
119
|
-
|
|
120
|
-
// src/decorators/skills.ts
|
|
121
|
-
var SKILLS_CONFIG = /* @__PURE__ */ Symbol.for("theokit:agents:skills");
|
|
122
|
-
function Skills(namesOrOptions) {
|
|
123
|
-
return (target) => {
|
|
124
|
-
const options = Array.isArray(namesOrOptions) ? {
|
|
125
|
-
include: namesOrOptions,
|
|
126
|
-
autoDiscover: false
|
|
127
|
-
} : namesOrOptions;
|
|
128
|
-
setMeta(SKILLS_CONFIG, target, options);
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
__name(Skills, "Skills");
|
|
132
|
-
function getSkillsConfig(target) {
|
|
133
|
-
return getMeta(SKILLS_CONFIG, target);
|
|
134
|
-
}
|
|
135
|
-
__name(getSkillsConfig, "getSkillsConfig");
|
|
136
|
-
|
|
137
98
|
// src/decorators/guardrails.ts
|
|
138
99
|
var GUARDRAILS_CONFIG = /* @__PURE__ */ Symbol.for("theokit:agents:guardrails");
|
|
139
100
|
function Guardrails(guardrails) {
|
|
@@ -147,19 +108,6 @@ function getGuardrailsConfig(target) {
|
|
|
147
108
|
}
|
|
148
109
|
__name(getGuardrailsConfig, "getGuardrailsConfig");
|
|
149
110
|
|
|
150
|
-
// src/decorators/mcp.ts
|
|
151
|
-
var MCP_CONFIG = /* @__PURE__ */ Symbol.for("theokit:agents:mcp");
|
|
152
|
-
function MCP(servers) {
|
|
153
|
-
return (target) => {
|
|
154
|
-
setMeta(MCP_CONFIG, target, servers);
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
__name(MCP, "MCP");
|
|
158
|
-
function getMcpConfig(target) {
|
|
159
|
-
return getMeta(MCP_CONFIG, target);
|
|
160
|
-
}
|
|
161
|
-
__name(getMcpConfig, "getMcpConfig");
|
|
162
|
-
|
|
163
111
|
// src/decorators/human-in-the-loop.ts
|
|
164
112
|
var HITL_CONFIG = /* @__PURE__ */ Symbol.for("theokit:agents:human-in-the-loop");
|
|
165
113
|
function HumanInTheLoop(options) {
|
|
@@ -179,60 +127,49 @@ function getHumanInTheLoopConfig(target, propertyKey) {
|
|
|
179
127
|
}
|
|
180
128
|
__name(getHumanInTheLoopConfig, "getHumanInTheLoopConfig");
|
|
181
129
|
|
|
182
|
-
// src/decorators/
|
|
183
|
-
var
|
|
184
|
-
function
|
|
185
|
-
return (target) => {
|
|
186
|
-
setMeta(CONTEXT_WINDOW_CONFIG, target, {
|
|
187
|
-
maxTokens: 1e5,
|
|
188
|
-
compactionStrategy: "summarize-oldest",
|
|
189
|
-
preserveSystemPrompt: true,
|
|
190
|
-
preserveLastN: 10,
|
|
191
|
-
preserveToolResults: true,
|
|
192
|
-
...options
|
|
193
|
-
});
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
__name(ContextWindow, "ContextWindow");
|
|
197
|
-
function getContextWindowConfig(target) {
|
|
198
|
-
return getMeta(CONTEXT_WINDOW_CONFIG, target);
|
|
199
|
-
}
|
|
200
|
-
__name(getContextWindowConfig, "getContextWindowConfig");
|
|
201
|
-
|
|
202
|
-
// src/decorators/compaction.ts
|
|
203
|
-
var COMPACTION_CONFIG = /* @__PURE__ */ Symbol.for("theokit:agents:compaction");
|
|
204
|
-
function Compaction(name, options = {}) {
|
|
130
|
+
// src/decorators/mcp.ts
|
|
131
|
+
var MCP_CONFIG = /* @__PURE__ */ Symbol.for("theokit:agents:mcp");
|
|
132
|
+
function MCP(servers) {
|
|
205
133
|
return (target) => {
|
|
206
|
-
setMeta(
|
|
207
|
-
name,
|
|
208
|
-
keepTokens: options.keepTokens
|
|
209
|
-
});
|
|
134
|
+
setMeta(MCP_CONFIG, target, servers);
|
|
210
135
|
};
|
|
211
136
|
}
|
|
212
|
-
__name(
|
|
213
|
-
function
|
|
214
|
-
return getMeta(
|
|
137
|
+
__name(MCP, "MCP");
|
|
138
|
+
function getMcpConfig(target) {
|
|
139
|
+
return getMeta(MCP_CONFIG, target);
|
|
215
140
|
}
|
|
216
|
-
__name(
|
|
141
|
+
__name(getMcpConfig, "getMcpConfig");
|
|
217
142
|
|
|
218
|
-
// src/decorators/
|
|
219
|
-
var
|
|
220
|
-
function
|
|
143
|
+
// src/decorators/memory.ts
|
|
144
|
+
var MEMORY_CONFIG = /* @__PURE__ */ Symbol.for("theokit:agents:memory");
|
|
145
|
+
function Memory(options = {}) {
|
|
221
146
|
return (target) => {
|
|
222
|
-
setMeta(
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
147
|
+
setMeta(MEMORY_CONFIG, target, {
|
|
148
|
+
provider: "built-in",
|
|
149
|
+
embeddings: false,
|
|
150
|
+
fts: false,
|
|
151
|
+
scope: "per-user",
|
|
227
152
|
...options
|
|
228
153
|
});
|
|
229
154
|
};
|
|
230
155
|
}
|
|
231
|
-
__name(
|
|
232
|
-
function
|
|
233
|
-
return getMeta(
|
|
156
|
+
__name(Memory, "Memory");
|
|
157
|
+
function getMemoryConfig(target) {
|
|
158
|
+
return getMeta(MEMORY_CONFIG, target);
|
|
234
159
|
}
|
|
235
|
-
__name(
|
|
160
|
+
__name(getMemoryConfig, "getMemoryConfig");
|
|
161
|
+
|
|
162
|
+
// src/decorators/observability.ts
|
|
163
|
+
import { createDecorator } from "@theokit/http";
|
|
164
|
+
var Trace = createDecorator();
|
|
165
|
+
var Audit = createDecorator();
|
|
166
|
+
|
|
167
|
+
// src/decorators/policies.ts
|
|
168
|
+
import { createDecorator as createDecorator2 } from "@theokit/http";
|
|
169
|
+
var RequiresApproval = createDecorator2();
|
|
170
|
+
var RequiresCapability = createDecorator2();
|
|
171
|
+
var Budget = createDecorator2();
|
|
172
|
+
var Policy = createDecorator2();
|
|
236
173
|
|
|
237
174
|
// src/decorators/project-context.ts
|
|
238
175
|
var PROJECT_CONTEXT_CONFIG = /* @__PURE__ */ Symbol.for("theokit:agents:project-context");
|
|
@@ -267,6 +204,69 @@ function getProjectContextConfig(target) {
|
|
|
267
204
|
}
|
|
268
205
|
__name(getProjectContextConfig, "getProjectContextConfig");
|
|
269
206
|
|
|
207
|
+
// src/decorators/skills.ts
|
|
208
|
+
var SKILLS_CONFIG = /* @__PURE__ */ Symbol.for("theokit:agents:skills");
|
|
209
|
+
function Skills(namesOrOptions) {
|
|
210
|
+
return (target) => {
|
|
211
|
+
const options = Array.isArray(namesOrOptions) ? {
|
|
212
|
+
include: namesOrOptions,
|
|
213
|
+
autoDiscover: false
|
|
214
|
+
} : namesOrOptions;
|
|
215
|
+
setMeta(SKILLS_CONFIG, target, options);
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
__name(Skills, "Skills");
|
|
219
|
+
function getSkillsConfig(target) {
|
|
220
|
+
return getMeta(SKILLS_CONFIG, target);
|
|
221
|
+
}
|
|
222
|
+
__name(getSkillsConfig, "getSkillsConfig");
|
|
223
|
+
|
|
224
|
+
// src/decorators/agent.ts
|
|
225
|
+
function inferAgentMeta(className) {
|
|
226
|
+
const stripped = className.replace(/Agent$/, "");
|
|
227
|
+
const kebab = stripped.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/([A-Z])([A-Z][a-z])/g, "$1-$2").toLowerCase();
|
|
228
|
+
return {
|
|
229
|
+
name: kebab,
|
|
230
|
+
route: `/api/agents/${kebab}`
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
__name(inferAgentMeta, "inferAgentMeta");
|
|
234
|
+
function Agent(options) {
|
|
235
|
+
return (target) => {
|
|
236
|
+
const inferred = inferAgentMeta(target.name);
|
|
237
|
+
setMeta(AGENT_CONFIG, target, {
|
|
238
|
+
stream: true,
|
|
239
|
+
name: inferred.name,
|
|
240
|
+
route: inferred.route,
|
|
241
|
+
...options
|
|
242
|
+
});
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
__name(Agent, "Agent");
|
|
246
|
+
function getAgentConfig(target) {
|
|
247
|
+
return getMeta(AGENT_CONFIG, target);
|
|
248
|
+
}
|
|
249
|
+
__name(getAgentConfig, "getAgentConfig");
|
|
250
|
+
|
|
251
|
+
// src/decorators/sub-agents.ts
|
|
252
|
+
var SUB_AGENTS = /* @__PURE__ */ Symbol.for("theokit:agents:sub-agents");
|
|
253
|
+
function SubAgents(agentClasses) {
|
|
254
|
+
return (target) => {
|
|
255
|
+
for (const cls of agentClasses) {
|
|
256
|
+
const config = getAgentConfig(cls);
|
|
257
|
+
if (!config) {
|
|
258
|
+
throw new Error(`[@theokit/agents] @SubAgents on ${target.name}: class ${cls.name} is missing @Agent() decorator.`);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
setMeta(SUB_AGENTS, target, agentClasses);
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
__name(SubAgents, "SubAgents");
|
|
265
|
+
function getSubAgents(target) {
|
|
266
|
+
return getMeta(SUB_AGENTS, target) ?? [];
|
|
267
|
+
}
|
|
268
|
+
__name(getSubAgents, "getSubAgents");
|
|
269
|
+
|
|
270
270
|
// src/decorators/mixin.ts
|
|
271
271
|
var MIXIN_CLASSES = /* @__PURE__ */ Symbol.for("theokit:agents:mixins");
|
|
272
272
|
function Mixin(...mixinClasses) {
|
|
@@ -292,38 +292,38 @@ export {
|
|
|
292
292
|
TOOL_METHODS,
|
|
293
293
|
setMeta,
|
|
294
294
|
getMeta,
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
Trace,
|
|
302
|
-
Audit,
|
|
295
|
+
Checkpoint,
|
|
296
|
+
getCheckpointConfig,
|
|
297
|
+
Compaction,
|
|
298
|
+
getCompactionConfig,
|
|
299
|
+
ContextWindow,
|
|
300
|
+
getContextWindowConfig,
|
|
303
301
|
Gateway,
|
|
304
302
|
getGatewayConfig,
|
|
305
303
|
resolveSessionId,
|
|
306
|
-
SubAgents,
|
|
307
|
-
getSubAgents,
|
|
308
|
-
Memory,
|
|
309
|
-
getMemoryConfig,
|
|
310
|
-
Skills,
|
|
311
|
-
getSkillsConfig,
|
|
312
304
|
Guardrails,
|
|
313
305
|
getGuardrailsConfig,
|
|
314
|
-
MCP,
|
|
315
|
-
getMcpConfig,
|
|
316
306
|
HumanInTheLoop,
|
|
317
307
|
getHumanInTheLoopConfig,
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
308
|
+
MCP,
|
|
309
|
+
getMcpConfig,
|
|
310
|
+
Memory,
|
|
311
|
+
getMemoryConfig,
|
|
312
|
+
Trace,
|
|
313
|
+
Audit,
|
|
314
|
+
RequiresApproval,
|
|
315
|
+
RequiresCapability,
|
|
316
|
+
Budget,
|
|
317
|
+
Policy,
|
|
324
318
|
ProjectContext,
|
|
325
319
|
getProjectContextConfig,
|
|
320
|
+
Skills,
|
|
321
|
+
getSkillsConfig,
|
|
322
|
+
Agent,
|
|
323
|
+
getAgentConfig,
|
|
324
|
+
SubAgents,
|
|
325
|
+
getSubAgents,
|
|
326
326
|
Mixin,
|
|
327
327
|
getMixins
|
|
328
328
|
};
|
|
329
|
-
//# sourceMappingURL=chunk-
|
|
329
|
+
//# sourceMappingURL=chunk-B24BAVE6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/metadata/index.ts","../src/metadata/keys.ts","../src/decorators/checkpoint.ts","../src/decorators/compaction.ts","../src/decorators/context-window.ts","../src/decorators/gateway.ts","../src/decorators/guardrails.ts","../src/decorators/human-in-the-loop.ts","../src/decorators/mcp.ts","../src/decorators/memory.ts","../src/decorators/observability.ts","../src/decorators/policies.ts","../src/decorators/project-context.ts","../src/decorators/skills.ts","../src/decorators/agent.ts","../src/decorators/sub-agents.ts","../src/decorators/mixin.ts"],"sourcesContent":["// Re-export setMeta/getMeta from http-decorators (DRY — single metadata engine)\n// Relative path for workspace-local usage; vitest resolves via alias\nexport { setMeta, getMeta } from '@theokit/http'\n\nexport * from './keys.js'\n","/** Symbol.for metadata keys for agent decorators — cross-module safe with SWC loader. */\n\nexport const AGENT_CONFIG = Symbol.for('theokit:agents:config')\nexport const AGENT_MAIN_LOOP = Symbol.for('theokit:agents:main-loop')\nexport const TOOLBOX_CONFIG = Symbol.for('theokit:agents:toolbox')\nexport const TOOL_CONFIG = Symbol.for('theokit:agents:tool')\nexport const TOOL_METHODS = Symbol.for('theokit:agents:tool-methods')\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: 'filesystem', // only 'filesystem' resumes across requests in the M2 harness (M4)\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: a follow-up POST /api/agents/research with the SAME sessionId replays the persisted\n * // history. NOTE (M4): only `storage: 'filesystem'` resumes across requests today — `memory`\n * // (the default below) is per-run; `drizzle`/`redis` are not shipped by the SDK. A non-filesystem\n * // @Checkpoint emits a THEO_AGENT_CHECKPOINT_STORAGE_METADATA_ONLY warning (honest enforcement).\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 * `@Compaction(name, opts)` — declares the agent's transcript-compaction strategy\n * (V4-F). Metadata-only: it records the choice; `AgentRunner.build()` resolves it\n * to a concrete {@link TranscriptCompactionStrategy} via `resolveCompactionStrategy`\n * (EC-5 — an invalid name/budget fails fast at build, not at decoration).\n *\n * Mirrors the `@ContextWindow` metadata pattern (`setMeta`/`getMeta` + a unique\n * Symbol). NOT auto-applied by the loop (ADR D1) — the resolved strategy is exposed\n * as `runner.compaction` for the app to call.\n *\n * @example\n * ```ts\n * @Agent({ model })\n * @Compaction('token-budget', { keepTokens: 8000 })\n * class CodeAgent {}\n * ```\n */\nimport { setMeta, getMeta } from '../metadata/index.js'\n\nconst COMPACTION_CONFIG = Symbol.for('theokit:agents:compaction')\n\n/** Stored `@Compaction` declaration (resolved + validated at `AgentRunner.build()`). */\nexport interface CompactionDecoratorConfig {\n /** Strategy name (e.g. `'token-budget'`). Validated at resolve time. */\n name: string\n /** Token budget for `'token-budget'`. Required at resolve time (EC-2). */\n keepTokens?: number\n}\n\nexport function Compaction(name: string, options: { keepTokens?: number } = {}): ClassDecorator {\n return (target: Function) => {\n setMeta(COMPACTION_CONFIG, target, { name, keepTokens: options.keepTokens })\n }\n}\n\nexport function getCompactionConfig(target: Function): CompactionDecoratorConfig | undefined {\n return getMeta<CompactionDecoratorConfig>(COMPACTION_CONFIG, target)\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 * @Gateway() — declares which platform adapters an agent supports.\n *\n * Stores gateway configuration metadata on the agent class.\n * The GatewayRunner reads this to auto-wire adapters without manual plumbing.\n *\n * @example\n * ```ts\n * @Agent({ name: 'support', route: '/api/agents/support' })\n * @Gateway({\n * platforms: ['telegram', 'discord', 'slack'],\n * sessionStrategy: 'per-user',\n * })\n * @UseGuards(AuthGuard)\n * class SupportAgent {\n * @MainLoop()\n * async run(ctx: AgentContext) { ... }\n * }\n * ```\n */\nimport { setMeta, getMeta } from '../metadata/index.js'\n\nconst GATEWAY_CONFIG = Symbol.for('theokit:agents:gateway')\n\nexport type PlatformName =\n | 'telegram'\n | 'discord'\n | 'slack'\n | 'whatsapp'\n | 'teams'\n | 'email'\n | 'sms'\n | 'mattermost'\n | 'line'\n | 'matrix'\n\nexport type SessionStrategy =\n | 'per-user' // telegram-dm-{userId}\n | 'per-channel' // telegram-grp-{channelId}\n | 'per-thread' // telegram-tpc-{channelId}-{topicId}\n\nexport interface GatewayOptions {\n /** Platform adapters this agent supports. */\n platforms: PlatformName[]\n /** How to resolve agentId from inbound events (default: 'per-user'). */\n sessionStrategy?: SessionStrategy\n /** Auto-start typing indicator while agent processes (default: true). */\n typing?: boolean\n}\n\nexport function Gateway(options: GatewayOptions): ClassDecorator {\n return (target: Function) => {\n setMeta(GATEWAY_CONFIG, target, { typing: true, sessionStrategy: 'per-user', ...options })\n }\n}\n\nexport function getGatewayConfig(target: Function): GatewayOptions | undefined {\n return getMeta<GatewayOptions>(GATEWAY_CONFIG, target)\n}\n\n/**\n * Resolve a stable agentId from a platform event based on the session strategy.\n *\n * Mirrors @theokit/gateway SessionRouter.defaultStrategy() but is configurable\n * via the @Gateway decorator.\n */\nexport function resolveSessionId(\n strategy: SessionStrategy,\n platform: string,\n sender: { id: string },\n channel: { id: string; type: 'dm' | 'group' | 'thread'; topicId?: string },\n): string {\n switch (strategy) {\n case 'per-user':\n return `${platform}-dm-${sender.id}`\n case 'per-channel':\n return `${platform}-grp-${channel.id}`\n case 'per-thread':\n return `${platform}-tpc-${channel.id}-${channel.topicId ?? 'main'}`\n }\n}\n","/**\n * `@Guardrails([...])` — M9 class-decorator surface for input/output guardrails.\n *\n * The functional `defineAgent({ guardrails: [...] })` path already applies guards at the framework\n * boundary (ADR-0040 § D2). This decorator gives the `@Agent` class path the SAME capability: the\n * declared guards compile into `compiled.guardrails` (via `walkAgentMetadata`), so `AgentRunner`\n * applies them identically. Metadata-only (like `@MCP`/`@Skills`) — it describes, the runner runs.\n *\n * @example\n * ```ts\n * @Agent({ name: 'support', route: '/api/agents/support' })\n * @Guardrails([promptInjectionDetector(), piiDetector({ redact: true })])\n * class SupportAgent {}\n * ```\n */\nimport type { Guardrail } from '../guardrails/index.js'\nimport { setMeta, getMeta } from '../metadata/index.js'\n\nconst GUARDRAILS_CONFIG = Symbol.for('theokit:agents:guardrails')\n\nexport function Guardrails(guardrails: readonly Guardrail[]): ClassDecorator {\n return (target: Function) => {\n setMeta(GUARDRAILS_CONFIG, target, guardrails)\n }\n}\n\nexport function getGuardrailsConfig(target: Function): readonly Guardrail[] | undefined {\n return getMeta<readonly Guardrail[]>(GUARDRAILS_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 * M20 — an optional JSON-schema descriptor of the custom payload the approver may attach (edited\n * args, a review note). Carried into the `approval_required` event + `GET /approvals` so the UI\n * knows what to collect. A plain JSON object, not a live Zod schema (keeps the wire serializable).\n */\n payloadSchema?: Record<string, unknown>\n}\n\nexport function HumanInTheLoop(options: HumanInTheLoopOptions): MethodDecorator {\n return (target: object, propertyKey: string | symbol) => {\n const actualTarget = target.constructor\n setMeta(\n HITL_CONFIG,\n actualTarget,\n {\n timeout: 300_000,\n onTimeout: 'abort',\n showInput: true,\n ...options,\n },\n propertyKey,\n )\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 * @MCP() — declares Model Context Protocol servers available to an agent.\n *\n * Compiles to SDK's mcpServers in Agent.create({ mcpServers }).\n * Each key is a server name; the value is the server configuration.\n *\n * @example\n * ```ts\n * @Agent({ name: 'dev', route: '/api/agents/dev' })\n * @MCP({\n * github: { command: 'npx', args: ['-y', '@modelcontextprotocol/server-github'] },\n * filesystem: { command: 'npx', args: ['-y', '@mcp/server-filesystem', '/workspace'] },\n * })\n * class DevAgent { ... }\n * ```\n */\nimport { setMeta, getMeta } from '../metadata/index.js'\n\nconst MCP_CONFIG = Symbol.for('theokit:agents:mcp')\n\nexport interface McpServerConfig {\n /** Command to start the MCP server. */\n command: string\n /** Arguments passed to the command. */\n args?: string[]\n /** Environment variables for the server process. */\n env?: Record<string, string>\n /** Working directory for the server process. */\n cwd?: string\n}\n\nexport type McpServersMap = Record<string, McpServerConfig>\n\nexport function MCP(servers: McpServersMap): ClassDecorator {\n return (target: Function) => {\n setMeta(MCP_CONFIG, target, servers)\n }\n}\n\nexport function getMcpConfig(target: Function): McpServersMap | undefined {\n return getMeta<McpServersMap>(MCP_CONFIG, target)\n}\n","/**\n * @Memory() — declares persistent memory configuration for an agent.\n *\n * Compiles to SDK's MemorySettings in Agent.create({ memory }).\n * Memory is per-agent, scoped by session strategy.\n *\n * @example\n * ```ts\n * @Agent({ name: 'support', route: '/api/agents/support' })\n * @Memory({ provider: 'built-in', embeddings: true, fts: true, scope: 'per-user' })\n * class SupportAgent { ... }\n * ```\n */\nimport { setMeta, getMeta } from '../metadata/index.js'\n\nconst MEMORY_CONFIG = Symbol.for('theokit:agents:memory')\n\nexport type MemoryProvider = 'built-in' | 'honcho' | 'supermemory' | 'mem0'\nexport type MemoryScope = 'per-user' | 'per-agent' | 'per-tenant' | 'global'\n\nexport interface MemoryOptions {\n /** Memory provider backend. */\n provider?: MemoryProvider\n /** Enable semantic search via embeddings. */\n embeddings?: boolean\n /** Enable full-text search (FTS5). */\n fts?: boolean\n /** Memory isolation scope (default: 'per-user'). */\n scope?: MemoryScope\n /** Maximum facts to retain per scope (0 = unlimited). */\n maxFacts?: number\n}\n\nexport function Memory(options: MemoryOptions = {}): ClassDecorator {\n return (target: Function) => {\n setMeta(MEMORY_CONFIG, target, {\n provider: 'built-in',\n embeddings: false,\n fts: false,\n scope: 'per-user',\n ...options,\n })\n }\n}\n\nexport function getMemoryConfig(target: Function): MemoryOptions | undefined {\n return getMeta<MemoryOptions>(MEMORY_CONFIG, target)\n}\n","/**\n * Observability decorators for agent tracing and auditing.\n */\nimport { createDecorator } from '@theokit/http'\n\n/** Enable distributed tracing for a tool/toolbox/agent. */\nexport const Trace = createDecorator<boolean>()\n\n/** Enable audit logging for a tool/toolbox/agent. */\nexport const Audit = createDecorator<boolean>()\n","/**\n * Agent-native policy decorators — built on http-decorators' createDecorator<T>().\n *\n * These decorators work with Reflector.getAllAndOverride() for hierarchical\n * resolution: tool → toolbox → agent (method-level overrides class-level).\n */\nimport { createDecorator } from '@theokit/http'\n\nimport type { ApprovalOptions, BudgetOptions, PolicyHandler } from '../types.js'\n\n/** Mark a tool as requiring human approval before execution. */\nexport const RequiresApproval = createDecorator<ApprovalOptions>()\n\n/** Require specific capabilities (permissions) to execute a tool. */\nexport const RequiresCapability = createDecorator<string[]>()\n\n/** Set a cost budget for an agent or tool scope. */\nexport const Budget = createDecorator<BudgetOptions>()\n\n/** Attach policy handler functions (CASL-style authorization). */\nexport const Policy = createDecorator<PolicyHandler[]>()\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 * @Skills() — declares markdown skill files injected into the agent's system prompt.\n *\n * Compiles to SDK's SkillsSettings in Agent.create({ skills }).\n * Skills are .theokit/skills/<name>/SKILL.md files discovered at agent creation.\n *\n * @example\n * ```ts\n * @Agent({ name: 'support', route: '/api/agents/support' })\n * @Skills(['customer-service', 'refund-policy', 'escalation-protocol'])\n * class SupportAgent { ... }\n * ```\n */\nimport { setMeta, getMeta } from '../metadata/index.js'\n\nconst SKILLS_CONFIG = Symbol.for('theokit:agents:skills')\n\nexport interface SkillsOptions {\n /** Skill names to include (resolved from .theokit/skills/<name>/SKILL.md). */\n include: string[]\n /** Auto-discover all skills in .theokit/skills/ (default: false). */\n autoDiscover?: boolean\n}\n\nexport function Skills(namesOrOptions: string[] | SkillsOptions): ClassDecorator {\n return (target: Function) => {\n const options: SkillsOptions = Array.isArray(namesOrOptions)\n ? { include: namesOrOptions, autoDiscover: false }\n : namesOrOptions\n setMeta(SKILLS_CONFIG, target, options)\n }\n}\n\nexport function getSkillsConfig(target: Function): SkillsOptions | undefined {\n return getMeta<SkillsOptions>(SKILLS_CONFIG, target)\n}\n","/**\n * @Agent() — marks a class as an AI agent controller.\n *\n * Convention over configuration:\n * @Agent() → name + route inferred from class name\n * @Agent({ model: '...' }) → name + route inferred, model explicit\n * @Agent({ name, route, model }) → fully explicit\n *\n * @example\n * ```ts\n * // Convention: SupportAgent → name: 'support', route: '/api/agents/support'\n * @Agent()\n * class SupportAgent { ... }\n *\n * // Partial: infer name + route, set model\n * @Agent({ model: 'claude-sonnet-4-5-20250929' })\n * class SupportAgent { ... }\n *\n * // Explicit: full control\n * @Agent({ name: 'support-agent', route: '/api/agents/support', model: '...' })\n * class SupportAgent { ... }\n * ```\n */\nimport { setMeta, getMeta, AGENT_CONFIG } from '../metadata/index.js'\nimport type { AgentOptions } from '../types.js'\n\n/**\n * Infer agent name and route from class name (Rails-style convention).\n *\n * SupportAgent → name: 'support', route: '/api/agents/support'\n * ResearchAgent → name: 'research', route: '/api/agents/research'\n * CodeReviewAgent → name: 'code-review', route: '/api/agents/code-review'\n */\nfunction inferAgentMeta(className: string): { name: string; route: string } {\n const stripped = className.replace(/Agent$/, '')\n const kebab = 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 return { name: kebab, route: `/api/agents/${kebab}` }\n}\n\nexport function Agent(options?: Partial<AgentOptions>): ClassDecorator {\n return (target: Function) => {\n const inferred = inferAgentMeta(target.name)\n setMeta(AGENT_CONFIG, target, {\n stream: true,\n name: inferred.name,\n route: inferred.route,\n ...options, // explicit values override inferred\n })\n }\n}\n\nexport function getAgentConfig(target: Function): AgentOptions | undefined {\n return getMeta<AgentOptions>(AGENT_CONFIG, target)\n}\n","/**\n * @SubAgents() — declares child agents that a parent agent can handoff to.\n *\n * Compiles to the SDK's `AgentOptions.agents` map. The parent agent\n * can delegate work to sub-agents via the built-in Agent tool.\n *\n * @example\n * ```ts\n * @Agent({ name: 'orchestrator', route: '/api/agents/orchestrator' })\n * @SubAgents([ResearchAgent, CoderAgent, ReviewerAgent])\n * class OrchestratorAgent {\n * @MainLoop({ strategy: 'plan-act-reflect' })\n * async run(ctx: AgentContext) { ... }\n * }\n * ```\n *\n * Each referenced class MUST be decorated with @Agent().\n * The compiler reads their metadata to build the SDK agents map.\n */\nimport { setMeta, getMeta } from '../metadata/index.js'\n\nimport { getAgentConfig } from './agent.js'\n\nconst SUB_AGENTS = Symbol.for('theokit:agents:sub-agents')\n\nexport function SubAgents(agentClasses: Function[]): ClassDecorator {\n return (target: Function) => {\n // Validate at decoration time: all classes must have @Agent\n for (const cls of agentClasses) {\n const config = getAgentConfig(cls)\n if (!config) {\n throw new Error(\n `[@theokit/agents] @SubAgents on ${target.name}: class ${cls.name} is missing @Agent() decorator.`,\n )\n }\n }\n setMeta(SUB_AGENTS, target, agentClasses)\n }\n}\n\nexport function getSubAgents(target: Function): Function[] {\n return getMeta<Function[]>(SUB_AGENTS, target) ?? []\n}\n","/**\n * @Mixin() — compose reusable capability classes into an agent.\n *\n * Mixins are classes with @Tool methods that can be shared across agents.\n * @Mixin copies tool metadata from mixin classes to the decorated agent,\n * making those tools available without inheritance.\n *\n * @example\n * ```ts\n * // Define reusable capabilities\n * class WithSearchCapability {\n * @Tool({ name: 'web_search', description: 'Search', input: z.object({...}) })\n * async webSearch(input) { ... }\n * }\n *\n * class WithFileSystem {\n * @Tool({ name: 'read_file', description: 'Read', input: z.object({...}) })\n * async readFile(input) { ... }\n * }\n *\n * // Compose into agent\n * @Agent({ name: 'research', route: '/research' })\n * @Mixin(WithSearchCapability, WithFileSystem)\n * class ResearchAgent {\n * @MainLoop()\n * async run() {}\n * }\n * ```\n */\nimport { setMeta, getMeta } from '../metadata/index.js'\n\nconst MIXIN_CLASSES = Symbol.for('theokit:agents:mixins')\n\nexport function Mixin(...mixinClasses: Function[]): ClassDecorator {\n return (target: Function) => {\n const existing = getMeta<Function[]>(MIXIN_CLASSES, target) ?? []\n setMeta(MIXIN_CLASSES, target, [...existing, ...mixinClasses])\n }\n}\n\nexport function getMixins(target: Function): Function[] {\n return getMeta<Function[]>(MIXIN_CLASSES, target) ?? []\n}\n"],"mappings":";;;;;AAEA,SAASA,SAASC,eAAe;;;ACA1B,IAAMC,eAAeC,uBAAOC,IAAI,uBAAA;AAChC,IAAMC,kBAAkBF,uBAAOC,IAAI,0BAAA;AACnC,IAAME,iBAAiBH,uBAAOC,IAAI,wBAAA;AAClC,IAAMG,cAAcJ,uBAAOC,IAAI,qBAAA;AAC/B,IAAMI,eAAeL,uBAAOC,IAAI,6BAAA;;;AC2BvC,IAAMK,oBAAoBC,uBAAOC,IAAI,2BAAA;AAgC9B,SAASC,WAAWC,UAA6B,CAAC,GAAC;AACxD,SAAO,CAACC,WAAAA;AACNC,YAAQN,mBAAmBK,QAAQ;MACjCE,SAAS;MACTC,UAAU;MACVC,gBAAgB;MAChBC,KAAK;MACL,GAAGN;IACL,CAAA;EACF;AACF;AAVgBD;AAYT,SAASQ,oBAAoBN,QAAgB;AAClD,SAAOO,QAA2BZ,mBAAmBK,MAAAA;AACvD;AAFgBM;;;AC1DhB,IAAME,oBAAoBC,uBAAOC,IAAI,2BAAA;AAU9B,SAASC,WAAWC,MAAcC,UAAmC,CAAC,GAAC;AAC5E,SAAO,CAACC,WAAAA;AACNC,YAAQP,mBAAmBM,QAAQ;MAAEF;MAAMI,YAAYH,QAAQG;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;;AC/BhB,IAAME,aAAaC,uBAAOC,IAAI,2BAAA;AAEvB,SAASC,UAAUC,cAAwB;AAChD,SAAO,CAACC,WAAAA;AAEN,eAAWC,OAAOF,cAAc;AAC9B,YAAMG,SAASC,eAAeF,GAAAA;AAC9B,UAAI,CAACC,QAAQ;AACX,cAAM,IAAIE,MACR,mCAAmCJ,OAAOK,IAAI,WAAWJ,IAAII,IAAI,iCAAiC;MAEtG;IACF;AACAC,YAAQX,YAAYK,QAAQD,YAAAA;EAC9B;AACF;AAbgBD;AAeT,SAASS,aAAaP,QAAgB;AAC3C,SAAOQ,QAAoBb,YAAYK,MAAAA,KAAW,CAAA;AACpD;AAFgBO;;;ACThB,IAAME,gBAAgBC,uBAAOC,IAAI,uBAAA;AAE1B,SAASC,SAASC,cAAwB;AAC/C,SAAO,CAACC,WAAAA;AACN,UAAMC,WAAWC,QAAoBP,eAAeK,MAAAA,KAAW,CAAA;AAC/DG,YAAQR,eAAeK,QAAQ;SAAIC;SAAaF;KAAa;EAC/D;AACF;AALgBD;AAOT,SAASM,UAAUJ,QAAgB;AACxC,SAAOE,QAAoBP,eAAeK,MAAAA,KAAW,CAAA;AACvD;AAFgBI;","names":["setMeta","getMeta","AGENT_CONFIG","Symbol","for","AGENT_MAIN_LOOP","TOOLBOX_CONFIG","TOOL_CONFIG","TOOL_METHODS","CHECKPOINT_CONFIG","Symbol","for","Checkpoint","options","target","setMeta","storage","strategy","maxCheckpoints","ttl","getCheckpointConfig","getMeta","COMPACTION_CONFIG","Symbol","for","Compaction","name","options","target","setMeta","keepTokens","getCompactionConfig","getMeta","CONTEXT_WINDOW_CONFIG","Symbol","for","ContextWindow","options","target","setMeta","maxTokens","compactionStrategy","preserveSystemPrompt","preserveLastN","preserveToolResults","getContextWindowConfig","getMeta","GATEWAY_CONFIG","Symbol","for","Gateway","options","target","setMeta","typing","sessionStrategy","getGatewayConfig","getMeta","resolveSessionId","strategy","platform","sender","channel","id","topicId","GUARDRAILS_CONFIG","Symbol","for","Guardrails","guardrails","target","setMeta","getGuardrailsConfig","getMeta","HITL_CONFIG","Symbol","for","HumanInTheLoop","options","target","propertyKey","actualTarget","setMeta","timeout","onTimeout","showInput","getHumanInTheLoopConfig","getMeta","MCP_CONFIG","Symbol","for","MCP","servers","target","setMeta","getMcpConfig","getMeta","MEMORY_CONFIG","Symbol","for","Memory","options","target","setMeta","provider","embeddings","fts","scope","getMemoryConfig","getMeta","createDecorator","Trace","Audit","createDecorator","RequiresApproval","RequiresCapability","Budget","Policy","PROJECT_CONTEXT_CONFIG","Symbol","for","ProjectContext","options","target","setMeta","rootMarkers","indexStrategy","maxFilesInContext","relevanceStrategy","ignorePatterns","getProjectContextConfig","getMeta","SKILLS_CONFIG","Symbol","for","Skills","namesOrOptions","target","options","Array","isArray","include","autoDiscover","setMeta","getSkillsConfig","getMeta","inferAgentMeta","className","stripped","replace","kebab","toLowerCase","name","route","Agent","options","target","inferred","setMeta","AGENT_CONFIG","stream","getAgentConfig","getMeta","SUB_AGENTS","Symbol","for","SubAgents","agentClasses","target","cls","config","getAgentConfig","Error","name","setMeta","getSubAgents","getMeta","MIXIN_CLASSES","Symbol","for","Mixin","mixinClasses","target","existing","getMeta","setMeta","getMixins"]}
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
getProjectContextConfig,
|
|
23
23
|
getSkillsConfig,
|
|
24
24
|
getSubAgents
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-B24BAVE6.js";
|
|
26
26
|
import {
|
|
27
27
|
__name
|
|
28
28
|
} from "./chunk-7QVYU63E.js";
|
|
@@ -1550,6 +1550,32 @@ function makeBuilder(config) {
|
|
|
1550
1550
|
tool
|
|
1551
1551
|
]
|
|
1552
1552
|
}), "tool"),
|
|
1553
|
+
guardrail: /* @__PURE__ */ __name((g) => makeBuilder({
|
|
1554
|
+
...config,
|
|
1555
|
+
guardrails: [
|
|
1556
|
+
...config.guardrails ?? [],
|
|
1557
|
+
g
|
|
1558
|
+
]
|
|
1559
|
+
}), "guardrail"),
|
|
1560
|
+
guardrails: /* @__PURE__ */ __name((gs) => makeBuilder({
|
|
1561
|
+
...config,
|
|
1562
|
+
guardrails: gs
|
|
1563
|
+
}), "guardrails"),
|
|
1564
|
+
approval: /* @__PURE__ */ __name((toolName, options) => makeBuilder({
|
|
1565
|
+
...config,
|
|
1566
|
+
approvals: {
|
|
1567
|
+
...config.approvals ?? {},
|
|
1568
|
+
[toolName]: options
|
|
1569
|
+
}
|
|
1570
|
+
}), "approval"),
|
|
1571
|
+
approvals: /* @__PURE__ */ __name((map) => makeBuilder({
|
|
1572
|
+
...config,
|
|
1573
|
+
approvals: map
|
|
1574
|
+
}), "approvals"),
|
|
1575
|
+
skills: /* @__PURE__ */ __name((selection) => makeBuilder({
|
|
1576
|
+
...config,
|
|
1577
|
+
skills: selection
|
|
1578
|
+
}), "skills"),
|
|
1553
1579
|
use: /* @__PURE__ */ __name((preset) => preset(runtime), "use"),
|
|
1554
1580
|
build: /* @__PURE__ */ __name(() => defineAgent(config), "build")
|
|
1555
1581
|
};
|
|
@@ -2881,7 +2907,6 @@ export {
|
|
|
2881
2907
|
createSdkAgentStream,
|
|
2882
2908
|
translateToUIMessageStream,
|
|
2883
2909
|
AGENT_BRAND,
|
|
2884
|
-
defineAgent,
|
|
2885
2910
|
isAgentDefinition,
|
|
2886
2911
|
compileAgentDefinition,
|
|
2887
2912
|
contextualTool,
|
|
@@ -2926,4 +2951,4 @@ export {
|
|
|
2926
2951
|
generateAgentManifest,
|
|
2927
2952
|
agentsPlugin
|
|
2928
2953
|
};
|
|
2929
|
-
//# sourceMappingURL=chunk-
|
|
2954
|
+
//# sourceMappingURL=chunk-IAE4FWBV.js.map
|