@insforge/mcp 1.2.4 → 1.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -201
- package/README.md +92 -92
- package/dist/{chunk-452MLCIR.js → chunk-FUYK7JVW.js} +929 -630
- package/dist/http-server.js +2 -2
- package/dist/index.js +12 -9
- package/mcp.json +7 -7
- package/package.json +57 -55
- package/server.json +17 -17
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/shared/tools.ts
|
|
4
|
-
import { z as
|
|
4
|
+
import { z as z23 } from "zod";
|
|
5
5
|
import fetch2 from "node-fetch";
|
|
6
6
|
import { promises as fs } from "fs";
|
|
7
7
|
import { exec } from "child_process";
|
|
8
8
|
import { promisify } from "util";
|
|
9
9
|
import { tmpdir } from "os";
|
|
10
|
+
import archiver from "archiver";
|
|
10
11
|
|
|
11
12
|
// src/shared/response-handler.ts
|
|
12
13
|
async function handleApiResponse(response) {
|
|
@@ -326,91 +327,136 @@ var databaseTriggersResponseSchema = z2.object({
|
|
|
326
327
|
triggers: z2.array(databaseTriggerSchema)
|
|
327
328
|
});
|
|
328
329
|
|
|
329
|
-
// node_modules/@insforge/shared-schemas/dist/
|
|
330
|
+
// node_modules/@insforge/shared-schemas/dist/secrets.schema.js
|
|
330
331
|
import { z as z3 } from "zod";
|
|
331
|
-
var
|
|
332
|
+
var secretSchema = z3.object({
|
|
333
|
+
id: z3.string(),
|
|
332
334
|
key: z3.string(),
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
var storageBucketSchema = z3.object({
|
|
340
|
-
name: z3.string(),
|
|
341
|
-
public: z3.boolean(),
|
|
342
|
-
createdAt: z3.string()
|
|
335
|
+
isActive: z3.boolean(),
|
|
336
|
+
isReserved: z3.boolean(),
|
|
337
|
+
lastUsedAt: z3.string().nullable(),
|
|
338
|
+
expiresAt: z3.string().nullable(),
|
|
339
|
+
createdAt: z3.string(),
|
|
340
|
+
updatedAt: z3.string()
|
|
343
341
|
});
|
|
344
342
|
|
|
345
|
-
// node_modules/@insforge/shared-schemas/dist/
|
|
343
|
+
// node_modules/@insforge/shared-schemas/dist/secrets-api.schema.js
|
|
346
344
|
import { z as z4 } from "zod";
|
|
347
|
-
var
|
|
348
|
-
|
|
349
|
-
isPublic: z4.boolean().default(true)
|
|
350
|
-
});
|
|
351
|
-
var updateBucketRequestSchema = z4.object({
|
|
352
|
-
isPublic: z4.boolean()
|
|
353
|
-
});
|
|
354
|
-
var listObjectsResponseSchema = z4.object({
|
|
355
|
-
objects: z4.array(storageFileSchema),
|
|
356
|
-
pagination: z4.object({
|
|
357
|
-
offset: z4.number(),
|
|
358
|
-
limit: z4.number(),
|
|
359
|
-
total: z4.number()
|
|
360
|
-
})
|
|
361
|
-
});
|
|
362
|
-
var uploadStrategyRequestSchema = z4.object({
|
|
363
|
-
filename: z4.string().min(1, "Filename cannot be empty"),
|
|
364
|
-
contentType: z4.string().optional(),
|
|
365
|
-
size: z4.number().optional()
|
|
345
|
+
var listSecretsResponseSchema = z4.object({
|
|
346
|
+
secrets: z4.array(secretSchema)
|
|
366
347
|
});
|
|
367
|
-
var
|
|
368
|
-
method: z4.enum(["presigned", "direct"]),
|
|
369
|
-
uploadUrl: z4.string(),
|
|
370
|
-
fields: z4.record(z4.string()).optional(),
|
|
348
|
+
var getSecretValueResponseSchema = z4.object({
|
|
371
349
|
key: z4.string(),
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
350
|
+
value: z4.string()
|
|
351
|
+
});
|
|
352
|
+
var createSecretRequestSchema = z4.object({
|
|
353
|
+
key: z4.string().regex(/^[A-Z0-9_]+$/, "Use uppercase letters, numbers, and underscores only"),
|
|
354
|
+
value: z4.string().min(1, "Value is required")
|
|
375
355
|
});
|
|
376
|
-
var
|
|
377
|
-
|
|
356
|
+
var createSecretResponseSchema = z4.object({
|
|
357
|
+
success: z4.literal(true),
|
|
358
|
+
message: z4.string(),
|
|
359
|
+
id: z4.string()
|
|
378
360
|
});
|
|
379
|
-
var
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
expiresAt: z4.date().optional(),
|
|
383
|
-
headers: z4.record(z4.string()).optional()
|
|
361
|
+
var updateSecretResponseSchema = z4.object({
|
|
362
|
+
success: z4.literal(true),
|
|
363
|
+
message: z4.string()
|
|
384
364
|
});
|
|
385
|
-
var
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
etag: z4.string().optional()
|
|
365
|
+
var deleteSecretResponseSchema = z4.object({
|
|
366
|
+
success: z4.literal(true),
|
|
367
|
+
message: z4.string()
|
|
389
368
|
});
|
|
390
369
|
|
|
391
|
-
// node_modules/@insforge/shared-schemas/dist/
|
|
370
|
+
// node_modules/@insforge/shared-schemas/dist/storage.schema.js
|
|
392
371
|
import { z as z5 } from "zod";
|
|
393
|
-
var
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
372
|
+
var storageFileSchema = z5.object({
|
|
373
|
+
key: z5.string(),
|
|
374
|
+
bucket: z5.string(),
|
|
375
|
+
size: z5.number(),
|
|
376
|
+
mimeType: z5.string().optional(),
|
|
377
|
+
uploadedAt: z5.string(),
|
|
378
|
+
url: z5.string()
|
|
379
|
+
});
|
|
380
|
+
var storageBucketSchema = z5.object({
|
|
381
|
+
name: z5.string(),
|
|
382
|
+
public: z5.boolean(),
|
|
383
|
+
createdAt: z5.string()
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
// node_modules/@insforge/shared-schemas/dist/storage-api.schema.js
|
|
387
|
+
import { z as z6 } from "zod";
|
|
388
|
+
var createBucketRequestSchema = z6.object({
|
|
389
|
+
bucketName: z6.string().min(1, "Bucket name cannot be empty"),
|
|
390
|
+
isPublic: z6.boolean().default(true)
|
|
391
|
+
});
|
|
392
|
+
var updateBucketRequestSchema = z6.object({
|
|
393
|
+
isPublic: z6.boolean()
|
|
394
|
+
});
|
|
395
|
+
var listObjectsResponseSchema = z6.object({
|
|
396
|
+
objects: z6.array(storageFileSchema),
|
|
397
|
+
pagination: z6.object({
|
|
398
|
+
offset: z6.number(),
|
|
399
|
+
limit: z6.number(),
|
|
400
|
+
total: z6.number()
|
|
401
|
+
})
|
|
402
|
+
});
|
|
403
|
+
var uploadStrategyRequestSchema = z6.object({
|
|
404
|
+
filename: z6.string().min(1, "Filename cannot be empty"),
|
|
405
|
+
contentType: z6.string().optional(),
|
|
406
|
+
size: z6.number().optional()
|
|
407
|
+
});
|
|
408
|
+
var uploadStrategyResponseSchema = z6.object({
|
|
409
|
+
method: z6.enum(["presigned", "direct"]),
|
|
410
|
+
uploadUrl: z6.string(),
|
|
411
|
+
fields: z6.record(z6.string()).optional(),
|
|
412
|
+
key: z6.string(),
|
|
413
|
+
confirmRequired: z6.boolean(),
|
|
414
|
+
confirmUrl: z6.string().optional(),
|
|
415
|
+
expiresAt: z6.date().optional()
|
|
416
|
+
});
|
|
417
|
+
var downloadStrategyRequestSchema = z6.object({
|
|
418
|
+
expiresIn: z6.number().optional().default(3600)
|
|
419
|
+
});
|
|
420
|
+
var downloadStrategyResponseSchema = z6.object({
|
|
421
|
+
method: z6.enum(["presigned", "direct"]),
|
|
422
|
+
url: z6.string(),
|
|
423
|
+
expiresAt: z6.date().optional(),
|
|
424
|
+
headers: z6.record(z6.string()).optional()
|
|
425
|
+
});
|
|
426
|
+
var confirmUploadRequestSchema = z6.object({
|
|
427
|
+
size: z6.number(),
|
|
428
|
+
contentType: z6.string().optional(),
|
|
429
|
+
etag: z6.string().optional()
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
// node_modules/@insforge/shared-schemas/dist/auth.schema.js
|
|
433
|
+
import { z as z7 } from "zod";
|
|
434
|
+
var userIdSchema = z7.string().uuid("Invalid user ID format");
|
|
435
|
+
var emailSchema = z7.string().email("Invalid email format").toLowerCase().trim();
|
|
436
|
+
var passwordSchema = z7.string();
|
|
437
|
+
var nameSchema = z7.string().min(1, "Name is required").max(100, "Name must be less than 100 characters").trim();
|
|
438
|
+
var roleSchema = z7.enum(["anon", "authenticated", "project_admin"]);
|
|
439
|
+
var verificationMethodSchema = z7.enum(["code", "link"]);
|
|
440
|
+
var profileSchema = z7.object({
|
|
441
|
+
name: z7.string().optional(),
|
|
442
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
443
|
+
avatar_url: z7.string().url().optional()
|
|
444
|
+
}).passthrough();
|
|
445
|
+
var userSchema = z7.object({
|
|
400
446
|
id: userIdSchema,
|
|
401
447
|
email: emailSchema,
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
provider: z5.string()
|
|
406
|
-
})).optional(),
|
|
407
|
-
providerType: z5.string().optional(),
|
|
408
|
-
createdAt: z5.string(),
|
|
448
|
+
emailVerified: z7.boolean(),
|
|
449
|
+
providers: z7.array(z7.string()).optional(),
|
|
450
|
+
createdAt: z7.string(),
|
|
409
451
|
// PostgreSQL timestamp
|
|
410
|
-
updatedAt:
|
|
452
|
+
updatedAt: z7.string(),
|
|
411
453
|
// PostgreSQL timestamp
|
|
454
|
+
profile: profileSchema.nullable(),
|
|
455
|
+
// User profile data (name, avatar_url, bio, etc.)
|
|
456
|
+
metadata: z7.record(z7.unknown()).nullable()
|
|
457
|
+
// System metadata (device ID, login IP, etc.)
|
|
412
458
|
});
|
|
413
|
-
var oAuthProvidersSchema =
|
|
459
|
+
var oAuthProvidersSchema = z7.enum([
|
|
414
460
|
"google",
|
|
415
461
|
"github",
|
|
416
462
|
"discord",
|
|
@@ -423,144 +469,155 @@ var oAuthProvidersSchema = z5.enum([
|
|
|
423
469
|
"spotify",
|
|
424
470
|
"microsoft"
|
|
425
471
|
]);
|
|
426
|
-
var oAuthStateSchema =
|
|
472
|
+
var oAuthStateSchema = z7.object({
|
|
427
473
|
provider: oAuthProvidersSchema,
|
|
428
|
-
redirectUri:
|
|
474
|
+
redirectUri: z7.string().url().optional()
|
|
429
475
|
});
|
|
430
|
-
var oAuthConfigSchema =
|
|
431
|
-
id:
|
|
476
|
+
var oAuthConfigSchema = z7.object({
|
|
477
|
+
id: z7.string().uuid(),
|
|
432
478
|
provider: oAuthProvidersSchema,
|
|
433
|
-
clientId:
|
|
434
|
-
scopes:
|
|
435
|
-
redirectUri:
|
|
436
|
-
useSharedKey:
|
|
437
|
-
createdAt:
|
|
479
|
+
clientId: z7.string().optional(),
|
|
480
|
+
scopes: z7.array(z7.string()).optional(),
|
|
481
|
+
redirectUri: z7.string().optional(),
|
|
482
|
+
useSharedKey: z7.boolean(),
|
|
483
|
+
createdAt: z7.string(),
|
|
438
484
|
// PostgreSQL timestamp
|
|
439
|
-
updatedAt:
|
|
485
|
+
updatedAt: z7.string()
|
|
440
486
|
// PostgreSQL timestamp
|
|
441
487
|
});
|
|
442
|
-
var authConfigSchema =
|
|
443
|
-
id:
|
|
444
|
-
requireEmailVerification:
|
|
445
|
-
passwordMinLength:
|
|
446
|
-
requireNumber:
|
|
447
|
-
requireLowercase:
|
|
448
|
-
requireUppercase:
|
|
449
|
-
requireSpecialChar:
|
|
488
|
+
var authConfigSchema = z7.object({
|
|
489
|
+
id: z7.string().uuid(),
|
|
490
|
+
requireEmailVerification: z7.boolean(),
|
|
491
|
+
passwordMinLength: z7.number().min(4).max(128),
|
|
492
|
+
requireNumber: z7.boolean(),
|
|
493
|
+
requireLowercase: z7.boolean(),
|
|
494
|
+
requireUppercase: z7.boolean(),
|
|
495
|
+
requireSpecialChar: z7.boolean(),
|
|
450
496
|
verifyEmailMethod: verificationMethodSchema,
|
|
451
497
|
resetPasswordMethod: verificationMethodSchema,
|
|
452
|
-
signInRedirectTo:
|
|
453
|
-
createdAt:
|
|
498
|
+
signInRedirectTo: z7.union([z7.string().url(), z7.literal(""), z7.null()]).optional().transform((val) => val === "" ? null : val),
|
|
499
|
+
createdAt: z7.string(),
|
|
454
500
|
// PostgreSQL timestamp
|
|
455
|
-
updatedAt:
|
|
501
|
+
updatedAt: z7.string()
|
|
456
502
|
// PostgreSQL timestamp
|
|
457
503
|
});
|
|
458
|
-
var tokenPayloadSchema =
|
|
504
|
+
var tokenPayloadSchema = z7.object({
|
|
459
505
|
sub: userIdSchema,
|
|
460
506
|
// Subject (user ID)
|
|
461
507
|
email: emailSchema,
|
|
462
508
|
role: roleSchema,
|
|
463
|
-
iat:
|
|
509
|
+
iat: z7.number().optional(),
|
|
464
510
|
// Issued at
|
|
465
|
-
exp:
|
|
511
|
+
exp: z7.number().optional()
|
|
466
512
|
// Expiration
|
|
467
513
|
});
|
|
468
514
|
|
|
469
515
|
// node_modules/@insforge/shared-schemas/dist/auth-api.schema.js
|
|
470
|
-
import { z as
|
|
471
|
-
var paginationSchema =
|
|
472
|
-
limit:
|
|
473
|
-
offset:
|
|
516
|
+
import { z as z8 } from "zod";
|
|
517
|
+
var paginationSchema = z8.object({
|
|
518
|
+
limit: z8.string().optional(),
|
|
519
|
+
offset: z8.string().optional()
|
|
474
520
|
});
|
|
475
|
-
var createUserRequestSchema =
|
|
521
|
+
var createUserRequestSchema = z8.object({
|
|
476
522
|
email: emailSchema,
|
|
477
523
|
password: passwordSchema,
|
|
478
524
|
name: nameSchema.optional()
|
|
479
525
|
});
|
|
480
|
-
var createSessionRequestSchema =
|
|
526
|
+
var createSessionRequestSchema = z8.object({
|
|
481
527
|
email: emailSchema,
|
|
482
528
|
password: passwordSchema
|
|
483
529
|
});
|
|
484
|
-
var exchangeAdminSessionRequestSchema =
|
|
485
|
-
code:
|
|
530
|
+
var exchangeAdminSessionRequestSchema = z8.object({
|
|
531
|
+
code: z8.string()
|
|
486
532
|
});
|
|
487
533
|
var listUsersRequestSchema = paginationSchema.extend({
|
|
488
|
-
search:
|
|
534
|
+
search: z8.string().optional()
|
|
489
535
|
}).optional();
|
|
490
|
-
var deleteUsersRequestSchema =
|
|
491
|
-
userIds:
|
|
536
|
+
var deleteUsersRequestSchema = z8.object({
|
|
537
|
+
userIds: z8.array(userIdSchema).min(1, "At least one user ID is required")
|
|
538
|
+
});
|
|
539
|
+
var updateProfileRequestSchema = z8.object({
|
|
540
|
+
profile: z8.record(z8.unknown())
|
|
492
541
|
});
|
|
493
|
-
var sendVerificationEmailRequestSchema =
|
|
542
|
+
var sendVerificationEmailRequestSchema = z8.object({
|
|
494
543
|
email: emailSchema
|
|
495
544
|
});
|
|
496
|
-
var verifyEmailRequestSchema =
|
|
545
|
+
var verifyEmailRequestSchema = z8.object({
|
|
497
546
|
email: emailSchema.optional(),
|
|
498
|
-
otp:
|
|
547
|
+
otp: z8.string().min(1)
|
|
499
548
|
}).refine((data) => data.email || data.otp, {
|
|
500
549
|
message: "Either email or otp must be provided"
|
|
501
550
|
});
|
|
502
|
-
var sendResetPasswordEmailRequestSchema =
|
|
551
|
+
var sendResetPasswordEmailRequestSchema = z8.object({
|
|
503
552
|
email: emailSchema
|
|
504
553
|
});
|
|
505
|
-
var exchangeResetPasswordTokenRequestSchema =
|
|
554
|
+
var exchangeResetPasswordTokenRequestSchema = z8.object({
|
|
506
555
|
email: emailSchema,
|
|
507
|
-
code:
|
|
556
|
+
code: z8.string().min(1)
|
|
508
557
|
});
|
|
509
|
-
var resetPasswordRequestSchema =
|
|
558
|
+
var resetPasswordRequestSchema = z8.object({
|
|
510
559
|
newPassword: passwordSchema,
|
|
511
|
-
otp:
|
|
560
|
+
otp: z8.string().min(1, "OTP/token is required")
|
|
512
561
|
});
|
|
513
|
-
var createUserResponseSchema =
|
|
562
|
+
var createUserResponseSchema = z8.object({
|
|
514
563
|
user: userSchema.optional(),
|
|
515
|
-
accessToken:
|
|
516
|
-
requireEmailVerification:
|
|
517
|
-
redirectTo:
|
|
564
|
+
accessToken: z8.string().nullable(),
|
|
565
|
+
requireEmailVerification: z8.boolean().optional(),
|
|
566
|
+
redirectTo: z8.string().url().optional(),
|
|
567
|
+
csrfToken: z8.string().nullable().optional()
|
|
518
568
|
});
|
|
519
|
-
var createSessionResponseSchema =
|
|
569
|
+
var createSessionResponseSchema = z8.object({
|
|
520
570
|
user: userSchema,
|
|
521
|
-
accessToken:
|
|
522
|
-
redirectTo:
|
|
571
|
+
accessToken: z8.string(),
|
|
572
|
+
redirectTo: z8.string().url().optional(),
|
|
573
|
+
csrfToken: z8.string().nullable().optional()
|
|
523
574
|
});
|
|
524
|
-
var verifyEmailResponseSchema =
|
|
575
|
+
var verifyEmailResponseSchema = z8.object({
|
|
525
576
|
user: userSchema,
|
|
526
|
-
accessToken:
|
|
527
|
-
redirectTo:
|
|
577
|
+
accessToken: z8.string(),
|
|
578
|
+
redirectTo: z8.string().url().optional(),
|
|
579
|
+
csrfToken: z8.string().nullable().optional()
|
|
528
580
|
});
|
|
529
|
-
var
|
|
530
|
-
|
|
531
|
-
|
|
581
|
+
var refreshSessionResponseSchema = z8.object({
|
|
582
|
+
accessToken: z8.string(),
|
|
583
|
+
user: userSchema,
|
|
584
|
+
csrfToken: z8.string()
|
|
532
585
|
});
|
|
533
|
-
var
|
|
534
|
-
|
|
586
|
+
var exchangeResetPasswordTokenResponseSchema = z8.object({
|
|
587
|
+
token: z8.string(),
|
|
588
|
+
expiresAt: z8.string().datetime()
|
|
535
589
|
});
|
|
536
|
-
var
|
|
537
|
-
|
|
538
|
-
id: userIdSchema,
|
|
539
|
-
email: emailSchema,
|
|
540
|
-
role: roleSchema
|
|
541
|
-
})
|
|
590
|
+
var resetPasswordResponseSchema = z8.object({
|
|
591
|
+
message: z8.string()
|
|
542
592
|
});
|
|
543
|
-
var
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
593
|
+
var getCurrentSessionResponseSchema = z8.object({
|
|
594
|
+
user: userSchema
|
|
595
|
+
});
|
|
596
|
+
var getProfileResponseSchema = z8.object({
|
|
597
|
+
id: userIdSchema,
|
|
598
|
+
profile: profileSchema.nullable()
|
|
599
|
+
});
|
|
600
|
+
var listUsersResponseSchema = z8.object({
|
|
601
|
+
data: z8.array(userSchema),
|
|
602
|
+
pagination: z8.object({
|
|
603
|
+
offset: z8.number(),
|
|
604
|
+
limit: z8.number(),
|
|
605
|
+
total: z8.number()
|
|
549
606
|
})
|
|
550
607
|
});
|
|
551
|
-
var deleteUsersResponseSchema =
|
|
552
|
-
message:
|
|
553
|
-
deletedCount:
|
|
608
|
+
var deleteUsersResponseSchema = z8.object({
|
|
609
|
+
message: z8.string(),
|
|
610
|
+
deletedCount: z8.number().int().nonnegative()
|
|
554
611
|
});
|
|
555
|
-
var getOauthUrlResponseSchema =
|
|
556
|
-
authUrl:
|
|
612
|
+
var getOauthUrlResponseSchema = z8.object({
|
|
613
|
+
authUrl: z8.string().url()
|
|
557
614
|
});
|
|
558
615
|
var createOAuthConfigRequestSchema = oAuthConfigSchema.omit({
|
|
559
616
|
id: true,
|
|
560
617
|
createdAt: true,
|
|
561
618
|
updatedAt: true
|
|
562
619
|
}).extend({
|
|
563
|
-
clientSecret:
|
|
620
|
+
clientSecret: z8.string().optional()
|
|
564
621
|
});
|
|
565
622
|
var updateOAuthConfigRequestSchema = oAuthConfigSchema.omit({
|
|
566
623
|
id: true,
|
|
@@ -568,19 +625,19 @@ var updateOAuthConfigRequestSchema = oAuthConfigSchema.omit({
|
|
|
568
625
|
createdAt: true,
|
|
569
626
|
updatedAt: true
|
|
570
627
|
}).extend({
|
|
571
|
-
clientSecret:
|
|
628
|
+
clientSecret: z8.string().optional()
|
|
572
629
|
}).partial();
|
|
573
|
-
var listOAuthConfigsResponseSchema =
|
|
574
|
-
data:
|
|
575
|
-
count:
|
|
630
|
+
var listOAuthConfigsResponseSchema = z8.object({
|
|
631
|
+
data: z8.array(oAuthConfigSchema),
|
|
632
|
+
count: z8.number()
|
|
576
633
|
});
|
|
577
634
|
var updateAuthConfigRequestSchema = authConfigSchema.omit({
|
|
578
635
|
id: true,
|
|
579
636
|
createdAt: true,
|
|
580
637
|
updatedAt: true
|
|
581
638
|
}).partial();
|
|
582
|
-
var getPublicAuthConfigResponseSchema =
|
|
583
|
-
oAuthProviders:
|
|
639
|
+
var getPublicAuthConfigResponseSchema = z8.object({
|
|
640
|
+
oAuthProviders: z8.array(oAuthProvidersSchema),
|
|
584
641
|
...authConfigSchema.omit({
|
|
585
642
|
id: true,
|
|
586
643
|
updatedAt: true,
|
|
@@ -588,465 +645,503 @@ var getPublicAuthConfigResponseSchema = z6.object({
|
|
|
588
645
|
signInRedirectTo: true
|
|
589
646
|
}).shape
|
|
590
647
|
});
|
|
591
|
-
var authErrorResponseSchema =
|
|
592
|
-
error:
|
|
593
|
-
message:
|
|
594
|
-
statusCode:
|
|
595
|
-
nextActions:
|
|
648
|
+
var authErrorResponseSchema = z8.object({
|
|
649
|
+
error: z8.string(),
|
|
650
|
+
message: z8.string(),
|
|
651
|
+
statusCode: z8.number().int(),
|
|
652
|
+
nextActions: z8.string().optional()
|
|
596
653
|
});
|
|
597
654
|
|
|
598
655
|
// node_modules/@insforge/shared-schemas/dist/metadata.schema.js
|
|
599
|
-
import { z as
|
|
656
|
+
import { z as z11 } from "zod";
|
|
600
657
|
|
|
601
658
|
// node_modules/@insforge/shared-schemas/dist/realtime.schema.js
|
|
602
|
-
import { z as
|
|
603
|
-
var senderTypeSchema =
|
|
604
|
-
var realtimeChannelSchema =
|
|
605
|
-
id:
|
|
606
|
-
pattern:
|
|
607
|
-
description:
|
|
608
|
-
webhookUrls:
|
|
609
|
-
enabled:
|
|
610
|
-
createdAt:
|
|
611
|
-
updatedAt:
|
|
612
|
-
});
|
|
613
|
-
var realtimeMessageSchema =
|
|
614
|
-
id:
|
|
615
|
-
eventName:
|
|
616
|
-
channelId:
|
|
617
|
-
channelName:
|
|
618
|
-
payload:
|
|
659
|
+
import { z as z9 } from "zod";
|
|
660
|
+
var senderTypeSchema = z9.enum(["system", "user"]);
|
|
661
|
+
var realtimeChannelSchema = z9.object({
|
|
662
|
+
id: z9.string().uuid(),
|
|
663
|
+
pattern: z9.string().min(1),
|
|
664
|
+
description: z9.string().nullable(),
|
|
665
|
+
webhookUrls: z9.array(z9.string().url()).nullable(),
|
|
666
|
+
enabled: z9.boolean(),
|
|
667
|
+
createdAt: z9.string().datetime(),
|
|
668
|
+
updatedAt: z9.string().datetime()
|
|
669
|
+
});
|
|
670
|
+
var realtimeMessageSchema = z9.object({
|
|
671
|
+
id: z9.string().uuid(),
|
|
672
|
+
eventName: z9.string().min(1),
|
|
673
|
+
channelId: z9.string().uuid().nullable(),
|
|
674
|
+
channelName: z9.string().min(1),
|
|
675
|
+
payload: z9.record(z9.string(), z9.unknown()),
|
|
619
676
|
senderType: senderTypeSchema,
|
|
620
|
-
senderId:
|
|
621
|
-
wsAudienceCount:
|
|
622
|
-
whAudienceCount:
|
|
623
|
-
whDeliveredCount:
|
|
624
|
-
createdAt:
|
|
625
|
-
});
|
|
626
|
-
var subscribeChannelPayloadSchema =
|
|
627
|
-
channel:
|
|
677
|
+
senderId: z9.string().uuid().nullable(),
|
|
678
|
+
wsAudienceCount: z9.number().int().min(0),
|
|
679
|
+
whAudienceCount: z9.number().int().min(0),
|
|
680
|
+
whDeliveredCount: z9.number().int().min(0),
|
|
681
|
+
createdAt: z9.string().datetime()
|
|
682
|
+
});
|
|
683
|
+
var subscribeChannelPayloadSchema = z9.object({
|
|
684
|
+
channel: z9.string().min(1)
|
|
628
685
|
// The resolved channel instance, e.g., "order:123"
|
|
629
686
|
});
|
|
630
|
-
var unsubscribeChannelPayloadSchema =
|
|
631
|
-
channel:
|
|
687
|
+
var unsubscribeChannelPayloadSchema = z9.object({
|
|
688
|
+
channel: z9.string().min(1)
|
|
632
689
|
// The resolved channel instance, e.g., "order:123"
|
|
633
690
|
});
|
|
634
|
-
var publishEventPayloadSchema =
|
|
635
|
-
channel:
|
|
636
|
-
event:
|
|
637
|
-
payload:
|
|
691
|
+
var publishEventPayloadSchema = z9.object({
|
|
692
|
+
channel: z9.string().min(1),
|
|
693
|
+
event: z9.string().min(1),
|
|
694
|
+
payload: z9.record(z9.string(), z9.unknown())
|
|
638
695
|
});
|
|
639
|
-
var subscribeResponseSchema =
|
|
640
|
-
|
|
641
|
-
ok:
|
|
642
|
-
channel:
|
|
696
|
+
var subscribeResponseSchema = z9.discriminatedUnion("ok", [
|
|
697
|
+
z9.object({
|
|
698
|
+
ok: z9.literal(true),
|
|
699
|
+
channel: z9.string().min(1)
|
|
643
700
|
}),
|
|
644
|
-
|
|
645
|
-
ok:
|
|
646
|
-
channel:
|
|
647
|
-
error:
|
|
648
|
-
code:
|
|
649
|
-
message:
|
|
701
|
+
z9.object({
|
|
702
|
+
ok: z9.literal(false),
|
|
703
|
+
channel: z9.string().min(1),
|
|
704
|
+
error: z9.object({
|
|
705
|
+
code: z9.string().min(1),
|
|
706
|
+
message: z9.string().min(1)
|
|
650
707
|
})
|
|
651
708
|
})
|
|
652
709
|
]);
|
|
653
|
-
var realtimeErrorPayloadSchema =
|
|
654
|
-
channel:
|
|
655
|
-
code:
|
|
656
|
-
message:
|
|
657
|
-
});
|
|
658
|
-
var webhookMessageSchema =
|
|
659
|
-
messageId:
|
|
660
|
-
channel:
|
|
661
|
-
eventName:
|
|
662
|
-
payload:
|
|
663
|
-
});
|
|
664
|
-
var socketMessageMetaSchema =
|
|
665
|
-
channel:
|
|
710
|
+
var realtimeErrorPayloadSchema = z9.object({
|
|
711
|
+
channel: z9.string().optional(),
|
|
712
|
+
code: z9.string().min(1),
|
|
713
|
+
message: z9.string().min(1)
|
|
714
|
+
});
|
|
715
|
+
var webhookMessageSchema = z9.object({
|
|
716
|
+
messageId: z9.string().uuid(),
|
|
717
|
+
channel: z9.string().min(1),
|
|
718
|
+
eventName: z9.string().min(1),
|
|
719
|
+
payload: z9.record(z9.string(), z9.unknown())
|
|
720
|
+
});
|
|
721
|
+
var socketMessageMetaSchema = z9.object({
|
|
722
|
+
channel: z9.string().optional(),
|
|
666
723
|
// Present for room broadcasts
|
|
667
|
-
messageId:
|
|
724
|
+
messageId: z9.string().uuid(),
|
|
668
725
|
senderType: senderTypeSchema,
|
|
669
|
-
senderId:
|
|
670
|
-
timestamp:
|
|
726
|
+
senderId: z9.string().uuid().optional(),
|
|
727
|
+
timestamp: z9.string().datetime()
|
|
671
728
|
});
|
|
672
|
-
var socketMessageSchema =
|
|
729
|
+
var socketMessageSchema = z9.object({
|
|
673
730
|
meta: socketMessageMetaSchema
|
|
674
731
|
}).passthrough();
|
|
675
732
|
|
|
676
733
|
// node_modules/@insforge/shared-schemas/dist/realtime-api.schema.js
|
|
677
|
-
import { z as
|
|
678
|
-
var createChannelRequestSchema =
|
|
679
|
-
pattern:
|
|
680
|
-
description:
|
|
681
|
-
webhookUrls:
|
|
682
|
-
enabled:
|
|
683
|
-
});
|
|
684
|
-
var updateChannelRequestSchema =
|
|
685
|
-
pattern:
|
|
686
|
-
description:
|
|
687
|
-
webhookUrls:
|
|
688
|
-
enabled:
|
|
689
|
-
});
|
|
690
|
-
var listChannelsResponseSchema =
|
|
691
|
-
var deleteChannelResponseSchema =
|
|
692
|
-
message:
|
|
693
|
-
});
|
|
694
|
-
var listMessagesRequestSchema =
|
|
695
|
-
channelId:
|
|
696
|
-
eventName:
|
|
697
|
-
limit:
|
|
698
|
-
offset:
|
|
699
|
-
});
|
|
700
|
-
var listMessagesResponseSchema =
|
|
701
|
-
var messageStatsRequestSchema =
|
|
702
|
-
channelId:
|
|
703
|
-
since:
|
|
704
|
-
});
|
|
705
|
-
var messageStatsResponseSchema =
|
|
706
|
-
totalMessages:
|
|
707
|
-
whDeliveryRate:
|
|
708
|
-
topEvents:
|
|
709
|
-
eventName:
|
|
710
|
-
count:
|
|
734
|
+
import { z as z10 } from "zod";
|
|
735
|
+
var createChannelRequestSchema = z10.object({
|
|
736
|
+
pattern: z10.string().min(1, "Channel pattern is required"),
|
|
737
|
+
description: z10.string().optional(),
|
|
738
|
+
webhookUrls: z10.array(z10.string().url()).optional(),
|
|
739
|
+
enabled: z10.boolean().optional().default(true)
|
|
740
|
+
});
|
|
741
|
+
var updateChannelRequestSchema = z10.object({
|
|
742
|
+
pattern: z10.string().min(1).optional(),
|
|
743
|
+
description: z10.string().optional(),
|
|
744
|
+
webhookUrls: z10.array(z10.string().url()).optional(),
|
|
745
|
+
enabled: z10.boolean().optional()
|
|
746
|
+
});
|
|
747
|
+
var listChannelsResponseSchema = z10.array(realtimeChannelSchema);
|
|
748
|
+
var deleteChannelResponseSchema = z10.object({
|
|
749
|
+
message: z10.string()
|
|
750
|
+
});
|
|
751
|
+
var listMessagesRequestSchema = z10.object({
|
|
752
|
+
channelId: z10.string().uuid().optional(),
|
|
753
|
+
eventName: z10.string().optional(),
|
|
754
|
+
limit: z10.coerce.number().int().min(1).max(1e3).optional().default(100),
|
|
755
|
+
offset: z10.coerce.number().int().min(0).optional().default(0)
|
|
756
|
+
});
|
|
757
|
+
var listMessagesResponseSchema = z10.array(realtimeMessageSchema);
|
|
758
|
+
var messageStatsRequestSchema = z10.object({
|
|
759
|
+
channelId: z10.string().uuid().optional(),
|
|
760
|
+
since: z10.coerce.date().optional()
|
|
761
|
+
});
|
|
762
|
+
var messageStatsResponseSchema = z10.object({
|
|
763
|
+
totalMessages: z10.number().int().min(0),
|
|
764
|
+
whDeliveryRate: z10.number().min(0).max(1),
|
|
765
|
+
topEvents: z10.array(z10.object({
|
|
766
|
+
eventName: z10.string(),
|
|
767
|
+
count: z10.number().int().min(0)
|
|
711
768
|
}))
|
|
712
769
|
});
|
|
713
|
-
var rlsPolicySchema =
|
|
714
|
-
policyName:
|
|
715
|
-
tableName:
|
|
716
|
-
command:
|
|
717
|
-
roles:
|
|
718
|
-
using:
|
|
719
|
-
withCheck:
|
|
720
|
-
});
|
|
721
|
-
var realtimePermissionsResponseSchema =
|
|
722
|
-
subscribe:
|
|
723
|
-
policies:
|
|
770
|
+
var rlsPolicySchema = z10.object({
|
|
771
|
+
policyName: z10.string(),
|
|
772
|
+
tableName: z10.string(),
|
|
773
|
+
command: z10.string(),
|
|
774
|
+
roles: z10.array(z10.string()),
|
|
775
|
+
using: z10.string().nullable(),
|
|
776
|
+
withCheck: z10.string().nullable()
|
|
777
|
+
});
|
|
778
|
+
var realtimePermissionsResponseSchema = z10.object({
|
|
779
|
+
subscribe: z10.object({
|
|
780
|
+
policies: z10.array(rlsPolicySchema)
|
|
724
781
|
}),
|
|
725
|
-
publish:
|
|
726
|
-
policies:
|
|
782
|
+
publish: z10.object({
|
|
783
|
+
policies: z10.array(rlsPolicySchema)
|
|
727
784
|
})
|
|
728
785
|
});
|
|
729
786
|
|
|
730
787
|
// node_modules/@insforge/shared-schemas/dist/metadata.schema.js
|
|
731
|
-
var authMetadataSchema =
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
tableName: z9.string(),
|
|
737
|
-
recordCount: z9.number()
|
|
788
|
+
var authMetadataSchema = getPublicAuthConfigResponseSchema;
|
|
789
|
+
var databaseMetadataSchema = z11.object({
|
|
790
|
+
tables: z11.array(z11.object({
|
|
791
|
+
tableName: z11.string(),
|
|
792
|
+
recordCount: z11.number()
|
|
738
793
|
})),
|
|
739
|
-
totalSizeInGB:
|
|
740
|
-
hint:
|
|
794
|
+
totalSizeInGB: z11.number(),
|
|
795
|
+
hint: z11.string().optional()
|
|
741
796
|
});
|
|
742
797
|
var bucketMetadataSchema = storageBucketSchema.extend({
|
|
743
|
-
objectCount:
|
|
744
|
-
});
|
|
745
|
-
var storageMetadataSchema =
|
|
746
|
-
buckets:
|
|
747
|
-
totalSizeInGB:
|
|
748
|
-
});
|
|
749
|
-
var edgeFunctionMetadataSchema =
|
|
750
|
-
slug:
|
|
751
|
-
name:
|
|
752
|
-
description:
|
|
753
|
-
status:
|
|
754
|
-
});
|
|
755
|
-
var aiMetadataSchema =
|
|
756
|
-
models:
|
|
757
|
-
inputModality:
|
|
758
|
-
outputModality:
|
|
759
|
-
modelId:
|
|
798
|
+
objectCount: z11.number().optional()
|
|
799
|
+
});
|
|
800
|
+
var storageMetadataSchema = z11.object({
|
|
801
|
+
buckets: z11.array(bucketMetadataSchema),
|
|
802
|
+
totalSizeInGB: z11.number()
|
|
803
|
+
});
|
|
804
|
+
var edgeFunctionMetadataSchema = z11.object({
|
|
805
|
+
slug: z11.string(),
|
|
806
|
+
name: z11.string(),
|
|
807
|
+
description: z11.string().nullable(),
|
|
808
|
+
status: z11.string()
|
|
809
|
+
});
|
|
810
|
+
var aiMetadataSchema = z11.object({
|
|
811
|
+
models: z11.array(z11.object({
|
|
812
|
+
inputModality: z11.array(z11.string()),
|
|
813
|
+
outputModality: z11.array(z11.string()),
|
|
814
|
+
modelId: z11.string()
|
|
760
815
|
}))
|
|
761
816
|
});
|
|
762
|
-
var realtimeMetadataSchema =
|
|
763
|
-
channels:
|
|
817
|
+
var realtimeMetadataSchema = z11.object({
|
|
818
|
+
channels: z11.array(realtimeChannelSchema),
|
|
764
819
|
permissions: realtimePermissionsResponseSchema
|
|
765
820
|
});
|
|
766
|
-
var appMetaDataSchema =
|
|
821
|
+
var appMetaDataSchema = z11.object({
|
|
767
822
|
auth: authMetadataSchema,
|
|
768
823
|
database: databaseMetadataSchema,
|
|
769
824
|
storage: storageMetadataSchema,
|
|
770
825
|
aiIntegration: aiMetadataSchema.optional(),
|
|
771
|
-
functions:
|
|
826
|
+
functions: z11.array(edgeFunctionMetadataSchema),
|
|
772
827
|
realtime: realtimeMetadataSchema.optional(),
|
|
773
|
-
version:
|
|
828
|
+
version: z11.string().optional()
|
|
829
|
+
});
|
|
830
|
+
var databaseConnectionParametersSchema = z11.object({
|
|
831
|
+
host: z11.string(),
|
|
832
|
+
port: z11.number(),
|
|
833
|
+
database: z11.string(),
|
|
834
|
+
user: z11.string(),
|
|
835
|
+
password: z11.string(),
|
|
836
|
+
sslmode: z11.string()
|
|
837
|
+
});
|
|
838
|
+
var databaseConnectionInfoSchema = z11.object({
|
|
839
|
+
connectionURL: z11.string(),
|
|
840
|
+
parameters: databaseConnectionParametersSchema
|
|
841
|
+
});
|
|
842
|
+
var databasePasswordInfoSchema = z11.object({
|
|
843
|
+
databasePassword: z11.string()
|
|
844
|
+
});
|
|
845
|
+
var apiKeyResponseSchema = z11.object({
|
|
846
|
+
apiKey: z11.string()
|
|
774
847
|
});
|
|
775
848
|
|
|
776
849
|
// node_modules/@insforge/shared-schemas/dist/ai.schema.js
|
|
777
|
-
import { z as
|
|
778
|
-
var modalitySchema =
|
|
779
|
-
var
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
850
|
+
import { z as z12 } from "zod";
|
|
851
|
+
var modalitySchema = z12.enum(["text", "image"]);
|
|
852
|
+
var aiConfigurationInputSchema = z12.object({
|
|
853
|
+
inputModality: z12.array(modalitySchema).min(1),
|
|
854
|
+
outputModality: z12.array(modalitySchema).min(1),
|
|
855
|
+
provider: z12.string(),
|
|
856
|
+
modelId: z12.string(),
|
|
857
|
+
systemPrompt: z12.string().optional()
|
|
858
|
+
});
|
|
859
|
+
var aiConfigurationSchema = aiConfigurationInputSchema.extend({
|
|
860
|
+
id: z12.string().uuid()
|
|
786
861
|
});
|
|
787
862
|
var aiConfigurationWithUsageSchema = aiConfigurationSchema.extend({
|
|
788
|
-
usageStats:
|
|
789
|
-
totalInputTokens:
|
|
790
|
-
totalOutputTokens:
|
|
791
|
-
totalTokens:
|
|
792
|
-
totalImageCount:
|
|
793
|
-
totalRequests:
|
|
863
|
+
usageStats: z12.object({
|
|
864
|
+
totalInputTokens: z12.number(),
|
|
865
|
+
totalOutputTokens: z12.number(),
|
|
866
|
+
totalTokens: z12.number(),
|
|
867
|
+
totalImageCount: z12.number(),
|
|
868
|
+
totalRequests: z12.number()
|
|
794
869
|
}).optional()
|
|
795
870
|
});
|
|
796
|
-
var aiUsageDataSchema =
|
|
797
|
-
configId:
|
|
798
|
-
inputTokens:
|
|
799
|
-
outputTokens:
|
|
800
|
-
imageCount:
|
|
801
|
-
imageResolution:
|
|
871
|
+
var aiUsageDataSchema = z12.object({
|
|
872
|
+
configId: z12.string().uuid(),
|
|
873
|
+
inputTokens: z12.number().int().optional(),
|
|
874
|
+
outputTokens: z12.number().int().optional(),
|
|
875
|
+
imageCount: z12.number().int().optional(),
|
|
876
|
+
imageResolution: z12.string().optional()
|
|
802
877
|
});
|
|
803
878
|
var aiUsageRecordSchema = aiUsageDataSchema.extend({
|
|
804
|
-
id:
|
|
805
|
-
createdAt:
|
|
806
|
-
modelId:
|
|
807
|
-
model:
|
|
808
|
-
provider:
|
|
809
|
-
inputModality:
|
|
810
|
-
outputModality:
|
|
811
|
-
});
|
|
812
|
-
var aiUsageSummarySchema =
|
|
813
|
-
totalInputTokens:
|
|
814
|
-
totalOutputTokens:
|
|
815
|
-
totalTokens:
|
|
816
|
-
totalImageCount:
|
|
817
|
-
totalRequests:
|
|
879
|
+
id: z12.string().uuid(),
|
|
880
|
+
createdAt: z12.date(),
|
|
881
|
+
modelId: z12.string().nullable().optional(),
|
|
882
|
+
model: z12.string().nullable(),
|
|
883
|
+
provider: z12.string().nullable(),
|
|
884
|
+
inputModality: z12.array(modalitySchema).nullable(),
|
|
885
|
+
outputModality: z12.array(modalitySchema).nullable()
|
|
886
|
+
});
|
|
887
|
+
var aiUsageSummarySchema = z12.object({
|
|
888
|
+
totalInputTokens: z12.number(),
|
|
889
|
+
totalOutputTokens: z12.number(),
|
|
890
|
+
totalTokens: z12.number(),
|
|
891
|
+
totalImageCount: z12.number(),
|
|
892
|
+
totalRequests: z12.number()
|
|
818
893
|
});
|
|
819
894
|
|
|
820
895
|
// node_modules/@insforge/shared-schemas/dist/ai-api.schema.js
|
|
821
|
-
import { z as
|
|
822
|
-
var textContentSchema =
|
|
823
|
-
type:
|
|
824
|
-
text:
|
|
896
|
+
import { z as z13 } from "zod";
|
|
897
|
+
var textContentSchema = z13.object({
|
|
898
|
+
type: z13.literal("text"),
|
|
899
|
+
text: z13.string()
|
|
825
900
|
});
|
|
826
|
-
var imageContentSchema =
|
|
827
|
-
type:
|
|
901
|
+
var imageContentSchema = z13.object({
|
|
902
|
+
type: z13.literal("image_url"),
|
|
828
903
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
829
|
-
image_url:
|
|
904
|
+
image_url: z13.object({
|
|
830
905
|
// URL can be either a public URL or base64-encoded data URI
|
|
831
906
|
// Examples:
|
|
832
907
|
// - Public URL: "https://example.com/image.jpg"
|
|
833
908
|
// - Base64: "data:image/jpeg;base64,/9j/4AAQ..."
|
|
834
|
-
url:
|
|
835
|
-
detail:
|
|
909
|
+
url: z13.string(),
|
|
910
|
+
detail: z13.enum(["auto", "low", "high"]).optional()
|
|
836
911
|
})
|
|
837
912
|
});
|
|
838
|
-
var contentSchema =
|
|
839
|
-
var chatMessageSchema =
|
|
840
|
-
role:
|
|
913
|
+
var contentSchema = z13.union([textContentSchema, imageContentSchema]);
|
|
914
|
+
var chatMessageSchema = z13.object({
|
|
915
|
+
role: z13.enum(["user", "assistant", "system"]),
|
|
841
916
|
// New format: content can be string or array of content parts (OpenAI-compatible)
|
|
842
|
-
content:
|
|
917
|
+
content: z13.union([z13.string(), z13.array(contentSchema)]),
|
|
843
918
|
// Legacy format: separate images field (deprecated but supported for backward compatibility)
|
|
844
|
-
images:
|
|
845
|
-
});
|
|
846
|
-
var chatCompletionRequestSchema =
|
|
847
|
-
model:
|
|
848
|
-
messages:
|
|
849
|
-
temperature:
|
|
850
|
-
maxTokens:
|
|
851
|
-
topP:
|
|
852
|
-
stream:
|
|
853
|
-
});
|
|
854
|
-
var chatCompletionResponseSchema =
|
|
855
|
-
text:
|
|
856
|
-
metadata:
|
|
857
|
-
model:
|
|
858
|
-
usage:
|
|
859
|
-
promptTokens:
|
|
860
|
-
completionTokens:
|
|
861
|
-
totalTokens:
|
|
919
|
+
images: z13.array(z13.object({ url: z13.string() })).optional()
|
|
920
|
+
});
|
|
921
|
+
var chatCompletionRequestSchema = z13.object({
|
|
922
|
+
model: z13.string(),
|
|
923
|
+
messages: z13.array(chatMessageSchema),
|
|
924
|
+
temperature: z13.number().min(0).max(2).optional(),
|
|
925
|
+
maxTokens: z13.number().positive().optional(),
|
|
926
|
+
topP: z13.number().min(0).max(1).optional(),
|
|
927
|
+
stream: z13.boolean().optional()
|
|
928
|
+
});
|
|
929
|
+
var chatCompletionResponseSchema = z13.object({
|
|
930
|
+
text: z13.string(),
|
|
931
|
+
metadata: z13.object({
|
|
932
|
+
model: z13.string(),
|
|
933
|
+
usage: z13.object({
|
|
934
|
+
promptTokens: z13.number().optional(),
|
|
935
|
+
completionTokens: z13.number().optional(),
|
|
936
|
+
totalTokens: z13.number().optional()
|
|
862
937
|
}).optional()
|
|
863
938
|
}).optional()
|
|
864
939
|
});
|
|
865
|
-
var imageGenerationRequestSchema =
|
|
866
|
-
model:
|
|
867
|
-
prompt:
|
|
868
|
-
images:
|
|
869
|
-
url:
|
|
940
|
+
var imageGenerationRequestSchema = z13.object({
|
|
941
|
+
model: z13.string(),
|
|
942
|
+
prompt: z13.string(),
|
|
943
|
+
images: z13.array(z13.object({
|
|
944
|
+
url: z13.string()
|
|
870
945
|
})).optional()
|
|
871
946
|
});
|
|
872
|
-
var imageGenerationResponseSchema =
|
|
873
|
-
text:
|
|
874
|
-
images:
|
|
875
|
-
type:
|
|
876
|
-
imageUrl:
|
|
947
|
+
var imageGenerationResponseSchema = z13.object({
|
|
948
|
+
text: z13.string().optional(),
|
|
949
|
+
images: z13.array(z13.object({
|
|
950
|
+
type: z13.literal("imageUrl"),
|
|
951
|
+
imageUrl: z13.string()
|
|
877
952
|
})),
|
|
878
|
-
metadata:
|
|
879
|
-
model:
|
|
880
|
-
usage:
|
|
881
|
-
promptTokens:
|
|
882
|
-
completionTokens:
|
|
883
|
-
totalTokens:
|
|
953
|
+
metadata: z13.object({
|
|
954
|
+
model: z13.string(),
|
|
955
|
+
usage: z13.object({
|
|
956
|
+
promptTokens: z13.number().optional(),
|
|
957
|
+
completionTokens: z13.number().optional(),
|
|
958
|
+
totalTokens: z13.number().optional()
|
|
884
959
|
}).optional()
|
|
885
960
|
}).optional()
|
|
886
961
|
});
|
|
887
|
-
var aiModelSchema =
|
|
888
|
-
id:
|
|
889
|
-
inputModality:
|
|
890
|
-
outputModality:
|
|
891
|
-
provider:
|
|
892
|
-
modelId:
|
|
893
|
-
priceLevel:
|
|
962
|
+
var aiModelSchema = z13.object({
|
|
963
|
+
id: z13.string(),
|
|
964
|
+
inputModality: z13.array(modalitySchema).min(1),
|
|
965
|
+
outputModality: z13.array(modalitySchema).min(1),
|
|
966
|
+
provider: z13.string(),
|
|
967
|
+
modelId: z13.string(),
|
|
968
|
+
priceLevel: z13.number().min(0).max(3).optional()
|
|
894
969
|
});
|
|
895
970
|
var createAIConfigurationRequestSchema = aiConfigurationSchema.omit({
|
|
896
971
|
id: true
|
|
897
972
|
});
|
|
898
|
-
var updateAIConfigurationRequestSchema =
|
|
899
|
-
systemPrompt:
|
|
973
|
+
var updateAIConfigurationRequestSchema = z13.object({
|
|
974
|
+
systemPrompt: z13.string().nullable()
|
|
900
975
|
});
|
|
901
|
-
var listAIUsageResponseSchema =
|
|
902
|
-
records:
|
|
903
|
-
total:
|
|
976
|
+
var listAIUsageResponseSchema = z13.object({
|
|
977
|
+
records: z13.array(aiUsageRecordSchema),
|
|
978
|
+
total: z13.number()
|
|
904
979
|
});
|
|
905
|
-
var getAIUsageRequestSchema =
|
|
906
|
-
startDate:
|
|
907
|
-
endDate:
|
|
908
|
-
limit:
|
|
909
|
-
offset:
|
|
980
|
+
var getAIUsageRequestSchema = z13.object({
|
|
981
|
+
startDate: z13.string().datetime().optional(),
|
|
982
|
+
endDate: z13.string().datetime().optional(),
|
|
983
|
+
limit: z13.string().regex(/^\d+$/).default("50"),
|
|
984
|
+
offset: z13.string().regex(/^\d+$/).default("0")
|
|
910
985
|
});
|
|
911
|
-
var getAIUsageSummaryRequestSchema =
|
|
912
|
-
configId:
|
|
913
|
-
startDate:
|
|
914
|
-
endDate:
|
|
986
|
+
var getAIUsageSummaryRequestSchema = z13.object({
|
|
987
|
+
configId: z13.string().uuid().optional(),
|
|
988
|
+
startDate: z13.string().datetime().optional(),
|
|
989
|
+
endDate: z13.string().datetime().optional()
|
|
915
990
|
});
|
|
916
991
|
|
|
917
992
|
// node_modules/@insforge/shared-schemas/dist/logs.schema.js
|
|
918
|
-
import { z as
|
|
919
|
-
var auditLogSchema =
|
|
920
|
-
id:
|
|
921
|
-
actor:
|
|
922
|
-
action:
|
|
923
|
-
module:
|
|
924
|
-
details:
|
|
925
|
-
ipAddress:
|
|
926
|
-
createdAt:
|
|
927
|
-
updatedAt:
|
|
928
|
-
});
|
|
929
|
-
var logSourceSchema =
|
|
930
|
-
id:
|
|
931
|
-
name:
|
|
932
|
-
token:
|
|
933
|
-
});
|
|
934
|
-
var logSchema =
|
|
935
|
-
id:
|
|
936
|
-
eventMessage:
|
|
937
|
-
timestamp:
|
|
938
|
-
body:
|
|
939
|
-
source:
|
|
940
|
-
});
|
|
941
|
-
var logStatsSchema =
|
|
942
|
-
source:
|
|
943
|
-
count:
|
|
944
|
-
lastActivity:
|
|
993
|
+
import { z as z14 } from "zod";
|
|
994
|
+
var auditLogSchema = z14.object({
|
|
995
|
+
id: z14.string(),
|
|
996
|
+
actor: z14.string(),
|
|
997
|
+
action: z14.string(),
|
|
998
|
+
module: z14.string(),
|
|
999
|
+
details: z14.record(z14.unknown()).nullable(),
|
|
1000
|
+
ipAddress: z14.string().nullable(),
|
|
1001
|
+
createdAt: z14.string(),
|
|
1002
|
+
updatedAt: z14.string()
|
|
1003
|
+
});
|
|
1004
|
+
var logSourceSchema = z14.object({
|
|
1005
|
+
id: z14.string(),
|
|
1006
|
+
name: z14.string(),
|
|
1007
|
+
token: z14.string()
|
|
1008
|
+
});
|
|
1009
|
+
var logSchema = z14.object({
|
|
1010
|
+
id: z14.string(),
|
|
1011
|
+
eventMessage: z14.string(),
|
|
1012
|
+
timestamp: z14.string(),
|
|
1013
|
+
body: z14.record(z14.string(), z14.unknown()),
|
|
1014
|
+
source: z14.string().optional()
|
|
1015
|
+
});
|
|
1016
|
+
var logStatsSchema = z14.object({
|
|
1017
|
+
source: z14.string(),
|
|
1018
|
+
count: z14.number(),
|
|
1019
|
+
lastActivity: z14.string()
|
|
945
1020
|
});
|
|
946
1021
|
|
|
947
1022
|
// node_modules/@insforge/shared-schemas/dist/logs-api.schema.js
|
|
948
|
-
import { z as
|
|
949
|
-
var getAuditLogsRequestSchema =
|
|
950
|
-
limit:
|
|
951
|
-
offset:
|
|
952
|
-
actor:
|
|
953
|
-
action:
|
|
954
|
-
module:
|
|
955
|
-
startDate:
|
|
956
|
-
endDate:
|
|
957
|
-
});
|
|
958
|
-
var getAuditLogsResponseSchema =
|
|
959
|
-
data:
|
|
960
|
-
pagination:
|
|
961
|
-
limit:
|
|
962
|
-
offset:
|
|
963
|
-
total:
|
|
1023
|
+
import { z as z15 } from "zod";
|
|
1024
|
+
var getAuditLogsRequestSchema = z15.object({
|
|
1025
|
+
limit: z15.number().default(100),
|
|
1026
|
+
offset: z15.number().default(0),
|
|
1027
|
+
actor: z15.string().optional(),
|
|
1028
|
+
action: z15.string().optional(),
|
|
1029
|
+
module: z15.string().optional(),
|
|
1030
|
+
startDate: z15.string().optional(),
|
|
1031
|
+
endDate: z15.string().optional()
|
|
1032
|
+
});
|
|
1033
|
+
var getAuditLogsResponseSchema = z15.object({
|
|
1034
|
+
data: z15.array(auditLogSchema),
|
|
1035
|
+
pagination: z15.object({
|
|
1036
|
+
limit: z15.number(),
|
|
1037
|
+
offset: z15.number(),
|
|
1038
|
+
total: z15.number()
|
|
964
1039
|
})
|
|
965
1040
|
});
|
|
966
|
-
var getAuditLogStatsRequestSchema =
|
|
967
|
-
days:
|
|
1041
|
+
var getAuditLogStatsRequestSchema = z15.object({
|
|
1042
|
+
days: z15.number().default(7)
|
|
968
1043
|
});
|
|
969
|
-
var getAuditLogStatsResponseSchema =
|
|
970
|
-
totalLogs:
|
|
971
|
-
uniqueActors:
|
|
972
|
-
uniqueModules:
|
|
973
|
-
actionsByModule:
|
|
974
|
-
recentActivity:
|
|
1044
|
+
var getAuditLogStatsResponseSchema = z15.object({
|
|
1045
|
+
totalLogs: z15.number(),
|
|
1046
|
+
uniqueActors: z15.number(),
|
|
1047
|
+
uniqueModules: z15.number(),
|
|
1048
|
+
actionsByModule: z15.record(z15.number()),
|
|
1049
|
+
recentActivity: z15.array(auditLogSchema)
|
|
975
1050
|
});
|
|
976
|
-
var clearAuditLogsRequestSchema =
|
|
977
|
-
daysToKeep:
|
|
1051
|
+
var clearAuditLogsRequestSchema = z15.object({
|
|
1052
|
+
daysToKeep: z15.number().default(90)
|
|
978
1053
|
});
|
|
979
|
-
var clearAuditLogsResponseSchema =
|
|
980
|
-
message:
|
|
981
|
-
deleted:
|
|
1054
|
+
var clearAuditLogsResponseSchema = z15.object({
|
|
1055
|
+
message: z15.string(),
|
|
1056
|
+
deleted: z15.number()
|
|
982
1057
|
});
|
|
983
|
-
var getLogsResponseSchema =
|
|
984
|
-
logs:
|
|
985
|
-
total:
|
|
1058
|
+
var getLogsResponseSchema = z15.object({
|
|
1059
|
+
logs: z15.array(logSchema),
|
|
1060
|
+
total: z15.number()
|
|
986
1061
|
});
|
|
987
1062
|
|
|
988
1063
|
// node_modules/@insforge/shared-schemas/dist/functions.schema.js
|
|
989
|
-
import { z as
|
|
990
|
-
var functionSchema =
|
|
991
|
-
id:
|
|
992
|
-
slug:
|
|
993
|
-
name:
|
|
994
|
-
description:
|
|
995
|
-
code:
|
|
996
|
-
status:
|
|
997
|
-
createdAt:
|
|
998
|
-
updatedAt:
|
|
999
|
-
deployedAt:
|
|
1064
|
+
import { z as z16 } from "zod";
|
|
1065
|
+
var functionSchema = z16.object({
|
|
1066
|
+
id: z16.string(),
|
|
1067
|
+
slug: z16.string(),
|
|
1068
|
+
name: z16.string(),
|
|
1069
|
+
description: z16.string().nullable(),
|
|
1070
|
+
code: z16.string(),
|
|
1071
|
+
status: z16.enum(["draft", "active", "error"]),
|
|
1072
|
+
createdAt: z16.string(),
|
|
1073
|
+
updatedAt: z16.string(),
|
|
1074
|
+
deployedAt: z16.string().nullable()
|
|
1000
1075
|
});
|
|
1001
1076
|
|
|
1002
1077
|
// node_modules/@insforge/shared-schemas/dist/functions-api.schema.js
|
|
1003
|
-
import { z as
|
|
1004
|
-
var
|
|
1005
|
-
name:
|
|
1006
|
-
slug:
|
|
1007
|
-
code:
|
|
1008
|
-
description:
|
|
1009
|
-
status:
|
|
1010
|
-
});
|
|
1011
|
-
var
|
|
1012
|
-
name:
|
|
1013
|
-
code:
|
|
1014
|
-
description:
|
|
1015
|
-
status:
|
|
1078
|
+
import { z as z17 } from "zod";
|
|
1079
|
+
var uploadFunctionRequestSchema = z17.object({
|
|
1080
|
+
name: z17.string().min(1, "Name is required"),
|
|
1081
|
+
slug: z17.string().regex(/^[a-zA-Z0-9_-]+$/, "Invalid slug format - must be alphanumeric with hyphens or underscores only").optional(),
|
|
1082
|
+
code: z17.string().min(1),
|
|
1083
|
+
description: z17.string().optional(),
|
|
1084
|
+
status: z17.enum(["draft", "active"]).optional().default("active")
|
|
1085
|
+
});
|
|
1086
|
+
var updateFunctionRequestSchema = z17.object({
|
|
1087
|
+
name: z17.string().optional(),
|
|
1088
|
+
code: z17.string().optional(),
|
|
1089
|
+
description: z17.string().optional(),
|
|
1090
|
+
status: z17.enum(["draft", "active"]).optional()
|
|
1091
|
+
});
|
|
1092
|
+
var listFunctionsResponseSchema = z17.object({
|
|
1093
|
+
functions: z17.array(functionSchema),
|
|
1094
|
+
runtime: z17.object({
|
|
1095
|
+
status: z17.enum(["running", "unavailable"])
|
|
1096
|
+
})
|
|
1016
1097
|
});
|
|
1017
1098
|
|
|
1018
1099
|
// node_modules/@insforge/shared-schemas/dist/cloud-events.schema.js
|
|
1019
|
-
import { z as
|
|
1020
|
-
var appRouteChangeEventSchema =
|
|
1021
|
-
type:
|
|
1022
|
-
path:
|
|
1100
|
+
import { z as z18 } from "zod";
|
|
1101
|
+
var appRouteChangeEventSchema = z18.object({
|
|
1102
|
+
type: z18.literal("APP_ROUTE_CHANGE"),
|
|
1103
|
+
path: z18.string()
|
|
1023
1104
|
});
|
|
1024
|
-
var authSuccessEventSchema =
|
|
1025
|
-
type:
|
|
1105
|
+
var authSuccessEventSchema = z18.object({
|
|
1106
|
+
type: z18.literal("AUTH_SUCCESS")
|
|
1026
1107
|
});
|
|
1027
|
-
var authErrorEventSchema =
|
|
1028
|
-
type:
|
|
1029
|
-
message:
|
|
1108
|
+
var authErrorEventSchema = z18.object({
|
|
1109
|
+
type: z18.literal("AUTH_ERROR"),
|
|
1110
|
+
message: z18.string()
|
|
1030
1111
|
});
|
|
1031
|
-
var mcpConnectionStatusEventSchema =
|
|
1032
|
-
type:
|
|
1033
|
-
connected:
|
|
1034
|
-
toolName:
|
|
1035
|
-
timestamp:
|
|
1112
|
+
var mcpConnectionStatusEventSchema = z18.object({
|
|
1113
|
+
type: z18.literal("MCP_CONNECTION_STATUS"),
|
|
1114
|
+
connected: z18.boolean(),
|
|
1115
|
+
toolName: z18.string(),
|
|
1116
|
+
timestamp: z18.union([z18.number(), z18.string()])
|
|
1036
1117
|
});
|
|
1037
|
-
var showOnboardingOverlayEventSchema =
|
|
1038
|
-
type:
|
|
1118
|
+
var showOnboardingOverlayEventSchema = z18.object({
|
|
1119
|
+
type: z18.literal("SHOW_ONBOARDING_OVERLAY")
|
|
1039
1120
|
});
|
|
1040
|
-
var showSettingsOverlayEventSchema =
|
|
1041
|
-
type:
|
|
1121
|
+
var showSettingsOverlayEventSchema = z18.object({
|
|
1122
|
+
type: z18.literal("SHOW_SETTINGS_OVERLAY")
|
|
1042
1123
|
});
|
|
1043
|
-
var onboardingSuccessSchema =
|
|
1044
|
-
type:
|
|
1124
|
+
var onboardingSuccessSchema = z18.object({
|
|
1125
|
+
type: z18.literal("ONBOARDING_SUCCESS")
|
|
1045
1126
|
});
|
|
1046
|
-
var navigateToUsageSchema =
|
|
1047
|
-
type:
|
|
1127
|
+
var navigateToUsageSchema = z18.object({
|
|
1128
|
+
type: z18.literal("NAVIGATE_TO_USAGE")
|
|
1048
1129
|
});
|
|
1049
|
-
var
|
|
1130
|
+
var showContactModalEventSchema = z18.object({
|
|
1131
|
+
type: z18.literal("SHOW_CONTACT_MODAL")
|
|
1132
|
+
});
|
|
1133
|
+
var showConnectOverlayEventSchema = z18.object({
|
|
1134
|
+
type: z18.literal("SHOW_CONNECT_OVERLAY")
|
|
1135
|
+
});
|
|
1136
|
+
var authorizationCodeEventSchema = z18.object({
|
|
1137
|
+
type: z18.literal("AUTHORIZATION_CODE"),
|
|
1138
|
+
code: z18.string()
|
|
1139
|
+
});
|
|
1140
|
+
var routeChangeEventSchema = z18.object({
|
|
1141
|
+
type: z18.literal("ROUTE_CHANGE"),
|
|
1142
|
+
path: z18.string()
|
|
1143
|
+
});
|
|
1144
|
+
var cloudEventSchema = z18.discriminatedUnion("type", [
|
|
1050
1145
|
appRouteChangeEventSchema,
|
|
1051
1146
|
authSuccessEventSchema,
|
|
1052
1147
|
authErrorEventSchema,
|
|
@@ -1054,121 +1149,192 @@ var cloudEventSchema = z16.discriminatedUnion("type", [
|
|
|
1054
1149
|
showOnboardingOverlayEventSchema,
|
|
1055
1150
|
showSettingsOverlayEventSchema,
|
|
1056
1151
|
onboardingSuccessSchema,
|
|
1057
|
-
navigateToUsageSchema
|
|
1152
|
+
navigateToUsageSchema,
|
|
1153
|
+
showContactModalEventSchema,
|
|
1154
|
+
showConnectOverlayEventSchema,
|
|
1155
|
+
authorizationCodeEventSchema,
|
|
1156
|
+
routeChangeEventSchema
|
|
1058
1157
|
]);
|
|
1059
1158
|
|
|
1060
1159
|
// node_modules/@insforge/shared-schemas/dist/docs.schema.js
|
|
1061
|
-
import { z as
|
|
1062
|
-
var docTypeSchema =
|
|
1160
|
+
import { z as z19 } from "zod";
|
|
1161
|
+
var docTypeSchema = z19.enum([
|
|
1063
1162
|
"instructions",
|
|
1163
|
+
"auth-sdk",
|
|
1064
1164
|
"db-sdk",
|
|
1065
1165
|
"storage-sdk",
|
|
1066
1166
|
"functions-sdk",
|
|
1067
1167
|
"ai-integration-sdk",
|
|
1068
1168
|
"auth-components-react",
|
|
1069
1169
|
"auth-components-nextjs",
|
|
1070
|
-
"real-time"
|
|
1170
|
+
"real-time",
|
|
1171
|
+
"deployment"
|
|
1071
1172
|
]).describe(`
|
|
1072
|
-
Documentation type:
|
|
1173
|
+
Documentation type:
|
|
1073
1174
|
"instructions" (essential backend setup - use FIRST),
|
|
1074
1175
|
"db-sdk" (database operations),
|
|
1075
1176
|
"storage-sdk" (file storage),
|
|
1076
1177
|
"functions-sdk" (edge functions),
|
|
1178
|
+
"auth-sdk" (direct SDK methods for custom auth flows),
|
|
1077
1179
|
"auth-components-react" (authentication components for React+Vite applications),
|
|
1078
1180
|
"auth-components-nextjs" (authentication components for Next.js applications),
|
|
1079
1181
|
"ai-integration-sdk" (AI features),
|
|
1080
|
-
"real-time" (real-time pub/sub through WebSockets)
|
|
1182
|
+
"real-time" (real-time pub/sub through WebSockets),
|
|
1183
|
+
"deployment" (deploy frontend applications via MCP tool)
|
|
1081
1184
|
`);
|
|
1082
1185
|
|
|
1083
1186
|
// node_modules/@insforge/shared-schemas/dist/email-api.schema.js
|
|
1084
|
-
import { z as
|
|
1085
|
-
var emailOrEmails =
|
|
1187
|
+
import { z as z20 } from "zod";
|
|
1188
|
+
var emailOrEmails = z20.union([
|
|
1086
1189
|
emailSchema,
|
|
1087
|
-
|
|
1190
|
+
z20.array(emailSchema).min(1, "At least one email is required").max(50, "Maximum 50 recipients allowed")
|
|
1088
1191
|
]);
|
|
1089
|
-
var sendRawEmailRequestSchema =
|
|
1192
|
+
var sendRawEmailRequestSchema = z20.object({
|
|
1090
1193
|
to: emailOrEmails,
|
|
1091
|
-
subject:
|
|
1092
|
-
html:
|
|
1194
|
+
subject: z20.string().trim().min(1, "Subject is required").max(500, "Subject too long"),
|
|
1195
|
+
html: z20.string().trim().min(1, "HTML content is required"),
|
|
1093
1196
|
cc: emailOrEmails.optional(),
|
|
1094
1197
|
bcc: emailOrEmails.optional(),
|
|
1095
|
-
from:
|
|
1096
|
-
replyTo:
|
|
1198
|
+
from: z20.string().trim().max(100, "From name too long").optional(),
|
|
1199
|
+
replyTo: z20.string().email("Reply-To must be a valid email").optional()
|
|
1200
|
+
});
|
|
1201
|
+
var sendEmailResponseSchema = z20.object({});
|
|
1202
|
+
|
|
1203
|
+
// node_modules/@insforge/shared-schemas/dist/deployments.schema.js
|
|
1204
|
+
import { z as z21 } from "zod";
|
|
1205
|
+
var deploymentStatusSchema = z21.enum([
|
|
1206
|
+
"WAITING",
|
|
1207
|
+
// Record created, waiting for client to upload zip to S3
|
|
1208
|
+
"UPLOADING",
|
|
1209
|
+
// Server is downloading from S3 and uploading to Vercel
|
|
1210
|
+
"QUEUED",
|
|
1211
|
+
// Vercel: deployment queued
|
|
1212
|
+
"BUILDING",
|
|
1213
|
+
// Vercel: deployment building
|
|
1214
|
+
"READY",
|
|
1215
|
+
// Vercel: deployment ready
|
|
1216
|
+
"ERROR",
|
|
1217
|
+
// Vercel: deployment failed
|
|
1218
|
+
"CANCELED"
|
|
1219
|
+
// Vercel: deployment canceled
|
|
1220
|
+
]);
|
|
1221
|
+
var deploymentSchema = z21.object({
|
|
1222
|
+
id: z21.string().uuid(),
|
|
1223
|
+
providerDeploymentId: z21.string().nullable(),
|
|
1224
|
+
// Provider's deployment ID, null until deployment starts
|
|
1225
|
+
provider: z21.string(),
|
|
1226
|
+
status: deploymentStatusSchema,
|
|
1227
|
+
url: z21.string().nullable(),
|
|
1228
|
+
metadata: z21.record(z21.unknown()).nullable(),
|
|
1229
|
+
createdAt: z21.string().datetime(),
|
|
1230
|
+
updatedAt: z21.string().datetime()
|
|
1231
|
+
});
|
|
1232
|
+
|
|
1233
|
+
// node_modules/@insforge/shared-schemas/dist/deployments-api.schema.js
|
|
1234
|
+
import { z as z22 } from "zod";
|
|
1235
|
+
var projectSettingsSchema = z22.object({
|
|
1236
|
+
buildCommand: z22.string().nullable().optional(),
|
|
1237
|
+
outputDirectory: z22.string().nullable().optional(),
|
|
1238
|
+
installCommand: z22.string().nullable().optional(),
|
|
1239
|
+
devCommand: z22.string().nullable().optional(),
|
|
1240
|
+
rootDirectory: z22.string().nullable().optional()
|
|
1241
|
+
});
|
|
1242
|
+
var envVarSchema = z22.object({
|
|
1243
|
+
key: z22.string(),
|
|
1244
|
+
value: z22.string()
|
|
1245
|
+
});
|
|
1246
|
+
var createDeploymentResponseSchema = z22.object({
|
|
1247
|
+
id: z22.string().uuid(),
|
|
1248
|
+
uploadUrl: z22.string().url(),
|
|
1249
|
+
uploadFields: z22.record(z22.string())
|
|
1250
|
+
// Required for S3 presigned POST (policy, signature, key, etc.)
|
|
1251
|
+
});
|
|
1252
|
+
var startDeploymentRequestSchema = z22.object({
|
|
1253
|
+
projectSettings: projectSettingsSchema.optional(),
|
|
1254
|
+
envVars: z22.array(envVarSchema).optional(),
|
|
1255
|
+
meta: z22.record(z22.string()).optional()
|
|
1256
|
+
});
|
|
1257
|
+
var listDeploymentsResponseSchema = z22.object({
|
|
1258
|
+
data: z22.array(deploymentSchema),
|
|
1259
|
+
pagination: z22.object({
|
|
1260
|
+
limit: z22.number(),
|
|
1261
|
+
offset: z22.number(),
|
|
1262
|
+
total: z22.number()
|
|
1263
|
+
})
|
|
1097
1264
|
});
|
|
1098
1265
|
|
|
1099
1266
|
// src/shared/tools.ts
|
|
1100
1267
|
import FormData from "form-data";
|
|
1101
1268
|
var execAsync = promisify(exec);
|
|
1102
1269
|
var TOOL_VERSION_REQUIREMENTS = {
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1270
|
+
// Schedule tools - require backend v1.1.1+
|
|
1271
|
+
"upsert-schedule": { minVersion: "1.1.1" },
|
|
1272
|
+
"delete-schedule": { minVersion: "1.1.1" },
|
|
1273
|
+
// 'get-schedules': { minVersion: '1.1.1' },
|
|
1274
|
+
// 'get-schedule-logs': { minVersion: '1.1.1' },
|
|
1275
|
+
"create-deployment": { minVersion: "1.4.7" }
|
|
1276
|
+
// Example of a deprecated tool (uncomment when needed):
|
|
1277
|
+
// 'legacy-tool': { minVersion: '1.0.0', maxVersion: '1.5.0' },
|
|
1107
1278
|
};
|
|
1108
|
-
function
|
|
1109
|
-
const
|
|
1110
|
-
const
|
|
1111
|
-
const
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
const
|
|
1116
|
-
if (
|
|
1117
|
-
|
|
1118
|
-
}
|
|
1119
|
-
try {
|
|
1120
|
-
const response = await fetch2(`${API_BASE_URL}/api/health`, {
|
|
1121
|
-
method: "GET",
|
|
1122
|
-
headers: {
|
|
1123
|
-
"Content-Type": "application/json"
|
|
1124
|
-
}
|
|
1125
|
-
});
|
|
1126
|
-
if (!response.ok) {
|
|
1127
|
-
throw new Error(`Health check failed with status ${response.status}`);
|
|
1128
|
-
}
|
|
1129
|
-
const health = await response.json();
|
|
1130
|
-
versionCache = {
|
|
1131
|
-
version: health.version,
|
|
1132
|
-
timestamp: now
|
|
1133
|
-
};
|
|
1134
|
-
return health.version;
|
|
1135
|
-
} catch (error) {
|
|
1136
|
-
const errMsg = error instanceof Error ? error.message : "Unknown error";
|
|
1137
|
-
throw new Error(`Failed to fetch backend version: ${errMsg}`);
|
|
1138
|
-
}
|
|
1279
|
+
function compareVersions(v1, v2) {
|
|
1280
|
+
const clean1 = v1.replace(/^v/, "").split("-")[0];
|
|
1281
|
+
const clean2 = v2.replace(/^v/, "").split("-")[0];
|
|
1282
|
+
const parts1 = clean1.split(".").map(Number);
|
|
1283
|
+
const parts2 = clean2.split(".").map(Number);
|
|
1284
|
+
for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) {
|
|
1285
|
+
const part1 = parts1[i] || 0;
|
|
1286
|
+
const part2 = parts2[i] || 0;
|
|
1287
|
+
if (part1 > part2) return 1;
|
|
1288
|
+
if (part1 < part2) return -1;
|
|
1139
1289
|
}
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
const part1 = parts1[i] || 0;
|
|
1147
|
-
const part2 = parts2[i] || 0;
|
|
1148
|
-
if (part1 > part2) return 1;
|
|
1149
|
-
if (part1 < part2) return -1;
|
|
1150
|
-
}
|
|
1151
|
-
return 0;
|
|
1290
|
+
return 0;
|
|
1291
|
+
}
|
|
1292
|
+
function shouldRegisterTool(toolName, backendVersion) {
|
|
1293
|
+
const requirement = TOOL_VERSION_REQUIREMENTS[toolName];
|
|
1294
|
+
if (!requirement) {
|
|
1295
|
+
return true;
|
|
1152
1296
|
}
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
throw error;
|
|
1168
|
-
}
|
|
1169
|
-
console.warn(`Warning: Could not verify backend version for tool '${toolName}': ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1297
|
+
const { minVersion, maxVersion } = requirement;
|
|
1298
|
+
if (minVersion && compareVersions(backendVersion, minVersion) < 0) {
|
|
1299
|
+
return false;
|
|
1300
|
+
}
|
|
1301
|
+
if (maxVersion && compareVersions(backendVersion, maxVersion) > 0) {
|
|
1302
|
+
return false;
|
|
1303
|
+
}
|
|
1304
|
+
return true;
|
|
1305
|
+
}
|
|
1306
|
+
async function fetchBackendVersion(apiBaseUrl) {
|
|
1307
|
+
const response = await fetch2(`${apiBaseUrl}/api/health`, {
|
|
1308
|
+
method: "GET",
|
|
1309
|
+
headers: {
|
|
1310
|
+
"Content-Type": "application/json"
|
|
1170
1311
|
}
|
|
1312
|
+
});
|
|
1313
|
+
if (!response.ok) {
|
|
1314
|
+
throw new Error(`Health check failed with status ${response.status}`);
|
|
1171
1315
|
}
|
|
1316
|
+
const health = await response.json();
|
|
1317
|
+
return health.version;
|
|
1318
|
+
}
|
|
1319
|
+
async function registerInsforgeTools(server, config = {}) {
|
|
1320
|
+
const GLOBAL_API_KEY = config.apiKey || process.env.API_KEY || "";
|
|
1321
|
+
const API_BASE_URL = config.apiBaseUrl || process.env.API_BASE_URL || "http://localhost:7130";
|
|
1322
|
+
const usageTracker = new UsageTracker(API_BASE_URL, GLOBAL_API_KEY);
|
|
1323
|
+
const backendVersion = await fetchBackendVersion(API_BASE_URL);
|
|
1324
|
+
console.error(`Backend version: ${backendVersion}`);
|
|
1325
|
+
let toolCount = 0;
|
|
1326
|
+
const registerTool = (toolName, ...args) => {
|
|
1327
|
+
if (shouldRegisterTool(toolName, backendVersion)) {
|
|
1328
|
+
server.tool(toolName, ...args);
|
|
1329
|
+
toolCount++;
|
|
1330
|
+
return true;
|
|
1331
|
+
} else {
|
|
1332
|
+
const req = TOOL_VERSION_REQUIREMENTS[toolName];
|
|
1333
|
+
const reason = req?.minVersion && compareVersions(backendVersion, req.minVersion) < 0 ? `requires backend >= ${req.minVersion}` : `deprecated after backend ${req?.maxVersion}`;
|
|
1334
|
+
console.error(`Skipping tool '${toolName}': ${reason} (current: ${backendVersion})`);
|
|
1335
|
+
return false;
|
|
1336
|
+
}
|
|
1337
|
+
};
|
|
1172
1338
|
async function trackToolUsage(toolName, success = true) {
|
|
1173
1339
|
if (GLOBAL_API_KEY) {
|
|
1174
1340
|
await usageTracker.trackUsage(toolName, success);
|
|
@@ -1225,28 +1391,23 @@ function registerInsforgeTools(server, config = {}) {
|
|
|
1225
1391
|
}
|
|
1226
1392
|
};
|
|
1227
1393
|
const addBackgroundContext = async (response) => {
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
const
|
|
1231
|
-
if (
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
type: "text",
|
|
1236
|
-
text: `
|
|
1394
|
+
const isLegacyVersion = compareVersions(backendVersion, "1.1.7") < 0;
|
|
1395
|
+
if (isLegacyVersion) {
|
|
1396
|
+
const context = await fetchInsforgeInstructionsContext();
|
|
1397
|
+
if (context && response.content && Array.isArray(response.content)) {
|
|
1398
|
+
response.content.push({
|
|
1399
|
+
type: "text",
|
|
1400
|
+
text: `
|
|
1237
1401
|
|
|
1238
1402
|
---
|
|
1239
1403
|
\u{1F527} INSFORGE DEVELOPMENT RULES (Auto-loaded):
|
|
1240
1404
|
${context}`
|
|
1241
|
-
|
|
1242
|
-
}
|
|
1405
|
+
});
|
|
1243
1406
|
}
|
|
1244
|
-
} catch {
|
|
1245
|
-
console.warn("Could not determine backend version, skipping background context");
|
|
1246
1407
|
}
|
|
1247
1408
|
return response;
|
|
1248
1409
|
};
|
|
1249
|
-
|
|
1410
|
+
registerTool(
|
|
1250
1411
|
"fetch-docs",
|
|
1251
1412
|
'Fetch Insforge documentation. Use "instructions" for essential backend setup (MANDATORY FIRST), or select specific SDK docs for database, auth, storage, functions, or AI integration.',
|
|
1252
1413
|
{
|
|
@@ -1279,11 +1440,11 @@ ${context}`
|
|
|
1279
1440
|
}
|
|
1280
1441
|
})
|
|
1281
1442
|
);
|
|
1282
|
-
|
|
1443
|
+
registerTool(
|
|
1283
1444
|
"get-anon-key",
|
|
1284
1445
|
"Generate an anonymous JWT token that never expires. Requires admin API key. Use this for client-side applications that need public access.",
|
|
1285
1446
|
{
|
|
1286
|
-
apiKey:
|
|
1447
|
+
apiKey: z23.string().optional().describe("API key for authentication (optional if provided via --api_key)")
|
|
1287
1448
|
},
|
|
1288
1449
|
withUsageTracking("get-anon-key", async ({ apiKey }) => {
|
|
1289
1450
|
try {
|
|
@@ -1318,12 +1479,12 @@ ${context}`
|
|
|
1318
1479
|
}
|
|
1319
1480
|
})
|
|
1320
1481
|
);
|
|
1321
|
-
|
|
1482
|
+
registerTool(
|
|
1322
1483
|
"get-table-schema",
|
|
1323
1484
|
"Returns the detailed schema(including RLS, indexes, constraints, etc.) of a specific table",
|
|
1324
1485
|
{
|
|
1325
|
-
apiKey:
|
|
1326
|
-
tableName:
|
|
1486
|
+
apiKey: z23.string().optional().describe("API key for authentication (optional if provided via --api_key)"),
|
|
1487
|
+
tableName: z23.string().describe("Name of the table")
|
|
1327
1488
|
},
|
|
1328
1489
|
withUsageTracking("get-table-schema", async ({ apiKey, tableName }) => {
|
|
1329
1490
|
try {
|
|
@@ -1357,11 +1518,11 @@ ${context}`
|
|
|
1357
1518
|
}
|
|
1358
1519
|
})
|
|
1359
1520
|
);
|
|
1360
|
-
|
|
1521
|
+
registerTool(
|
|
1361
1522
|
"get-backend-metadata",
|
|
1362
1523
|
"Index all backend metadata",
|
|
1363
1524
|
{
|
|
1364
|
-
apiKey:
|
|
1525
|
+
apiKey: z23.string().optional().describe("API key for authentication (optional if provided via --api_key)")
|
|
1365
1526
|
},
|
|
1366
1527
|
withUsageTracking("get-backend-metadata", async ({ apiKey }) => {
|
|
1367
1528
|
try {
|
|
@@ -1397,11 +1558,11 @@ ${JSON.stringify(metadata, null, 2)}`
|
|
|
1397
1558
|
}
|
|
1398
1559
|
})
|
|
1399
1560
|
);
|
|
1400
|
-
|
|
1561
|
+
registerTool(
|
|
1401
1562
|
"run-raw-sql",
|
|
1402
1563
|
"Execute raw SQL query with optional parameters. Admin access required. Use with caution as it can modify data directly.",
|
|
1403
1564
|
{
|
|
1404
|
-
apiKey:
|
|
1565
|
+
apiKey: z23.string().optional().describe("API key for authentication (optional if provided via --api_key)"),
|
|
1405
1566
|
...rawSQLRequestSchema.shape
|
|
1406
1567
|
},
|
|
1407
1568
|
withUsageTracking("run-raw-sql", async ({ apiKey, query, params }) => {
|
|
@@ -1442,12 +1603,12 @@ ${JSON.stringify(metadata, null, 2)}`
|
|
|
1442
1603
|
}
|
|
1443
1604
|
})
|
|
1444
1605
|
);
|
|
1445
|
-
|
|
1606
|
+
registerTool(
|
|
1446
1607
|
"download-template",
|
|
1447
1608
|
"CRITICAL: MANDATORY FIRST STEP for all new InsForge projects. Download pre-configured starter template to a temporary directory. After download, you MUST copy files to current directory using the provided command.",
|
|
1448
1609
|
{
|
|
1449
|
-
frame:
|
|
1450
|
-
projectName:
|
|
1610
|
+
frame: z23.enum(["react", "nextjs"]).describe("Framework to use for the template (support React and Next.js)"),
|
|
1611
|
+
projectName: z23.string().optional().describe('Name for the project directory (optional, defaults to "insforge-react")')
|
|
1451
1612
|
},
|
|
1452
1613
|
withUsageTracking("download-template", async ({ frame, projectName }) => {
|
|
1453
1614
|
try {
|
|
@@ -1518,13 +1679,13 @@ To: Your current project directory
|
|
|
1518
1679
|
}
|
|
1519
1680
|
})
|
|
1520
1681
|
);
|
|
1521
|
-
|
|
1682
|
+
registerTool(
|
|
1522
1683
|
"bulk-upsert",
|
|
1523
1684
|
"Bulk insert or update data from CSV or JSON file. Supports upsert operations with a unique key.",
|
|
1524
1685
|
{
|
|
1525
|
-
apiKey:
|
|
1686
|
+
apiKey: z23.string().optional().describe("API key for authentication (optional if provided via --api_key)"),
|
|
1526
1687
|
...bulkUpsertRequestSchema.shape,
|
|
1527
|
-
filePath:
|
|
1688
|
+
filePath: z23.string().describe("Path to CSV or JSON file containing data to import")
|
|
1528
1689
|
},
|
|
1529
1690
|
withUsageTracking("bulk-upsert", async ({ apiKey, table, filePath, upsertKey }) => {
|
|
1530
1691
|
try {
|
|
@@ -1575,11 +1736,11 @@ To: Your current project directory
|
|
|
1575
1736
|
}
|
|
1576
1737
|
})
|
|
1577
1738
|
);
|
|
1578
|
-
|
|
1739
|
+
registerTool(
|
|
1579
1740
|
"create-bucket",
|
|
1580
1741
|
"Create new storage bucket",
|
|
1581
1742
|
{
|
|
1582
|
-
apiKey:
|
|
1743
|
+
apiKey: z23.string().optional().describe("API key for authentication (optional if provided via --api_key)"),
|
|
1583
1744
|
...createBucketRequestSchema.shape
|
|
1584
1745
|
},
|
|
1585
1746
|
withUsageTracking("create-bucket", async ({ apiKey, bucketName, isPublic }) => {
|
|
@@ -1616,7 +1777,7 @@ To: Your current project directory
|
|
|
1616
1777
|
}
|
|
1617
1778
|
})
|
|
1618
1779
|
);
|
|
1619
|
-
|
|
1780
|
+
registerTool(
|
|
1620
1781
|
"list-buckets",
|
|
1621
1782
|
"Lists all storage buckets",
|
|
1622
1783
|
{},
|
|
@@ -1651,12 +1812,12 @@ To: Your current project directory
|
|
|
1651
1812
|
}
|
|
1652
1813
|
})
|
|
1653
1814
|
);
|
|
1654
|
-
|
|
1815
|
+
registerTool(
|
|
1655
1816
|
"delete-bucket",
|
|
1656
1817
|
"Deletes a storage bucket",
|
|
1657
1818
|
{
|
|
1658
|
-
apiKey:
|
|
1659
|
-
bucketName:
|
|
1819
|
+
apiKey: z23.string().optional().describe("API key for authentication (optional if provided via --api_key)"),
|
|
1820
|
+
bucketName: z23.string().describe("Name of the bucket to delete")
|
|
1660
1821
|
},
|
|
1661
1822
|
withUsageTracking("delete-bucket", async ({ apiKey, bucketName }) => {
|
|
1662
1823
|
try {
|
|
@@ -1690,12 +1851,12 @@ To: Your current project directory
|
|
|
1690
1851
|
}
|
|
1691
1852
|
})
|
|
1692
1853
|
);
|
|
1693
|
-
|
|
1854
|
+
registerTool(
|
|
1694
1855
|
"create-function",
|
|
1695
1856
|
"Create a new edge function that runs in Deno runtime. The code must be written to a file first for version control",
|
|
1696
1857
|
{
|
|
1697
|
-
...
|
|
1698
|
-
codeFile:
|
|
1858
|
+
...uploadFunctionRequestSchema.omit({ code: true }).shape,
|
|
1859
|
+
codeFile: z23.string().describe(
|
|
1699
1860
|
"Path to JavaScript file containing the function code. Must export: module.exports = async function(request) { return new Response(...) }"
|
|
1700
1861
|
)
|
|
1701
1862
|
},
|
|
@@ -1749,11 +1910,11 @@ To: Your current project directory
|
|
|
1749
1910
|
}
|
|
1750
1911
|
})
|
|
1751
1912
|
);
|
|
1752
|
-
|
|
1913
|
+
registerTool(
|
|
1753
1914
|
"get-function",
|
|
1754
1915
|
"Get details of a specific edge function including its code",
|
|
1755
1916
|
{
|
|
1756
|
-
slug:
|
|
1917
|
+
slug: z23.string().describe("The slug identifier of the function")
|
|
1757
1918
|
},
|
|
1758
1919
|
withUsageTracking("get-function", async (args) => {
|
|
1759
1920
|
try {
|
|
@@ -1786,13 +1947,13 @@ To: Your current project directory
|
|
|
1786
1947
|
}
|
|
1787
1948
|
})
|
|
1788
1949
|
);
|
|
1789
|
-
|
|
1950
|
+
registerTool(
|
|
1790
1951
|
"update-function",
|
|
1791
1952
|
"Update an existing edge function code or metadata",
|
|
1792
1953
|
{
|
|
1793
|
-
slug:
|
|
1794
|
-
...
|
|
1795
|
-
codeFile:
|
|
1954
|
+
slug: z23.string().describe("The slug identifier of the function to update"),
|
|
1955
|
+
...updateFunctionRequestSchema.omit({ code: true }).shape,
|
|
1956
|
+
codeFile: z23.string().optional().describe(
|
|
1796
1957
|
"Path to JavaScript file containing the new function code. Must export: module.exports = async function(request) { return new Response(...) }"
|
|
1797
1958
|
)
|
|
1798
1959
|
},
|
|
@@ -1852,11 +2013,11 @@ To: Your current project directory
|
|
|
1852
2013
|
}
|
|
1853
2014
|
})
|
|
1854
2015
|
);
|
|
1855
|
-
|
|
2016
|
+
registerTool(
|
|
1856
2017
|
"delete-function",
|
|
1857
2018
|
"Delete an edge function permanently",
|
|
1858
2019
|
{
|
|
1859
|
-
slug:
|
|
2020
|
+
slug: z23.string().describe("The slug identifier of the function to delete")
|
|
1860
2021
|
},
|
|
1861
2022
|
withUsageTracking("delete-function", async (args) => {
|
|
1862
2023
|
try {
|
|
@@ -1889,13 +2050,13 @@ To: Your current project directory
|
|
|
1889
2050
|
}
|
|
1890
2051
|
})
|
|
1891
2052
|
);
|
|
1892
|
-
|
|
2053
|
+
registerTool(
|
|
1893
2054
|
"get-container-logs",
|
|
1894
2055
|
"Get latest logs from a specific container/service. Use this to help debug problems with your app.",
|
|
1895
2056
|
{
|
|
1896
|
-
apiKey:
|
|
1897
|
-
source:
|
|
1898
|
-
limit:
|
|
2057
|
+
apiKey: z23.string().optional().describe("API key for authentication (optional if provided via --api_key)"),
|
|
2058
|
+
source: z23.enum(["insforge.logs", "postgREST.logs", "postgres.logs", "function.logs"]).describe("Log source to retrieve"),
|
|
2059
|
+
limit: z23.number().optional().default(20).describe("Number of logs to return (default: 20)")
|
|
1899
2060
|
},
|
|
1900
2061
|
withUsageTracking("get-container-logs", async ({ apiKey, source, limit }) => {
|
|
1901
2062
|
try {
|
|
@@ -1939,10 +2100,148 @@ To: Your current project directory
|
|
|
1939
2100
|
}
|
|
1940
2101
|
})
|
|
1941
2102
|
);
|
|
2103
|
+
registerTool(
|
|
2104
|
+
"create-deployment",
|
|
2105
|
+
"Deploy source code from a directory. This tool zips files, uploads to cloud storage, and triggers deployment with optional environment variables and project settings.",
|
|
2106
|
+
{
|
|
2107
|
+
sourceDirectory: z23.string().describe('Absolute path to the source directory containing files to deploy (e.g., /Users/name/project or C:\\Users\\name\\project). Do not use relative paths like "."'),
|
|
2108
|
+
...startDeploymentRequestSchema.shape
|
|
2109
|
+
},
|
|
2110
|
+
withUsageTracking("create-deployment", async ({ sourceDirectory, projectSettings, envVars, meta }) => {
|
|
2111
|
+
try {
|
|
2112
|
+
const isAbsolutePath = sourceDirectory.startsWith("/") || /^[a-zA-Z]:[/\\]/.test(sourceDirectory);
|
|
2113
|
+
if (!isAbsolutePath) {
|
|
2114
|
+
return {
|
|
2115
|
+
content: [
|
|
2116
|
+
{
|
|
2117
|
+
type: "text",
|
|
2118
|
+
text: `Error: sourceDirectory must be an absolute path, not a relative path like "${sourceDirectory}". Please provide the full path to the source directory (e.g., /Users/name/project on macOS/Linux or C:\\Users\\name\\project on Windows).`
|
|
2119
|
+
}
|
|
2120
|
+
],
|
|
2121
|
+
isError: true
|
|
2122
|
+
};
|
|
2123
|
+
}
|
|
2124
|
+
try {
|
|
2125
|
+
const stats = await fs.stat(sourceDirectory);
|
|
2126
|
+
if (!stats.isDirectory()) {
|
|
2127
|
+
return {
|
|
2128
|
+
content: [
|
|
2129
|
+
{
|
|
2130
|
+
type: "text",
|
|
2131
|
+
text: `Error: "${sourceDirectory}" is not a directory. Please provide a path to a directory containing the source code.`
|
|
2132
|
+
}
|
|
2133
|
+
],
|
|
2134
|
+
isError: true
|
|
2135
|
+
};
|
|
2136
|
+
}
|
|
2137
|
+
} catch (statError) {
|
|
2138
|
+
return {
|
|
2139
|
+
content: [
|
|
2140
|
+
{
|
|
2141
|
+
type: "text",
|
|
2142
|
+
text: `Error: Directory "${sourceDirectory}" does not exist or is not accessible. Please verify the path is correct.`
|
|
2143
|
+
}
|
|
2144
|
+
],
|
|
2145
|
+
isError: true
|
|
2146
|
+
};
|
|
2147
|
+
}
|
|
2148
|
+
const resolvedSourceDir = sourceDirectory;
|
|
2149
|
+
const createResponse = await fetch2(`${API_BASE_URL}/api/deployments`, {
|
|
2150
|
+
method: "POST",
|
|
2151
|
+
headers: {
|
|
2152
|
+
"x-api-key": getApiKey(),
|
|
2153
|
+
"Content-Type": "application/json"
|
|
2154
|
+
}
|
|
2155
|
+
});
|
|
2156
|
+
const createResult = await handleApiResponse(createResponse);
|
|
2157
|
+
const { id: deploymentId, uploadUrl, uploadFields } = createResult;
|
|
2158
|
+
const zipBuffer = await new Promise((resolve, reject) => {
|
|
2159
|
+
const archive = archiver("zip", { zlib: { level: 9 } });
|
|
2160
|
+
const chunks = [];
|
|
2161
|
+
archive.on("data", (chunk) => chunks.push(chunk));
|
|
2162
|
+
archive.on("end", () => resolve(Buffer.concat(chunks)));
|
|
2163
|
+
archive.on("error", (err) => reject(err));
|
|
2164
|
+
const excludePatterns = [
|
|
2165
|
+
"node_modules",
|
|
2166
|
+
".git",
|
|
2167
|
+
".next",
|
|
2168
|
+
".env",
|
|
2169
|
+
".env.local",
|
|
2170
|
+
"dist",
|
|
2171
|
+
"build",
|
|
2172
|
+
".DS_Store"
|
|
2173
|
+
];
|
|
2174
|
+
archive.directory(resolvedSourceDir, false, (entry) => {
|
|
2175
|
+
const normalizedName = entry.name.replace(/\\/g, "/");
|
|
2176
|
+
for (const pattern of excludePatterns) {
|
|
2177
|
+
if (normalizedName.startsWith(pattern + "/") || normalizedName === pattern || normalizedName.endsWith("/" + pattern) || normalizedName.includes("/" + pattern + "/")) {
|
|
2178
|
+
return false;
|
|
2179
|
+
}
|
|
2180
|
+
}
|
|
2181
|
+
if (normalizedName.endsWith(".log")) {
|
|
2182
|
+
return false;
|
|
2183
|
+
}
|
|
2184
|
+
return entry;
|
|
2185
|
+
});
|
|
2186
|
+
archive.finalize();
|
|
2187
|
+
});
|
|
2188
|
+
const uploadFormData = new FormData();
|
|
2189
|
+
for (const [key, value] of Object.entries(uploadFields)) {
|
|
2190
|
+
uploadFormData.append(key, value);
|
|
2191
|
+
}
|
|
2192
|
+
uploadFormData.append("file", zipBuffer, {
|
|
2193
|
+
filename: "deployment.zip",
|
|
2194
|
+
contentType: "application/zip"
|
|
2195
|
+
});
|
|
2196
|
+
const uploadResponse = await fetch2(uploadUrl, {
|
|
2197
|
+
method: "POST",
|
|
2198
|
+
body: uploadFormData,
|
|
2199
|
+
headers: uploadFormData.getHeaders()
|
|
2200
|
+
});
|
|
2201
|
+
if (!uploadResponse.ok) {
|
|
2202
|
+
const uploadError = await uploadResponse.text();
|
|
2203
|
+
throw new Error(`Failed to upload zip file: ${uploadError}`);
|
|
2204
|
+
}
|
|
2205
|
+
const startBody = {};
|
|
2206
|
+
if (projectSettings) startBody.projectSettings = projectSettings;
|
|
2207
|
+
if (envVars) startBody.envVars = envVars;
|
|
2208
|
+
if (meta) startBody.meta = meta;
|
|
2209
|
+
const startResponse = await fetch2(`${API_BASE_URL}/api/deployments/${deploymentId}/start`, {
|
|
2210
|
+
method: "POST",
|
|
2211
|
+
headers: {
|
|
2212
|
+
"x-api-key": getApiKey(),
|
|
2213
|
+
"Content-Type": "application/json"
|
|
2214
|
+
},
|
|
2215
|
+
body: JSON.stringify(startBody)
|
|
2216
|
+
});
|
|
2217
|
+
const startResult = await handleApiResponse(startResponse);
|
|
2218
|
+
return await addBackgroundContext({
|
|
2219
|
+
content: [
|
|
2220
|
+
{
|
|
2221
|
+
type: "text",
|
|
2222
|
+
text: formatSuccessMessage("Deployment started", startResult) + "\n\nNote: You can check deployment status by querying the system.deployments table."
|
|
2223
|
+
}
|
|
2224
|
+
]
|
|
2225
|
+
});
|
|
2226
|
+
} catch (error) {
|
|
2227
|
+
const errMsg = error instanceof Error ? error.message : "Unknown error occurred";
|
|
2228
|
+
return {
|
|
2229
|
+
content: [
|
|
2230
|
+
{
|
|
2231
|
+
type: "text",
|
|
2232
|
+
text: `Error creating deployment: ${errMsg}`
|
|
2233
|
+
}
|
|
2234
|
+
],
|
|
2235
|
+
isError: true
|
|
2236
|
+
};
|
|
2237
|
+
}
|
|
2238
|
+
})
|
|
2239
|
+
);
|
|
1942
2240
|
return {
|
|
1943
2241
|
apiKey: GLOBAL_API_KEY,
|
|
1944
2242
|
apiBaseUrl: API_BASE_URL,
|
|
1945
|
-
toolCount
|
|
2243
|
+
toolCount,
|
|
2244
|
+
backendVersion
|
|
1946
2245
|
};
|
|
1947
2246
|
}
|
|
1948
2247
|
|