@alpic-ai/api 0.0.0-staging.8dc60a3 → 0.0.0-staging.8e09e6a

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 = [
@@ -33,7 +34,8 @@ const RESERVED_KEYS = [
33
34
  "BUILD_ARG_BUILD_COMMAND",
34
35
  "BUILD_ARG_BUILD_OUTPUT_DIR",
35
36
  "BUILD_ARG_START_COMMAND",
36
- "ALPIC_HOST"
37
+ "ALPIC_HOST",
38
+ "ALPIC_CUSTOM_DOMAINS"
37
39
  ];
38
40
  const environmentVariableSchema = z.object({
39
41
  key: z.string().min(2, "Key must be at least 2 characters").regex(/^[a-zA-Z]([a-zA-Z0-9_])+$/, "Key must start with a letter and contain only letters, numbers, and underscores").refine((key) => !RESERVED_KEYS.includes(key), "This key is reserved and cannot be used as an environment variable key"),
@@ -41,6 +43,10 @@ const environmentVariableSchema = z.object({
41
43
  isSecret: z.boolean().default(false)
42
44
  });
43
45
  const environmentVariablesSchema = z.array(environmentVariableSchema);
46
+ const updateEnvironmentVariableSchema = environmentVariableSchema.partial({
47
+ value: true,
48
+ isSecret: true
49
+ });
44
50
  const buildSettingsSchema = z.object({
45
51
  installCommand: z.string().optional(),
46
52
  buildCommand: z.string().optional(),
@@ -58,6 +64,102 @@ const transportSchema = z.enum([
58
64
  "sse",
59
65
  "streamablehttp"
60
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
+ status: z.enum([
94
+ "pass",
95
+ "fail",
96
+ "skip",
97
+ "pending"
98
+ ]),
99
+ message: z.string(),
100
+ skipReason: z.string().optional(),
101
+ severity: checkSeveritySchema,
102
+ category: checkCategorySchema,
103
+ scope: checkScopeSchema,
104
+ platforms: z.array(platformSchema).readonly().optional(),
105
+ durationMs: z.number(),
106
+ details: z.array(checkDetailSchema).optional(),
107
+ hint: z.object({ text: z.string() }).optional()
108
+ });
109
+ const auditReportSchema = z.object({
110
+ schemaVersion: z.string(),
111
+ auditId: z.string(),
112
+ targetUrl: z.string(),
113
+ startedAt: z.string(),
114
+ completedAt: z.string(),
115
+ durationMs: z.number(),
116
+ results: z.array(checkResultSchema),
117
+ requiresAuth: z.boolean(),
118
+ hasViewSupport: z.boolean(),
119
+ viewPlatforms: z.array(platformSchema).readonly().optional(),
120
+ isReadyForPlatform: z.record(platformSchema, z.boolean()),
121
+ widgetScreenshotKeys: z.object({
122
+ chatgpt: z.string().optional(),
123
+ claudeai: z.string().optional()
124
+ }).optional(),
125
+ widgetScreenshots: z.object({
126
+ chatgpt: z.object({ url: z.string() }).optional(),
127
+ claudeai: z.object({ url: z.string() }).optional()
128
+ }).optional()
129
+ });
130
+ const playgroundHeaderSchema = z.object({
131
+ name: z.string().min(1).max(100),
132
+ description: z.string().max(200),
133
+ isRequired: z.boolean().default(false),
134
+ isSecret: z.boolean().default(false)
135
+ });
136
+ const playgroundExamplePromptSchema = z.object({
137
+ title: z.string().min(1).max(100),
138
+ prompt: z.string().min(1).max(500)
139
+ });
140
+ const serverFieldsSchema = z.object({
141
+ $schema: z.string(),
142
+ name: z.string(),
143
+ description: z.string(),
144
+ version: z.string().optional(),
145
+ title: z.string().optional(),
146
+ websiteUrl: z.url().optional(),
147
+ icons: z.array(z.object({
148
+ src: z.url(),
149
+ mimeType: z.string().optional(),
150
+ sizes: z.array(z.string()).optional()
151
+ })).optional(),
152
+ remotes: z.array(z.object({
153
+ type: z.string(),
154
+ url: z.url().optional(),
155
+ headers: z.array(z.object({
156
+ name: z.string(),
157
+ description: z.string(),
158
+ isRequired: z.boolean().optional(),
159
+ isSecret: z.boolean().optional()
160
+ })).optional()
161
+ })).optional()
162
+ });
61
163
  //#endregion
62
164
  //#region src/api.contract.ts
63
165
  const deploymentStatusSchema = z.enum([
@@ -82,9 +184,16 @@ const deploymentSchema = z.object({
82
184
  authorUsername: z.string().nullable(),
83
185
  authorAvatarUrl: z.string().nullable(),
84
186
  startedAt: z.coerce.date().nullable(),
85
- completedAt: z.coerce.date().nullable()
187
+ completedAt: z.coerce.date().nullable(),
188
+ environmentId: z.string(),
189
+ environmentName: z.string(),
190
+ isCurrent: z.boolean(),
191
+ deploymentPageUrl: z.url().nullable()
86
192
  });
87
- const deploymentWithPageUrlSchema = deploymentSchema.extend({ deploymentPageUrl: z.url().nullable() });
193
+ const isValidLogTimeInput = (value) => {
194
+ if (ms(value) !== void 0) return true;
195
+ return !Number.isNaN(new Date(value).getTime());
196
+ };
88
197
  const createEnvironmentContractV1 = oc.route({
89
198
  path: "/v1/environments",
90
199
  method: "POST",
@@ -223,8 +332,61 @@ const createProjectContractV1 = oc.route({
223
332
  startCommand: z.string().nullable(),
224
333
  createdAt: z.coerce.date()
225
334
  }));
335
+ const environmentVariableOutputSchema = z.object({
336
+ id: z.string(),
337
+ key: z.string(),
338
+ value: z.string(),
339
+ isSecret: z.boolean(),
340
+ createdAt: z.coerce.date()
341
+ });
342
+ const listEnvironmentVariablesContractV1 = oc.route({
343
+ path: "/v1/environments/{environmentId}/environment-variables",
344
+ method: "GET",
345
+ summary: "List environment variables",
346
+ description: "List all environment variables for an environment",
347
+ tags: ["environments"],
348
+ successDescription: "The list of environment variables"
349
+ }).errors({ NOT_FOUND: {} }).input(z.object({ environmentId: z.string().describe("The ID of the environment") })).output(z.array(environmentVariableOutputSchema));
350
+ const createEnvironmentVariablesContractV1 = oc.route({
351
+ path: "/v1/environments/{environmentId}/environment-variables",
352
+ method: "POST",
353
+ summary: "Add environment variables",
354
+ description: "Add one or more environment variables to an environment",
355
+ tags: ["environments"],
356
+ successDescription: "The environment variables have been added successfully"
357
+ }).errors({
358
+ NOT_FOUND: {},
359
+ BAD_REQUEST: {}
360
+ }).input(z.object({
361
+ environmentId: z.string().describe("The ID of the environment"),
362
+ environmentVariables: environmentVariablesSchema
363
+ })).output(z.object({ success: z.literal(true) }));
364
+ const updateEnvironmentVariableContractV1 = oc.route({
365
+ path: "/v1/environment-variables/{environmentVariableId}",
366
+ method: "PATCH",
367
+ summary: "Update an environment variable",
368
+ description: "Update an environment variable by ID",
369
+ tags: ["environments"],
370
+ successDescription: "The environment variable has been updated successfully"
371
+ }).errors({
372
+ NOT_FOUND: {},
373
+ BAD_REQUEST: {}
374
+ }).input(z.object({
375
+ environmentVariableId: z.string().describe("The ID of the environment variable"),
376
+ key: environmentVariableSchema.shape.key,
377
+ value: environmentVariableSchema.shape.value.optional(),
378
+ isSecret: environmentVariableSchema.shape.isSecret.optional()
379
+ })).output(z.object({ success: z.literal(true) }));
380
+ const deleteEnvironmentVariableContractV1 = oc.route({
381
+ path: "/v1/environment-variables/{environmentVariableId}",
382
+ method: "DELETE",
383
+ summary: "Delete an environment variable",
384
+ description: "Delete an environment variable by ID",
385
+ tags: ["environments"],
386
+ successDescription: "The environment variable has been deleted successfully"
387
+ }).errors({ NOT_FOUND: {} }).input(z.object({ environmentVariableId: z.string().describe("The ID of the environment variable") })).output(z.object({ success: z.literal(true) }));
226
388
  const deleteProjectContractV1 = oc.route({
227
- path: "/v1/projects/:projectId",
389
+ path: "/v1/projects/{projectId}",
228
390
  method: "DELETE",
229
391
  summary: "Delete a project",
230
392
  description: "Delete a project and all its environments",
@@ -259,7 +421,7 @@ const deployEnvironmentContractV1 = oc.route({
259
421
  }).input(z.object({
260
422
  environmentId: z.string().describe("The ID of the environment to deploy"),
261
423
  token: z.string().describe("The token to identify the source archive").optional()
262
- })).output(deploymentWithPageUrlSchema);
424
+ })).output(deploymentSchema);
263
425
  const uploadDeploymentArtifactContractV1 = oc.route({
264
426
  path: "/v1/deployments/upload",
265
427
  method: "POST",
@@ -268,21 +430,22 @@ const uploadDeploymentArtifactContractV1 = oc.route({
268
430
  tags: ["deployments"],
269
431
  successDescription: "The presigned upload URL has been generated successfully"
270
432
  }).input(z.object({ teamId: z.string().optional() }).optional()).output(z.object({
271
- uploadUrl: z.string().url().describe("Presigned S3 URL to upload the source archive with HTTP PUT"),
433
+ uploadUrl: z.url().describe("Presigned S3 URL to upload the source archive with HTTP PUT"),
272
434
  token: z.string().describe("Token to identify the source archive"),
273
435
  expiresAt: z.coerce.date().describe("Expiration date of the presigned URL")
274
436
  }));
275
- const listProjectDeploymentsContractV1 = oc.route({
437
+ const listDeploymentsContractV1 = oc.route({
276
438
  path: "/v1/projects/{projectId}/deployments",
277
439
  method: "GET",
278
440
  summary: "List project deployments",
279
441
  description: "List all deployments for a project",
280
442
  tags: ["deployments"],
281
443
  successDescription: "The list of deployments"
282
- }).errors({ NOT_FOUND: {} }).input(z.object({ projectId: z.string().describe("The ID of the project") })).output(z.array(deploymentSchema.extend({
283
- isCurrent: z.boolean(),
284
- environmentId: z.string()
285
- })));
444
+ }).errors({ NOT_FOUND: {} }).input(z.object({
445
+ projectId: z.string().describe("The ID of the project"),
446
+ status: z.array(deploymentStatusSchema).optional().describe("Filter by one or more statuses"),
447
+ environmentId: z.string().optional().describe("Filter by environment ID")
448
+ })).output(z.array(deploymentSchema));
286
449
  const getDeploymentContractV1 = oc.route({
287
450
  path: "/v1/deployments/{deploymentId}",
288
451
  method: "GET",
@@ -290,7 +453,48 @@ const getDeploymentContractV1 = oc.route({
290
453
  description: "Get a deployment by ID",
291
454
  tags: ["deployments"],
292
455
  successDescription: "The deployment details"
293
- }).errors({ NOT_FOUND: {} }).input(z.object({ deploymentId: z.string().describe("The ID of the deployment") })).output(deploymentWithPageUrlSchema);
456
+ }).errors({ NOT_FOUND: {} }).input(z.object({ deploymentId: z.string().describe("The ID of the deployment") })).output(deploymentSchema);
457
+ const getLogsContractV1 = oc.route({
458
+ path: "/v1/environments/{environmentId}/logs",
459
+ method: "GET",
460
+ summary: "Get logs",
461
+ description: "Get logs for an environment",
462
+ tags: ["environments"],
463
+ successDescription: "The logs"
464
+ }).errors({
465
+ NOT_FOUND: {},
466
+ BAD_REQUEST: {}
467
+ }).input(z.object({
468
+ environmentId: z.string().describe("The ID of the environment"),
469
+ 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)"),
470
+ 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"),
471
+ limit: z.coerce.number().int().min(1).max(1e3).default(1e3).describe("Maximum number of log entries to return."),
472
+ level: z.array(z.enum([
473
+ "INFO",
474
+ "ERROR",
475
+ "WARNING",
476
+ "DEBUG"
477
+ ])).optional().describe("Filter by log level"),
478
+ search: z.string().optional().describe("Filter pattern to search for in log content"),
479
+ nextToken: z.string().optional().describe("Pagination token from a previous response")
480
+ })).output(z.object({
481
+ logs: z.array(z.object({
482
+ timestamp: z.coerce.date(),
483
+ type: z.enum([
484
+ "START",
485
+ "END",
486
+ "INFO",
487
+ "ERROR",
488
+ "WARNING",
489
+ "DEBUG"
490
+ ]),
491
+ requestId: z.string(),
492
+ content: z.string().optional(),
493
+ method: z.string().optional(),
494
+ durationInMs: z.number().optional()
495
+ })),
496
+ nextToken: z.string().nullable()
497
+ }));
294
498
  const getDeploymentLogsContractV1 = oc.route({
295
499
  path: "/v1/deployments/{deploymentId}/logs",
296
500
  method: "GET",
@@ -368,11 +572,115 @@ const getTunnelTicketContractV1 = oc.route({
368
572
  ticket: z.string().describe("The signed tunnel ticket"),
369
573
  tunnelHost: z.string().describe("The tunnel host to connect to")
370
574
  }));
575
+ const publishServerContractV1 = oc.route({
576
+ path: "/v1/distribution/publish",
577
+ method: "POST",
578
+ summary: "Publish a server to the MCP registry",
579
+ tags: ["distribution"],
580
+ successDescription: "The server has been published successfully"
581
+ }).errors({
582
+ NOT_FOUND: {},
583
+ BAD_REQUEST: {}
584
+ }).input(z.object({
585
+ projectId: z.string(),
586
+ domain: z.string(),
587
+ title: z.string().min(1).max(100),
588
+ description: z.string().min(1).max(100),
589
+ websiteUrl: z.url().max(255).optional(),
590
+ iconSrc: z.url().max(255).optional(),
591
+ dryRun: z.boolean().optional()
592
+ })).output(z.object({ serverFields: serverFieldsSchema }));
593
+ const getServerInfoContractV1 = oc.route({
594
+ path: "/v1/distribution/get",
595
+ method: "GET",
596
+ summary: "Get server info",
597
+ description: "Get info about a server",
598
+ tags: ["distribution"],
599
+ successDescription: "The server info"
600
+ }).errors({
601
+ NOT_FOUND: {},
602
+ BAD_REQUEST: {}
603
+ }).input(z.object({
604
+ projectId: z.string(),
605
+ domain: z.string()
606
+ })).output(z.object({ serverFields: serverFieldsSchema }));
607
+ const playgroundServerMetadataOutputSchema = z.object({
608
+ name: z.string(),
609
+ description: z.string(),
610
+ headers: z.array(z.object({
611
+ name: z.string(),
612
+ description: z.string(),
613
+ isRequired: z.boolean(),
614
+ isSecret: z.boolean()
615
+ })),
616
+ examplePrompts: z.array(playgroundExamplePromptSchema)
617
+ });
618
+ const playgroundOutputSchema = z.object({
619
+ isPlaygroundEnabled: z.boolean(),
620
+ serverMetadata: playgroundServerMetadataOutputSchema.nullable()
621
+ });
622
+ const getPlaygroundContractV1 = oc.route({
623
+ path: "/v1/environments/{environmentId}/playground",
624
+ method: "GET",
625
+ summary: "Get playground configuration",
626
+ description: "Get the playground configuration for an environment",
627
+ tags: ["environments"],
628
+ successDescription: "The playground configuration"
629
+ }).errors({ NOT_FOUND: {} }).input(z.object({ environmentId: z.string().describe("The ID of the environment") })).output(playgroundOutputSchema);
630
+ const upsertPlaygroundContractV1 = oc.route({
631
+ path: "/v1/environments/{environmentId}/playground",
632
+ method: "PUT",
633
+ summary: "Update playground configuration",
634
+ description: "Update the playground configuration for an environment. All fields are optional — only provided fields are updated.",
635
+ tags: ["environments"],
636
+ successDescription: "The updated playground configuration"
637
+ }).errors({
638
+ NOT_FOUND: {},
639
+ BAD_REQUEST: {}
640
+ }).input(z.object({
641
+ environmentId: z.string().describe("The ID of the environment"),
642
+ isPlaygroundEnabled: z.boolean().optional(),
643
+ name: z.string().min(1).max(100).optional(),
644
+ description: z.string().min(1).max(500).optional(),
645
+ headers: z.array(playgroundHeaderSchema).optional(),
646
+ examplePrompts: z.array(playgroundExamplePromptSchema).max(3).optional()
647
+ })).output(playgroundOutputSchema);
648
+ const createBeaconContractV1 = oc.route({
649
+ path: "/v1/beacon/audits",
650
+ method: "POST",
651
+ summary: "Create a beacon audit",
652
+ description: "Audit an MCP server for spec compliance and AI client compatibility",
653
+ tags: ["beacon"],
654
+ successDescription: "The audit has been created"
655
+ }).errors({
656
+ NOT_FOUND: {},
657
+ BAD_REQUEST: {}
658
+ }).input(z.object({
659
+ targetUrl: z.string().url().describe("The HTTPS URL of the MCP server to audit"),
660
+ teamId: z.string().optional().describe("The team ID to associate the audit with"),
661
+ projectId: z.string().optional().describe("The project ID to associate the audit with"),
662
+ excludeCategories: z.array(checkCategorySchema).optional().describe("Check categories to exclude from the audit")
663
+ })).output(z.object({ id: z.string() }));
664
+ const getBeaconContractV1 = oc.route({
665
+ path: "/v1/beacon/audits/{auditId}",
666
+ method: "GET",
667
+ summary: "Get a beacon audit",
668
+ description: "Get a beacon audit by ID, including the report if completed",
669
+ tags: ["beacon"],
670
+ successDescription: "The audit details"
671
+ }).errors({ NOT_FOUND: {} }).input(z.object({ auditId: z.string().describe("The ID of the audit") })).output(z.object({
672
+ id: z.string(),
673
+ targetUrl: z.string(),
674
+ status: auditStatusSchema,
675
+ durationMs: z.number().nullable(),
676
+ createdAt: z.coerce.date(),
677
+ report: auditReportSchema.nullable()
678
+ }));
371
679
  const contract = {
372
680
  teams: { list: { v1: listTeamsContractV1 } },
373
681
  analytics: { get: { v1: getProjectAnalyticsContractV1 } },
374
682
  deployments: {
375
- list: { v1: listProjectDeploymentsContractV1 },
683
+ list: { v1: listDeploymentsContractV1 },
376
684
  get: { v1: getDeploymentContractV1 },
377
685
  uploadArtifact: { v1: uploadDeploymentArtifactContractV1 },
378
686
  getLogs: { v1: getDeploymentLogsContractV1 }
@@ -380,7 +688,14 @@ const contract = {
380
688
  environments: {
381
689
  create: { v1: createEnvironmentContractV1 },
382
690
  get: { v1: getEnvironmentContractV1 },
383
- deploy: { v1: deployEnvironmentContractV1 }
691
+ deploy: { v1: deployEnvironmentContractV1 },
692
+ getLogs: { v1: getLogsContractV1 }
693
+ },
694
+ environmentVariables: {
695
+ list: { v1: listEnvironmentVariablesContractV1 },
696
+ create: { v1: createEnvironmentVariablesContractV1 },
697
+ update: { v1: updateEnvironmentVariableContractV1 },
698
+ delete: { v1: deleteEnvironmentVariableContractV1 }
384
699
  },
385
700
  projects: {
386
701
  update: { v1: updateProjectContractV1 },
@@ -389,7 +704,19 @@ const contract = {
389
704
  create: { v1: createProjectContractV1 },
390
705
  delete: { v1: deleteProjectContractV1 }
391
706
  },
392
- tunnels: { getTicket: { v1: getTunnelTicketContractV1 } }
707
+ playground: {
708
+ get: { v1: getPlaygroundContractV1 },
709
+ upsert: { v1: upsertPlaygroundContractV1 }
710
+ },
711
+ tunnels: { getTicket: { v1: getTunnelTicketContractV1 } },
712
+ distribution: {
713
+ publish: { v1: publishServerContractV1 },
714
+ get: { v1: getServerInfoContractV1 }
715
+ },
716
+ beacon: {
717
+ create: { v1: createBeaconContractV1 },
718
+ get: { v1: getBeaconContractV1 }
719
+ }
393
720
  };
394
721
  //#endregion
395
- export { buildSettingsSchema, contract, createEnvironmentContractV1, environmentVariableSchema, environmentVariablesSchema, runtimeSchema, transportSchema };
722
+ 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.8dc60a3",
3
+ "version": "0.0.0-staging.8e09e6a",
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.13",
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.7",
29
+ "typescript": "^6.0.2",
30
+ "vitest": "^4.1.3"
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
  }