@dainprotocol/service-sdk 2.0.52 → 2.0.54

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.
@@ -0,0 +1,144 @@
1
+ "use strict";
2
+ /**
3
+ * Actionable Tool Schema & Utilities
4
+ *
5
+ * Provides standardized schema and helpers for tools that send actionable messages.
6
+ * These tools enable users to trigger system actions through responses (buttons, callbacks, links).
7
+ *
8
+ * @see automation-core/src/core/tools/actionable-tool.schema.ts (matching schema)
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.ActionableToolBaseSchema = exports.MetadataSchema = exports.ActionSchema = void 0;
12
+ exports.extendActionableSchema = extendActionableSchema;
13
+ exports.buildActionableTool = buildActionableTool;
14
+ exports.validateActionableSchema = validateActionableSchema;
15
+ const zod_1 = require("zod");
16
+ /**
17
+ * Action button/option schema
18
+ */
19
+ exports.ActionSchema = zod_1.z.object({
20
+ label: zod_1.z.string().describe('Button/action label shown to user'),
21
+ type: zod_1.z
22
+ .enum(['approve', 'reject', 'callback', 'url', 'custom'])
23
+ .describe('Type of action'),
24
+ value: zod_1.z.string().optional().describe('Value sent back when action is triggered'),
25
+ url: zod_1.z.string().optional().describe('URL to open (for url type actions)'),
26
+ });
27
+ /**
28
+ * Automation metadata schema (auto-injected by automation-core)
29
+ */
30
+ exports.MetadataSchema = zod_1.z.object({
31
+ runId: zod_1.z.string().optional().describe('Current run ID'),
32
+ waitId: zod_1.z.string().optional().describe('Wait node ID if applicable'),
33
+ automationId: zod_1.z.string().optional().describe('Automation ID'),
34
+ interactionUrl: zod_1.z.string().optional().describe('URL for user interaction'),
35
+ });
36
+ /**
37
+ * Base schema for all actionable tools
38
+ * Tools marked with supportsUserActions: true MUST accept these fields
39
+ */
40
+ exports.ActionableToolBaseSchema = zod_1.z.object({
41
+ recipient: zod_1.z.string().describe('Who receives this message (chatId, channel, email, etc.)'),
42
+ message: zod_1.z.string().describe('The message text to send'),
43
+ actions: zod_1.z.array(exports.ActionSchema).optional().describe('Interactive actions the user can trigger'),
44
+ metadata: exports.MetadataSchema.optional().describe('Automation metadata (auto-injected by system)'),
45
+ });
46
+ /**
47
+ * Extend base actionable schema with tool-specific fields
48
+ * Use this to add additional parameters while keeping the standard actionable fields
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * const TelegramInputSchema = extendActionableSchema({
53
+ * parse_mode: z.enum(['HTML', 'Markdown']).optional(),
54
+ * disable_notification: z.boolean().optional(),
55
+ * });
56
+ * ```
57
+ */
58
+ function extendActionableSchema(additionalFields) {
59
+ return exports.ActionableToolBaseSchema.extend(additionalFields);
60
+ }
61
+ /**
62
+ * Helper function to build an actionable tool with type safety and schema enforcement
63
+ * Automatically merges base actionable schema with tool-specific fields
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * export const sendTelegramMessage = buildActionableTool({
68
+ * id: 'send-telegram-message',
69
+ * name: 'Send Telegram Message',
70
+ * description: 'Send a message with interactive buttons to a Telegram chat',
71
+ * additionalFields: {
72
+ * parse_mode: z.enum(['HTML', 'Markdown']).optional(),
73
+ * },
74
+ * handler: async (input, agentInfo, context) => {
75
+ * // input is typed with: recipient, message, actions, metadata, parse_mode
76
+ * const { recipient, message, actions, parse_mode } = input;
77
+ *
78
+ * // Use recipient as chatId for Telegram API
79
+ * const result = await sendToTelegram({
80
+ * chat_id: recipient,
81
+ * text: message,
82
+ * parse_mode,
83
+ * reply_markup: actions ? buildInlineKeyboard(actions) : undefined,
84
+ * });
85
+ *
86
+ * return {
87
+ * text: `Message sent to ${recipient}`,
88
+ * data: { messageId: result.message_id },
89
+ * };
90
+ * },
91
+ * });
92
+ * ```
93
+ */
94
+ function buildActionableTool(config) {
95
+ // Merge base actionable schema with additional fields
96
+ const inputSchema = config.additionalFields
97
+ ? exports.ActionableToolBaseSchema.extend(config.additionalFields)
98
+ : exports.ActionableToolBaseSchema;
99
+ const outputSchema = config.output || zod_1.z.any();
100
+ return {
101
+ id: config.id,
102
+ name: config.name,
103
+ description: config.description,
104
+ input: inputSchema,
105
+ output: outputSchema,
106
+ supportsUserActions: true, // Always true for actionable tools
107
+ handler: config.handler,
108
+ };
109
+ }
110
+ /**
111
+ * Validate that a tool schema includes required actionable fields
112
+ * Use this to check if a manually-defined tool complies with actionable schema
113
+ */
114
+ function validateActionableSchema(toolConfig) {
115
+ if (!toolConfig.supportsUserActions) {
116
+ return { valid: true }; // Not an actionable tool, no validation needed
117
+ }
118
+ const errors = [];
119
+ // Check if input schema is a Zod object
120
+ if (!(toolConfig.input instanceof zod_1.z.ZodObject)) {
121
+ errors.push('Input schema must be a Zod object for actionable tools');
122
+ return { valid: false, errors };
123
+ }
124
+ const shape = toolConfig.input.shape;
125
+ // Check required fields
126
+ if (!shape.recipient) {
127
+ errors.push("Missing required field: 'recipient'");
128
+ }
129
+ if (!shape.message) {
130
+ errors.push("Missing required field: 'message'");
131
+ }
132
+ // Check field types
133
+ if (shape.recipient && !(shape.recipient instanceof zod_1.z.ZodString)) {
134
+ errors.push("Field 'recipient' must be a string");
135
+ }
136
+ if (shape.message && !(shape.message instanceof zod_1.z.ZodString)) {
137
+ errors.push("Field 'message' must be a string");
138
+ }
139
+ return {
140
+ valid: errors.length === 0,
141
+ errors: errors.length > 0 ? errors : undefined,
142
+ };
143
+ }
144
+ //# sourceMappingURL=actionable-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actionable-tools.js","sourceRoot":"","sources":["../../src/service/actionable-tools.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAyDH,wDAIC;AAmCD,kDAsCC;AAMD,4DAsCC;AAhLD,6BAAwB;AAGxB;;GAEG;AACU,QAAA,YAAY,GAAG,OAAC,CAAC,MAAM,CAAC;IACnC,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,mCAAmC,CAAC;IAC/D,IAAI,EAAE,OAAC;SACJ,IAAI,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,K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,IAAI,CAAC,qCAAqC,CAAC,CAAC;IACrD,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACnB,MAAM,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;IACnD,CAAC;IAED,oBAAoB;IACpB,IAAI,KAAK,CAAC,SAAS,IAAI,CAAC,CAAC,KAAK,CAAC,SAAS,YAAY,OAAC,CAAC,SAAS,CAAC,EAAE,CAAC;QACjE,MAAM,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC;IACpD,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,OAAC,CAAC,SAAS,CAAC,EAAE,CAAC;QAC7D,MAAM,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;IAClD,CAAC;IAED,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;QAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;KAC/C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,154 @@
1
+ import { StorageAdapter } from '@dainprotocol/oauth2-token-manager';
2
+ /**
3
+ * Pending setup information
4
+ */
5
+ export interface PendingSetup {
6
+ setupCode: string;
7
+ userId: string;
8
+ provider: string;
9
+ expiresAt: number;
10
+ }
11
+ /**
12
+ * Setup completion result
13
+ */
14
+ export interface SetupCompletionResult {
15
+ success: boolean;
16
+ userId?: string;
17
+ error?: string;
18
+ }
19
+ /**
20
+ * Onboarding UI configuration
21
+ * Returned by adapter to display setup instructions to user
22
+ */
23
+ export interface OnboardingUI {
24
+ /** Primary action URL (e.g., deep link, authorization URL) */
25
+ actionUrl: string;
26
+ /** QR code image URL */
27
+ qrCodeUrl?: string;
28
+ /** Instructions to display to the user */
29
+ instructions: string[];
30
+ /** Button label for primary action */
31
+ buttonLabel?: string;
32
+ /** Provider logo URL */
33
+ logoUrl?: string;
34
+ }
35
+ /**
36
+ * DirectAuthAdapter Interface
37
+ *
38
+ * Contract for provider-specific direct authentication adapters.
39
+ * Implementations handle provider-specific UI generation.
40
+ * Webhook parsing is handled by the service's existing infrastructure.
41
+ */
42
+ export interface DirectAuthAdapter {
43
+ /** Provider name */
44
+ provider: string;
45
+ /**
46
+ * Generate the onboarding UI for the user
47
+ * @param setupCode - The generated setup code
48
+ * @param expiresAt - Timestamp when the setup code expires
49
+ */
50
+ generateOnboardingUI(setupCode: string, expiresAt: number): OnboardingUI;
51
+ /**
52
+ * Send a confirmation message after successful setup
53
+ * @param config - The stored configuration
54
+ */
55
+ sendConfirmation?(config: Record<string, any>): Promise<void>;
56
+ }
57
+ /**
58
+ * DirectAuthSetupManager - Manages temporary setup codes for direct authentication providers
59
+ *
60
+ * Used for services that require user-provided configuration without external OAuth flow
61
+ * Examples: Telegram bot (chat ID), SMS (phone number), custom API endpoints
62
+ *
63
+ * Storage Strategy:
64
+ * - Uses StorageAdapter (backed by database from @dainprotocol/oauth2-storage-drizzle)
65
+ * - Pending setups: Stored as tokens with provider `setup_pending_{provider}`
66
+ * - userId field = setup code (for quick lookup)
67
+ * - email field = actual user ID
68
+ * - metadata = { originalUserId, provider, expiresAt }
69
+ * - token.expiresAt = expiry timestamp
70
+ * - Completed setups: Stored as tokens with provider `{provider}`
71
+ * - userId field = user ID
72
+ * - metadata = { chatId, username, firstName, etc. }
73
+ */
74
+ export declare class DirectAuthSetupManager {
75
+ private storage;
76
+ constructor(storage: StorageAdapter);
77
+ /**
78
+ * Generate a cryptographically secure setup code
79
+ * 32 hex characters (16 bytes entropy)
80
+ */
81
+ private generateSetupCode;
82
+ /**
83
+ * Get the pending provider name for storage
84
+ */
85
+ private getPendingProviderName;
86
+ /**
87
+ * Create a pending setup for a user and provider
88
+ *
89
+ * @param userId - The user ID (e.g., smart account ID)
90
+ * @param provider - The provider name (e.g., 'telegram')
91
+ * @param expiryMinutes - How long the setup code is valid (default: 15 minutes)
92
+ * @returns The generated setup code
93
+ */
94
+ createSetup(userId: string, provider: string, expiryMinutes?: number): Promise<string>;
95
+ /**
96
+ * Verify a setup code is valid and not expired
97
+ *
98
+ * @param setupCode - The setup code to verify
99
+ * @param provider - The provider name
100
+ * @returns The pending setup info if valid, null otherwise
101
+ */
102
+ verifySetup(setupCode: string, provider: string): Promise<PendingSetup | null>;
103
+ /**
104
+ * Complete setup and store the provider configuration
105
+ *
106
+ * @param setupCode - The setup code that was verified
107
+ * @param provider - The provider name
108
+ * @param config - The configuration to store (e.g., { chatId: 123456789 })
109
+ * @returns Result indicating success or failure
110
+ */
111
+ completeSetup(setupCode: string, provider: string, config: Record<string, any>): Promise<SetupCompletionResult>;
112
+ /**
113
+ * Check if a user has completed setup for a provider
114
+ *
115
+ * @param userId - The user ID
116
+ * @param provider - The provider name
117
+ * @returns True if setup is complete
118
+ */
119
+ isSetupComplete(userId: string, provider: string): Promise<boolean>;
120
+ /**
121
+ * Get the stored configuration for a user and provider
122
+ *
123
+ * @param userId - The user ID
124
+ * @param provider - The provider name
125
+ * @returns The stored config or null if not found
126
+ */
127
+ getProviderConfig(userId: string, provider: string): Promise<Record<string, any> | null>;
128
+ /**
129
+ * Delete provider configuration for a user
130
+ * Used when user wants to disconnect/revoke access
131
+ *
132
+ * @param userId - The user ID
133
+ * @param provider - The provider name
134
+ * @returns True if deleted successfully
135
+ */
136
+ deleteProviderConfig(userId: string, provider: string): Promise<boolean>;
137
+ /**
138
+ * Get pending setup status for a user
139
+ * Useful for showing setup progress in UI
140
+ *
141
+ * @param userId - The user ID
142
+ * @param provider - The provider name
143
+ * @returns Pending setup info if exists, null otherwise
144
+ */
145
+ getPendingSetup(userId: string, provider: string): Promise<PendingSetup | null>;
146
+ /**
147
+ * Cleanup expired pending setups
148
+ * Should be called periodically to prevent stale data accumulation
149
+ *
150
+ * @param provider - The provider name to clean up
151
+ * @returns Number of expired setups cleaned up
152
+ */
153
+ cleanupExpiredSetups(provider: string): Promise<number>;
154
+ }
@@ -0,0 +1,308 @@
1
+ "use strict";
2
+ // File: src/service/direct-auth-setup.ts
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.DirectAuthSetupManager = void 0;
5
+ const crypto_1 = require("crypto");
6
+ /**
7
+ * DirectAuthSetupManager - Manages temporary setup codes for direct authentication providers
8
+ *
9
+ * Used for services that require user-provided configuration without external OAuth flow
10
+ * Examples: Telegram bot (chat ID), SMS (phone number), custom API endpoints
11
+ *
12
+ * Storage Strategy:
13
+ * - Uses StorageAdapter (backed by database from @dainprotocol/oauth2-storage-drizzle)
14
+ * - Pending setups: Stored as tokens with provider `setup_pending_{provider}`
15
+ * - userId field = setup code (for quick lookup)
16
+ * - email field = actual user ID
17
+ * - metadata = { originalUserId, provider, expiresAt }
18
+ * - token.expiresAt = expiry timestamp
19
+ * - Completed setups: Stored as tokens with provider `{provider}`
20
+ * - userId field = user ID
21
+ * - metadata = { chatId, username, firstName, etc. }
22
+ */
23
+ class DirectAuthSetupManager {
24
+ storage;
25
+ constructor(storage) {
26
+ this.storage = storage;
27
+ }
28
+ /**
29
+ * Generate a cryptographically secure setup code
30
+ * 32 hex characters (16 bytes entropy)
31
+ */
32
+ generateSetupCode() {
33
+ return (0, crypto_1.randomBytes)(16).toString('hex');
34
+ }
35
+ /**
36
+ * Get the pending provider name for storage
37
+ */
38
+ getPendingProviderName(provider) {
39
+ return `setup_pending_${provider}`;
40
+ }
41
+ /**
42
+ * Create a pending setup for a user and provider
43
+ *
44
+ * @param userId - The user ID (e.g., smart account ID)
45
+ * @param provider - The provider name (e.g., 'telegram')
46
+ * @param expiryMinutes - How long the setup code is valid (default: 15 minutes)
47
+ * @returns The generated setup code
48
+ */
49
+ async createSetup(userId, provider, expiryMinutes = 15) {
50
+ const setupCode = this.generateSetupCode();
51
+ const expiresAt = Date.now() + (expiryMinutes * 60 * 1000);
52
+ const pendingProvider = this.getPendingProviderName(provider);
53
+ // Store pending setup using StorageAdapter
54
+ // We use setupCode as userId for quick lookup when verifying
55
+ // The actual userId is stored in the email field and metadata
56
+ await this.storage.saveToken({
57
+ provider: pendingProvider,
58
+ userId: setupCode, // Use setup code as userId for lookup
59
+ email: `${userId}@dain.local`, // Store actual userId in email field
60
+ token: {
61
+ accessToken: setupCode,
62
+ expiresAt: new Date(expiresAt),
63
+ tokenType: 'pending_setup'
64
+ },
65
+ metadata: {
66
+ originalUserId: userId,
67
+ provider: provider,
68
+ expiresAt: expiresAt,
69
+ createdAt: Date.now()
70
+ }
71
+ });
72
+ console.log(`[DirectAuthSetupManager] Created setup code for user ${userId}, provider ${provider}, expires in ${expiryMinutes} minutes`);
73
+ return setupCode;
74
+ }
75
+ /**
76
+ * Verify a setup code is valid and not expired
77
+ *
78
+ * @param setupCode - The setup code to verify
79
+ * @param provider - The provider name
80
+ * @returns The pending setup info if valid, null otherwise
81
+ */
82
+ async verifySetup(setupCode, provider) {
83
+ const pendingProvider = this.getPendingProviderName(provider);
84
+ try {
85
+ // Look up the setup code (stored as userId)
86
+ const tokens = await this.storage.queryTokens({
87
+ userId: setupCode,
88
+ provider: pendingProvider
89
+ });
90
+ if (!tokens || tokens.length === 0) {
91
+ console.log(`[DirectAuthSetupManager] Setup code not found: ${setupCode.substring(0, 8)}...`);
92
+ return null;
93
+ }
94
+ const token = tokens[0];
95
+ const metadata = token.metadata;
96
+ // Check expiry
97
+ const expiresAt = metadata?.expiresAt || 0;
98
+ if (Date.now() > expiresAt) {
99
+ console.log(`[DirectAuthSetupManager] Setup code expired: ${setupCode.substring(0, 8)}...`);
100
+ // Clean up expired token
101
+ await this.storage.deleteTokenByProviderEmail(pendingProvider, `${metadata.originalUserId}@dain.local`);
102
+ return null;
103
+ }
104
+ return {
105
+ setupCode,
106
+ userId: metadata.originalUserId,
107
+ provider: metadata.provider,
108
+ expiresAt
109
+ };
110
+ }
111
+ catch (error) {
112
+ console.error(`[DirectAuthSetupManager] Error verifying setup:`, error);
113
+ return null;
114
+ }
115
+ }
116
+ /**
117
+ * Complete setup and store the provider configuration
118
+ *
119
+ * @param setupCode - The setup code that was verified
120
+ * @param provider - The provider name
121
+ * @param config - The configuration to store (e.g., { chatId: 123456789 })
122
+ * @returns Result indicating success or failure
123
+ */
124
+ async completeSetup(setupCode, provider, config) {
125
+ // First verify the setup code
126
+ const pendingSetup = await this.verifySetup(setupCode, provider);
127
+ if (!pendingSetup) {
128
+ return {
129
+ success: false,
130
+ error: 'Invalid or expired setup code'
131
+ };
132
+ }
133
+ const { userId } = pendingSetup;
134
+ const pendingProvider = this.getPendingProviderName(provider);
135
+ try {
136
+ // Store the completed setup as a token for the actual provider
137
+ // This makes it accessible via hasValidTokens() and getTokensByUserId()
138
+ // Use far-future expiry for direct auth configs (10 years)
139
+ const farFutureExpiry = new Date(Date.now() + 10 * 365 * 24 * 60 * 60 * 1000);
140
+ await this.storage.saveToken({
141
+ provider: provider,
142
+ userId: userId,
143
+ email: `${userId}@dain.local`,
144
+ token: {
145
+ accessToken: 'direct_auth_configured',
146
+ expiresAt: farFutureExpiry,
147
+ tokenType: 'configured'
148
+ },
149
+ metadata: {
150
+ ...config,
151
+ configuredAt: Date.now(),
152
+ setupCode: setupCode.substring(0, 8) + '...' // Store partial code for debugging
153
+ }
154
+ });
155
+ // Delete the pending setup
156
+ await this.storage.deleteTokenByProviderEmail(pendingProvider, `${userId}@dain.local`);
157
+ console.log(`[DirectAuthSetupManager] Completed setup for user ${userId}, provider ${provider}`);
158
+ return {
159
+ success: true,
160
+ userId
161
+ };
162
+ }
163
+ catch (error) {
164
+ console.error(`[DirectAuthSetupManager] Error completing setup:`, error);
165
+ return {
166
+ success: false,
167
+ error: error.message || 'Failed to complete setup'
168
+ };
169
+ }
170
+ }
171
+ /**
172
+ * Check if a user has completed setup for a provider
173
+ *
174
+ * @param userId - The user ID
175
+ * @param provider - The provider name
176
+ * @returns True if setup is complete
177
+ */
178
+ async isSetupComplete(userId, provider) {
179
+ try {
180
+ const tokens = await this.storage.queryTokens({
181
+ userId: userId,
182
+ provider: provider
183
+ });
184
+ return tokens.length > 0;
185
+ }
186
+ catch (error) {
187
+ console.error(`[DirectAuthSetupManager] Error checking setup status:`, error);
188
+ return false;
189
+ }
190
+ }
191
+ /**
192
+ * Get the stored configuration for a user and provider
193
+ *
194
+ * @param userId - The user ID
195
+ * @param provider - The provider name
196
+ * @returns The stored config or null if not found
197
+ */
198
+ async getProviderConfig(userId, provider) {
199
+ try {
200
+ const tokens = await this.storage.queryTokens({
201
+ userId: userId,
202
+ provider: provider
203
+ });
204
+ if (!tokens || tokens.length === 0) {
205
+ return null;
206
+ }
207
+ return tokens[0].metadata;
208
+ }
209
+ catch (error) {
210
+ console.error(`[DirectAuthSetupManager] Error getting provider config:`, error);
211
+ return null;
212
+ }
213
+ }
214
+ /**
215
+ * Delete provider configuration for a user
216
+ * Used when user wants to disconnect/revoke access
217
+ *
218
+ * @param userId - The user ID
219
+ * @param provider - The provider name
220
+ * @returns True if deleted successfully
221
+ */
222
+ async deleteProviderConfig(userId, provider) {
223
+ try {
224
+ await this.storage.deleteTokenByProviderEmail(provider, `${userId}@dain.local`);
225
+ console.log(`[DirectAuthSetupManager] Deleted config for user ${userId}, provider ${provider}`);
226
+ return true;
227
+ }
228
+ catch (error) {
229
+ console.error(`[DirectAuthSetupManager] Error deleting config:`, error);
230
+ return false;
231
+ }
232
+ }
233
+ /**
234
+ * Get pending setup status for a user
235
+ * Useful for showing setup progress in UI
236
+ *
237
+ * @param userId - The user ID
238
+ * @param provider - The provider name
239
+ * @returns Pending setup info if exists, null otherwise
240
+ */
241
+ async getPendingSetup(userId, provider) {
242
+ const pendingProvider = this.getPendingProviderName(provider);
243
+ try {
244
+ // We need to search by the actual user ID in email/metadata
245
+ // This is less efficient but necessary since we store by setup code
246
+ const allTokens = await this.storage.queryTokens({
247
+ provider: pendingProvider
248
+ });
249
+ for (const token of allTokens) {
250
+ const metadata = token.metadata;
251
+ if (metadata?.originalUserId === userId) {
252
+ const expiresAt = metadata?.expiresAt || 0;
253
+ // Check expiry
254
+ if (Date.now() > expiresAt) {
255
+ // Clean up expired token
256
+ await this.storage.deleteTokenByProviderEmail(pendingProvider, `${userId}@dain.local`);
257
+ return null;
258
+ }
259
+ return {
260
+ setupCode: token.userId,
261
+ userId: metadata.originalUserId,
262
+ provider: metadata.provider,
263
+ expiresAt
264
+ };
265
+ }
266
+ }
267
+ return null;
268
+ }
269
+ catch (error) {
270
+ console.error(`[DirectAuthSetupManager] Error getting pending setup:`, error);
271
+ return null;
272
+ }
273
+ }
274
+ /**
275
+ * Cleanup expired pending setups
276
+ * Should be called periodically to prevent stale data accumulation
277
+ *
278
+ * @param provider - The provider name to clean up
279
+ * @returns Number of expired setups cleaned up
280
+ */
281
+ async cleanupExpiredSetups(provider) {
282
+ const pendingProvider = this.getPendingProviderName(provider);
283
+ let cleanedUp = 0;
284
+ try {
285
+ const allTokens = await this.storage.queryTokens({
286
+ provider: pendingProvider
287
+ });
288
+ for (const token of allTokens) {
289
+ const metadata = token.metadata;
290
+ const expiresAt = metadata?.expiresAt || 0;
291
+ if (Date.now() > expiresAt) {
292
+ await this.storage.deleteTokenByProviderEmail(pendingProvider, token.email || `${metadata?.originalUserId}@dain.local`);
293
+ cleanedUp++;
294
+ }
295
+ }
296
+ if (cleanedUp > 0) {
297
+ console.log(`[DirectAuthSetupManager] Cleaned up ${cleanedUp} expired ${provider} setups`);
298
+ }
299
+ return cleanedUp;
300
+ }
301
+ catch (error) {
302
+ console.error(`[DirectAuthSetupManager] Error cleaning up expired setups:`, error);
303
+ return 0;
304
+ }
305
+ }
306
+ }
307
+ exports.DirectAuthSetupManager = DirectAuthSetupManager;
308
+ //# sourceMappingURL=direct-auth-setup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"direct-auth-setup.js","sourceRoot":"","sources":["../../src/service/direct-auth-setup.ts"],"names":[],"mappings":";AAAA,yCAAyC;;;AAGzC,mCAAqC;AA+DrC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,sBAAsB;IACzB,OAAO,CAAiB;IAEh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,CAAC;QACnB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,4DAA4D,EAAE,KAAK,CAAC,CAAC;YACnF,OAAO,CAAC,CAAC;QACX,CAAC;IACH,CAAC;CACF;AAlVD,wDAkVC"}
@@ -9,7 +9,9 @@ import { requireScope } from "./server";
9
9
  import { hasScope, hasAllScopes, hasAnyScope } from "./auth";
