@economic/agents 2.11.0 → 2.11.2
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/README.md +1 -1
- package/dist/index.d.mts +14 -9
- package/dist/index.mjs +3 -2
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -663,7 +663,7 @@ Imported from `@economic/agents` unless noted.
|
|
|
663
663
|
| Export | Description |
|
|
664
664
|
| ------------------------------------------------------------------------ | -------------------------------------------------------------------------- |
|
|
665
665
|
| `tool(def)` / `Tool` / `ToolSet` | Define a tool with optional `approval`, `authorize`, and `onUnauthorized`. |
|
|
666
|
-
| `action(def)` / `Action` / `
|
|
666
|
+
| `action(def)` / `Action` / `RegisteredAction` / `ActionContext` | Define a ledger-backed action with approval and idempotency support. |
|
|
667
667
|
| `skill(def)` / `Skill` | Define a skill with optional `tools`, `actions`, and authorization. |
|
|
668
668
|
| `ToolContext` | `RequestContext & { _userContext?: UserContext }`. |
|
|
669
669
|
| `AgentEnv` | The bindings the runtime expects. |
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Agent as Agent$1, AgentOptions, Connection, ConnectionContext, SubAgentClass } from "agents";
|
|
2
|
-
import { Action as Action$1,
|
|
3
|
-
import { FlexibleSchema,
|
|
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
|
+
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";
|
|
6
6
|
import { SkillSource as SkillSource$1 } from "agents/skills";
|
|
@@ -415,17 +415,22 @@ type ActionContext<Context extends Record<string, unknown> = Record<string, unkn
|
|
|
415
415
|
experimental_context: Context; /** The action's resolved domain key, or its tool-call fallback when none was declared. */
|
|
416
416
|
idempotencyKey: string;
|
|
417
417
|
};
|
|
418
|
-
type
|
|
418
|
+
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
|
+
description: string;
|
|
420
|
+
inputSchema: FlexibleSchema<Input>;
|
|
421
|
+
approval?: ActionApprovalPolicy<Input>;
|
|
422
|
+
idempotencyKey?: ActionIdempotencyKey<Input>;
|
|
423
|
+
permissions?: ActionPermissionSpec<Input>;
|
|
419
424
|
authorize?: (ctx?: Context) => boolean;
|
|
420
425
|
onUnauthorized?: UnauthorizedToolPolicy<Context>;
|
|
421
|
-
execute(input:
|
|
426
|
+
execute(input: Input, ctx: ActionContext<Context>): Promise<Output> | Output;
|
|
422
427
|
};
|
|
423
|
-
type
|
|
428
|
+
type RegisteredAction<Context extends Record<string, unknown> = Record<string, unknown>, InputSchema extends FlexibleSchema = FlexibleSchema, Output = unknown> = Action$1<InputSchema, Output> & {
|
|
424
429
|
authorize?: (ctx?: Context) => boolean;
|
|
425
430
|
onUnauthorized?: UnauthorizedToolPolicy<Context>;
|
|
426
431
|
};
|
|
427
432
|
/** A native Think action with the SDK's standard authorization policy. */
|
|
428
|
-
declare function action<Context extends Record<string, unknown> = Record<string, unknown>,
|
|
433
|
+
declare function action<Context extends Record<string, unknown> = Record<string, unknown>, Input = any, Output = any>(definition: Action<Context, Input, Output>): RegisteredAction<Context, FlexibleSchema<Input>, Output>;
|
|
429
434
|
//#endregion
|
|
430
435
|
//#region src/server/util/skills.d.ts
|
|
431
436
|
interface Skill<Context extends Record<string, unknown> = Record<string, unknown>> {
|
|
@@ -433,12 +438,12 @@ interface Skill<Context extends Record<string, unknown> = Record<string, unknown
|
|
|
433
438
|
description: string;
|
|
434
439
|
instructions: string;
|
|
435
440
|
tools?: Record<string, Tool<Context>>;
|
|
436
|
-
actions?: Record<string,
|
|
441
|
+
actions?: Record<string, RegisteredAction<Context, any, any>>;
|
|
437
442
|
authorize?: (ctx?: Context) => boolean;
|
|
438
443
|
}
|
|
439
444
|
interface SkillSource<Context extends Record<string, unknown> = Record<string, unknown>> extends SkillSource$1 {
|
|
440
445
|
tools?: Record<string, Tool<Context>>;
|
|
441
|
-
actions?: Record<string,
|
|
446
|
+
actions?: Record<string, RegisteredAction<Context, any, any>>;
|
|
442
447
|
authorize?: (ctx?: Context | undefined) => boolean;
|
|
443
448
|
}
|
|
444
449
|
declare function skill<Context extends Record<string, unknown> = Record<string, unknown>>(definition: Skill<Context>): SkillSource<Context>;
|
|
@@ -449,4 +454,4 @@ declare function routeAgentRequest<Env>(request: Request, env: Env, options?: Ag
|
|
|
449
454
|
//#region src/server/index.d.ts
|
|
450
455
|
declare function getCurrentToolContext(): any;
|
|
451
456
|
//#endregion
|
|
452
|
-
export { type Action, type
|
|
457
|
+
export { type Action, type ActionContext, Agent, type AgentConnectionStatus, type AgentConnectionType, type AgentEnv, Assistant, ChatAgent, type ExchangedToken, type JwtAuthConfig, type RegisteredAction, type Skill, type SkillSource, type TokenExchangeConfig, type TokenExchangeResult, type Tool, type ToolContext, type ToolSet, type TurnSnapshot, type UnauthorizedToolPolicy, action, createJwtAuthConfig, exchangeToken, getCurrentToolContext, routeAgentRequest, skill, tool };
|
package/dist/index.mjs
CHANGED
|
@@ -2497,10 +2497,11 @@ function action(definition) {
|
|
|
2497
2497
|
...config,
|
|
2498
2498
|
approval: config.approval ?? true,
|
|
2499
2499
|
execute: async (input, ctx) => {
|
|
2500
|
-
const
|
|
2500
|
+
const configuredKey = config.idempotencyKey;
|
|
2501
|
+
const idempotencyKey = typeof configuredKey === "function" ? await configuredKey({
|
|
2501
2502
|
input,
|
|
2502
2503
|
ctx
|
|
2503
|
-
}) :
|
|
2504
|
+
}) : typeof configuredKey === "string" ? configuredKey : ctx.toolCallId;
|
|
2504
2505
|
return execute(input, {
|
|
2505
2506
|
...ctx,
|
|
2506
2507
|
messages: [...ctx.messages],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@economic/agents",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.2",
|
|
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
|
}
|