terse-types 0.0.1 → 0.0.3

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/dist/types.js CHANGED
@@ -1,7 +1,128 @@
1
+ import * as z from "zod";
2
+ import { configDataSchema, configTypeEnum } from "./Configs.js";
3
+ import { integrationTypeEnum } from "./Integrations.js";
4
+ import { RUN_HISTORY_ACTION_TYPES, RunHistoryStatus, runHistoryActionBaseSchema } from "./RunHistoryTypes.js";
5
+ import { slackUserResponseSchema } from "./Tools.js";
6
+ const pointSchema = z.object({
7
+ x: z.number(),
8
+ y: z.number()
9
+ });
10
+ const unknownRecordSchema = z.record(z.string(), z.unknown());
11
+ export const roleSchema = z.enum(["admin", "user"]);
12
+ export const userSchema = z.object({
13
+ id: z.string(),
14
+ workosId: z.string(),
15
+ organizationId: z.string(),
16
+ organizationName: z.string(),
17
+ email: z.string(),
18
+ displayName: z.string(),
19
+ firstName: z.string().nullable(),
20
+ lastName: z.string().nullable(),
21
+ displayPhotoUrl: z.string(),
22
+ roles: z.array(roleSchema)
23
+ });
24
+ export const userNoOrganizationSchema = userSchema.omit({
25
+ organizationId: true,
26
+ organizationName: true,
27
+ roles: true
28
+ });
29
+ export const commitAssociationSchema = z.object({
30
+ sha: z.string(),
31
+ message: z.string(),
32
+ url: z.string()
33
+ });
34
+ export const subActivitySchema = z.object({
35
+ summary: z.string(),
36
+ commits: z.array(commitAssociationSchema)
37
+ });
38
+ export const activityEventSchema = z.object({
39
+ event_type: z.string(),
40
+ title: z.string(),
41
+ github_repository_owner_id: z.string(),
42
+ github_repository_name: z.string(),
43
+ created_at: z.date(),
44
+ sub_activities: z.array(subActivitySchema)
45
+ });
46
+ export const linearWorkspaceSchema = z.object({
47
+ id: z.string(),
48
+ name: z.string()
49
+ });
50
+ export const jiraProjectSchema = z.object({
51
+ id: z.string(),
52
+ key: z.string(),
53
+ name: z.string()
54
+ });
55
+ export const jiraCredentialsValidationResponseSchema = z.object({
56
+ valid: z.boolean(),
57
+ projects: z.array(jiraProjectSchema).optional(),
58
+ error: z.string().optional()
59
+ });
60
+ export const notionResourceTypeSchema = z.enum(["database", "page"]);
61
+ export const notionResourceSchema = z.object({
62
+ id: z.string(),
63
+ title: z.string(),
64
+ url: z.string(),
65
+ type: notionResourceTypeSchema
66
+ });
67
+ export const notionResourcesResponseSchema = z.object({
68
+ resources: z.array(notionResourceSchema)
69
+ });
70
+ export const posthogProjectSchema = z.object({
71
+ id: z.string(),
72
+ name: z.string(),
73
+ organization_id: z.string().optional()
74
+ });
75
+ export const posthogProjectsResponseSchema = z.object({
76
+ projects: z.array(posthogProjectSchema)
77
+ });
78
+ export const launchDarklyProjectSchema = z.object({
79
+ key: z.string(),
80
+ name: z.string()
81
+ });
82
+ export const launchDarklyProjectsResponseSchema = z.object({
83
+ projects: z.array(launchDarklyProjectSchema)
84
+ });
85
+ export const launchDarklyEnvironmentSchema = z.object({
86
+ key: z.string(),
87
+ name: z.string()
88
+ });
89
+ export const launchDarklyEnvironmentsResponseSchema = z.object({
90
+ environments: z.array(launchDarklyEnvironmentSchema)
91
+ });
92
+ export const datadogIndexSchema = z.object({
93
+ id: z.string(),
94
+ name: z.string(),
95
+ isEnabled: z.boolean(),
96
+ dailyLimit: z.number().int().optional(),
97
+ retentionDays: z.number().int().optional()
98
+ });
99
+ export const datadogIndexesResponseSchema = z.object({
100
+ indexes: z.array(datadogIndexSchema)
101
+ });
102
+ export const slackChannelSchema = z.object({
103
+ id: z.string(),
104
+ name: z.string(),
105
+ isPrivate: z.boolean(),
106
+ isArchived: z.boolean(),
107
+ isMPIM: z.boolean()
108
+ });
109
+ export const slackChannelsResponseSchema = z.object({
110
+ channels: z.array(slackChannelSchema),
111
+ selectedChannelId: z.string().nullable()
112
+ });
113
+ export const slackUsersResponseSchema = z.object({
114
+ users: z.array(slackUserResponseSchema)
115
+ });
1
116
  export const TERSE_AGENT_MESSAGE_EVENT_TYPE = "terse_agent_message";
2
- /**
3
- * Slack channel type enum
4
- */
117
+ export const terseAgentMessageEventPayloadSchema = z.object({
118
+ run_id: z.string(),
119
+ automation_id: z.string(),
120
+ organization_id: z.string()
121
+ });
122
+ export const terseAgentMessageMetadataSchema = z.object({
123
+ event_type: z.literal(TERSE_AGENT_MESSAGE_EVENT_TYPE),
124
+ event_payload: terseAgentMessageEventPayloadSchema
125
+ });
5
126
  export var SlackChannelType;
