@macro-inc/sdk 0.2.2 → 0.4.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.
Files changed (175) hide show
  1. package/README.md +177 -3
  2. package/dist/{chunk-OGE7WXJE.js → chunk-AZJUIUIV.js} +177 -23
  3. package/dist/{chunk-PRUFPW3B.js → chunk-G43PLP2U.js} +144 -0
  4. package/dist/{chunk-7LVVPVNT.js → chunk-K4G5VO4P.js} +76 -1
  5. package/dist/{chunk-PAAFJYGO.js → chunk-PPR7IWZ7.js} +77 -51
  6. package/dist/{chunk-QVBNNMQS.js → chunk-PTX2RV2N.js} +169 -20
  7. package/dist/{chunk-SUINKDXF.js → chunk-PZPTJI6F.js} +42 -0
  8. package/dist/{chunk-7YJ6Y7HJ.js → chunk-XFA7NCJ5.js} +207 -0
  9. package/dist/{chunk-ZQXOHNDB.js → chunk-ZLBDES7U.js} +789 -12
  10. package/dist/generated/agent-fold/index.d.ts +4332 -0
  11. package/dist/generated/agent-fold/index.js +0 -0
  12. package/dist/generated/agent-harness/index.d.ts +1 -1
  13. package/dist/generated/agent-harness/index.js +1 -1
  14. package/dist/generated/agent-harness/sdk.gen.d.ts +83 -9
  15. package/dist/generated/agent-harness/types.gen.d.ts +1504 -160
  16. package/dist/generated/agent-reviews/index.d.ts +893 -0
  17. package/dist/generated/agent-reviews/index.js +0 -0
  18. package/dist/generated/auth/index.d.ts +1 -1
  19. package/dist/generated/auth/index.js +1 -1
  20. package/dist/generated/auth/sdk.gen.d.ts +108 -2
  21. package/dist/generated/auth/types.gen.d.ts +799 -6
  22. package/dist/generated/calendar/index.d.ts +1 -1
  23. package/dist/generated/calendar/index.js +1 -1
  24. package/dist/generated/calendar/sdk.gen.d.ts +63 -1
  25. package/dist/generated/calendar/types.gen.d.ts +1234 -5
  26. package/dist/generated/cognition/index.d.ts +1 -1
  27. package/dist/generated/cognition/index.js +1 -1
  28. package/dist/generated/cognition/sdk.gen.d.ts +85 -20
  29. package/dist/generated/cognition/types.gen.d.ts +1040 -121
  30. package/dist/generated/connection/index.d.ts +1 -1
  31. package/dist/generated/connection/index.js +15 -0
  32. package/dist/generated/connection/sdk.gen.d.ts +6 -1
  33. package/dist/generated/connection/types.gen.d.ts +18 -1
  34. package/dist/generated/email/index.d.ts +1 -1
  35. package/dist/generated/email/index.js +1 -1
  36. package/dist/generated/email/sdk.gen.d.ts +44 -2
  37. package/dist/generated/email/types.gen.d.ts +475 -10
  38. package/dist/generated/notification/index.d.ts +1 -1
  39. package/dist/generated/notification/index.js +1 -1
  40. package/dist/generated/notification/sdk.gen.d.ts +29 -21
  41. package/dist/generated/notification/types.gen.d.ts +267 -73
  42. package/dist/generated/properties/index.d.ts +1 -1
  43. package/dist/generated/properties/types.gen.d.ts +21 -1
  44. package/dist/generated/scheduled-action/index.d.ts +1 -1
  45. package/dist/generated/scheduled-action/index.js +1 -1
  46. package/dist/generated/scheduled-action/sdk.gen.d.ts +8 -1
  47. package/dist/generated/scheduled-action/types.gen.d.ts +669 -19
  48. package/dist/generated/search/index.d.ts +1 -1
  49. package/dist/generated/search/types.gen.d.ts +87 -7
  50. package/dist/generated/static-files/types.gen.d.ts +6 -0
  51. package/dist/generated/storage/index.d.ts +1 -1
  52. package/dist/generated/storage/index.js +1 -1
  53. package/dist/generated/storage/sdk.gen.d.ts +376 -13
  54. package/dist/generated/storage/types.gen.d.ts +12038 -5562
  55. package/dist/src/entities/account-managers/grant.d.ts +39 -0
  56. package/dist/src/entities/account-managers/namespace.d.ts +17 -0
  57. package/dist/src/entities/agent-sessions/activity.d.ts +39 -0
  58. package/dist/src/entities/agent-sessions/agent-session.d.ts +148 -6
  59. package/dist/src/entities/agent-sessions/code-execution.d.ts +5 -0
  60. package/dist/src/entities/agent-sessions/namespace.d.ts +54 -4
  61. package/dist/src/entities/agent-sessions/origin.d.ts +94 -0
  62. package/dist/src/entities/agent-sessions/review.d.ts +18 -62
  63. package/dist/src/entities/agent-sessions/view.d.ts +11 -0
  64. package/dist/src/entities/agents/namespace.d.ts +11 -2
  65. package/dist/src/entities/ai/namespace.d.ts +5 -1
  66. package/dist/src/entities/api-keys/namespace.d.ts +5 -1
  67. package/dist/src/entities/bots/bot.d.ts +108 -0
  68. package/dist/src/entities/bots/namespace.d.ts +17 -4
  69. package/dist/src/entities/bots/token.d.ts +34 -0
  70. package/dist/src/entities/calendar/booking-link.d.ts +49 -0
  71. package/dist/src/entities/calendar/booking-namespace.d.ts +130 -0
  72. package/dist/src/entities/calendar/booking-namespace.test.d.ts +1 -0
  73. package/dist/src/entities/calendar/booking.d.ts +77 -0
  74. package/dist/src/entities/calendar/calendar.d.ts +11 -4
  75. package/dist/src/entities/calendar/create-confirmed.test.d.ts +1 -0
  76. package/dist/src/entities/calendar/event.d.ts +104 -3
  77. package/dist/src/entities/calendar/namespace.d.ts +151 -7
  78. package/dist/src/entities/calendar/namespace.test.d.ts +1 -0
  79. package/dist/src/entities/calls/call-record.d.ts +34 -4
  80. package/dist/src/entities/calls/connection.d.ts +53 -0
  81. package/dist/src/entities/calls/errors.d.ts +15 -0
  82. package/dist/src/entities/calls/namespace.d.ts +21 -1
  83. package/dist/src/entities/calls/participant.d.ts +22 -0
  84. package/dist/src/entities/channels/access-request.d.ts +34 -0
  85. package/dist/src/entities/channels/channel.d.ts +47 -1
  86. package/dist/src/entities/channels/namespace.d.ts +21 -5
  87. package/dist/src/entities/channels/namespace.test.d.ts +1 -0
  88. package/dist/src/entities/channels/post.d.ts +14 -3
  89. package/dist/src/entities/channels/thread.d.ts +10 -1
  90. package/dist/src/entities/chats/chat.d.ts +7 -1
  91. package/dist/src/entities/chats/namespace.d.ts +14 -1
  92. package/dist/src/entities/connected-apps/connected-app.d.ts +107 -0
  93. package/dist/src/entities/connected-apps/connector.d.ts +56 -0
  94. package/dist/src/entities/connected-apps/namespace.d.ts +74 -0
  95. package/dist/src/entities/crm/company.d.ts +7 -3
  96. package/dist/src/entities/crm/contact.d.ts +4 -4
  97. package/dist/src/entities/crm/namespace.d.ts +34 -1
  98. package/dist/src/entities/crm/pipeline.d.ts +43 -2
  99. package/dist/src/entities/databases/database.d.ts +17 -0
  100. package/dist/src/entities/databases/namespace.d.ts +56 -0
  101. package/dist/src/entities/documents/ai-edit.d.ts +52 -0
  102. package/dist/src/entities/documents/document.d.ts +244 -5
  103. package/dist/src/entities/documents/namespace.d.ts +89 -4
  104. package/dist/src/entities/documents/office-files.d.ts +47 -0
  105. package/dist/src/entities/email/draft.d.ts +36 -7
  106. package/dist/src/entities/email/message.d.ts +99 -3
  107. package/dist/src/entities/email/namespace.d.ts +47 -4
  108. package/dist/src/entities/email/namespace.test.d.ts +1 -0
  109. package/dist/src/entities/email/thread.d.ts +55 -3
  110. package/dist/src/entities/entity-mentions/namespace.d.ts +5 -1
  111. package/dist/src/entities/external-chat/chat.d.ts +105 -0
  112. package/dist/src/entities/external-chat/message.d.ts +54 -0
  113. package/dist/src/entities/external-chat/namespace.d.ts +18 -0
  114. package/dist/src/entities/external-chat/participant.d.ts +28 -0
  115. package/dist/src/entities/external-chat/send.d.ts +32 -0
  116. package/dist/src/entities/external-chat/upload.d.ts +25 -0
  117. package/dist/src/entities/favorites/namespace.d.ts +5 -1
  118. package/dist/src/entities/foreign/namespace.d.ts +3 -0
  119. package/dist/src/entities/forms/form.d.ts +17 -2
  120. package/dist/src/entities/forms/namespace.d.ts +5 -1
  121. package/dist/src/entities/github-pull-requests/namespace.d.ts +5 -1
  122. package/dist/src/entities/harnesses/harness.d.ts +9 -0
  123. package/dist/src/entities/harnesses/namespace.d.ts +5 -1
  124. package/dist/src/entities/images/image.d.ts +77 -0
  125. package/dist/src/entities/images/namespace.d.ts +48 -0
  126. package/dist/src/entities/images/namespace.test.d.ts +1 -0
  127. package/dist/src/entities/initiatives/initiative.d.ts +12 -1
  128. package/dist/src/entities/initiatives/namespace.d.ts +15 -2
  129. package/dist/src/entities/me/namespace.d.ts +43 -0
  130. package/dist/src/entities/meetings/meeting.d.ts +5 -0
  131. package/dist/src/entities/meetings/namespace.d.ts +5 -1
  132. package/dist/src/entities/messages/thread.d.ts +1 -1
  133. package/dist/src/entities/notifications/namespace.d.ts +3 -0
  134. package/dist/src/entities/pins/namespace.d.ts +5 -1
  135. package/dist/src/entities/projects/namespace.d.ts +4 -1
  136. package/dist/src/entities/projects/project.d.ts +9 -1
  137. package/dist/src/entities/properties/namespace.d.ts +2 -0
  138. package/dist/src/entities/referrals/namespace.d.ts +33 -0
  139. package/dist/src/entities/routines/namespace.d.ts +42 -2
  140. package/dist/src/entities/routines/routine.d.ts +84 -5
  141. package/dist/src/entities/search/namespace.d.ts +65 -0
  142. package/dist/src/entities/{search.d.ts → search/options.d.ts} +8 -2
  143. package/dist/src/entities/search/types.d.ts +90 -0
  144. package/dist/src/entities/sharing/access.d.ts +14 -0
  145. package/dist/src/entities/tasks/namespace.d.ts +42 -3
  146. package/dist/src/entities/tasks/task.d.ts +47 -6
  147. package/dist/src/entities/teams/invite.d.ts +30 -0
  148. package/dist/src/entities/teams/namespace.d.ts +3 -0
  149. package/dist/src/entities/teams/team.d.ts +37 -0
  150. package/dist/src/entities/unfurls/namespace.d.ts +5 -1
  151. package/dist/src/entities/users/namespace.d.ts +9 -0
  152. package/dist/src/entities/users/user.d.ts +8 -0
  153. package/dist/src/entities/web/namespace.d.ts +61 -0
  154. package/dist/src/entities/web/namespace.test.d.ts +1 -0
  155. package/dist/src/entities/webhooks/namespace.d.ts +2 -0
  156. package/dist/src/entities/whatsapp/account.d.ts +20 -0
  157. package/dist/src/entities/whatsapp/chat.d.ts +54 -0
  158. package/dist/src/entities/whatsapp/namespace.d.ts +23 -0
  159. package/dist/src/entities/workspace/items.d.ts +7 -0
  160. package/dist/src/entities/workspace/namespace.d.ts +14 -9
  161. package/dist/src/entities/workspace/query.d.ts +23 -0
  162. package/dist/src/entities/workspace/types.d.ts +6 -3
  163. package/dist/src/events/hydrate/agentSession.d.ts +1 -1
  164. package/dist/src/events/hydrate/call.d.ts +101 -0
  165. package/dist/src/events/hydrate/channel.d.ts +8 -1
  166. package/dist/src/events/hydrate/document.d.ts +1 -1
  167. package/dist/src/events/hydrate/message.d.ts +1 -1
  168. package/dist/src/events/types.d.ts +2 -1
  169. package/dist/src/macro.d.ts +73 -4
  170. package/dist/src/macro.js +8235 -3701
  171. package/dist/src/mentions.d.ts +6 -1
  172. package/dist/src/utils/activity.d.ts +23 -2
  173. package/dist/src/utils/index.d.ts +1 -1
  174. package/dist/src/utils/unwrap.d.ts +27 -2
  175. package/package.json +2 -2
