@economic/agents 2.11.1 → 2.11.3
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 +6 -2
- package/dist/index.mjs +3 -2
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Agent as Agent$1, AgentOptions, Connection, ConnectionContext, SubAgentClass } from "agents";
|
|
2
|
-
import { Action as Action$1, ActionConfig, ActionContext as ActionContext$1, ChatResponseResult, PrepareStepContext, Session, Think, ToolCallContext, ToolCallDecision, TurnConfig, TurnContext, skills } from "@cloudflare/think";
|
|
2
|
+
import { Action as Action$1, ActionApprovalPolicy, ActionConfig, ActionContext as ActionContext$1, ActionIdempotencyKey, ActionPermissionSpec, ChatResponseResult, PrepareStepContext, Session, Think, ToolCallContext, ToolCallDecision, TurnConfig, TurnContext, skills } from "@cloudflare/think";
|
|
3
3
|
import { FlexibleSchema, JSONValue, LanguageModel, ModelMessage, Tool as Tool$1, ToolExecutionOptions, UIMessage } from "ai";
|
|
4
4
|
import { Observability } from "agents/observability";
|
|
5
5
|
import { createCompactFunction } from "agents/experimental/memory/utils";
|
|
@@ -133,6 +133,7 @@ type Authentication<UserContext> = {
|
|
|
133
133
|
success: false;
|
|
134
134
|
status: 401 | 403 | 500;
|
|
135
135
|
message: string;
|
|
136
|
+
closeCode?: number;
|
|
136
137
|
};
|
|
137
138
|
declare abstract class Agent<RequestContext extends Record<string, unknown> = Record<string, unknown>, UserContext extends Record<string, unknown> = Record<string, unknown>, State = unknown> extends Think<Cloudflare.Env & AgentEnv, State> {
|
|
138
139
|
protected agentType: AgentConnectionType;
|
|
@@ -415,9 +416,12 @@ type ActionContext<Context extends Record<string, unknown> = Record<string, unkn
|
|
|
415
416
|
experimental_context: Context; /** The action's resolved domain key, or its tool-call fallback when none was declared. */
|
|
416
417
|
idempotencyKey: string;
|
|
417
418
|
};
|
|
418
|
-
type Action<Context extends Record<string, unknown> = Record<string, unknown>, Input = any, Output = any> = Omit<
|
|
419
|
+
type Action<Context extends Record<string, unknown> = Record<string, unknown>, Input = any, Output = any> = Omit<ActionConfig<FlexibleSchema<Input>, Output>, "approval" | "execute" | "idempotencyKey" | "inputSchema" | "permissions"> & {
|
|
419
420
|
description: string;
|
|
420
421
|
inputSchema: FlexibleSchema<Input>;
|
|
422
|
+
approval?: ActionApprovalPolicy<Input>;
|
|
423
|
+
idempotencyKey?: ActionIdempotencyKey<Input>;
|
|
424
|
+
permissions?: ActionPermissionSpec<Input>;
|
|
421
425
|
authorize?: (ctx?: Context) => boolean;
|
|
422
426
|
onUnauthorized?: UnauthorizedToolPolicy<Context>;
|
|
423
427
|
execute(input: Input, ctx: ActionContext<Context>): Promise<Output> | Output;
|
package/dist/index.mjs
CHANGED
|
@@ -936,7 +936,7 @@ var Agent = class extends Think {
|
|
|
936
936
|
this.forwardedFor = ctx.request.headers.get("X-Forwarded-For") ?? void 0;
|
|
937
937
|
const auth = await this.authenticate(ctx.request);
|
|
938
938
|
if (!auth.success) {
|
|
939
|
-
const closeCode = auth.status === 401 ? 4001 : auth.status === 403 ? 4003 : 1011;
|
|
939
|
+
const closeCode = auth.closeCode ?? (auth.status === 401 ? 4001 : auth.status === 403 ? 4003 : 1011);
|
|
940
940
|
sendConnectionStatus(connection, closeCode === 1011 ? "error" : "unauthorized");
|
|
941
941
|
connection.close(closeCode, auth.message);
|
|
942
942
|
return;
|
|
@@ -1346,7 +1346,8 @@ var Agent = class extends Think {
|
|
|
1346
1346
|
return {
|
|
1347
1347
|
success: false,
|
|
1348
1348
|
status: closeCode === 4003 ? 403 : closeCode === 4001 ? 401 : 500,
|
|
1349
|
-
message: "Could not establish user context"
|
|
1349
|
+
message: "Could not establish user context",
|
|
1350
|
+
closeCode
|
|
1350
1351
|
};
|
|
1351
1352
|
}
|
|
1352
1353
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@economic/agents",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.3",
|
|
4
4
|
"description": "A starter for creating a TypeScript package.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@ai-sdk/anthropic": "^3.0.77",
|
|
26
26
|
"@ai-sdk/google": "^3.0.73",
|
|
27
|
-
"@cloudflare/ai-chat": "^0.
|
|
28
|
-
"@cloudflare/think": "^0.
|
|
27
|
+
"@cloudflare/ai-chat": "^0.11.0",
|
|
28
|
+
"@cloudflare/think": "^0.17.0",
|
|
29
29
|
"@opentelemetry/sdk-trace-base": "^2.8.0",
|
|
30
|
-
"agents": "^0.
|
|
30
|
+
"agents": "^0.22.0",
|
|
31
31
|
"ai": "^6.0.197",
|
|
32
32
|
"jose": "^6.2.3",
|
|
33
33
|
"nanoid": "^5.1.11"
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"vitest": "^4.1.4"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@cloudflare/think": "^0.
|
|
47
|
+
"@cloudflare/think": "^0.17.0",
|
|
48
48
|
"@cloudflare/vite-plugin": "^1.43.0 <1.43.2",
|
|
49
49
|
"@cloudflare/worker-bundler": "^0.2.1",
|
|
50
|
-
"agents": "^0.
|
|
50
|
+
"agents": "^0.22.0",
|
|
51
51
|
"vite": ">=8.0.0"
|
|
52
52
|
}
|
|
53
53
|
}
|