@alpic-ai/api 0.0.0-dev.gd9e9ea8 → 0.0.0-dev.gd9ec27f

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
@@ -2,7 +2,7 @@ import { z } from "zod";
2
2
  import * as z$1 from "zod/v4";
3
3
  import { oc } from "@orpc/contract";
4
4
  import ms from "ms";
5
- //#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_supports-color@7.2.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth.js
5
+ //#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_supports-color@8.1.1_zod@4.5.4/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth.js
6
6
  /**
7
7
  * Reusable URL validation that disallows javascript: scheme
8
8
  */
@@ -119,7 +119,12 @@ z$1.object({
119
119
  token_type: z$1.string(),
120
120
  expires_in: z$1.coerce.number().optional(),
121
121
  scope: z$1.string().optional(),
122
- refresh_token: z$1.string().optional()
122
+ refresh_token: z$1.string().optional(),
123
+ /**
124
+ * Not part of the wire format: the authorization server this value was obtained from, added by
125
+ * the client's `auth()` before it is stored and compared when it is read back.
126
+ */
127
+ issuer: z$1.string().optional().catch(void 0)
123
128
  }).strip();
124
129
  z$1.object({
125
130
  error: z$1.string(),
@@ -158,7 +163,12 @@ const OAuthClientInformationSchema = z$1.object({
158
163
  client_id: z$1.string(),
159
164
  client_secret: z$1.string().optional(),
160
165
  client_id_issued_at: z$1.number().optional(),
161
- client_secret_expires_at: z$1.number().optional()
166
+ client_secret_expires_at: z$1.number().optional(),
167
+ /**
168
+ * Not part of the wire format: the authorization server this value was obtained from, added by
169
+ * the client's `auth()` before it is stored and compared when it is read back.
170
+ */
171
+ issuer: z$1.string().optional().catch(void 0)
162
172
  }).strip();
163
173
  OAuthClientMetadataSchema.merge(OAuthClientInformationSchema);
164
174
  z$1.object({
@@ -179,6 +189,7 @@ const PLATFORM_LABELS = {
179
189
  };
180
190
  const WAF_PLATFORMS = [
181
191
  "akamai",
192
+ "cato",
182
193
  "cloudflare",
183
194
  "fastly"
184
195
  ];
@@ -256,16 +267,25 @@ z.object({
256
267
  clientSecret: z.string(),
257
268
  clientScopes: z.array(z.string())
258
269
  });
259
- z.enum([
260
- "opening_balance",
270
+ const creditEntryReasonSchema = z.enum([
261
271
  "free_seed",
262
272
  "paid_conversion_floor",
263
273
  "top_up",
264
274
  "usage",
265
- "refund",
266
275
  "admin_adjustment"
267
276
  ]);
268
277
  z.enum(["playground"]);
278
+ z.number().int().min(500);
279
+ const creditActivityEntrySchema = z.object({
280
+ reason: creditEntryReasonSchema,
281
+ day: z.number(),
282
+ amountInNanoUSD: z.number(),
283
+ messageCount: z.number().nullable()
284
+ });
285
+ z.object({
286
+ balanceInNanoUSD: z.number(),
287
+ recentActivity: z.array(creditActivityEntrySchema)
288
+ });
269
289
  const deploymentStatusSchema$1 = z.enum([
270
290
  "ongoing",
271
291
  "deployed",
@@ -326,7 +346,8 @@ const standaloneEnvironmentSchema = z.object({
326
346
  const protectedWithoutDiscoveryEnvironmentSchema = z.object({
327
347
  allowsAnonymous: z.literal(false),
328
348
  oAuthMetadata: z.strictObject({}),
329
- scope: z.string().optional()
349
+ scope: z.string().optional(),
350
+ wwwAuthenticate: z.string().optional()
330
351
  });
331
352
  const legacyPublicEnvironmentSchema = z.object({
332
353
  isPublic: z.literal(true),
@@ -371,10 +392,13 @@ z.union([
371
392
  legacyProtectedWithoutDiscoveryEnvironmentSchema
372
393
  ]);
373
394
  const playgroundModelSchema = z.enum([
395
+ "global.anthropic.claude-haiku-5-5",
374
396
  "global.anthropic.claude-haiku-4-5-20251001-v1:0",
375
- "global.anthropic.claude-sonnet-4-5-20250929-v1:0",
397
+ "global.anthropic.claude-sonnet-5-5",
376
398
  "openai.gpt-5.4",
377
- "openai.gpt-5.5"
399
+ "openai.gpt-5.5",
400
+ "openai.gpt-6-luna",
401
+ "openai.gpt-6.1-sol"
378
402
  ]);
379
403
  const environmentDomainSchema = z.object({
380
404
  name: z.string(),
@@ -410,7 +434,8 @@ z.object({
410
434
  collectResponsePayload: z.boolean(),
411
435
  collectErrorMessage: z.boolean(),
412
436
  collectUserData: z.boolean(),
413
- identityTraitKey: z.string().min(1).max(200).nullable()
437
+ identityTraitKey: z.string().min(1).max(200).nullable(),
438
+ leadEventName: z.string().min(1).max(200).nullable()
414
439
  });
415
440
  const feedbackSchema = z.object({
416
441
  id: z.string(),
@@ -529,6 +554,14 @@ z.enum([
529
554
  "DEBUG",
530
555
  "ERROR"
531
556
  ]);
557
+ const LOG_SEARCH_MAX_ESCAPED_LENGTH = 960;
558
+ function escapeLogSearchTerm(search) {
559
+ return [...search].flatMap((character) => [...new TextEncoder().encode(character)]).map((byte) => {
560
+ const character = String.fromCharCode(byte);
561
+ return /^[a-zA-Z0-9]$/.test(character) ? character : `\\x${byte.toString(16).toUpperCase().padStart(2, "0")}`;
562
+ }).join("");
563
+ }
564
+ const logSearchSchema = z.string().max(240, `Search must be 240 characters or fewer`).refine((search) => escapeLogSearchTerm(search).length <= LOG_SEARCH_MAX_ESCAPED_LENGTH, "Search is too complex; shorten it or use fewer special characters");
532
565
  /** Only names a vendor actually ships belong here: lookalikes like `claude-code-test` are customers' own scripts. */
533
566
  const MCP_CLIENT_GROUPS = [
534
567
  {
@@ -596,7 +629,7 @@ const MCP_CLIENT_GROUPS = [
596
629
  id: "chatgpt",
597
630
  label: "ChatGPT",
598
631
  vendor: "openai",
599
- rawNames: ["openai-mcp (ChatGPT)"]
632
+ rawNames: ["openai-mcp", "openai-mcp (ChatGPT)"]
600
633
  },
601
634
  {
602
635
  id: "openai_responses_api",
@@ -610,12 +643,6 @@ const MCP_CLIENT_GROUPS = [
610
643
  vendor: "openai",
611
644
  rawNames: ["openai-mcp (Agent Builder)"]
612
645
  },
613
- {
614
- id: "openai_other",
615
- label: "OpenAI Other",
616
- vendor: "openai",
617
- rawNames: ["openai-mcp"]
618
- },
619
646
  {
620
647
  id: "cursor",
621
648
  label: "Cursor",
@@ -773,7 +800,8 @@ const runtimeSchema = z.enum([
773
800
  "python3.13",
774
801
  "python3.14",
775
802
  "node22",
776
- "node24"
803
+ "node24",
804
+ "node26"
777
805
  ]);
778
806
  const transportSchema = z.enum([
779
807
  "stdio",
@@ -854,6 +882,10 @@ const clampStringField = (field) => {
854
882
  const withMin = field.minLength === null ? clamped : clamped.min(field.minLength);
855
883
  return field.description ? withMin.describe(field.description) : withMin;
856
884
  };
885
+ const unboundedArrayField = (field) => {
886
+ const unbounded = z.array(field.element);
887
+ return field.description ? unbounded.describe(field.description) : unbounded;
888
+ };
857
889
  const toolDefinitionSchema = z.object({
858
890
  name: z.string(),
859
891
  title: z.string().optional().describe("Human-friendly name for the tool, used in the UI. If not provided, `name` will be used."),
@@ -866,11 +898,22 @@ const toolDefinitionSchema = z.object({
866
898
  }).optional()
867
899
  });
868
900
  const positiveTestCaseSchema = z.object({
869
- scenario: z.string().describe("Short label for what this case demonstrates."),
870
- userPrompt: z.string().describe("A realistic, standalone user message a reviewer can paste and run with no prior state or multi-turn setup. Vary phrasing and tone across cases."),
901
+ scenario: z.string().min(1).describe("Short label for what this case demonstrates."),
902
+ userPrompt: z.string().min(1).describe("A realistic, standalone user message a reviewer can paste and run with no prior state or multi-turn setup. Vary phrasing and tone across cases."),
871
903
  toolTriggered: z.string().optional().describe("The tool this prompt should invoke."),
872
904
  expectedOutput: z.string().optional().describe("What the user should see, including post-interaction behaviour where relevant.")
873
- }).partial().describe("Each case: Scenario, User prompt, Tool triggered, Expected output.");
905
+ }).describe("Each case: Scenario, User prompt, Tool triggered, Expected output.");
906
+ const positiveTestCaseDraftSchema = positiveTestCaseSchema.partial().extend({
907
+ scenario: z.string().optional(),
908
+ userPrompt: z.string().optional()
909
+ });
910
+ const blankPositiveTestCase = () => ({
911
+ scenario: "",
912
+ userPrompt: "",
913
+ toolTriggered: "",
914
+ expectedOutput: ""
915
+ });
916
+ const toFixedLength = (entries, length, blank) => Array.from({ length }, (_, index) => entries[index] ?? blank());
874
917
  const screenshotEntrySchema = z.object({
875
918
  prompt: z.string(),
876
919
  url: z.url()
@@ -1183,9 +1226,18 @@ const chatgptTranslationLocaleSchema = z.enum([
1183
1226
  "zh-TW"
1184
1227
  ]);
1185
1228
  const negativeTestCaseSchema = z.object({
1186
- scenario: z.string(),
1187
- userPrompt: z.string()
1188
- }).partial().describe("Each case: Scenario + User prompt (the app should NOT trigger).");
1229
+ scenario: z.string().min(1),
1230
+ userPrompt: z.string().min(1)
1231
+ }).describe("Each case: Scenario + User prompt (the plugin should NOT trigger).");
1232
+ const negativeTestCaseDraftSchema = negativeTestCaseSchema.partial().extend({
1233
+ scenario: z.string().optional(),
1234
+ userPrompt: z.string().optional()
1235
+ });
1236
+ const blankNegativeTestCase = () => ({
1237
+ scenario: "",
1238
+ userPrompt: ""
1239
+ });
1240
+ const chatgptSkillSchema = z.object({ name: z.string() }).describe("A skill discovered on the MCP server, by name.");
1189
1241
  const chatgptToolJustificationSchema = z.object({
1190
1242
  toolName: z.string(),
1191
1243
  readOnlyJustification: z.string().describe("One sentence on what the tool reads and returns."),
@@ -1205,27 +1257,28 @@ chatgptTranslationSchema.extend({ tagline: clampStringField(chatgptTaglineSchema
1205
1257
  const chatgptSubmissionFormDataSchema = z.object({
1206
1258
  logoLight: z.string().describe("Logo icon for light mode. Square PNG, no borders or rounded corners (clients apply circular cropping)."),
1207
1259
  logoDark: z.string().optional().describe("Optional dark-mode logo icon. Square PNG, same specs as the light icon. Leave empty if the light icon also works on dark backgrounds."),
1208
- appName: z.string().describe("The name users will see in ChatGPT and in the Apps Directory."),
1260
+ appName: z.string().describe("The name users will see in ChatGPT and in the Plugin Directory."),
1209
1261
  tagline: chatgptTaglineSchema.describe("Plain-language phrase focused on function and user value, 30 chars max. Avoid generic superlatives like \"the best …\"."),
1210
- description: chatgptDescriptionSchema.describe("Clear, engaging description highlighting what the app does and why people will love it. Appears publicly on the directory page. End it by naming the product categories or intents the app does NOT cover, so ChatGPT learns when not to route to it (define exclusions by absent categories or wrong intents, never by naming other brands)."),
1262
+ description: chatgptDescriptionSchema.describe("Clear, engaging description highlighting what the plugin does and why people will love it. Appears publicly on the directory page. End it by naming the product categories or intents the plugin does NOT cover, so ChatGPT learns when not to route to it (define exclusions by absent categories or wrong intents, never by naming other brands)."),
1211
1263
  category: chatgptCategorySchema.describe("Category from the OpenAI taxonomy."),
1212
- developerName: z.string().describe("Developer name shown publicly on the app's directory page."),
1264
+ developerName: z.string().describe("Developer name shown publicly on the plugin's directory page."),
1213
1265
  companyUrl: urlField.describe("Your company's main website URL."),
1214
1266
  supportChannel: supportChannelSchema.describe("Customer support URL or email address."),
1215
1267
  privacyPolicyUrl: urlField.describe("URL to your privacy policy."),
1216
- termsOfServiceUrl: urlField.describe("URL to the app's terms of service."),
1217
- demoRecordingUrl: urlField.describe("URL to a video demonstrating the app, recorded via OpenAI Developer Mode. Cover all main use cases on web, iOS, and Android."),
1218
- appCommerceAndPurchasing: z.boolean().describe("Checkbox: 'My app links or directs users out of ChatGPT to make purchases.' Defaults to false. Verify the app does not offer digital goods."),
1268
+ termsOfServiceUrl: urlField.describe("URL to the plugin's terms of service."),
1269
+ demoRecordingUrl: urlField.describe("URL to a video demonstrating the plugin, recorded via OpenAI Developer Mode. Cover all main use cases on web, iOS, and Android."),
1270
+ appCommerceAndPurchasing: z.boolean().describe("Checkbox: 'My plugin links or directs users out of ChatGPT to make purchases.' Defaults to false. Verify the plugin does not offer digital goods."),
1219
1271
  serverUrl: urlField.describe("URL of the MCP server."),
1220
1272
  authentication: chatgptAuthenticationSchema.describe("OAuth 2.0 or No auth. OAuth configuration is auto-discovered from the MCP server's metadata."),
1221
1273
  tools: z.array(toolDefinitionSchema).describe("List of tools exposed by the MCP server (auto-populated from the production server's manifest)."),
1222
1274
  toolJustifications: z.array(chatgptToolJustificationSchema).describe("Per-tool justification of `readOnlyHint`, `openWorldHint`, and `destructiveHint` annotation values. One short, specific sentence per hint describing what the tool actually does."),
1223
- testCases: z.array(positiveTestCaseSchema).describe("At least 5 positive test cases. Each: Scenario, User prompt, Tool triggered, Expected output. Collectively cover the full capability across different flow stages (initial search or browse, market or locale handling, post-interaction detail, an action ChatGPT performs on the user's behalf, and a conversion or secondary tool) rather than five variations of the same first step."),
1224
- negativeTestCases: z.array(negativeTestCaseSchema).describe("3 negative test cases: prompts where the app should NOT trigger but the model might think it is relevant. These become production routing metadata that teaches ChatGPT when to stay silent, so pick tight near-misses: a product category the app does not carry, the right brand or domain but an intent the app does not serve, or a boundary with a sibling app."),
1225
- screenshots: z.array(screenshotEntrySchema.extend({ prompt: z.string().max(75, { error: "Screenshot prompts are limited to 75 characters." }) })).max(3).describe("In-app screenshots paired with the user prompt that produced them (each prompt is 75 characters max). Widget apps must show the widget UI; non-widget apps show the model response. Min 1, max 3 entries, all public. Images: 706px wide, 400–860px tall, PNG."),
1275
+ skills: z.array(chatgptSkillSchema).optional().describe("Skills the server exposes over MCP (auto-populated from the production server's manifest). Left unset when the server does not advertise the skills extension, which is a different state from advertising it and exposing none."),
1276
+ testCases: z.array(positiveTestCaseSchema).length(5).describe("Exactly 5 positive test cases. Each: Scenario, User prompt, Tool triggered, Expected output. Collectively cover the full capability across different flow stages (initial search or browse, market or locale handling, post-interaction detail, an action ChatGPT performs on the user's behalf, and a conversion or secondary tool) rather than five variations of the same first step."),
1277
+ negativeTestCases: z.array(negativeTestCaseSchema).length(3).describe("Exactly 3 negative test cases: prompts where the plugin should NOT trigger but the model might think it is relevant. These become production routing metadata that teaches ChatGPT when to stay silent, so pick tight near-misses: a product category the plugin does not carry, the right brand or domain but an intent the plugin does not serve, or a boundary with a sibling plugin."),
1278
+ screenshots: z.array(screenshotEntrySchema.extend({ prompt: z.string().max(75, { error: "Screenshot prompts are limited to 75 characters." }) })).max(3).describe("In-plugin screenshots paired with the user prompt that produced them (each prompt is 75 characters max). Widget plugins must show the widget UI; non-widget plugins show the model response. Min 1, max 3 entries, all public. Images: 706px wide, 400–860px tall, PNG."),
1226
1279
  translations: z.array(chatgptTranslationSchema).describe("Per-locale translation of tagline + description. English (US) is the default."),
1227
1280
  allowedCountries: chatgptAllowedCountriesSchema.describe("Availability: all supported countries, or an allow-list / block-list of specific ones (ISO alpha-2)."),
1228
- releaseNotes: z.string().describe("Publicly displayed on the app details page.")
1281
+ releaseNotes: z.string().describe("Publicly displayed on the plugin details page.")
1229
1282
  });
1230
1283
  const chatgptSubmissionDraftSchema = chatgptSubmissionFormDataSchema.partial().extend({
1231
1284
  tagline: z.string().optional(),
@@ -1236,23 +1289,35 @@ const chatgptSubmissionDraftSchema = chatgptSubmissionFormDataSchema.partial().e
1236
1289
  demoRecordingUrl: z.string().optional(),
1237
1290
  serverUrl: z.string().optional(),
1238
1291
  screenshots: z.array(screenshotDraftEntrySchema).optional(),
1292
+ testCases: z.array(positiveTestCaseDraftSchema).optional(),
1293
+ negativeTestCases: z.array(negativeTestCaseDraftSchema).optional(),
1239
1294
  translations: z.array(chatgptTranslationSchema.extend({ tagline: z.string() })).optional()
1240
1295
  });
1241
- chatgptSubmissionFormDataSchema.pick({
1296
+ /** Source of truth for the fields `SubmissionPrefillService.prefill({ platform: "chatgpt" })` can populate. */
1297
+ const chatgptPrefillFormDataSchema = chatgptSubmissionFormDataSchema.pick({
1242
1298
  appName: true,
1243
1299
  developerName: true,
1244
1300
  serverUrl: true,
1245
1301
  tools: true,
1302
+ skills: true,
1246
1303
  authentication: true
1247
1304
  });
1248
- chatgptSubmissionFormDataSchema.pick({
1305
+ /** Source of truth for `SubmissionPrefillService.generate({ platform: "chatgpt" })`. */
1306
+ const chatgptAiGeneratedFormDataSchema = chatgptSubmissionFormDataSchema.pick({
1249
1307
  tagline: true,
1250
1308
  description: true,
1251
1309
  category: true,
1252
1310
  testCases: true,
1253
1311
  negativeTestCases: true,
1254
1312
  toolJustifications: true
1255
- }).extend({ tagline: clampStringField(chatgptSubmissionFormDataSchema.shape.tagline) });
1313
+ }).extend({
1314
+ testCases: unboundedArrayField(chatgptSubmissionFormDataSchema.shape.testCases),
1315
+ negativeTestCases: unboundedArrayField(chatgptSubmissionFormDataSchema.shape.negativeTestCases)
1316
+ }).extend({
1317
+ tagline: clampStringField(chatgptSubmissionFormDataSchema.shape.tagline),
1318
+ testCases: z.array(positiveTestCaseDraftSchema).transform((cases) => toFixedLength(cases, 5, blankPositiveTestCase)),
1319
+ negativeTestCases: z.array(negativeTestCaseDraftSchema).transform((cases) => toFixedLength(cases, 3, blankNegativeTestCase))
1320
+ });
1256
1321
  const claudeCategorySchema = z.enum([
1257
1322
  "Productivity",
1258
1323
  "Communication",
@@ -1375,7 +1440,8 @@ const claudeSubmissionDraftSchema = claudeSubmissionFormDataSchema.partial().ext
1375
1440
  categories: z.array(claudeCategorySchema).optional(),
1376
1441
  screenshots: z.array(screenshotDraftEntrySchema).optional()
1377
1442
  });
1378
- claudeSubmissionFormDataSchema.pick({
1443
+ /** Source of truth for the fields `SubmissionPrefillService.prefill({ platform: "claudeai" })` can populate. */
1444
+ const claudePrefillFormDataSchema = claudeSubmissionFormDataSchema.pick({
1379
1445
  serverUrl: true,
1380
1446
  name: true,
1381
1447
  slug: true,
@@ -1397,27 +1463,81 @@ const claudeAiGeneratedFormDataRawSchema = z.object({
1397
1463
  categories: z.array(claudeCategorySchema).describe(claudeCategoryDescription),
1398
1464
  primaryUseCases: claudeSubmissionFormDataSchema.shape.primaryUseCases
1399
1465
  });
1400
- claudeAiGeneratedFormDataRawSchema.extend({
1466
+ const claudeAiGeneratedFormDataSchema = claudeAiGeneratedFormDataRawSchema.extend({
1401
1467
  oneLiner: clampStringField(claudeSubmissionFormDataSchema.shape.oneLiner),
1402
1468
  categories: claudeAiGeneratedFormDataRawSchema.shape.categories.transform((categories) => categories.slice(0, 5))
1403
1469
  });
1470
+ function provenanceByField(prefillShape, aiGeneratedShape) {
1471
+ const byField = {};
1472
+ for (const field of Object.keys(prefillShape)) byField[field] = "prefilled";
1473
+ for (const field of Object.keys(aiGeneratedShape)) byField[field] = "ai-generated";
1474
+ return byField;
1475
+ }
1476
+ provenanceByField(claudePrefillFormDataSchema.shape, claudeAiGeneratedFormDataSchema.shape), provenanceByField(chatgptPrefillFormDataSchema.shape, chatgptAiGeneratedFormDataSchema.shape);
1477
+ const urlVerificationOutcomeSchema = z.enum([
1478
+ "pass",
1479
+ "fail",
1480
+ "unverified"
1481
+ ]);
1482
+ const VERIFIABLE_URL_FIELDS = {
1483
+ chatgpt: ["privacyPolicyUrl", "termsOfServiceUrl"],
1484
+ claudeai: ["privacyPolicy"]
1485
+ };
1486
+ const verifiableUrlFieldSchema = z.enum([...VERIFIABLE_URL_FIELDS.chatgpt, ...VERIFIABLE_URL_FIELDS.claudeai]);
1487
+ const policyDisclosureSchema = z.enum([
1488
+ "dataCategories",
1489
+ "purposesOfUse",
1490
+ "recipients",
1491
+ "retention"
1492
+ ]);
1493
+ const urlVerificationFieldResultSchema = z.object({
1494
+ field: verifiableUrlFieldSchema,
1495
+ url: z.string(),
1496
+ outcome: urlVerificationOutcomeSchema,
1497
+ reason: z.string(),
1498
+ concerns: z.array(z.string()).optional(),
1499
+ scrapedWith: z.enum(["fetch", "firecrawl"]).optional()
1500
+ });
1501
+ const urlVerificationSchema = z.object({
1502
+ verifiedAt: z.coerce.date(),
1503
+ results: z.array(urlVerificationFieldResultSchema)
1504
+ });
1505
+ const pageKindSchema = z.enum([
1506
+ "expectedDocument",
1507
+ "errorPage",
1508
+ "loginWall",
1509
+ "parkedDomain",
1510
+ "comingSoon",
1511
+ "marketingPage",
1512
+ "unrelatedDocument"
1513
+ ]);
1514
+ z.object({
1515
+ pageKind: pageKindSchema.describe("What the page actually is. Use 'expectedDocument' only when it is genuinely the document the field claims."),
1516
+ reason: z.string().max(200).describe("One sentence naming what the page is, addressed to the developer who entered the URL."),
1517
+ missingDisclosures: z.array(policyDisclosureSchema).describe("For a privacy policy only: which of the four required disclosures the text does not cover. Empty for every other page kind.")
1518
+ });
1404
1519
  const submissionMetaFieldsSchema = z.object({
1405
1520
  id: z.string(),
1406
1521
  environmentId: z.string(),
1407
1522
  auditId: z.string().nullable(),
1523
+ urlVerification: urlVerificationSchema.nullable().default(null),
1408
1524
  createdAt: z.coerce.date(),
1409
1525
  updatedAt: z.coerce.date()
1410
1526
  });
1411
1527
  const claudeSubmissionSchemaInternal = submissionMetaFieldsSchema.extend({
1412
1528
  platform: z.literal("claudeai"),
1413
- formData: claudeSubmissionDraftSchema
1529
+ formData: claudeSubmissionDraftSchema,
1530
+ prefillSnapshot: claudeSubmissionDraftSchema.nullable().default(null)
1414
1531
  });
1415
1532
  const chatgptSubmissionSchemaInternal = submissionMetaFieldsSchema.extend({
1416
1533
  platform: z.literal("chatgpt"),
1417
- formData: chatgptSubmissionDraftSchema
1534
+ formData: chatgptSubmissionDraftSchema,
1535
+ prefillSnapshot: chatgptSubmissionDraftSchema.nullable().default(null)
1418
1536
  });
1419
- z.discriminatedUnion("platform", [claudeSubmissionSchemaInternal, chatgptSubmissionSchemaInternal]);
1537
+ const submissionSchemaInternal = z.discriminatedUnion("platform", [claudeSubmissionSchemaInternal, chatgptSubmissionSchemaInternal]);
1420
1538
  z.union([claudeSubmissionDraftSchema, chatgptSubmissionDraftSchema]);
1539
+ /** Discriminated on `platform`, which pins the shape of `formData`: a Claude submission cannot carry chatgpt-only fields, and vice-versa. */
1540
+ const submissionSchema = submissionSchemaInternal;
1421
1541
  z.literal([
1422
1542
  100,
1423
1543
  75,
@@ -1434,24 +1554,41 @@ const customerCreditsSchema = z.object({
1434
1554
  expiresAt: z.number().nullable(),
1435
1555
  currency: z.string()
1436
1556
  });
1437
- const customerUsageSchema = z.object({
1438
- amountInCents: z.number(),
1439
- currency: z.string(),
1440
- periodEnd: z.number()
1441
- });
1442
1557
  const partnerDiscountSchema = z.object({ endsAt: z.number() });
1443
- z.object({ balanceInNanoUSD: z.number() });
1444
1558
  z.object({
1445
1559
  customerCredits: customerCreditsSchema.nullable(),
1446
- customerUsage: customerUsageSchema.nullable(),
1447
1560
  partnerDiscount: partnerDiscountSchema.nullable()
1448
1561
  });
1449
- const telemetrySignalSchema = z.enum([
1562
+ const metricsQueueEventSchema = z.object({
1563
+ ts: z.number().int(),
1564
+ method: z.string(),
1565
+ tool: z.string().nullable(),
1566
+ client: z.string(),
1567
+ sessionId: z.string().nullable(),
1568
+ conversationId: z.string().nullable().optional(),
1569
+ durationMs: z.number().int(),
1570
+ outputTokens: z.number().int().nullable(),
1571
+ errorType: z.enum([
1572
+ "mcp_error",
1573
+ "tool_error",
1574
+ "timeout"
1575
+ ]).nullable(),
1576
+ errorCode: z.number().int().nullable()
1577
+ });
1578
+ z.object({
1579
+ v: z.literal(1),
1580
+ envId: z.string(),
1581
+ events: z.array(metricsQueueEventSchema)
1582
+ });
1583
+ z.object({ v: z.number() });
1584
+ const TELEMETRY_SIGNALS = [
1450
1585
  "logs",
1451
1586
  "metrics",
1452
1587
  "traces"
1453
- ]);
1454
- const otlpProtocolSchema = z.enum(["http/protobuf", "http/json"]);
1588
+ ];
1589
+ const telemetrySignalSchema = z.enum(TELEMETRY_SIGNALS);
1590
+ const OTLP_PROTOCOLS = ["http/protobuf", "http/json"];
1591
+ const otlpProtocolSchema = z.enum(OTLP_PROTOCOLS);
1455
1592
  const otlpEndpointSchema = z.string().trim().min(1).max(2048);
1456
1593
  const OTLP_HEADER_VALUE_MAX_LENGTH = 2048;
1457
1594
  const otlpHeaderNameSchema = z.string().trim().min(1, "Enter a header name").max(128).regex(/^[A-Za-z0-9!#$%&'*+\-.^_`|~]+$/, "Use letters, digits and !#$%&'*+-.^_`|~ only");
@@ -1482,8 +1619,13 @@ z.object({
1482
1619
  protocol: otlpProtocolSchema,
1483
1620
  headers: z.array(telemetryDestinationHeaderSchema),
1484
1621
  status: telemetryDestinationStatusSchema,
1485
- lastFailureReason: otlpPushFailureReasonSchema.nullable()
1622
+ lastFailureReason: otlpPushFailureReasonSchema.nullable(),
1623
+ isScopedToIntentionalRequestsOnly: z.boolean()
1486
1624
  });
1625
+ const hasDuplicateHeaderNames = (headers) => {
1626
+ const names = headers.map(({ name }) => name.trim().toLowerCase());
1627
+ return new Set(names).size !== names.length;
1628
+ };
1487
1629
  //#endregion
1488
1630
  //#region src/auth-scope.ts
1489
1631
  /** Accepts an API key or OAuth access token (default for most routes). */
@@ -1582,6 +1724,14 @@ const serverFieldsSchema = z.object({
1582
1724
  });
1583
1725
  //#endregion
1584
1726
  //#region src/api.contract.ts
1727
+ const isValidIanaTimeZone = (timeZone) => {
1728
+ try {
1729
+ new Intl.DateTimeFormat("en-US", { timeZone });
1730
+ return true;
1731
+ } catch {
1732
+ return false;
1733
+ }
1734
+ };
1585
1735
  const deploymentStatusSchema = z.enum([
1586
1736
  "ongoing",
1587
1737
  "deployed",
@@ -1652,6 +1802,14 @@ const getEnvironmentContractV1 = base.route({
1652
1802
  createdAt: z.coerce.date(),
1653
1803
  projectId: z.string()
1654
1804
  }));
1805
+ const deleteEnvironmentContractV1 = base.route({
1806
+ path: "/v1/environments/{environmentId}",
1807
+ method: "DELETE",
1808
+ summary: "Delete an environment",
1809
+ description: "All environments can be deleted except the production environment. This operation is not reversible: associated logs, analytics, and metrics are deleted as well.",
1810
+ tags: ["environments"],
1811
+ successDescription: "The environment has been deleted successfully"
1812
+ }).errors({ NOT_FOUND: {} }).input(z.object({ environmentId: z.string().describe("The ID of the environment") })).output(z.object({ success: z.literal(true) }));
1655
1813
  const domainSchema = z.object({
1656
1814
  domain: z.string(),
1657
1815
  status: z.enum([
@@ -1758,6 +1916,100 @@ const environmentVariableOutputSchema = z.object({
1758
1916
  isSecret: z.boolean(),
1759
1917
  createdAt: z.coerce.date()
1760
1918
  });
1919
+ const telemetryDestinationHeaderOutputSchema = z.discriminatedUnion("isSecret", [z.object({
1920
+ id: z.string(),
1921
+ name: otlpHeaderNameSchema,
1922
+ value: z.null(),
1923
+ isSecret: z.literal(true)
1924
+ }), z.object({
1925
+ id: z.string(),
1926
+ name: otlpHeaderNameSchema,
1927
+ value: otlpHeaderValueSchema,
1928
+ isSecret: z.literal(false)
1929
+ })]);
1930
+ const telemetryDestinationOutputSchema = z.object({
1931
+ id: z.string(),
1932
+ signal: telemetrySignalSchema,
1933
+ endpoint: otlpEndpointSchema,
1934
+ protocol: otlpProtocolSchema,
1935
+ headers: z.array(telemetryDestinationHeaderOutputSchema),
1936
+ status: telemetryDestinationStatusSchema,
1937
+ lastFailureReason: otlpPushFailureReasonSchema.nullable(),
1938
+ isScopedToIntentionalRequestsOnly: z.boolean()
1939
+ });
1940
+ const createTelemetryDestinationHeaderInputSchema = z.object({
1941
+ name: otlpHeaderNameSchema,
1942
+ value: otlpHeaderValueSchema.min(1, "Enter a header value"),
1943
+ isSecret: z.boolean()
1944
+ });
1945
+ const updateTelemetryDestinationHeaderInputSchema = z.object({
1946
+ id: z.string().optional(),
1947
+ name: otlpHeaderNameSchema,
1948
+ value: otlpHeaderValueSchema.optional(),
1949
+ isSecret: z.boolean()
1950
+ });
1951
+ const uniqueTelemetryHeaders = (headers) => !hasDuplicateHeaderNames(headers);
1952
+ const listTelemetryDestinationsContractV1 = base.route({
1953
+ path: "/v1/environments/{environmentId}/telemetry-destinations",
1954
+ method: "GET",
1955
+ summary: "List telemetry destinations",
1956
+ description: "List the OTLP destinations configured for an environment. Secret header values are never returned.",
1957
+ tags: ["telemetry"],
1958
+ successDescription: "The list of telemetry destinations"
1959
+ }).errors({ NOT_FOUND: {} }).input(z.object({ environmentId: z.string().describe("The ID of the environment") })).output(z.array(telemetryDestinationOutputSchema));
1960
+ const createTelemetryDestinationContractV1 = base.route({
1961
+ path: "/v1/environments/{environmentId}/telemetry-destinations",
1962
+ method: "POST",
1963
+ summary: "Create a telemetry destination",
1964
+ description: "Verify and save an OTLP destination for logs, metrics, or traces.",
1965
+ tags: ["telemetry"],
1966
+ successDescription: "The telemetry destination has been created"
1967
+ }).errors({
1968
+ NOT_FOUND: {},
1969
+ FORBIDDEN: {},
1970
+ OTLP_DESTINATION_UNVERIFIED: { status: 400 },
1971
+ INTERNAL_SERVER_ERROR: {}
1972
+ }).input(z.object({
1973
+ environmentId: z.string().describe("The ID of the environment"),
1974
+ signal: telemetrySignalSchema,
1975
+ endpoint: otlpEndpointSchema,
1976
+ protocol: otlpProtocolSchema.default("http/protobuf"),
1977
+ isScopedToIntentionalRequestsOnly: z.boolean().default(false),
1978
+ headers: z.array(createTelemetryDestinationHeaderInputSchema).default([]).refine(uniqueTelemetryHeaders, "Header names must be unique")
1979
+ })).output(telemetryDestinationOutputSchema);
1980
+ const updateTelemetryDestinationContractV1 = base.route({
1981
+ path: "/v1/environments/{environmentId}/telemetry-destinations/{destinationId}",
1982
+ method: "PATCH",
1983
+ summary: "Update a telemetry destination",
1984
+ description: "Verify and save changes to an OTLP destination. Omit headers to keep them unchanged; omit the value of an existing header to preserve it. A secret header value must be re-entered when the endpoint changes.",
1985
+ tags: ["telemetry"],
1986
+ successDescription: "The telemetry destination has been updated"
1987
+ }).errors({
1988
+ NOT_FOUND: {},
1989
+ FORBIDDEN: {},
1990
+ OTLP_DESTINATION_UNVERIFIED: { status: 400 }
1991
+ }).input(z.object({
1992
+ environmentId: z.string().describe("The ID of the environment"),
1993
+ destinationId: z.string().describe("The ID of the telemetry destination"),
1994
+ endpoint: otlpEndpointSchema.optional(),
1995
+ protocol: otlpProtocolSchema.optional(),
1996
+ isScopedToIntentionalRequestsOnly: z.boolean().optional(),
1997
+ headers: z.array(updateTelemetryDestinationHeaderInputSchema).refine(uniqueTelemetryHeaders, "Header names must be unique").optional()
1998
+ })).output(telemetryDestinationOutputSchema);
1999
+ const deleteTelemetryDestinationContractV1 = base.route({
2000
+ path: "/v1/environments/{environmentId}/telemetry-destinations/{destinationId}",
2001
+ method: "DELETE",
2002
+ summary: "Delete a telemetry destination",
2003
+ description: "Delete an OTLP destination from an environment.",
2004
+ tags: ["telemetry"],
2005
+ successDescription: "The telemetry destination has been deleted"
2006
+ }).errors({
2007
+ NOT_FOUND: {},
2008
+ INTERNAL_SERVER_ERROR: {}
2009
+ }).input(z.object({
2010
+ environmentId: z.string().describe("The ID of the environment"),
2011
+ destinationId: z.string().describe("The ID of the telemetry destination")
2012
+ })).output(z.object({ success: z.literal(true) }));
1761
2013
  const listEnvironmentVariablesContractV1 = base.route({
1762
2014
  path: "/v1/environments/{environmentId}/environment-variables",
1763
2015
  method: "GET",
@@ -1901,7 +2153,7 @@ const getLogsContractV1 = base.route({
1901
2153
  "WARNING",
1902
2154
  "DEBUG"
1903
2155
  ])).optional().describe("Filter by log level"),
1904
- search: z.string().optional().describe("Filter pattern to search for in log content"),
2156
+ search: logSearchSchema.optional().describe("Term to search for in log content"),
1905
2157
  nextToken: z.string().optional().describe("Pagination token from a previous response")
1906
2158
  })).output(z.object({
1907
2159
  logs: z.array(logEntrySchema),
@@ -1923,7 +2175,7 @@ const getLatestLogsContractV1 = base.route({
1923
2175
  "WARNING",
1924
2176
  "DEBUG"
1925
2177
  ])).optional().describe("Filter by log level"),
1926
- search: z.string().optional().describe("Filter pattern to search for in log content")
2178
+ search: logSearchSchema.optional().describe("Term to search for in log content")
1927
2179
  })).output(z.object({ logs: z.array(logEntrySchema) }));
1928
2180
  const getDeploymentLogsContractV1 = base.route({
1929
2181
  path: "/v1/deployments/{deploymentId}/logs",
@@ -1964,7 +2216,7 @@ const getProjectAnalyticsContractV1 = base.route({
1964
2216
  startTimestamp: z.coerce.number().describe("Start timestamp in milliseconds"),
1965
2217
  endTimestamp: z.coerce.number().describe("End timestamp in milliseconds"),
1966
2218
  timeZone: z.string().describe("IANA timezone (e.g. Europe/Paris)")
1967
- }).refine(({ startTimestamp, endTimestamp }) => endTimestamp - startTimestamp > 0, { message: "End date must be after start date" }).refine(({ startTimestamp, endTimestamp }) => endTimestamp - startTimestamp <= 26784e5, { message: "Date range must be less than 1 month" }).refine(({ timeZone }) => Intl.supportedValuesOf("timeZone").includes(timeZone), { message: "Time zone must be a valid IANA timezone" })).output(z.object({
2219
+ }).refine(({ startTimestamp, endTimestamp }) => endTimestamp - startTimestamp > 0, { message: "End date must be after start date" }).refine(({ startTimestamp, endTimestamp }) => endTimestamp - startTimestamp <= 26784e5, { message: "Date range must be less than 1 month" }).refine(({ timeZone }) => isValidIanaTimeZone(timeZone), { message: "Time zone must be a valid IANA timezone" })).output(z.object({
1968
2220
  metadata: z.object({
1969
2221
  startTimestamp: z.number(),
1970
2222
  endTimestamp: z.number(),
@@ -2234,6 +2486,57 @@ const getBeaconContractV1 = base.route({
2234
2486
  createdAt: z.coerce.date(),
2235
2487
  report: auditReportWithScreenshotsSchema.nullable()
2236
2488
  }));
2489
+ const PLATFORM_DESCRIPTION = "The directory the package targets: `chatgpt` for the OpenAI App Directory, `claudeai` for the Anthropic MCP Directory";
2490
+ const submissionIdSchema = z.string().describe("The ID of the submission package");
2491
+ const claudeSubmissionUpdateSchema = claudeSubmissionDraftSchema.strict();
2492
+ const chatgptSubmissionUpdateSchema = chatgptSubmissionDraftSchema.strict();
2493
+ const createSubmissionContractV1 = base.route({
2494
+ path: "/v1/submissions",
2495
+ method: "POST",
2496
+ summary: "Create a submission package",
2497
+ description: "Create a submission package for an environment. Alpic reads the environment's live MCP server and prefills every field it can infer, so the response already carries the populated package. The environment must have a successful deployment and must not require authentication.",
2498
+ tags: ["submissions"],
2499
+ successDescription: "The created submission package, with its prefilled fields"
2500
+ }).errors({ NOT_FOUND: {} }).input(z.object({
2501
+ environmentId: z.string().describe("The ID of the environment to build the package from"),
2502
+ platform: platformSchema.describe(PLATFORM_DESCRIPTION)
2503
+ })).output(submissionSchema);
2504
+ const listSubmissionsContractV1 = base.route({
2505
+ path: "/v1/projects/{projectId}/submissions",
2506
+ method: "GET",
2507
+ summary: "List submission packages",
2508
+ description: "List the submission packages of a project, grouped by directory and most recently updated first, optionally narrowed to one environment or one directory",
2509
+ tags: ["submissions"],
2510
+ successDescription: "The list of submission packages"
2511
+ }).errors({ NOT_FOUND: {} }).input(z.object({
2512
+ projectId: z.string().describe("The ID of the project"),
2513
+ environmentId: z.string().optional().describe("Filter by environment ID"),
2514
+ platform: platformSchema.optional().describe(PLATFORM_DESCRIPTION)
2515
+ })).output(z.array(submissionSchema));
2516
+ const getSubmissionContractV1 = base.route({
2517
+ path: "/v1/submissions/{submissionId}",
2518
+ method: "GET",
2519
+ summary: "Get a submission package",
2520
+ description: "Get a submission package by ID, including its form data and the prefill it started from",
2521
+ tags: ["submissions"],
2522
+ successDescription: "The submission package"
2523
+ }).errors({ NOT_FOUND: {} }).input(z.object({ submissionId: submissionIdSchema })).output(submissionSchema);
2524
+ const updateSubmissionContractV1 = base.route({
2525
+ path: "/v1/submissions/{submissionId}",
2526
+ method: "PUT",
2527
+ summary: "Update a submission package",
2528
+ description: "Update the form data of a submission package. Only the fields you send are changed; the rest are left as they are. Unknown field names are rejected rather than ignored, so a typo fails the call. `platform` must match the package's own platform.",
2529
+ tags: ["submissions"],
2530
+ successDescription: "The updated submission package"
2531
+ }).errors({ NOT_FOUND: {} }).input(z.discriminatedUnion("platform", [z.object({
2532
+ submissionId: submissionIdSchema,
2533
+ platform: z.literal("claudeai").describe(PLATFORM_DESCRIPTION),
2534
+ formData: claudeSubmissionUpdateSchema
2535
+ }), z.object({
2536
+ submissionId: submissionIdSchema,
2537
+ platform: z.literal("chatgpt").describe(PLATFORM_DESCRIPTION),
2538
+ formData: chatgptSubmissionUpdateSchema
2539
+ })])).output(submissionSchema);
2237
2540
  const contract = {
2238
2541
  teams: {
2239
2542
  list: { v1: listTeamsContractV1 },
@@ -2259,6 +2562,7 @@ const contract = {
2259
2562
  environments: {
2260
2563
  create: { v1: createEnvironmentContractV1 },
2261
2564
  get: { v1: getEnvironmentContractV1 },
2565
+ delete: { v1: deleteEnvironmentContractV1 },
2262
2566
  deploy: { v1: deployEnvironmentContractV1 },
2263
2567
  getLogs: { v1: getLogsContractV1 },
2264
2568
  getLatestLogs: { v1: getLatestLogsContractV1 }
@@ -2269,6 +2573,12 @@ const contract = {
2269
2573
  update: { v1: updateEnvironmentVariableContractV1 },
2270
2574
  delete: { v1: deleteEnvironmentVariableContractV1 }
2271
2575
  },
2576
+ telemetryDestinations: {
2577
+ list: { v1: listTelemetryDestinationsContractV1 },
2578
+ create: { v1: createTelemetryDestinationContractV1 },
2579
+ update: { v1: updateTelemetryDestinationContractV1 },
2580
+ delete: { v1: deleteTelemetryDestinationContractV1 }
2581
+ },
2272
2582
  projects: {
2273
2583
  update: { v1: updateProjectContractV1 },
2274
2584
  get: { v1: getProjectContractV1 },
@@ -2288,6 +2598,12 @@ const contract = {
2288
2598
  beacon: {
2289
2599
  create: { v1: createBeaconContractV1 },
2290
2600
  get: { v1: getBeaconContractV1 }
2601
+ },
2602
+ submissions: {
2603
+ create: { v1: createSubmissionContractV1 },
2604
+ list: { v1: listSubmissionsContractV1 },
2605
+ get: { v1: getSubmissionContractV1 },
2606
+ update: { v1: updateSubmissionContractV1 }
2291
2607
  }
2292
2608
  };
2293
2609
  const { uploadArtifact: _discard, ...deploymentsForDocs } = contract.deployments;
@@ -2295,5 +2611,26 @@ const contractForDocs = {
2295
2611
  ...contract,
2296
2612
  deployments: deploymentsForDocs
2297
2613
  };
2614
+ /** Shared by the served `openapi.json` and the snapshot test that guards it, so the two cannot drift. */
2615
+ const OPENAPI_DOC_OPTIONS = {
2616
+ info: {
2617
+ title: "Alpic API",
2618
+ version: "1.0.0"
2619
+ },
2620
+ servers: [{ url: "https://api.alpic.ai" }],
2621
+ security: [{ bearerAuth: [] }],
2622
+ components: { securitySchemes: { bearerAuth: {
2623
+ type: "http",
2624
+ description: "Bearer token for authentication. Use an API key from the API Keys page in team settings, or an OAuth access token.",
2625
+ scheme: "bearer"
2626
+ } } },
2627
+ commonSchemas: {
2628
+ Submission: { schema: submissionSchema },
2629
+ ClaudeSubmissionFormData: { schema: claudeSubmissionDraftSchema },
2630
+ ChatgptSubmissionFormData: { schema: chatgptSubmissionDraftSchema },
2631
+ ClaudeSubmissionFormDataUpdate: { schema: claudeSubmissionUpdateSchema },
2632
+ ChatgptSubmissionFormDataUpdate: { schema: chatgptSubmissionUpdateSchema }
2633
+ }
2634
+ };
2298
2635
  //#endregion
2299
- export { AUTH_SCOPE_ANY, AUTH_SCOPE_USER, INTENT_CATEGORY_COLORS, PLATFORM_LABELS, buildSettingsSchema, contract, contractForDocs, createEnvironmentContractV1, deploymentStatusSchema, environmentVariableSchema, environmentVariablesSchema, intentCategoryColorSchema, playgroundExamplePromptSchema, playgroundHeaderSchema, runtimeSchema, serverFieldsSchema, transportSchema, updateEnvironmentVariableSchema };
2636
+ export { AI_PLATFORMS, AUTH_SCOPE_ANY, AUTH_SCOPE_USER, INTENT_CATEGORY_COLORS, OPENAPI_DOC_OPTIONS, OTLP_PROTOCOLS, PLATFORM_LABELS, TELEMETRY_SIGNALS, buildSettingsSchema, chatgptSubmissionUpdateSchema, claudeSubmissionUpdateSchema, contract, contractForDocs, createEnvironmentContractV1, deploymentStatusSchema, environmentVariableSchema, environmentVariablesSchema, intentCategoryColorSchema, otlpProtocolSchema, playgroundExamplePromptSchema, playgroundHeaderSchema, runtimeSchema, serverFieldsSchema, telemetrySignalSchema, transportSchema, updateEnvironmentVariableSchema };