@@ -2,22 +2,36 @@ export type ClientOptions = {
2
2
  baseUrl: `${string}://${string}` | (string & {});
3
3
  };
4
4
  /**
5
- * Canonical client configuration. Ownership and execution state are server-owned.
5
+ * Client configuration, the create body. Ownership and execution state are
6
+ * server-owned.
6
7
  */
7
8
  export type ActionConfiguration = {
9
+ /**
10
+ * What the routine is for, in the owner's words; empty when unset.
11
+ */
12
+ description?: string;
8
13
  enabled: boolean;
9
14
  kind: ActionKind;
10
15
  name: string;
16
+ /**
17
+ * Omitted by clients that predate the setting; runs then start unlisted.
18
+ */
19
+ run_visibility?: RunVisibility;
11
20
  task: {
12
21
  [key: string]: unknown;
13
22
  };
14
23
  trigger: ActionTrigger;
15
24
  };
16
25
  /**
17
- * Canonical configuration replacement. Activation has its own endpoint, so
18
- * omitting `enabled` keeps the stored value.
26
+ * Configuration replacement, the update body. Activation has its own endpoint, so
27
+ * omitting `enabled` keeps the stored value; omitting `run_visibility` or
28
+ * `description` keeps them too, so clients that predate them do not reset them.
19
29
  */
