terse-types 0.0.2 → 0.0.4

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,13 +1,10 @@
1
1
  import * as z from "zod";
2
- import { configDataSchema, configTypeEnum } from "./Configs.js";
2
+ import { configDataSchema, configTypeEnum, skillConfigDataSchema, triggerConfigDataSchema } from "./Configs.js";
3
3
  import { integrationTypeEnum } from "./Integrations.js";
4
- import { RUN_HISTORY_ACTION_TYPES, RunHistoryStatus, runHistoryActionBaseSchema } from "./RunHistoryTypes.js";
4
+ import { runHistoryActionBaseSchema, runHistoryActionTypeSchema, runHistoryDecisionActionSchema, runHistoryStatusSchema } from "./RunHistoryTypes.js";
5
+ import { SlackChannelType, slackChannelTypeSchema } from "./SlackTypes.js";
5
6
  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());
7
+ import { TriggerSchema, serializedEventSchema } from "./Triggers.js";
11
8
  export const roleSchema = z.enum(["admin", "user"]);
12
9
  export const userSchema = z.object({
13
10
  id: z.string(),
@@ -47,16 +44,6 @@ export const linearWorkspaceSchema = z.object({
47
44
  id: z.string(),
48
45
  name: z.string()
49
46
  });
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
47
  export const notionResourceTypeSchema = z.enum(["database", "page"]);
61
48
  export const notionResourceSchema = z.object({
62
49
  id: z.string(),
@@ -123,173 +110,7 @@ export const terseAgentMessageMetadataSchema = z.object({
123
110
  event_type: z.literal(TERSE_AGENT_MESSAGE_EVENT_TYPE),
124
111
  event_payload: terseAgentMessageEventPayloadSchema
125
112
  });
126
- export var SlackChannelType;
127
- (function (SlackChannelType) {
128
- SlackChannelType["CHANNEL"] = "channel";
129
- SlackChannelType["GROUP"] = "group";
130
- SlackChannelType["MPIM"] = "mpim";
131
- SlackChannelType["IM"] = "im";
132
- })(SlackChannelType || (SlackChannelType = {}));
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
- });
188
- export var FigmaEventTypes;
189
- (function (FigmaEventTypes) {
190
- FigmaEventTypes["FILE_COMMENT"] = "FILE_COMMENT";
191
- })(FigmaEventTypes || (FigmaEventTypes = {}));
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
- });
113
+ export { SlackChannelType, slackChannelTypeSchema };
293
114
  export const apiTokenSchema = z.object({
294
115
  id: z.string(),
295
116
  name: z.string(),
@@ -311,16 +132,21 @@ export const deviceTokenExchangeResponseSchema = z.object({
311
132
  user: deviceTokenExchangeUserSchema
312
133
  });
313
134
  const configInstanceDataSchema = configDataSchema;
135
+ export const triggerMetadataSchema = z.object({
136
+ webhookUrl: z.string().nullable().optional()
137
+ });
314
138
  export const agentTriggerSchema = z.object({
315
139
  id: z.string(),
316
- config: configInstanceDataSchema
140
+ config: configInstanceDataSchema,
141
+ metadata: triggerMetadataSchema.nullable().optional()
317
142
  });
318
143
  export const agentOutputSchema = z.object({
319
144
  id: z.string(),
320
145
  config: configInstanceDataSchema
321
146
  });
322
147
  export const agentPromptSchema = z.object({
323
- text: z.string()
148
+ text: z.string(),
149
+ remoteServerUrl: z.string().optional()
324
150
  });
325
151
  export const transientAgentTriggerSchema = z.object({
326
152
  id: z.string(),
@@ -355,9 +181,7 @@ export const agentTemplateSchema = z.object({
355
181
  requireApproval: z.boolean(),
356
182
  isActive: z.boolean()
357
183
  });
358
- const runHistoryActionTypeSchema = z.enum(RUN_HISTORY_ACTION_TYPES);
359
- const runHistoryStatusSchema = z.enum(RunHistoryStatus);
360
- const runHistoryTriggerSchema = z.object({
184
+ export const runHistoryTriggerSchema = z.object({
361
185
  event: z.string(),
362
186
  integration: integrationTypeEnum,
363
187
  source: z.string(),
@@ -365,11 +189,11 @@ const runHistoryTriggerSchema = z.object({
365
189
  subheader: z.string().optional(),
366
190
  url: z.string().optional()
367
191
  });
368
- const runHistoryDecisionSchema = z.object({
369
- action: z.enum(["processed", "skipped"]),
192
+ export const runHistoryDecisionSchema = z.object({
193
+ action: runHistoryDecisionActionSchema,
370
194
  reasoning: z.string()
371
195
  });
372
- const runHistoryRecordSchema = z.object({
196
+ export const runHistoryRecordSchema = z.object({
373
197
  id: z.string(),
374
198
  agentId: z.string(),
375
199
  timestamp: z.string(),
@@ -380,7 +204,7 @@ const runHistoryRecordSchema = z.object({
380
204
  status: runHistoryStatusSchema,
381
205
  isManuallyTriggered: z.boolean()
382
206
  });
383
- const runHistoryRecordWithAgentSchema = runHistoryRecordSchema.extend({
207
+ export const runHistoryRecordWithAgentSchema = runHistoryRecordSchema.extend({
384
208
  agentName: z.string()
385
209
  });
386
210
  export const agentNotificationSettingsSchema = z.object({
@@ -566,32 +390,14 @@ export const statsResponseSchema = z.object({
566
390
  actionIntegrations: z.array(countByStringSchema),
567
391
  actionTypes: z.array(countByStringSchema)
568
392
  });
569
- export const triggerPayloadSchema = z.object({
570
- integrationId: z.string(),
571
- integrationType: integrationTypeEnum,
572
- config: configDataSchema
573
- });
574
- export const serializedEventSchema = z.object({
575
- integrationType: integrationTypeEnum,
576
- eventType: z.string().optional(),
577
- formattedContent: z.string(),
578
- debugLog: z.string(),
579
- metadata: unknownRecordSchema.optional()
580
- });
581
- export const sdkAgentRunEventPayloadSchema = z.object({
582
- integrationType: integrationTypeEnum,
583
- formattedContent: z.string(),
584
- debugLog: z.string()
585
- });
586
- export const partialSdkAgentRunEventPayloadSchema = sdkAgentRunEventPayloadSchema.partial();
587
393
  export const sdkAgentRunOptionsPayloadSchema = z.object({
588
394
  maxTurns: z.number().int().optional(),
589
395
  requireApproval: z.boolean().optional()
590
396
  });
591
397
  export const sdkAgentRunRequestBodySchema = z.object({
592
398
  prompt: z.string().optional(),
593
- event: partialSdkAgentRunEventPayloadSchema.optional(),
594
- skills: z.array(configDataSchema).optional(),
399
+ event: TriggerSchema.optional(),
400
+ skills: z.array(skillConfigDataSchema).optional(),
595
401
  options: sdkAgentRunOptionsPayloadSchema.optional(),
596
402
  toolApprovals: z.array(z.string()).optional()
597
403
  });
@@ -605,8 +411,8 @@ export const sdkAgentRunNormalizedRequestOptionsSchema = z.object({
605
411
  });
606
412
  export const sdkAgentRunNormalizedRequestSchema = z.object({
607
413
  prompt: z.string(),
608
- event: sdkAgentRunEventPayloadSchema,
609
- skills: z.array(configDataSchema),
414
+ event: TriggerSchema,
415
+ skills: z.array(skillConfigDataSchema),
610
416
  toolApprovals: z.array(z.string()),
611
417
  options: sdkAgentRunNormalizedRequestOptionsSchema
612
418
  });
@@ -622,20 +428,30 @@ export const toolApprovalRequestedPayloadSchema = z.object({
622
428
  toolName: z.string(),
623
429
  arguments: z.string()
624
430
  });
431
+ export const runStartedSchema = z.object({ type: z.literal("run_started"), runId: z.string() });
432
+ export const textSchema = z.object({ type: z.literal("text"), text: z.string() });
433
+ export const finalOutputSchema = z.object({ type: z.literal("final_output"), finalOutput: z.string() });
434
+ export const toolCallParamsSchema = z.object({ type: z.literal("tool_call_params"), toolCallParams: z.string() });
435
+ export const toolCallStartedSchema = z.object({ type: z.literal("tool_call_started"), toolCallStarted: z.string() });
436
+ export const toolCallCompletedSchema = z.object({ type: z.literal("tool_call_completed"), toolCallCompleted: z.string() });
437
+ export const toolApprovalRequestedSchema = z.object({
438
+ type: z.literal("tool_approval_requested"),
439
+ toolApprovalRequested: toolApprovalRequestedPayloadSchema
440
+ });
441
+ export const actionSchema = z.object({ type: z.literal("action"), action: runHistoryActionBaseSchema });
442
+ export const errorSchema = z.object({ type: z.literal("error"), message: z.string() });
443
+ export const doneSchema = z.object({ type: z.literal("done") });
625
444
  export const sdkAgentStreamEventSchema = z.discriminatedUnion("type", [
626
- z.object({ type: z.literal("run_started"), runId: z.string() }),
627
- z.object({ type: z.literal("text"), text: z.string() }),
628
- z.object({ type: z.literal("final_output"), finalOutput: z.string() }),
629
- z.object({ type: z.literal("tool_call_params"), toolCallParams: z.string() }),
630
- z.object({ type: z.literal("tool_call_started"), toolCallStarted: z.string() }),
631
- z.object({ type: z.literal("tool_call_completed"), toolCallCompleted: z.string() }),
632
- z.object({
633
- type: z.literal("tool_approval_requested"),
634
- toolApprovalRequested: toolApprovalRequestedPayloadSchema
635
- }),
636
- z.object({ type: z.literal("action"), action: runHistoryActionBaseSchema }),
637
- z.object({ type: z.literal("error"), message: z.string() }),
638
- z.object({ type: z.literal("done") })
445
+ runStartedSchema,
446
+ textSchema,
447
+ finalOutputSchema,
448
+ toolCallParamsSchema,
449
+ toolCallStartedSchema,
450
+ toolCallCompletedSchema,
451
+ toolApprovalRequestedSchema,
452
+ actionSchema,
453
+ errorSchema,
454
+ doneSchema
639
455
  ]);
640
456
  export const sdkApprovalDecisionRequestBodySchema = z.object({
641
457
  runId: z.string(),
@@ -644,19 +460,35 @@ export const sdkApprovalDecisionRequestBodySchema = z.object({
644
460
  });
645
461
  export const sdkDeployJobSchema = z.object({
646
462
  jobName: z.string(),
647
- triggers: z.array(configDataSchema),
648
- outputs: z.array(configDataSchema),
649
- toolApprovals: z.array(z.string()),
650
- webhookURL: z.string().optional()
463
+ triggers: z.array(triggerConfigDataSchema),
464
+ outputs: z.array(skillConfigDataSchema),
465
+ toolApprovals: z.array(z.string())
651
466
  });
652
- export const sdkDeployRequestBodySchema = z.object({
467
+ export const sdkDeployRequestBodySchema = z
468
+ .object({
653
469
  jobs: z.array(sdkDeployJobSchema),
654
- sourceZipBase64: z.string()
470
+ remoteServerUrl: z.string().optional(),
471
+ sourceZipBase64: z.string().optional()
472
+ })
473
+ .refine(data => !(data.remoteServerUrl && data.sourceZipBase64), {
474
+ message: "remoteServerUrl and sourceZipBase64 cannot be provided together",
475
+ path: ["remoteServerUrl"]
476
+ })
477
+ .refine(data => data.remoteServerUrl != null || data.sourceZipBase64 != null, {
478
+ message: "Either remoteServerUrl or sourceZipBase64 is required",
479
+ path: ["sourceZipBase64"]
655
480
  });
656
481
  export const sdkDeployResultSchema = z.object({
657
482
  jobName: z.string(),
658
483
  automationId: z.string(),
659
- isUpdate: z.boolean()
484
+ isUpdate: z.boolean(),
485
+ signingSecret: z.string().optional(),
486
+ triggers: z
487
+ .array(z.object({
488
+ id: z.string(),
489
+ metadata: triggerMetadataSchema.optional()
490
+ }))
491
+ .optional()
660
492
  });
661
493
  export const sdkDeployRemovedSchema = z.object({
662
494
  id: z.string(),
@@ -669,6 +501,14 @@ export const sdkDeployResponseBodySchema = z.object({
669
501
  error: z.string().optional(),
670
502
  details: z.string().optional()
671
503
  });
504
+ export const sdkJobServerCheckStepSchema = z.enum(["http", "json", "response_schema", "challenge_echo", "challenge_signature"]);
505
+ export const sdkJobServerCheckResponseSchema = z.object({
506
+ success: z.boolean(),
507
+ message: z.string(),
508
+ triggerUrl: z.string().optional(),
509
+ step: sdkJobServerCheckStepSchema.optional(),
510
+ httpStatus: z.number().optional()
511
+ });
672
512
  // ─── Request / param schemas ─────────────────────────────────────────
673
513
  export const agentIdParamsSchema = z.object({
674
514
  agentId: z.string()
@@ -727,8 +567,55 @@ export const workosWebhookSecretUpdateRequestSchema = z.object({
727
567
  state: z.string().optional()
728
568
  });
729
569
  export const sdkSampleEventsRequestSchema = z.object({
730
- triggers: z.array(triggerPayloadSchema).min(1)
570
+ triggers: z
571
+ .array(z.object({
572
+ integrationId: z.string(),
573
+ integrationType: integrationTypeEnum,
574
+ config: configDataSchema
575
+ }))
576
+ .min(1)
731
577
  });
732
578
  export const triggerWithEventRequestSchema = z.object({
579
+ event: TriggerSchema
580
+ });
581
+ export const TERSE_SIGNATURE_HEADER = "x-terse-signature";
582
+ export const TERSE_TIMESTAMP_HEADER = "x-terse-timestamp";
583
+ export const TERSE_SIGNATURE_VERSION = "v0";
584
+ /** Challenge request sent by the Terse backend to the customer's SDK server. */
585
+ export const webhookJobChallengeRequestSchema = z.object({
586
+ type: z.literal("challenge"),
587
+ challenge: z.string().min(1)
588
+ });
589
+ /** Challenge response from the customer's SDK server -- echoes the token and signs it with the shared signing secret. */
590
+ export const webhookJobChallengeResponseSchema = z.object({
591
+ challenge: z.string().min(1),
592
+ signature: z.string().min(1)
593
+ });
594
+ /** Second-phase POST: full trigger payload after the backend has verified the challenge handshake. */
595
+ export const webhookJobTriggerRequestSchema = z.object({
596
+ jobName: z.string(),
597
+ runId: z.string(),
733
598
  event: serializedEventSchema
734
599
  });
600
+ export const webhookJobTriggerResponseSchema = z.object({
601
+ status: z.string().optional(),
602
+ filtered: z.boolean().optional()
603
+ });
604
+ const fileSchema = z.object({
605
+ id: z.string(),
606
+ name: z.string(),
607
+ get children() {
608
+ return z.array(fileSchema).optional();
609
+ }
610
+ });
611
+ export const agentFilesResponseSchema = z.object({
612
+ id: z.string(),
613
+ files: z.array(fileSchema)
614
+ });
615
+ /** Proxied SDK zip member: raw bytes as base64 plus path metadata (no separate GCS objects). */
616
+ export const agentFileContentResponseSchema = z.object({
617
+ path: z.string(),
618
+ fileName: z.string(),
619
+ contentBase64: z.string(),
620
+ mimeType: z.string().optional()
621
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "terse-types",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "type": "module",
5
5
  "description": "Shared Terse TypeScript types, enums, constants, and helpers.",
6
6
  "main": "./dist/index.js",
@@ -34,6 +34,8 @@
34
34
  "typescript": "^5.8.3"
35
35
  },
36
36
  "dependencies": {
37
+ "@slack/types": "^2.20.1",
38
+ "@slack/web-api": "^7.15.0",
37
39
  "zod": "4.3.6"
38
40
  },
39
41
  "scripts": {