6
127
  (function (SlackChannelType) {
7
128
  SlackChannelType["CHANNEL"] = "channel";
@@ -9,107 +130,615 @@ export var SlackChannelType;
9
130
  SlackChannelType["MPIM"] = "mpim";
10
131
  SlackChannelType["IM"] = "im";
11
132
  })(SlackChannelType || (SlackChannelType = {}));
12
- // Figma webhook and API types
133
+ export const slackChannelTypeSchema = z.enum(SlackChannelType);
134
+ export const confluencePageSchema = z.object({
135
+ id: z.string(),
136
+ title: z.string(),
137
+ spaceId: z.string(),
138
+ spaceName: z.string(),
139
+ url: z.string(),
140
+ status: z.string(),
141
+ version: z.number().int()
142
+ });
143
+ export const confluencePagesQuerySchema = z
144
+ .object({
145
+ integrationId: z.string(),
146
+ spaceId: z.string().optional(),
147
+ spaceKey: z.string().optional()
148
+ })
149
+ .refine(({ spaceId, spaceKey }) => spaceId != null || spaceKey != null, {
150
+ message: "Either spaceId or spaceKey is required"
151
+ });
152
+ export const confluencePagesResponseSchema = z.object({
153
+ pages: z.array(confluencePageSchema),
154
+ spaceId: z.string(),
155
+ total: z.number().int()
156
+ });
157
+ export const confluenceResourcesResponseSchema = z.object({
158
+ resources: z.array(confluencePageSchema),
159
+ spaceId: z.string(),
160
+ total: z.number().int()
161
+ });
162
+ export const jiraResourceProjectSchema = z.object({
163
+ id: z.string(),
164
+ key: z.string(),
165
+ name: z.string(),
166
+ projectTypeKey: z.string()
167
+ });
168
+ export const jiraResourcesPayloadSchema = z.object({
169
+ projects: z.array(jiraResourceProjectSchema),
170
+ baseUrl: z.string(),
171
+ cloudId: z.string()
172
+ });
173
+ export const jiraResourcesResponseSchema = z.object({
174
+ success: z.boolean(),
175
+ resources: jiraResourcesPayloadSchema
176
+ });
177
+ export const useConfluenceResourcesReturnBaseSchema = z.object({
178
+ resources: z.array(confluencePageSchema),
179
+ response: confluenceResourcesResponseSchema.optional(),
180
+ isLoading: z.boolean(),
181
+ isError: z.boolean(),
182
+ error: z.unknown(),
183
+ isValidating: z.boolean()
184
+ });
185
+ export const createUseConfluenceResourcesReturnSchema = (mutateSchema) => useConfluenceResourcesReturnBaseSchema.extend({
186
+ mutate: mutateSchema
187
+ });
13
188
  export var FigmaEventTypes;
14
189
  (function (FigmaEventTypes) {
15
190
  FigmaEventTypes["FILE_COMMENT"] = "FILE_COMMENT";
16
191
  })(FigmaEventTypes || (FigmaEventTypes = {}));