10
10
  import { WebhookTriggerRegistry, createWebhookTriggerRegistry, createSimpleTrigger, type WebhookTrigger, type WebhookTriggerDefinition, type WebhookProcessResult } from "./webhooks";
11
11
  import { HITLHandler, routeActionToService, type HITLConfig, type HITLResult } from "./hitl";
12
+ import { ActionableToolBaseSchema, ActionSchema, MetadataSchema, extendActionableSchema, buildActionableTool, validateActionableSchema, type ActionableToolInput, type Action, type AutomationMetadata } from "./actionable-tools";
13
+ import { DirectAuthSetupManager, type DirectAuthAdapter, type OnboardingUI, type PendingSetup, type SetupCompletionResult } from "./direct-auth-setup";
12
14
  export declare const defineDAINService: (config: DAINServiceConfig) => DAINService;
13
- export { defineNodeService, defineDenoService, defineCloudflareService, createNextDainService, createTool, createService, createToolbox, CoreUtils, createOAuth2Tool, createAgent, ProcessHandler, RedisProcessStore, MemoryProcessStore, requireScope, hasScope, hasAllScopes, hasAnyScope, WebhookTriggerRegistry, createWebhookTriggerRegistry, createSimpleTrigger, type WebhookTrigger, type WebhookTriggerDefinition, type WebhookProcessResult, HITLHandler, routeActionToService, type HITLConfig, type HITLResult, };
15
+ export { defineNodeService, defineDenoService, defineCloudflareService, createNextDainService, createTool, createService, createToolbox, CoreUtils, createOAuth2Tool, createAgent, ProcessHandler, RedisProcessStore, MemoryProcessStore, requireScope, hasScope, hasAllScopes, hasAnyScope, WebhookTriggerRegistry, createWebhookTriggerRegistry, createSimpleTrigger, type WebhookTrigger, type WebhookTriggerDefinition, type WebhookProcessResult, HITLHandler, routeActionToService, type HITLConfig, type HITLResult, ActionableToolBaseSchema, ActionSchema, MetadataSchema, extendActionableSchema, buildActionableTool, validateActionableSchema, type ActionableToolInput, type Action, type AutomationMetadata, DirectAuthSetupManager, type DirectAuthAdapter, type OnboardingUI, type PendingSetup, type SetupCompletionResult, };
14
16
  export * from './types';
