agents 0.3.10 → 0.4.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.
Files changed (67) hide show
  1. package/README.md +2 -2
  2. package/dist/{index-N6791tVt.d.ts → agent-DY6QmSI_.d.ts} +3 -25
  3. package/dist/ai-types.js +1 -1
  4. package/dist/client-connection-CGMuV62J.js +472 -0
  5. package/dist/client-connection-CGMuV62J.js.map +1 -0
  6. package/dist/client-storage-Cvy5r9FG.d.ts +355 -0
  7. package/dist/client.d.ts +11 -7
  8. package/dist/client.js +6 -2
  9. package/dist/client.js.map +1 -1
  10. package/dist/email.d.ts +146 -16
  11. package/dist/email.js +222 -2
  12. package/dist/email.js.map +1 -0
  13. package/dist/index.d.ts +142 -41
  14. package/dist/index.js +2326 -6
  15. package/dist/index.js.map +1 -0
  16. package/dist/internal_context.d.ts +33 -6
  17. package/dist/internal_context.js +11 -2
  18. package/dist/internal_context.js.map +1 -0
  19. package/dist/mcp/client.d.ts +516 -2
  20. package/dist/mcp/client.js +662 -3
  21. package/dist/mcp/client.js.map +1 -0
  22. package/dist/mcp/do-oauth-client-provider.d.ts +61 -2
  23. package/dist/mcp/do-oauth-client-provider.js +154 -2
  24. package/dist/mcp/do-oauth-client-provider.js.map +1 -0
  25. package/dist/mcp/index.d.ts +3 -5
  26. package/dist/mcp/index.js +8 -7
  27. package/dist/mcp/index.js.map +1 -1
  28. package/dist/mcp/x402.d.ts +34 -14
  29. package/dist/mcp/x402.js +128 -66
  30. package/dist/mcp/x402.js.map +1 -1
  31. package/dist/{mcp-BwPscEiF.d.ts → mcp-Dw5vDrY8.d.ts} +1 -1
  32. package/dist/observability/index.d.ts +23 -2
  33. package/dist/observability/index.js +25 -6
  34. package/dist/observability/index.js.map +1 -0
  35. package/dist/react.d.ts +10 -10
  36. package/dist/react.js +6 -2
  37. package/dist/react.js.map +1 -1
  38. package/dist/types.d.ts +14 -1
  39. package/dist/types.js +16 -2
  40. package/dist/types.js.map +1 -0
  41. package/dist/utils.js +15 -2
  42. package/dist/utils.js.map +1 -0
  43. package/dist/workflow-types.d.ts +235 -23
  44. package/dist/workflows.d.ts +22 -24
  45. package/dist/workflows.js +2 -5
  46. package/dist/workflows.js.map +1 -1
  47. package/package.json +24 -28
  48. package/dist/client-CtC9E06G.js +0 -1122
  49. package/dist/client-CtC9E06G.js.map +0 -1
  50. package/dist/client-DV1CZKqa.d.ts +0 -969
  51. package/dist/do-oauth-client-provider-BqnOQzjy.d.ts +0 -70
  52. package/dist/do-oauth-client-provider-DDg8QrEA.js +0 -155
  53. package/dist/do-oauth-client-provider-DDg8QrEA.js.map +0 -1
  54. package/dist/email-8ljcpvwV.d.ts +0 -157
  55. package/dist/email-XHsSYsTO.js +0 -223
  56. package/dist/email-XHsSYsTO.js.map +0 -1
  57. package/dist/internal_context-CEu5ji80.d.ts +0 -29
  58. package/dist/internal_context-D9eKFth1.js +0 -8
  59. package/dist/internal_context-D9eKFth1.js.map +0 -1
  60. package/dist/src-i_UcyBYf.js +0 -2147
  61. package/dist/src-i_UcyBYf.js.map +0 -1
  62. package/dist/types-BITaDFf-.js +0 -16
  63. package/dist/types-BITaDFf-.js.map +0 -1
  64. package/dist/types-DSSHBW6w.d.ts +0 -14
  65. package/dist/utils-B49TmLCI.js +0 -16
  66. package/dist/utils-B49TmLCI.js.map +0 -1
  67. package/dist/workflow-types-Z_Oem1FJ.d.ts +0 -260
