terse-types 0.0.3 → 0.0.5

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(),
@@ -312,19 +133,20 @@ export const deviceTokenExchangeResponseSchema = z.object({
312
133
  });
313
134
  const configInstanceDataSchema = configDataSchema;
314
135
  export const triggerMetadataSchema = z.object({
315
- webhookUrl: z.string().optional()
136
+ webhookUrl: z.string().nullable().optional()
316
137
  });
317
138
  export const agentTriggerSchema = z.object({
318
139
  id: z.string(),
319
140
  config: configInstanceDataSchema,
320
- metadata: triggerMetadataSchema.optional()
141
+ metadata: triggerMetadataSchema.nullable().optional()
321
142
  });
322
143
  export const agentOutputSchema = z.object({
323
144
  id: z.string(),
324
145
  config: configInstanceDataSchema
325
146
  });
326
147
  export const agentPromptSchema = z.object({
327
- text: z.string()
148
+ text: z.string(),
149
+ remoteServerUrl: z.string().optional()
328
150
  });
329
151
  export const transientAgentTriggerSchema = z.object({
330
152
  id: z.string(),
@@ -359,9 +181,7 @@ export const agentTemplateSchema = z.object({
359
181
  requireApproval: z.boolean(),
360
182
  isActive: z.boolean()
361
183
  });
362
- const runHistoryActionTypeSchema = z.enum(RUN_HISTORY_ACTION_TYPES);
363
- const runHistoryStatusSchema = z.enum(RunHistoryStatus);
364
- const runHistoryTriggerSchema = z.object({
184
+ export const runHistoryTriggerSchema = z.object({
365
185
  event: z.string(),
366
186
  integration: integrationTypeEnum,
367
187
  source: z.string(),
@@ -369,11 +189,11 @@ const runHistoryTriggerSchema = z.object({
369
189
  subheader: z.string().optional(),
370
190
  url: z.string().optional()
371
191
  });
372
- const runHistoryDecisionSchema = z.object({
373
- action: z.enum(["processed", "skipped"]),
192
+ export const runHistoryDecisionSchema = z.object({
193
+ action: runHistoryDecisionActionSchema,
374
194
  reasoning: z.string()
375
195
  });
376
- const runHistoryRecordSchema = z.object({
196
+ export const runHistoryRecordSchema = z.object({
377
197
  id: z.string(),
378
198
  agentId: z.string(),
379
199
  timestamp: z.string(),
@@ -384,7 +204,7 @@ const runHistoryRecordSchema = z.object({
384
204
  status: runHistoryStatusSchema,
385
205
  isManuallyTriggered: z.boolean()
386
206
  });
387
- const runHistoryRecordWithAgentSchema = runHistoryRecordSchema.extend({
207
+ export const runHistoryRecordWithAgentSchema = runHistoryRecordSchema.extend({
388
208
  agentName: z.string()
389
209
  });
390
210
  export const agentNotificationSettingsSchema = z.object({
@@ -570,32 +390,14 @@ export const statsResponseSchema = z.object({
570
390
  actionIntegrations: z.array(countByStringSchema),
571
391
  actionTypes: z.array(countByStringSchema)
572
392
  });
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
393
  export const sdkAgentRunOptionsPayloadSchema = z.object({
592
394
  maxTurns: z.number().int().optional(),
593
395
  requireApproval: z.boolean().optional()
594
396
  });
595
397
  export const sdkAgentRunRequestBodySchema = z.object({
596
398
  prompt: z.string().optional(),
597
- event: partialSdkAgentRunEventPayloadSchema.optional(),
598
- skills: z.array(configDataSchema).optional(),
399
+ event: TriggerSchema.optional(),
400
+ skills: z.array(skillConfigDataSchema).optional(),
599
401
  options: sdkAgentRunOptionsPayloadSchema.optional(),
600
402
  toolApprovals: z.array(z.string()).optional()
601
403
  });
@@ -609,8 +411,8 @@ export const sdkAgentRunNormalizedRequestOptionsSchema = z.object({
609
411
  });
610
412
  export const sdkAgentRunNormalizedRequestSchema = z.object({
611
413
  prompt: z.string(),
612
- event: sdkAgentRunEventPayloadSchema,
613
- skills: z.array(configDataSchema),
414
+ event: TriggerSchema,
415
+ skills: z.array(skillConfigDataSchema),
614
416
  toolApprovals: z.array(z.string()),
615
417
  options: sdkAgentRunNormalizedRequestOptionsSchema
616
418
  });
@@ -626,20 +428,30 @@ export const toolApprovalRequestedPayloadSchema = z.object({
626
428
  toolName: z.string(),
627
429
  arguments: z.string()
628
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") });
629
444
  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") })
445
+ runStartedSchema,
446
+ textSchema,
447
+ finalOutputSchema,
448
+ toolCallParamsSchema,
449
+ toolCallStartedSchema,
450
+ toolCallCompletedSchema,
451
+ toolApprovalRequestedSchema,
452
+ actionSchema,
453
+ errorSchema,
454
+ doneSchema
643
455
  ]);
644
456
  export const sdkApprovalDecisionRequestBodySchema = z.object({
645
457
  runId: z.string(),
@@ -648,19 +460,29 @@ export const sdkApprovalDecisionRequestBodySchema = z.object({
648
460
  });
649
461
  export const sdkDeployJobSchema = z.object({
650
462
  jobName: z.string(),
651
- triggers: z.array(configDataSchema),
652
- outputs: z.array(configDataSchema),
653
- toolApprovals: z.array(z.string()),
654
- webhookURL: z.string().optional()
463
+ triggers: z.array(triggerConfigDataSchema),
464
+ outputs: z.array(skillConfigDataSchema),
465
+ toolApprovals: z.array(z.string())
655
466
  });
656
- export const sdkDeployRequestBodySchema = z.object({
467
+ export const sdkDeployRequestBodySchema = z
468
+ .object({
657
469
  jobs: z.array(sdkDeployJobSchema),
658
- 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"]
659
480
  });
660
481
  export const sdkDeployResultSchema = z.object({
661
482
  jobName: z.string(),
662
483
  automationId: z.string(),
663
484
  isUpdate: z.boolean(),
485
+ signingSecret: z.string().optional(),
664
486
  triggers: z
665
487
  .array(z.object({
666
488
  id: z.string(),
@@ -679,6 +501,14 @@ export const sdkDeployResponseBodySchema = z.object({
679
501
  error: z.string().optional(),
680
502
  details: z.string().optional()
681
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
+ });
682
512
  // ─── Request / param schemas ─────────────────────────────────────────
683
513
  export const agentIdParamsSchema = z.object({
684
514
  agentId: z.string()
@@ -737,8 +567,55 @@ export const workosWebhookSecretUpdateRequestSchema = z.object({
737
567
  state: z.string().optional()
738
568
  });
739
569
  export const sdkSampleEventsRequestSchema = z.object({
740
- 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)
741
577
  });
742
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(),
743
598
  event: serializedEventSchema
744
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.3",
3
+ "version": "0.0.5",
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": {