20
30
  export type ActionConfigurationUpdate = {
31
+ /**
32
+ * An empty string clears it.
33
+ */
34
+ description?: string | null;
21
35
  /**
22
36
  * Still sent by clients deployed before the activation endpoint.
23
37
  *
@@ -26,6 +40,7 @@ export type ActionConfigurationUpdate = {
26
40
  enabled?: boolean | null;
27
41
  kind: ActionKind;
28
42
  name: string;
43
+ run_visibility?: null | RunVisibility;
29
44
  task: {
30
45
  [key: string]: unknown;
31
46
  };
@@ -58,20 +73,57 @@ export type ActionTrigger = {
58
73
  } | {
59
74
  filters: EventFilters;
60
75
  type: 'events';
76
+ } | {
77
+ at: string;
78
+ type: 'once';
61
79
  } | {
62
80
  triggers: RoutineTriggers;
63
81
  type: 'multiple';
64
82
  };
83
+ /**
84
+ * One Pipedream app an agent lists under [`AgentMcpServers::Selected`].
85
+ *
86
+ * Only the catalog identity is stored. Whether a given person has connected
87
+ * the app is theirs, resolved at call time by the egress proxy, never here.
88
+ */
89
+ export type AgentMcpServer = {
90
+ /**
91
+ * Pipedream app slug, e.g. `linear`.
92
+ */
93
+ app_slug: string;
94
+ /**
95
+ * Display name, e.g. `Linear`.
96
+ */
97
+ server_name: string;
98
+ };
99
+ /**
100
+ * The single agent task: how routines were stored before they had steps,
101
+ * and still how a routine that is only an agent is saved.
102
+ */
65
103
  export type AgentTask = {
66
104
  agent?: null | AgentTaskAgent;
105
+ /**
106
+ * Apps the routine requires on top of the agent's own. The owner must
107
+ * have each one connected to save the routine and for it to run.
108
+ */
109
+ mcp_servers?: Array<AgentMcpServer>;
67
110
  model?: null | RoutineModelId;
111
+ /**
112
+ * Instructions placed before the user's.
113
+ */
68
114
  prompt: string;
115
+ /**
116
+ * What the agent should do.
117
+ */
69
118
  user_prompt: string;
70
119
  };
71
120
  /**
72
121
  * A persona selection, independent of its runtime and current default model.
73
122
  */
74
123
  export type AgentTaskAgent = {
124
+ /**
125
+ * The agent's bot id.
126
+ */
75
127
  bot_id: string;
76
128
  };
77
129
  /**
@@ -88,6 +140,39 @@ export type AiAdmissionErrorBody = {
88
140
  */
89
141
  error: string;
90
142
  };
