@todoist/automations-sdk 0.0.0-stage → 1.0.0
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 +31 -2
- package/dist/authoring.d.ts +76 -0
- package/dist/authoring.js +162 -0
- package/dist/automations-api-CLcJvEjY.d.ts +6093 -0
- package/dist/base-client.d.ts +2 -0
- package/dist/base-client.js +1 -0
- package/dist/chat-turn.d.ts +314 -0
- package/dist/chat-turn.js +710 -0
- package/dist/connection-selection-BjNp9A-d.js +226 -0
- package/dist/connection-selection-C9yMkCvL.d.ts +29 -0
- package/dist/context-CxEkwuyE.js +109 -0
- package/dist/context-DsrXdqq8.d.ts +65 -0
- package/dist/index.d.ts +1060 -0
- package/dist/index.js +6030 -0
- package/dist/request-error-DoLXUa2p.js +34 -0
- package/dist/webhook-event-subscription.constants-CBmz0huQ.js +31 -0
- package/dist/webhooks.d.ts +52 -0
- package/dist/webhooks.js +83 -0
- package/package.json +84 -5
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1060 @@
|
|
|
1
|
+
import { $ as PartialManifestInput, A as ConnectionsClient, At as AutomationVisibility, B as ListWorkspaceAutomationDraftsArgs, Bt as TriggerAutomationResponse, C as ListNotificationsArgs, D as ListConnectorActionsArgs, Dt as AutomationDraftDto, E as ConnectorsClient, Et as AutomationDraftConnectionValidationDto, F as ChatClient, Ft as DraftTestTrigger, G as WorkspaceAutomationDraftConnectionsClient, H as ListWorkspaceAutomationsArgs, Ht as ConnectionType, I as ListChatConversationsArgs, It as DraftTestTriggerSelector, J as ListAutomationsArgs, K as WorkspaceAutomationRunsClient, L as WorkspacesClient, Lt as FinalizeAutomationDraftResponse, M as DeleteConnectionOptions, Mt as DraftTestRunFailedStep, N as ListConnectionsArgs, O as ListConnectorsArgs, Ot as AutomationDraftWithValidationDto, P as getConnectionInUseError, Pt as CreateAutomationDraftConnection, Q as ListAutomationDraftsArgs, R as WorkspaceChatClient, Rt as TestAutomationDraftRequest, S as UserSettingsClient, T as PushSubscriptionsClient, Tt as AutomationDraftConnectionDto, U as WorkspaceAutomationsClient, V as WorkspaceAutomationDraftsClient, Vt as ConnectionStatus, W as WorkspaceCreateOptions, X as AutomationDraftsClient, Y as getOpenDraftConflictError, Z as CreateAutomationDraftOptions, _ as getUsageBillingTopUpRefusal, _t as GetConnectorsResponseDto, a as ListWebhookEventDeliveriesArgs, at as AutomationDraftConnectionsClient, b as isUsageBillingTopUpPlanRequiredError, c as WebhookEventSubscriptionsClient, ct as PromptNotificationStatus, d as ReadUsageSummaryArgs, dt as CursorPaginationResponse, et as getDraftNotReadyError, f as StartTopUpArgs, ft as ManifestSchema, g as UsageBillingTopUpRefusalTag, gt as ConnectorDto, h as UsageBillingTopUpRefusal, ht as TriggerType, i as CreateWebhookEventSubscriptionArgs, it as ListAutomationRunsArgs, j as CreateConnectionArgs, jt as DraftTestRunDetailDto, k as getConnectorActionError, kt as AutomationDto, l as BillingPortalUrlArgs, lt as WorkspaceDto, m as UsageBillingClient, mt as StepSchema, n as AutomationsApiOptions, nt as AutomationRunsClient, o as ListWebhookEventSubscriptionsArgs, ot as AutomationConnectionsClient, p as USAGE_BILLING_TOP_UP_REFUSAL_TAGS, pt as PartialManifestSchema, q as AutomationsClient, r as WebhookSubscriptionsClient, rt as GetAutomationRunDetailsArgs, s as UpdateWebhookEventSubscriptionArgs, st as PromptNotificationDto, t as AutomationsApi, tt as getDraftTestRequestError, u as ReadTransactionsArgs, ut as SampleAutomationDto, v as isKnownUsageBillingTopUpRefusalTag, vt as ConnectionDetailsDto, w as NotificationsClient, wt as AutomationRunDetailDto, x as isUsageBillingTopUpUnavailableError, xt as GetConnectionsResponseDto, y as isUsageBillingAccountNotFoundError, yt as ConnectionDto, z as CreateWorkspaceAutomationDraftOptions, zt as TestAutomationDraftResponse } from "./automations-api-CLcJvEjY.js";
|
|
2
|
+
import { n as DEFAULT_BASE_URL, r as DEFAULT_TODOIST_BASE_URL, s as RequestOptions } from "./context-DsrXdqq8.js";
|
|
3
|
+
import { a as mcpServerHost, i as describeCandidateConnection, n as ConnectionSelection, r as connectionAccountLabel, t as CandidateConnection } from "./connection-selection-C9yMkCvL.js";
|
|
4
|
+
//#region ../core/dist/types/types/failure-category.types.d.ts
|
|
5
|
+
declare const FAILURE_CATEGORY_REGISTRY: {
|
|
6
|
+
readonly mcp_upstream_unavailable: {
|
|
7
|
+
readonly reliabilityLabel: "Mcp Upstream Unavailable";
|
|
8
|
+
};
|
|
9
|
+
readonly mcp_client_missing: {
|
|
10
|
+
readonly reliabilityLabel: "Mcp Client Missing";
|
|
11
|
+
};
|
|
12
|
+
readonly mcp_tool_missing: {
|
|
13
|
+
readonly reliabilityLabel: "Mcp Tool Missing";
|
|
14
|
+
};
|
|
15
|
+
readonly mcp_tool_call_failed: {
|
|
16
|
+
readonly reliabilityLabel: "Mcp Tool Call Failed";
|
|
17
|
+
};
|
|
18
|
+
readonly llm_schema_validation: {
|
|
19
|
+
readonly reliabilityLabel: "Llm Schema Validation";
|
|
20
|
+
};
|
|
21
|
+
readonly llm_empty_response: {
|
|
22
|
+
readonly reliabilityLabel: "Llm Empty Response";
|
|
23
|
+
};
|
|
24
|
+
readonly llm_provider_error: {
|
|
25
|
+
readonly reliabilityLabel: "Llm Provider Error";
|
|
26
|
+
};
|
|
27
|
+
readonly prompt_too_large: {
|
|
28
|
+
readonly reliabilityLabel: "Prompt Too Large";
|
|
29
|
+
};
|
|
30
|
+
readonly json_parse_error: {
|
|
31
|
+
readonly reliabilityLabel: "Json Parse Error";
|
|
32
|
+
};
|
|
33
|
+
readonly code_execution_error: {
|
|
34
|
+
readonly reliabilityLabel: "Code Execution Error";
|
|
35
|
+
};
|
|
36
|
+
readonly code_generation_error: {
|
|
37
|
+
readonly reliabilityLabel: "Code Generation Error";
|
|
38
|
+
};
|
|
39
|
+
readonly step_execution_error: {
|
|
40
|
+
readonly reliabilityLabel: "Step Execution Error";
|
|
41
|
+
};
|
|
42
|
+
readonly step_failure_pattern: {
|
|
43
|
+
readonly reliabilityLabel: "Step Failure Pattern";
|
|
44
|
+
};
|
|
45
|
+
readonly schema_validation: {
|
|
46
|
+
readonly reliabilityLabel: "Schema Validation";
|
|
47
|
+
};
|
|
48
|
+
readonly template_variable_error: {
|
|
49
|
+
readonly reliabilityLabel: "Template Variable Error";
|
|
50
|
+
};
|
|
51
|
+
readonly invalid_configuration: {
|
|
52
|
+
readonly reliabilityLabel: "Invalid Configuration";
|
|
53
|
+
};
|
|
54
|
+
readonly invalid_manifest: {
|
|
55
|
+
readonly reliabilityLabel: "Invalid Manifest";
|
|
56
|
+
};
|
|
57
|
+
readonly automation_not_found: {
|
|
58
|
+
readonly reliabilityLabel: "Automation Not Found";
|
|
59
|
+
};
|
|
60
|
+
readonly timeout: {
|
|
61
|
+
readonly reliabilityLabel: "Timeout";
|
|
62
|
+
};
|
|
63
|
+
readonly runtime_error: {
|
|
64
|
+
readonly reliabilityLabel: "Runtime Error";
|
|
65
|
+
};
|
|
66
|
+
readonly billing_unavailable: {
|
|
67
|
+
readonly reliabilityLabel: "Billing Unavailable";
|
|
68
|
+
};
|
|
69
|
+
readonly unknown: {
|
|
70
|
+
readonly reliabilityLabel: "Unknown";
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
type FailureCategory = keyof typeof FAILURE_CATEGORY_REGISTRY;
|
|
74
|
+
/** Persisted authorization denials are skipped runs, not failures. */
|
|
75
|
+
declare const SKIP_CATEGORIES: readonly ["insufficient_credit", "temporarily_unavailable", "plan_required", "billing_paused", "no_billing_account"];
|
|
76
|
+
type SkipCategory = (typeof SKIP_CATEGORIES)[number];
|
|
77
|
+
type RunOutcomeCategory = FailureCategory | SkipCategory;
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/errors/request-error.d.ts
|
|
80
|
+
/**
|
|
81
|
+
* A request that never produced a response: the network was unreachable, or
|
|
82
|
+
* the browser refused to expose a cross-origin response to the page. There is
|
|
83
|
+
* no status or body to read, so callers cannot classify these by status code.
|
|
84
|
+
*/
|
|
85
|
+
export declare class AutomationsNetworkError extends Error {
|
|
86
|
+
constructor(message: string, cause: unknown);
|
|
87
|
+
}
|
|
88
|
+
export declare class AutomationsRequestError extends Error {
|
|
89
|
+
readonly httpStatusCode: number;
|
|
90
|
+
readonly responseData: unknown;
|
|
91
|
+
/**
|
|
92
|
+
* The `WWW-Authenticate` challenge the response carried, verbatim. Undefined
|
|
93
|
+
* when it carried none — and in a browser unless the header is listed in
|
|
94
|
+
* `Access-Control-Expose-Headers`, which is why callers must still work
|
|
95
|
+
* without it.
|
|
96
|
+
*
|
|
97
|
+
* A 403 with a challenge is a refusal of the grant. A 403 without one is a
|
|
98
|
+
* refusal of something else — a membership, a plan, a waiting list — which
|
|
99
|
+
* authorizing again cannot fix, so the two must stay distinguishable.
|
|
100
|
+
*/
|
|
101
|
+
readonly authChallenge: string | undefined;
|
|
102
|
+
/**
|
|
103
|
+
* The scope the route asked for, read out of {@link authChallenge}. Undefined
|
|
104
|
+
* when there was no challenge, and also when there was one that named no
|
|
105
|
+
* scope: a challenge can say the grant falls short without saying of what.
|
|
106
|
+
*/
|
|
107
|
+
readonly requiredScope: string | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* The `X-Request-Id` the response carried, which the backend logs the request
|
|
110
|
+
* under. Undefined in a browser unless the header is exposed by CORS.
|
|
111
|
+
*/
|
|
112
|
+
readonly requestId: string | undefined;
|
|
113
|
+
constructor(message: string, httpStatusCode: number, responseData: unknown, authChallenge?: string, requestId?: string);
|
|
114
|
+
isAuthError(): boolean;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Whether a challenge blames the grant rather than the credential. Only these
|
|
118
|
+
* are worth answering by authorizing again; every other 403 has its own reason
|
|
119
|
+
* and its own message, which the caller should show instead of guessing.
|
|
120
|
+
*/
|
|
121
|
+
export declare function isInsufficientScopeChallenge(header: string | null | undefined): boolean;
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region src/summaries/automation-summary.d.ts
|
|
124
|
+
type AutomationConnectionSummary = Pick<ConnectionDetailsDto, 'id' | 'name' | 'connectorId' | 'capabilities' | 'status' | 'createdAt'>;
|
|
125
|
+
type AutomationSummary = Omit<AutomationDto, 'connections'> & {
|
|
126
|
+
readonly connections: readonly AutomationConnectionSummary[];
|
|
127
|
+
};
|
|
128
|
+
/** Removes provider identity and setup metadata from an automation API response. */
|
|
129
|
+
export declare function summarizeAutomation(automation: AutomationDto): AutomationSummary;
|
|
130
|
+
export declare function summarizeAutomationPage(page: CursorPaginationResponse<AutomationDto>): CursorPaginationResponse<AutomationSummary>;
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region src/links/automation-url.d.ts
|
|
133
|
+
/**
|
|
134
|
+
* The automation's page in the web app at `appUrl`: `/<id>` for a personal
|
|
135
|
+
* automation and `/<workspaceId>/<id>` for a workspace one, as the app routes them.
|
|
136
|
+
*/
|
|
137
|
+
export declare function getAutomationUrl(appUrl: string, automation: Pick<AutomationDto, 'id' | 'workspaceId'>): string;
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region src/summaries/run-summary.d.ts
|
|
140
|
+
type RunSummary = ReturnType<typeof summarizeRun>;
|
|
141
|
+
/** Selects the failure-focused fields needed for routine run diagnostics. */
|
|
142
|
+
export declare function summarizeRun(run: AutomationRunDetailDto): {
|
|
143
|
+
id: string;
|
|
144
|
+
automationId: string;
|
|
145
|
+
status: "pending" | "running" | "completed" | "cancelled" | "data-expired" | "failed" | "skipped";
|
|
146
|
+
createdAt: string;
|
|
147
|
+
updatedAt: string;
|
|
148
|
+
failureCategory: RunOutcomeCategory | null;
|
|
149
|
+
failureReason: string | null;
|
|
150
|
+
result: {
|
|
151
|
+
type: "markdown";
|
|
152
|
+
text: string;
|
|
153
|
+
} | {
|
|
154
|
+
type: "markdown";
|
|
155
|
+
text: string;
|
|
156
|
+
} | {
|
|
157
|
+
type: "markdown";
|
|
158
|
+
text: string;
|
|
159
|
+
} | {
|
|
160
|
+
type: "markdown";
|
|
161
|
+
text: string;
|
|
162
|
+
} | {
|
|
163
|
+
type: "markdown";
|
|
164
|
+
text: string;
|
|
165
|
+
} | {
|
|
166
|
+
type: "markdown";
|
|
167
|
+
text: string;
|
|
168
|
+
} | {
|
|
169
|
+
type: "markdown";
|
|
170
|
+
text: string;
|
|
171
|
+
} | null;
|
|
172
|
+
temporalUrl: string | null | undefined;
|
|
173
|
+
triggeredBy: string | null;
|
|
174
|
+
steps: {
|
|
175
|
+
stepId: string;
|
|
176
|
+
type: string;
|
|
177
|
+
description: string;
|
|
178
|
+
status: "pending" | "running" | "completed" | "cancelled" | "failed" | "skipped";
|
|
179
|
+
startedAt: string | undefined;
|
|
180
|
+
completedAt: string | undefined;
|
|
181
|
+
error: string | undefined;
|
|
182
|
+
toolCalls: {
|
|
183
|
+
id: string;
|
|
184
|
+
name: string;
|
|
185
|
+
argumentKeys: string[];
|
|
186
|
+
hasResult: boolean;
|
|
187
|
+
hasError: boolean;
|
|
188
|
+
resultPreview: string | undefined;
|
|
189
|
+
errorPreview: string | undefined;
|
|
190
|
+
timestamp: string;
|
|
191
|
+
}[] | undefined;
|
|
192
|
+
}[];
|
|
193
|
+
};
|
|
194
|
+
//#endregion
|
|
195
|
+
//#region src/summaries/draft-test-run-summary.d.ts
|
|
196
|
+
type DraftTestRunSummary = ReturnType<typeof summarizeDraftTestRun>;
|
|
197
|
+
/** The run-summary fields for a draft's test run, plus what failed and that calls were mocked. */
|
|
198
|
+
export declare function summarizeDraftTestRun(run: DraftTestRunDetailDto): {
|
|
199
|
+
id: string;
|
|
200
|
+
draftId: string;
|
|
201
|
+
automationId: string | null;
|
|
202
|
+
status: "pending" | "running" | "completed" | "cancelled" | "data-expired" | "failed" | "skipped";
|
|
203
|
+
connectorCalls: "mocked";
|
|
204
|
+
createdAt: string;
|
|
205
|
+
updatedAt: string;
|
|
206
|
+
failureCategory: RunOutcomeCategory | null;
|
|
207
|
+
failureReason: string | null;
|
|
208
|
+
failedStep: {
|
|
209
|
+
stepId: string;
|
|
210
|
+
description: string;
|
|
211
|
+
error: string | null;
|
|
212
|
+
} | {
|
|
213
|
+
stepId: string;
|
|
214
|
+
description: string;
|
|
215
|
+
error: string | null;
|
|
216
|
+
} | {
|
|
217
|
+
stepId: string;
|
|
218
|
+
description: string;
|
|
219
|
+
error: string | null;
|
|
220
|
+
} | {
|
|
221
|
+
stepId: string;
|
|
222
|
+
description: string;
|
|
223
|
+
error: string | null;
|
|
224
|
+
} | {
|
|
225
|
+
stepId: string;
|
|
226
|
+
description: string;
|
|
227
|
+
error: string | null;
|
|
228
|
+
} | {
|
|
229
|
+
stepId: string;
|
|
230
|
+
description: string;
|
|
231
|
+
error: string | null;
|
|
232
|
+
} | {
|
|
233
|
+
stepId: string;
|
|
234
|
+
description: string;
|
|
235
|
+
error: string | null;
|
|
236
|
+
} | null;
|
|
237
|
+
result: {
|
|
238
|
+
type: "markdown";
|
|
239
|
+
text: string;
|
|
240
|
+
} | {
|
|
241
|
+
type: "markdown";
|
|
242
|
+
text: string;
|
|
243
|
+
} | {
|
|
244
|
+
type: "markdown";
|
|
245
|
+
text: string;
|
|
246
|
+
} | {
|
|
247
|
+
type: "markdown";
|
|
248
|
+
text: string;
|
|
249
|
+
} | {
|
|
250
|
+
type: "markdown";
|
|
251
|
+
text: string;
|
|
252
|
+
} | {
|
|
253
|
+
type: "markdown";
|
|
254
|
+
text: string;
|
|
255
|
+
} | {
|
|
256
|
+
type: "markdown";
|
|
257
|
+
text: string;
|
|
258
|
+
} | null;
|
|
259
|
+
temporalUrl: string | null | undefined;
|
|
260
|
+
steps: {
|
|
261
|
+
stepId: string;
|
|
262
|
+
type: string;
|
|
263
|
+
description: string;
|
|
264
|
+
status: "pending" | "running" | "completed" | "cancelled" | "failed" | "skipped";
|
|
265
|
+
startedAt: string | undefined;
|
|
266
|
+
completedAt: string | undefined;
|
|
267
|
+
error: string | undefined;
|
|
268
|
+
toolCalls: {
|
|
269
|
+
id: string;
|
|
270
|
+
name: string;
|
|
271
|
+
argumentKeys: string[];
|
|
272
|
+
hasResult: boolean;
|
|
273
|
+
hasError: boolean;
|
|
274
|
+
resultPreview: string | undefined;
|
|
275
|
+
errorPreview: string | undefined;
|
|
276
|
+
timestamp: string;
|
|
277
|
+
}[] | undefined;
|
|
278
|
+
}[];
|
|
279
|
+
};
|
|
280
|
+
//#endregion
|
|
281
|
+
//#region src/summaries/list-summaries.d.ts
|
|
282
|
+
/**
|
|
283
|
+
* List shapes for automations and drafts: identity, state and triggers, without
|
|
284
|
+
* the manifest body. A manifest is untyped on the DTO (a draft can hold a
|
|
285
|
+
* partial one), so every field is read defensively and a nameless manifest is
|
|
286
|
+
* reported as such rather than failing the whole list.
|
|
287
|
+
*/
|
|
288
|
+
type AutomationListItem = ReturnType<typeof summarizeAutomationListItem>;
|
|
289
|
+
type DraftListItem = ReturnType<typeof summarizeDraftListItem>;
|
|
290
|
+
type TriggerListItem = {
|
|
291
|
+
readonly type: TriggerType;
|
|
292
|
+
readonly schedule?: {
|
|
293
|
+
interval?: string;
|
|
294
|
+
cron?: string;
|
|
295
|
+
timezone?: string;
|
|
296
|
+
};
|
|
297
|
+
readonly event?: string;
|
|
298
|
+
};
|
|
299
|
+
type ManifestMetadata = {
|
|
300
|
+
name?: string;
|
|
301
|
+
description?: string;
|
|
302
|
+
};
|
|
303
|
+
/** The name and description of an automation, or undefined when it has no manifest. */
|
|
304
|
+
export declare function readManifestMetadata(dto: AutomationDto): ManifestMetadata | undefined;
|
|
305
|
+
/** The type of the trigger that starts an automation, or undefined when it has none. */
|
|
306
|
+
export declare function readPrimaryTriggerType(dto: AutomationDto): TriggerType | undefined;
|
|
307
|
+
/** Whether a run can be started by hand, as the app's Run now allows; an api run starts with empty input. */
|
|
308
|
+
export declare function isManuallyTriggerable(triggerType: TriggerType | undefined): boolean;
|
|
309
|
+
/**
|
|
310
|
+
* Reduces an automation to its list shape. Connections keep only their
|
|
311
|
+
* identity and status, so provider identity and setup metadata never leave
|
|
312
|
+
* with a listing.
|
|
313
|
+
*/
|
|
314
|
+
export declare function summarizeAutomationListItem(dto: AutomationDto): {
|
|
315
|
+
triggers: TriggerListItem[];
|
|
316
|
+
connections: {
|
|
317
|
+
status?: "error" | "pending" | "authorized" | "expired" | undefined;
|
|
318
|
+
id: string;
|
|
319
|
+
name: string;
|
|
320
|
+
connectorId: string;
|
|
321
|
+
}[];
|
|
322
|
+
updatedAt: string;
|
|
323
|
+
disabledReason?: "creator-left-workspace" | "workspace-plan-lapsed" | undefined;
|
|
324
|
+
updatedBy?: string | undefined;
|
|
325
|
+
createdBy?: string | undefined;
|
|
326
|
+
workspaceId?: string | undefined;
|
|
327
|
+
connectionStatus: "ready" | "almost-ready" | "not-ready";
|
|
328
|
+
visibility: "private" | "workspace";
|
|
329
|
+
isOwner: boolean;
|
|
330
|
+
skipReason?: string | undefined;
|
|
331
|
+
failureReason?: string | undefined;
|
|
332
|
+
lastRun?: string | undefined;
|
|
333
|
+
enabled: boolean;
|
|
334
|
+
status: "pending" | "running" | "completed" | "cancelled" | "failed" | "skipped";
|
|
335
|
+
description?: string | undefined;
|
|
336
|
+
id: string;
|
|
337
|
+
name: string;
|
|
338
|
+
};
|
|
339
|
+
export declare function summarizeAutomationListPage(page: CursorPaginationResponse<AutomationDto>): CursorPaginationResponse<AutomationListItem>;
|
|
340
|
+
/** Reduces a draft to its list shape: identity and links, without the partial manifest. */
|
|
341
|
+
export declare function summarizeDraftListItem(dto: AutomationDraftDto): {
|
|
342
|
+
createdAt: string;
|
|
343
|
+
updatedAt: string;
|
|
344
|
+
workspaceId?: string | undefined;
|
|
345
|
+
conversationId?: string | undefined;
|
|
346
|
+
automationId?: string | undefined;
|
|
347
|
+
isComplete: boolean;
|
|
348
|
+
description?: string | undefined;
|
|
349
|
+
name?: string | undefined;
|
|
350
|
+
id: string;
|
|
351
|
+
};
|
|
352
|
+
export declare function summarizeDraftListPage(page: CursorPaginationResponse<AutomationDraftDto>): CursorPaginationResponse<DraftListItem>;
|
|
353
|
+
//#endregion
|
|
354
|
+
//#region src/connectors/connector-catalog.d.ts
|
|
355
|
+
/** The capabilities a connector can offer. The `api` connection type is internal and never listed. */
|
|
356
|
+
export declare const CONNECTOR_CAPABILITIES: readonly ["mcp", "trigger"];
|
|
357
|
+
type ConnectorCapability = (typeof CONNECTOR_CAPABILITIES)[number];
|
|
358
|
+
/** A connection as it appears under a connector: enough to tell what is linked and whether it works. */
|
|
359
|
+
type ConnectorConnectionSummary = Pick<ConnectionDto, 'id' | 'status' | 'capabilities' | 'createdAt' | 'mcpServerUrl'>;
|
|
360
|
+
type EnrichedConnector = ConnectorDto & {
|
|
361
|
+
readonly connections?: readonly ConnectorConnectionSummary[];
|
|
362
|
+
};
|
|
363
|
+
type ConnectorListOptions = {
|
|
364
|
+
readonly query?: string;
|
|
365
|
+
readonly capability?: ConnectorCapability;
|
|
366
|
+
readonly connectionStatus?: ConnectionStatus;
|
|
367
|
+
/** Whether to fetch the user's connections and join them onto each connector. */
|
|
368
|
+
readonly connections: boolean;
|
|
369
|
+
readonly withoutConnections?: boolean;
|
|
370
|
+
};
|
|
371
|
+
type ConnectorListResult = {
|
|
372
|
+
readonly connectionsIncluded: boolean;
|
|
373
|
+
readonly data: readonly EnrichedConnector[];
|
|
374
|
+
};
|
|
375
|
+
export declare class ConnectorNotFoundError extends Error {
|
|
376
|
+
readonly connectorId: string;
|
|
377
|
+
constructor(connectorId: string);
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Walks the connector catalog one full page at a time, guarding against a
|
|
381
|
+
* server that hands back a cursor it already served.
|
|
382
|
+
*/
|
|
383
|
+
export declare function iterateConnectorPages(api: AutomationsApi, query: string | undefined, options?: RequestOptions): AsyncGenerator<GetConnectorsResponseDto>;
|
|
384
|
+
/**
|
|
385
|
+
* Finds one connector by id, stopping at the first page that has it. The API
|
|
386
|
+
* has no single-connector route and its search matches names, not ids.
|
|
387
|
+
*/
|
|
388
|
+
export declare function findConnector(api: AutomationsApi, connectorId: string, options?: RequestOptions): Promise<ConnectorDto>;
|
|
389
|
+
/**
|
|
390
|
+
* Fetches the connector catalog, optionally joins the user's connections, and
|
|
391
|
+
* applies the connector filters. Callers validate that the filter combination
|
|
392
|
+
* makes sense; a connection filter with `connections: false` is silently a
|
|
393
|
+
* no-op here.
|
|
394
|
+
*/
|
|
395
|
+
export declare function listConnectors(api: AutomationsApi, options: ConnectorListOptions, requestOptions?: RequestOptions): Promise<ConnectorListResult>;
|
|
396
|
+
/** The capabilities a connector offers, in the order the CLI prints them. */
|
|
397
|
+
export declare function getConnectorCapabilities(connector: ConnectorDto): ConnectorCapability[];
|
|
398
|
+
export declare function connectorSupportsCapability(connector: ConnectorDto, capability: ConnectorCapability | undefined): boolean;
|
|
399
|
+
/** Adds lightweight user connection summaries to one catalog connector. */
|
|
400
|
+
export declare function enrichConnector(connector: ConnectorDto, connections: readonly ConnectionDto[]): EnrichedConnector;
|
|
401
|
+
export declare function groupConnectionsByConnector(connections: readonly ConnectionDto[]): ReadonlyMap<string, ConnectionDto[]>;
|
|
402
|
+
/**
|
|
403
|
+
* Whether a connector passes the connection filters. `withoutConnections`
|
|
404
|
+
* wants none; `connectionStatus` wants one in that state which, when a
|
|
405
|
+
* capability filter is on too, also covers that capability.
|
|
406
|
+
*/
|
|
407
|
+
export declare function matchesConnectionFilters(connector: EnrichedConnector, options: Pick<ConnectorListOptions, 'capability' | 'connectionStatus' | 'withoutConnections'>): boolean;
|
|
408
|
+
//#endregion
|
|
409
|
+
//#region src/connectors/connection-usage.d.ts
|
|
410
|
+
/**
|
|
411
|
+
* The published personal automations bound to one exact connection. The API
|
|
412
|
+
* has no connection filter on the automation list, so this walks every page
|
|
413
|
+
* and keeps only the matches, guarding against a repeated cursor the way the
|
|
414
|
+
* connector catalog does.
|
|
415
|
+
*/
|
|
416
|
+
export declare function findAutomationsUsingConnection(api: AutomationsApi, connectionId: string, options?: RequestOptions): Promise<AutomationDto[]>;
|
|
417
|
+
//#endregion
|
|
418
|
+
//#region src/templates/template-catalog.d.ts
|
|
419
|
+
/**
|
|
420
|
+
* Templates are the curated sample automations: ready-made manifests to install or start
|
|
421
|
+
* a draft from. A summary says everything about one except the manifest body, which is
|
|
422
|
+
* what keeps the whole catalogue small enough to list.
|
|
423
|
+
*/
|
|
424
|
+
type TemplateTrigger = TriggerListItem & {
|
|
425
|
+
/** When it runs, in words. */
|
|
426
|
+
readonly description: string;
|
|
427
|
+
/** The connector whose event starts it, for a webhook trigger. */
|
|
428
|
+
readonly connectorId?: string;
|
|
429
|
+
};
|
|
430
|
+
type TemplateConnector = {
|
|
431
|
+
readonly id: string;
|
|
432
|
+
readonly name: string;
|
|
433
|
+
/** "mcp": a step calls it; "trigger": its events start the automation. */
|
|
434
|
+
readonly usedFor: ConnectorCapability[];
|
|
435
|
+
};
|
|
436
|
+
type TemplateStep = {
|
|
437
|
+
readonly id: string;
|
|
438
|
+
readonly type: StepSchema['type'];
|
|
439
|
+
readonly title?: string;
|
|
440
|
+
readonly description: string;
|
|
441
|
+
/** The tools the step may call, by connector. */
|
|
442
|
+
readonly tools?: Record<string, string[]>;
|
|
443
|
+
};
|
|
444
|
+
type TemplateSummary = {
|
|
445
|
+
readonly id: string;
|
|
446
|
+
readonly name: string;
|
|
447
|
+
readonly description: string;
|
|
448
|
+
readonly staffPick: boolean;
|
|
449
|
+
/** Whether it can be installed as it is, without a draft. */
|
|
450
|
+
readonly oneClickInstall: boolean;
|
|
451
|
+
readonly triggers: TemplateTrigger[];
|
|
452
|
+
readonly connectors: TemplateConnector[];
|
|
453
|
+
readonly steps: TemplateStep[];
|
|
454
|
+
};
|
|
455
|
+
type TemplateDetail = TemplateSummary & {
|
|
456
|
+
/** Curated guidance on what to keep and what to customise when adapting it. */
|
|
457
|
+
readonly instructions?: string;
|
|
458
|
+
readonly manifest: ManifestSchema;
|
|
459
|
+
};
|
|
460
|
+
type TemplateFilters = {
|
|
461
|
+
/** Matches the name, the description and the names of the connectors it uses. */
|
|
462
|
+
readonly query?: string;
|
|
463
|
+
readonly connectorId?: string;
|
|
464
|
+
readonly triggerType?: TriggerType;
|
|
465
|
+
readonly staffPick?: boolean;
|
|
466
|
+
};
|
|
467
|
+
export declare class TemplateNotFoundError extends Error {
|
|
468
|
+
readonly templateId: string;
|
|
469
|
+
constructor(templateId: string);
|
|
470
|
+
}
|
|
471
|
+
/** Thrown when a template must be adapted in a draft rather than installed as it is. */
|
|
472
|
+
export declare class TemplateNotInstallableError extends Error {
|
|
473
|
+
readonly templateId: string;
|
|
474
|
+
constructor(templateId: string);
|
|
475
|
+
}
|
|
476
|
+
/** Lists the published templates as summaries, narrowed by the filters. */
|
|
477
|
+
export declare function listTemplates(api: AutomationsApi, filters?: TemplateFilters, options?: RequestOptions): Promise<TemplateSummary[]>;
|
|
478
|
+
/** One template in full: its summary, its authoring instructions and its manifest. */
|
|
479
|
+
export declare function getTemplate(api: AutomationsApi, templateId: string, options?: RequestOptions): Promise<TemplateDetail>;
|
|
480
|
+
/**
|
|
481
|
+
* Publishes a template as it is, into the personal space (`workspaceId` null or absent) or a
|
|
482
|
+
* workspace, where `visibility` defaults to team-visible. The automation stays disabled until
|
|
483
|
+
* the connections it needs are ready. Throws `TemplateNotInstallableError` for a template
|
|
484
|
+
* without one-click install, which needs a draft instead.
|
|
485
|
+
*/
|
|
486
|
+
export declare function installTemplate(api: AutomationsApi, { templateId, workspaceId, visibility }: {
|
|
487
|
+
templateId: string;
|
|
488
|
+
workspaceId?: string | null;
|
|
489
|
+
visibility?: AutomationVisibility;
|
|
490
|
+
}, options?: RequestOptions): Promise<AutomationDto>;
|
|
491
|
+
export declare function summarizeTemplate(sample: SampleAutomationDto): TemplateSummary;
|
|
492
|
+
//#endregion
|
|
493
|
+
//#region src/workspaces/creation-scope.d.ts
|
|
494
|
+
/** Where something new is created. */
|
|
495
|
+
type CreationScope = {
|
|
496
|
+
/** The workspace, or `null` for the personal space. */
|
|
497
|
+
readonly workspaceId: string | null;
|
|
498
|
+
/**
|
|
499
|
+
* The visibility a new workspace automation starts with. Only set when the
|
|
500
|
+
* user's default space chose the workspace; absent means team-visible.
|
|
501
|
+
*/
|
|
502
|
+
readonly visibility?: AutomationVisibility;
|
|
503
|
+
/** Whether the caller named the space or the user's default space chose it. */
|
|
504
|
+
readonly source: 'explicit' | 'default';
|
|
505
|
+
/** The workspace's name, for messages. Absent when the workspace list could not be read. */
|
|
506
|
+
readonly workspaceName?: string;
|
|
507
|
+
};
|
|
508
|
+
/** Workspace names by id, for messages that name a workspace. */
|
|
509
|
+
export declare function workspaceNamesById(workspaces: readonly WorkspaceDto[]): Readonly<Record<string, string>>;
|
|
510
|
+
/**
|
|
511
|
+
* The names of the caller's workspaces, by id. Empty when the list cannot be read,
|
|
512
|
+
* so a message that names a workspace falls back to its id instead of failing.
|
|
513
|
+
*/
|
|
514
|
+
export declare function readWorkspaceNames(api: AutomationsApi, options?: RequestOptions): Promise<Readonly<Record<string, string>>>;
|
|
515
|
+
/**
|
|
516
|
+
* Where a new automation, draft or conversation goes. `explicit` is the space the
|
|
517
|
+
* caller named: a workspace id, or `null` for personal. Left `undefined`, the
|
|
518
|
+
* user's default space decides, which lands a workspace automation with the
|
|
519
|
+
* visibility the user chose for it (private unless they said otherwise).
|
|
520
|
+
*/
|
|
521
|
+
export declare function resolveCreationScope(api: AutomationsApi, explicit: string | null | undefined, options?: RequestOptions): Promise<CreationScope>;
|
|
522
|
+
//#endregion
|
|
523
|
+
//#region src/drafts/draft-api.d.ts
|
|
524
|
+
/**
|
|
525
|
+
* The draft routes bound to one space, so a caller dispatches on personal versus
|
|
526
|
+
* workspace once instead of at every call.
|
|
527
|
+
*/
|
|
528
|
+
type DraftApi = {
|
|
529
|
+
/** The workspace the routes are bound to, or null for the personal space. */
|
|
530
|
+
readonly workspaceId: string | null;
|
|
531
|
+
readonly get: (draftId: string) => Promise<AutomationDraftWithValidationDto>;
|
|
532
|
+
readonly create: (manifest: PartialManifestSchema) => Promise<AutomationDraftWithValidationDto>;
|
|
533
|
+
readonly update: (draftId: string, manifest: PartialManifestSchema) => Promise<AutomationDraftWithValidationDto>;
|
|
534
|
+
readonly createAutomationDraft: (automationId: string) => Promise<{
|
|
535
|
+
draft: AutomationDraftDto;
|
|
536
|
+
}>;
|
|
537
|
+
/** A new draft holding a template's manifest, translated into the user's language. */
|
|
538
|
+
readonly createFromTemplate: (templateId: string) => Promise<AutomationDraftWithValidationDto>;
|
|
539
|
+
readonly upsertConnection: (draftId: string, body: CreateAutomationDraftConnection) => Promise<AutomationDraftConnectionDto>;
|
|
540
|
+
readonly getConnectionStatus: (draftId: string) => Promise<AutomationDraftConnectionValidationDto>;
|
|
541
|
+
/** The caller's own connections, which are not scoped to a space. */
|
|
542
|
+
readonly listConnections: (args: ListConnectionsArgs) => Promise<GetConnectionsResponseDto>;
|
|
543
|
+
readonly finalize: (draftId: string) => Promise<FinalizeAutomationDraftResponse>;
|
|
544
|
+
readonly getAutomation: (automationId: string) => Promise<AutomationDto>;
|
|
545
|
+
readonly test: (draftId: string, request: TestAutomationDraftRequest) => Promise<TestAutomationDraftResponse>;
|
|
546
|
+
readonly getTestRun: (draftId: string, runId: string, args?: {
|
|
547
|
+
includeGeneratedCode?: boolean;
|
|
548
|
+
includeToolCallPreviews?: boolean;
|
|
549
|
+
},
|
|
550
|
+
/** Replaces the bound signal for this request, to bound it more tightly. */
|
|
551
|
+
requestSignal?: AbortSignal) => Promise<DraftTestRunDetailDto>;
|
|
552
|
+
};
|
|
553
|
+
/**
|
|
554
|
+
* Binds the draft routes to the personal space (`null`) or a workspace. In a workspace,
|
|
555
|
+
* `visibility` is what a new automation published from a draft created through this
|
|
556
|
+
* binding starts with; absent means team-visible.
|
|
557
|
+
*/
|
|
558
|
+
export declare function bindDraftApi(api: AutomationsApi, workspaceId: string | null, { signal, visibility }?: {
|
|
559
|
+
signal?: AbortSignal;
|
|
560
|
+
visibility?: AutomationVisibility;
|
|
561
|
+
}): DraftApi;
|
|
562
|
+
//#endregion
|
|
563
|
+
//#region src/drafts/draft-changes.d.ts
|
|
564
|
+
/** What a draft will become when published. */
|
|
565
|
+
type DraftTarget = {
|
|
566
|
+
readonly kind: 'new';
|
|
567
|
+
} | {
|
|
568
|
+
readonly kind: 'automation';
|
|
569
|
+
readonly automationId: string;
|
|
570
|
+
};
|
|
571
|
+
type DraftChangeResult = AutomationDraftWithValidationDto & {
|
|
572
|
+
readonly action: 'created' | 'updated';
|
|
573
|
+
readonly target: DraftTarget;
|
|
574
|
+
};
|
|
575
|
+
/**
|
|
576
|
+
* Creates a draft from a manifest. With `automationId` the draft edits that
|
|
577
|
+
* automation: the API opens it seeded from the published manifest, then the
|
|
578
|
+
* given manifest replaces that seed, so publishing later updates the automation
|
|
579
|
+
* in place.
|
|
580
|
+
*/
|
|
581
|
+
export declare function createDraft(draftApi: DraftApi, { manifest, automationId }: {
|
|
582
|
+
manifest: unknown;
|
|
583
|
+
automationId?: string;
|
|
584
|
+
}): Promise<DraftChangeResult>;
|
|
585
|
+
/**
|
|
586
|
+
* Creates a new draft from a template, by id: the API copies the template's manifest, so
|
|
587
|
+
* the caller never holds it. Throws `TemplateNotFoundError` for an unknown template.
|
|
588
|
+
*/
|
|
589
|
+
export declare function createDraftFromTemplate(draftApi: DraftApi, { templateId }: {
|
|
590
|
+
templateId: string;
|
|
591
|
+
}): Promise<DraftChangeResult>;
|
|
592
|
+
/** Replaces a draft's manifest. */
|
|
593
|
+
export declare function updateDraft(draftApi: DraftApi, { draftId, manifest }: {
|
|
594
|
+
draftId: string;
|
|
595
|
+
manifest: unknown;
|
|
596
|
+
}): Promise<DraftChangeResult>;
|
|
597
|
+
/**
|
|
598
|
+
* Checks that a value is at least a partial manifest before it is sent anywhere,
|
|
599
|
+
* so a malformed one fails with the field paths rather than as an API 400.
|
|
600
|
+
*/
|
|
601
|
+
export declare function parsePartialManifest(value: unknown): PartialManifestSchema;
|
|
602
|
+
//#endregion
|
|
603
|
+
//#region src/drafts/connect-draft.d.ts
|
|
604
|
+
type BoundConnection = {
|
|
605
|
+
readonly connectorId: string;
|
|
606
|
+
readonly connectionType: ConnectionType;
|
|
607
|
+
readonly connectionId: string;
|
|
608
|
+
/** `explicit` was chosen by the caller; `auto` was the only authorised connection. */
|
|
609
|
+
readonly mode: 'explicit' | 'auto';
|
|
610
|
+
};
|
|
611
|
+
type UnresolvedConnection = {
|
|
612
|
+
readonly connectorId: string;
|
|
613
|
+
readonly connectionType: ConnectionType;
|
|
614
|
+
readonly reason: 'no_connection' | 'multiple_connections';
|
|
615
|
+
/** The authorised connections to choose from when there is more than one. */
|
|
616
|
+
readonly candidateConnections: readonly CandidateConnection[];
|
|
617
|
+
/** @deprecated The ids of `candidateConnections`. */
|
|
618
|
+
readonly candidateConnectionIds: readonly string[];
|
|
619
|
+
};
|
|
620
|
+
type DraftConnectResult = {
|
|
621
|
+
readonly action: 'connected';
|
|
622
|
+
readonly draftId: string;
|
|
623
|
+
readonly bound: readonly BoundConnection[];
|
|
624
|
+
readonly unresolved: readonly UnresolvedConnection[];
|
|
625
|
+
readonly isValid: boolean;
|
|
626
|
+
readonly missing: AutomationDraftConnectionValidationDto['missing'];
|
|
627
|
+
};
|
|
628
|
+
/**
|
|
629
|
+
* Binds connections to a draft. Explicit selections are applied as given; with
|
|
630
|
+
* `auto`, every required slot with no binding at all is filled when the user has
|
|
631
|
+
* exactly one authorised connection for it, the same rule the chat agent applies.
|
|
632
|
+
* A slot that is bound but expired or unauthorised is left alone, since replacing
|
|
633
|
+
* the account is the caller's decision; it stays in `missing`. Slots `auto`
|
|
634
|
+
* cannot settle come back as `unresolved`.
|
|
635
|
+
*/
|
|
636
|
+
export declare function connectDraft(draftApi: DraftApi, { draftId, selections, auto }: {
|
|
637
|
+
draftId: string;
|
|
638
|
+
selections: readonly ConnectionSelection[];
|
|
639
|
+
auto: boolean;
|
|
640
|
+
}): Promise<DraftConnectResult>;
|
|
641
|
+
//#endregion
|
|
642
|
+
//#region src/questions/ask-steps.d.ts
|
|
643
|
+
/** Where an automation's runs stop to ask the user, as its manifest declares it. */
|
|
644
|
+
type AskStepSummary = {
|
|
645
|
+
readonly stepId: string;
|
|
646
|
+
readonly question: string;
|
|
647
|
+
readonly options: readonly {
|
|
648
|
+
readonly label: string;
|
|
649
|
+
readonly endsRun: boolean;
|
|
650
|
+
}[];
|
|
651
|
+
/** How long a run waits for an answer before it stops, such as `1w`. */
|
|
652
|
+
readonly expiresAfter: string;
|
|
653
|
+
};
|
|
654
|
+
/**
|
|
655
|
+
* The ask steps of a manifest, in step order. Reads a partial manifest as
|
|
656
|
+
* readily as a complete one, skipping any ask step too incomplete to describe
|
|
657
|
+
* (no id or a blank question) and any option with a blank label.
|
|
658
|
+
*/
|
|
659
|
+
export declare function describeAskSteps(manifest: unknown): AskStepSummary[];
|
|
660
|
+
//#endregion
|
|
661
|
+
//#region src/drafts/manifest-diff.d.ts
|
|
662
|
+
/**
|
|
663
|
+
* A step-level summary of how one manifest differs from another: which top-level
|
|
664
|
+
* properties changed, which steps were added, removed or changed (and where inside
|
|
665
|
+
* each changed step), and whether the steps they share run in a different order.
|
|
666
|
+
* Steps are matched by `id`, so moving a step reports as `reordered`, not as a
|
|
667
|
+
* removal plus an addition.
|
|
668
|
+
*/
|
|
669
|
+
type ManifestDiff = {
|
|
670
|
+
readonly changedProperties: readonly string[];
|
|
671
|
+
readonly steps: {
|
|
672
|
+
readonly added: readonly string[];
|
|
673
|
+
readonly removed: readonly string[];
|
|
674
|
+
readonly changed: readonly string[];
|
|
675
|
+
/** For each changed step, the paths inside it that differ, such as `input.channel` or `tools[1]`. */
|
|
676
|
+
readonly changedFields: Readonly<Record<string, readonly string[]>>;
|
|
677
|
+
/** Steps run in order, so a reshuffle of unchanged steps still changes behaviour. */
|
|
678
|
+
readonly reordered: boolean;
|
|
679
|
+
};
|
|
680
|
+
readonly isEmpty: boolean;
|
|
681
|
+
};
|
|
682
|
+
export declare function diffManifests(before: unknown, after: unknown): ManifestDiff;
|
|
683
|
+
//#endregion
|
|
684
|
+
//#region src/drafts/submitted-manifest.d.ts
|
|
685
|
+
/**
|
|
686
|
+
* A manifest the way the API hands a published one back: parsed as the API
|
|
687
|
+
* parses a draft it saves, which fills in defaults such as `overlap` and drops
|
|
688
|
+
* keys the schema does not know, then migrated, as the API migrates a published
|
|
689
|
+
* manifest on every read. A manifest that does not parse is only migrated.
|
|
690
|
+
*/
|
|
691
|
+
export declare function normaliseManifest(manifest: unknown): unknown;
|
|
692
|
+
//#endregion
|
|
693
|
+
//#region src/drafts/publish-draft.d.ts
|
|
694
|
+
/** Everything a caller should know before deciding to publish. */
|
|
695
|
+
type PublishSummary = {
|
|
696
|
+
readonly draftId: string;
|
|
697
|
+
readonly name: string;
|
|
698
|
+
readonly scope: {
|
|
699
|
+
readonly kind: 'personal';
|
|
700
|
+
} | {
|
|
701
|
+
readonly kind: 'workspace';
|
|
702
|
+
readonly workspaceId: string;
|
|
703
|
+
/** What the automation will be once published; an edit keeps what it has. */
|
|
704
|
+
readonly visibility: AutomationDto['visibility'];
|
|
705
|
+
};
|
|
706
|
+
readonly target: DraftTarget;
|
|
707
|
+
/** Whether it will be enabled once published: a new one starts enabled, an edit keeps its state. */
|
|
708
|
+
readonly enabled: boolean;
|
|
709
|
+
readonly validation: {
|
|
710
|
+
readonly state: 'incomplete' | 'ready';
|
|
711
|
+
readonly issues: readonly string[];
|
|
712
|
+
};
|
|
713
|
+
readonly connections: {
|
|
714
|
+
readonly isValid: boolean;
|
|
715
|
+
readonly connected: readonly Pick<AutomationDraftConnectionDto, 'connectorId' | 'connectionType' | 'connectionId'>[];
|
|
716
|
+
readonly missing: AutomationDraftConnectionValidationDto['missing'];
|
|
717
|
+
};
|
|
718
|
+
/** The schedule in words, or null when the draft runs on something else. */
|
|
719
|
+
readonly schedule: string | null;
|
|
720
|
+
/**
|
|
721
|
+
* Where its runs will stop to ask the user, so they can be told before it
|
|
722
|
+
* goes live that it will wait on them.
|
|
723
|
+
*/
|
|
724
|
+
readonly questions: readonly AskStepSummary[];
|
|
725
|
+
/** How the draft differs from the published automation; null for a new one. */
|
|
726
|
+
readonly diff: ManifestDiff | null;
|
|
727
|
+
/** How the saved draft differs from the manifest the caller submitted; null when none was given. */
|
|
728
|
+
readonly submittedDiff: ManifestDiff | null;
|
|
729
|
+
};
|
|
730
|
+
/**
|
|
731
|
+
* What the published manifest was compared with: the manifest the caller
|
|
732
|
+
* submitted, which also catches what the API changed while saving it, or else
|
|
733
|
+
* the saved draft.
|
|
734
|
+
*/
|
|
735
|
+
type VerificationBasis = 'submitted' | 'draft';
|
|
736
|
+
/**
|
|
737
|
+
* The published manifest compared with `against`. `unavailable` means reading
|
|
738
|
+
* the automation back failed after the publish succeeded.
|
|
739
|
+
*/
|
|
740
|
+
type PublishVerification = {
|
|
741
|
+
readonly status: 'matched';
|
|
742
|
+
readonly against: VerificationBasis;
|
|
743
|
+
} | {
|
|
744
|
+
readonly status: 'mismatched';
|
|
745
|
+
readonly against: VerificationBasis;
|
|
746
|
+
readonly mismatch: ManifestDiff;
|
|
747
|
+
} | {
|
|
748
|
+
readonly status: 'unavailable';
|
|
749
|
+
readonly reason: string;
|
|
750
|
+
};
|
|
751
|
+
type PublishResult = {
|
|
752
|
+
readonly action: 'publish_preview';
|
|
753
|
+
readonly summary: PublishSummary;
|
|
754
|
+
} | {
|
|
755
|
+
readonly action: 'published';
|
|
756
|
+
readonly summary: PublishSummary;
|
|
757
|
+
readonly automation: AutomationDto;
|
|
758
|
+
readonly verification: PublishVerification;
|
|
759
|
+
};
|
|
760
|
+
/**
|
|
761
|
+
* Publishes a draft, or previews what publishing would do.
|
|
762
|
+
*
|
|
763
|
+
* The preview gathers what the API would otherwise only reveal by failing:
|
|
764
|
+
* validation issues, unbound connections, the schedule in words and, for an
|
|
765
|
+
* edit draft, how it differs from the published automation. A confirmed publish
|
|
766
|
+
* lets the API be the judge, then reads the automation back and checks that
|
|
767
|
+
* what was published is what the draft held, or what `submittedManifest` held
|
|
768
|
+
* when the caller passes the manifest it created or updated the draft with.
|
|
769
|
+
* Once finalize succeeds the draft is gone, so a failed read-back is reported
|
|
770
|
+
* as unverified, never as a failure.
|
|
771
|
+
*/
|
|
772
|
+
export declare function publishDraft(draftApi: DraftApi, { draftId, confirmed, submittedManifest }: {
|
|
773
|
+
draftId: string;
|
|
774
|
+
confirmed: boolean;
|
|
775
|
+
submittedManifest?: unknown;
|
|
776
|
+
}): Promise<PublishResult>;
|
|
777
|
+
/**
|
|
778
|
+
* What publishing a draft would do, with the draft as it was read for it. With
|
|
779
|
+
* `submittedManifest`, it also says how the saved draft differs from it.
|
|
780
|
+
*/
|
|
781
|
+
export declare function previewPublish(draftApi: DraftApi, draftId: string, submittedManifest?: unknown): Promise<{
|
|
782
|
+
summary: PublishSummary;
|
|
783
|
+
detail: AutomationDraftWithValidationDto;
|
|
784
|
+
}>;
|
|
785
|
+
/** The manifest's schedule trigger in words, or null when it has none. */
|
|
786
|
+
export declare function describeSchedule(manifest: unknown): string | null;
|
|
787
|
+
//#endregion
|
|
788
|
+
//#region src/runs/poll-until-closed.d.ts
|
|
789
|
+
/** How a wait on a started run polls it, and for how long. */
|
|
790
|
+
type PollOptions<T> = {
|
|
791
|
+
readonly timeoutMs: number;
|
|
792
|
+
readonly pollIntervalsMs?: {
|
|
793
|
+
readonly first: number;
|
|
794
|
+
readonly max: number;
|
|
795
|
+
};
|
|
796
|
+
readonly requestGraceMs?: number;
|
|
797
|
+
/** Sees each state the run is read in, while it is still being waited for. */
|
|
798
|
+
readonly onPoll?: (run: T) => void;
|
|
799
|
+
/**
|
|
800
|
+
* Ends the wait early on a run that is still open but will not move until
|
|
801
|
+
* someone acts, such as one parked on a question. Asked after each read
|
|
802
|
+
* that finds the run open.
|
|
803
|
+
*/
|
|
804
|
+
readonly isParked?: (run: T, requestSignal: AbortSignal) => Promise<boolean>;
|
|
805
|
+
readonly signal: AbortSignal;
|
|
806
|
+
};
|
|
807
|
+
//#endregion
|
|
808
|
+
//#region src/drafts/draft-test.d.ts
|
|
809
|
+
export declare const DRAFT_TEST_OUTCOMES: readonly ["passed", "failed", "skipped", "cancelled", "timed_out"];
|
|
810
|
+
/** How a waited-for test run ended, from the caller's point of view. */
|
|
811
|
+
type DraftTestOutcome = (typeof DRAFT_TEST_OUTCOMES)[number];
|
|
812
|
+
/** A test run the API accepted, which goes on running whether or not anyone waits for it. */
|
|
813
|
+
type DraftTestStarted = {
|
|
814
|
+
readonly draftId: string;
|
|
815
|
+
readonly testRunId: string;
|
|
816
|
+
readonly trigger: DraftTestTrigger;
|
|
817
|
+
readonly connectorCalls: 'mocked';
|
|
818
|
+
readonly status: TestAutomationDraftResponse['status'];
|
|
819
|
+
};
|
|
820
|
+
type DraftTestFinished = {
|
|
821
|
+
readonly outcome: DraftTestOutcome;
|
|
822
|
+
readonly status: DraftTestRunDetailDto['status'];
|
|
823
|
+
readonly failedStep: DraftTestRunFailedStep | null;
|
|
824
|
+
/** The failed step's error, else why the run failed or was skipped. */
|
|
825
|
+
readonly error: string | null;
|
|
826
|
+
readonly result: DraftTestRunDetailDto['result'];
|
|
827
|
+
};
|
|
828
|
+
type DraftTestWaitOptions = Omit<PollOptions<DraftTestRunDetailDto>, 'isParked'>;
|
|
829
|
+
/**
|
|
830
|
+
* Starts a draft test run. The API's refusal to start one is rethrown as it
|
|
831
|
+
* came; `getDraftTestRequestError` reads its code.
|
|
832
|
+
*/
|
|
833
|
+
export declare function startDraftTest(draftApi: DraftApi, { draftId, request }: {
|
|
834
|
+
draftId: string;
|
|
835
|
+
request: TestAutomationDraftRequest;
|
|
836
|
+
}): Promise<DraftTestStarted>;
|
|
837
|
+
/**
|
|
838
|
+
* Polls a started test run until it ends or the timeout passes. A run that
|
|
839
|
+
* ends without passing is still a result, not an error: the caller decides
|
|
840
|
+
* what it means.
|
|
841
|
+
*/
|
|
842
|
+
export declare function waitForDraftTest(draftApi: DraftApi, { draftId, testRunId }: {
|
|
843
|
+
draftId: string;
|
|
844
|
+
testRunId: string;
|
|
845
|
+
}, options: DraftTestWaitOptions): Promise<DraftTestFinished>;
|
|
846
|
+
/** A number, or a string of digits, picks a trigger by position; any other string is a webhook event. */
|
|
847
|
+
export declare function toDraftTestTriggerSelector(value: number | string): DraftTestTriggerSelector;
|
|
848
|
+
//#endregion
|
|
849
|
+
//#region src/questions/questions.d.ts
|
|
850
|
+
/** One way to answer a question, and whether choosing it ends the run that asked. */
|
|
851
|
+
type QuestionOption = {
|
|
852
|
+
readonly label: string;
|
|
853
|
+
readonly value: string;
|
|
854
|
+
readonly endsRun: boolean;
|
|
855
|
+
};
|
|
856
|
+
/** A question an automation's `ask` step put to the user, and its answer once given. */
|
|
857
|
+
type QuestionSummary = {
|
|
858
|
+
readonly id: string;
|
|
859
|
+
readonly status: PromptNotificationStatus;
|
|
860
|
+
readonly question: string;
|
|
861
|
+
readonly details: string | null;
|
|
862
|
+
readonly options: readonly QuestionOption[];
|
|
863
|
+
/** The value of the chosen option, once answered. */
|
|
864
|
+
readonly answer: string | null;
|
|
865
|
+
readonly automationId: string | null;
|
|
866
|
+
readonly workspaceId: string | null;
|
|
867
|
+
readonly runId: string | null;
|
|
868
|
+
readonly stepId: string | null;
|
|
869
|
+
readonly askedAt: string;
|
|
870
|
+
/** When an unanswered question stops its run. */
|
|
871
|
+
readonly expiresAt: string | null;
|
|
872
|
+
readonly answeredAt: string | null;
|
|
873
|
+
};
|
|
874
|
+
type QuestionErrorCode =
|
|
875
|
+
/** The id names a notification that is not a question. */
|
|
876
|
+
'not_a_question' |
|
|
877
|
+
/** Nobody answered in time, so the run that asked has stopped. */
|
|
878
|
+
'expired' |
|
|
879
|
+
/** The question was answered with a different option. */
|
|
880
|
+
'already_answered' |
|
|
881
|
+
/** The choice matches none of the question's options. */
|
|
882
|
+
'unknown_option' |
|
|
883
|
+
/** The choice matches more than one option's label. */
|
|
884
|
+
'ambiguous_option';
|
|
885
|
+
/** A question that cannot take the answer given, with the reason in `code`. */
|
|
886
|
+
export declare class QuestionError extends Error {
|
|
887
|
+
readonly code: QuestionErrorCode;
|
|
888
|
+
readonly questionId: string;
|
|
889
|
+
constructor(code: QuestionErrorCode, message: string, questionId: string);
|
|
890
|
+
}
|
|
891
|
+
export declare function summarizeQuestion(prompt: PromptNotificationDto): QuestionSummary;
|
|
892
|
+
/**
|
|
893
|
+
* Every question still waiting on the user, oldest first, across both spaces.
|
|
894
|
+
* Questions belong to the user rather than a space, so there is no workspace
|
|
895
|
+
* binding; `automationId` narrows the list to one automation.
|
|
896
|
+
*/
|
|
897
|
+
export declare function listPendingQuestions(api: AutomationsApi, { automationId, signal }?: {
|
|
898
|
+
automationId?: string;
|
|
899
|
+
signal?: AbortSignal;
|
|
900
|
+
}): Promise<QuestionSummary[]>;
|
|
901
|
+
export declare function getQuestion(api: AutomationsApi, questionId: string, { signal }?: {
|
|
902
|
+
signal?: AbortSignal;
|
|
903
|
+
}): Promise<QuestionSummary>;
|
|
904
|
+
/** A run as far as finding its question goes: whether it is running, and its latest step. */
|
|
905
|
+
type QuestionRun = {
|
|
906
|
+
readonly id: string;
|
|
907
|
+
readonly automationId: string;
|
|
908
|
+
readonly status: string;
|
|
909
|
+
readonly steps: readonly {
|
|
910
|
+
readonly type: string;
|
|
911
|
+
}[];
|
|
912
|
+
};
|
|
913
|
+
/**
|
|
914
|
+
* The question a run is parked on, or null when it is not waiting. A parked run
|
|
915
|
+
* is running and its latest step is the ask, so any other run costs no request.
|
|
916
|
+
*/
|
|
917
|
+
export declare function findRunQuestion(api: AutomationsApi, run: QuestionRun, { signal }?: {
|
|
918
|
+
signal?: AbortSignal;
|
|
919
|
+
}): Promise<QuestionSummary | null>;
|
|
920
|
+
/**
|
|
921
|
+
* Like {@link findRunQuestion}, but null when the grant does not let the caller
|
|
922
|
+
* read questions, for a caller that only adds the question to a run it already
|
|
923
|
+
* has. Any other failure still throws, so an outage never reads as "not waiting".
|
|
924
|
+
*/
|
|
925
|
+
export declare function findRunQuestionIfReadable(api: AutomationsApi, run: QuestionRun, { signal }?: {
|
|
926
|
+
signal?: AbortSignal;
|
|
927
|
+
}): Promise<QuestionSummary | null>;
|
|
928
|
+
/** Whether a question request was refused by the grant, as from a login without the notifications scope. */
|
|
929
|
+
export declare function isQuestionReadRefused(error: unknown): boolean;
|
|
930
|
+
/**
|
|
931
|
+
* The option `choice` picks: its exact value, or failing that the one option
|
|
932
|
+
* whose value or label matches ignoring case, so both "approve" and "Approve"
|
|
933
|
+
* work.
|
|
934
|
+
*/
|
|
935
|
+
export declare function findQuestionOption(question: QuestionSummary, choice: string): QuestionOption;
|
|
936
|
+
/**
|
|
937
|
+
* The option an answer of `choice` would record, or a `QuestionError` when the
|
|
938
|
+
* question cannot take it. Repeating the answer already given is allowed: the
|
|
939
|
+
* API treats it as a retry and makes sure the run has received it.
|
|
940
|
+
*/
|
|
941
|
+
export declare function prepareAnswer(question: QuestionSummary, choice: string): QuestionOption;
|
|
942
|
+
/** Records `choice` as the answer, which lets the parked run continue or stop. */
|
|
943
|
+
export declare function answerQuestion(api: AutomationsApi, questionId: string, choice: string, { signal }?: {
|
|
944
|
+
signal?: AbortSignal;
|
|
945
|
+
}): Promise<{
|
|
946
|
+
question: QuestionSummary;
|
|
947
|
+
chosen: QuestionOption;
|
|
948
|
+
}>;
|
|
949
|
+
//#endregion
|
|
950
|
+
//#region src/runs/run-api.d.ts
|
|
951
|
+
/**
|
|
952
|
+
* The routes for starting and following an automation's runs, bound to one
|
|
953
|
+
* space so a caller dispatches on personal versus workspace once.
|
|
954
|
+
*/
|
|
955
|
+
type RunApi = {
|
|
956
|
+
/** The workspace the routes are bound to, or null for the personal space. */
|
|
957
|
+
readonly workspaceId: string | null;
|
|
958
|
+
readonly getAutomation: (automationId: string) => Promise<AutomationDto>;
|
|
959
|
+
/** Starts a run now. Undefined from an API that predates returning the run. */
|
|
960
|
+
readonly trigger: (automationId: string) => Promise<TriggerAutomationResponse | undefined>;
|
|
961
|
+
readonly getRun: (automationId: string, runId: string, args?: GetAutomationRunDetailsArgs,
|
|
962
|
+
/** Replaces the bound signal for this request, to bound it more tightly. */
|
|
963
|
+
requestSignal?: AbortSignal) => Promise<AutomationRunDetailDto>;
|
|
964
|
+
/**
|
|
965
|
+
* The question the run is parked on, or null. Questions belong to the user
|
|
966
|
+
* rather than a space, so this reads the same route whatever the binding.
|
|
967
|
+
*/
|
|
968
|
+
readonly findQuestion: (run: AutomationRunDetailDto, requestSignal?: AbortSignal) => Promise<QuestionSummary | null>;
|
|
969
|
+
};
|
|
970
|
+
/** Binds the run routes to the personal space (`null`) or a workspace. */
|
|
971
|
+
export declare function bindRunApi(api: AutomationsApi, workspaceId: string | null, { signal }?: {
|
|
972
|
+
signal?: AbortSignal;
|
|
973
|
+
}): RunApi;
|
|
974
|
+
//#endregion
|
|
975
|
+
//#region src/runs/run-wait.d.ts
|
|
976
|
+
export declare const RUN_OUTCOMES: readonly ["completed", "failed", "skipped", "cancelled", "timed_out"];
|
|
977
|
+
/** How a waited-for run ended, from the caller's point of view. */
|
|
978
|
+
type RunOutcome = (typeof RUN_OUTCOMES)[number];
|
|
979
|
+
/** The first step of a run that failed, with the error its activity reported. */
|
|
980
|
+
type RunFailedStep = {
|
|
981
|
+
readonly stepId: string;
|
|
982
|
+
readonly description: string;
|
|
983
|
+
readonly error: string | null;
|
|
984
|
+
};
|
|
985
|
+
type RunFinished = {
|
|
986
|
+
readonly outcome: RunOutcome;
|
|
987
|
+
readonly status: AutomationRunDetailDto['status'];
|
|
988
|
+
readonly failedStep: RunFailedStep | null;
|
|
989
|
+
/** The failed step's error, else why the run failed or was skipped. */
|
|
990
|
+
readonly error: string | null;
|
|
991
|
+
readonly result: AutomationRunDetailDto['result'];
|
|
992
|
+
};
|
|
993
|
+
/** A run that stopped at an `ask` step and waits for the user to answer. */
|
|
994
|
+
type RunWaitingForAnswer = {
|
|
995
|
+
readonly outcome: 'waiting_for_answer';
|
|
996
|
+
readonly status: AutomationRunDetailDto['status'];
|
|
997
|
+
readonly question: QuestionSummary;
|
|
998
|
+
};
|
|
999
|
+
type RunWaitOptions = Omit<PollOptions<AutomationRunDetailDto>, 'isParked'>;
|
|
1000
|
+
/**
|
|
1001
|
+
* Polls a started run until it ends or the timeout passes. A run that ends
|
|
1002
|
+
* without completing is still a result, not an error: the caller decides what
|
|
1003
|
+
* it means.
|
|
1004
|
+
*/
|
|
1005
|
+
export declare function waitForRun(runApi: RunApi, { automationId, runId }: {
|
|
1006
|
+
automationId: string;
|
|
1007
|
+
runId: string;
|
|
1008
|
+
}, options: RunWaitOptions): Promise<RunFinished>;
|
|
1009
|
+
/**
|
|
1010
|
+
* Like {@link waitForRun}, but stops as soon as the run parks on a question,
|
|
1011
|
+
* since it will not move again until someone answers. A question is only
|
|
1012
|
+
* looked up while the run's latest step is the ask (see `findRunQuestion`). A
|
|
1013
|
+
* lookup that fails reads as not parked, so the wait carries on rather than
|
|
1014
|
+
* failing; once the grant refuses one, the wait stops looking.
|
|
1015
|
+
*/
|
|
1016
|
+
export declare function waitForRunOrQuestion(runApi: RunApi, { automationId, runId }: {
|
|
1017
|
+
automationId: string;
|
|
1018
|
+
runId: string;
|
|
1019
|
+
}, options: RunWaitOptions): Promise<RunFinished | RunWaitingForAnswer>;
|
|
1020
|
+
//#endregion
|
|
1021
|
+
//#region src/drafts/conversation-draft.d.ts
|
|
1022
|
+
/**
|
|
1023
|
+
* The newest draft a chat conversation authored, or null. The list filters by
|
|
1024
|
+
* conversation, edit drafts included; an API older than that filter returns the
|
|
1025
|
+
* newest drafts instead, so the match is still checked here.
|
|
1026
|
+
*/
|
|
1027
|
+
export declare function findConversationDraftId(api: AutomationsApi, { conversationId, workspaceId, signal }: {
|
|
1028
|
+
conversationId: string;
|
|
1029
|
+
workspaceId: string | null;
|
|
1030
|
+
signal?: AbortSignal;
|
|
1031
|
+
}): Promise<string | null>;
|
|
1032
|
+
//#endregion
|
|
1033
|
+
//#region src/drafts/draft-workflow-error.d.ts
|
|
1034
|
+
type DraftWorkflowErrorCode =
|
|
1035
|
+
/** The manifest is not even a partial manifest; nothing was sent. */
|
|
1036
|
+
'manifest_invalid' |
|
|
1037
|
+
/** The automation already has an open draft, named by `draftId`. */
|
|
1038
|
+
'draft_conflict' |
|
|
1039
|
+
/** An edit draft was opened (`draftId`), but the API refused the manifest. */
|
|
1040
|
+
'draft_manifest_rejected' |
|
|
1041
|
+
/** The API refused to publish a draft that is not ready. */
|
|
1042
|
+
'draft_not_ready' |
|
|
1043
|
+
/** A connection was chosen for a connector the draft does not use. */
|
|
1044
|
+
'connector_not_required';
|
|
1045
|
+
/**
|
|
1046
|
+
* A draft workflow step the caller can recover from. `draftId` names the draft
|
|
1047
|
+
* the caller should act on next, which for a conflict is the one already open.
|
|
1048
|
+
*/
|
|
1049
|
+
export declare class DraftWorkflowError extends Error {
|
|
1050
|
+
readonly code: DraftWorkflowErrorCode;
|
|
1051
|
+
readonly draftId: string | undefined;
|
|
1052
|
+
readonly automationId: string | undefined;
|
|
1053
|
+
constructor(code: DraftWorkflowErrorCode, message: string, options?: {
|
|
1054
|
+
draftId?: string;
|
|
1055
|
+
automationId?: string;
|
|
1056
|
+
cause?: unknown;
|
|
1057
|
+
});
|
|
1058
|
+
}
|
|
1059
|
+
//#endregion
|
|
1060
|
+
export { type AskStepSummary, type AutomationConnectionSummary, AutomationConnectionsClient, AutomationDraftConnectionsClient, AutomationDraftsClient, type AutomationListItem, AutomationRunsClient, type AutomationSummary, AutomationsApi, type AutomationsApiOptions, AutomationsClient, type BillingPortalUrlArgs, type BoundConnection, type CandidateConnection, ChatClient, type ConnectionSelection, ConnectionsClient, type ConnectorCapability, type ConnectorConnectionSummary, type ConnectorListOptions, type ConnectorListResult, ConnectorsClient, type CreateAutomationDraftOptions, type CreateConnectionArgs, type CreateWebhookEventSubscriptionArgs, type CreateWorkspaceAutomationDraftOptions, type CreationScope, DEFAULT_BASE_URL, DEFAULT_TODOIST_BASE_URL, type DeleteConnectionOptions, type DraftApi, type DraftChangeResult, type DraftConnectResult, type DraftListItem, type DraftTarget, type DraftTestFinished, type DraftTestOutcome, type DraftTestRunSummary, type DraftTestStarted, type DraftTestWaitOptions, type DraftWorkflowErrorCode, type EnrichedConnector, type ListAutomationDraftsArgs, type ListAutomationRunsArgs, type ListAutomationsArgs, type ListChatConversationsArgs, type ListConnectionsArgs, type ListConnectorActionsArgs, type ListConnectorsArgs, type ListNotificationsArgs, type ListWebhookEventDeliveriesArgs, type ListWebhookEventSubscriptionsArgs, type ListWorkspaceAutomationDraftsArgs, type ListWorkspaceAutomationsArgs, type ManifestDiff, type ManifestMetadata, NotificationsClient, type PartialManifestInput, type PublishResult, type PublishSummary, type PublishVerification, PushSubscriptionsClient, type QuestionErrorCode, type QuestionOption, type QuestionRun, type QuestionSummary, type ReadTransactionsArgs, type ReadUsageSummaryArgs, type RequestOptions, type RunApi, type RunFailedStep, type RunFinished, type RunOutcome, type RunSummary, type RunWaitOptions, type RunWaitingForAnswer, type StartTopUpArgs, type TemplateConnector, type TemplateDetail, type TemplateFilters, type TemplateStep, type TemplateSummary, type TemplateTrigger, type TriggerListItem, USAGE_BILLING_TOP_UP_REFUSAL_TAGS, type UnresolvedConnection, type UpdateWebhookEventSubscriptionArgs, UsageBillingClient, type UsageBillingTopUpRefusal, type UsageBillingTopUpRefusalTag, UserSettingsClient, type VerificationBasis, WebhookEventSubscriptionsClient, WebhookSubscriptionsClient, WorkspaceAutomationDraftConnectionsClient, WorkspaceAutomationDraftsClient, WorkspaceAutomationRunsClient, WorkspaceAutomationsClient, WorkspaceChatClient, type WorkspaceCreateOptions, WorkspacesClient, connectionAccountLabel, describeCandidateConnection, getConnectionInUseError, getConnectorActionError, getDraftNotReadyError, getDraftTestRequestError, getOpenDraftConflictError, getUsageBillingTopUpRefusal, isKnownUsageBillingTopUpRefusalTag, isUsageBillingAccountNotFoundError, isUsageBillingTopUpPlanRequiredError, isUsageBillingTopUpUnavailableError, mcpServerHost };
|