15
17
  export * from './oauth2Store';
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  // File: src/service/index.ts
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.routeActionToService = exports.HITLHandler = exports.createSimpleTrigger = exports.createWebhookTriggerRegistry = exports.WebhookTriggerRegistry = exports.hasAnyScope = exports.hasAllScopes = exports.hasScope = exports.requireScope = exports.MemoryProcessStore = exports.RedisProcessStore = exports.ProcessHandler = exports.createAgent = exports.createOAuth2Tool = exports.CoreUtils = exports.createToolbox = exports.createService = exports.createTool = exports.createNextDainService = exports.defineCloudflareService = exports.defineDenoService = exports.defineNodeService = exports.defineDAINService = void 0;
4
+ exports.DirectAuthSetupManager = exports.validateActionableSchema = exports.buildActionableTool = exports.extendActionableSchema = exports.MetadataSchema = exports.ActionSchema = exports.ActionableToolBaseSchema = exports.routeActionToService = exports.HITLHandler = exports.createSimpleTrigger = exports.createWebhookTriggerRegistry = exports.WebhookTriggerRegistry = exports.hasAnyScope = exports.hasAllScopes = exports.hasScope = exports.requireScope = exports.MemoryProcessStore = exports.RedisProcessStore = exports.ProcessHandler = exports.createAgent = exports.createOAuth2Tool = exports.CoreUtils = exports.createToolbox = exports.createService = exports.createTool = exports.createNextDainService = exports.defineCloudflareService = exports.defineDenoService = exports.defineNodeService = exports.defineDAINService = void 0;
5
5
  const tslib_1 = require("tslib");
