@economic/agents 3.0.0-alpha.39514403335.1.0 → 3.0.1
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 +61 -1
- package/dist/index.d.mts +63 -113
- package/dist/index.mjs +205 -170
- package/dist/providers.d.mts +0 -8
- package/dist/providers.mjs +4 -8
- package/package.json +20 -20
package/README.md
CHANGED
|
@@ -89,6 +89,21 @@ the entry-point agent class as `agentId` in `cf-aig-metadata`. This includes
|
|
|
89
89
|
requests made by child chat/facet agents and allows a shared gateway's usage to
|
|
90
90
|
be grouped by agent without application configuration or duplicated analytics.
|
|
91
91
|
|
|
92
|
+
### Model and turn settings
|
|
93
|
+
|
|
94
|
+
The providers return models without per-model defaults, and the SDK sets none. The agent sets what its models need, such as a lower `effort` for Sonnet 5, from `getAgentConfig()`:
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
getAgentConfig() {
|
|
98
|
+
return {
|
|
99
|
+
providerOptions: { anthropic: { effort: "low" } },
|
|
100
|
+
timeout: { stepMs: 60_000 },
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Think's own timeouts are properties of the agent, such as `chatStreamStallTimeoutMs`, which aborts a model stream that stops sending; an action's is its `timeoutMs`.
|
|
106
|
+
|
|
92
107
|
## Quick start: an agent
|
|
93
108
|
|
|
94
109
|
Subclass `Agent` and implement `getModel` and `getSystemPrompt`. Add tools with `getTools`, skills with `getSkills`. Expose a `@callable` method to run a turn — `saveMessages` injects a message, runs the turn, and persists the result:
|
|
@@ -230,6 +245,30 @@ What `ChatAgent` adds over `Agent`:
|
|
|
230
245
|
|
|
231
246
|
Surfaced by the client as `chat.submitMessageFeedback` / `chat.getMessageFeedback`.
|
|
232
247
|
|
|
248
|
+
### Context blocks
|
|
249
|
+
|
|
250
|
+
To give the model facts about the user, such as their company, add each fact as its own block of the system prompt with `configureContext()`. A block is read on every turn:
|
|
251
|
+
|
|
252
|
+
```typescript
|
|
253
|
+
override async configureContext() {
|
|
254
|
+
return [
|
|
255
|
+
...(await super.configureContext()),
|
|
256
|
+
{
|
|
257
|
+
label: "company",
|
|
258
|
+
provider: {
|
|
259
|
+
get: async () => {
|
|
260
|
+
const agreement = this.identity.userContext()?.currentAgreement;
|
|
261
|
+
|
|
262
|
+
return agreement ? `Name: ${agreement.name}\nCVR: ${agreement.cvr}` : "";
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
},
|
|
266
|
+
];
|
|
267
|
+
}
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
Read the user context with `this.identity.userContext()`, and request values, such as the page the user is on, with `this.getToolContextForCurrentTurn()`.
|
|
271
|
+
|
|
233
272
|
## Many chats per user: Assistant
|
|
234
273
|
|
|
235
274
|
When one user needs a list of chats — a sidebar, titles, summaries — add an `Assistant`. It owns the chat list and routes to a `ChatAgent` per chat.
|
|
@@ -364,6 +403,23 @@ const send_invoice = tool<ToolContext>({
|
|
|
364
403
|
|
|
365
404
|
`step.runAgent(name, Agent, input, { inheritAuth })` runs another agent and returns its answer; see [migration](./MIGRATION.md#agents-you-run-can-act-as-your-caller) for `inheritAuth`.
|
|
366
405
|
|
|
406
|
+
### MCP tools
|
|
407
|
+
|
|
408
|
+
Think adds every connected MCP server's tools to every turn, with no `authorize` and no skill. To gate them, turn that off and add them from `getTools()` yourself:
|
|
409
|
+
|
|
410
|
+
```typescript
|
|
411
|
+
override includeMcpTools = false;
|
|
412
|
+
|
|
413
|
+
getTools(): ToolSet {
|
|
414
|
+
return Object.fromEntries(
|
|
415
|
+
Object.entries(this.mcp.getAITools()).map(([name, mcpTool]) => [
|
|
416
|
+
name,
|
|
417
|
+
{ ...mcpTool, authorize: (ctx) => ctx?._userContext?.canUseConnectors === true },
|
|
418
|
+
]),
|
|
419
|
+
);
|
|
420
|
+
}
|
|
421
|
+
```
|
|
422
|
+
|
|
367
423
|
## Actions
|
|
368
424
|
|
|
369
425
|
Use `action()` instead of `tool()` for operations with side effects. Actions use Cloudflare Think's durable action ledger for idempotent execution, settled-result replay, pending-action handling, recovery, timeouts, cancellation, and structured errors.
|
|
@@ -593,7 +649,7 @@ const tokenExchange = new TokenExchange({
|
|
|
593
649
|
});
|
|
594
650
|
|
|
595
651
|
const authenticator = jwtAuthenticator<UserContext>({
|
|
596
|
-
issuers: [env.IDENTITY_ENDPOINT], // strings or
|
|
652
|
+
issuers: [env.IDENTITY_ENDPOINT], // strings, or RegExps that must match the whole issuer
|
|
597
653
|
audience: "my-api",
|
|
598
654
|
scopes: ["support.read"],
|
|
599
655
|
actorId: (claims) => `${claims.agreement_number}_${claims.user_guid}`,
|
|
@@ -695,6 +751,10 @@ Separately, the SDK writes structured operational logs for completed/failed LLM
|
|
|
695
751
|
|
|
696
752
|
To send Worker logs through an existing Logpush job, enable `"logpush": true` in the Worker configuration; this does not create the Logpush job. Worker CPU, memory, and resource-limit metrics come from Cloudflare's platform telemetry rather than these SDK logs.
|
|
697
753
|
|
|
754
|
+
## Testing
|
|
755
|
+
|
|
756
|
+
Test agents against the real runtime with [`@cloudflare/vitest-plugin`](https://developers.cloudflare.com/workers/testing/vitest-integration/), as the SDK's own tests do, rather than mocking the SDK, Think or `agents`: a mock drifts from the runtime it stands in for. Evals use [`@economic/evals`](../evals/README.md).
|
|
757
|
+
|
|
698
758
|
## API reference
|
|
699
759
|
|
|
700
760
|
Imported from `@economic/agents` unless noted.
|
package/dist/index.d.mts
CHANGED
|
@@ -9,7 +9,6 @@ import { z } from "zod";
|
|
|
9
9
|
import { DurableObject } from "cloudflare:workers";
|
|
10
10
|
import { ContextConfig } from "agents/context";
|
|
11
11
|
import { SkillSource as SkillSource$1 } from "agents/skills";
|
|
12
|
-
//#region src/server/features/auth/errors.d.ts
|
|
13
12
|
/** A request or connection refused because of who made it. */
|
|
14
13
|
export declare class AuthenticationError extends Error {
|
|
15
14
|
readonly status: 401 | 403;
|
|
@@ -21,8 +20,6 @@ export declare class AuthenticationError extends Error {
|
|
|
21
20
|
reason?: string;
|
|
22
21
|
});
|
|
23
22
|
}
|
|
24
|
-
//#endregion
|
|
25
|
-
//#region src/server/features/auth/types.d.ts
|
|
26
23
|
type Claims = JWTPayload;
|
|
27
24
|
/** Who sent a request, as an authenticator checked them. */
|
|
28
25
|
interface Identity {
|
|
@@ -91,8 +88,6 @@ interface Caller<UserContext> {
|
|
|
91
88
|
auth: Auth;
|
|
92
89
|
userContext: UserContext | undefined;
|
|
93
90
|
}
|
|
94
|
-
//#endregion
|
|
95
|
-
//#region src/server/features/auth/identityStore.d.ts
|
|
96
91
|
interface IdentityStoreOptions<UserContext> {
|
|
97
92
|
/** Whose agent this is. Only an identity with this `actorId` is kept. */
|
|
98
93
|
owner: () => string | undefined;
|
|
@@ -147,8 +142,6 @@ interface InheritedCaller<UserContext = unknown> {
|
|
|
147
142
|
identity: Identity;
|
|
148
143
|
userContext: UserContext | undefined;
|
|
149
144
|
}
|
|
150
|
-
//#endregion
|
|
151
|
-
//#region src/server/features/auth/jwt.d.ts
|
|
152
145
|
interface JwtOptions {
|
|
153
146
|
/** Trusted issuers, matched exactly or by pattern. */
|
|
154
147
|
issuers: readonly (string | RegExp)[];
|
|
@@ -183,8 +176,6 @@ export declare function bearerToken(request: Request): string | undefined;
|
|
|
183
176
|
* without an expiry is refused.
|
|
184
177
|
*/
|
|
185
178
|
export declare function verifyJwt(token: string, options: JwtOptions): Promise<JWTPayload>;
|
|
186
|
-
//#endregion
|
|
187
|
-
//#region src/server/features/auth/tokenExchange.d.ts
|
|
188
179
|
type Stage = "client_credentials" | "token_exchange";
|
|
189
180
|
interface TokenExchangeOptions {
|
|
190
181
|
tokenUrl: string;
|
|
@@ -236,8 +227,6 @@ export declare class TokenExchange {
|
|
|
236
227
|
private _exchange;
|
|
237
228
|
private _request;
|
|
238
229
|
}
|
|
239
|
-
//#endregion
|
|
240
|
-
//#region src/server/features/users/store.d.ts
|
|
241
230
|
/** How often a user may call a tool: per UTC day, and per minute for bursts. Either can be left out. */
|
|
242
231
|
interface ToolCallLimit {
|
|
243
232
|
dailyCalls?: number;
|
|
@@ -259,8 +248,6 @@ export declare class UserStore extends DurableObject {
|
|
|
259
248
|
/** Deletes everything kept for the user. The call ends with an error, as the object is shut down. */
|
|
260
249
|
destroy(): Promise<void>;
|
|
261
250
|
}
|
|
262
|
-
//#endregion
|
|
263
|
-
//#region src/server/types.d.ts
|
|
264
251
|
/**
|
|
265
252
|
* The context object available throughout an agent's lifetime — passed via
|
|
266
253
|
* `context` to tool `execute` functions. Contains the typed
|
|
@@ -303,8 +290,6 @@ type AgentConnectionType = "agent" | "chat" | "assistant";
|
|
|
303
290
|
* with that guidance; `undefined` from a function keeps it hidden.
|
|
304
291
|
*/
|
|
305
292
|
type UnauthorizedPolicy<Context extends Record<string, unknown> = Record<string, unknown>> = string | ((ctx?: Context) => string | undefined);
|
|
306
|
-
//#endregion
|
|
307
|
-
//#region src/server/features/tasks/runAgent.d.ts
|
|
308
293
|
type AgentClass = DynamicAgentClass<Agent>;
|
|
309
294
|
interface RunAgentOptions {
|
|
310
295
|
/**
|
|
@@ -314,8 +299,6 @@ interface RunAgentOptions {
|
|
|
314
299
|
*/
|
|
315
300
|
inheritAuth?: boolean;
|
|
316
301
|
}
|
|
317
|
-
//#endregion
|
|
318
|
-
//#region src/server/features/tasks/step.d.ts
|
|
319
302
|
interface ApprovalRequest {
|
|
320
303
|
summary: string;
|
|
321
304
|
risk?: "low" | "medium" | "high";
|
|
@@ -338,8 +321,6 @@ interface BranchStep extends ToolStep {
|
|
|
338
321
|
/** Aborts the signal of the branch's running steps and refuses any more. */
|
|
339
322
|
cancel(reason?: string): void;
|
|
340
323
|
}
|
|
341
|
-
//#endregion
|
|
342
|
-
//#region src/server/util/tools.d.ts
|
|
343
324
|
type ToolSet = Record<string, Tool>;
|
|
344
325
|
/** What a durable tool's `executeTask` gets: its call ID, its context, and `step` for durable steps and approvals. */
|
|
345
326
|
interface ExecuteTaskOptions<Context extends Record<string, unknown> = Record<string, unknown>> {
|
|
@@ -360,8 +341,61 @@ type Tool<Context extends Record<string, unknown> = Record<string, unknown>, INP
|
|
|
360
341
|
executeTask?: ExecuteTask<Context, INPUT, NoInfer<OUTPUT> & TaskValue>;
|
|
361
342
|
};
|
|
362
343
|
export declare function tool<Context extends Record<string, unknown> = Record<string, unknown>, INPUT extends JSONValue | unknown | never = any, OUTPUT extends JSONValue | unknown | never = any>(definition: Tool<Context, INPUT, OUTPUT>): Tool<Context, INPUT, OUTPUT>;
|
|
363
|
-
|
|
364
|
-
|
|
344
|
+
/** Tool execution options plus the additional context supplied by native Think actions. */
|
|
345
|
+
type ActionContext<Context extends Record<string, unknown> = Record<string, unknown>> = ToolExecutionOptions<Context> & ActionContext$1 & {
|
|
346
|
+
/** The action's resolved domain key, or its tool-call fallback when none was declared. */
|
|
347
|
+
idempotencyKey: string;
|
|
348
|
+
};
|
|
349
|
+
type Action<Context extends Record<string, unknown> = Record<string, unknown>, Input = any, Output = any> = Omit<ActionConfig<FlexibleSchema<Input>, Output>, "approval" | "execute" | "idempotencyKey" | "inputSchema" | "permissions"> & {
|
|
350
|
+
description: string;
|
|
351
|
+
inputSchema: FlexibleSchema<Input>;
|
|
352
|
+
approval?: ActionApprovalPolicy<Input>;
|
|
353
|
+
idempotencyKey?: ActionIdempotencyKey<Input>;
|
|
354
|
+
permissions?: ActionPermissionSpec<Input>;
|
|
355
|
+
authorize?: (ctx?: Context) => boolean;
|
|
356
|
+
onUnauthorized?: UnauthorizedPolicy<Context>;
|
|
357
|
+
execute(input: Input, ctx: ActionContext<Context>): Promise<Output> | Output;
|
|
358
|
+
};
|
|
359
|
+
type RegisteredAction<Context extends Record<string, unknown> = Record<string, unknown>, InputSchema extends FlexibleSchema = FlexibleSchema, Output = unknown> = Action$1<InputSchema, Output> & {
|
|
360
|
+
authorize?: (ctx?: Context) => boolean;
|
|
361
|
+
onUnauthorized?: UnauthorizedPolicy<Context>;
|
|
362
|
+
};
|
|
363
|
+
/** A native Think action with the SDK's standard authorization policy. */
|
|
364
|
+
export 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>;
|
|
365
|
+
interface SkillDefinition<Context extends Record<string, unknown>> {
|
|
366
|
+
name: string;
|
|
367
|
+
description: string;
|
|
368
|
+
instructions: string;
|
|
369
|
+
tools?: Record<string, Tool<Context>>;
|
|
370
|
+
actions?: Record<string, RegisteredAction<Context, any, any>>;
|
|
371
|
+
authorize?: (ctx?: Context) => boolean;
|
|
372
|
+
onUnauthorized?: UnauthorizedPolicy<Context>;
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* When the skill is active:
|
|
376
|
+
* - `"auto"`: once the model starts it, when it's relevant. The default.
|
|
377
|
+
* - `"always"`: on every turn, without being started.
|
|
378
|
+
* - `"manual"`: once the user starts it with its `command`. It's hidden from
|
|
379
|
+
* the model, which can't start it itself.
|
|
380
|
+
*/
|
|
381
|
+
type SkillActivation = "auto" | "always" | "manual";
|
|
382
|
+
type Skill<Context extends Record<string, unknown> = Record<string, unknown>> = SkillDefinition<Context> & ({
|
|
383
|
+
activation?: "auto" | "always";
|
|
384
|
+
/** Lets the user start the skill from chat with `/command`. */
|
|
385
|
+
command?: string;
|
|
386
|
+
} | {
|
|
387
|
+
activation: "manual";
|
|
388
|
+
command: string;
|
|
389
|
+
});
|
|
390
|
+
interface SkillSource<Context extends Record<string, unknown> = Record<string, unknown>> extends SkillSource$1 {
|
|
391
|
+
command?: string;
|
|
392
|
+
activation?: SkillActivation;
|
|
393
|
+
tools?: Record<string, Tool<Context>>;
|
|
394
|
+
actions?: Record<string, RegisteredAction<Context, any, any>>;
|
|
395
|
+
authorize?: (ctx?: Context | undefined) => boolean;
|
|
396
|
+
onUnauthorized?: UnauthorizedPolicy<Context>;
|
|
397
|
+
}
|
|
398
|
+
export declare function skill<Context extends Record<string, unknown> = Record<string, unknown>>(definition: Skill<Context>): SkillSource<Context>;
|
|
365
399
|
interface SpanIds {
|
|
366
400
|
traceId: string;
|
|
367
401
|
spanId: string;
|
|
@@ -376,8 +410,6 @@ interface TurnExchange extends SpanIds {
|
|
|
376
410
|
/** An earlier turn already answered the user message, e.g. before a tool approval. */
|
|
377
411
|
continues: boolean;
|
|
378
412
|
}
|
|
379
|
-
//#endregion
|
|
380
|
-
//#region src/server/features/telemetry/utils.d.ts
|
|
381
413
|
/** The agent, chat and actor a turn belongs to. */
|
|
382
414
|
interface AgentIdentity {
|
|
383
415
|
agentName: string;
|
|
@@ -390,8 +422,6 @@ interface RequestOrigin {
|
|
|
390
422
|
clientIp?: string;
|
|
391
423
|
forwardedFor?: string;
|
|
392
424
|
}
|
|
393
|
-
//#endregion
|
|
394
|
-
//#region src/server/features/telemetry/tracing.d.ts
|
|
395
425
|
/** A completed turn and the OpenTelemetry spans the `ai` SDK recorded for it. */
|
|
396
426
|
interface TracedTurn extends AgentIdentity, RequestOrigin {
|
|
397
427
|
type: "turn";
|
|
@@ -485,11 +515,10 @@ declare class Tracing {
|
|
|
485
515
|
*/
|
|
486
516
|
private _keepAliveUntil;
|
|
487
517
|
}
|
|
488
|
-
//#endregion
|
|
489
|
-
//#region src/server/agents/Agent.d.ts
|
|
490
518
|
type MessagePart = UIMessage["parts"][number];
|
|
491
519
|
interface TurnInspection<RequestContext extends Record<string, unknown> = Record<string, unknown>, UserContext extends Record<string, unknown> = Record<string, unknown>> {
|
|
492
520
|
messages?: ModelMessage[];
|
|
521
|
+
continuation?: boolean;
|
|
493
522
|
requestContext?: RequestContext;
|
|
494
523
|
userContext?: UserContext;
|
|
495
524
|
}
|
|
@@ -506,6 +535,8 @@ type CurrentTurnState<RequestContext extends Record<string, unknown>, UserContex
|
|
|
506
535
|
context?: ToolContext<RequestContext, UserContext>;
|
|
507
536
|
inputTools: ToolSet;
|
|
508
537
|
preparedTools: ToolSet;
|
|
538
|
+
activeSkillNames: Set<string>;
|
|
539
|
+
skillSourcesByName?: Promise<Map<string, SkillSource>>;
|
|
509
540
|
unavailableSkillIds: Set<string>;
|
|
510
541
|
skillsSystemBlock: string;
|
|
511
542
|
visibleSkillNames: string[];
|
|
@@ -682,7 +713,7 @@ export declare abstract class Agent<RequestContext extends Record<string, unknow
|
|
|
682
713
|
workspaceTools: boolean;
|
|
683
714
|
sendReasoning: boolean;
|
|
684
715
|
getSkillScriptRunner(): skills.SkillScriptRunner | null;
|
|
685
|
-
protected pruneTurnMessages(messages: ModelMessage[]): ModelMessage[];
|
|
716
|
+
protected pruneTurnMessages(messages: ModelMessage[], continuation?: boolean): ModelMessage[];
|
|
686
717
|
private _prepareTools;
|
|
687
718
|
private _renderSkillsSystemBlock;
|
|
688
719
|
/**
|
|
@@ -693,7 +724,6 @@ export declare abstract class Agent<RequestContext extends Record<string, unknow
|
|
|
693
724
|
private _filterSkillHelperTools;
|
|
694
725
|
private _filterActivateSkillTool;
|
|
695
726
|
private _skillSources?;
|
|
696
|
-
private _skillSourcesByName?;
|
|
697
727
|
private _getUnauthorizedReason;
|
|
698
728
|
private _getSkillSources;
|
|
699
729
|
/** Each skill's source, by the skill's name. A source can hold several skills. */
|
|
@@ -730,12 +760,10 @@ export declare abstract class Agent<RequestContext extends Record<string, unknow
|
|
|
730
760
|
private _withTurnContextFallback;
|
|
731
761
|
/** The current turn's tool context, for every tool prepared for the turn. */
|
|
732
762
|
private _toolsContext;
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
private _activeSkillName;
|
|
738
|
-
private _getLastActivatedSkillName;
|
|
763
|
+
private _skillTurnStart;
|
|
764
|
+
private _activeSkillNamesForTurn;
|
|
765
|
+
private _activatedSkillNames;
|
|
766
|
+
private _getActivatedSkillNames;
|
|
739
767
|
/**
|
|
740
768
|
* The caller's identity, user context and credentials, kept until the
|
|
741
769
|
* token expires so turns after hibernation, and scheduled turns, can still
|
|
@@ -816,8 +844,6 @@ export declare abstract class Agent<RequestContext extends Record<string, unknow
|
|
|
816
844
|
/** The owner authentication checks, when the agent has an authenticator. */
|
|
817
845
|
protected getTelemetryActorId(): string;
|
|
818
846
|
}
|
|
819
|
-
//#endregion
|
|
820
|
-
//#region src/server/features/messages.d.ts
|
|
821
847
|
type MessageFeedback = {
|
|
822
848
|
message_id: string;
|
|
823
849
|
rating: number;
|
|
@@ -825,67 +851,6 @@ type MessageFeedback = {
|
|
|
825
851
|
created_at: number;
|
|
826
852
|
updated_at: number;
|
|
827
853
|
};
|
|
828
|
-
//#endregion
|
|
829
|
-
//#region src/server/util/actions.d.ts
|
|
830
|
-
/** Tool execution options plus the additional context supplied by native Think actions. */
|
|
831
|
-
type ActionContext<Context extends Record<string, unknown> = Record<string, unknown>> = ToolExecutionOptions<Context> & ActionContext$1 & {
|
|
832
|
-
/** The action's resolved domain key, or its tool-call fallback when none was declared. */
|
|
833
|
-
idempotencyKey: string;
|
|
834
|
-
};
|
|
835
|
-
type Action<Context extends Record<string, unknown> = Record<string, unknown>, Input = any, Output = any> = Omit<ActionConfig<FlexibleSchema<Input>, Output>, "approval" | "execute" | "idempotencyKey" | "inputSchema" | "permissions"> & {
|
|
836
|
-
description: string;
|
|
837
|
-
inputSchema: FlexibleSchema<Input>;
|
|
838
|
-
approval?: ActionApprovalPolicy<Input>;
|
|
839
|
-
idempotencyKey?: ActionIdempotencyKey<Input>;
|
|
840
|
-
permissions?: ActionPermissionSpec<Input>;
|
|
841
|
-
authorize?: (ctx?: Context) => boolean;
|
|
842
|
-
onUnauthorized?: UnauthorizedPolicy<Context>;
|
|
843
|
-
execute(input: Input, ctx: ActionContext<Context>): Promise<Output> | Output;
|
|
844
|
-
};
|
|
845
|
-
type RegisteredAction<Context extends Record<string, unknown> = Record<string, unknown>, InputSchema extends FlexibleSchema = FlexibleSchema, Output = unknown> = Action$1<InputSchema, Output> & {
|
|
846
|
-
authorize?: (ctx?: Context) => boolean;
|
|
847
|
-
onUnauthorized?: UnauthorizedPolicy<Context>;
|
|
848
|
-
};
|
|
849
|
-
/** A native Think action with the SDK's standard authorization policy. */
|
|
850
|
-
export 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>;
|
|
851
|
-
//#endregion
|
|
852
|
-
//#region src/server/util/skills.d.ts
|
|
853
|
-
interface SkillDefinition<Context extends Record<string, unknown>> {
|
|
854
|
-
name: string;
|
|
855
|
-
description: string;
|
|
856
|
-
instructions: string;
|
|
857
|
-
tools?: Record<string, Tool<Context>>;
|
|
858
|
-
actions?: Record<string, RegisteredAction<Context, any, any>>;
|
|
859
|
-
authorize?: (ctx?: Context) => boolean;
|
|
860
|
-
onUnauthorized?: UnauthorizedPolicy<Context>;
|
|
861
|
-
}
|
|
862
|
-
/**
|
|
863
|
-
* When the skill is active:
|
|
864
|
-
* - `"auto"`: once the model starts it, when it's relevant. The default.
|
|
865
|
-
* - `"always"`: on every turn, without being started.
|
|
866
|
-
* - `"manual"`: once the user starts it with its `command`. It's hidden from
|
|
867
|
-
* the model, which can't start it itself.
|
|
868
|
-
*/
|
|
869
|
-
type SkillActivation = "auto" | "always" | "manual";
|
|
870
|
-
type Skill<Context extends Record<string, unknown> = Record<string, unknown>> = SkillDefinition<Context> & ({
|
|
871
|
-
activation?: "auto" | "always";
|
|
872
|
-
/** Lets the user start the skill from chat with `/command`. */
|
|
873
|
-
command?: string;
|
|
874
|
-
} | {
|
|
875
|
-
activation: "manual";
|
|
876
|
-
command: string;
|
|
877
|
-
});
|
|
878
|
-
interface SkillSource<Context extends Record<string, unknown> = Record<string, unknown>> extends SkillSource$1 {
|
|
879
|
-
command?: string;
|
|
880
|
-
activation?: SkillActivation;
|
|
881
|
-
tools?: Record<string, Tool<Context>>;
|
|
882
|
-
actions?: Record<string, RegisteredAction<Context, any, any>>;
|
|
883
|
-
authorize?: (ctx?: Context | undefined) => boolean;
|
|
884
|
-
onUnauthorized?: UnauthorizedPolicy<Context>;
|
|
885
|
-
}
|
|
886
|
-
export declare function skill<Context extends Record<string, unknown> = Record<string, unknown>>(definition: Skill<Context>): SkillSource<Context>;
|
|
887
|
-
//#endregion
|
|
888
|
-
//#region src/server/util/skillCommands.d.ts
|
|
889
854
|
interface InvocableSkill {
|
|
890
855
|
/** Slash command without the leading `/`. */
|
|
891
856
|
command: string;
|
|
@@ -894,8 +859,6 @@ interface InvocableSkill {
|
|
|
894
859
|
/** Human- and model-readable summary from the skill definition. */
|
|
895
860
|
description: string;
|
|
896
861
|
}
|
|
897
|
-
//#endregion
|
|
898
|
-
//#region src/server/agents/ChatAgent.d.ts
|
|
899
862
|
declare const DELETE_MESSAGES_CALLBACK = "deleteMessagesCallback";
|
|
900
863
|
/** How a `run` ended: with its answer, waiting for an approval, or without one. */
|
|
901
864
|
type RunResult = {
|
|
@@ -962,8 +925,6 @@ export declare abstract class ChatAgent<RequestContext extends Record<string, un
|
|
|
962
925
|
private _scheduleMessageDeletion;
|
|
963
926
|
private [DELETE_MESSAGES_CALLBACK];
|
|
964
927
|
}
|
|
965
|
-
//#endregion
|
|
966
|
-
//#region src/server/features/chats.d.ts
|
|
967
928
|
type Chat = {
|
|
968
929
|
durable_object_name: string;
|
|
969
930
|
title?: string;
|
|
@@ -979,8 +940,6 @@ interface ChatSummaryInput {
|
|
|
979
940
|
recentMessages: UIMessage[];
|
|
980
941
|
}
|
|
981
942
|
declare const DELETE_CHAT_CALLBACK: "deleteChatCallback";
|
|
982
|
-
//#endregion
|
|
983
|
-
//#region src/server/agents/Assistant.d.ts
|
|
984
943
|
export declare abstract class Assistant<State = unknown> extends Agent$1<Cloudflare.Env & AgentEnv, State> {
|
|
985
944
|
private _fix;
|
|
986
945
|
protected abstract fastModel: LanguageModel;
|
|
@@ -1035,8 +994,6 @@ export declare abstract class Assistant<State = unknown> extends Agent$1<Cloudfl
|
|
|
1035
994
|
private deleteChatFromGlobalList;
|
|
1036
995
|
observability?: Observability;
|
|
1037
996
|
}
|
|
1038
|
-
//#endregion
|
|
1039
|
-
//#region src/server/features/turn-schemas.d.ts
|
|
1040
997
|
/**
|
|
1041
998
|
* A file input, sent inline as a data URL, of one of `mediaTypes`. A type
|
|
1042
999
|
* such as "image/*" takes any image.
|
|
@@ -1047,11 +1004,7 @@ export declare function file(mediaTypes: readonly string[]): z.ZodObject<{
|
|
|
1047
1004
|
url: z.ZodString;
|
|
1048
1005
|
filename: z.ZodOptional<z.ZodString>;
|
|
1049
1006
|
}, z.core.$strip>;
|
|
1050
|
-
//#endregion
|
|
1051
|
-
//#region src/server/route-agent-request.d.ts
|
|
1052
1007
|
export declare function routeAgentRequest<Env>(request: Request, env: Env, options?: AgentOptions<Env>): Promise<Response | null>;
|
|
1053
|
-
//#endregion
|
|
1054
|
-
//#region src/server/features/telemetry/audit-log/handler.d.ts
|
|
1055
1008
|
/**
|
|
1056
1009
|
* Writes one audit log per turn to `bucket`. Each is kept in the agent's
|
|
1057
1010
|
* `storage` until the bucket has it, and an undelivered one is sent again with
|
|
@@ -1070,8 +1023,6 @@ export declare class AuditLogHandler implements TracingHandler {
|
|
|
1070
1023
|
/** The turn's last model call, and its tool calls with the skill each ran in. */
|
|
1071
1024
|
private _modelAndToolCalls;
|
|
1072
1025
|
}
|
|
1073
|
-
//#endregion
|
|
1074
|
-
//#region src/server/features/telemetry/analytics/handler.d.ts
|
|
1075
1026
|
/** Writes per-turn and per-tool analytics events to an Analytics Engine `dataset`. */
|
|
1076
1027
|
export declare class AnalyticsHandler implements TracingHandler {
|
|
1077
1028
|
readonly name = "analytics";
|
|
@@ -1081,5 +1032,4 @@ export declare class AnalyticsHandler implements TracingHandler {
|
|
|
1081
1032
|
handle(event: TracingEvent): Promise<void>;
|
|
1082
1033
|
private _events;
|
|
1083
1034
|
}
|
|
1084
|
-
//#endregion
|
|
1085
1035
|
export { type Action, type ActionContext, type AgentConfig, type AgentConnectionStatus, type AgentConnectionType, type AgentEnv, type Auth, type Authenticator, type Claims, type Credential, type CredentialProvider, type Identity, type InvocableSkill, type JwtAuthenticatorOptions, type JwtOptions, type RegisteredAction, type RunResult, type Skill, type SkillActivation, type SkillInvoked, type SkillSource, type TokenExchangeOptions, type Tool, type ToolContext, type ToolSet, type TracedFeedback, type TracedSpan, type TracedTurn, type TracingEvent, type TracingHandler, type TurnEnded, type TurnInspection, type TurnSnapshot, type TurnStarted, type UnauthorizedPolicy, getCurrentAgent };
|