@@ -1,260 +0,0 @@
1
- import {
2
- WorkflowEvent,
3
- WorkflowSleepDuration,
4
- WorkflowStep
5
- } from "cloudflare:workers";
6
-
7
- //#region src/workflow-types.d.ts
8
- /**
9
- * Type alias for WorkflowEvent in AgentWorkflow context.
10
- * Identical to WorkflowEvent - provided for naming consistency with AgentWorkflowStep.
11
- */
12
- type AgentWorkflowEvent<Params = unknown> = WorkflowEvent<Params>;
13
- /**
14
- * Extended WorkflowStep with durable Agent communication methods.
15
- * All added methods on this interface are durable - they're idempotent and won't
16
- * repeat on workflow retry.
17
- */
18
- interface AgentWorkflowStep extends WorkflowStep {
19
- /**
20
- * Report successful completion to the Agent (durable).
21
- * Triggers onWorkflowComplete() on the Agent.
22
- * @param result - Optional result data
23
- */
24
- reportComplete<T = unknown>(result?: T): Promise<void>;
25
- /**
26
- * Report an error to the Agent (durable).
27
- * Triggers onWorkflowError() on the Agent.
28
- * @param error - Error or error message
29
- */
30
- reportError(error: Error | string): Promise<void>;
31
- /**
32
- * Send a custom event to the Agent (durable).
33
- * Triggers onWorkflowEvent() on the Agent.
34
- * @param event - Custom event payload
35
- */
36
- sendEvent<T = unknown>(event: T): Promise<void>;
37
- /**
38
- * Update the Agent's state entirely (durable).
39
- * This will replace the Agent's state and broadcast to all connected clients.
40
- * @param state - New state to set
41
- */
42
- updateAgentState(state: unknown): Promise<void>;
43
- /**
44
- * Merge partial state into the Agent's existing state (durable).
45
- * Performs a shallow merge and broadcasts to all connected clients.
46
- * @param partialState - Partial state to merge
47
- */
48
- mergeAgentState(partialState: Record<string, unknown>): Promise<void>;
49
- /**
50
- * Reset the Agent's state to its initialState (durable).
51
- * Broadcasts the reset state to all connected clients.
52
- */
53
- resetAgentState(): Promise<void>;
54
- }
55
- /**
56
- * Internal parameters injected by runWorkflow() to identify the originating Agent
57
- */
58
- type AgentWorkflowInternalParams = {
59
- /** Name/ID of the Agent that started this workflow */ __agentName: string; /** Environment binding name for the Agent's namespace */
60
- __agentBinding: string; /** Workflow binding name (for callbacks) */
61
- __workflowName: string;
62
- };
63
- /**
64
- * Combined workflow params: user params + internal agent params
65
- */
66
- type AgentWorkflowParams<T = unknown> = T & AgentWorkflowInternalParams;
67
- /**
68
- * Workflow callback types for Agent-Workflow communication
69
- */
70
- type WorkflowCallbackType = "progress" | "complete" | "error" | "event";
71
- /**
72
- * Base callback structure sent from Workflow to Agent
73
- */
74
- type WorkflowCallbackBase = {
75
- /** Workflow binding name */ workflowName: string; /** ID of the workflow instance */
76
- workflowId: string; /** Type of callback */
77
- type: WorkflowCallbackType; /** Timestamp when callback was sent */
78
- timestamp: number;
79
- };
80
- /**
81
- * Default progress type - covers common use cases.
82
- * Developers can define their own progress type for domain-specific needs.
83
- */
84
- type DefaultProgress = {
85
- /** Current step name */ step?: string; /** Step/overall status */
86
- status?:
87
- | "pending"
88
- | "running"
89
- | "complete"
90
- | "error"; /** Human-readable message */
91
- message?: string; /** Progress percentage (0-1) */
92
- percent?: number; /** Allow additional custom fields */
93
- [key: string]: unknown;
94
- };
95
- /**
96
- * Progress callback - reports workflow progress with typed payload
97
- */
98
- type WorkflowProgressCallback<P = DefaultProgress> = WorkflowCallbackBase & {
99
- type: "progress"; /** Typed progress data */
100
- progress: P;
101
- };
102
- /**
103
- * Complete callback - workflow finished successfully
104
- */
105
- type WorkflowCompleteCallback = WorkflowCallbackBase & {
106
- type: "complete"; /** Result of the workflow */
107
- result?: unknown;
108
- };
109
- /**
110
- * Error callback - workflow encountered an error
111
- */
112
- type WorkflowErrorCallback = WorkflowCallbackBase & {
113
- type: "error"; /** Error message */
114
- error: string;
115
- };
116
- /**
117
- * Event callback - custom event from workflow
118
- */
119
- type WorkflowEventCallback = WorkflowCallbackBase & {
120
- type: "event"; /** Custom event payload */
121
- event: unknown;
122
- };
123
- /**
124
- * Union of all callback types
125
- */
126
- type WorkflowCallback<P = DefaultProgress> =
127
- | WorkflowProgressCallback<P>
128
- | WorkflowCompleteCallback
129
- | WorkflowErrorCallback
130
- | WorkflowEventCallback;
131
- /**
132
- * Workflow status values - derived from Cloudflare's InstanceStatus
133
- */
134
- type WorkflowStatus = InstanceStatus["status"];
135
- /**
136
- * Row structure for cf_agents_workflows tracking table
137
- */
138
- type WorkflowTrackingRow = {
139
- /** Internal row ID (UUID) */ id: string; /** Cloudflare Workflow instance ID */
140
- workflow_id: string; /** Workflow binding name */
141
- workflow_name: string; /** Current workflow status */
142
- status: WorkflowStatus; /** JSON-serialized metadata for querying */
143
- metadata: string | null; /** Error name if workflow failed */
144
- error_name: string | null; /** Error message if workflow failed */
145
- error_message: string | null; /** Unix timestamp when workflow was created */
146
- created_at: number; /** Unix timestamp when workflow was last updated */
147
- updated_at: number; /** Unix timestamp when workflow completed (null if not complete) */
148
- completed_at: number | null;
149
- };
150
- /**
151
- * Options for runWorkflow()
152
- */
153
- type RunWorkflowOptions = {
154
- /** Custom workflow instance ID (auto-generated if not provided) */ id?: string; /** Optional metadata for querying (stored as JSON) */
155
- metadata?: Record<
156
- string,
157
- unknown
158
- >; /** Agent binding name (auto-detected from class name if not provided) */
159
- agentBinding?: string;
160
- };
161
- /**
162
- * Event payload for sendWorkflowEvent()
163
- */
164
- type WorkflowEventPayload = {
165
- /** Event type name */ type: string; /** Event payload data */
166
- payload: unknown;
167
- };
168
- /**
169
- * Parsed workflow tracking info returned by getWorkflow()
170
- */
171
- type WorkflowInfo = {
172
- /** Internal row ID */ id: string; /** Cloudflare Workflow instance ID */
173
- workflowId: string; /** Workflow binding name */
174
- workflowName: string; /** Current workflow status */
175
- status: WorkflowStatus; /** Metadata (parsed from JSON) */
176
- metadata: Record<string, unknown> | null; /** Error info if workflow failed */
177
- error: {
178
- name: string;
179
- message: string;
180
- } | null; /** When workflow was created */
181
- createdAt: Date; /** When workflow was last updated */
182
- updatedAt: Date; /** When workflow completed (null if not complete) */
183
- completedAt: Date | null;
184
- };
185
- /**
186
- * Criteria for querying tracked workflows
187
- */
188
- type WorkflowQueryCriteria = {
189
- /** Filter by status */ status?:
190
- | WorkflowStatus
191
- | WorkflowStatus[]; /** Filter by workflow binding name */
192
- workflowName?: string; /** Filter by metadata key-value pairs (exact match) */
193
- metadata?: Record<
194
- string,
195
- string | number | boolean
196
- >; /** Limit number of results (default 50, max 100) */
197
- limit?: number; /** Order by created_at */
198
- orderBy?:
199
- | "asc"
200
- | "desc"; /** Cursor for pagination (from previous WorkflowPage.nextCursor) */
201
- cursor?: string;
202
- };
203
- /**
204
- * Paginated result from getWorkflows()
205
- */
206
- type WorkflowPage = {
207
- /** Workflows for this page */ workflows: WorkflowInfo[]; /** Total count of workflows matching the criteria (ignoring pagination) */
208
- total: number; /** Cursor for next page, or null if no more pages */
209
- nextCursor: string | null;
210
- };
211
- /**
212
- * Standard approval event payload used by approveWorkflow/rejectWorkflow
213
- */
214
- type ApprovalEventPayload = {
215
- /** Whether the workflow was approved */ approved: boolean; /** Optional reason for approval/rejection */
216
- reason?: string; /** Optional additional metadata */
217
- metadata?: Record<string, unknown>;
218
- };
219
- /**
220
- * Options for waitForApproval()
221
- */
222
- type WaitForApprovalOptions = {
223
- /** Step name for waitForEvent (default: "wait-for-approval") */ stepName?: string; /** Timeout duration (e.g., "7 days") */
224
- timeout?: WorkflowSleepDuration; /** Event type to wait for (default: "approval") */
225
- eventType?: string;
226
- };
227
- /**
228
- * Error thrown when a workflow is rejected via rejectWorkflow()
229
- */
230
- declare class WorkflowRejectedError extends Error {
231
- readonly reason?: string | undefined;
232
- readonly workflowId?: string | undefined;
233
- constructor(reason?: string | undefined, workflowId?: string | undefined);
234
- }
235
- //#endregion
236
- export {
237
- WorkflowTrackingRow as S,
238
- WorkflowPage as _,
239
- ApprovalEventPayload as a,
240
- WorkflowRejectedError as b,
241
- WaitForApprovalOptions as c,
242
- WorkflowCallbackType as d,
243
- WorkflowCompleteCallback as f,
244
- WorkflowInfo as g,
245
- WorkflowEventPayload as h,
246
- AgentWorkflowStep as i,
247
- WorkflowCallback as l,
248
- WorkflowEventCallback as m,
249
- AgentWorkflowInternalParams as n,
250
- DefaultProgress as o,
251
- WorkflowErrorCallback as p,
252
- AgentWorkflowParams as r,
253
- RunWorkflowOptions as s,
254
- AgentWorkflowEvent as t,
255
- WorkflowCallbackBase as u,
256
- WorkflowProgressCallback as v,
257
- WorkflowStatus as x,
258
- WorkflowQueryCriteria as y
259
- };
260
- //# sourceMappingURL=workflow-types-Z_Oem1FJ.d.ts.map