143
+ /**
144
+ * One time a routine's code was brought to a new SDK.
145
+ */
146
+ export type CodeUpgrade = {
147
+ createdAt: string;
148
+ /**
149
+ * The SDK the code was checked against before; none when it never was.
150
+ */
151
+ fromSdk?: string | null;
152
+ id: string;
153
+ outcome: UpgradeOutcome;
154
+ /**
155
+ * The task before.
156
+ */
157
+ previousTask: {
158
+ [key: string]: unknown;
159
+ };
160
+ /**
161
+ * Why the routine needs its owner.
162
+ */
163
+ reason?: string | null;
164
+ /**
165
+ * The saved rewrite, or the rewrite that failed its checks.
166
+ */
167
+ task?: {
168
+ [key: string]: unknown;
169
+ } | null;
170
+ /**
171
+ * The SDK it was brought to.
172
+ */
173
+ toSdk: string;
174
+ updatedAt: string;
175
+ };
91
176
  /**
92
177
  * Why an event-triggered run was skipped before it started.
93
178
  */
@@ -101,9 +186,102 @@ export type ConditionResult = {
101
186
  status: 'unavailable';
102
187
  };
103
188
  /**
104
- * Exactly one representation is accepted, even if mixed fields agree or are null.
189
+ * What AI drafted, or why it couldn't.
105
190
  */
106
- export type CreateScheduledAction = ActionConfiguration | LegacyActionConfiguration;
191
+ export type Draft = (DraftedRoutine & {
192
+ outcome: 'routine';
193
+ }) | (DraftedStep & {
194
+ outcome: 'step';
195
+ }) | {
196
+ message: string;
197
+ outcome: 'failed';
198
+ };
199
+ /**
200
+ * What the drafter may write, and the person's workspace by name and id.
201
+ */
202
+ export type DraftContext = {
203
+ /**
204
+ * The model Ask AI steps it writes run on.
205
+ */
206
+ agentModel: string;
207
+ /**
208
+ * Whether it may write code steps; otherwise it writes Ask AI steps.
209
+ * Changing a code step needs no permission.
210
+ */
211
+ code?: boolean;
212
+ /**
213
+ * Whether triggers may ask AI a yes/no question before a run. This host
214
+ * must also be able to answer it.
215
+ */
216
+ conditions?: boolean;
217
+ /**
218
+ * IANA time zone schedules are written in, e.g. `America/New_York`.
219
+ */
220
+ timezone: string;
221
+ workspace?: Workspace;
222
+ };
223
+ /**
224
+ * What to draft.
225
+ */
226
+ export type DraftRequest = {
227
+ description: string;
228
+ type: 'routine';
229
+ } | {
230
+ description: string;
231
+ kind?: null | StepKind;
232
+ routine: RoutineSoFar;
233
+ type: 'add_step';
234
+ } | {
235
+ index: number;
236
+ instruction: string;
237
+ routine: RoutineSoFar;
238
+ type: 'change_step';
239
+ };
240
+ /**
241
+ * What to draft, and what the drafter may write and name.
242
+ */
243
+ export type DraftRoutineRequest = {
244
+ context: DraftContext;
245
+ draft: DraftRequest;
246
+ };
247
+ /**
248
+ * A drafted routine.
249
+ */
250
+ export type DraftedRoutine = {
251
+ name: string;
252
+ /**
253
+ * Steps whose code still fails the type checker.
254
+ */
255
+ problems: Array<StepProblem>;
256
+ /**
257
+ * What it does, in the shape a routine's task holds steps, each code
258
+ * step named as saving names it.
259
+ */
260
+ steps: Array<{
261
+ [key: string]: unknown;
262
+ }>;
263
+ trigger?: null | ActionTrigger;
264
+ };
265
+ /**
266
+ * A drafted step.
267
+ */
268
+ export type DraftedStep = {
269
+ /**
270
+ * What the type checker still finds in its code.
271
+ */
272
+ problems: Array<string>;
273
+ /**
274
+ * Why AI made a step it chose code or Ask AI, in a few words; empty
275
+ * when it gave no short reason or didn't choose.
276
+ */
277
+ reason: string;
278
+ /**
279
+ * The step, in the shape a routine's task holds it.
280
+ */
281
+ step: {
282
+ [key: string]: unknown;
283
+ };
284
+ };
107
285
  /**
108
286
  * Empty response is required due to custom fetch forcing `response.json()`
109
287
  */