17
- // export type SlackChannelListItem = z.infer<typeof slackChannelListItemSchema>
18
- // export type SlackConversationMessage = z.infer<typeof slackConversationMessageSchema>
19
- // export type GitHubPagination = z.infer<typeof gitHubPaginationSchema>
20
- // export type GitHubCodeSearchResult = z.infer<typeof gitHubCodeSearchResultSchema>
21
- // export type GitHubCodeGrepResult = z.infer<typeof gitHubCodeGrepResultSchema>
22
- // export type GitHubPullRequestSummary = z.infer<typeof gitHubPullRequestSummarySchema>
23
- // export type GitHubDirectoryEntry = z.infer<typeof gitHubDirectoryEntrySchema>
24
- // export type GitHubFileEntry = z.infer<typeof gitHubFileEntrySchema>
25
- // export type GitHubOtherEntry = z.infer<typeof gitHubOtherEntrySchema>
26
- // export type GitHubCommitSummary = z.infer<typeof gitHubCommitSummarySchema>
27
- // export type GitHubPullRequestRef = z.infer<typeof gitHubPullRequestRefSchema>
28
- // export type SnowflakeQueryRow = Record<string, unknown>
29
- // export type LinearIssueAssignee = z.infer<typeof linearIssueAssigneeSchema>
30
- // export type LinearIssueTeam = z.infer<typeof linearIssueTeamSchema>
31
- // export type LinearIssueProject = z.infer<typeof linearIssueProjectSchema>
32
- // export type LinearIssueSummary = z.infer<typeof linearIssueSummarySchema>
33
- // export type LinearIssueDetail = z.infer<typeof linearIssueDetailSchema>
34
- // export type LinearIssueHandle = z.infer<typeof linearIssueHandleSchema>
35
- // export type LinearCommentHandle = z.infer<typeof linearCommentHandleSchema>
36
- // export type LinearStateSummary = z.infer<typeof linearStateSummarySchema>
37
- // export type LinearLabelSummary = z.infer<typeof linearLabelSummarySchema>
38
- // export type LinearProjectSummary = z.infer<typeof linearProjectSummarySchema>
39
- // export type LinearUserSummary = z.infer<typeof linearUserSummarySchema>
40
- // export type LinearSearchPagination = z.infer<typeof linearSearchPaginationSchema>
41
- // export type JiraIssueState = z.infer<typeof jiraIssueStateSchema>
42
- // export type JiraIssueAssignee = z.infer<typeof jiraIssueAssigneeSchema>
43
- // export type JiraIssueProjectRef = z.infer<typeof jiraIssueProjectRefSchema>
44
- // export type JiraIssueTypeRef = z.infer<typeof jiraIssueTypeRefSchema>
45
- // export type JiraRichDescription = z.infer<typeof jiraRichDescriptionSchema>
46
- // export type JiraIssueSummary = z.infer<typeof jiraIssueSummarySchema>
47
- // export type GmailSendSummary = z.infer<typeof gmailSendSummarySchema>
48
- // export type GmailDraftSummary = z.infer<typeof gmailDraftSummarySchema>
49
- // export type NotionUserReference = z.infer<typeof notionUserReferenceSchema>
50
- // export type NotionFileReference = z.infer<typeof notionFileReferenceSchema>
51
- // export type NotionDateReference = z.infer<typeof notionDateReferenceSchema>
52
- // export type NotionReadablePropertyValue = z.infer<typeof notionReadablePropertyValueSchema>
53
- // export type NotionPageBlock = z.infer<typeof notionPageBlockSchema>
54
- // export type NotionPageParent = z.infer<typeof notionPageParentSchema>
55
- // export type NotionPageQueryMetadata = z.infer<typeof notionPageQueryMetadataSchema>
56
- // export type NotionDatabaseRowMutationResult = z.infer<typeof notionDatabaseRowMutationResultSchema>
57
- // export type NotionSchemaProperty = z.infer<typeof notionSchemaPropertySchema>
58
- // export type NotionDatabaseQueryPage = z.infer<typeof notionDatabaseQueryPageSchema>
59
- // export type NotionQueryDatabaseFailure = z.infer<typeof notionQueryDatabaseFailureSchema>
60
- // export type NotionQueryDatabaseSuccess = z.infer<typeof notionQueryDatabaseSuccessSchema>
61
- // export type NotionModifyBlocksAppendResult = z.infer<typeof notionModifyBlocksAppendResultSchema>
62
- // export type NotionModifyBlocksUpdateResult = z.infer<typeof notionModifyBlocksUpdateResultSchema>
63
- // export type NotionModifyBlocksDeleteResult = z.infer<typeof notionModifyBlocksDeleteResultSchema>
64
- // export type NotionModifyBlocksOperationResult = z.infer<typeof notionModifyBlocksOperationResultSchema>
65
- // export type NotionModifyBlocksSuccess = z.infer<typeof notionModifyBlocksSuccessSchema>
66
- // export type NotionModifyBlocksFailure = z.infer<typeof notionModifyBlocksFailureSchema>
67
- // export type NotionWorkspaceUser = z.infer<typeof notionWorkspaceUserSchema>
68
- // export type ConfluencePageSpace = z.infer<typeof confluencePageSpaceSchema>
69
- // export type ConfluencePageVersionAuthor = z.infer<typeof confluencePageVersionAuthorSchema>
70
- // export type ConfluencePageVersion = z.infer<typeof confluencePageVersionSchema>
71
- // export type ConfluenceBodyRepresentation = z.infer<typeof confluenceBodyRepresentationSchema>
72
- // export type ConfluenceBodyContent = z.infer<typeof confluenceBodyContentSchema>
73
- // export type ConfluencePageRelation = z.infer<typeof confluencePageRelationSchema>
74
- // export type ConfluencePageQueryResult = z.infer<typeof confluencePageQueryResultSchema>
75
- // export type ConfluenceCommentPosition = z.infer<typeof confluenceCommentPositionSchema>
76
- // export type PosthogSessionSummary = z.infer<typeof posthogSessionSummarySchema>
77
- // export type PosthogSearchSessionsPagination = z.infer<typeof posthogSearchSessionsPaginationSchema>
78
- // export type PosthogSearchSessionsFound = z.infer<typeof posthogSearchSessionsFoundSchema>
79
- // export type PosthogSearchSessionsNotFound = z.infer<typeof posthogSearchSessionsNotFoundSchema>
80
- // export type PosthogLogEntry = z.infer<typeof posthogLogEntrySchema>
81
- // export type PosthogOffsetPagination = z.infer<typeof posthogOffsetPaginationSchema>
82
- // export type PosthogEventCount = z.infer<typeof posthogEventCountSchema>
83
- // export type PosthogEventSummary = z.infer<typeof posthogEventSummarySchema>
84
- // export type PosthogSessionEvent = z.infer<typeof posthogSessionEventSchema>
85
- // export type PosthogSessionConsoleLog = z.infer<typeof posthogSessionConsoleLogSchema>
86
- // export type PosthogSessionEventsSummary = z.infer<typeof posthogSessionEventsSummarySchema>
87
- // export type LaunchDarklyFlagSummary = z.infer<typeof launchDarklyFlagSummarySchema>
88
- // export type LaunchDarklyFlagMetadata = z.infer<typeof launchDarklyFlagMetadataSchema>
89
- // export type LaunchDarklyEnvironmentConfig = z.infer<typeof launchDarklyEnvironmentConfigSchema>
90
- // export type LaunchDarklyHistoryEntry = z.infer<typeof launchDarklyHistoryEntrySchema>
91
- // export type LaunchDarklyHistoryResult = z.infer<typeof launchDarklyHistoryResultSchema>
92
- // export type DatadogLogEntry = z.infer<typeof datadogLogEntrySchema>
93
- // export type DatadogCursorPagination = z.infer<typeof datadogCursorPaginationSchema>
94
- // export type DatadogRumSessionDetails = z.infer<typeof datadogRumSessionDetailsSchema>
95
- // export type DatadogRumViewDetails = z.infer<typeof datadogRumViewDetailsSchema>
96
- // export type DatadogRumActionDetails = z.infer<typeof datadogRumActionDetailsSchema>
97
- // export type DatadogRumErrorDetails = z.infer<typeof datadogRumErrorDetailsSchema>
98
- // export type DatadogRumResourceDetails = z.infer<typeof datadogRumResourceDetailsSchema>
99
- // export type DatadogRumLongTaskDetails = z.infer<typeof datadogRumLongTaskDetailsSchema>
100
- // export type DatadogRumEvent = z.infer<typeof datadogRumEventSchema>
101
- // export type DatadogAggregationBucketCompute = z.infer<typeof datadogAggregationBucketComputeSchema>
102
- // export type DatadogAggregationBucket = z.infer<typeof datadogAggregationBucketSchema>
103
- // export type DatadogAggregationMeta = z.infer<typeof datadogAggregationMetaSchema>
104
- // export type WorkOSUserSummary = z.infer<typeof workOSUserSummarySchema>
105
- // export type WorkOSOrganizationSummary = z.infer<typeof workOSOrganizationSummarySchema>
106
- // export type WorkOSPagination = z.infer<typeof workOSPaginationSchema>
107
- // // TO DO manually define schemas here
108
- // export type WebSearchResultItem = z.infer<typeof webSearchResultItemSchema>
109
- // export type WebSearchOutput = z.infer<typeof webSearchOutputSchema>
110
- // export type WebExtractResultItem = z.infer<typeof webExtractResultItemSchema>
111
- // export type WebExtractOutput = z.infer<typeof webExtractOutputSchema>
112
- // export type WebResearchSource = z.infer<typeof webResearchSourceSchema>
113
- // export type WebResearchOutput = z.infer<typeof webResearchOutputSchema>
114
- // export type ImageEditSnippet = z.infer<typeof imageEditSnippetSchema>
115
- // export type ImageEditOutput = z.infer<typeof imageEditOutputSchema>
192
+ export const figmaEventTypesSchema = z.enum(FigmaEventTypes);
193
+ export const figmaWebhookUserSchema = z.object({
194
+ id: z.string(),
195
+ handle: z.string(),
196
+ email: z.string(),
197
+ img_url: z.string()
198
+ });
199
+ export const figmaCommentImageUrlsSchema = z.object({
200
+ nodeImage: z.string().optional(),
201
+ fullFrame: z.string().optional()
202
+ });
203
+ export const figmaVectorDataSchema = pointSchema;
204
+ export const figmaFrameOffsetDataSchema = z.object({
205
+ node_id: z.string(),
206
+ node_offset: pointSchema
207
+ });
208
+ export const figmaRegionDataSchema = z.object({
209
+ x: z.number(),
210
+ y: z.number(),
211
+ width: z.number(),
212
+ height: z.number()
213
+ });
214
+ export const figmaFrameOffsetRegionDataSchema = z.object({
215
+ node_id: z.string(),
216
+ node_offset: pointSchema,
217
+ x: z.number(),
218
+ y: z.number(),
219
+ width: z.number(),
220
+ height: z.number()
221
+ });
222
+ export const figmaVectorPositioningSchema = z.object({ type: z.literal("Vector"), data: figmaVectorDataSchema });
223
+ export const figmaFrameOffsetPositioningSchema = z.object({ type: z.literal("FrameOffset"), data: figmaFrameOffsetDataSchema });
224
+ export const figmaRegionPositioningSchema = z.object({ type: z.literal("Region"), data: figmaRegionDataSchema });
225
+ export const figmaFrameOffsetRegionPositioningSchema = z.object({ type: z.literal("FrameOffsetRegion"), data: figmaFrameOffsetRegionDataSchema });
226
+ export const figmaPositioningDataSchema = z.discriminatedUnion("type", [
227
+ figmaVectorPositioningSchema,
228
+ figmaFrameOffsetPositioningSchema,
229
+ figmaRegionPositioningSchema,
230
+ figmaFrameOffsetRegionPositioningSchema
231
+ ]);
232
+ export const figmaClientMetaSchema = z.object({
233
+ x: z.number(),
234
+ y: z.number(),
235
+ width: z.number(),
236
+ height: z.number(),
237
+ node_id: z.string(),
238
+ node_offset: pointSchema
239
+ });
240
+ export const figmaWebhookCommentSchema = z.object({
241
+ id: z.string(),
242
+ message: z.string(),
243
+ client_meta: figmaClientMetaSchema,
244
+ user: figmaWebhookUserSchema,
245
+ created_at: z.string(),
246
+ resolved_at: z.string().nullable()
247
+ });
248
+ export const figmaApiCommentSchema = z.object({
249
+ id: z.string(),
250
+ message: z.string(),
251
+ client_meta: figmaClientMetaSchema.nullable(),
252
+ user: figmaWebhookUserSchema,
253
+ created_at: z.string(),
254
+ resolved_at: z.string().nullable(),
255
+ parent_id: z.string().nullable().optional(),
256
+ order_id: z.string().optional(),
257
+ mentions: z.array(z.unknown()).optional(),
258
+ reactions: z.array(z.unknown()).optional()
259
+ });
260
+ export const figmaCommentThreadEntrySchema = z.object({
261
+ id: z.string(),
262
+ message: z.string(),
263
+ author: figmaWebhookUserSchema,
264
+ createdAt: z.string(),
265
+ resolvedAt: z.string().nullable(),
266
+ parentId: z.string().nullable(),
267
+ orderId: z.string().optional(),
268
+ isRoot: z.boolean().optional()
269
+ });
270
+ export const figmaFileMetadataSchema = z
271
+ .object({
272
+ name: z.string().optional(),
273
+ folder_name: z.string().optional(),
274
+ url: z.string().optional()
275
+ })
276
+ .passthrough();
277
+ export const figmaCommentEventDataSchema = z.object({
278
+ integrationId: z.string(),
279
+ commentId: z.string(),
280
+ fileKey: z.string(),
281
+ fileUrl: z.string(),
282
+ nodeId: z.string().optional(),
283
+ message: z.string(),
284
+ author: figmaWebhookUserSchema,
285
+ createdAt: z.string(),
286
+ resolved: z.boolean().optional(),
287
+ thread: z.array(figmaCommentThreadEntrySchema).optional(),
288
+ fileMetadata: figmaFileMetadataSchema.optional(),
289
+ positioningData: figmaPositioningDataSchema.optional(),
290
+ matchedNodeIds: z.array(z.string()).optional(),
291
+ imageUrls: figmaCommentImageUrlsSchema.optional()
292
+ });
293
+ export const apiTokenSchema = z.object({
294
+ id: z.string(),
295
+ name: z.string(),
296
+ tokenPrefix: z.string(),
297
+ createdAt: z.string(),
298
+ lastUsedAt: z.string().nullable()
299
+ });
300
+ export const apiTokenCreateResponseSchema = z.object({
301
+ token: apiTokenSchema,
302
+ rawToken: z.string()
303
+ });
304
+ export const deviceTokenExchangeUserSchema = z.object({
305
+ email: z.string(),
306
+ firstName: z.string().nullable(),
307
+ displayName: z.string().nullable()
308
+ });
309
+ export const deviceTokenExchangeResponseSchema = z.object({
310
+ apiKey: z.string(),
311
+ user: deviceTokenExchangeUserSchema
312
+ });
313
+ const configInstanceDataSchema = configDataSchema;
314
+ export const triggerMetadataSchema = z.object({
315
+ webhookUrl: z.string().optional()
316
+ });
317
+ export const agentTriggerSchema = z.object({
318
+ id: z.string(),
319
+ config: configInstanceDataSchema,
320
+ metadata: triggerMetadataSchema.optional()
321
+ });
322
+ export const agentOutputSchema = z.object({
323
+ id: z.string(),
324
+ config: configInstanceDataSchema
325
+ });
326
+ export const agentPromptSchema = z.object({
327
+ text: z.string()
328
+ });
329
+ export const transientAgentTriggerSchema = z.object({
330
+ id: z.string(),
331
+ config: configInstanceDataSchema.optional(),
332
+ configType: configTypeEnum
333
+ });
334
+ export const transientAgentOutputSchema = z.object({
335
+ id: z.string(),
336
+ config: configInstanceDataSchema.optional(),
337
+ configType: configTypeEnum
338
+ });
339
+ export const templateConfigRefSchema = z.object({
340
+ configType: configTypeEnum,
341
+ integrationType: integrationTypeEnum
342
+ });
343
+ export const templateTriggerSchema = z.object({
344
+ config: templateConfigRefSchema
345
+ });
346
+ export const templateOutputSchema = z.object({
347
+ config: templateConfigRefSchema
348
+ });
349
+ export const templateCategorySchema = z.enum(["ship", "users", "sync", "track"]);
350
+ export const agentTemplateSchema = z.object({
351
+ id: z.string(),
352
+ category: templateCategorySchema,
353
+ name: z.string(),
354
+ description: z.string(),
355
+ chatPrompt: z.string(),
356
+ prompt: agentPromptSchema,
357
+ triggers: z.array(templateTriggerSchema),
358
+ outputs: z.array(templateOutputSchema),
359
+ requireApproval: z.boolean(),
360
+ isActive: z.boolean()
361
+ });
362
+ const runHistoryActionTypeSchema = z.enum(RUN_HISTORY_ACTION_TYPES);
363
+ const runHistoryStatusSchema = z.enum(RunHistoryStatus);
364
+ const runHistoryTriggerSchema = z.object({
365
+ event: z.string(),
366
+ integration: integrationTypeEnum,
367
+ source: z.string(),
368
+ title: z.string().optional(),
369
+ subheader: z.string().optional(),
370
+ url: z.string().optional()
371
+ });
372
+ const runHistoryDecisionSchema = z.object({
373
+ action: z.enum(["processed", "skipped"]),
374
+ reasoning: z.string()
375
+ });
376
+ const runHistoryRecordSchema = z.object({
377
+ id: z.string(),
378
+ agentId: z.string(),
379
+ timestamp: z.string(),
380
+ trigger: runHistoryTriggerSchema,
381
+ filtered: z.boolean(),
382
+ decision: runHistoryDecisionSchema,
383
+ actions: z.array(runHistoryActionBaseSchema).optional(),
384
+ status: runHistoryStatusSchema,
385
+ isManuallyTriggered: z.boolean()
386
+ });
387
+ const runHistoryRecordWithAgentSchema = runHistoryRecordSchema.extend({
388
+ agentName: z.string()
389
+ });
390
+ export const agentNotificationSettingsSchema = z.object({
391
+ enabled: z.boolean(),
392
+ actionTypes: z.array(runHistoryActionTypeSchema)
393
+ });
394
+ export const agentSchema = z.object({
395
+ id: z.string(),
396
+ name: z.string(),
397
+ isActive: z.boolean(),
398
+ requireApproval: z.boolean(),
399
+ prompt: agentPromptSchema,
400
+ triggers: z.array(agentTriggerSchema),
401
+ outputs: z.array(agentOutputSchema),
402
+ createdByUserId: z.string(),
403
+ notificationSettings: agentNotificationSettingsSchema.nullable(),
404
+ toolApprovals: z.array(z.string()).nullable(),
405
+ updatedAt: z.string().nullable(),
406
+ source: z.enum(["WEB_UI", "SDK"]).nullable()
407
+ });
408
+ export const agentUpdateSchema = z.object({
409
+ name: z.string().optional(),
410
+ triggers: z.array(agentTriggerSchema).optional(),
411
+ outputs: z.array(agentOutputSchema).optional(),
412
+ prompt: agentPromptSchema.optional(),
413
+ isActive: z.boolean().optional(),
414
+ requireApproval: z.boolean().optional(),
415
+ notificationSettings: agentNotificationSettingsSchema.nullable().optional(),
416
+ toolApprovals: z.array(z.string()).nullable().optional()
417
+ });
418
+ export const agentCreateSchema = agentSchema.omit({
419
+ id: true,
420
+ createdByUserId: true,
421
+ source: true,
422
+ updatedAt: true
423
+ });
424
+ export const agentDraftSchema = agentCreateSchema.extend({
425
+ id: z.string().nullable(),
426
+ createdByUserId: z.string()
427
+ });
428
+ export const paginationSchema = z.object({
429
+ page: z.number(),
430
+ limit: z.number(),
431
+ total: z.number(),
432
+ totalPages: z.number()
433
+ });
434
+ export const agentsResponseSchema = z.object({
435
+ agents: z.array(agentSchema),
436
+ pagination: paginationSchema
437
+ });
438
+ export const recentAgentSchema = agentSchema.extend({
439
+ updatedAt: z.string(),
440
+ lastEventProcessedAt: z.string().nullable()
441
+ });
442
+ export const agentImprovementStatusSchema = z.enum(["PENDING", "APPLIED", "DISMISSED"]);
443
+ export const agentImprovementTargetAreaSchema = z.enum(["prompt", "trigger_config", "output_config", "general", "code"]);
444
+ export const agentReviewSchema = z.object({
445
+ id: z.string(),
446
+ automationId: z.string(),
447
+ title: z.string(),
448
+ summary: z.string(),
449
+ runsAnalyzed: z.number().int(),
450
+ reviewPeriodStart: z.string(),
451
+ reviewPeriodEnd: z.string(),
452
+ createdAt: z.string()
453
+ });
454
+ export const agentImprovementSchema = z.object({
455
+ id: z.string(),
456
+ reviewId: z.string(),
457
+ automationId: z.string(),
458
+ title: z.string(),
459
+ description: z.string(),
460
+ targetArea: agentImprovementTargetAreaSchema,
461
+ confidence: z.number(),
462
+ status: agentImprovementStatusSchema,
463
+ suggestedPatch: z.string().optional(),
464
+ appliedPrompt: z.string().optional(),
465
+ appliedAt: z.string().optional(),
466
+ dismissedAt: z.string().optional(),
467
+ createdAt: z.string(),
468
+ updatedAt: z.string()
469
+ });
470
+ export const getAgentImprovementsResponseSchema = z.object({
471
+ review: agentReviewSchema.nullable(),
472
+ improvements: z.array(agentImprovementSchema),
473
+ improvementsEnabled: z.boolean()
474
+ });
475
+ export const applyImprovementResponseSchema = z.object({
476
+ success: z.boolean(),
477
+ appliedPrompt: z.string()
478
+ });
479
+ export const dismissImprovementResponseSchema = z.object({
480
+ success: z.boolean()
481
+ });
482
+ export const toggleImprovementsEnabledResponseSchema = z.object({
483
+ success: z.boolean(),
484
+ improvementsEnabled: z.boolean()
485
+ });
486
+ export const repositorySchema = z.object({
487
+ name: z.string(),
488
+ owner: z.string(),
489
+ id: z.number().int()
490
+ });
491
+ export const githubAppInstallationCallbackRequestSchema = z.object({
492
+ name: z.string(),
493
+ email: z.string(),
494
+ username: z.string(),
495
+ installationId: z.number().int(),
496
+ accountName: z.string().nullable(),
497
+ repositories: z.array(repositorySchema)
498
+ });
499
+ export const getGithubRepositoriesForIntegrationRequestSchema = z.object({});
500
+ export const getGithubRepositoriesForIntegrationResponseSchema = z.object({
501
+ repositories: z.array(repositorySchema)
502
+ });
503
+ export const oauthInstallationDetailsSchema = z.object({
504
+ oauthUrl: z.string()
505
+ });
506
+ export const formFieldTypeSchema = z.enum(["text", "password", "textarea"]);
507
+ export const formFieldDefinitionSchema = z.object({
508
+ name: z.string(),
509
+ type: formFieldTypeSchema,
510
+ label: z.string(),
511
+ placeholder: z.string().optional(),
512
+ required: z.boolean().optional(),
513
+ hint: z.string().optional()
514
+ });
515
+ export const configurationFieldTypeSchema = z.enum(["radio", "select"]);
516
+ export const configurationOptionSchema = z.object({
517
+ label: z.string(),
518
+ value: z.string()
519
+ });
520
+ export const configurationFieldDefinitionSchema = z.object({
521
+ name: z.string(),
522
+ type: configurationFieldTypeSchema,
523
+ label: z.string(),
524
+ options: z.array(configurationOptionSchema),
525
+ required: z.boolean().optional(),
526
+ hint: z.string().optional()
527
+ });
528
+ export const integrationFieldsResponseSchema = z.object({
529
+ installationType: z.enum(["form", "oauth"]),
530
+ fields: z.union([z.array(formFieldDefinitionSchema), z.array(configurationFieldDefinitionSchema)])
531
+ });
532
+ export const statsIntervalSchema = z.enum(["1h", "24h", "7d", "1mo", "3mo", "1y"]);
533
+ export const dailyEventCountSchema = z.object({
534
+ date: z.string(),
535
+ events: z.number().int()
536
+ });
537
+ export const recentActionSchema = z.object({
538
+ action: z.string(),
539
+ integration: integrationTypeEnum,
540
+ target: z.string(),
541
+ details: z.string(),
542
+ url: z.string().optional(),
543
+ timestamp: z.string(),
544
+ agentName: z.string(),
545
+ type: runHistoryActionTypeSchema
546
+ });
547
+ export const agentActivityItemSchema = z.object({
548
+ agentId: z.string(),
549
+ agentName: z.string(),
550
+ runCount: z.number().int()
551
+ });
552
+ export const countByStringSchema = z.object({
553
+ label: z.string(),
554
+ count: z.number().int()
555
+ });
556
+ export const statsResponseSchema = z.object({
557
+ totalEventsProcessed: z.number(),
558
+ totalEventsProcessedChange: z.string(),
559
+ actionsTaken: z.number(),
560
+ actionsTakenChange: z.string(),
561
+ numberOfAgents: z.number(),
562
+ numberOfAgentsChange: z.string(),
563
+ dailyEvents: z.array(dailyEventCountSchema),
564
+ recentActions: z.array(recentActionSchema),
565
+ recentRuns: z.array(runHistoryRecordWithAgentSchema),
566
+ timezone: z.string(),
567
+ agentActivity: z.array(agentActivityItemSchema),
568
+ statusBreakdown: z.array(countByStringSchema),
569
+ triggerIntegrations: z.array(countByStringSchema),
570
+ actionIntegrations: z.array(countByStringSchema),
571
+ actionTypes: z.array(countByStringSchema)
572
+ });
573
+ export const triggerPayloadSchema = z.object({
574
+ integrationId: z.string(),
575
+ integrationType: integrationTypeEnum,
576
+ config: configDataSchema
577
+ });
578
+ export const serializedEventSchema = z.object({
579
+ integrationType: integrationTypeEnum,
580
+ eventType: z.string().optional(),
581
+ formattedContent: z.string(),
582
+ debugLog: z.string(),
583
+ metadata: unknownRecordSchema.optional()
584
+ });
585
+ export const sdkAgentRunEventPayloadSchema = z.object({
586
+ integrationType: integrationTypeEnum,
587
+ formattedContent: z.string(),
588
+ debugLog: z.string()
589
+ });
590
+ export const partialSdkAgentRunEventPayloadSchema = sdkAgentRunEventPayloadSchema.partial();
591
+ export const sdkAgentRunOptionsPayloadSchema = z.object({
592
+ maxTurns: z.number().int().optional(),
593
+ requireApproval: z.boolean().optional()
594
+ });
595
+ export const sdkAgentRunRequestBodySchema = z.object({
596
+ prompt: z.string().optional(),
597
+ event: partialSdkAgentRunEventPayloadSchema.optional(),
598
+ skills: z.array(configDataSchema).optional(),
599
+ options: sdkAgentRunOptionsPayloadSchema.optional(),
600
+ toolApprovals: z.array(z.string()).optional()
601
+ });
602
+ export const sdkAgentRunResponseContractSchema = z.object({
603
+ responseMode: z.literal("streaming"),
604
+ supportsInterruptions: z.boolean()
605
+ });
606
+ export const sdkAgentRunNormalizedRequestOptionsSchema = z.object({
607
+ maxTurns: z.number().int(),
608
+ requireApproval: z.boolean()
609
+ });
610
+ export const sdkAgentRunNormalizedRequestSchema = z.object({
611
+ prompt: z.string(),
612
+ event: sdkAgentRunEventPayloadSchema,
613
+ skills: z.array(configDataSchema),
614
+ toolApprovals: z.array(z.string()),
615
+ options: sdkAgentRunNormalizedRequestOptionsSchema
616
+ });
617
+ export const sdkAgentRunResponseBodySchema = z.object({
618
+ success: z.boolean(),
619
+ error: z.string().optional(),
620
+ details: z.array(z.string()).optional(),
621
+ contract: sdkAgentRunResponseContractSchema.optional(),
622
+ normalizedRequest: sdkAgentRunNormalizedRequestSchema.optional()
623
+ });
624
+ export const toolApprovalRequestedPayloadSchema = z.object({
625
+ stepId: z.string(),
626
+ toolName: z.string(),
627
+ arguments: z.string()
628
+ });
629
+ export const sdkAgentStreamEventSchema = z.discriminatedUnion("type", [
630
+ z.object({ type: z.literal("run_started"), runId: z.string() }),
631
+ z.object({ type: z.literal("text"), text: z.string() }),
632
+ z.object({ type: z.literal("final_output"), finalOutput: z.string() }),
633
+ z.object({ type: z.literal("tool_call_params"), toolCallParams: z.string() }),
634
+ z.object({ type: z.literal("tool_call_started"), toolCallStarted: z.string() }),
635
+ z.object({ type: z.literal("tool_call_completed"), toolCallCompleted: z.string() }),
636
+ z.object({
637
+ type: z.literal("tool_approval_requested"),
638
+ toolApprovalRequested: toolApprovalRequestedPayloadSchema
639
+ }),
640
+ z.object({ type: z.literal("action"), action: runHistoryActionBaseSchema }),
641
+ z.object({ type: z.literal("error"), message: z.string() }),
642
+ z.object({ type: z.literal("done") })
643
+ ]);
644
+ export const sdkApprovalDecisionRequestBodySchema = z.object({
645
+ runId: z.string(),
646
+ stepId: z.string(),
647
+ approved: z.boolean()
648
+ });
649
+ export const sdkDeployJobSchema = z.object({
650
+ jobName: z.string(),
651
+ triggers: z.array(configDataSchema),
652
+ outputs: z.array(configDataSchema),
653
+ toolApprovals: z.array(z.string()),
654
+ webhookURL: z.string().optional()
655
+ });
656
+ export const sdkDeployRequestBodySchema = z.object({
657
+ jobs: z.array(sdkDeployJobSchema),
658
+ sourceZipBase64: z.string()
659
+ });
660
+ export const sdkDeployResultSchema = z.object({
661
+ jobName: z.string(),
662
+ automationId: z.string(),
663
+ isUpdate: z.boolean(),
664
+ triggers: z
665
+ .array(z.object({
666
+ id: z.string(),
667
+ metadata: triggerMetadataSchema.optional()
668
+ }))
669
+ .optional()
670
+ });
671
+ export const sdkDeployRemovedSchema = z.object({
672
+ id: z.string(),
673
+ name: z.string()
674
+ });
675
+ export const sdkDeployResponseBodySchema = z.object({
676
+ success: z.boolean(),
677
+ results: z.array(sdkDeployResultSchema),
678
+ removed: z.array(sdkDeployRemovedSchema),
679
+ error: z.string().optional(),
680
+ details: z.string().optional()
681
+ });
682
+ // ─── Request / param schemas ─────────────────────────────────────────
683
+ export const agentIdParamsSchema = z.object({
684
+ agentId: z.string()
685
+ });
686
+ export const agentAndImprovementParamsSchema = z.object({
687
+ agentId: z.string(),
688
+ id: z.string()
689
+ });
690
+ export const manualTriggerParamsSchema = z.object({
691
+ inputId: z.string()
692
+ });
693
+ export const triggerWithEventParamsSchema = z.object({
694
+ automationId: z.string()
695
+ });
696
+ export const logoUploadUrlQuerySchema = z.object({
697
+ contentType: z.string()
698
+ });
699
+ export const logoParamsSchema = z.object({
700
+ organizationId: z.string()
701
+ });
702
+ export const webhookWorkOSTriggerParamsSchema = z.object({
703
+ integrationId: z.string()
704
+ });
705
+ export const organizationCreateRequestSchema = z.object({
706
+ name: z.string(),
707
+ firstName: z.string().optional(),
708
+ lastName: z.string().optional()
709
+ });
710
+ export const organizationSwitchRequestSchema = z.object({
711
+ organizationId: z.string()
712
+ });
713
+ export const organizationUpdateRequestSchema = z.object({
714
+ name: z.string()
715
+ });
716
+ export const apiTokenCreateRequestSchema = z.object({
717
+ name: z.string().max(100)
718
+ });
719
+ export const apiTokenUpdateRequestSchema = z.object({
720
+ name: z.string().max(100)
721
+ });
722
+ export const deviceTokenExchangeRequestSchema = z.object({
723
+ accessToken: z.string()
724
+ });
725
+ export const sdkToolExecuteRequestSchema = z.object({
726
+ toolName: z.string(),
727
+ params: z.record(z.string(), z.unknown()).optional()
728
+ });
729
+ export const manualTriggerRequestSchema = z.object({
730
+ context: z.string().optional()
731
+ });
732
+ export const toggleImprovementsEnabledRequestSchema = z.object({
733
+ enabled: z.boolean()
734
+ });
735
+ export const workosWebhookSecretUpdateRequestSchema = z.object({
736
+ webhookSecret: z.string(),
737
+ state: z.string().optional()
738
+ });
739
+ export const sdkSampleEventsRequestSchema = z.object({
740
+ triggers: z.array(triggerPayloadSchema).min(1)
741
+ });
742
+ export const triggerWithEventRequestSchema = z.object({
743
+ event: serializedEventSchema
744
+ });