@economic/agents 2.3.24 → 2.3.26
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/index.d.mts +1 -0
- package/dist/index.mjs +11 -3
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -49,6 +49,7 @@ declare abstract class Agent<RequestContext extends Record<string, unknown> = Re
|
|
|
49
49
|
configureSession(session: Session): Session;
|
|
50
50
|
onConnect(connection: Connection, ctx: ConnectionContext): Promise<void>;
|
|
51
51
|
private _toolsForCurrentTurn;
|
|
52
|
+
private _authorizedToolsForCurrentTurn;
|
|
52
53
|
private _toolContextForCurrentTurn?;
|
|
53
54
|
private getToolContextForCurrentTurn;
|
|
54
55
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -176,6 +176,7 @@ var Agent = class extends Think {
|
|
|
176
176
|
sendConnectionStatus(connection, "connected");
|
|
177
177
|
}
|
|
178
178
|
_toolsForCurrentTurn = {};
|
|
179
|
+
_authorizedToolsForCurrentTurn = {};
|
|
179
180
|
_toolContextForCurrentTurn;
|
|
180
181
|
getToolContextForCurrentTurn(requestContext = {}) {
|
|
181
182
|
const connectionState = getCurrentAgent().connection?.state;
|
|
@@ -247,12 +248,18 @@ var Agent = class extends Think {
|
|
|
247
248
|
};
|
|
248
249
|
}
|
|
249
250
|
async beforeToolCall(ctx) {
|
|
251
|
+
const toolCtx = this._toolContextForCurrentTurn ?? {};
|
|
250
252
|
if (ctx.toolName === "activate_skill") {
|
|
251
|
-
if ((await this.getSkills()).find((source) => source.id === ctx.input["name"])?.authorize?.(
|
|
253
|
+
if ((await this.getSkills()).find((source) => source.id === ctx.input["name"])?.authorize?.(toolCtx) === false) return {
|
|
252
254
|
action: "block",
|
|
253
255
|
reason: "Unauthorized skill"
|
|
254
256
|
};
|
|
257
|
+
return;
|
|
255
258
|
}
|
|
259
|
+
if (this._authorizedToolsForCurrentTurn[ctx.toolName]?.authorize?.(toolCtx) === false) return {
|
|
260
|
+
action: "block",
|
|
261
|
+
reason: `You do not have permission to use the "${ctx.toolName}" tool. Tell the user they don't have access to this capability, then stop -- do not try other tools to work around it.`
|
|
262
|
+
};
|
|
256
263
|
}
|
|
257
264
|
getTools() {
|
|
258
265
|
return {};
|
|
@@ -271,16 +278,17 @@ var Agent = class extends Think {
|
|
|
271
278
|
}
|
|
272
279
|
async _getAuthorizedTools(availableTools, activeSkillName) {
|
|
273
280
|
const tools = { ...availableTools };
|
|
274
|
-
const activeTools = Object.keys(
|
|
281
|
+
const activeTools = Object.keys(tools);
|
|
275
282
|
const authorizedSkills = (await this.getSkills()).filter((skill) => !skill.authorize || skill.authorize?.(this._toolContextForCurrentTurn) !== false);
|
|
276
283
|
for (const skill of authorizedSkills) {
|
|
277
284
|
if (!skill.tools || Object.keys(skill.tools).length === 0) continue;
|
|
278
285
|
Object.assign(tools, skill.tools);
|
|
279
286
|
if (skill.id === activeSkillName) activeTools.push(...Object.keys(skill.tools));
|
|
280
287
|
}
|
|
288
|
+
this._authorizedToolsForCurrentTurn = tools;
|
|
281
289
|
return {
|
|
282
290
|
tools,
|
|
283
|
-
activeTools
|
|
291
|
+
activeTools
|
|
284
292
|
};
|
|
285
293
|
}
|
|
286
294
|
_getLastActivatedSkillName(items = []) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@economic/agents",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.26",
|
|
4
4
|
"description": "A starter for creating a TypeScript package.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@babel/core": "^7.29.7",
|
|
38
38
|
"@babel/plugin-proposal-decorators": "^7.29.7",
|
|
39
|
-
"@cloudflare/workers-types": "^4.
|
|
39
|
+
"@cloudflare/workers-types": "^4.20260702.1",
|
|
40
40
|
"@rolldown/plugin-babel": "^0.2.3",
|
|
41
41
|
"@types/node": "^25.6.0",
|
|
42
42
|
"@typescript/native-preview": "7.0.0-dev.20260412.1",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"@cloudflare/think": "^0.12.1",
|
|
49
|
-
"@cloudflare/vite-plugin": "^1.
|
|
49
|
+
"@cloudflare/vite-plugin": "^1.43.0",
|
|
50
50
|
"@cloudflare/worker-bundler": "^0.2.1",
|
|
51
51
|
"agents": "^0.17.3",
|
|
52
52
|
"vite": ">=8.0.0"
|