@elevasis/core 0.15.1 → 0.16.0

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 (68) hide show
  1. package/dist/index.d.ts +1662 -23
  2. package/dist/index.js +171 -24
  3. package/dist/organization-model/index.d.ts +1662 -23
  4. package/dist/organization-model/index.js +171 -24
  5. package/dist/test-utils/index.d.ts +711 -10
  6. package/dist/test-utils/index.js +159 -16
  7. package/package.json +7 -3
  8. package/src/__tests__/publish.test.ts +14 -13
  9. package/src/__tests__/template-core-compatibility.test.ts +4 -4
  10. package/src/_gen/__tests__/__snapshots__/contracts.md.snap +305 -201
  11. package/src/auth/multi-tenancy/index.ts +3 -0
  12. package/src/auth/multi-tenancy/theme-presets.ts +45 -0
  13. package/src/auth/multi-tenancy/types.ts +57 -83
  14. package/src/auth/multi-tenancy/users/api-schemas.ts +165 -194
  15. package/src/business/acquisition/activity-events.ts +1 -1
  16. package/src/business/acquisition/api-schemas.ts +1196 -1177
  17. package/src/business/acquisition/crm-state-actions.test.ts +139 -139
  18. package/src/business/acquisition/types.ts +381 -390
  19. package/src/business/crm/api-schemas.ts +40 -0
  20. package/src/business/crm/index.ts +1 -0
  21. package/src/business/deals/api-schemas.ts +79 -0
  22. package/src/business/deals/index.ts +1 -0
  23. package/src/business/projects/types.ts +124 -88
  24. package/src/execution/core/runner-types.ts +61 -80
  25. package/src/execution/engine/tools/integration/server/adapters/gmail/gmail-tools.ts +105 -104
  26. package/src/execution/engine/tools/integration/server/adapters/instantly/instantly-tools.ts +1474 -1473
  27. package/src/execution/engine/tools/integration/server/adapters/millionverifier/millionverifier-tools.ts +103 -102
  28. package/src/execution/engine/tools/integration/server/adapters/signature-api/signature-api-tools.ts +182 -179
  29. package/src/execution/engine/tools/integration/server/adapters/stripe/stripe-tools.ts +310 -309
  30. package/src/execution/engine/tools/integration/tool.ts +255 -253
  31. package/src/execution/engine/tools/lead-service-types.ts +895 -894
  32. package/src/execution/engine/tools/messages.ts +43 -0
  33. package/src/execution/engine/tools/platform/acquisition/types.ts +2 -1
  34. package/src/execution/engine/tools/platform/email/types.ts +97 -96
  35. package/src/execution/engine/tools/types.ts +234 -233
  36. package/src/execution/engine/workflow/types.ts +195 -193
  37. package/src/execution/external/api-schemas.ts +40 -0
  38. package/src/execution/external/index.ts +1 -0
  39. package/src/knowledge/README.md +32 -0
  40. package/src/knowledge/__tests__/queries.test.ts +504 -0
  41. package/src/knowledge/format.ts +99 -0
  42. package/src/knowledge/index.ts +5 -0
  43. package/src/knowledge/queries.ts +256 -0
  44. package/src/organization-model/__tests__/defaults.test.ts +172 -172
  45. package/src/organization-model/__tests__/foundation.test.ts +7 -7
  46. package/src/organization-model/__tests__/icons.test.ts +27 -0
  47. package/src/organization-model/__tests__/knowledge.test.ts +214 -0
  48. package/src/organization-model/contracts.ts +17 -15
  49. package/src/organization-model/defaults.ts +74 -19
  50. package/src/organization-model/domains/knowledge.ts +53 -0
  51. package/src/organization-model/domains/navigation.ts +416 -399
  52. package/src/organization-model/domains/shared.ts +6 -5
  53. package/src/organization-model/foundation.ts +10 -6
  54. package/src/organization-model/graph/build.ts +209 -182
  55. package/src/organization-model/graph/schema.ts +37 -34
  56. package/src/organization-model/graph/types.ts +47 -31
  57. package/src/organization-model/icons.ts +81 -0
  58. package/src/organization-model/index.ts +8 -3
  59. package/src/organization-model/organization-model.mdx +1 -1
  60. package/src/organization-model/published.ts +103 -86
  61. package/src/organization-model/schema.ts +90 -85
  62. package/src/organization-model/types.ts +40 -33
  63. package/src/platform/index.ts +23 -27
  64. package/src/platform/registry/index.ts +0 -4
  65. package/src/platform/registry/resource-registry.ts +0 -77
  66. package/src/platform/registry/serialized-types.ts +148 -219
  67. package/src/platform/registry/stats-types.ts +60 -60
  68. package/src/reference/_generated/contracts.md +1265 -1154
