agent-relay 2.0.23 → 2.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/dist/src/cli/index.js +66 -13
  2. package/package.json +18 -52
  3. package/packages/api-types/package.json +1 -1
  4. package/packages/bridge/package.json +8 -8
  5. package/packages/cli-tester/package.json +1 -1
  6. package/packages/config/package.json +2 -2
  7. package/packages/continuity/package.json +1 -1
  8. package/packages/daemon/package.json +12 -12
  9. package/packages/hooks/package.json +4 -4
  10. package/packages/mcp/package.json +2 -2
  11. package/packages/memory/package.json +2 -2
  12. package/packages/policy/package.json +2 -2
  13. package/packages/protocol/package.json +1 -1
  14. package/packages/resiliency/package.json +1 -1
  15. package/packages/sdk/package.json +2 -2
  16. package/packages/spawner/package.json +1 -1
  17. package/packages/state/package.json +1 -1
  18. package/packages/storage/package.json +2 -2
  19. package/packages/telemetry/package.json +1 -1
  20. package/packages/trajectory/package.json +2 -2
  21. package/packages/user-directory/package.json +2 -2
  22. package/packages/utils/package.json +1 -1
  23. package/packages/wrapper/package.json +6 -6
  24. package/deploy/init-db.sql +0 -5
  25. package/deploy/scripts/setup-fly-workspaces.sh +0 -69
  26. package/deploy/scripts/setup-railway.sh +0 -75
  27. package/dist/src/cloud/index.d.ts +0 -8
  28. package/dist/src/cloud/index.js +0 -8
  29. package/packages/cloud/dist/api/admin.d.ts +0 -8
  30. package/packages/cloud/dist/api/admin.js +0 -225
  31. package/packages/cloud/dist/api/auth.d.ts +0 -20
  32. package/packages/cloud/dist/api/auth.js +0 -138
  33. package/packages/cloud/dist/api/billing.d.ts +0 -7
  34. package/packages/cloud/dist/api/billing.js +0 -564
  35. package/packages/cloud/dist/api/cli-pty-runner.d.ts +0 -53
  36. package/packages/cloud/dist/api/cli-pty-runner.js +0 -175
  37. package/packages/cloud/dist/api/codex-auth-helper.d.ts +0 -21
  38. package/packages/cloud/dist/api/codex-auth-helper.js +0 -327
  39. package/packages/cloud/dist/api/consensus.d.ts +0 -13
  40. package/packages/cloud/dist/api/consensus.js +0 -261
  41. package/packages/cloud/dist/api/coordinators.d.ts +0 -8
  42. package/packages/cloud/dist/api/coordinators.js +0 -750
  43. package/packages/cloud/dist/api/daemons.d.ts +0 -12
  44. package/packages/cloud/dist/api/daemons.js +0 -535
  45. package/packages/cloud/dist/api/email-auth.d.ts +0 -11
  46. package/packages/cloud/dist/api/email-auth.js +0 -347
  47. package/packages/cloud/dist/api/generic-webhooks.d.ts +0 -8
  48. package/packages/cloud/dist/api/generic-webhooks.js +0 -129
  49. package/packages/cloud/dist/api/git.d.ts +0 -8
  50. package/packages/cloud/dist/api/git.js +0 -269
  51. package/packages/cloud/dist/api/github-app.d.ts +0 -11
  52. package/packages/cloud/dist/api/github-app.js +0 -223
  53. package/packages/cloud/dist/api/middleware/planLimits.d.ts +0 -43
  54. package/packages/cloud/dist/api/middleware/planLimits.js +0 -202
  55. package/packages/cloud/dist/api/monitoring.d.ts +0 -11
  56. package/packages/cloud/dist/api/monitoring.js +0 -578
  57. package/packages/cloud/dist/api/nango-auth.d.ts +0 -9
  58. package/packages/cloud/dist/api/nango-auth.js +0 -741
  59. package/packages/cloud/dist/api/onboarding.d.ts +0 -15
  60. package/packages/cloud/dist/api/onboarding.js +0 -679
  61. package/packages/cloud/dist/api/policy.d.ts +0 -8
  62. package/packages/cloud/dist/api/policy.js +0 -229
  63. package/packages/cloud/dist/api/provider-env.d.ts +0 -26
  64. package/packages/cloud/dist/api/provider-env.js +0 -141
  65. package/packages/cloud/dist/api/providers.d.ts +0 -7
  66. package/packages/cloud/dist/api/providers.js +0 -574
  67. package/packages/cloud/dist/api/repos.d.ts +0 -8
  68. package/packages/cloud/dist/api/repos.js +0 -577
  69. package/packages/cloud/dist/api/sessions.d.ts +0 -11
  70. package/packages/cloud/dist/api/sessions.js +0 -302
  71. package/packages/cloud/dist/api/teams.d.ts +0 -7
  72. package/packages/cloud/dist/api/teams.js +0 -281
  73. package/packages/cloud/dist/api/test-helpers.d.ts +0 -10
  74. package/packages/cloud/dist/api/test-helpers.js +0 -745
  75. package/packages/cloud/dist/api/usage.d.ts +0 -7
  76. package/packages/cloud/dist/api/usage.js +0 -111
  77. package/packages/cloud/dist/api/webhooks.d.ts +0 -8
  78. package/packages/cloud/dist/api/webhooks.js +0 -645
  79. package/packages/cloud/dist/api/workspaces.d.ts +0 -25
  80. package/packages/cloud/dist/api/workspaces.js +0 -1799
  81. package/packages/cloud/dist/billing/index.d.ts +0 -9
  82. package/packages/cloud/dist/billing/index.js +0 -9
  83. package/packages/cloud/dist/billing/plans.d.ts +0 -39
  84. package/packages/cloud/dist/billing/plans.js +0 -245
  85. package/packages/cloud/dist/billing/service.d.ts +0 -80
  86. package/packages/cloud/dist/billing/service.js +0 -388
  87. package/packages/cloud/dist/billing/types.d.ts +0 -141
  88. package/packages/cloud/dist/billing/types.js +0 -7
  89. package/packages/cloud/dist/config.d.ts +0 -5
  90. package/packages/cloud/dist/config.js +0 -5
  91. package/packages/cloud/dist/db/bulk-ingest.d.ts +0 -89
  92. package/packages/cloud/dist/db/bulk-ingest.js +0 -268
  93. package/packages/cloud/dist/db/drizzle.d.ts +0 -290
  94. package/packages/cloud/dist/db/drizzle.js +0 -1422
  95. package/packages/cloud/dist/db/index.d.ts +0 -56
  96. package/packages/cloud/dist/db/index.js +0 -70
  97. package/packages/cloud/dist/db/schema.d.ts +0 -5117
  98. package/packages/cloud/dist/db/schema.js +0 -656
  99. package/packages/cloud/dist/index.d.ts +0 -11
  100. package/packages/cloud/dist/index.js +0 -38
  101. package/packages/cloud/dist/provisioner/index.d.ts +0 -207
  102. package/packages/cloud/dist/provisioner/index.js +0 -2118
  103. package/packages/cloud/dist/server.d.ts +0 -17
  104. package/packages/cloud/dist/server.js +0 -2055
  105. package/packages/cloud/dist/services/auto-scaler.d.ts +0 -152
  106. package/packages/cloud/dist/services/auto-scaler.js +0 -439
  107. package/packages/cloud/dist/services/capacity-manager.d.ts +0 -148
  108. package/packages/cloud/dist/services/capacity-manager.js +0 -449
  109. package/packages/cloud/dist/services/ci-agent-spawner.d.ts +0 -49
  110. package/packages/cloud/dist/services/ci-agent-spawner.js +0 -373
  111. package/packages/cloud/dist/services/cloud-message-bus.d.ts +0 -28
  112. package/packages/cloud/dist/services/cloud-message-bus.js +0 -19
  113. package/packages/cloud/dist/services/compute-enforcement.d.ts +0 -57
  114. package/packages/cloud/dist/services/compute-enforcement.js +0 -175
  115. package/packages/cloud/dist/services/coordinator.d.ts +0 -62
  116. package/packages/cloud/dist/services/coordinator.js +0 -389
  117. package/packages/cloud/dist/services/index.d.ts +0 -17
  118. package/packages/cloud/dist/services/index.js +0 -25
  119. package/packages/cloud/dist/services/intro-expiration.d.ts +0 -60
  120. package/packages/cloud/dist/services/intro-expiration.js +0 -252
  121. package/packages/cloud/dist/services/mention-handler.d.ts +0 -65
  122. package/packages/cloud/dist/services/mention-handler.js +0 -405
  123. package/packages/cloud/dist/services/nango.d.ts +0 -219
  124. package/packages/cloud/dist/services/nango.js +0 -424
  125. package/packages/cloud/dist/services/persistence.d.ts +0 -131
  126. package/packages/cloud/dist/services/persistence.js +0 -200
  127. package/packages/cloud/dist/services/planLimits.d.ts +0 -147
  128. package/packages/cloud/dist/services/planLimits.js +0 -335
  129. package/packages/cloud/dist/services/presence-registry.d.ts +0 -56
  130. package/packages/cloud/dist/services/presence-registry.js +0 -91
  131. package/packages/cloud/dist/services/scaling-orchestrator.d.ts +0 -159
  132. package/packages/cloud/dist/services/scaling-orchestrator.js +0 -502
  133. package/packages/cloud/dist/services/scaling-policy.d.ts +0 -121
  134. package/packages/cloud/dist/services/scaling-policy.js +0 -415
  135. package/packages/cloud/dist/services/ssh-security.d.ts +0 -31
  136. package/packages/cloud/dist/services/ssh-security.js +0 -63
  137. package/packages/cloud/dist/services/workspace-keepalive.d.ts +0 -76
  138. package/packages/cloud/dist/services/workspace-keepalive.js +0 -234
  139. package/packages/cloud/dist/shims/consensus.d.ts +0 -23
  140. package/packages/cloud/dist/shims/consensus.js +0 -5
  141. package/packages/cloud/dist/webhooks/index.d.ts +0 -24
  142. package/packages/cloud/dist/webhooks/index.js +0 -29
  143. package/packages/cloud/dist/webhooks/parsers/github.d.ts +0 -8
  144. package/packages/cloud/dist/webhooks/parsers/github.js +0 -234
  145. package/packages/cloud/dist/webhooks/parsers/index.d.ts +0 -23
  146. package/packages/cloud/dist/webhooks/parsers/index.js +0 -30
  147. package/packages/cloud/dist/webhooks/parsers/linear.d.ts +0 -9
  148. package/packages/cloud/dist/webhooks/parsers/linear.js +0 -258
  149. package/packages/cloud/dist/webhooks/parsers/slack.d.ts +0 -9
  150. package/packages/cloud/dist/webhooks/parsers/slack.js +0 -214
  151. package/packages/cloud/dist/webhooks/responders/github.d.ts +0 -8
  152. package/packages/cloud/dist/webhooks/responders/github.js +0 -73
  153. package/packages/cloud/dist/webhooks/responders/index.d.ts +0 -23
  154. package/packages/cloud/dist/webhooks/responders/index.js +0 -30
  155. package/packages/cloud/dist/webhooks/responders/linear.d.ts +0 -9
  156. package/packages/cloud/dist/webhooks/responders/linear.js +0 -149
  157. package/packages/cloud/dist/webhooks/responders/slack.d.ts +0 -20
  158. package/packages/cloud/dist/webhooks/responders/slack.js +0 -178
  159. package/packages/cloud/dist/webhooks/router.d.ts +0 -25
  160. package/packages/cloud/dist/webhooks/router.js +0 -504
  161. package/packages/cloud/dist/webhooks/rules-engine.d.ts +0 -24
  162. package/packages/cloud/dist/webhooks/rules-engine.js +0 -287
  163. package/packages/cloud/dist/webhooks/types.d.ts +0 -186
  164. package/packages/cloud/dist/webhooks/types.js +0 -8
  165. package/packages/cloud/package.json +0 -60
  166. package/scripts/run-migrations.js +0 -43
  167. package/scripts/setup-stripe-products.ts +0 -312
  168. package/scripts/verify-schema.js +0 -134
