@agentuity/core 2.0.0 → 2.0.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.
Files changed (59) hide show
  1. package/AGENTS.md +15 -0
  2. package/dist/deprecation.d.ts +1 -1
  3. package/dist/deprecation.d.ts.map +1 -1
  4. package/dist/index.d.ts +1 -1
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +1 -1
  7. package/dist/index.js.map +1 -1
  8. package/dist/services/auth/index.d.ts +7 -0
  9. package/dist/services/auth/index.d.ts.map +1 -0
  10. package/dist/services/auth/index.js +7 -0
  11. package/dist/services/auth/index.js.map +1 -0
  12. package/dist/services/auth/types.d.ts +192 -0
  13. package/dist/services/auth/types.d.ts.map +1 -0
  14. package/dist/services/auth/types.js +11 -0
  15. package/dist/services/auth/types.js.map +1 -0
  16. package/dist/services/index.d.ts +2 -0
  17. package/dist/services/index.d.ts.map +1 -1
  18. package/dist/services/index.js +2 -0
  19. package/dist/services/index.js.map +1 -1
  20. package/dist/services/queue/destinations.d.ts +10 -0
  21. package/dist/services/queue/destinations.d.ts.map +1 -1
  22. package/dist/services/queue/destinations.js.map +1 -1
  23. package/dist/services/queue/types.d.ts +24 -33
  24. package/dist/services/queue/types.d.ts.map +1 -1
  25. package/dist/services/queue/types.js +11 -5
  26. package/dist/services/queue/types.js.map +1 -1
  27. package/dist/services/webhook/types.d.ts +1 -0
  28. package/dist/services/webhook/types.d.ts.map +1 -1
  29. package/dist/services/webhook/types.js +1 -0
  30. package/dist/services/webhook/types.js.map +1 -1
  31. package/dist/services/workflow/api-reference.d.ts +4 -0
  32. package/dist/services/workflow/api-reference.d.ts.map +1 -0
  33. package/dist/services/workflow/api-reference.js +335 -0
  34. package/dist/services/workflow/api-reference.js.map +1 -0
  35. package/dist/services/workflow/index.d.ts +3 -0
  36. package/dist/services/workflow/index.d.ts.map +1 -0
  37. package/dist/services/workflow/index.js +3 -0
  38. package/dist/services/workflow/index.js.map +1 -0
  39. package/dist/services/workflow/service.d.ts +235 -0
  40. package/dist/services/workflow/service.d.ts.map +1 -0
  41. package/dist/services/workflow/service.js +553 -0
  42. package/dist/services/workflow/service.js.map +1 -0
  43. package/dist/services/workflow/types.d.ts +270 -0
  44. package/dist/services/workflow/types.d.ts.map +1 -0
  45. package/dist/services/workflow/types.js +174 -0
  46. package/dist/services/workflow/types.js.map +1 -0
  47. package/package.json +2 -2
  48. package/src/deprecation.ts +1 -1
  49. package/src/index.ts +1 -1
  50. package/src/services/auth/index.ts +19 -0
  51. package/src/services/auth/types.ts +223 -0
  52. package/src/services/index.ts +2 -0
  53. package/src/services/queue/destinations.ts +1 -1
  54. package/src/services/queue/types.ts +11 -5
  55. package/src/services/webhook/types.ts +1 -0
  56. package/src/services/workflow/api-reference.ts +350 -0
  57. package/src/services/workflow/index.ts +2 -0
  58. package/src/services/workflow/service.ts +633 -0
  59. package/src/services/workflow/types.ts +233 -0
