@alpic-ai/api 0.0.0-staging.5d6044c → 0.0.0-staging.5e6792e

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/dist/index.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import { oc } from "@orpc/contract";
2
+ import ms from "ms";
2
3
  import { z } from "zod";
3
4
  //#region src/schemas.ts
4
5
  const RESERVED_KEYS = [
@@ -42,6 +43,10 @@ const environmentVariableSchema = z.object({
42
43
  isSecret: z.boolean().default(false)
43
44
  });
44
45
  const environmentVariablesSchema = z.array(environmentVariableSchema);
46
+ const updateEnvironmentVariableSchema = environmentVariableSchema.partial({
47
+ value: true,
48
+ isSecret: true
49
+ });
45
50
  const buildSettingsSchema = z.object({
46
51
  installCommand: z.string().optional(),
47
52
  buildCommand: z.string().optional(),
@@ -59,6 +64,104 @@ const transportSchema = z.enum([
59
64
  "sse",
60
65
  "streamablehttp"
61
66
  ]);
67
+ const auditStatusSchema = z.enum([
68
+ "pending",
69
+ "partial",
70
+ "completed",
71
+ "failed"
72
+ ]);
73
+ const platformSchema = z.enum(["chatgpt", "claudeai"]);
74
+ const checkSeveritySchema = z.enum([
75
+ "error",
76
+ "warning",
77
+ "info"
78
+ ]);
79
+ const checkCategorySchema = z.enum([
80
+ "connectivity",
81
+ "tool-metadata",
82
+ "resource-metadata",
83
+ "performance",
84
+ "e2e"
85
+ ]);
86
+ const checkScopeSchema = z.enum(["server", "view"]);
87
+ const checkDetailSchema = z.object({
88
+ label: z.string(),
89
+ value: z.string().optional()
90
+ });
91
+ const checkResultSchema = z.object({
92
+ checkId: z.string(),
93
+ checkName: z.string(),
94
+ description: z.string(),
95
+ status: z.enum([
96
+ "pass",
97
+ "fail",
98
+ "skip",
99
+ "pending"
100
+ ]),
101
+ message: z.string(),
102
+ skipReason: z.string().optional(),
103
+ severity: checkSeveritySchema,
104
+ category: checkCategorySchema,
105
+ scope: checkScopeSchema,
106
+ platforms: z.array(platformSchema).readonly().optional(),
107
+ durationMs: z.number(),
108
+ details: z.array(checkDetailSchema).optional(),
109
+ hint: z.object({ text: z.string() }).optional()
110
+ });
111
+ const auditReportSchema = z.object({
112
+ schemaVersion: z.string(),
113
+ auditId: z.string(),
114
+ targetUrl: z.string(),
115
+ startedAt: z.string(),
116
+ completedAt: z.string(),
117
+ durationMs: z.number(),
118
+ results: z.array(checkResultSchema),
119
+ requiresAuth: z.boolean(),
120
+ hasViewSupport: z.boolean(),
121
+ viewPlatforms: z.array(platformSchema).readonly().optional(),
122
+ isReadyForPlatform: z.record(platformSchema, z.boolean()),
123
+ widgetScreenshotKeys: z.object({
124
+ chatgpt: z.string().optional(),
125
+ claudeai: z.string().optional()
126
+ }).optional(),
127
+ widgetScreenshots: z.object({
128
+ chatgpt: z.object({ url: z.string() }).optional(),
129
+ claudeai: z.object({ url: z.string() }).optional()
130
+ }).optional()
131
+ });
132
+ const playgroundHeaderSchema = z.object({
133
+ name: z.string().min(1).max(100),
134
+ description: z.string().max(200),
135
+ isRequired: z.boolean().default(false),
136
+ isSecret: z.boolean().default(false)
137
+ });
138
+ const playgroundExamplePromptSchema = z.object({
139
+ title: z.string().min(1).max(100),
140
+ prompt: z.string().min(1).max(500)
141
+ });
142
+ const serverFieldsSchema = z.object({
143
+ $schema: z.string(),
144
+ name: z.string(),
145
+ description: z.string(),
146
+ version: z.string().optional(),
147
+ title: z.string().optional(),
148
+ websiteUrl: z.url().optional(),
149
+ icons: z.array(z.object({
150
+ src: z.url(),
151
+ mimeType: z.string().optional(),
152
+ sizes: z.array(z.string()).optional()
153
+ })).optional(),
154
+ remotes: z.array(z.object({
155
+ type: z.string(),
156
+ url: z.url().optional(),
157
+ headers: z.array(z.object({
158
+ name: z.string(),
159
+ description: z.string(),
160
+ isRequired: z.boolean().optional(),
161
+ isSecret: z.boolean().optional()
162
+ })).optional()
163
+ })).optional()
164
+ });
62
165
  //#endregion
63
166
  //#region src/api.contract.ts
64
167
  const deploymentStatusSchema = z.enum([
@@ -83,9 +186,16 @@ const deploymentSchema = z.object({
83
186
  authorUsername: z.string().nullable(),
84
187
  authorAvatarUrl: z.string().nullable(),
85
188
  startedAt: z.coerce.date().nullable(),
86
- completedAt: z.coerce.date().nullable()
189
+ completedAt: z.coerce.date().nullable(),
190
+ environmentId: z.string(),
191
+ environmentName: z.string(),
192
+ isCurrent: z.boolean(),
193
+ deploymentPageUrl: z.url().nullable()
87
194
  });
88
- const deploymentWithPageUrlSchema = deploymentSchema.extend({ deploymentPageUrl: z.url().nullable() });
195
+ const isValidLogTimeInput = (value) => {
196
+ if (ms(value) !== void 0) return true;
197
+ return !Number.isNaN(new Date(value).getTime());
198
+ };
89
199
  const createEnvironmentContractV1 = oc.route({
90
200
  path: "/v1/environments",
91
201
  method: "POST",
@@ -267,7 +377,7 @@ const updateEnvironmentVariableContractV1 = oc.route({
267
377
  environmentVariableId: z.string().describe("The ID of the environment variable"),
268
378
  key: environmentVariableSchema.shape.key,
269
379
  value: environmentVariableSchema.shape.value.optional(),
270
- isSecret: environmentVariableSchema.shape.isSecret
380
+ isSecret: environmentVariableSchema.shape.isSecret.optional()
271
381
  })).output(z.object({ success: z.literal(true) }));
272
382
  const deleteEnvironmentVariableContractV1 = oc.route({
273
383
  path: "/v1/environment-variables/{environmentVariableId}",
@@ -278,7 +388,7 @@ const deleteEnvironmentVariableContractV1 = oc.route({
278
388
  successDescription: "The environment variable has been deleted successfully"
279
389
  }).errors({ NOT_FOUND: {} }).input(z.object({ environmentVariableId: z.string().describe("The ID of the environment variable") })).output(z.object({ success: z.literal(true) }));
280
390
  const deleteProjectContractV1 = oc.route({
281
- path: "/v1/projects/:projectId",
391
+ path: "/v1/projects/{projectId}",
282
392
  method: "DELETE",
283
393
  summary: "Delete a project",
284
394
  description: "Delete a project and all its environments",
@@ -313,7 +423,7 @@ const deployEnvironmentContractV1 = oc.route({
313
423
  }).input(z.object({
314
424
  environmentId: z.string().describe("The ID of the environment to deploy"),
315
425
  token: z.string().describe("The token to identify the source archive").optional()
316
- })).output(deploymentWithPageUrlSchema);
426
+ })).output(deploymentSchema);
317
427
  const uploadDeploymentArtifactContractV1 = oc.route({
318
428
  path: "/v1/deployments/upload",
319
429
  method: "POST",
@@ -322,21 +432,22 @@ const uploadDeploymentArtifactContractV1 = oc.route({
322
432
  tags: ["deployments"],
323
433
  successDescription: "The presigned upload URL has been generated successfully"
324
434
  }).input(z.object({ teamId: z.string().optional() }).optional()).output(z.object({
325
- uploadUrl: z.string().url().describe("Presigned S3 URL to upload the source archive with HTTP PUT"),
435
+ uploadUrl: z.url().describe("Presigned S3 URL to upload the source archive with HTTP PUT"),
326
436
  token: z.string().describe("Token to identify the source archive"),
327
437
  expiresAt: z.coerce.date().describe("Expiration date of the presigned URL")
328
438
  }));
329
- const listProjectDeploymentsContractV1 = oc.route({
439
+ const listDeploymentsContractV1 = oc.route({
330
440
  path: "/v1/projects/{projectId}/deployments",
331
441
  method: "GET",
332
442
  summary: "List project deployments",
333
443
  description: "List all deployments for a project",
334
444
  tags: ["deployments"],
335
445
  successDescription: "The list of deployments"
336
- }).errors({ NOT_FOUND: {} }).input(z.object({ projectId: z.string().describe("The ID of the project") })).output(z.array(deploymentSchema.extend({
337
- isCurrent: z.boolean(),
338
- environmentId: z.string()
339
- })));
446
+ }).errors({ NOT_FOUND: {} }).input(z.object({
447
+ projectId: z.string().describe("The ID of the project"),
448
+ status: z.array(deploymentStatusSchema).optional().describe("Filter by one or more statuses"),
449
+ environmentId: z.string().optional().describe("Filter by environment ID")
450
+ })).output(z.array(deploymentSchema));
340
451
  const getDeploymentContractV1 = oc.route({
341
452
  path: "/v1/deployments/{deploymentId}",
342
453
  method: "GET",
@@ -344,7 +455,83 @@ const getDeploymentContractV1 = oc.route({
344
455
  description: "Get a deployment by ID",
345
456
  tags: ["deployments"],
346
457
  successDescription: "The deployment details"
347
- }).errors({ NOT_FOUND: {} }).input(z.object({ deploymentId: z.string().describe("The ID of the deployment") })).output(deploymentWithPageUrlSchema);
458
+ }).errors({ NOT_FOUND: {} }).input(z.object({ deploymentId: z.string().describe("The ID of the deployment") })).output(deploymentSchema);
459
+ const getLogsContractV1 = oc.route({
460
+ path: "/v1/environments/{environmentId}/logs",
461
+ method: "GET",
462
+ summary: "Get logs",
463
+ description: "Get logs for an environment",
464
+ tags: ["environments"],
465
+ successDescription: "The logs"
466
+ }).errors({
467
+ NOT_FOUND: {},
468
+ BAD_REQUEST: {}
469
+ }).input(z.object({
470
+ environmentId: z.string().describe("The ID of the environment"),
471
+ since: z.string().refine(isValidLogTimeInput, { message: "Invalid time. Use relative (1h, 30m, 2d) or ISO 8601 format." }).optional().describe("Start time — ISO 8601 (2024-01-01T00:00:00Z) or relative (1h, 30m, 2d)"),
472
+ until: z.string().refine(isValidLogTimeInput, { message: "Invalid time. Use relative (1h, 30m, 2d) or ISO 8601 format." }).optional().describe("End time — ISO 8601 or relative"),
473
+ limit: z.coerce.number().int().min(1).max(1e3).default(1e3).describe("Maximum number of log entries to return."),
474
+ level: z.array(z.enum([
475
+ "INFO",
476
+ "ERROR",
477
+ "WARNING",
478
+ "DEBUG"
479
+ ])).optional().describe("Filter by log level"),
480
+ search: z.string().optional().describe("Filter pattern to search for in log content"),
481
+ nextToken: z.string().optional().describe("Pagination token from a previous response")
482
+ })).output(z.object({
483
+ logs: z.array(z.object({
484
+ timestamp: z.coerce.date(),
485
+ type: z.enum([
486
+ "START",
487
+ "END",
488
+ "INFO",
489
+ "ERROR",
490
+ "WARNING",
491
+ "DEBUG"
492
+ ]),
493
+ requestId: z.string(),
494
+ content: z.string().optional(),
495
+ method: z.string().optional(),
496
+ durationInMs: z.number().optional()
497
+ })),
498
+ nextToken: z.string().nullable()
499
+ }));
500
+ const getLatestLogsContractV1 = oc.route({
501
+ path: "/v1/environments/{environmentId}/latest-logs",
502
+ method: "GET",
503
+ summary: "Get latest logs",
504
+ description: "Get the N most recent logs for an environment",
505
+ tags: ["environments"],
506
+ successDescription: "The latest logs"
507
+ }).errors({
508
+ NOT_FOUND: {},
509
+ BAD_REQUEST: {}
510
+ }).input(z.object({
511
+ environmentId: z.string().describe("The ID of the environment"),
512
+ limit: z.coerce.number().int().min(1).max(1e3).default(100).describe("Number of most recent log entries to return"),
513
+ level: z.array(z.enum([
514
+ "INFO",
515
+ "ERROR",
516
+ "WARNING",
517
+ "DEBUG"
518
+ ])).optional().describe("Filter by log level"),
519
+ search: z.string().optional().describe("Filter pattern to search for in log content")
520
+ })).output(z.object({ logs: z.array(z.object({
521
+ timestamp: z.coerce.date(),
522
+ type: z.enum([
523
+ "START",
524
+ "END",
525
+ "INFO",
526
+ "ERROR",
527
+ "WARNING",
528
+ "DEBUG"
529
+ ]),
530
+ requestId: z.string(),
531
+ content: z.string().optional(),
532
+ method: z.string().optional(),
533
+ durationInMs: z.number().optional()
534
+ })) }));
348
535
  const getDeploymentLogsContractV1 = oc.route({
349
536
  path: "/v1/deployments/{deploymentId}/logs",
350
537
  method: "GET",
@@ -422,11 +609,115 @@ const getTunnelTicketContractV1 = oc.route({
422
609
  ticket: z.string().describe("The signed tunnel ticket"),
423
610
  tunnelHost: z.string().describe("The tunnel host to connect to")
424
611
  }));
612
+ const publishServerContractV1 = oc.route({
613
+ path: "/v1/distribution/publish",
614
+ method: "POST",
615
+ summary: "Publish a server to the MCP registry",
616
+ tags: ["distribution"],
617
+ successDescription: "The server has been published successfully"
618
+ }).errors({
619
+ NOT_FOUND: {},
620
+ BAD_REQUEST: {}
621
+ }).input(z.object({
622
+ projectId: z.string(),
623
+ domain: z.string(),
624
+ title: z.string().min(1).max(100),
625
+ description: z.string().min(1).max(100),
626
+ websiteUrl: z.url().max(255).optional(),
627
+ iconSrc: z.url().max(255).optional(),
628
+ dryRun: z.boolean().optional()
629
+ })).output(z.object({ serverFields: serverFieldsSchema }));
630
+ const getServerInfoContractV1 = oc.route({
631
+ path: "/v1/distribution/get",
632
+ method: "GET",
633
+ summary: "Get server info",
634
+ description: "Get info about a server",
635
+ tags: ["distribution"],
636
+ successDescription: "The server info"
637
+ }).errors({
638
+ NOT_FOUND: {},
639
+ BAD_REQUEST: {}
640
+ }).input(z.object({
641
+ projectId: z.string(),
642
+ domain: z.string()
643
+ })).output(z.object({ serverFields: serverFieldsSchema }));
644
+ const playgroundServerMetadataOutputSchema = z.object({
645
+ name: z.string(),
646
+ description: z.string(),
647
+ headers: z.array(z.object({
648
+ name: z.string(),
649
+ description: z.string(),
650
+ isRequired: z.boolean(),
651
+ isSecret: z.boolean()
652
+ })),
653
+ examplePrompts: z.array(playgroundExamplePromptSchema)
654
+ });
655
+ const playgroundOutputSchema = z.object({
656
+ isPlaygroundEnabled: z.boolean(),
657
+ serverMetadata: playgroundServerMetadataOutputSchema.nullable()
658
+ });
659
+ const getPlaygroundContractV1 = oc.route({
660
+ path: "/v1/environments/{environmentId}/playground",
661
+ method: "GET",
662
+ summary: "Get playground configuration",
663
+ description: "Get the playground configuration for an environment",
664
+ tags: ["environments"],
665
+ successDescription: "The playground configuration"
666
+ }).errors({ NOT_FOUND: {} }).input(z.object({ environmentId: z.string().describe("The ID of the environment") })).output(playgroundOutputSchema);
667
+ const upsertPlaygroundContractV1 = oc.route({
668
+ path: "/v1/environments/{environmentId}/playground",
669
+ method: "PUT",
670
+ summary: "Update playground configuration",
671
+ description: "Update the playground configuration for an environment. All fields are optional — only provided fields are updated.",
672
+ tags: ["environments"],
673
+ successDescription: "The updated playground configuration"
674
+ }).errors({
675
+ NOT_FOUND: {},
676
+ BAD_REQUEST: {}
677
+ }).input(z.object({
678
+ environmentId: z.string().describe("The ID of the environment"),
679
+ isPlaygroundEnabled: z.boolean().optional(),
680
+ name: z.string().min(1).max(100).optional(),
681
+ description: z.string().min(1).max(500).optional(),
682
+ headers: z.array(playgroundHeaderSchema).optional(),
683
+ examplePrompts: z.array(playgroundExamplePromptSchema).max(3).optional()
684
+ })).output(playgroundOutputSchema);
685
+ const createBeaconContractV1 = oc.route({
686
+ path: "/v1/beacon/audits",
687
+ method: "POST",
688
+ summary: "Create a beacon audit",
689
+ description: "Audit an MCP server for spec compliance and AI client compatibility",
690
+ tags: ["beacon"],
691
+ successDescription: "The audit has been created"
692
+ }).errors({
693
+ NOT_FOUND: {},
694
+ BAD_REQUEST: {}
695
+ }).input(z.object({
696
+ targetUrl: z.string().url().describe("The HTTPS URL of the MCP server to audit"),
697
+ teamId: z.string().optional().describe("The team ID to associate the audit with"),
698
+ projectId: z.string().optional().describe("The project ID to associate the audit with"),
699
+ excludeCategories: z.array(checkCategorySchema).optional().describe("Check categories to exclude from the audit")
700
+ })).output(z.object({ id: z.string() }));
701
+ const getBeaconContractV1 = oc.route({
702
+ path: "/v1/beacon/audits/{auditId}",
703
+ method: "GET",
704
+ summary: "Get a beacon audit",
705
+ description: "Get a beacon audit by ID, including the report if completed",
706
+ tags: ["beacon"],
707
+ successDescription: "The audit details"
708
+ }).errors({ NOT_FOUND: {} }).input(z.object({ auditId: z.string().describe("The ID of the audit") })).output(z.object({
709
+ id: z.string(),
710
+ targetUrl: z.string(),
711
+ status: auditStatusSchema,
712
+ durationMs: z.number().nullable(),
713
+ createdAt: z.coerce.date(),
714
+ report: auditReportSchema.nullable()
715
+ }));
425
716
  const contract = {
426
717
  teams: { list: { v1: listTeamsContractV1 } },
427
718
  analytics: { get: { v1: getProjectAnalyticsContractV1 } },
428
719
  deployments: {
429
- list: { v1: listProjectDeploymentsContractV1 },
720
+ list: { v1: listDeploymentsContractV1 },
430
721
  get: { v1: getDeploymentContractV1 },
431
722
  uploadArtifact: { v1: uploadDeploymentArtifactContractV1 },
432
723
  getLogs: { v1: getDeploymentLogsContractV1 }
@@ -434,7 +725,9 @@ const contract = {
434
725
  environments: {
435
726
  create: { v1: createEnvironmentContractV1 },
436
727
  get: { v1: getEnvironmentContractV1 },
437
- deploy: { v1: deployEnvironmentContractV1 }
728
+ deploy: { v1: deployEnvironmentContractV1 },
729
+ getLogs: { v1: getLogsContractV1 },
730
+ getLatestLogs: { v1: getLatestLogsContractV1 }
438
731
  },
439
732
  environmentVariables: {
440
733
  list: { v1: listEnvironmentVariablesContractV1 },
@@ -449,7 +742,19 @@ const contract = {
449
742
  create: { v1: createProjectContractV1 },
450
743
  delete: { v1: deleteProjectContractV1 }
451
744
  },
452
- tunnels: { getTicket: { v1: getTunnelTicketContractV1 } }
745
+ playground: {
746
+ get: { v1: getPlaygroundContractV1 },
747
+ upsert: { v1: upsertPlaygroundContractV1 }
748
+ },
749
+ tunnels: { getTicket: { v1: getTunnelTicketContractV1 } },
750
+ distribution: {
751
+ publish: { v1: publishServerContractV1 },
752
+ get: { v1: getServerInfoContractV1 }
753
+ },
754
+ beacon: {
755
+ create: { v1: createBeaconContractV1 },
756
+ get: { v1: getBeaconContractV1 }
757
+ }
453
758
  };
454
759
  //#endregion
455
- export { buildSettingsSchema, contract, createEnvironmentContractV1, environmentVariableSchema, environmentVariablesSchema, runtimeSchema, transportSchema };
760
+ export { auditReportSchema, auditStatusSchema, buildSettingsSchema, checkCategorySchema, checkDetailSchema, checkResultSchema, contract, createEnvironmentContractV1, deploymentStatusSchema, environmentVariableSchema, environmentVariablesSchema, platformSchema, playgroundExamplePromptSchema, playgroundHeaderSchema, runtimeSchema, serverFieldsSchema, transportSchema, updateEnvironmentVariableSchema };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alpic-ai/api",
3
- "version": "0.0.0-staging.5d6044c",
3
+ "version": "0.0.0-staging.5e6792e",
4
4
  "description": "Contract for the Alpic API",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",
@@ -17,22 +17,25 @@
17
17
  "author": "Alpic",
18
18
  "license": "ISC",
19
19
  "dependencies": {
20
- "@orpc/contract": "^1.13.6",
20
+ "@orpc/contract": "^1.13.14",
21
+ "ms": "^2.1.3",
21
22
  "zod": "^4.3.6"
22
23
  },
23
24
  "devDependencies": {
24
25
  "@total-typescript/tsconfig": "^1.0.4",
26
+ "@types/ms": "^2.1.0",
25
27
  "shx": "^0.4.0",
26
- "tsdown": "^0.21.1",
27
- "typescript": "^5.9.3",
28
- "vitest": "^4.0.18"
28
+ "tsdown": "^0.21.8",
29
+ "typescript": "^6.0.2",
30
+ "vitest": "^4.1.4"
29
31
  },
30
32
  "scripts": {
31
33
  "build": "shx rm -rf dist && tsdown",
32
- "format": "biome check --write --error-on-warnings",
34
+ "format": "biome check --write --error-on-warnings .",
33
35
  "test": "pnpm run test:unit && pnpm run test:type && pnpm run test:format",
34
36
  "test:unit": "vitest run",
35
- "test:format": "prettier --check .",
36
- "test:type": "tsc --noEmit"
37
+ "test:format": "biome check --error-on-warnings .",
38
+ "test:type": "tsc --noEmit",
39
+ "publish:npm": "pnpm publish --tag \"${NPM_TAG}\" --access public --no-git-checks"
37
40
  }
38
41
  }