@@ -1,309 +1,310 @@
1
- import { z } from 'zod'
2
- import type { Tool } from '../../../../types'
3
- import { createIntegrationTool } from '../../../tool'
4
-
5
- /**
6
- * Create a tool that generates Stripe payment links
7
- *
8
- * @param credentialName - Name of the Stripe credential to use
9
- * @returns Tool instance
10
- *
11
- * @example
12
- * ```typescript
13
- * const tool = createStripeCreatePaymentLinkTool('elevasis-stripe')
14
- * const result = await tool.execute({
15
- * priceId: 'price_xxx',
16
- * metadata: { deal_id: 'deal-123' },
17
- * redirectUrl: 'https://app.elevasis.io/payment-success'
18
- * }, context)
19
- * ```
20
- */
21
- export function createStripeCreatePaymentLinkTool(credentialName: string): Tool {
22
- return createIntegrationTool({
23
- name: 'stripe_create_payment_link',
24
- description: `Create a Stripe payment link for collecting payments.
25
-
26
- Use this tool to generate a payment URL that can be sent to customers.
27
- The link directs to Stripe's hosted checkout page.
28
-
29
- Examples:
30
- - Create link for proposal payment: priceId, metadata with deal_id, redirectUrl
31
- - Create link with invoice: set invoiceCreation=true`,
32
- inputSchema: z.object({
33
- priceId: z.string().describe('Stripe price ID (price_xxx)'),
34
- quantity: z.number().optional().default(1).describe('Quantity of items'),
35
- metadata: z.record(z.string(), z.string()).optional().describe('Custom metadata'),
36
- afterCompletionType: z
37
- .enum(['redirect', 'hosted_confirmation'])
38
- .optional()
39
- .describe('What happens after payment'),
40
- redirectUrl: z.string().url().optional().describe('URL to redirect after payment'),
41
- allowPromotionCodes: z.boolean().optional().describe('Allow promo codes'),
42
- automaticTax: z.boolean().optional().describe('Enable automatic tax'),
43
- billingAddressCollection: z.enum(['auto', 'required']).optional().describe('Billing address mode'),
44
- invoiceCreation: z.boolean().optional().describe('Generate invoice')
45
- }),
46
- outputSchema: z.object({
47
- id: z.string().describe('Payment link ID (plink_xxx)'),
48
- url: z.string().describe('Shareable payment URL'),
49
- active: z.boolean().describe('Whether the link is active'),
50
- livemode: z.boolean().describe('Whether in production mode')
51
- }),
52
- integration: 'stripe' as const,
53
- method: 'createPaymentLink' as const,
54
- credentialName
55
- })
56
- }
57
-
58
- /**
59
- * Create a tool that retrieves a Stripe payment link
60
- *
61
- * @param credentialName - Name of the Stripe credential to use
62
- * @returns Tool instance
63
- *
64
- * @example
65
- * ```typescript
66
- * const tool = createStripeGetPaymentLinkTool('elevasis-stripe')
67
- * const result = await tool.execute({
68
- * paymentLinkId: 'plink_xxx'
69
- * }, context)
70
- * ```
71
- */
72
- export function createStripeGetPaymentLinkTool(credentialName: string): Tool {
73
- return createIntegrationTool({
74
- name: 'stripe_get_payment_link',
75
- description: `Get details of a Stripe payment link.
76
-
77
- Use this tool to retrieve information about an existing payment link,
78
- including its URL, status, and metadata.
79
-
80
- Useful for:
81
- - Checking if a payment link is still active
82
- - Retrieving the URL for a previously created link
83
- - Accessing metadata associated with the link`,
84
- inputSchema: z.object({
85
- paymentLinkId: z.string().describe('Payment link ID (plink_xxx)')
86
- }),
87
- outputSchema: z.object({
88
- id: z.string().describe('Payment link ID'),
89
- url: z.string().describe('Shareable payment URL'),
90
- active: z.boolean().describe('Whether the link is active'),
91
- livemode: z.boolean().describe('Whether in production mode'),
92
- metadata: z.record(z.string(), z.string()).describe('Custom metadata')
93
- }),
94
- integration: 'stripe' as const,
95
- method: 'getPaymentLink' as const,
96
- credentialName
97
- })
98
- }
99
-
100
- /**
101
- * Create a tool that updates a Stripe payment link
102
- *
103
- * @param credentialName - Name of the Stripe credential to use
104
- * @returns Tool instance
105
- *
106
- * @example
107
- * ```typescript
108
- * const tool = createStripeUpdatePaymentLinkTool('elevasis-stripe')
109
- * const result = await tool.execute({
110
- * paymentLinkId: 'plink_xxx',
111
- * active: false // Deactivate the link
112
- * }, context)
113
- * ```
114
- */
115
- export function createStripeUpdatePaymentLinkTool(credentialName: string): Tool {
116
- return createIntegrationTool({
117
- name: 'stripe_update_payment_link',
118
- description: `Update a Stripe payment link.
119
-
120
- Use this tool to modify an existing payment link.
121
- Common operations:
122
- - Deactivate a link (set active=false)
123
- - Update metadata
124
-
125
- Note: You cannot change the price after creation.`,
126
- inputSchema: z.object({
127
- paymentLinkId: z.string().describe('Payment link ID (plink_xxx)'),
128
- active: z.boolean().optional().describe('Enable or disable the link'),
129
- metadata: z.record(z.string(), z.string()).optional().describe('Update metadata')
130
- }),
131
- outputSchema: z.object({
132
- id: z.string().describe('Payment link ID'),
133
- active: z.boolean().describe('Whether the link is active'),
134
- url: z.string().describe('Shareable payment URL')
135
- }),
136
- integration: 'stripe' as const,
137
- method: 'updatePaymentLink' as const,
138
- credentialName
139
- })
140
- }
141
-
142
- /**
143
- * Create a tool that lists Stripe payment links
144
- *
145
- * @param credentialName - Name of the Stripe credential to use
146
- * @returns Tool instance
147
- *
148
- * @example
149
- * ```typescript
150
- * const tool = createStripeListPaymentLinksTool('elevasis-stripe')
151
- * const result = await tool.execute({
152
- * active: true,
153
- * limit: 10
154
- * }, context)
155
- * ```
156
- */
157
- export function createStripeListPaymentLinksTool(credentialName: string): Tool {
158
- return createIntegrationTool({
159
- name: 'stripe_list_payment_links',
160
- description: `List Stripe payment links.
161
-
162
- Use this tool to retrieve a list of payment links.
163
- Supports filtering by active status and pagination.
164
-
165
- Useful for:
166
- - Finding active payment links
167
- - Auditing created links
168
- - Paginating through large numbers of links`,
169
- inputSchema: z.object({
170
- active: z.boolean().optional().describe('Filter by active status'),
171
- limit: z.number().min(1).max(100).optional().describe('Number of links to return (1-100)'),
172
- startingAfter: z.string().optional().describe('Cursor for pagination (payment link ID)'),
173
- endingBefore: z.string().optional().describe('Cursor for pagination (payment link ID)')
174
- }),
175
- outputSchema: z.object({
176
- data: z
177
- .array(
178
- z.object({
179
- id: z.string().describe('Payment link ID'),
180
- url: z.string().describe('Shareable payment URL'),
181
- active: z.boolean().describe('Whether the link is active'),
182
- metadata: z.record(z.string(), z.string()).describe('Custom metadata')
183
- })
184
- )
185
- .describe('List of payment links'),
186
- hasMore: z.boolean().describe('Whether more results are available')
187
- }),
188
- integration: 'stripe' as const,
189
- method: 'listPaymentLinks' as const,
190
- credentialName
191
- })
192
- }
193
-
194
- /**
195
- * Create a tool that generates Stripe checkout sessions for custom amounts
196
- *
197
- * Use this for variable/custom pricing where the amount comes from the proposal.
198
- * Unlike payment links (which require pre-defined price IDs), checkout sessions
199
- * support price_data with any unit_amount.
200
- *
201
- * @param credentialName - Name of the Stripe credential to use
202
- * @returns Tool instance
203
- *
204
- * @example
205
- * ```typescript
206
- * const tool = createStripeCheckoutSessionTool('elevasis-stripe')
207
- * const result = await tool.execute({
208
- * amount: 2400000, // $24,000 in cents
209
- * metadata: { deal_id: 'deal-123' },
210
- * successUrl: 'https://app.elevasis.io/payment-success',
211
- * cancelUrl: 'https://app.elevasis.io/payment-cancelled'
212
- * }, context)
213
- * ```
214
- */
215
- export function createStripeCheckoutSessionTool(credentialName: string): Tool {
216
- return createIntegrationTool({
217
- name: 'stripe_create_checkout_session',
218
- description: `Create a Stripe checkout session for custom-amount payments.
219
-
220
- Use this tool for variable pricing where the amount comes from the proposal.
221
- Creates a one-time payment URL that expires in 24 hours.
222
-
223
- Key differences from payment links:
224
- - Supports any amount (no pre-defined price IDs needed)
225
- - URL expires in 24 hours (must recreate if needed)
226
- - Created per-transaction (not reusable)
227
-
228
- Examples:
229
- - Collect payment for signed proposal: amount from proposal, metadata with deal_id
230
- - Customer receives hosted Stripe checkout page`,
231
- inputSchema: z.object({
232
- amount: z.number().int().positive().describe('Amount in cents (e.g., 2400000 for $24,000)'),
233
- currency: z.string().optional().default('usd').describe('Currency code (default: usd)'),
234
- productName: z.string().optional().describe('Product name shown in checkout'),
235
- productDescription: z.string().optional().describe('Product description'),
236
- metadata: z.record(z.string(), z.string()).optional().describe('Metadata (deal_id, etc.)'),
237
- successUrl: z.string().url().describe('URL after successful payment'),
238
- cancelUrl: z.string().url().describe('URL if customer cancels'),
239
- customerEmail: z.string().email().optional().describe('Pre-fill customer email')
240
- }),
241
- outputSchema: z.object({
242
- id: z.string().describe('Session ID (cs_xxx)'),
243
- url: z.string().describe('Payment URL (expires in 24h)'),
244
- expiresAt: z.number().describe('Expiration timestamp (Unix seconds)')
245
- }),
246
- integration: 'stripe' as const,
247
- method: 'createCheckoutSession' as const,
248
- credentialName
249
- })
250
- }
251
-
252
- /**
253
- * Create a tool that generates Stripe payment links with dynamic pricing
254
- *
255
- * Unlike standard payment links (which require pre-created Price IDs),
256
- * this tool uses inline price_data for dynamic pricing. Supports both
257
- * one-time setup fees and recurring monthly subscriptions.
258
- *
259
- * @param credentialName - Name of the Stripe credential to use
260
- * @returns Tool instance
261
- *
262
- * @example
263
- * ```typescript
264
- * const tool = createStripeAutoPaymentLinkTool('elevasis-stripe')
265
- * const result = await tool.execute({
266
- * dealId: 'deal-123',
267
- * companyName: 'Acme Corp',
268
- * contactEmail: 'john@acme.com',
269
- * initialFee: 3000, // $3,000 one-time
270
- * monthlyFee: 500 // $500/month recurring
271
- * }, context)
272
- * ```
273
- */
274
- export function createStripeAutoPaymentLinkTool(credentialName: string): Tool {
275
- return createIntegrationTool({
276
- name: 'stripe_create_auto_payment_link',
277
- description: `Create a Stripe payment link with dynamic pricing (inline price_data).
278
-
279
- Use this tool for variable pricing with both one-time and recurring fees.
280
- URLs NEVER EXPIRE - same link can be used in all reminder emails.
281
-
282
- Key features:
283
- - Supports dynamic amounts (no pre-defined Price IDs needed)
284
- - Can include both one-time setup fee AND monthly recurring in one link
285
- - URL never expires (unlike checkout sessions)
286
- - Metadata propagates to all webhooks (checkout.session.completed, etc.)
287
-
288
- Examples:
289
- - Setup + monthly: initialFee=3000, monthlyFee=500 ($3,000 one-time + $500/month)
290
- - Monthly only: initialFee=0, monthlyFee=500 ($500/month subscription)
291
- - One-time only: initialFee=3000, monthlyFee=0 ($3,000 one-time payment)`,
292
- inputSchema: z.object({
293
- dealId: z.string().describe('Local deal ID for metadata'),
294
- companyName: z.string().describe('Company name for product description'),
295
- contactEmail: z.string().email().describe('Contact email for metadata'),
296
- initialFee: z.number().min(0).describe('One-time setup fee in dollars (e.g., 3000 for $3,000)'),
297
- monthlyFee: z.number().min(0).describe('Recurring monthly fee in dollars (e.g., 500 for $500/month)')
298
- }),
299
- outputSchema: z.object({
300
- paymentLinkId: z.string().describe('Payment link ID (plink_xxx)'),
301
- url: z.string().describe('Payment URL (NEVER EXPIRES)'),
302
- hasInitialFee: z.boolean().describe('Whether link includes one-time fee'),
303
- hasRecurring: z.boolean().describe('Whether link includes recurring subscription')
304
- }),
305
- integration: 'stripe' as const,
306
- method: 'createAutoPaymentLink' as const,
307
- credentialName
308
- })
309
- }
1
+ import { z } from 'zod'
2
+ import type { Tool } from '../../../../types'
3
+ import { createIntegrationTool } from '../../../tool'
4
+ import { EmailSchema } from '../../../../../../../platform/utils/validation'
5
+
6
+ /**
7
+ * Create a tool that generates Stripe payment links
8
+ *
9
+ * @param credentialName - Name of the Stripe credential to use
10
+ * @returns Tool instance
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const tool = createStripeCreatePaymentLinkTool('elevasis-stripe')
15
+ * const result = await tool.execute({
16
+ * priceId: 'price_xxx',
17
+ * metadata: { deal_id: 'deal-123' },
18
+ * redirectUrl: 'https://app.elevasis.io/payment-success'
19
+ * }, context)
20
+ * ```
21
+ */
22
+ export function createStripeCreatePaymentLinkTool(credentialName: string): Tool {
23
+ return createIntegrationTool({
24
+ name: 'stripe_create_payment_link',
25
+ description: `Create a Stripe payment link for collecting payments.
26
+
27
+ Use this tool to generate a payment URL that can be sent to customers.
28
+ The link directs to Stripe's hosted checkout page.
29
+
30
+ Examples:
31
+ - Create link for proposal payment: priceId, metadata with deal_id, redirectUrl
32
+ - Create link with invoice: set invoiceCreation=true`,
33
+ inputSchema: z.object({
34
+ priceId: z.string().describe('Stripe price ID (price_xxx)'),
35
+ quantity: z.number().optional().default(1).describe('Quantity of items'),
36
+ metadata: z.record(z.string(), z.string()).optional().describe('Custom metadata'),
37
+ afterCompletionType: z
38
+ .enum(['redirect', 'hosted_confirmation'])
39
+ .optional()
40
+ .describe('What happens after payment'),
41
+ redirectUrl: z.string().url().optional().describe('URL to redirect after payment'),
42
+ allowPromotionCodes: z.boolean().optional().describe('Allow promo codes'),
43
+ automaticTax: z.boolean().optional().describe('Enable automatic tax'),
44
+ billingAddressCollection: z.enum(['auto', 'required']).optional().describe('Billing address mode'),
45
+ invoiceCreation: z.boolean().optional().describe('Generate invoice')
46
+ }),
47
+ outputSchema: z.object({
48
+ id: z.string().describe('Payment link ID (plink_xxx)'),
49
+ url: z.string().describe('Shareable payment URL'),
50
+ active: z.boolean().describe('Whether the link is active'),
51
+ livemode: z.boolean().describe('Whether in production mode')
52
+ }),
53
+ integration: 'stripe' as const,
54
+ method: 'createPaymentLink' as const,
55
+ credentialName
56
+ })
57
+ }
58
+
59
+ /**
60
+ * Create a tool that retrieves a Stripe payment link
61
+ *
62
+ * @param credentialName - Name of the Stripe credential to use
63
+ * @returns Tool instance
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * const tool = createStripeGetPaymentLinkTool('elevasis-stripe')
68
+ * const result = await tool.execute({
69
+ * paymentLinkId: 'plink_xxx'
70
+ * }, context)
71
+ * ```
72
+ */
73
+ export function createStripeGetPaymentLinkTool(credentialName: string): Tool {
74
+ return createIntegrationTool({
75
+ name: 'stripe_get_payment_link',
76
+ description: `Get details of a Stripe payment link.
77
+
78
+ Use this tool to retrieve information about an existing payment link,
79
+ including its URL, status, and metadata.
80
+
81
+ Useful for:
82
+ - Checking if a payment link is still active
83
+ - Retrieving the URL for a previously created link
84
+ - Accessing metadata associated with the link`,
85
+ inputSchema: z.object({
86
+ paymentLinkId: z.string().describe('Payment link ID (plink_xxx)')
87
+ }),
88
+ outputSchema: z.object({
89
+ id: z.string().describe('Payment link ID'),
90
+ url: z.string().describe('Shareable payment URL'),
91
+ active: z.boolean().describe('Whether the link is active'),
92
+ livemode: z.boolean().describe('Whether in production mode'),
93
+ metadata: z.record(z.string(), z.string()).describe('Custom metadata')
94
+ }),
95
+ integration: 'stripe' as const,
96
+ method: 'getPaymentLink' as const,
97
+ credentialName
98
+ })
99
+ }
100
+
101
+ /**
102
+ * Create a tool that updates a Stripe payment link
103
+ *
104
+ * @param credentialName - Name of the Stripe credential to use
105
+ * @returns Tool instance
106
+ *
107
+ * @example
108
+ * ```typescript
109
+ * const tool = createStripeUpdatePaymentLinkTool('elevasis-stripe')
110
+ * const result = await tool.execute({
111
+ * paymentLinkId: 'plink_xxx',
112
+ * active: false // Deactivate the link
113
+ * }, context)
114
+ * ```
115
+ */
116
+ export function createStripeUpdatePaymentLinkTool(credentialName: string): Tool {
117
+ return createIntegrationTool({
118
+ name: 'stripe_update_payment_link',
119
+ description: `Update a Stripe payment link.
120
+
121
+ Use this tool to modify an existing payment link.
122
+ Common operations:
123
+ - Deactivate a link (set active=false)
124
+ - Update metadata
125
+
126
+ Note: You cannot change the price after creation.`,
127
+ inputSchema: z.object({
128
+ paymentLinkId: z.string().describe('Payment link ID (plink_xxx)'),
129
+ active: z.boolean().optional().describe('Enable or disable the link'),
130
+ metadata: z.record(z.string(), z.string()).optional().describe('Update metadata')
131
+ }),
132
+ outputSchema: z.object({
133
+ id: z.string().describe('Payment link ID'),
134
+ active: z.boolean().describe('Whether the link is active'),
135
+ url: z.string().describe('Shareable payment URL')
136
+ }),
137
+ integration: 'stripe' as const,
138
+ method: 'updatePaymentLink' as const,
139
+ credentialName
140
+ })
141
+ }
142
+
143
+ /**
144
+ * Create a tool that lists Stripe payment links
145
+ *
146
+ * @param credentialName - Name of the Stripe credential to use
147
+ * @returns Tool instance
148
+ *
149
+ * @example
150
+ * ```typescript
151
+ * const tool = createStripeListPaymentLinksTool('elevasis-stripe')
152
+ * const result = await tool.execute({
153
+ * active: true,
154
+ * limit: 10
155
+ * }, context)
156
+ * ```
157
+ */
158
+ export function createStripeListPaymentLinksTool(credentialName: string): Tool {
159
+ return createIntegrationTool({
160
+ name: 'stripe_list_payment_links',
161
+ description: `List Stripe payment links.
162
+
163
+ Use this tool to retrieve a list of payment links.
164
+ Supports filtering by active status and pagination.
165
+
166
+ Useful for:
167
+ - Finding active payment links
168
+ - Auditing created links
169
+ - Paginating through large numbers of links`,
170
+ inputSchema: z.object({
171
+ active: z.boolean().optional().describe('Filter by active status'),
172
+ limit: z.number().min(1).max(100).optional().describe('Number of links to return (1-100)'),
173
+ startingAfter: z.string().optional().describe('Cursor for pagination (payment link ID)'),
174
+ endingBefore: z.string().optional().describe('Cursor for pagination (payment link ID)')
175
+ }),
176
+ outputSchema: z.object({
177
+ data: z
178
+ .array(
179
+ z.object({
180
+ id: z.string().describe('Payment link ID'),
181
+ url: z.string().describe('Shareable payment URL'),
182
+ active: z.boolean().describe('Whether the link is active'),
183
+ metadata: z.record(z.string(), z.string()).describe('Custom metadata')
184
+ })
185
+ )
186
+ .describe('List of payment links'),
187
+ hasMore: z.boolean().describe('Whether more results are available')
188
+ }),
189
+ integration: 'stripe' as const,
190
+ method: 'listPaymentLinks' as const,
191
+ credentialName
192
+ })
193
+ }
194
+
195
+ /**
196
+ * Create a tool that generates Stripe checkout sessions for custom amounts
197
+ *
198
+ * Use this for variable/custom pricing where the amount comes from the proposal.
199
+ * Unlike payment links (which require pre-defined price IDs), checkout sessions
200
+ * support price_data with any unit_amount.
201
+ *
202
+ * @param credentialName - Name of the Stripe credential to use
203
+ * @returns Tool instance
204
+ *
205
+ * @example
206
+ * ```typescript
207
+ * const tool = createStripeCheckoutSessionTool('elevasis-stripe')
208
+ * const result = await tool.execute({
209
+ * amount: 2400000, // $24,000 in cents
210
+ * metadata: { deal_id: 'deal-123' },
211
+ * successUrl: 'https://app.elevasis.io/payment-success',
212
+ * cancelUrl: 'https://app.elevasis.io/payment-cancelled'
213
+ * }, context)
214
+ * ```
215
+ */
216
+ export function createStripeCheckoutSessionTool(credentialName: string): Tool {
217
+ return createIntegrationTool({
218
+ name: 'stripe_create_checkout_session',
219
+ description: `Create a Stripe checkout session for custom-amount payments.
220
+
221
+ Use this tool for variable pricing where the amount comes from the proposal.
222
+ Creates a one-time payment URL that expires in 24 hours.
223
+
224
+ Key differences from payment links:
225
+ - Supports any amount (no pre-defined price IDs needed)
226
+ - URL expires in 24 hours (must recreate if needed)
227
+ - Created per-transaction (not reusable)
228
+
229
+ Examples:
230
+ - Collect payment for signed proposal: amount from proposal, metadata with deal_id
231
+ - Customer receives hosted Stripe checkout page`,
232
+ inputSchema: z.object({
233
+ amount: z.number().int().positive().describe('Amount in cents (e.g., 2400000 for $24,000)'),
234
+ currency: z.string().optional().default('usd').describe('Currency code (default: usd)'),
235
+ productName: z.string().optional().describe('Product name shown in checkout'),
236
+ productDescription: z.string().optional().describe('Product description'),
237
+ metadata: z.record(z.string(), z.string()).optional().describe('Metadata (deal_id, etc.)'),
238
+ successUrl: z.string().url().describe('URL after successful payment'),
239
+ cancelUrl: z.string().url().describe('URL if customer cancels'),
240
+ customerEmail: EmailSchema.optional().describe('Pre-fill customer email')
241
+ }),
242
+ outputSchema: z.object({
243
+ id: z.string().describe('Session ID (cs_xxx)'),
244
+ url: z.string().describe('Payment URL (expires in 24h)'),
245
+ expiresAt: z.number().describe('Expiration timestamp (Unix seconds)')
246
+ }),
247
+ integration: 'stripe' as const,
248
+ method: 'createCheckoutSession' as const,
249
+ credentialName
250
+ })
251
+ }
252
+
253
+ /**
254
+ * Create a tool that generates Stripe payment links with dynamic pricing
255
+ *
256
+ * Unlike standard payment links (which require pre-created Price IDs),
257
+ * this tool uses inline price_data for dynamic pricing. Supports both
258
+ * one-time setup fees and recurring monthly subscriptions.
259
+ *
260
+ * @param credentialName - Name of the Stripe credential to use
261
+ * @returns Tool instance
262
+ *
263
+ * @example
264
+ * ```typescript
265
+ * const tool = createStripeAutoPaymentLinkTool('elevasis-stripe')
266
+ * const result = await tool.execute({
267
+ * dealId: 'deal-123',
268
+ * companyName: 'Acme Corp',
269
+ * contactEmail: 'john@acme.com',
270
+ * initialFee: 3000, // $3,000 one-time
271
+ * monthlyFee: 500 // $500/month recurring
272
+ * }, context)
273
+ * ```
274
+ */
275
+ export function createStripeAutoPaymentLinkTool(credentialName: string): Tool {
276
+ return createIntegrationTool({
277
+ name: 'stripe_create_auto_payment_link',
278
+ description: `Create a Stripe payment link with dynamic pricing (inline price_data).
279
+
280
+ Use this tool for variable pricing with both one-time and recurring fees.
281
+ URLs NEVER EXPIRE - same link can be used in all reminder emails.
282
+
283
+ Key features:
284
+ - Supports dynamic amounts (no pre-defined Price IDs needed)
285
+ - Can include both one-time setup fee AND monthly recurring in one link
286
+ - URL never expires (unlike checkout sessions)
287
+ - Metadata propagates to all webhooks (checkout.session.completed, etc.)
288
+
289
+ Examples:
290
+ - Setup + monthly: initialFee=3000, monthlyFee=500 ($3,000 one-time + $500/month)
291
+ - Monthly only: initialFee=0, monthlyFee=500 ($500/month subscription)
292
+ - One-time only: initialFee=3000, monthlyFee=0 ($3,000 one-time payment)`,
293
+ inputSchema: z.object({
294
+ dealId: z.string().describe('Local deal ID for metadata'),
295
+ companyName: z.string().describe('Company name for product description'),
296
+ contactEmail: EmailSchema.describe('Contact email for metadata'),
297
+ initialFee: z.number().min(0).describe('One-time setup fee in dollars (e.g., 3000 for $3,000)'),
298
+ monthlyFee: z.number().min(0).describe('Recurring monthly fee in dollars (e.g., 500 for $500/month)')
299
+ }),
300
+ outputSchema: z.object({
301
+ paymentLinkId: z.string().describe('Payment link ID (plink_xxx)'),
302
+ url: z.string().describe('Payment URL (NEVER EXPIRES)'),
303
+ hasInitialFee: z.boolean().describe('Whether link includes one-time fee'),
304
+ hasRecurring: z.boolean().describe('Whether link includes recurring subscription')
305
+ }),
306
+ integration: 'stripe' as const,
307
+ method: 'createAutoPaymentLink' as const,
308
+ credentialName
309
+ })
310
+ }