@@ -0,0 +1,235 @@
1
+ import type { CreateWorkflowRequest, ListWorkflowsRequest, UpdateWorkflowGraphRequest, UpdateWorkflowRequest, WorkflowActivity, WorkflowCreateResult, WorkflowDelivery, WorkflowExecution, WorkflowGetResult, WorkflowListResult, WorkflowUpdateResult, TestWorkflowRequest, TestWorkflowResult } from './types.ts';
2
+ import type { FetchAdapter } from '../adapter.ts';
3
+ /**
4
+ * Client for the Agentuity Workflow service.
5
+ *
6
+ * Provides methods for creating and managing workflows that route events from
7
+ * sources (email, queue, webhook, schedule) to configured destinations. The
8
+ * service supports:
9
+ *
10
+ * - **Workflows**: Named routing configurations with a source and graph
11
+ * - **Executions**: Records of workflow runs with step-level detail
12
+ * - **Deliveries**: Records of destination delivery attempts
13
+ * - **Testing**: Send test payloads through a workflow
14
+ *
15
+ * All methods are instrumented with OpenTelemetry spans for observability.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const workflows = new WorkflowService(baseUrl, adapter);
20
+ *
21
+ * // Create a workflow
22
+ * const { workflow } = await workflows.create({
23
+ * name: 'GitHub to Slack',
24
+ * source_type: 'webhook',
25
+ * source_ref_id: 'wh_abc123',
26
+ * });
27
+ *
28
+ * // List active workflows
29
+ * const { workflows: list } = await workflows.list({ status: 'enabled' });
30
+ * ```
31
+ */
32
+ export declare class WorkflowService {
33
+ #private;
34
+ /**
35
+ * Creates a new WorkflowService instance.
36
+ *
37
+ * @param baseUrl - The base URL of the workflow API
38
+ * @param adapter - The HTTP fetch adapter used for making API requests
39
+ */
40
+ constructor(baseUrl: string, adapter: FetchAdapter);
41
+ /**
42
+ * Lists all workflows for the authenticated organization.
43
+ *
44
+ * @param params - Optional filter and pagination parameters
45
+ * @returns A promise resolving to the paginated list of workflows
46
+ * @throws {@link WorkflowResponseError} If the API returns a failure response body
47
+ * @throws {@link ServiceException} If the HTTP request fails
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * const result = await service.list({ status: 'enabled', limit: 10 });
52
+ * console.log(`Found ${result.total} workflows`);
53
+ * for (const wf of result.workflows) {
54
+ * console.log(`${wf.name} (${wf.source_type})`);
55
+ * }
56
+ * ```
57
+ */
58
+ list(params?: ListWorkflowsRequest): Promise<WorkflowListResult>;
59
+ /**
60
+ * Gets a single workflow by its ID.
61
+ *
62
+ * @param workflowId - The unique workflow identifier (prefixed with wf_)
63
+ * @returns A promise resolving to the workflow details
64
+ * @throws {@link WorkflowResponseError} If the API returns a failure response body
65
+ * @throws {@link ServiceException} If the HTTP request fails
66
+ *
67
+ * @example
68
+ * ```typescript
69
+ * const result = await service.get('wf_abc123');
70
+ * console.log(result.workflow.name);
71
+ * ```
72
+ */
73
+ get(workflowId: string): Promise<WorkflowGetResult>;
74
+ /**
75
+ * Creates a new workflow.
76
+ *
77
+ * @param params - The workflow creation parameters including name, source type, and source reference
78
+ * @returns A promise resolving to the newly created workflow
79
+ * @throws {@link WorkflowResponseError} If the API returns a failure response body
80
+ * @throws {@link ServiceException} If the HTTP request fails
81
+ *
82
+ * @example
83
+ * ```typescript
84
+ * const result = await service.create({
85
+ * name: 'Email to Slack',
86
+ * source_type: 'email',
87
+ * source_ref_id: 'user@example.com',
88
+ * });
89
+ * console.log('Created:', result.workflow.id);
90
+ * ```
91
+ */
92
+ create(params: CreateWorkflowRequest): Promise<WorkflowCreateResult>;
93
+ /**
94
+ * Updates an existing workflow's name, description, or status.
95
+ *
96
+ * @param workflowId - The unique workflow identifier
97
+ * @param params - Fields to update; only provided fields are changed
98
+ * @returns A promise resolving to the updated workflow
99
+ * @throws {@link WorkflowResponseError} If the API returns a failure response body
100
+ * @throws {@link ServiceException} If the HTTP request fails
101
+ *
102
+ * @example
103
+ * ```typescript
104
+ * const result = await service.update('wf_abc123', {
105
+ * name: 'Updated Workflow Name',
106
+ * status: 'disabled',
107
+ * });
108
+ * console.log('Updated:', result.workflow.name);
109
+ * ```
110
+ */
111
+ update(workflowId: string, params: UpdateWorkflowRequest): Promise<WorkflowUpdateResult>;
112
+ /**
113
+ * Updates the workflow graph (nodes and edges) for a workflow.
114
+ *
115
+ * @param workflowId - The unique workflow identifier
116
+ * @param params - The new graph definition with nodes and edges
117
+ * @returns A promise resolving to the updated workflow
118
+ * @throws {@link WorkflowResponseError} If the API returns a failure response body
119
+ * @throws {@link ServiceException} If the HTTP request fails
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * const result = await service.updateGraph('wf_abc123', {
124
+ * nodes: [{ id: 'n1', type: 'filter', data: { expr: '...' } }],
125
+ * edges: [{ id: 'e1', source: 'n1', target: 'n2' }],
126
+ * });
127
+ * ```
128
+ */
129
+ updateGraph(workflowId: string, params: UpdateWorkflowGraphRequest): Promise<WorkflowUpdateResult>;
130
+ /**
131
+ * Deletes a workflow and all associated data.
132
+ *
133
+ * @param workflowId - The unique workflow identifier
134
+ * @throws {@link WorkflowResponseError} If the API returns a failure response body
135
+ * @throws {@link ServiceException} If the HTTP request fails
136
+ *
137
+ * @example
138
+ * ```typescript
139
+ * await service.delete('wf_abc123');
140
+ * console.log('Workflow deleted');
141
+ * ```
142
+ */
143
+ delete(workflowId: string): Promise<void>;
144
+ /**
145
+ * Tests a workflow with a sample payload.
146
+ *
147
+ * Sends the provided payload through the workflow and returns the execution
148
+ * result including individual step outcomes.
149
+ *
150
+ * @param workflowId - The unique workflow identifier
151
+ * @param params - The test parameters including the payload to send
152
+ * @returns A promise resolving to the test execution result
153
+ * @throws {@link WorkflowResponseError} If the API returns a failure response body
154
+ * @throws {@link ServiceException} If the HTTP request fails
155
+ *
156
+ * @example
157
+ * ```typescript
158
+ * const result = await service.test('wf_abc123', {
159
+ * payload: { event: 'push', repo: 'my-repo' },
160
+ * });
161
+ * console.log('Test status:', result.status);
162
+ * ```
163
+ */
164
+ test(workflowId: string, params: TestWorkflowRequest): Promise<TestWorkflowResult>;
165
+ /**
166
+ * Gets workflow activity statistics for the authenticated organization.
167
+ *
168
+ * Returns aggregate counts of workflows, executions, and their statuses.
169
+ *
170
+ * @param days - Optional number of days to look back for activity (default: server-side default)
171
+ * @returns A promise resolving to the activity statistics
172
+ * @throws {@link WorkflowResponseError} If the API returns a failure response body
173
+ * @throws {@link ServiceException} If the HTTP request fails
174
+ *
175
+ * @example
176
+ * ```typescript
177
+ * const activity = await service.activity(7);
178
+ * console.log(`${activity.total_workflows} workflows, ${activity.total_executions} executions`);
179
+ * ```
180
+ */
181
+ activity(days?: number): Promise<WorkflowActivity>;
182
+ /**
183
+ * Lists execution records for a specific workflow.
184
+ *
185
+ * @param workflowId - The unique workflow identifier
186
+ * @returns A promise resolving to the list of executions
187
+ * @throws {@link WorkflowResponseError} If the API returns a failure response body
188
+ * @throws {@link ServiceException} If the HTTP request fails
189
+ *
190
+ * @example
191
+ * ```typescript
192
+ * const executions = await service.listExecutions('wf_abc123');
193
+ * for (const exec of executions) {
194
+ * console.log(`${exec.id}: ${exec.status}`);
195
+ * }
196
+ * ```
197
+ */
198
+ listExecutions(workflowId: string): Promise<WorkflowExecution[]>;
199
+ /**
200
+ * Lists delivery records for a specific workflow execution.
201
+ *
202
+ * @param executionId - The unique execution identifier
203
+ * @returns A promise resolving to the list of deliveries
204
+ * @throws {@link WorkflowResponseError} If the API returns a failure response body
205
+ * @throws {@link ServiceException} If the HTTP request fails
206
+ *
207
+ * @example
208
+ * ```typescript
209
+ * const deliveries = await service.listDeliveries('exec_abc123');
210
+ * for (const d of deliveries) {
211
+ * console.log(`${d.destination_type}: ${d.status}`);
212
+ * }
213
+ * ```
214
+ */
215
+ listDeliveries(executionId: string): Promise<WorkflowDelivery[]>;
216
+ /**
217
+ * Gets the most recent payload received by a workflow.
218
+ *
219
+ * Useful for inspecting the last event that triggered the workflow, e.g.
220
+ * when building or debugging workflow graphs.
221
+ *
222
+ * @param workflowId - The unique workflow identifier
223
+ * @returns A promise resolving to the recent payload data
224
+ * @throws {@link WorkflowResponseError} If the API returns a failure response body
225
+ * @throws {@link ServiceException} If the HTTP request fails
226
+ *
227
+ * @example
228
+ * ```typescript
229
+ * const payload = await service.getRecentPayload('wf_abc123');
230
+ * console.log('Last payload:', JSON.stringify(payload, null, 2));
231
+ * ```
232
+ */
233
+ getRecentPayload(workflowId: string): Promise<unknown>;
234
+ }
235
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/services/workflow/service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACX,qBAAqB,EACrB,oBAAoB,EACpB,0BAA0B,EAC1B,qBAAqB,EACrB,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AA8ClD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,eAAe;;IAI3B;;;;;OAKG;gBACS,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY;IAUlD;;;;;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