@alpic-ai/api 0.0.0-staging.4e5172b → 0.0.0-staging.4f81e5f

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,102 @@ 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
+ 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
+ });
62
163
  //#endregion
63
164
  //#region src/api.contract.ts
64
165
  const deploymentStatusSchema = z.enum([
@@ -83,9 +184,16 @@ const deploymentSchema = z.object({
83
184
  authorUsername: z.string().nullable(),
84
185
  authorAvatarUrl: z.string().nullable(),
85
186
  startedAt: z.coerce.date().nullable(),
86
- 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()
87
192
  });
88
- 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
+ };
89
197
  const createEnvironmentContractV1 = oc.route({
90
198
  path: "/v1/environments",
91
199
  method: "POST",
@@ -267,7 +375,7 @@ const updateEnvironmentVariableContractV1 = oc.route({
267
375
  environmentVariableId: z.string().describe("The ID of the environment variable"),
268
376
  key: environmentVariableSchema.shape.key,
269
377
  value: environmentVariableSchema.shape.value.optional(),
270
- isSecret: environmentVariableSchema.shape.isSecret
378
+ isSecret: environmentVariableSchema.shape.isSecret.optional()
271
379
  })).output(z.object({ success: z.literal(true) }));
272
380
  const deleteEnvironmentVariableContractV1 = oc.route({
273
381
  path: "/v1/environment-variables/{environmentVariableId}",
@@ -278,7 +386,7 @@ const deleteEnvironmentVariableContractV1 = oc.route({
278
386
  successDescription: "The environment variable has been deleted successfully"
279
387
  }).errors({ NOT_FOUND: {} }).input(z.object({ environmentVariableId: z.string().describe("The ID of the environment variable") })).output(z.object({ success: z.literal(true) }));
280
388
  const deleteProjectContractV1 = oc.route({
281
- path: "/v1/projects/:projectId",
389
+ path: "/v1/projects/{projectId}",
282
390
  method: "DELETE",
283
391
  summary: "Delete a project",
284
392
  description: "Delete a project and all its environments",
@@ -313,7 +421,7 @@ const deployEnvironmentContractV1 = oc.route({
313
421
  }).input(z.object({
314
422
  environmentId: z.string().describe("The ID of the environment to deploy"),
315
423
  token: z.string().describe("The token to identify the source archive").optional()
316
- })).output(deploymentWithPageUrlSchema);
424
+ })).output(deploymentSchema);
317
425
  const uploadDeploymentArtifactContractV1 = oc.route({
318
426
  path: "/v1/deployments/upload",
319
427
  method: "POST",
@@ -322,21 +430,22 @@ const uploadDeploymentArtifactContractV1 = oc.route({
322
430
  tags: ["deployments"],
323
431
  successDescription: "The presigned upload URL has been generated successfully"
324
432
  }).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"),
433
+ uploadUrl: z.url().describe("Presigned S3 URL to upload the source archive with HTTP PUT"),
326
434
  token: z.string().describe("Token to identify the source archive"),
327
435
  expiresAt: z.coerce.date().describe("Expiration date of the presigned URL")
328
436
  }));
329
- const listProjectDeploymentsContractV1 = oc.route({
437
+ const listDeploymentsContractV1 = oc.route({
330
438
  path: "/v1/projects/{projectId}/deployments",
331
439
  method: "GET",
332
440
  summary: "List project deployments",
333
441
  description: "List all deployments for a project",
334
442
  tags: ["deployments"],
335
443
  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
- })));
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));
340
449
  const getDeploymentContractV1 = oc.route({
341
450
  path: "/v1/deployments/{deploymentId}",
342
451
  method: "GET",
@@ -344,7 +453,83 @@ const getDeploymentContractV1 = oc.route({
344
453
  description: "Get a deployment by ID",
345
454
  tags: ["deployments"],
346
455
  successDescription: "The deployment details"
347
- }).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
+ }));
498
+ const getLatestLogsContractV1 = oc.route({
499
+ path: "/v1/environments/{environmentId}/latest-logs",
500
+ method: "GET",
501
+ summary: "Get latest logs",
502
+ description: "Get the N most recent logs for an environment",
503
+ tags: ["environments"],
504
+ successDescription: "The latest logs"
505
+ }).errors({
506
+ NOT_FOUND: {},
507
+ BAD_REQUEST: {}
508
+ }).input(z.object({
509
+ environmentId: z.string().describe("The ID of the environment"),
510
+ limit: z.coerce.number().int().min(1).max(1e3).default(100).describe("Number of most recent log entries to return"),
511
+ level: z.array(z.enum([
512
+ "INFO",
513
+ "ERROR",
514
+ "WARNING",
515
+ "DEBUG"
516
+ ])).optional().describe("Filter by log level"),
517
+ search: z.string().optional().describe("Filter pattern to search for in log content")
518
+ })).output(z.object({ logs: z.array(z.object({
519
+ timestamp: z.coerce.date(),
520
+ type: z.enum([
521
+ "START",
522
+ "END",
523
+ "INFO",
524
+ "ERROR",
525
+ "WARNING",
526
+ "DEBUG"
527
+ ]),
528
+ requestId: z.string(),
529
+ content: z.string().optional(),
530
+ method: z.string().optional(),
531
+ durationInMs: z.number().optional()
532
+ })) }));
348
533
  const getDeploymentLogsContractV1 = oc.route({
349
534
  path: "/v1/deployments/{deploymentId}/logs",
350
535
  method: "GET",
@@ -422,11 +607,115 @@ const getTunnelTicketContractV1 = oc.route({
422
607
  ticket: z.string().describe("The signed tunnel ticket"),
423
608
  tunnelHost: z.string().describe("The tunnel host to connect to")
424
609
  }));
610
+ const publishServerContractV1 = oc.route({
611
+ path: "/v1/distribution/publish",
612
+ method: "POST",
613
+ summary: "Publish a server to the MCP registry",
614
+ tags: ["distribution"],
615
+ successDescription: "The server has been published successfully"
616
+ }).errors({
617
+ NOT_FOUND: {},
618
+ BAD_REQUEST: {}
619
+ }).input(z.object({
620
+ projectId: z.string(),
621
+ domain: z.string(),
622
+ title: z.string().min(1).max(100),
623
+ description: z.string().min(1).max(100),
624
+ websiteUrl: z.url().max(255).optional(),
625
+ iconSrc: z.url().max(255).optional(),
626
+ dryRun: z.boolean().optional()
627
+ })).output(z.object({ serverFields: serverFieldsSchema }));
628
+ const getServerInfoContractV1 = oc.route({
629
+ path: "/v1/distribution/get",
630
+ method: "GET",
631
+ summary: "Get server info",
632
+ description: "Get info about a server",
633
+ tags: ["distribution"],
634
+ successDescription: "The server info"
635
+ }).errors({
636
+ NOT_FOUND: {},
637
+ BAD_REQUEST: {}
638
+ }).input(z.object({
639
+ projectId: z.string(),
640
+ domain: z.string()
641
+ })).output(z.object({ serverFields: serverFieldsSchema }));
642
+ const playgroundServerMetadataOutputSchema = z.object({
643
+ name: z.string(),
644
+ description: z.string(),
645
+ headers: z.array(z.object({
646
+ name: z.string(),
647
+ description: z.string(),
648
+ isRequired: z.boolean(),
649
+ isSecret: z.boolean()
650
+ })),
651
+ examplePrompts: z.array(playgroundExamplePromptSchema)
652
+ });
653
+ const playgroundOutputSchema = z.object({
654
+ isPlaygroundEnabled: z.boolean(),
655
+ serverMetadata: playgroundServerMetadataOutputSchema.nullable()
656
+ });
657
+ const getPlaygroundContractV1 = oc.route({
658
+ path: "/v1/environments/{environmentId}/playground",
659
+ method: "GET",
660
+ summary: "Get playground configuration",
661
+ description: "Get the playground configuration for an environment",
662
+ tags: ["environments"],
663
+ successDescription: "The playground configuration"
664
+ }).errors({ NOT_FOUND: {} }).input(z.object({ environmentId: z.string().describe("The ID of the environment") })).output(playgroundOutputSchema);
665
+ const upsertPlaygroundContractV1 = oc.route({
666
+ path: "/v1/environments/{environmentId}/playground",
667
+ method: "PUT",
668
+ summary: "Update playground configuration",
669
+ description: "Update the playground configuration for an environment. All fields are optional — only provided fields are updated.",
670
+ tags: ["environments"],
671
+ successDescription: "The updated playground configuration"
672
+ }).errors({
673
+ NOT_FOUND: {},
674
+ BAD_REQUEST: {}
675
+ }).input(z.object({
676
+ environmentId: z.string().describe("The ID of the environment"),
677
+ isPlaygroundEnabled: z.boolean().optional(),
678
+ name: z.string().min(1).max(100).optional(),
679
+ description: z.string().min(1).max(500).optional(),
680
+ headers: z.array(playgroundHeaderSchema).optional(),
681
+ examplePrompts: z.array(playgroundExamplePromptSchema).max(3).optional()
682
+ })).output(playgroundOutputSchema);
683
+ const createBeaconContractV1 = oc.route({
684
+ path: "/v1/beacon/audits",
685
+ method: "POST",
686
+ summary: "Create a beacon audit",
687
+ description: "Audit an MCP server for spec compliance and AI client compatibility",
688
+ tags: ["beacon"],
689
+ successDescription: "The audit has been created"
690
+ }).errors({
691
+ NOT_FOUND: {},
692
+ BAD_REQUEST: {}
693
+ }).input(z.object({
694
+ targetUrl: z.string().url().describe("The HTTPS URL of the MCP server to audit"),
695
+ teamId: z.string().optional().describe("The team ID to associate the audit with"),
696
+ projectId: z.string().optional().describe("The project ID to associate the audit with"),
697
+ excludeCategories: z.array(checkCategorySchema).optional().describe("Check categories to exclude from the audit")
698
+ })).output(z.object({ id: z.string() }));
699
+ const getBeaconContractV1 = oc.route({
700
+ path: "/v1/beacon/audits/{auditId}",
701
+ method: "GET",
702
+ summary: "Get a beacon audit",
703
+ description: "Get a beacon audit by ID, including the report if completed",
704
+ tags: ["beacon"],
705
+ successDescription: "The audit details"
706
+ }).errors({ NOT_FOUND: {} }).input(z.object({ auditId: z.string().describe("The ID of the audit") })).output(z.object({
707
+ id: z.string(),
708
+ targetUrl: z.string(),
709
+ status: auditStatusSchema,
710
+ durationMs: z.number().nullable(),
711
+ createdAt: z.coerce.date(),
712
+ report: auditReportSchema.nullable()
713
+ }));
425
714
  const contract = {
426
715
  teams: { list: { v1: listTeamsContractV1 } },
427
716
  analytics: { get: { v1: getProjectAnalyticsContractV1 } },
428
717
  deployments: {
429
- list: { v1: listProjectDeploymentsContractV1 },
718
+ list: { v1: listDeploymentsContractV1 },
430
719
  get: { v1: getDeploymentContractV1 },
431
720
  uploadArtifact: { v1: uploadDeploymentArtifactContractV1 },
432
721
  getLogs: { v1: getDeploymentLogsContractV1 }
@@ -434,7 +723,9 @@ const contract = {
434
723
  environments: {
435
724
  create: { v1: createEnvironmentContractV1 },
436
725
  get: { v1: getEnvironmentContractV1 },
437
- deploy: { v1: deployEnvironmentContractV1 }
726
+ deploy: { v1: deployEnvironmentContractV1 },
727
+ getLogs: { v1: getLogsContractV1 },
728
+ getLatestLogs: { v1: getLatestLogsContractV1 }
438
729
  },
439
730
  environmentVariables: {
440
731
  list: { v1: listEnvironmentVariablesContractV1 },
@@ -449,7 +740,19 @@ const contract = {
449
740
  create: { v1: createProjectContractV1 },
450
741
  delete: { v1: deleteProjectContractV1 }
451
742
  },
452
- tunnels: { getTicket: { v1: getTunnelTicketContractV1 } }
743
+ playground: {
744
+ get: { v1: getPlaygroundContractV1 },
745
+ upsert: { v1: upsertPlaygroundContractV1 }
746
+ },
747
+ tunnels: { getTicket: { v1: getTunnelTicketContractV1 } },
748
+ distribution: {
749
+ publish: { v1: publishServerContractV1 },
750
+ get: { v1: getServerInfoContractV1 }
751
+ },
752
+ beacon: {
753
+ create: { v1: createBeaconContractV1 },
754
+ get: { v1: getBeaconContractV1 }
755
+ }
453
756
  };
454
757
  //#endregion
455
- export { buildSettingsSchema, contract, createEnvironmentContractV1, environmentVariableSchema, environmentVariablesSchema, runtimeSchema, transportSchema };
758
+ 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.4e5172b",
3
+ "version": "0.0.0-staging.4f81e5f",
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
  }