@@ -1,287 +0,0 @@
1
- /**
2
- * Webhook Rules Engine
3
- *
4
- * Matches normalized events against configured rules and determines actions to take.
5
- */
6
- /**
7
- * Simple JSONPath-like evaluator for conditions
8
- * Supports: $.field, $.field.subfield, comparisons (==, !=, in, contains)
9
- */
10
- function evaluateCondition(condition, event) {
11
- if (!condition || condition.trim() === '')
12
- return true;
13
- try {
14
- // Parse condition: $.path operator value
15
- // Note: >= and <= must come before > and < in the alternation to match correctly
16
- const conditionPattern = /^\$\.([a-zA-Z0-9_.]+)\s*(==|!=|>=|<=|>|<|in|contains)\s*(.+)$/;
17
- const match = condition.match(conditionPattern);
18
- if (!match) {
19
- console.warn(`[rules-engine] Invalid condition format: ${condition}`);
20
- return false;
21
- }
22
- const [, path, operator, rawValue] = match;
23
- const value = rawValue.trim();
24
- // Get the value from the event
25
- const eventValue = getValueByPath(event, path);
26
- // Parse the comparison value
27
- let compareValue;
28
- if (value.startsWith('[') && value.endsWith(']')) {
29
- // Array literal
30
- compareValue = JSON.parse(value);
31
- }
32
- else if (value.startsWith('"') && value.endsWith('"')) {
33
- // String literal
34
- compareValue = value.slice(1, -1);
35
- }
36
- else if (value === 'true') {
37
- compareValue = true;
38
- }
39
- else if (value === 'false') {
40
- compareValue = false;
41
- }
42
- else if (value === 'null') {
43
- compareValue = null;
44
- }
45
- else if (!isNaN(Number(value))) {
46
- compareValue = Number(value);
47
- }
48
- else {
49
- // Treat as string
50
- compareValue = value;
51
- }
52
- switch (operator) {
53
- case '==':
54
- // Handle null/undefined equivalence
55
- if (compareValue === null) {
56
- return eventValue === null || eventValue === undefined;
57
- }
58
- return eventValue === compareValue;
59
- case '!=':
60
- return eventValue !== compareValue;
61
- case 'in':
62
- return Array.isArray(compareValue) && compareValue.includes(eventValue);
63
- case 'contains':
64
- if (Array.isArray(eventValue)) {
65
- return eventValue.includes(compareValue);
66
- }
67
- if (typeof eventValue === 'string' && typeof compareValue === 'string') {
68
- return eventValue.includes(compareValue);
69
- }
70
- return false;
71
- case '>':
72
- return typeof eventValue === 'number' && typeof compareValue === 'number' && eventValue > compareValue;
73
- case '<':
74
- return typeof eventValue === 'number' && typeof compareValue === 'number' && eventValue < compareValue;
75
- case '>=':
76
- return typeof eventValue === 'number' && typeof compareValue === 'number' && eventValue >= compareValue;
77
- case '<=':
78
- return typeof eventValue === 'number' && typeof compareValue === 'number' && eventValue <= compareValue;
79
- default:
80
- return false;
81
- }
82
- }
83
- catch (error) {
84
- console.error(`[rules-engine] Error evaluating condition: ${condition}`, error);
85
- return false;
86
- }
87
- }
88
- /**
89
- * Get a value from an object by dot-separated path
90
- */
91
- function getValueByPath(obj, path) {
92
- const parts = path.split('.');
93
- let current = obj;
94
- for (const part of parts) {
95
- if (current === null || current === undefined)
96
- return undefined;
97
- if (typeof current !== 'object')
98
- return undefined;
99
- current = current[part];
100
- }
101
- return current;
102
- }
103
- /**
104
- * Check if a rule matches an event
105
- */
106
- export function matchesRule(rule, event) {
107
- // Check if rule is enabled
108
- if (!rule.enabled)
109
- return false;
110
- // Check source match
111
- if (rule.source !== '*' && rule.source !== event.source) {
112
- return false;
113
- }
114
- // Check event type match
115
- if (rule.eventType !== '*' && rule.eventType !== event.type) {
116
- // Support wildcard prefix matching (e.g., 'ci_*' matches 'ci_failure')
117
- if (rule.eventType.endsWith('*')) {
118
- const prefix = rule.eventType.slice(0, -1);
119
- if (!event.type.startsWith(prefix)) {
120
- return false;
121
- }
122
- }
123
- else {
124
- return false;
125
- }
126
- }
127
- // Check condition if present
128
- if (rule.condition && !evaluateCondition(rule.condition, event)) {
129
- return false;
130
- }
131
- return true;
132
- }
133
- /**
134
- * Find all matching rules for an event, sorted by priority
135
- */
136
- export function findMatchingRules(rules, event) {
137
- return rules
138
- .filter(rule => matchesRule(rule, event))
139
- .sort((a, b) => a.priority - b.priority);
140
- }
141
- /**
142
- * Resolve template variables in action configuration
143
- * Supports: ${event.field}, ${event.field.subfield}
144
- */
145
- export function resolveActionTemplate(action, event) {
146
- const resolvedAction = { ...action };
147
- // Resolve agentType if it references an event field
148
- if (resolvedAction.agentType?.startsWith('$.')) {
149
- const path = resolvedAction.agentType.slice(2);
150
- const value = getValueByPath(event, path);
151
- if (typeof value === 'string') {
152
- resolvedAction.agentType = value;
153
- }
154
- else if (Array.isArray(value) && value.length > 0) {
155
- // Use first mentioned agent
156
- resolvedAction.agentType = String(value[0]);
157
- }
158
- }
159
- // Resolve prompt template references
160
- if (resolvedAction.prompt?.startsWith('${') && resolvedAction.prompt?.endsWith('}')) {
161
- const path = resolvedAction.prompt.slice(2, -1);
162
- const value = getValueByPath(event, path);
163
- if (typeof value === 'string') {
164
- resolvedAction.prompt = value;
165
- }
166
- }
167
- return resolvedAction;
168
- }
169
- /**
170
- * Default rules for common patterns
171
- */
172
- export const defaultRules = [
173
- // CI Failures
174
- {
175
- id: 'ci-failure',
176
- name: 'CI Failure Handler',
177
- enabled: true,
178
- source: 'github',
179
- eventType: 'ci_failure',
180
- action: {
181
- type: 'spawn_agent',
182
- agentType: 'ci-fix',
183
- prompt: 'ci-failure',
184
- },
185
- priority: 10,
186
- },
187
- // GitHub Mentions
188
- {
189
- id: 'github-mention',
190
- name: 'GitHub Mention Handler',
191
- enabled: true,
192
- source: 'github',
193
- eventType: 'mention',
194
- action: {
195
- type: 'spawn_agent',
196
- agentType: '$.mentions', // Use first mentioned agent
197
- prompt: 'mention',
198
- },
199
- priority: 20,
200
- },
201
- // GitHub Issues
202
- {
203
- id: 'github-issue',
204
- name: 'GitHub Issue Handler',
205
- enabled: true,
206
- source: 'github',
207
- eventType: 'issue_created',
208
- condition: '$.priority in ["critical", "high"]',
209
- action: {
210
- type: 'spawn_agent',
211
- agentType: 'developer',
212
- prompt: 'issue',
213
- },
214
- priority: 30,
215
- },
216
- // Linear Issues
217
- {
218
- id: 'linear-issue',
219
- name: 'Linear Issue Handler',
220
- enabled: true,
221
- source: 'linear',
222
- eventType: 'issue_created',
223
- action: {
224
- type: 'spawn_agent',
225
- agentType: 'developer',
226
- prompt: 'linear-issue',
227
- },
228
- priority: 20,
229
- },
230
- // Linear Mentions
231
- {
232
- id: 'linear-mention',
233
- name: 'Linear Mention Handler',
234
- enabled: true,
235
- source: 'linear',
236
- eventType: 'mention',
237
- action: {
238
- type: 'spawn_agent',
239
- agentType: '$.mentions',
240
- prompt: 'mention',
241
- },
242
- priority: 20,
243
- },
244
- // Slack App Mentions
245
- {
246
- id: 'slack-mention',
247
- name: 'Slack App Mention Handler',
248
- enabled: true,
249
- source: 'slack',
250
- eventType: 'mention',
251
- action: {
252
- type: 'spawn_agent',
253
- agentType: '$.mentions',
254
- prompt: 'slack-request',
255
- },
256
- priority: 20,
257
- },
258
- // Linear Issue Assignments (native integration)
259
- {
260
- id: 'linear-assignment',
261
- name: 'Linear Issue Assignment Handler',
262
- enabled: true,
263
- source: 'linear',
264
- eventType: 'issue_assigned',
265
- action: {
266
- type: 'spawn_agent',
267
- agentType: '$.mentions', // Use the assigned agent type
268
- prompt: 'linear-issue',
269
- },
270
- priority: 15,
271
- },
272
- // GitHub Issue Assignments
273
- {
274
- id: 'github-assignment',
275
- name: 'GitHub Issue Assignment Handler',
276
- enabled: true,
277
- source: 'github',
278
- eventType: 'issue_assigned',
279
- action: {
280
- type: 'spawn_agent',
281
- agentType: '$.mentions',
282
- prompt: 'issue',
283
- },
284
- priority: 15,
285
- },
286
- ];
287
- //# sourceMappingURL=rules-engine.js.map
@@ -1,186 +0,0 @@
1
- /**
2
- * Generic Webhook System - Type Definitions
3
- *
4
- * Defines the core types for a configurable webhook system
5
- * that can handle events from any source (GitHub, GitLab, Linear, Slack, etc.)
6
- */
7
- /**
8
- * Normalized event format that all parsers produce
9
- */
10
- export interface NormalizedEvent {
11
- /** Unique event ID */
12
- id: string;
13
- /** Source system (github, gitlab, linear, slack, etc.) */
14
- source: string;
15
- /** Event type (e.g., 'ci_failure', 'mention', 'issue_created') */
16
- type: string;
17
- /** Timestamp of the event */
18
- timestamp: Date;
19
- /** Actor who triggered the event */
20
- actor: {
21
- id: string;
22
- name: string;
23
- email?: string;
24
- };
25
- /** Repository or project context */
26
- context: {
27
- /** Full name (e.g., 'owner/repo' or project ID) */
28
- name: string;
29
- /** URL to the repository/project */
30
- url?: string;
31
- };
32
- /** The item this event relates to (issue, PR, ticket, message) */
33
- item?: {
34
- type: 'issue' | 'pull_request' | 'ticket' | 'message' | 'comment' | 'check';
35
- id: string | number;
36
- number?: number;
37
- title?: string;
38
- body?: string;
39
- url?: string;
40
- state?: string;
41
- };
42
- /** Mentioned agents or users */
43
- mentions: string[];
44
- /** Labels, tags, or categories */
45
- labels: string[];
46
- /** Priority level if applicable */
47
- priority?: 'critical' | 'high' | 'medium' | 'low';
48
- /** Additional source-specific data */
49
- metadata: Record<string, unknown>;
50
- /** Raw payload for debugging */
51
- rawPayload: unknown;
52
- }
53
- /**
54
- * Action to take in response to an event
55
- */
56
- export interface WebhookAction {
57
- type: 'spawn_agent' | 'message_agent' | 'post_comment' | 'create_issue' | 'custom';
58
- /** Agent type or name to spawn/message */
59
- agentType?: string;
60
- /** Prompt template name or inline prompt */
61
- prompt?: string;
62
- /** Additional action-specific config */
63
- config?: Record<string, unknown>;
64
- }
65
- /**
66
- * Signature verification configuration
67
- */
68
- export interface SignatureConfig {
69
- /** Header containing the signature */
70
- header: string;
71
- /** Algorithm to use for verification */
72
- algorithm: 'sha256' | 'sha1' | 'token' | 'slack-v0' | 'none';
73
- /** Environment variable containing the secret */
74
- secretEnvVar: string;
75
- /** Optional prefix to strip from signature (e.g., 'sha256=') */
76
- signaturePrefix?: string;
77
- }
78
- /**
79
- * Webhook source configuration
80
- */
81
- export interface WebhookSourceConfig {
82
- /** Source identifier */
83
- id: string;
84
- /** Display name */
85
- name: string;
86
- /** Whether this source is enabled */
87
- enabled: boolean;
88
- /** Signature verification config */
89
- signature: SignatureConfig;
90
- /** Parser to use for this source */
91
- parser: string;
92
- /** Responder to use for sending responses */
93
- responder: string;
94
- /** Parser-specific configuration */
95
- parserConfig?: Record<string, unknown>;
96
- /** Responder-specific configuration */
97
- responderConfig?: Record<string, unknown>;
98
- }
99
- /**
100
- * Event routing rule
101
- */
102
- export interface WebhookRule {
103
- /** Rule identifier */
104
- id: string;
105
- /** Display name */
106
- name: string;
107
- /** Whether this rule is enabled */
108
- enabled: boolean;
109
- /** Source to match (* for any) */
110
- source: string;
111
- /** Event type to match (* for any) */
112
- eventType: string;
113
- /** JSONPath condition (optional) */
114
- condition?: string;
115
- /** Action to take when matched */
116
- action: WebhookAction;
117
- /** Priority (lower = higher priority) */
118
- priority: number;
119
- }
120
- /**
121
- * Complete webhook configuration
122
- */
123
- export interface WebhookConfig {
124
- sources: Record<string, WebhookSourceConfig>;
125
- rules: WebhookRule[];
126
- }
127
- /**
128
- * Parser interface - transforms source-specific payloads to normalized events
129
- */
130
- export interface WebhookParser {
131
- /** Parser identifier */
132
- id: string;
133
- /** Parse raw payload into normalized event(s) */
134
- parse(payload: unknown, headers: Record<string, string | string[] | undefined>, config?: Record<string, unknown>): NormalizedEvent[];
135
- }
136
- /**
137
- * Response to send back to the source system
138
- */
139
- export interface WebhookResponse {
140
- /** Type of response */
141
- type: 'comment' | 'message' | 'reaction' | 'status';
142
- /** Target (issue number, channel ID, etc.) */
143
- target: string | number;
144
- /** Response body/content */
145
- body: string;
146
- /** Additional response metadata */
147
- metadata?: Record<string, unknown>;
148
- }
149
- /**
150
- * Responder interface - sends responses back to source systems
151
- */
152
- export interface WebhookResponder {
153
- /** Responder identifier */
154
- id: string;
155
- /** Send a response to the source system */
156
- respond(event: NormalizedEvent, response: WebhookResponse, config?: Record<string, unknown>): Promise<{
157
- success: boolean;
158
- id?: string;
159
- url?: string;
160
- error?: string;
161
- }>;
162
- }
163
- /**
164
- * Result of processing a webhook
165
- */
166
- export interface WebhookResult {
167
- success: boolean;
168
- eventId: string;
169
- source: string;
170
- eventType: string;
171
- matchedRules: string[];
172
- actions: Array<{
173
- ruleId: string;
174
- action: WebhookAction;
175
- success: boolean;
176
- error?: string;
177
- }>;
178
- responses: Array<{
179
- type: string;
180
- success: boolean;
181
- id?: string;
182
- url?: string;
183
- error?: string;
184
- }>;
185
- }
186
- //# sourceMappingURL=types.d.ts.map
@@ -1,8 +0,0 @@
1
- /**
2
- * Generic Webhook System - Type Definitions
3
- *
4
- * Defines the core types for a configurable webhook system
5
- * that can handle events from any source (GitHub, GitLab, Linear, Slack, etc.)
6
- */
7
- export {};
8
- //# sourceMappingURL=types.js.map
@@ -1,60 +0,0 @@
1
- {
2
- "name": "@agent-relay/cloud",
3
- "version": "2.0.23",
4
- "description": "Cloud API server and services for Agent Relay",
5
- "type": "module",
6
- "main": "dist/index.js",
7
- "types": "dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/index.js",
12
- "default": "./dist/index.js"
13
- },
14
- "./db/drizzle": {
15
- "types": "./dist/db/drizzle.d.ts",
16
- "import": "./dist/db/drizzle.js",
17
- "default": "./dist/db/drizzle.js"
18
- },
19
- "./db/schema": {
20
- "types": "./dist/db/schema.d.ts",
21
- "import": "./dist/db/schema.js",
22
- "default": "./dist/db/schema.js"
23
- },
24
- "./server": {
25
- "types": "./dist/server.d.ts",
26
- "import": "./dist/server.js",
27
- "default": "./dist/server.js"
28
- }
29
- },
30
- "files": [
31
- "dist",
32
- "README.md"
33
- ],
34
- "scripts": {
35
- "build": "tsc",
36
- "clean": "rm -rf dist",
37
- "test": "vitest run",
38
- "test:watch": "vitest"
39
- },
40
- "dependencies": {
41
- "@agent-relay/wrapper": "2.0.23",
42
- "@agent-relay/config": "2.0.23",
43
- "@agent-relay/resiliency": "2.0.23",
44
- "@agent-relay/storage": "2.0.23",
45
- "@agent-relay/protocol": "2.0.23"
46
- },
47
- "devDependencies": {
48
- "@types/node": "^22.19.3",
49
- "typescript": "^5.9.3",
50
- "vitest": "^3.2.4"
51
- },
52
- "publishConfig": {
53
- "access": "public"
54
- },
55
- "repository": {
56
- "type": "git",
57
- "url": "git+https://github.com/AgentWorkforce/relay.git",
58
- "directory": "packages/cloud"
59
- }
60
- }
@@ -1,43 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Run database migrations (standalone)
4
- *
5
- * This script is used in CI to verify migrations run successfully.
6
- * It connects to the database and runs all pending migrations.
7
- *
8
- * This is a standalone script that doesn't depend on the cloud config,
9
- * so it only requires DATABASE_URL to run.
10
- *
11
- * Usage: DATABASE_URL=postgres://... node scripts/run-migrations.js
12
- */
13
-
14
- import pg from 'pg';
15
- import { drizzle } from 'drizzle-orm/node-postgres';
16
- import { migrate } from 'drizzle-orm/node-postgres/migrator';
17
-
18
- const { Pool } = pg;
19
-
20
- async function main() {
21
- console.log('Starting database migrations...');
22
- console.log(`Database URL: ${process.env.DATABASE_URL?.replace(/:[^:@]+@/, ':***@') || 'not set'}`);
23
-
24
- if (!process.env.DATABASE_URL) {
25
- console.error('ERROR: DATABASE_URL environment variable is required');
26
- process.exit(1);
27
- }
28
-
29
- const pool = new Pool({ connectionString: process.env.DATABASE_URL });
30
- const db = drizzle(pool);
31
-
32
- try {
33
- await migrate(db, { migrationsFolder: './src/cloud/db/migrations' });
34
- console.log('All migrations completed successfully');
35
- } catch (error) {
36
- console.error('Migration failed:', error);
37
- process.exit(1);
38
- } finally {
39
- await pool.end();
40
- }
41
- }
42
-
43
- main();