terse-types 0.0.12 → 0.0.13

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.
@@ -152,6 +152,7 @@ export declare const ApiRoutes: {
152
152
  WORKOS: string;
153
153
  LINEAR_BY_USER_ID: string;
154
154
  SCHEDULE_BY_INPUT_ID: string;
155
+ WEBMONITOR_BY_INPUT_ID: string;
155
156
  WORKOS_TRIGGER_BY_INTEGRATION_ID: string;
156
157
  WEBHOOK_TRIGGER_BY_TOKEN: string;
157
158
  };
@@ -152,6 +152,7 @@
152
152
  "WORKOS": "/webhooks/workos",
153
153
  "LINEAR_BY_USER_ID": "/webhooks/linear/:userId",
154
154
  "SCHEDULE_BY_INPUT_ID": "/webhooks/schedule/:inputId",
155
+ "WEBMONITOR_BY_INPUT_ID": "/webhooks/webmonitor/:inputId",
155
156
  "WORKOS_TRIGGER_BY_INTEGRATION_ID": "/webhooks/workos-trigger/:integrationId",
156
157
  "WEBHOOK_TRIGGER_BY_TOKEN": "/webhooks/trigger/:webhookToken"
157
158
  },
package/dist/Configs.d.ts CHANGED
@@ -19,9 +19,16 @@ export declare enum ConfigType {
19
19
  WORKOS_OUTPUT = "workos_output",
20
20
  ATTIO_OUTPUT = "attio_output",
21
21
  SNOWFLAKE_OUTPUT = "snowflake_output",
22
- WEBHOOK_INPUT = "webhook_input"
22
+ WEBHOOK_INPUT = "webhook_input",
23
+ WEBMONITOR = "webmonitor"
23
24
  }
24
25
  export declare const configTypeEnum: z.ZodEnum<typeof ConfigType>;
