@theokit/agents 1.0.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bridge.js +1 -1
- package/dist/{chunk-PTHRG25K.js → chunk-K3VX4S65.js} +50 -5
- package/dist/chunk-K3VX4S65.js.map +1 -0
- package/dist/index.d.ts +32 -13
- package/dist/index.js +35 -35
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-PTHRG25K.js.map +0 -1
package/dist/bridge.js
CHANGED
|
@@ -2,6 +2,14 @@ import {
|
|
|
2
2
|
__name
|
|
3
3
|
} from "./chunk-7QVYU63E.js";
|
|
4
4
|
|
|
5
|
+
// src/errors.ts
|
|
6
|
+
var ConfigurationError = class extends Error {
|
|
7
|
+
static {
|
|
8
|
+
__name(this, "ConfigurationError");
|
|
9
|
+
}
|
|
10
|
+
name = "ConfigurationError";
|
|
11
|
+
};
|
|
12
|
+
|
|
5
13
|
// src/bridge/define-agent.ts
|
|
6
14
|
var AGENT_BRAND = /* @__PURE__ */ Symbol.for("theokit.agent.definition");
|
|
7
15
|
function defineAgent(config) {
|
|
@@ -175,21 +183,57 @@ __name(compileSkills, "compileSkills");
|
|
|
175
183
|
|
|
176
184
|
// src/bridge/agent-compiler.ts
|
|
177
185
|
var SDK_TOOL_NAME = /^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/;
|
|
186
|
+
var SDK_TOOL_NAME_MAX_LENGTH = 64;
|
|
187
|
+
var SDK_TOOL_NAME_CHARSET = /^[a-zA-Z][a-zA-Z0-9_-]*$/;
|
|
188
|
+
var SDK_RESERVED_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
189
|
+
"shell",
|
|
190
|
+
"memory_search",
|
|
191
|
+
"memory_get"
|
|
192
|
+
]);
|
|
193
|
+
var SDK_RESERVED_TOOL_PREFIX = "mcp_";
|
|
178
194
|
function toolRuntimeName(namespace, toolName) {
|
|
179
|
-
|
|
195
|
+
if (toolName.trim().length === 0) {
|
|
196
|
+
const where = namespace ? ` no namespace "${namespace}"` : "";
|
|
197
|
+
throw new ConfigurationError(`tool: nome vazio${where} \u2014 declare um nome n\xE3o vazio para a tool`);
|
|
198
|
+
}
|
|
199
|
+
const name = namespace ? `${namespace}_${toolName}` : toolName;
|
|
200
|
+
if (!SDK_TOOL_NAME.test(name)) {
|
|
201
|
+
if (SDK_TOOL_NAME_CHARSET.test(name)) {
|
|
202
|
+
throw new ConfigurationError(`tool: nome "${name}" tem comprimento ${name.length} \u2014 a composi\xE7\xE3o namespace + "_" + tool excede o m\xE1ximo de ${SDK_TOOL_NAME_MAX_LENGTH} que o SDK aceita`);
|
|
203
|
+
}
|
|
204
|
+
throw new ConfigurationError(`tool: nome inv\xE1lido "${name}" \u2014 deve casar ${String(SDK_TOOL_NAME)} (o SDK rejeita o resto; verifique o namespace e o nome da tool)`);
|
|
205
|
+
}
|
|
206
|
+
if (SDK_RESERVED_TOOL_NAMES.has(name) || name.startsWith(SDK_RESERVED_TOOL_PREFIX)) {
|
|
207
|
+
throw new ConfigurationError(`tool: nome reservado "${name}" \u2014 o SDK reserva ${[
|
|
208
|
+
...SDK_RESERVED_TOOL_NAMES
|
|
209
|
+
].join(", ")} e o prefixo "${SDK_RESERVED_TOOL_PREFIX}"`);
|
|
210
|
+
}
|
|
211
|
+
return name;
|
|
180
212
|
}
|
|
181
213
|
__name(toolRuntimeName, "toolRuntimeName");
|
|
214
|
+
function compileHitlGates(toolboxes) {
|
|
215
|
+
const gates = /* @__PURE__ */ new Map();
|
|
216
|
+
for (const tb of toolboxes) {
|
|
217
|
+
for (const tool of tb.tools) {
|
|
218
|
+
if (tool.hitl) {
|
|
219
|
+
gates.set(toolRuntimeName(tb.namespace, tool.config.name), tool.hitl);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return gates;
|
|
224
|
+
}
|
|
225
|
+
__name(compileHitlGates, "compileHitlGates");
|
|
182
226
|
function compileTools(toolboxes, toolboxInstances) {
|
|
183
227
|
const tools = [];
|
|
184
228
|
for (const tb of toolboxes) {
|
|
185
229
|
const instance = toolboxInstances.get(tb.class);
|
|
186
230
|
if (!instance) {
|
|
187
|
-
throw new
|
|
231
|
+
throw new ConfigurationError(`toolbox: ${tb.class.name} n\xE3o foi instanciado \u2014 passe a inst\xE2ncia em \`toolboxInstances\``);
|
|
188
232
|
}
|
|
189
233
|
for (const tool of tb.tools) {
|
|
190
234
|
const handler = instance[tool.propertyKey];
|
|
191
235
|
if (typeof handler !== "function") {
|
|
192
|
-
throw new
|
|
236
|
+
throw new ConfigurationError(`toolbox: ${tb.class.name}.${String(tool.propertyKey)} n\xE3o \xE9 um m\xE9todo (tool "${tool.config.name}")`);
|
|
193
237
|
}
|
|
194
238
|
const name = toolRuntimeName(tb.namespace, tool.config.name);
|
|
195
239
|
tools.push({
|
|
@@ -3308,14 +3352,15 @@ function matchRoute(routes, method, pathname) {
|
|
|
3308
3352
|
__name(matchRoute, "matchRoute");
|
|
3309
3353
|
|
|
3310
3354
|
export {
|
|
3355
|
+
ConfigurationError,
|
|
3311
3356
|
AGENT_BRAND,
|
|
3312
3357
|
isAgentDefinition,
|
|
3313
3358
|
compileAgentDefinition,
|
|
3314
3359
|
compileSkillsSelection,
|
|
3315
3360
|
compileContextWindow,
|
|
3316
3361
|
compileSkills,
|
|
3317
|
-
SDK_TOOL_NAME,
|
|
3318
3362
|
toolRuntimeName,
|
|
3363
|
+
compileHitlGates,
|
|
3319
3364
|
compileTools,
|
|
3320
3365
|
createAgentExecutionContext,
|
|
3321
3366
|
isAgentContext,
|
|
@@ -3379,4 +3424,4 @@ export {
|
|
|
3379
3424
|
generateAgentManifest,
|
|
3380
3425
|
agentsPlugin
|
|
3381
3426
|
};
|
|
3382
|
-
//# sourceMappingURL=chunk-
|
|
3427
|
+
//# sourceMappingURL=chunk-K3VX4S65.js.map
|