6
6
  const nodeService_1 = require("./nodeService");
7
7
  Object.defineProperty(exports, "defineNodeService", { enumerable: true, get: function () { return nodeService_1.defineDAINService; } });
@@ -35,6 +35,15 @@ Object.defineProperty(exports, "createSimpleTrigger", { enumerable: true, get: f
35
35
  const hitl_1 = require("./hitl");
36
36
  Object.defineProperty(exports, "HITLHandler", { enumerable: true, get: function () { return hitl_1.HITLHandler; } });
37
37
  Object.defineProperty(exports, "routeActionToService", { enumerable: true, get: function () { return hitl_1.routeActionToService; } });
38
+ const actionable_tools_1 = require("./actionable-tools");
39
+ Object.defineProperty(exports, "ActionableToolBaseSchema", { enumerable: true, get: function () { return actionable_tools_1.ActionableToolBaseSchema; } });
40
+ Object.defineProperty(exports, "ActionSchema", { enumerable: true, get: function () { return actionable_tools_1.ActionSchema; } });
41
+ Object.defineProperty(exports, "MetadataSchema", { enumerable: true, get: function () { return actionable_tools_1.MetadataSchema; } });
42
+ Object.defineProperty(exports, "extendActionableSchema", { enumerable: true, get: function () { return actionable_tools_1.extendActionableSchema; } });
43
+ Object.defineProperty(exports, "buildActionableTool", { enumerable: true, get: function () { return actionable_tools_1.buildActionableTool; } });
44
+ Object.defineProperty(exports, "validateActionableSchema", { enumerable: true, get: function () { return actionable_tools_1.validateActionableSchema; } });
45
+ const direct_auth_setup_1 = require("./direct-auth-setup");
46
+ Object.defineProperty(exports, "DirectAuthSetupManager", { enumerable: true, get: function () { return direct_auth_setup_1.DirectAuthSetupManager; } });
38
47
  const defineDAINService = (config) => {
39
48
  throw new Error("This is a fallback implementation. Use the appropriate runtime-specific import.");
40
49
  };