@@ -113,6 +291,11 @@ export type EmptyResponse = {
113
291
  /**
114
292
  * An event name AND an entity ID must match within the same filter. A
115
293
  * condition further requires the event's content to answer it with yes.
294
+ *
295
+ * `github` comes from outside Macro and carries its payload: it stands
296
+ * alone in its filter, takes no ids, and may require
297
+ * exact payload values with `match`. A `github` filter narrows deliveries
298
+ * with its `github` selector.
116
299
  */
117
300
  export type EventFilter = {
118
301
  /**
@@ -121,7 +304,13 @@ export type EventFilter = {
121
304
  */
122
305
  condition?: string | null;
123
306
  events: Array<EventName>;
307
+ github?: null | GithubSelector;
124
308
  ids?: Array<string> | null;
309
+ /**
310
+ * Exact tests on the payload, all of which must pass.
311
+ */
312
+ match?: Array<PayloadCondition> | null;
313
+ property?: null | PropertySelector;
125
314
  };
126
315
  /**
127
316
  * Bounded nonempty OR of filters, canonicalized to remove duplicates.
@@ -131,7 +320,7 @@ export type EventFilters = Array<EventFilter>;
131
320
  * Closed allowlist: unknown names, deletions and ambiguous attribution are not
132
321
  * selectors. Adding a broker variant does not automatically enable routines.
133
322
  */
134
- export type EventName = 'document.created' | 'document.updated' | 'document.deleted' | 'task.created' | 'task.status_changed' | 'task.priority_changed' | 'task.property_changed' | 'email.message_received' | 'channel.created' | 'channel.message_posted' | 'channel.mentioned' | 'channel.message_patched' | 'channel.message_attachment_created' | 'call.started' | 'call.ended';
323
+ export type EventName = 'document.created' | 'document.updated' | 'document.deleted' | 'task.created' | 'task.status_changed' | 'task.priority_changed' | 'task.property_changed' | 'email.message_received' | 'channel.created' | 'channel.message_posted' | 'channel.mentioned' | 'channel.message_patched' | 'channel.message_attachment_created' | 'call.started' | 'call.ended' | 'github';
135
324
  /**
136
325
  * Transcript resource created by a run. Never infer this from current task configuration.
137
326
  */
@@ -149,32 +338,151 @@ export type ExecutionResourceType = 'chat' | 'agent';
149
338
  */
150
339
  export type ExecutionResult = {
151
340
  condition?: null | ConditionResult;
341
+ /**
342
+ * The routine configuration the run used. Step paths only name the same
343
+ * steps in that configuration; a later edit can put another step there.
344
+ */
345
+ configuration_revision?: number | null;
152
346
  error?: string | null;
153
347
  resource?: null | ExecutionResource;
348
+ run?: null | RunInfo;
349
+ /**
350
+ * What each step that ran did, in order: decisions, tool calls, the agent.
351
+ */
352
+ steps?: Array<{
353
+ [key: string]: unknown;
354
+ }>;
154
355
  version: number;
155
356
  };
357
+ /**
358
+ * Which GitHub deliveries match.
359
+ */
360
+ export type GithubSelector = {
361
+ /**
362
+ * Payload actions, such as `completed` or `opened`; any when empty.
363
+ */
364
+ actions?: Array<string>;
365
+ /**
366
+ * GitHub event names, such as `workflow_run` or `pull_request`; any when empty.
367
+ */
368
+ events?: Array<string>;
369
+ /**
370
+ * Also run for deliveries caused by bots and apps, including Macro's own.
371
+ */
372
+ includeBots?: boolean;
373
+ /**
374
+ * Repositories as `owner/name`, matched without regard to case; every
375
+ * repository the owner's installations cover when empty. A renamed
376
+ * repository stops matching until it is chosen again.
377
+ */
378
+ repositories?: Array<string>;
379
+ };
156
380
  export type InProgressExecution = {
157
381
  action_id: string;
158
382
  chat_id?: string | null;
159
383
  resource?: null | ExecutionResource;
160
384
  };
161
385
  /**
162
- * Deprecated cron-only input, accepted during the compatibility rollout.
386
+ * An item and its name.
163
387
  */
164
- export type LegacyActionConfiguration = {
165
- enabled: boolean;
166
- kind: ActionKind;
388
+ export type NamedItem = {
389
+ id: string;
167
390
  name: string;
168
- schedule: Schedule;
169
- task: {
170
- [key: string]: unknown;
171
- };
172
- timezone: string;
391
+ };
392
+ /**
393
+ * `path` walks objects by key; `*` steps into every element of an array and
394
+ * a number into one. Give exactly one test. `notIn` also passes when the
395
+ * path finds nothing.
396
+ */
397
+ export type PayloadCondition = {
398
+ equals?: null | PayloadScalar;
399
+ /**
400
+ * Whether the path finds a non-null value.
401
+ */
402
+ exists?: boolean | null;
403
+ /**
404
+ * Some text found matches this glob; `*` matches any run of characters.
405
+ */
406
+ glob?: string | null;
407
+ /**
408
+ * Some value found is one of these.
409
+ */
410
+ in?: Array<PayloadScalar> | null;
411
+ /**
412
+ * No value found is one of these.
413
+ */
414
+ notIn?: Array<PayloadScalar> | null;
415
+ /**
416
+ * Keys from the payload's root, e.g. `["workflow_run", "conclusion"]`.
417
+ */
418
+ path: Array<string>;
419
+ };
420
+ /**
421
+ * A JSON text, number, boolean or null that payload values are compared with.
422
+ */
423
+ export type PayloadScalar = null | boolean | number | string;
424
+ /**
425
+ * Narrows a task property change filter to one property and, optionally, the
426
+ * values it must gain.
427
+ */
428
+ export type PropertySelector = {
429
+ /**
430
+ * The property definition that must have changed.
431
+ */
432
+ definitionId: string;
433
+ /**
434
+ * Select option ids or referenced entity ids, one of which the change must
435
+ * add. Any change to the property matches when empty.
436
+ */
437
+ values?: Array<string>;
173
438
  };
174
439
  /**
175
440
  * A nonblank model identifier. Runtime catalogs, not the scheduler, own availability.
176
441
  */
177
442
  export type RoutineModelId = string;
443
+ /**
444
+ * The routine a step is added to or changed in.
445
+ */
446
+ export type RoutineSoFar = {
447
+ /**
448
+ * Its steps, in the shape a routine's task holds them.
449
+ */
450
+ steps: Array<{
451
+ [key: string]: unknown;
452
+ }>;
453
+ /**
454
+ * Its trigger as it would be saved, for AI to read; absent while it has none.
455
+ */
456
+ trigger?: {
457
+ [key: string]: unknown;
458
+ } | null;
459
+ };
460
+ /**
461
+ * A shared routine's snapshot, readable by signed-in users with sharing enabled.
462
+ */
463
+ export type RoutineTemplate = {
464
+ /**
465
+ * Routines activated from this template, including stopped ones.
466
+ */
467
+ active_count: number;
468
+ /**
469
+ * Who shared it: the source routine's owner.
470
+ */
471
+ author: string;
472
+ created_at: string;
473
+ description: string;
474
+ /**
475
+ * The routine it was shared from.
476
+ */
477
+ id: string;
478
+ name: string;
479
+ task: {
480
+ [key: string]: unknown;
481
+ };
482
+ trigger: ActionTrigger;
483
+ updated_at: string;
484
+ variables: Array<TemplateVariable>;
485
+ };
178
486
  /**
179
487
  * An individual trigger in a routine's trigger list.
180
488
  */
@@ -185,11 +493,73 @@ export type RoutineTrigger = {
185
493
  } | {
186
494
  filters: EventFilters;
187
495
  type: 'events';
496
+ } | {
497
+ at: string;
498
+ type: 'once';
188
499
  };
189
500
  /**
190
501
  * Bounded schedules and one combined set of event filters.
191
502
  */
192
503
  export type RoutineTriggers = Array<RoutineTrigger>;
504
+ /**
505
+ * What the run page says about a run: what started it, when it counts as
506
+ * happening, and since when.
507
+ */
508
+ export type RunInfo = {
509
+ /**
510
+ * When the run counts as happening: its trigger's time.
511
+ */
512
+ at: string;
513
+ /**
514
+ * When the routine's previous finished run started.
515
+ */
516
+ previous_at?: string | null;
517
+ /**
518
+ * What started it.
519
+ */
520
+ started_by: RunStart;
521
+ /**
522
+ * The IANA time zone code reads `at` in, when the run had one.
523
+ */
524
+ timezone?: string | null;
525
+ };
526
+ /**
527
+ * What started a run, for its page.
528
+ */
529
+ export type RunStart = {
530
+ kind: 'schedule';
531
+ /**
532
+ * The cron expression.
533
+ */
534
+ schedule: string;
535
+ /**
536
+ * Its IANA time zone.
537
+ */
538
+ timezone: string;
539
+ } | {
540
+ /**
541
+ * The item the event is about.
542
+ */
543
+ entity_id?: string | null;
544
+ /**
545
+ * The event's name, e.g. `email.message_received`.
546
+ */
547
+ event: string;
548
+ kind: 'event';
549
+ } | {
550
+ /**
551
+ * Who started it.
552
+ */
553
+ by: string;
554
+ kind: 'manual';
555
+ };
556
+ /**
557
+ * Whether a routine's runs are listed in Home and the Agents list. Routines
558
+ * that run often would bury the owner's own work, so runs start unlisted;
559
+ * either way they stay in the routine's history. The string form is the
560
+ * `scheduled_action.run_visibility` column's.
561
+ */
562
+ export type RunVisibility = 'listed' | 'unlisted';
193
563
  export type Schedule = string;
194
564
  export type ScheduledAction = {
195
565
  claimed?: string | null;
@@ -198,6 +568,10 @@ export type ScheduledAction = {
198
568
  */
199
569
  configuration_revision: number;
200
570
  created_at: string;
571
+ /**
572
+ * What the routine is for, in the owner's words; empty when unset.
573
+ */
574
+ description?: string;
201
575
  /**
202
576
  * When false, automatic dispatch skips this action. `run_now` remains
203
577
  * available regardless.
@@ -221,9 +595,17 @@ export type ScheduledAction = {
221
595
  * rather than failing to parse.
222
596
  */
223
597
  owner: string;
598
+ /**
599
+ * Whether the action's runs are listed in Home and the Agents list.
600
+ */
601
+ run_visibility: RunVisibility;
224
602
  task: {
225
603
  [key: string]: unknown;
226
604
  };
605
+ /**
606
+ * The shared template this routine was activated from, if any.
607
+ */
608
+ template_id?: string | null;
227
609
  trigger: ActionTrigger;
228
610
  updated_at: string;
229
611
  };
@@ -232,6 +614,7 @@ export type ScheduledAction = {
232
614
  * responses omit legacy fields rather than inventing a schedule or timezone.
233
615
  */
234
616
  export type ScheduledActionResponse = ScheduledAction & {
617
+ last_run?: null | ActionExecutionRecord;
235
618
  /**
236
619
  * Deprecated: use `trigger.schedule`. Present only for cron actions.
237
620
  *
@@ -272,9 +655,115 @@ export type SetScheduledActionEnabled = {
272
655
  enabled: boolean;
273
656
  };
274
657
  /**
275
- * Full replacement of client configuration, not of server-owned action state.
658
+ * What the owner supplies when sharing; the rest is snapshotted from the routine.
659
+ */
660
+ export type ShareRoutineTemplate = {
661
+ description: string;
662
+ variables: Array<TemplateVariable>;
663
+ };
664
+ /**
665
+ * A starter routine whose step is code: offered when a routine is created,
666
+ * and shown to the drafter as a worked example.
667
+ */
668
+ export type StarterRoutine = {
669
+ /**
670
+ * Names it, e.g. `inbox`.
671
+ */
672
+ key: string;
673
+ /**
674
+ * What someone asks for, with when it runs.
675
+ */
676
+ request: string;
677
+ /**
678
+ * Its steps, in the shape a routine's task holds them.
679
+ */
680
+ steps: Array<{
681
+ [key: string]: unknown;
682
+ }>;
683
+ };
684
+ /**
685
+ * Code written once, or Ask AI each run.
686
+ */
687
+ export type StepKind = 'code' | 'agent';
688
+ /**
689
+ * A drafted step whose code still fails the type checker.
690
+ */
691
+ export type StepProblem = {
692
+ /**
693
+ * Its place among the steps, from zero.
694
+ */
695
+ index: number;
696
+ problems: Array<string>;
697
+ };
698
+ /**
699
+ * A user-specific part of a shared routine.
700
+ */
701
+ export type TemplateVariable = {
702
+ fill: VariableFill;
703
+ id: string;
704
+ kind: 'user';
705
+ label: string;
706
+ } | {
707
+ /**
708
+ * The mention's block name, such as `channel` or `md`.
709
+ */
710
+ block_name: string;
711
+ fill: VariableFill;
712
+ id: string;
713
+ kind: 'item';
714
+ label: string;
715
+ } | {
716
+ fill: VariableFill;
717
+ kind: 'time_zone';
718
+ timezone: string;
719
+ };
720
+ /**
721
+ * How an upgrade went.
722
+ */
723
+ export type UpgradeOutcome = 'running' | 'checked' | 'rewritten' | 'needs_update';
724
+ /**
725
+ * How a variable is filled when someone activates the template.
276
726
  */
277
- export type UpdateScheduledAction = ActionConfigurationUpdate | LegacyActionConfiguration;
727
+ export type VariableFill = 'activator' | 'shared' | 'choice';
728
+ /**
729
+ * The items AI may name in a draft. They are data for the model; saving
730
+ * checks every id the draft uses.
731
+ */
732
+ export type Workspace = {
733
+ /**
734
+ * Agents a step may hand the run to.
735
+ */
736
+ agents?: Array<WorkspaceAgent>;
737
+ channels?: Array<NamedItem>;
738
+ /**
739
+ * Projects.
740
+ */
741
+ folders?: Array<NamedItem>;
742
+ /**
743
+ * Email label names.
744
+ */
745
+ labels?: Array<string>;
746
+ people?: Array<NamedItem>;
747
+ /**
748
+ * Tag options, by the property definition they belong to.
749
+ */
750
+ tags?: Array<WorkspaceTag>;
751
+ };
752
+ /**
753
+ * An agent and its bot id.
754
+ */
755
+ export type WorkspaceAgent = {
756
+ botId: string;
757
+ name: string;
758
+ };
759
+ /**
760
+ * A tag: one option of a property.
761
+ */
762
+ export type WorkspaceTag = {
763
+ definitionId: string;
764
+ label: string;
765
+ optionId: string;
766
+ };
278
767
  export type ScheduledActionHealthData = {
279
768
  body?: never;
280
769
  path?: never;
@@ -310,7 +799,7 @@ export type ListScheduledActionsResponses = {
310
799
  };
311
800
  export type ListScheduledActionsResponse = ListScheduledActionsResponses[keyof ListScheduledActionsResponses];
312
801
  export type CreateScheduledActionData = {
313
- body: CreateScheduledAction;
802
+ body: ActionConfiguration;
314
803
  path?: never;
315
804
  query?: never;
316
805
  url: '/scheduled-actions';
@@ -326,6 +815,50 @@ export type CreateScheduledActionResponses = {
326
815
  201: ScheduledActionResponse;
327
816
  };
328
817
  export type CreateScheduledActionResponse = CreateScheduledActionResponses[keyof CreateScheduledActionResponses];
818
+ export type RoutineCodeStartersData = {
819
+ body?: never;
820
+ path?: never;
821
+ query?: never;
822
+ url: '/scheduled-actions/code/starters';
823
+ };
824
+ export type RoutineCodeStartersErrors = {
825
+ 401: string;
826
+ };
827
+ export type RoutineCodeStartersError = RoutineCodeStartersErrors[keyof RoutineCodeStartersErrors];
828
+ export type RoutineCodeStartersResponses = {
829
+ /**
830
+ * Starter routines whose step is code; empty where code steps aren't available
831
+ */
832
+ 200: Array<StarterRoutine>;
833
+ };
834
+ export type RoutineCodeStartersResponse = RoutineCodeStartersResponses[keyof RoutineCodeStartersResponses];
835
+ export type DraftRoutineData = {
836
+ body: DraftRoutineRequest;
837
+ path?: never;
838
+ query?: never;
839
+ url: '/scheduled-actions/drafts';
840
+ };
841
+ export type DraftRoutineErrors = {
842
+ 400: string;
843
+ 401: string;
844
+ /**
845
+ * AI usage limit reached
846
+ */
847
+ 402: AiAdmissionErrorBody;
848
+ 500: string;
849
+ /**
850
+ * AI usage validation unavailable
851
+ */
852
+ 503: AiAdmissionErrorBody;
853
+ };
854
+ export type DraftRoutineError = DraftRoutineErrors[keyof DraftRoutineErrors];
855
+ export type DraftRoutineResponses = {
856
+ /**
857
+ * A routine or step to review before saving, with any code problems AI couldn't fix, or why AI couldn't draft it
858
+ */
859
+ 200: Draft;
860
+ };
861
+ export type DraftRoutineResponse = DraftRoutineResponses[keyof DraftRoutineResponses];
329
862
  export type DeleteScheduledActionData = {
330
863
  body?: never;
331
864
  path: {
@@ -369,7 +902,7 @@ export type GetScheduledActionResponses = {
369
902
  };
370
903
  export type GetScheduledActionResponse = GetScheduledActionResponses[keyof GetScheduledActionResponses];
371
904
  export type UpdateScheduledActionData = {
372
- body: UpdateScheduledAction;
905
+ body: ActionConfigurationUpdate;
373
906
  path: {
374
907
  /**
375
908
  * ID of the scheduled action
@@ -394,6 +927,30 @@ export type UpdateScheduledActionResponses = {
394
927
  200: ScheduledActionResponse;
395
928
  };
396
929
  export type UpdateScheduledActionResponse = UpdateScheduledActionResponses[keyof UpdateScheduledActionResponses];
930
+ export type ListScheduledActionCodeUpgradesData = {
931
+ body?: never;
932
+ path: {
933
+ /**
934
+ * ID of the scheduled action
935
+ */
936
+ id: string;
937
+ };
938
+ query?: never;
939
+ url: '/scheduled-actions/{id}/code-upgrades';
940
+ };
941
+ export type ListScheduledActionCodeUpgradesErrors = {
942
+ 401: string;
943
+ 404: string;
944
+ 500: string;
945
+ };
946
+ export type ListScheduledActionCodeUpgradesError = ListScheduledActionCodeUpgradesErrors[keyof ListScheduledActionCodeUpgradesErrors];
947
+ export type ListScheduledActionCodeUpgradesResponses = {
948
+ /**
949
+ * How the routine's code steps were brought to new SDKs, newest first
950
+ */
951
+ 200: Array<CodeUpgrade>;
952
+ };
953
+ export type ListScheduledActionCodeUpgradesResponse = ListScheduledActionCodeUpgradesResponses[keyof ListScheduledActionCodeUpgradesResponses];
397
954
  export type SetScheduledActionEnabledData = {
398
955
  body: SetScheduledActionEnabled;
399
956
  path: {
@@ -475,3 +1032,96 @@ export type ListScheduledActionHistoryResponses = {
475
1032
  200: Array<ActionExecutionRecord>;
476
1033
  };
477
1034
  export type ListScheduledActionHistoryResponse = ListScheduledActionHistoryResponses[keyof ListScheduledActionHistoryResponses];
1035
+ export type UnshareScheduledActionTemplateData = {
1036
+ body?: never;
1037
+ path: {
1038
+ /**
1039
+ * ID of the shared routine
1040
+ */
1041
+ id: string;
1042
+ };
1043
+ query?: never;
1044
+ url: '/scheduled-actions/{id}/template';
1045
+ };
1046
+ export type UnshareScheduledActionTemplateErrors = {
1047
+ 401: string;
1048
+ 404: string;
1049
+ 500: string;
1050
+ };
1051
+ export type UnshareScheduledActionTemplateError = UnshareScheduledActionTemplateErrors[keyof UnshareScheduledActionTemplateErrors];
1052
+ export type UnshareScheduledActionTemplateResponses = {
1053
+ 204: void;
1054
+ };
1055
+ export type UnshareScheduledActionTemplateResponse = UnshareScheduledActionTemplateResponses[keyof UnshareScheduledActionTemplateResponses];
1056
+ export type GetScheduledActionTemplateData = {
1057
+ body?: never;
1058
+ path: {
1059
+ /**
1060
+ * ID of the shared routine
1061
+ */
1062
+ id: string;
1063
+ };
1064
+ query?: never;
1065
+ url: '/scheduled-actions/{id}/template';
1066
+ };
1067
+ export type GetScheduledActionTemplateErrors = {
1068
+ 401: string;
1069
+ /**
1070
+ * The routine is not shared
1071
+ */
1072
+ 404: string;
1073
+ 500: string;
1074
+ };
1075
+ export type GetScheduledActionTemplateError = GetScheduledActionTemplateErrors[keyof GetScheduledActionTemplateErrors];
1076
+ export type GetScheduledActionTemplateResponses = {
1077
+ 200: RoutineTemplate;
1078
+ };
1079
+ export type GetScheduledActionTemplateResponse = GetScheduledActionTemplateResponses[keyof GetScheduledActionTemplateResponses];
1080
+ export type ShareScheduledActionTemplateData = {
1081
+ body: ShareRoutineTemplate;
1082
+ path: {
1083
+ /**
1084
+ * ID of the routine to share
1085
+ */
1086
+ id: string;
1087
+ };
1088
+ query?: never;
1089
+ url: '/scheduled-actions/{id}/template';
1090
+ };
1091
+ export type ShareScheduledActionTemplateErrors = {
1092
+ 400: string;
1093
+ 401: string;
1094
+ 404: string;
1095
+ 500: string;
1096
+ };
1097
+ export type ShareScheduledActionTemplateError = ShareScheduledActionTemplateErrors[keyof ShareScheduledActionTemplateErrors];
1098
+ export type ShareScheduledActionTemplateResponses = {
1099
+ 200: RoutineTemplate;
1100
+ };
1101
+ export type ShareScheduledActionTemplateResponse = ShareScheduledActionTemplateResponses[keyof ShareScheduledActionTemplateResponses];
1102
+ export type ActivateScheduledActionTemplateData = {
1103
+ body: ActionConfiguration;
1104
+ path: {
1105
+ /**
1106
+ * ID of the shared routine
1107
+ */
1108
+ id: string;
1109
+ };
1110
+ query?: never;
1111
+ url: '/scheduled-actions/{id}/template/activate';
1112
+ };
1113
+ export type ActivateScheduledActionTemplateErrors = {
1114
+ 400: string;
1115
+ 401: string;
1116
+ 403: string;
1117
+ /**
1118
+ * The routine is not shared
1119
+ */
1120
+ 404: string;
1121
+ 500: string;
1122
+ };
1123
+ export type ActivateScheduledActionTemplateError = ActivateScheduledActionTemplateErrors[keyof ActivateScheduledActionTemplateErrors];
1124
+ export type ActivateScheduledActionTemplateResponses = {
1125
+ 201: ScheduledActionResponse;
1126
+ };
1127
+ export type ActivateScheduledActionTemplateResponse = ActivateScheduledActionTemplateResponses[keyof ActivateScheduledActionTemplateResponses];