26
+ export declare const frequencyUnitSchema: z.ZodEnum<{
27
+ hour: "hour";
28
+ day: "day";
29
+ week: "week";
30
+ }>;
31
+ export type FrequencyUnit = z.infer<typeof frequencyUnitSchema>;
25
32
  export interface ConfigDetails {
26
33
  configType: ConfigType;
27
34
  name: string;
@@ -182,6 +189,14 @@ export declare const WebhookInputConfigMetadata: {
182
189
  readonly isInput: true;
183
190
  readonly isOutput: false;
184
191
  };
192
+ export declare const WebMonitorConfigMetadata: {
193
+ readonly configType: ConfigType.WEBMONITOR;
194
+ readonly name: "Web Monitor";
195
+ readonly description: "Run when scheduled web monitoring detects relevant changes";
196
+ readonly integrationType: IntegrationType.WEBMONITOR;
197
+ readonly isInput: true;
198
+ readonly isOutput: false;
199
+ };
185
200
  export type ConfigDetailsMap = Record<ConfigType, ConfigDetails>;
186
201
  export declare const CONFIG_DETAILS: ConfigDetailsMap;
187
202
  export declare const SlackEventType: {
@@ -603,6 +618,50 @@ export declare class WebhookInputConfig extends BaseConfigInstance<IntegrationTy
603
618
  isComplete(): boolean;
604
619
  formatForAgent(): string;
605
620
  }
621
+ export declare const WebMonitorOutputSchemaSchema: z.ZodObject<{
622
+ type: z.ZodLiteral<"json">;
623
+ jsonSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
624
+ }, z.core.$strip>;
625
+ export type WebMonitorOutputSchema = z.infer<typeof WebMonitorOutputSchemaSchema>;
626
+ export declare const WebMonitorConfigSchema: z.ZodObject<{
627
+ integrationId: z.ZodLiteral<"system">;
628
+ integrationType: z.ZodLiteral<IntegrationType.WEBMONITOR>;
629
+ configType: z.ZodLiteral<ConfigType.WEBMONITOR>;
630
+ query: z.ZodString;
631
+ frequency: z.ZodObject<{
632
+ number: z.ZodNumber;
633
+ unit: z.ZodEnum<{
634
+ hour: "hour";
635
+ day: "day";
636
+ week: "week";
637
+ }>;
638
+ }, z.core.$strip>;
639
+ outputSchema: z.ZodPipe<z.ZodTransform<{
640
+ type: "json";
641
+ jsonSchema: Record<string, unknown>;
642
+ } | undefined, unknown>, z.ZodOptional<z.ZodObject<{
643
+ type: z.ZodLiteral<"json">;
644
+ jsonSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
645
+ }, z.core.$strip>>>;
646
+ }, z.core.$strip>;
647
+ export type WebMonitorConfigData = z.infer<typeof WebMonitorConfigSchema>;
648
+ export type WebMonitorConfigInstance = WebMonitorConfigData & ConfigBehavior;
649
+ export declare class WebMonitorConfig extends BaseConfigInstance<IntegrationType.WEBMONITOR, ConfigType.WEBMONITOR, "system"> implements WebMonitorConfigInstance {
650
+ query: string;
651
+ frequency: {
652
+ number: number;
653
+ unit: FrequencyUnit;
654
+ };
655
+ readonly outputSchema?: WebMonitorOutputSchema;
656
+ private readonly rawOutputSchema?;
657
+ constructor(query: string, frequency: {
658
+ number: number;
659
+ unit: FrequencyUnit;
660
+ }, outputSchema?: unknown);
661
+ isComplete(): boolean;
662
+ formatForAgent(): string;
663
+ toJSON(): WebMonitorConfigData;
664
+ }
606
665
  export declare const configDataSchema: z.ZodUnion<readonly [z.ZodObject<{
607
666
  integrationId: z.ZodString;
608
667
  integrationType: z.ZodLiteral<IntegrationType.GMAIL>;
@@ -743,6 +802,26 @@ export declare const configDataSchema: z.ZodUnion<readonly [z.ZodObject<{
743
802
  integrationId: z.ZodLiteral<"system">;
744
803
  integrationType: z.ZodLiteral<IntegrationType.WEBHOOK>;
745
804
  configType: z.ZodLiteral<ConfigType.WEBHOOK_INPUT>;
805
+ }, z.core.$strip>, z.ZodObject<{
806
+ integrationId: z.ZodLiteral<"system">;
807
+ integrationType: z.ZodLiteral<IntegrationType.WEBMONITOR>;
808
+ configType: z.ZodLiteral<ConfigType.WEBMONITOR>;
809
+ query: z.ZodString;
810
+ frequency: z.ZodObject<{
811
+ number: z.ZodNumber;
812
+ unit: z.ZodEnum<{
813
+ hour: "hour";
814
+ day: "day";
815
+ week: "week";
816
+ }>;
817
+ }, z.core.$strip>;
818
+ outputSchema: z.ZodPipe<z.ZodTransform<{
819
+ type: "json";
820
+ jsonSchema: Record<string, unknown>;
821
+ } | undefined, unknown>, z.ZodOptional<z.ZodObject<{
822
+ type: z.ZodLiteral<"json">;
823
+ jsonSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
824
+ }, z.core.$strip>>>;
746
825
  }, z.core.$strip>]>;
747
826
  export type ConfigData = z.infer<typeof configDataSchema>;
748
827
  /** Configs that can serve as triggers (event sources). */
@@ -815,6 +894,26 @@ export declare const triggerConfigDataSchema: z.ZodUnion<readonly [z.ZodObject<{
815
894
  integrationId: z.ZodLiteral<"system">;
816
895
  integrationType: z.ZodLiteral<IntegrationType.WEBHOOK>;
817
896
  configType: z.ZodLiteral<ConfigType.WEBHOOK_INPUT>;
897
+ }, z.core.$strip>, z.ZodObject<{
898
+ integrationId: z.ZodLiteral<"system">;
899
+ integrationType: z.ZodLiteral<IntegrationType.WEBMONITOR>;
900
+ configType: z.ZodLiteral<ConfigType.WEBMONITOR>;
901
+ query: z.ZodString;
902
+ frequency: z.ZodObject<{
903
+ number: z.ZodNumber;
904
+ unit: z.ZodEnum<{
905
+ hour: "hour";
906
+ day: "day";
907
+ week: "week";
908
+ }>;
909
+ }, z.core.$strip>;
910
+ outputSchema: z.ZodPipe<z.ZodTransform<{
911
+ type: "json";
912
+ jsonSchema: Record<string, unknown>;
913
+ } | undefined, unknown>, z.ZodOptional<z.ZodObject<{
914
+ type: z.ZodLiteral<"json">;
915
+ jsonSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
916
+ }, z.core.$strip>>>;
818
917
  }, z.core.$strip>]>;
819
918
  export type TriggerConfigData = z.infer<typeof triggerConfigDataSchema>;
820
919
  /** Configs that can serve as skills (tools / outputs). */
@@ -914,6 +1013,7 @@ export type ConfigMetadataMap = EnsureExhaustiveMetadata<{
914
1013
  [ConfigType.ATTIO_OUTPUT]: typeof AttioOutputConfig;
915
1014
  [ConfigType.SNOWFLAKE_OUTPUT]: typeof SnowflakeOutputConfig;
916
1015
  [ConfigType.WEBHOOK_INPUT]: typeof WebhookInputConfig;
1016
+ [ConfigType.WEBMONITOR]: typeof WebMonitorConfig;
917
1017
  }>;
918
1018
  export declare const CONFIG_METADATA: ConfigMetadataMap;
919
1019
  export {};
package/dist/Configs.js CHANGED
@@ -21,8 +21,10 @@ export var ConfigType;
21
21
  ConfigType["ATTIO_OUTPUT"] = "attio_output";
22
22
  ConfigType["SNOWFLAKE_OUTPUT"] = "snowflake_output";
23
23
  ConfigType["WEBHOOK_INPUT"] = "webhook_input";
24
+ ConfigType["WEBMONITOR"] = "webmonitor";
24
25
  })(ConfigType || (ConfigType = {}));
25
26
  export const configTypeEnum = z.enum(ConfigType);
27
+ export const frequencyUnitSchema = z.enum(["hour", "day", "week"]);
26
28
  // Metadata objects - using const objects instead of classes
27
29
  export const GmailConfigMetadata = {
28
30
  configType: ConfigType.GMAIL,
@@ -176,6 +178,14 @@ export const WebhookInputConfigMetadata = {
176
178
  isInput: true,
177
179
  isOutput: false
178
180
  };
181
+ export const WebMonitorConfigMetadata = {
182
+ configType: ConfigType.WEBMONITOR,
183
+ name: "Web Monitor",
184
+ description: "Run when scheduled web monitoring detects relevant changes",
185
+ integrationType: IntegrationType.WEBMONITOR,
186
+ isInput: true,
187
+ isOutput: false
188
+ };
179
189
  export const CONFIG_DETAILS = {
180
190
  [ConfigType.GMAIL]: GmailConfigMetadata,
181
191
  [ConfigType.GMAIL_OUTPUT]: GmailOutputConfigMetadata,
@@ -195,7 +205,8 @@ export const CONFIG_DETAILS = {
195
205
  [ConfigType.WORKOS_OUTPUT]: WorkOSOutputConfigMetadata,
196
206
  [ConfigType.ATTIO_OUTPUT]: AttioOutputConfigMetadata,
197
207
  [ConfigType.SNOWFLAKE_OUTPUT]: SnowflakeOutputConfigMetadata,
198
- [ConfigType.WEBHOOK_INPUT]: WebhookInputConfigMetadata
208
+ [ConfigType.WEBHOOK_INPUT]: WebhookInputConfigMetadata,
209
+ [ConfigType.WEBMONITOR]: WebMonitorConfigMetadata
199
210
  };
200
211
  // MARK: Event Types — specific events within each integration trigger
201
212
  export const SlackEventType = {
@@ -241,6 +252,9 @@ export const ConfigInstanceSchema = z.object({
241
252
  integrationType: integrationTypeEnum,
242
253
  configType: configTypeEnum
243
254
  });
255
+ function isZodSchemaLike(value) {
256
+ return !!value && typeof value === "object" && "_zod" in value;
257
+ }
244
258
  class BaseConfigInstance {
245
259
  integrationId;
246
260
  integrationType;
@@ -735,6 +749,80 @@ export class WebhookInputConfig extends BaseConfigInstance {
735
749
  return "Type: Webhook Trigger";
736
750
  }
737
751
  }
752
+ function isPlainObject(value) {
753
+ return !!value && typeof value === "object" && !Array.isArray(value);
754
+ }
755
+ export const WebMonitorOutputSchemaSchema = z.object({
756
+ type: z.literal("json"),
757
+ jsonSchema: z.record(z.string(), z.unknown())
758
+ });
759
+ function normalizeWebMonitorOutputSchema(value) {
760
+ if (value == null) {
761
+ return undefined;
762
+ }
763
+ if (isZodSchemaLike(value)) {
764
+ const jsonSchema = z.toJSONSchema(value, {
765
+ target: "draft-2020-12",
766
+ unrepresentable: "any",
767
+ cycles: "throw"
768
+ });
769
+ if (!isPlainObject(jsonSchema)) {
770
+ throw new Error("WebMonitor outputSchema did not produce a valid JSON schema object.");
771
+ }
772
+ if ("$schema" in jsonSchema) {
773
+ delete jsonSchema.$schema;
774
+ }
775
+ return { type: "json", jsonSchema };
776
+ }
777
+ return WebMonitorOutputSchemaSchema.parse(value);
778
+ }
779
+ export const WebMonitorConfigSchema = ConfigInstanceSchema.extend({
780
+ integrationId: z.literal("system"),
781
+ integrationType: z.literal(IntegrationType.WEBMONITOR),
782
+ configType: z.literal(ConfigType.WEBMONITOR),
783
+ query: z.string(),
784
+ frequency: z.object({
785
+ number: z.number(),
786
+ unit: frequencyUnitSchema
787
+ }),
788
+ outputSchema: z.preprocess(value => normalizeWebMonitorOutputSchema(value), WebMonitorOutputSchemaSchema.optional())
789
+ });
790
+ export class WebMonitorConfig extends BaseConfigInstance {
791
+ query;
792
+ frequency;
793
+ outputSchema;
794
+ rawOutputSchema;
795
+ constructor(query, frequency, outputSchema) {
796
+ super("system", IntegrationType.WEBMONITOR, ConfigType.WEBMONITOR);
797
+ this.query = query;
798
+ this.frequency = frequency;
799
+ this.rawOutputSchema = outputSchema;
800
+ this.outputSchema = normalizeWebMonitorOutputSchema(outputSchema);
801
+ }
802
+ isComplete() {
803
+ return !!(this.query && this.frequency);
804
+ }
805
+ formatForAgent() {
806
+ const parts = [`Type: Web Monitor`];
807
+ if (this.query)
808
+ parts.push(`Query: ${this.query}`);
809
+ if (this.frequency)
810
+ parts.push(`Frequency: ${this.frequency.number}${this.frequency.unit}`);
811
+ if (this.outputSchema)
812
+ parts.push(`Structured Output: ${typeof this.outputSchema === "object" ? "enabled" : "configured"}`);
813
+ return parts.join("\n");
814
+ }
815
+ toJSON() {
816
+ return WebMonitorConfigSchema.parse({
817
+ integrationId: this.integrationId,
818
+ integrationType: this.integrationType,
819
+ configType: this.configType,
820
+ query: this.query,
821
+ frequency: this.frequency,
822
+ outputSchema: this.rawOutputSchema ?? this.outputSchema
823
+ });
824
+ }
825
+ }
738
826
  export const configDataSchema = z.union([
739
827
  GmailConfigSchema,
740
828
  SlackConfigSchema,
@@ -755,7 +843,8 @@ export const configDataSchema = z.union([
755
843
  WorkOSOutputConfigSchema,
756
844
  AttioOutputConfigSchema,
757
845
  SnowflakeOutputConfigSchema,
758
- WebhookInputConfigSchema
846
+ WebhookInputConfigSchema,
847
+ WebMonitorConfigSchema
759
848
  ]);
760
849
  /** Configs that can serve as triggers (event sources). */
761
850
  export const triggerConfigDataSchema = z.union([
@@ -765,7 +854,8 @@ export const triggerConfigDataSchema = z.union([
765
854
  GitHubConfigSchema,
766
855
  TimeTriggerConfigSchema,
767
856
  WorkOSInputConfigSchema,
768
- WebhookInputConfigSchema
857
+ WebhookInputConfigSchema,
858
+ WebMonitorConfigSchema
769
859
  ]);
770
860
  /** Configs that can serve as skills (tools / outputs). */
771
861
  export const skillConfigDataSchema = z.union([
@@ -813,6 +903,8 @@ export function isConfigComplete(config) {
813
903
  return !!config.projectId;
814
904
  case ConfigType.TIME_TRIGGER:
815
905
  return !!config.cronExpression;
906
+ case ConfigType.WEBMONITOR:
907
+ return !!(config.query && config.frequency);
816
908
  case ConfigType.LAUNCHDARKLY:
817
909
  return !!(config.projectKey && config.environmentKeys.length > 0);
818
910
  case ConfigType.WORKOS_INPUT:
@@ -949,6 +1041,14 @@ export function formatConfigForAgent(config) {
949
1041
  return `Type: Snowflake Output\nIntegration ID: ${config.integrationId}`;
950
1042
  case ConfigType.WEBHOOK_INPUT:
951
1043
  return "Type: Webhook Trigger";
1044
+ case ConfigType.WEBMONITOR: {
1045
+ const parts = [`Type: Web Event`];
1046
+ if (config.query)
1047
+ parts.push(`Query: ${config.query}`);
1048
+ if (config.frequency)
1049
+ parts.push(`Frequency: ${config.frequency.number}${config.frequency.unit}`);
1050
+ return parts.join("\n");
1051
+ }
952
1052
  default: {
953
1053
  const _exhaustive = config;
954
1054
  return _exhaustive;
@@ -974,5 +1074,6 @@ export const CONFIG_METADATA = {
974
1074
  [ConfigType.WORKOS_OUTPUT]: WorkOSOutputConfig,
975
1075
  [ConfigType.ATTIO_OUTPUT]: AttioOutputConfig,
976
1076
  [ConfigType.SNOWFLAKE_OUTPUT]: SnowflakeOutputConfig,
977
- [ConfigType.WEBHOOK_INPUT]: WebhookInputConfig
1077
+ [ConfigType.WEBHOOK_INPUT]: WebhookInputConfig,
1078
+ [ConfigType.WEBMONITOR]: WebMonitorConfig
978
1079
  };
@@ -13,7 +13,8 @@ export declare enum IntegrationType {
13
13
  WORKOS = "workos",
14
14
  ATTIO = "attio",
15
15
  SNOWFLAKE = "snowflake",
16
- WEBHOOK = "webhook"
16
+ WEBHOOK = "webhook",
17
+ WEBMONITOR = "webmonitor"
17
18
  }
18
19
  export declare const integrationTypeEnum: z.ZodEnum<typeof IntegrationType>;
19
20
  export interface IntegrationDetails {
@@ -86,6 +87,13 @@ export declare const CronJobIntegrationMetadata: {
86
87
  readonly isInput: true;
87
88
  readonly isOutput: false;
88
89
  };
90
+ export declare const WebMonitorIntegrationMetadata: {
91
+ readonly type: IntegrationType.WEBMONITOR;
92
+ readonly name: "Web Monitor";
93
+ readonly description: "Trigger when scheduled web monitoring detects relevant changes";
94
+ readonly isInput: true;
95
+ readonly isOutput: false;
96
+ };
89
97
  export declare const LaunchDarklyIntegrationMetadata: {
90
98
  readonly type: IntegrationType.LAUNCHDARKLY;
91
99
  readonly name: "LaunchDarkly";
@@ -148,6 +156,7 @@ export type IntegrationInstallationOptions = EnsureExhaustiveInstallationOptions
148
156
  [IntegrationType.ATTIO]: NoInstallationOptions;
149
157
  [IntegrationType.SNOWFLAKE]: NoInstallationOptions;
150
158
  [IntegrationType.WEBHOOK]: NoInstallationOptions;
159
+ [IntegrationType.WEBMONITOR]: NoInstallationOptions;
151
160
  }>;
152
161
  export type InstallationOptionsFor<T extends IntegrationType> = IntegrationInstallationOptions[T];
153
162
  export declare const SlackIntegrationSchema: z.ZodObject<{
@@ -16,6 +16,7 @@ export var IntegrationType;
16
16
  IntegrationType["ATTIO"] = "attio";
17
17
  IntegrationType["SNOWFLAKE"] = "snowflake";
18
18
  IntegrationType["WEBHOOK"] = "webhook";
19
+ IntegrationType["WEBMONITOR"] = "webmonitor";
19
20
  })(IntegrationType || (IntegrationType = {}));
20
21
  export const integrationTypeEnum = z.enum(IntegrationType);
21
22
  // Metadata objects - using const objects instead of classes
@@ -82,6 +83,13 @@ export const CronJobIntegrationMetadata = {
82
83
  isInput: true,
83
84
  isOutput: false
84
85
  };
86
+ export const WebMonitorIntegrationMetadata = {
87
+ type: IntegrationType.WEBMONITOR,
88
+ name: "Web Monitor",
89
+ description: "Trigger when scheduled web monitoring detects relevant changes",
90
+ isInput: true,
91
+ isOutput: false
92
+ };
85
93
  export const LaunchDarklyIntegrationMetadata = {
86
94
  type: IntegrationType.LAUNCHDARKLY,
87
95
  name: "LaunchDarkly",
@@ -131,7 +139,8 @@ export const INTEGRATION_METADATA = {
131
139
  [IntegrationType.WORKOS]: WorkOSIntegrationMetadata,
132
140
  [IntegrationType.ATTIO]: AttioIntegrationMetadata,
133
141
  [IntegrationType.SNOWFLAKE]: SnowflakeIntegrationMetadata,
134
- [IntegrationType.WEBHOOK]: WebhookIntegrationMetadata
142
+ [IntegrationType.WEBHOOK]: WebhookIntegrationMetadata,
143
+ [IntegrationType.WEBMONITOR]: WebMonitorIntegrationMetadata
135
144
  };
136
145
  // MARK: Integration Details
137
146
  export const IntegrationInstanceSchema = z.object({
@@ -0,0 +1,15 @@
1
+ export type SandboxLogEntry = {
2
+ stream: "stdout" | "stderr";
3
+ text: string;
4
+ timestamp: number;
5
+ };
6
+ export type SandboxLogPayload = SandboxLogEntry & {
7
+ runId: string;
8
+ agentId: string;
9
+ };
10
+ export type SandboxLogsResponse = {
11
+ sandboxId: string | null;
12
+ entries: SandboxLogEntry[];
13
+ timestamp: number;
14
+ error?: string;
15
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { Trigger } from "./Triggers.js";
2
+ export declare function formatTriggerForAgent(event: Trigger): string;
3
+ export declare function debugTrigger(event: Trigger): string;
@@ -0,0 +1,238 @@
1
+ import { IntegrationType } from "./Integrations.js";
2
+ const TriggerPresenters = {
3
+ manual_sample: {
4
+ formatForAgent: (event) => `Manual sample event for ${event.integrationType}.`,
5
+ debug: (event) => `${event.integrationType} ${event.eventType}`
6
+ },
7
+ [IntegrationType.GITHUB]: {
8
+ formatForAgent: formatGithubTrigger,
9
+ debug: (event) => `GitHub Event: ${event.eventType} - ${event.repository.owner}/${event.repository.name} - ${event.sender.login}`
10
+ },
11
+ [IntegrationType.SLACK]: {
12
+ formatForAgent: formatSlackTrigger,
13
+ debug: (event) => {
14
+ const isDM = event.channelType === "im";
15
+ return `Slack Event: ${event.eventType} - ${isDM ? "DM" : event.channelName || event.channelId} - ${event.userName || event.userId}`;
16
+ }
17
+ },
18
+ [IntegrationType.GMAIL]: {
19
+ formatForAgent: formatGmailTrigger,
20
+ debug: (event) => `Gmail Event: ${event.subject} message ID: ${event.messageId}`
21
+ },
22
+ [IntegrationType.LINEAR]: {
23
+ formatForAgent: formatLinearTrigger,
24
+ debug: (event) => {
25
+ if (event.type === "Issue") {
26
+ return `Linear ${event.type} Event: ${event.data.identifier} - ${event.data.title} (${event.action})`;
27
+ }
28
+ return `Linear ${event.type} Event: Comment on issue ${event.data.issueId || "Unknown"} (${event.action})`;
29
+ }
30
+ },
31
+ [IntegrationType.WORKOS]: {
32
+ formatForAgent: formatWorkOSTrigger,
33
+ debug: (event) => `WorkOS ${event.eventType}`
34
+ },
35
+ [IntegrationType.WEBHOOK]: {
36
+ formatForAgent: formatWebhookTrigger,
37
+ debug: (event) => `Webhook Trigger (${event.method})`
38
+ },
39
+ [IntegrationType.CRON_JOB]: {
40
+ formatForAgent: formatCronTrigger,
41
+ debug: (event) => (event.isManualTrigger ? "Manual Trigger" : "Scheduled Event")
42
+ }
43
+ };
44
+ export function formatTriggerForAgent(event) {
45
+ if (event.eventType === "manual_sample") {
46
+ return TriggerPresenters.manual_sample.formatForAgent(event);
47
+ }
48
+ const presenter = TriggerPresenters[event.integrationType];
49
+ return presenter.formatForAgent(event);
50
+ }
51
+ export function debugTrigger(event) {
52
+ if (event.eventType === "manual_sample") {
53
+ return TriggerPresenters.manual_sample.debug(event);
54
+ }
55
+ const presenter = TriggerPresenters[event.integrationType];
56
+ return presenter.debug(event);
57
+ }
58
+ function formatGithubTrigger(event) {
59
+ const indentMultiline = (text) => text
60
+ .split("\n")
61
+ .map(line => ` ${line}`)
62
+ .join("\n");
63
+ const eventTypeDescriptions = {
64
+ push: "Code Push Event",
65
+ "pull_request.opened": "Pull Request Opened",
66
+ "pull_request.synchronize": "Pull Request Updated (new commits added)",
67
+ "pull_request.closed": "Pull Request Closed",
68
+ "pull_request.merged": "Pull Request Merged"
69
+ };
70
+ const eventDescription = eventTypeDescriptions[event.eventType] || event.eventType;
71
+ const repoInfo = [
72
+ `Repository: ${event.repository.owner}/${event.repository.name}`,
73
+ `Repository ID: ${event.repository.id}`,
74
+ `Default Branch: ${event.repository.defaultBranch}`,
75
+ `View on GitHub: https://github.com/${event.repository.owner}/${event.repository.name}`
76
+ ].join("\n");
77
+ const senderInfo = [`Actor: ${event.sender.login}`, ...(event.sender.email ? [`Email: ${event.sender.email}`] : [])].join("\n");
78
+ const branchInfo = event.branch ? `Branch: ${event.branch}` : null;
79
+ let prInfo = "";
80
+ if (event.pullRequest) {
81
+ const pr = event.pullRequest;
82
+ const author = pr.author ?? pr.user;
83
+ const prLines = [
84
+ `Pull Request #${pr.number}: ${pr.title}`,
85
+ `State: ${pr.state}${pr.merged ? " (merged)" : ""}`,
86
+ `Author: ${author.login}${author.email ? ` (${author.email})` : ""}`,
87
+ `Head Branch: ${pr.head.ref} (${pr.head.sha.substring(0, 7)})`,
88
+ `Base Branch: ${pr.base.ref} (${pr.base.sha.substring(0, 7)})`,
89
+ `View PR: ${pr.url}`
90
+ ];
91
+ if (pr.body) {
92
+ prLines.push(`\nDescription:\n${indentMultiline(pr.body)}`);
93
+ }
94
+ prInfo = prLines.join("\n");
95
+ }
96
+ let commitsInfo = "";
97
+ if (event.commits.length > 0) {
98
+ const commitLines = [];
99
+ commitLines.push(`Commits (${event.commits.length}):`);
100
+ event.commits.forEach((commit, index) => {
101
+ const shortSha = commit.sha.substring(0, 7);
102
+ const commitUrl = `https://github.com/${event.repository.owner}/${event.repository.name}/commit/${commit.sha}`;
103
+ commitLines.push(`\n${index + 1}. Commit ${shortSha}: ${commit.message || commit.name || ""}`);
104
+ commitLines.push(` URL: ${commitUrl}`);
105
+ if (commit.fileDiffs.length > 0) {
106
+ commitLines.push(` Files Changed: ${commit.fileDiffs.length}`);
107
+ const fileList = commit.fileDiffs.map(f => ` - ${f.filename}`).join("\n");
108
+ commitLines.push(` Files:\n${fileList}`);
109
+ }
110
+ });
111
+ commitsInfo = commitLines.join("\n");
112
+ }
113
+ return [
114
+ `Incoming GitHub Event: ${eventDescription}`,
115
+ `\nRepository Information:\n${indentMultiline(repoInfo)}`,
116
+ `\nActor Information:\n${indentMultiline(senderInfo)}`,
117
+ ...(branchInfo ? [`\nBranch Information:\n${indentMultiline(branchInfo)}`] : []),
118
+ ...(prInfo ? [`\nPull Request Information:\n${indentMultiline(prInfo)}`] : []),
119
+ ...(commitsInfo ? [`\n${commitsInfo}`] : [])
120
+ ].join("\n\n");
121
+ }
122
+ function formatSlackTrigger(event) {
123
+ const blockContent = JSON.stringify(event.blocks);
124
+ const attachmentContent = JSON.stringify(event.attachments);
125
+ const messageText = event.text || "(no plain text)";
126
+ const threadTs = event.threadTs ?? event.threadTimestamp ?? null;
127
+ const eventLabel = event.eventType === "app_mention" ? "Incoming Slack App Mention Event." : event.eventType === "reaction_added" ? "Incoming Slack Reaction Added Event." : "Incoming Slack Message Event.";
128
+ const reactionInfo = event.eventType === "reaction_added"
129
+ ? `Reaction: ${event.reaction || "unknown"}\n Target Message Timestamp: ${event.itemTimestamp || "unknown"}\n Target User: ${event.itemUserId || "unknown"}`
130
+ : "";
131
+ return `
132
+ ${eventLabel}
133
+
134
+ Slack Event:
135
+ Event Type: ${event.eventType}
136
+ Channel: ${event.channelName || event.channelId}
137
+ User: ${event.userName || event.userId}
138
+ Message: ${messageText}
139
+ Timestamp: ${event.timestamp}
140
+ ${threadTs ? `Thread: ${threadTs}` : ""}
141
+ Team ID: ${event.teamId}
142
+ ${reactionInfo}
143
+ ${blockContent
144
+ ? `
145
+ Rich Content (from blocks):
146
+ ${blockContent}`
147
+ : ""}
148
+ ${attachmentContent
149
+ ? `
150
+ Attachment Content:
151
+ ${attachmentContent}`
152
+ : ""}
153
+ `;
154
+ }
155
+ function formatGmailTrigger(event) {
156
+ const attachmentInfo = event.attachments?.map(attachment => `- ${attachment.filename} ${attachment.isInline ? "Inline" : "Attachment"} (${attachment.mimeType})`).join("\n") || "No attachments";
157
+ return `
158
+ Incoming Email Event.
159
+
160
+ Gmail Event:
161
+ Subject: ${event.subject}
162
+ From: ${event.from}
163
+ To: ${event.to}
164
+ Date: ${event.date}
165
+ Message ID: ${event.messageId}
166
+ Thread ID: ${event.threadId}
167
+ Body: ${event.body}
168
+ Snippet: ${event.snippet}
169
+ Attachments (if any listed, actual files should be added below):
170
+ ${attachmentInfo}
171
+ `;
172
+ }
173
+ function formatLinearTrigger(event) {
174
+ const indentMultiline = (text) => text
175
+ .split("\n")
176
+ .map(line => ` ${line}`)
177
+ .join("\n");
178
+ const sections = [];
179
+ sections.push(`Incoming Linear ${event.type} Event`);
180
+ sections.push(`Action: ${event.action}`);
181
+ sections.push(`Actor: ${event.actor.name} (${event.actor.email})`);
182
+ sections.push(`Created: ${event.createdAt}`);
183
+ if (event.type === "Issue" && event.data) {
184
+ const issue = event.data;
185
+ const issueSections = [];
186
+ issueSections.push(`Issue: ${issue.identifier} - ${issue.title}`);
187
+ if (issue.description)
188
+ issueSections.push(`Description:\n${indentMultiline(issue.description)}`);
189
+ issueSections.push(`Priority: ${issue.priorityLabel || issue.priority}`);
190
+ issueSections.push(`State: ${issue.state?.name || "Unknown"}`);
191
+ issueSections.push(`Team: ${issue.team?.name || "Unknown"}`);
192
+ if (issue.assignee)
193
+ issueSections.push(`Assignee: ${issue.assignee.name}`);
194
+ if (issue.labels?.length)
195
+ issueSections.push(`Labels: ${issue.labels.map((label) => label.name || label).join(", ")}`);
196
+ if (issue.url)
197
+ issueSections.push(`URL: ${issue.url}`);
198
+ sections.push(issueSections.join("\n"));
199
+ }
200
+ else if (event.type === "Comment" && event.data) {
201
+ const commentSections = [`Comment on Issue: ${event.data.issueId || "Unknown"}`];
202
+ if (event.data.body)
203
+ commentSections.push(`Comment:\n${indentMultiline(event.data.body)}`);
204
+ sections.push(commentSections.join("\n"));
205
+ }
206
+ else {
207
+ sections.push(`Event Data:\n${indentMultiline(JSON.stringify(event.data, null, 2))}`);
208
+ }
209
+ if (event.organizationId) {
210
+ sections.push(`Organization ID: ${event.organizationId}`);
211
+ }
212
+ return sections.join("\n\n");
213
+ }
214
+ function formatWorkOSTrigger(event) {
215
+ const parts = [`WorkOS Event: ${event.eventType}`];
216
+ if ("user" in event && event.user) {
217
+ parts.push(`User Email: ${event.user.email}`);
218
+ if (event.user.firstName || event.user.lastName) {
219
+ parts.push(`User Name: ${[event.user.firstName, event.user.lastName].filter(Boolean).join(" ")}`);
220
+ }
221
+ parts.push(`User ID: ${event.user.id}`);
222
+ }
223
+ parts.push(`\nFull Event Data:\n${JSON.stringify(event, null, 2)}`);
224
+ return parts.join("\n");
225
+ }
226
+ function formatWebhookTrigger(event) {
227
+ return `Webhook request received.\n\nMethod: ${event.method}\n\nPayload:\n${JSON.stringify(event.body, null, 2)}`;
228
+ }
229
+ function formatCronTrigger(event) {
230
+ if (event.isManualTrigger) {
231
+ let message = `This is a manually triggered event for the channel input ${event.inputId}.`;
232
+ if (event.manualContext) {
233
+ message += `\n\nUser provided context for this manual trigger:\n${event.manualContext}`;
234
+ }
235
+ return message;
236
+ }
237
+ return `This is a scheduled event for the channel input ${event.inputId}. The channel input is configured to run at the following cron expression.`;
238
+ }