@alpic-ai/api 0.0.0-dev.gef959c0 → 0.0.0-dev.gefacfca

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.
Files changed (3) hide show
  1. package/dist/index.d.mts +1523 -59
  2. package/dist/index.mjs +553 -188
  3. package/package.json +7 -7
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.29.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth.js
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
6
6
  /**
7
7
  * Reusable URL validation that disallows javascript: scheme
8
8
  */
@@ -169,11 +169,21 @@ z$1.object({
169
169
  token: z$1.string(),
170
170
  token_type_hint: z$1.string().optional()
171
171
  }).strip();
172
- const platformSchema = z.enum(["chatgpt", "claudeai"]);
172
+ //#endregion
173
+ //#region ../domains/dist/index.mjs
174
+ const AI_PLATFORMS = ["chatgpt", "claudeai"];
175
+ const platformSchema = z.enum(AI_PLATFORMS);
173
176
  const PLATFORM_LABELS = {
174
177
  chatgpt: "ChatGPT",
175
178
  claudeai: "Claude.ai"
176
179
  };
180
+ const WAF_PLATFORMS = [
181
+ "akamai",
182
+ "cloudflare",
183
+ "fastly"
184
+ ];
185
+ const ALLOWED_PLATFORMS = [...AI_PLATFORMS, ...WAF_PLATFORMS];
186
+ const allowedPlatformSchema = z.enum(ALLOWED_PLATFORMS);
177
187
  const auditStatusSchema = z.enum([
178
188
  "pending",
179
189
  "partial",
@@ -246,6 +256,16 @@ z.object({
246
256
  clientSecret: z.string(),
247
257
  clientScopes: z.array(z.string())
248
258
  });
259
+ z.enum([
260
+ "opening_balance",
261
+ "free_seed",
262
+ "paid_conversion_floor",
263
+ "top_up",
264
+ "usage",
265
+ "refund",
266
+ "admin_adjustment"
267
+ ]);
268
+ z.enum(["playground"]);
249
269
  const deploymentStatusSchema$1 = z.enum([
250
270
  "ongoing",
251
271
  "deployed",
@@ -273,34 +293,51 @@ const deploymentSummarySchema = z.object({
273
293
  createdAt: z.coerce.date(),
274
294
  updatedAt: z.coerce.date()
275
295
  });
276
- /**
277
- * Public environment
278
- *
279
- * No OAuth metadata exposed.
280
- */
296
+ /** Public environment: answers anonymously and exposes no OAuth metadata. */
281
297
  const publicEnvironmentSchema = z.object({
298
+ allowsAnonymous: z.literal(true),
299
+ oAuthMetadata: z.strictObject({})
300
+ });
301
+ /** Protected environment whose external resource metadata URL is returned in the WWW-Authenticate header on the first 401; everything after is handled outside the MCP server scope. */
302
+ const externalResourceMetadataEnvironmentSchema = z.object({
303
+ allowsAnonymous: z.boolean(),
304
+ oAuthMetadata: z.object({ externalResourceMetadataUrl: z.url() }),
305
+ scope: z.string().optional()
306
+ });
307
+ /** Protected environment whose own /.well-known/oauth-protected-resource endpoint points at an external authorization server; everything after is handled outside the MCP server scope. */
308
+ const externalAuthorizationServerEnvironmentSchema = z.object({
309
+ allowsAnonymous: z.boolean(),
310
+ oAuthMetadata: z.object({
311
+ externalAuthorizationServerUrl: z.url(),
312
+ resourceMetadata: OAuthProtectedResourceMetadataSchema.optional()
313
+ }),
314
+ scope: z.string().optional()
315
+ });
316
+ /** Standalone protected environment: the server itself exposes both the /.well-known/oauth-protected-resource and /.well-known/oauth-authorization-server endpoints. */
317
+ const standaloneEnvironmentSchema = z.object({
318
+ allowsAnonymous: z.boolean(),
319
+ oAuthMetadata: z.object({
320
+ authorizationServerMetadata: z.union([OAuthMetadataSchema, OpenIdProviderDiscoveryMetadataSchema]),
321
+ resourceMetadata: OAuthProtectedResourceMetadataSchema.optional()
322
+ }),
323
+ scope: z.string().optional()
324
+ });
325
+ /** Protected environment that enforces authentication but advertises no OAuth discovery metadata; clients must obtain credentials out-of-band. */
326
+ const protectedWithoutDiscoveryEnvironmentSchema = z.object({
327
+ allowsAnonymous: z.literal(false),
328
+ oAuthMetadata: z.strictObject({}),
329
+ scope: z.string().optional()
330
+ });
331
+ const legacyPublicEnvironmentSchema = z.object({
282
332
  isPublic: z.literal(true),
283
333
  oAuthMetadata: z.undefined().optional()
284
334
  });
285
- /**
286
- * Protected environment with an external resource metadata URL
287
- *
288
- * An external resource metadata URL is returned in the WWW-Authenticate header during the first 401 response.
289
- * Everything that follows is handled outside of the MCP server scope.
290
- */
291
- const externalResourceMetadataEnvironmentSchema = z.object({
335
+ const legacyExternalResourceMetadataEnvironmentSchema = z.object({
292
336
  isPublic: z.literal(false),
293
337
  oAuthMetadata: z.object({ externalResourceMetadataUrl: z.url() }),
294
338
  scope: z.string().optional()
295
339
  });
296
- /**
297
- * Protected environment with an external authorization server URL
298
- *
299
- * The server itself exposes the /.well-known/oauth-protected-resource endpoint.
300
- * An external authorization server URL is returned when requesting the endpoint.
301
- * Everything that follows is handled outside of the MCP server scope.
302
- */
303
- const externalAuthorizationServerEnvironmentSchema = z.object({
340
+ const legacyExternalAuthorizationServerEnvironmentSchema = z.object({
304
341
  isPublic: z.literal(false),
305
342
  oAuthMetadata: z.object({
306
343
  externalAuthorizationServerUrl: z.url(),
@@ -308,13 +345,7 @@ const externalAuthorizationServerEnvironmentSchema = z.object({
308
345
  }),
309
346
  scope: z.string().optional()
310
347
  });
311
- /**
312
- * Standalone protected environment
313
- *
314
- * The server itself exposes the /.well-known/oauth-protected-resource endpoint.
315
- * The server itself exposes the /.well-known/oauth-authorization-server endpoint.
316
- */
317
- const standaloneEnvironmentSchema = z.object({
348
+ const legacyStandaloneEnvironmentSchema = z.object({
318
349
  isPublic: z.literal(false),
319
350
  oAuthMetadata: z.object({
320
351
  authorizationServerMetadata: z.union([OAuthMetadataSchema, OpenIdProviderDiscoveryMetadataSchema]),
@@ -322,14 +353,7 @@ const standaloneEnvironmentSchema = z.object({
322
353
  }),
323
354
  scope: z.string().optional()
324
355
  });
325
- /**
326
- * Protected environment without OAuth discovery
327
- *
328
- * The server enforces authentication but exposes no OAuth discovery metadata.
329
- * Neither /.well-known/oauth-protected-resource nor /.well-known/oauth-authorization-server
330
- * are advertised. Clients must obtain credentials out-of-band.
331
- */
332
- const protectedWithoutDiscoveryEnvironmentSchema = z.object({
356
+ const legacyProtectedWithoutDiscoveryEnvironmentSchema = z.object({
333
357
  isPublic: z.literal(false),
334
358
  oAuthMetadata: z.strictObject({}),
335
359
  scope: z.string().optional()
@@ -339,9 +363,13 @@ z.union([
339
363
  externalResourceMetadataEnvironmentSchema,
340
364
  externalAuthorizationServerEnvironmentSchema,
341
365
  standaloneEnvironmentSchema,
342
- protectedWithoutDiscoveryEnvironmentSchema
366
+ protectedWithoutDiscoveryEnvironmentSchema,
367
+ legacyPublicEnvironmentSchema,
368
+ legacyExternalResourceMetadataEnvironmentSchema,
369
+ legacyExternalAuthorizationServerEnvironmentSchema,
370
+ legacyStandaloneEnvironmentSchema,
371
+ legacyProtectedWithoutDiscoveryEnvironmentSchema
343
372
  ]);
344
- const allowedPlatformSchema = platformSchema;
345
373
  const playgroundModelSchema = z.enum([
346
374
  "global.anthropic.claude-haiku-4-5-20251001-v1:0",
347
375
  "global.anthropic.claude-sonnet-4-5-20250929-v1:0",
@@ -350,6 +378,7 @@ const playgroundModelSchema = z.enum([
350
378
  ]);
351
379
  const environmentDomainSchema = z.object({
352
380
  name: z.string(),
381
+ pathPrefix: z.string(),
353
382
  status: z.enum([
354
383
  "ongoing",
355
384
  "deployed",
@@ -381,14 +410,16 @@ z.object({
381
410
  collectRequestPayload: z.boolean(),
382
411
  collectResponsePayload: z.boolean(),
383
412
  collectErrorMessage: z.boolean(),
384
- collectUserData: z.boolean()
413
+ collectUserData: z.boolean(),
414
+ identityTraitKey: z.string().min(1).max(200).nullable()
385
415
  });
386
- z.object({
416
+ const feedbackSchema = z.object({
387
417
  id: z.string(),
388
418
  createdAt: z.coerce.date(),
389
419
  environmentId: z.string(),
390
420
  content: z.string(),
391
- source: z.enum(["model", "user"])
421
+ source: z.enum(["model", "user"]),
422
+ clientName: z.string().nullable()
392
423
  });
393
424
  z.object({
394
425
  content: z.string(),
@@ -404,7 +435,7 @@ const intentCategoryColorSchema = z.enum([
404
435
  "pink",
405
436
  "gray"
406
437
  ]);
407
- intentCategoryColorSchema.options;
438
+ const INTENT_CATEGORY_COLORS = intentCategoryColorSchema.options;
408
439
  const intentCategorySchema = z.object({
409
440
  id: z.string(),
410
441
  createdAt: z.coerce.date(),
@@ -412,7 +443,7 @@ const intentCategorySchema = z.object({
412
443
  name: z.string(),
413
444
  color: intentCategoryColorSchema
414
445
  });
415
- z.object({
446
+ const intentCategorySummarySchema = z.object({
416
447
  id: z.string(),
417
448
  name: z.string(),
418
449
  color: intentCategoryColorSchema,
@@ -424,6 +455,7 @@ z.object({
424
455
  environmentId: z.string(),
425
456
  toolName: z.string(),
426
457
  message: z.string(),
458
+ clientName: z.string().nullable(),
427
459
  categories: z.array(intentCategorySchema)
428
460
  });
429
461
  const signalCategorySchema = z.object({
@@ -488,6 +520,246 @@ z.enum([
488
520
  "DEBUG",
489
521
  "ERROR"
490
522
  ]);
523
+ /** Only names a vendor actually ships belong here: lookalikes like `claude-code-test` are customers' own scripts. */
524
+ const MCP_CLIENT_GROUPS = [
525
+ {
526
+ id: "claude_code",
527
+ label: "Claude Code",
528
+ vendor: "anthropic",
529
+ rawNames: ["claude-code", "Anthropic/ClaudeCodeDesktop"]
530
+ },
531
+ {
532
+ id: "claude",
533
+ label: "Claude",
534
+ vendor: "anthropic",
535
+ rawNames: [
536
+ "Anthropic/ClaudeAI",
537
+ "claude-ai",
538
+ "claude",
539
+ "Claude",
540
+ "claude-desktop",
541
+ "claude-desktop-3p"
542
+ ]
543
+ },
544
+ {
545
+ id: "claude_mobile",
546
+ label: "Claude mobile",
547
+ vendor: "anthropic",
548
+ rawNames: ["claude-ios", "ClaudeAndroid"]
549
+ },
550
+ {
551
+ id: "claude_cowork",
552
+ label: "Claude Cowork",
553
+ vendor: "anthropic",
554
+ rawNames: ["Anthropic/Cowork"]
555
+ },
556
+ {
557
+ id: "claude_toolbox",
558
+ label: "Claude Toolbox",
559
+ vendor: "anthropic",
560
+ rawNames: ["Anthropic/Toolbox", "Anthropic/toolbox-bootstrap"]
561
+ },
562
+ {
563
+ id: "anthropic_api",
564
+ label: "Anthropic API",
565
+ vendor: "anthropic",
566
+ rawNames: ["Anthropic/API"]
567
+ },
568
+ {
569
+ id: "anthropic_connector_refresh",
570
+ label: "Anthropic (connector refresh)",
571
+ vendor: "anthropic",
572
+ rawNames: ["Anthropic"]
573
+ },
574
+ {
575
+ id: "codex",
576
+ label: "Codex",
577
+ vendor: "openai",
578
+ rawNames: [
579
+ "codex-mcp-client",
580
+ "codex",
581
+ "Codex",
582
+ "codex-cli",
583
+ "openai-mcp (Codex)"
584
+ ]
585
+ },
586
+ {
587
+ id: "chatgpt",
588
+ label: "ChatGPT",
589
+ vendor: "openai",
590
+ rawNames: ["openai-mcp (ChatGPT)"]
591
+ },
592
+ {
593
+ id: "openai_responses_api",
594
+ label: "OpenAI Responses API",
595
+ vendor: "openai",
596
+ rawNames: ["openai-mcp (Responses API)"]
597
+ },
598
+ {
599
+ id: "openai_agent_builder",
600
+ label: "OpenAI Agent Builder",
601
+ vendor: "openai",
602
+ rawNames: ["openai-mcp (Agent Builder)"]
603
+ },
604
+ {
605
+ id: "openai_other",
606
+ label: "OpenAI Other",
607
+ vendor: "openai",
608
+ rawNames: ["openai-mcp"]
609
+ },
610
+ {
611
+ id: "cursor",
612
+ label: "Cursor",
613
+ vendor: "cursor",
614
+ rawNames: [
615
+ "cursor-vscode",
616
+ "Cursor",
617
+ "cursor"
618
+ ]
619
+ },
620
+ {
621
+ id: "cline",
622
+ label: "Cline",
623
+ vendor: "cline",
624
+ rawNames: [
625
+ "Cline",
626
+ "cline",
627
+ "@cline/core"
628
+ ]
629
+ },
630
+ {
631
+ id: "github_copilot",
632
+ label: "GitHub Copilot",
633
+ vendor: "githubCopilot",
634
+ rawNames: [
635
+ "Copilot",
636
+ "github-copilot-developer",
637
+ "Copilot MCP Gateway",
638
+ "Xcode/copilot-xcode"
639
+ ]
640
+ },
641
+ {
642
+ id: "gemini_cli",
643
+ label: "Gemini CLI",
644
+ vendor: "google",
645
+ rawNames: ["gemini-cli-mcp-client", "gemini-cli"]
646
+ },
647
+ {
648
+ id: "antigravity",
649
+ label: "Antigravity",
650
+ vendor: "google",
651
+ rawNames: ["antigravity-client"]
652
+ },
653
+ {
654
+ id: "gemini",
655
+ label: "Gemini",
656
+ vendor: "google",
657
+ rawNames: ["Gemini", "google-ai-edge-gallery"]
658
+ },
659
+ {
660
+ id: "windsurf",
661
+ label: "Windsurf",
662
+ vendor: "windsurf",
663
+ rawNames: ["Windsurf", "windsurf-client"]
664
+ },
665
+ {
666
+ id: "mistral",
667
+ label: "Mistral / Le Chat",
668
+ vendor: "mistral",
669
+ rawNames: ["Mistral"],
670
+ rawNamePrefixes: ["connector:custom-mcp:"]
671
+ },
672
+ {
673
+ id: "n8n",
674
+ label: "n8n",
675
+ vendor: "n8n",
676
+ rawNames: [
677
+ "@n8n/n8n-nodes-langchain.mcpClient",
678
+ "@n8n/n8n-nodes-langchain.mcpClientTool",
679
+ "n8n"
680
+ ]
681
+ },
682
+ {
683
+ id: "alpic_playground",
684
+ label: "Alpic Playground",
685
+ vendor: "alpic",
686
+ rawNames: ["alpic-playground", "playground"]
687
+ },
688
+ {
689
+ id: "opencode",
690
+ label: "opencode",
691
+ vendor: "opencode",
692
+ rawNames: ["opencode"]
693
+ },
694
+ {
695
+ id: "zed",
696
+ label: "Zed",
697
+ vendor: "zed",
698
+ rawNames: ["Zed", "zed"]
699
+ },
700
+ {
701
+ id: "zapier",
702
+ label: "Zapier",
703
+ vendor: "zapier",
704
+ rawNames: ["Zapier", "zapier"]
705
+ },
706
+ {
707
+ id: "make",
708
+ label: "Make",
709
+ vendor: "make",
710
+ rawNames: ["Make", "make"]
711
+ },
712
+ {
713
+ id: "librechat",
714
+ label: "LibreChat",
715
+ vendor: "mcp",
716
+ rawNames: ["LibreChat", "librechat"]
717
+ },
718
+ {
719
+ id: "jan",
720
+ label: "Jan",
721
+ vendor: "mcp",
722
+ rawNames: ["Jan", "jan"]
723
+ },
724
+ {
725
+ id: "goose",
726
+ label: "goose",
727
+ vendor: "mcp",
728
+ rawNames: ["goose", "Goose"]
729
+ },
730
+ {
731
+ id: "mcphost",
732
+ label: "mcphost",
733
+ vendor: "mcp",
734
+ rawNames: ["mcphost"]
735
+ },
736
+ {
737
+ id: "mcporter",
738
+ label: "mcporter",
739
+ vendor: "mcp",
740
+ rawNames: ["mcporter"]
741
+ },
742
+ {
743
+ id: "rmcp",
744
+ label: "rmcp",
745
+ vendor: "mcp",
746
+ rawNames: ["rmcp"]
747
+ },
748
+ {
749
+ id: "unnamed_client",
750
+ label: "Unnamed client",
751
+ vendor: "mcp",
752
+ rawNames: [
753
+ "mcp",
754
+ "unknown",
755
+ ""
756
+ ]
757
+ }
758
+ ];
759
+ /** A source pattern, not a RegExp, because analytics renders the same rule into ClickHouse RE2, which shares this syntax. */
760
+ const MCP_REMOTE_WRAPPER_SUFFIX = String.raw` \(via mcp-remote [^\n]+?\)$`;
761
+ new RegExp(MCP_REMOTE_WRAPPER_SUFFIX);
762
+ new Map(MCP_CLIENT_GROUPS.map((group) => [group.id, group]));
491
763
  const runtimeSchema = z.enum([
492
764
  "python3.13",
493
765
  "python3.14",
@@ -565,15 +837,7 @@ z.object({
565
837
  serverFields: serverFieldsSchema$1,
566
838
  source: z.enum(["registry", "defaults"])
567
839
  });
568
- /**
569
- * Returns a variant of a `maxLength`-constrained string that clamps (truncates) instead of
570
- * rejecting on overflow — used for AI-generated copy where the model routinely overshoots.
571
- *
572
- * NOTE: this rebuilds the schema from scratch, carrying over only `maxLength` (as a clamp),
573
- * `minLength`, and the description. Any other validators on the source field (`.regex()`,
574
- * `.email()`, custom refinements) are intentionally dropped — this helper is meant for plain
575
- * free-text length caps only. A field with `null` `maxLength` is returned unchanged.
576
- */
840
+ /** Clamps instead of rejecting on max-length overflow (for AI-generated copy that overshoots); intentionally carries over only maxLength, minLength, and description, dropping any other validators. */
577
841
  const clampStringField = (field) => {
578
842
  const max = field.maxLength;
579
843
  if (max === null) return field;
@@ -919,11 +1183,7 @@ const chatgptToolJustificationSchema = z.object({
919
1183
  openWorldJustification: z.string().describe("One sentence on whether the tool reaches external systems beyond your own service."),
920
1184
  destructiveJustification: z.string().describe("One sentence on whether the tool changes data. For a read-only tool, state the full triad: \"No data is created, modified, or deleted.\"")
921
1185
  }).describe("Per-tool justification of each MCP annotation value (one specific sentence per hint).");
922
- /**
923
- * Base copy fields, defined once and reused by both the submission form and per-locale
924
- * translations so the constraints (tagline ≤ 30 chars) never drift. The translation generation
925
- * path wraps these in {@link clampStringField} since the LLM tends to overshoot the limit.
926
- */
1186
+ /** Defined once and reused by both the submission form and per-locale translations so the tagline ≤ 30 chars constraint never drifts. */
927
1187
  const chatgptTaglineSchema = z.string().max(30);
928
1188
  const chatgptDescriptionSchema = z.string();
929
1189
  const chatgptTranslationSchema = z.object({
@@ -932,10 +1192,7 @@ const chatgptTranslationSchema = z.object({
932
1192
  description: chatgptDescriptionSchema
933
1193
  }).describe("Locale-scoped override for tagline + description. English (US) is the default.");
934
1194
  chatgptTranslationSchema.extend({ tagline: clampStringField(chatgptTaglineSchema) });
935
- /**
936
- * Field order mirrors the ChatGPT (OpenAI) submission spreadsheet, grouped by section.
937
- * When adding/removing/reordering fields, keep this in sync with the sheet.
938
- */
1195
+ /** Field order mirrors the ChatGPT (OpenAI) submission spreadsheet, grouped by section; keep it in sync with the sheet. */
939
1196
  const chatgptSubmissionFormDataSchema = z.object({
940
1197
  logoLight: z.string().describe("Logo icon for light mode. Square PNG, no borders or rounded corners (clients apply circular cropping)."),
941
1198
  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."),
@@ -1032,11 +1289,7 @@ const claudePolicyAcknowledgementSchema = z.enum([
1032
1289
  "My connector does not collect conversation data beyond what is needed for its function.",
1033
1290
  "Public documentation for this connector will be live by the publish date."
1034
1291
  ]);
1035
- /**
1036
- * Field order mirrors the claude.ai directory submission wizard
1037
- * (`claude.ai/admin-settings/directory/submissions/new`), grouped by step.
1038
- * When adding/removing/reordering fields, keep this in sync with the wizard.
1039
- */
1292
+ /** Field order mirrors the claude.ai directory submission wizard (`claude.ai/admin-settings/directory/submissions/new`), grouped by step; keep it in sync with the wizard. */
1040
1293
  const claudeSubmissionFormDataSchema = z.object({
1041
1294
  serverUrl: z.url().describe(`The full https:// URL where your MCP server is hosted and reachable. In the claude.ai wizard this is read live
1042
1295
  from the custom connector you select — the connection is used to verify the URL and the tool list at submission time.
@@ -1128,12 +1381,7 @@ claudeSubmissionFormDataSchema.pick({
1128
1381
  connectionRequirements: claudeSubmissionFormDataSchema.shape.connectionRequirements.optional(),
1129
1382
  testInstructions: claudeSubmissionFormDataSchema.shape.testInstructions.optional()
1130
1383
  });
1131
- /**
1132
- * Narrative fields the LLM-backed generation step produces for Claude submissions.
1133
- * This schema accepts the slightly loose shape returned by AI generation, then normalizes it into
1134
- * the strict form shape. Keep transforms here rather than in callers so generation leniency is
1135
- * colocated with the Claude contract.
1136
- */
1384
+ /** Loose shape returned by AI generation for Claude narrative fields; transforms live here so generation leniency stays colocated with the Claude contract. */
1137
1385
  const claudeAiGeneratedFormDataRawSchema = z.object({
1138
1386
  oneLiner: claudeSubmissionFormDataSchema.shape.oneLiner,
1139
1387
  description: claudeSubmissionFormDataSchema.shape.description,
@@ -1161,6 +1409,11 @@ const chatgptSubmissionSchemaInternal = submissionMetaFieldsSchema.extend({
1161
1409
  });
1162
1410
  z.discriminatedUnion("platform", [claudeSubmissionSchemaInternal, chatgptSubmissionSchemaInternal]);
1163
1411
  z.union([claudeSubmissionDraftSchema, chatgptSubmissionDraftSchema]);
1412
+ z.literal([
1413
+ 100,
1414
+ 75,
1415
+ 50
1416
+ ]);
1164
1417
  const subscriptionPlanSchema = z.enum([
1165
1418
  "pro",
1166
1419
  "business",
@@ -1178,6 +1431,7 @@ const customerUsageSchema = z.object({
1178
1431
  periodEnd: z.number()
1179
1432
  });
1180
1433
  const partnerDiscountSchema = z.object({ endsAt: z.number() });
1434
+ z.object({ balanceInNanoUSD: z.number() });
1181
1435
  z.object({
1182
1436
  customerCredits: customerCreditsSchema.nullable(),
1183
1437
  customerUsage: customerUsageSchema.nullable(),
@@ -1225,7 +1479,10 @@ const RESERVED_KEYS = [
1225
1479
  "BUILD_ARG_START_COMMAND",
1226
1480
  "ALPIC_HOST",
1227
1481
  "ALPIC_CUSTOM_DOMAINS",
1228
- "ALPIC_INTENT_META_KEY"
1482
+ "ALPIC_INTENT_META_KEY",
1483
+ "ALPIC_FEEDBACK_META_KEY",
1484
+ "ALPIC_EVENTS_META_KEY",
1485
+ "ALPIC_IDENTIFY_META_KEY"
1229
1486
  ];
1230
1487
  const environmentVariableSchema = z.object({
1231
1488
  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"),
@@ -1306,21 +1563,20 @@ const deploymentSchema = z.object({
1306
1563
  isCurrent: z.boolean(),
1307
1564
  deploymentPageUrl: z.url().nullable()
1308
1565
  });
1309
- const isValidLogTimeInput = (value) => {
1566
+ const isValidTimeInput = (value) => {
1310
1567
  if (ms(value) !== void 0) return true;
1311
1568
  return !Number.isNaN(new Date(value).getTime());
1312
1569
  };
1313
- const createEnvironmentContractV1 = oc.route({
1570
+ const timeInputSchema = z.string().refine(isValidTimeInput, { message: "Invalid time. Use relative (1h, 30m, 2d) or ISO 8601 format." });
1571
+ const base = oc.errors({ BAD_REQUEST: {} });
1572
+ const createEnvironmentContractV1 = base.route({
1314
1573
  path: "/v1/environments",
1315
1574
  method: "POST",
1316
1575
  summary: "Create an environment",
1317
1576
  description: "Create an environment for a project",
1318
1577
  tags: ["environments"],
1319
1578
  successDescription: "The environment has been created successfully"
1320
- }).errors({
1321
- NOT_FOUND: {},
1322
- BAD_REQUEST: {}
1323
- }).input(z.object({
1579
+ }).errors({ NOT_FOUND: {} }).input(z.object({
1324
1580
  projectId: z.string().describe("The ID of the project to create the environment for"),
1325
1581
  name: z.string().min(1).describe("The name of the environment"),
1326
1582
  sourceBranch: z.string().min(1).describe("The branch used to build the environment"),
@@ -1333,7 +1589,7 @@ const createEnvironmentContractV1 = oc.route({
1333
1589
  createdAt: z.coerce.date(),
1334
1590
  projectId: z.string().describe("The ID of the project the environment belongs to")
1335
1591
  }));
1336
- const getEnvironmentContractV1 = oc.route({
1592
+ const getEnvironmentContractV1 = base.route({
1337
1593
  path: "/v1/environments/{environmentId}",
1338
1594
  method: "GET",
1339
1595
  summary: "Get an environment",
@@ -1390,7 +1646,7 @@ const projectOutputSchema = z.object({
1390
1646
  productionEnvironment: productionEnvironmentSchema.nullable(),
1391
1647
  environments: z.array(environmentSchema)
1392
1648
  });
1393
- const getProjectContractV1 = oc.route({
1649
+ const getProjectContractV1 = base.route({
1394
1650
  path: "/v1/projects/{projectId}",
1395
1651
  method: "GET",
1396
1652
  summary: "Get a project",
@@ -1398,18 +1654,15 @@ const getProjectContractV1 = oc.route({
1398
1654
  tags: ["projects"],
1399
1655
  successDescription: "The project details"
1400
1656
  }).errors({ NOT_FOUND: {} }).input(z.object({ projectId: z.string().describe("The ID of the project") })).output(projectOutputSchema);
1401
- const listProjectsContractV1 = oc.route({
1657
+ const listProjectsContractV1 = base.route({
1402
1658
  path: "/v1/projects",
1403
1659
  method: "GET",
1404
1660
  summary: "List projects",
1405
1661
  description: "List all projects for a team",
1406
1662
  tags: ["projects"],
1407
1663
  successDescription: "The list of projects"
1408
- }).errors({
1409
- NOT_FOUND: {},
1410
- BAD_REQUEST: {}
1411
- }).input(z.object({ teamId: z.string().optional() }).optional()).output(z.array(projectOutputSchema));
1412
- const createProjectContractV1 = oc.route({
1664
+ }).errors({ NOT_FOUND: {} }).input(z.object({ teamId: z.string().optional() }).optional()).output(z.array(projectOutputSchema));
1665
+ const createProjectContractV1 = base.route({
1413
1666
  path: "/v1/projects",
1414
1667
  method: "POST",
1415
1668
  summary: "Create a project",
@@ -1418,7 +1671,6 @@ const createProjectContractV1 = oc.route({
1418
1671
  successDescription: "The project has been created successfully"
1419
1672
  }).errors({
1420
1673
  NOT_FOUND: {},
1421
- BAD_REQUEST: {},
1422
1674
  FORBIDDEN: {}
1423
1675
  }).input(z.object({
1424
1676
  teamId: z.string().optional(),
@@ -1459,7 +1711,7 @@ const environmentVariableOutputSchema = z.object({
1459
1711
  isSecret: z.boolean(),
1460
1712
  createdAt: z.coerce.date()
1461
1713
  });
1462
- const listEnvironmentVariablesContractV1 = oc.route({
1714
+ const listEnvironmentVariablesContractV1 = base.route({
1463
1715
  path: "/v1/environments/{environmentId}/environment-variables",
1464
1716
  method: "GET",
1465
1717
  summary: "List environment variables",
@@ -1467,48 +1719,39 @@ const listEnvironmentVariablesContractV1 = oc.route({
1467
1719
  tags: ["environments"],
1468
1720
  successDescription: "The list of environment variables"
1469
1721
  }).errors({ NOT_FOUND: {} }).input(z.object({ environmentId: z.string().describe("The ID of the environment") })).output(z.array(environmentVariableOutputSchema));
1470
- const createEnvironmentVariablesContractV1 = oc.route({
1722
+ const createEnvironmentVariablesContractV1 = base.route({
1471
1723
  path: "/v1/environments/{environmentId}/environment-variables",
1472
1724
  method: "POST",
1473
1725
  summary: "Add environment variables",
1474
1726
  description: "Add one or more environment variables to an environment",
1475
1727
  tags: ["environments"],
1476
1728
  successDescription: "The environment variables have been added successfully"
1477
- }).errors({
1478
- NOT_FOUND: {},
1479
- BAD_REQUEST: {}
1480
- }).input(z.object({
1729
+ }).errors({ NOT_FOUND: {} }).input(z.object({
1481
1730
  environmentId: z.string().describe("The ID of the environment"),
1482
1731
  environmentVariables: environmentVariablesSchema
1483
1732
  })).output(z.object({ success: z.literal(true) }));
1484
- const updateEnvironmentVariableContractV1 = oc.route({
1733
+ const updateEnvironmentVariableContractV1 = base.route({
1485
1734
  path: "/v1/environment-variables/{environmentVariableId}",
1486
1735
  method: "PATCH",
1487
1736
  summary: "Update an environment variable",
1488
1737
  description: "Update an environment variable by ID",
1489
1738
  tags: ["environments"],
1490
1739
  successDescription: "The environment variable has been updated successfully"
1491
- }).errors({
1492
- NOT_FOUND: {},
1493
- BAD_REQUEST: {}
1494
- }).input(z.object({
1740
+ }).errors({ NOT_FOUND: {} }).input(z.object({
1495
1741
  environmentVariableId: z.string().describe("The ID of the environment variable"),
1496
1742
  key: environmentVariableSchema.shape.key,
1497
1743
  value: environmentVariableSchema.shape.value.optional(),
1498
1744
  isSecret: environmentVariableSchema.shape.isSecret.optional()
1499
1745
  })).output(z.object({ success: z.literal(true) }));
1500
- const deleteEnvironmentVariableContractV1 = oc.route({
1746
+ const deleteEnvironmentVariableContractV1 = base.route({
1501
1747
  path: "/v1/environment-variables/{environmentVariableId}",
1502
1748
  method: "DELETE",
1503
1749
  summary: "Delete an environment variable",
1504
1750
  description: "Delete an environment variable by ID",
1505
1751
  tags: ["environments"],
1506
1752
  successDescription: "The environment variable has been deleted successfully"
1507
- }).errors({
1508
- NOT_FOUND: {},
1509
- BAD_REQUEST: {}
1510
- }).input(z.object({ environmentVariableId: z.string().describe("The ID of the environment variable") })).output(z.object({ success: z.literal(true) }));
1511
- const deleteProjectContractV1 = oc.route({
1753
+ }).errors({ NOT_FOUND: {} }).input(z.object({ environmentVariableId: z.string().describe("The ID of the environment variable") })).output(z.object({ success: z.literal(true) }));
1754
+ const deleteProjectContractV1 = base.route({
1512
1755
  path: "/v1/projects/{projectId}",
1513
1756
  method: "DELETE",
1514
1757
  summary: "Delete a project",
@@ -1516,7 +1759,7 @@ const deleteProjectContractV1 = oc.route({
1516
1759
  tags: ["projects"],
1517
1760
  successDescription: "The project has been deleted successfully"
1518
1761
  }).errors({ NOT_FOUND: {} }).input(z.object({ projectId: z.string().describe("The ID of the project") })).output(z.object({ success: z.literal(true) }));
1519
- const updateProjectContractV1 = oc.route({
1762
+ const updateProjectContractV1 = base.route({
1520
1763
  path: "/v1/projects/{projectId}",
1521
1764
  method: "PATCH",
1522
1765
  summary: "Update a project",
@@ -1525,14 +1768,13 @@ const updateProjectContractV1 = oc.route({
1525
1768
  successDescription: "The project has been updated successfully"
1526
1769
  }).errors({
1527
1770
  NOT_FOUND: {},
1528
- BAD_REQUEST: {},
1529
1771
  FORBIDDEN: {}
1530
1772
  }).input(z.object({
1531
1773
  projectId: z.string().describe("The ID of the project"),
1532
1774
  name: z.string().min(1).max(100).optional().describe("The new name for the project"),
1533
1775
  sourceRepository: z.string().nullable().optional().describe("The source repository to connect to the project")
1534
1776
  })).output(projectOutputSchema);
1535
- const deployEnvironmentContractV1 = oc.route({
1777
+ const deployEnvironmentContractV1 = base.route({
1536
1778
  path: "/v1/environments/{environmentId}/deploy",
1537
1779
  method: "POST",
1538
1780
  summary: "Deploy an environment",
@@ -1541,28 +1783,25 @@ const deployEnvironmentContractV1 = oc.route({
1541
1783
  successDescription: "The environment has been deployed successfully"
1542
1784
  }).errors({
1543
1785
  NOT_FOUND: {},
1544
- BAD_REQUEST: {}
1786
+ CONFLICT: {}
1545
1787
  }).input(z.object({
1546
1788
  environmentId: z.string().describe("The ID of the environment to deploy"),
1547
1789
  token: z.string().describe("The token to identify the source archive").optional(),
1548
1790
  settings: buildSettingsSchema.extend({ transport: transportSchema }).optional().describe("Project settings detected by the client from the source. When provided, the server skips downloading and extracting the source archive to detect them.")
1549
1791
  })).output(deploymentSchema);
1550
- const uploadDeploymentArtifactContractV1 = oc.route({
1792
+ const uploadDeploymentArtifactContractV1 = base.route({
1551
1793
  path: "/v1/deployments/upload",
1552
1794
  method: "POST",
1553
1795
  summary: "Upload deployment artifacts",
1554
1796
  description: "Return a presigned S3 URL to upload a deployment artifact",
1555
1797
  tags: ["deployments"],
1556
1798
  successDescription: "The presigned upload URL has been generated successfully"
1557
- }).errors({
1558
- NOT_FOUND: {},
1559
- BAD_REQUEST: {}
1560
- }).input(z.object({ teamId: z.string().optional() }).optional()).output(z.object({
1799
+ }).errors({ NOT_FOUND: {} }).input(z.object({ teamId: z.string().optional() }).optional()).output(z.object({
1561
1800
  uploadUrl: z.url().describe("Presigned S3 URL to upload the source archive with HTTP PUT"),
1562
1801
  token: z.string().describe("Token to identify the source archive"),
1563
1802
  expiresAt: z.coerce.date().describe("Expiration date of the presigned URL")
1564
1803
  }));
1565
- const listDeploymentsContractV1 = oc.route({
1804
+ const listDeploymentsContractV1 = base.route({
1566
1805
  path: "/v1/projects/{projectId}/deployments",
1567
1806
  method: "GET",
1568
1807
  summary: "List project deployments",
@@ -1574,7 +1813,7 @@ const listDeploymentsContractV1 = oc.route({
1574
1813
  status: z.array(deploymentStatusSchema).optional().describe("Filter by one or more statuses"),
1575
1814
  environmentId: z.string().optional().describe("Filter by environment ID")
1576
1815
  })).output(z.array(deploymentSchema));
1577
- const getDeploymentContractV1 = oc.route({
1816
+ const getDeploymentContractV1 = base.route({
1578
1817
  path: "/v1/deployments/{deploymentId}",
1579
1818
  method: "GET",
1580
1819
  summary: "Get a deployment",
@@ -1582,20 +1821,32 @@ const getDeploymentContractV1 = oc.route({
1582
1821
  tags: ["deployments"],
1583
1822
  successDescription: "The deployment details"
1584
1823
  }).errors({ NOT_FOUND: {} }).input(z.object({ deploymentId: z.string().describe("The ID of the deployment") })).output(deploymentSchema);
1585
- const getLogsContractV1 = oc.route({
1824
+ const logEntrySchema = z.object({
1825
+ timestamp: z.coerce.date(),
1826
+ type: z.enum([
1827
+ "START",
1828
+ "END",
1829
+ "INFO",
1830
+ "ERROR",
1831
+ "WARNING",
1832
+ "DEBUG"
1833
+ ]),
1834
+ requestId: z.string(),
1835
+ content: z.string().optional(),
1836
+ method: z.string().optional(),
1837
+ durationInMs: z.number().optional()
1838
+ });
1839
+ const getLogsContractV1 = base.route({
1586
1840
  path: "/v1/environments/{environmentId}/logs",
1587
1841
  method: "GET",
1588
1842
  summary: "Get logs",
1589
1843
  description: "Get logs for an environment",
1590
1844
  tags: ["environments"],
1591
1845
  successDescription: "The logs"
1592
- }).errors({
1593
- NOT_FOUND: {},
1594
- BAD_REQUEST: {}
1595
- }).input(z.object({
1846
+ }).errors({ NOT_FOUND: {} }).input(z.object({
1596
1847
  environmentId: z.string().describe("The ID of the environment"),
1597
- 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)"),
1598
- 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"),
1848
+ since: timeInputSchema.optional().describe("Start time — ISO 8601 (2024-01-01T00:00:00Z) or relative (1h, 30m, 2d)"),
1849
+ until: timeInputSchema.optional().describe("End time — ISO 8601 or relative"),
1599
1850
  limit: z.coerce.number().int().min(1).max(1e3).default(1e3).describe("Maximum number of log entries to return."),
1600
1851
  level: z.array(z.enum([
1601
1852
  "INFO",
@@ -1606,34 +1857,17 @@ const getLogsContractV1 = oc.route({
1606
1857
  search: z.string().optional().describe("Filter pattern to search for in log content"),
1607
1858
  nextToken: z.string().optional().describe("Pagination token from a previous response")
1608
1859
  })).output(z.object({
1609
- logs: z.array(z.object({
1610
- timestamp: z.coerce.date(),
1611
- type: z.enum([
1612
- "START",
1613
- "END",
1614
- "INFO",
1615
- "ERROR",
1616
- "WARNING",
1617
- "DEBUG"
1618
- ]),
1619
- requestId: z.string(),
1620
- content: z.string().optional(),
1621
- method: z.string().optional(),
1622
- durationInMs: z.number().optional()
1623
- })),
1860
+ logs: z.array(logEntrySchema),
1624
1861
  nextToken: z.string().nullable()
1625
1862
  }));
1626
- const getLatestLogsContractV1 = oc.route({
1863
+ const getLatestLogsContractV1 = base.route({
1627
1864
  path: "/v1/environments/{environmentId}/latest-logs",
1628
1865
  method: "GET",
1629
1866
  summary: "Get latest logs",
1630
1867
  description: "Get the N most recent logs for an environment",
1631
1868
  tags: ["environments"],
1632
1869
  successDescription: "The latest logs"
1633
- }).errors({
1634
- NOT_FOUND: {},
1635
- BAD_REQUEST: {}
1636
- }).input(z.object({
1870
+ }).errors({ NOT_FOUND: {} }).input(z.object({
1637
1871
  environmentId: z.string().describe("The ID of the environment"),
1638
1872
  limit: z.coerce.number().int().min(1).max(1e3).default(100).describe("Number of most recent log entries to return"),
1639
1873
  level: z.array(z.enum([
@@ -1643,22 +1877,8 @@ const getLatestLogsContractV1 = oc.route({
1643
1877
  "DEBUG"
1644
1878
  ])).optional().describe("Filter by log level"),
1645
1879
  search: z.string().optional().describe("Filter pattern to search for in log content")
1646
- })).output(z.object({ logs: z.array(z.object({
1647
- timestamp: z.coerce.date(),
1648
- type: z.enum([
1649
- "START",
1650
- "END",
1651
- "INFO",
1652
- "ERROR",
1653
- "WARNING",
1654
- "DEBUG"
1655
- ]),
1656
- requestId: z.string(),
1657
- content: z.string().optional(),
1658
- method: z.string().optional(),
1659
- durationInMs: z.number().optional()
1660
- })) }));
1661
- const getDeploymentLogsContractV1 = oc.route({
1880
+ })).output(z.object({ logs: z.array(logEntrySchema) }));
1881
+ const getDeploymentLogsContractV1 = base.route({
1662
1882
  path: "/v1/deployments/{deploymentId}/logs",
1663
1883
  method: "GET",
1664
1884
  summary: "Get deployment logs",
@@ -1685,17 +1905,14 @@ const analyticsTimeSeriesSchema = z.object({
1685
1905
  output_token_mean: z.array(analyticsDataPointSchema),
1686
1906
  task_count: z.array(analyticsDataPointSchema)
1687
1907
  });
1688
- const getProjectAnalyticsContractV1 = oc.route({
1908
+ const getProjectAnalyticsContractV1 = base.route({
1689
1909
  path: "/v1/analytics/{projectId}",
1690
1910
  method: "GET",
1691
1911
  summary: "Get project analytics",
1692
1912
  description: "Get analytics data for a project over a time range",
1693
1913
  tags: ["analytics"],
1694
1914
  successDescription: "The project analytics data"
1695
- }).errors({
1696
- NOT_FOUND: {},
1697
- BAD_REQUEST: {}
1698
- }).input(z.object({
1915
+ }).errors({ NOT_FOUND: {} }).input(z.object({
1699
1916
  projectId: z.string().describe("The ID of the project"),
1700
1917
  startTimestamp: z.coerce.number().describe("Start timestamp in milliseconds"),
1701
1918
  endTimestamp: z.coerce.number().describe("End timestamp in milliseconds"),
@@ -1710,7 +1927,132 @@ const getProjectAnalyticsContractV1 = oc.route({
1710
1927
  }),
1711
1928
  timeSeries: analyticsTimeSeriesSchema
1712
1929
  }));
1713
- const listTeamsContractV1 = oc.route({
1930
+ const paginatedInsightsInputShape = {
1931
+ environmentId: z.string().describe("The ID of the environment"),
1932
+ since: timeInputSchema.default("7d").describe("Start time — ISO 8601 (2024-01-01T00:00:00Z) or relative (1h, 30m, 2d)"),
1933
+ until: timeInputSchema.optional().describe("End time — ISO 8601 or relative"),
1934
+ limit: z.coerce.number().int().min(1).max(200).default(50),
1935
+ offset: z.coerce.number().int().min(0).default(0),
1936
+ search: z.string().trim().min(1).max(200).optional()
1937
+ };
1938
+ const listIntentsContractV1 = base.route({
1939
+ path: "/v1/environments/{environmentId}/intents",
1940
+ method: "GET",
1941
+ summary: "List intents",
1942
+ description: "List grouped user intents for an environment over a time range",
1943
+ tags: ["insights"],
1944
+ successDescription: "The grouped user intents"
1945
+ }).errors({ NOT_FOUND: {} }).input(z.object({
1946
+ ...paginatedInsightsInputShape,
1947
+ tools: z.array(z.string().trim().min(1)).min(1).max(100).optional(),
1948
+ clientIds: z.array(z.string().min(1)).min(1).max(100).optional(),
1949
+ categoryIds: z.array(z.string().trim().min(1)).min(1).max(100).optional(),
1950
+ sortDir: z.enum(["asc", "desc"]).default("desc")
1951
+ })).output(z.object({
1952
+ intents: z.array(z.object({
1953
+ id: z.string(),
1954
+ intentIds: z.array(z.string()).min(1),
1955
+ environmentId: z.string(),
1956
+ message: z.string(),
1957
+ toolName: z.string(),
1958
+ createdAt: z.coerce.date(),
1959
+ occurrenceCount: z.number().int().positive(),
1960
+ clientName: z.string().nullable(),
1961
+ clientId: z.string().nullable(),
1962
+ categories: z.array(z.object({
1963
+ id: z.string(),
1964
+ name: z.string(),
1965
+ color: intentCategoryColorSchema
1966
+ }))
1967
+ })),
1968
+ totalCount: z.number().int().nonnegative()
1969
+ }));
1970
+ const listFeedbacksContractV1 = base.route({
1971
+ path: "/v1/environments/{environmentId}/feedbacks",
1972
+ method: "GET",
1973
+ summary: "List feedbacks",
1974
+ description: "List user feedback for an environment over a time range",
1975
+ tags: ["insights"],
1976
+ successDescription: "The user feedback"
1977
+ }).errors({ NOT_FOUND: {} }).input(z.object({
1978
+ ...paginatedInsightsInputShape,
1979
+ clientIds: z.array(z.string().min(1)).min(1).max(100).optional()
1980
+ })).output(z.object({
1981
+ feedbacks: z.array(feedbackSchema.extend({ clientId: z.string().nullable() })),
1982
+ totalCount: z.number().int().nonnegative()
1983
+ }));
1984
+ const intentCategoryNameSchema = z.string().trim().min(1).max(100).describe("The category name");
1985
+ const categorizableIntentIdsSchema = z.array(z.string().trim().min(1)).min(1).max(100).describe("IDs of the intents to categorize");
1986
+ const listIntentCategoriesContractV1 = base.route({
1987
+ path: "/v1/environments/{environmentId}/intent-categories",
1988
+ method: "GET",
1989
+ summary: "List intent categories",
1990
+ description: "List intent categories for an environment, including how many intents each category is linked to",
1991
+ tags: ["insights"],
1992
+ successDescription: "The intent categories"
1993
+ }).errors({ NOT_FOUND: {} }).input(z.object({ environmentId: z.string().describe("The ID of the environment") })).output(z.array(intentCategorySummarySchema));
1994
+ const createIntentCategoryContractV1 = base.route({
1995
+ path: "/v1/environments/{environmentId}/intent-categories",
1996
+ method: "POST",
1997
+ summary: "Create an intent category",
1998
+ description: "Create an intent category, optionally linking it to existing intents",
1999
+ tags: ["insights"],
2000
+ successDescription: "The created intent category"
2001
+ }).errors({ NOT_FOUND: {} }).input(z.object({
2002
+ environmentId: z.string().describe("The ID of the environment"),
2003
+ name: intentCategoryNameSchema,
2004
+ color: intentCategoryColorSchema.optional().describe("The category color; derived from the name when omitted"),
2005
+ intentIds: categorizableIntentIdsSchema.optional().describe("IDs of intents to link to the new category")
2006
+ })).output(intentCategorySchema);
2007
+ const updateIntentCategoryContractV1 = base.route({
2008
+ path: "/v1/environments/{environmentId}/intent-categories/{categoryId}",
2009
+ method: "PATCH",
2010
+ summary: "Update an intent category",
2011
+ description: "Rename or recolor an intent category",
2012
+ tags: ["insights"],
2013
+ successDescription: "The updated intent category"
2014
+ }).errors({ NOT_FOUND: {} }).input(z.object({
2015
+ environmentId: z.string().describe("The ID of the environment"),
2016
+ categoryId: z.string().describe("The ID of the category"),
2017
+ name: intentCategoryNameSchema.optional(),
2018
+ color: intentCategoryColorSchema.optional().describe("The category color")
2019
+ }).refine(({ name, color }) => name !== void 0 || color !== void 0, { message: "At least one of name or color must be provided" })).output(intentCategorySchema);
2020
+ const deleteIntentCategoryContractV1 = base.route({
2021
+ path: "/v1/environments/{environmentId}/intent-categories/{categoryId}",
2022
+ method: "DELETE",
2023
+ summary: "Delete an intent category",
2024
+ description: "Delete an intent category; its intents are unlinked but not deleted",
2025
+ tags: ["insights"],
2026
+ successDescription: "The intent category has been deleted successfully"
2027
+ }).errors({ NOT_FOUND: {} }).input(z.object({
2028
+ environmentId: z.string().describe("The ID of the environment"),
2029
+ categoryId: z.string().describe("The ID of the category")
2030
+ })).output(z.object({ success: z.literal(true) }));
2031
+ const linkIntentCategoryContractV1 = base.route({
2032
+ path: "/v1/environments/{environmentId}/intent-categories/{categoryId}/link",
2033
+ method: "POST",
2034
+ summary: "Link an intent category",
2035
+ description: "Link an intent category to intents; already linked intents are ignored",
2036
+ tags: ["insights"],
2037
+ successDescription: "The intents have been linked successfully"
2038
+ }).errors({ NOT_FOUND: {} }).input(z.object({
2039
+ environmentId: z.string().describe("The ID of the environment"),
2040
+ categoryId: z.string().describe("The ID of the category"),
2041
+ intentIds: categorizableIntentIdsSchema
2042
+ })).output(z.object({ success: z.literal(true) }));
2043
+ const unlinkIntentCategoryContractV1 = base.route({
2044
+ path: "/v1/environments/{environmentId}/intent-categories/{categoryId}/unlink",
2045
+ method: "POST",
2046
+ summary: "Unlink an intent category",
2047
+ description: "Unlink an intent category from intents; intents without the category are ignored",
2048
+ tags: ["insights"],
2049
+ successDescription: "The intents have been unlinked successfully"
2050
+ }).errors({ NOT_FOUND: {} }).input(z.object({
2051
+ environmentId: z.string().describe("The ID of the environment"),
2052
+ categoryId: z.string().describe("The ID of the category"),
2053
+ intentIds: categorizableIntentIdsSchema
2054
+ })).output(z.object({ success: z.literal(true) }));
2055
+ const listTeamsContractV1 = base.route({
1714
2056
  path: "/v1/teams",
1715
2057
  method: "GET",
1716
2058
  summary: "List teams",
@@ -1723,7 +2065,22 @@ const listTeamsContractV1 = oc.route({
1723
2065
  createdAt: z.coerce.date(),
1724
2066
  hasStripeAccount: z.boolean()
1725
2067
  })));
1726
- const getTunnelTicketContractV1 = oc.route({
2068
+ const getTeamUsageContractV1 = base.route({
2069
+ path: "/v1/teams/{teamId}/usage",
2070
+ method: "GET",
2071
+ summary: "Get team usage",
2072
+ description: "Get the MCP request usage of a team for its current billing window. A team that has made no request in the window reports zero.",
2073
+ tags: ["teams"],
2074
+ successDescription: "The current billing window usage"
2075
+ }).errors({ NOT_FOUND: {} }).input(z.object({ teamId: z.string().describe("The ID of the team") })).output(z.object({
2076
+ teamId: z.string(),
2077
+ plan: subscriptionPlanSchema.nullable().describe("The plan in force for the window, null on the Free plan"),
2078
+ periodStart: z.coerce.date().describe("Start of the current billing window"),
2079
+ periodEnd: z.coerce.date().describe("End of the current billing window"),
2080
+ requestCount: z.number().int().describe("MCP requests settled during the current billing window"),
2081
+ includedRequests: z.number().int().nullable().describe("Requests included in the plan for one window, null when the allowance is contract-specific")
2082
+ }));
2083
+ const getTunnelTicketContractV1 = base.route({
1727
2084
  path: "/v1/tunnels/ticket",
1728
2085
  method: "GET",
1729
2086
  summary: "Get a tunnel ticket",
@@ -1735,16 +2092,13 @@ const getTunnelTicketContractV1 = oc.route({
1735
2092
  ticket: z.string().describe("The signed tunnel ticket"),
1736
2093
  tunnelHost: z.string().describe("The tunnel host to connect to")
1737
2094
  }));
1738
- const publishServerContractV1 = oc.route({
2095
+ const publishServerContractV1 = base.route({
1739
2096
  path: "/v1/distribution/publish",
1740
2097
  method: "POST",
1741
2098
  summary: "Publish a server to the MCP registry",
1742
2099
  tags: ["distribution"],
1743
2100
  successDescription: "The server has been published successfully"
1744
- }).errors({
1745
- NOT_FOUND: {},
1746
- BAD_REQUEST: {}
1747
- }).input(z.object({
2101
+ }).errors({ NOT_FOUND: {} }).input(z.object({
1748
2102
  projectId: z.string(),
1749
2103
  domain: z.string(),
1750
2104
  title: z.string().min(1).max(100),
@@ -1753,17 +2107,14 @@ const publishServerContractV1 = oc.route({
1753
2107
  iconSrc: z.url().max(255).optional(),
1754
2108
  dryRun: z.boolean().optional()
1755
2109
  })).output(z.object({ serverFields: serverFieldsSchema }));
1756
- const getServerInfoContractV1 = oc.route({
2110
+ const getServerInfoContractV1 = base.route({
1757
2111
  path: "/v1/distribution/get",
1758
2112
  method: "GET",
1759
2113
  summary: "Get server info",
1760
2114
  description: "Get info about a server",
1761
2115
  tags: ["distribution"],
1762
2116
  successDescription: "The server info"
1763
- }).errors({
1764
- NOT_FOUND: {},
1765
- BAD_REQUEST: {}
1766
- }).input(z.object({
2117
+ }).errors({ NOT_FOUND: {} }).input(z.object({
1767
2118
  projectId: z.string(),
1768
2119
  domain: z.string()
1769
2120
  })).output(z.object({ serverFields: serverFieldsSchema }));
@@ -1782,7 +2133,7 @@ const playgroundOutputSchema = z.object({
1782
2133
  isPlaygroundEnabled: z.boolean(),
1783
2134
  serverMetadata: playgroundServerMetadataOutputSchema.nullable()
1784
2135
  });
1785
- const getPlaygroundContractV1 = oc.route({
2136
+ const getPlaygroundContractV1 = base.route({
1786
2137
  path: "/v1/environments/{environmentId}/playground",
1787
2138
  method: "GET",
1788
2139
  summary: "Get playground configuration",
@@ -1790,17 +2141,14 @@ const getPlaygroundContractV1 = oc.route({
1790
2141
  tags: ["environments"],
1791
2142
  successDescription: "The playground configuration"
1792
2143
  }).errors({ NOT_FOUND: {} }).input(z.object({ environmentId: z.string().describe("The ID of the environment") })).output(playgroundOutputSchema);
1793
- const upsertPlaygroundContractV1 = oc.route({
2144
+ const upsertPlaygroundContractV1 = base.route({
1794
2145
  path: "/v1/environments/{environmentId}/playground",
1795
2146
  method: "PUT",
1796
2147
  summary: "Update playground configuration",
1797
2148
  description: "Update the playground configuration for an environment. All fields are optional — only provided fields are updated.",
1798
2149
  tags: ["environments"],
1799
2150
  successDescription: "The updated playground configuration"
1800
- }).errors({
1801
- NOT_FOUND: {},
1802
- BAD_REQUEST: {}
1803
- }).input(z.object({
2151
+ }).errors({ NOT_FOUND: {} }).input(z.object({
1804
2152
  environmentId: z.string().describe("The ID of the environment"),
1805
2153
  isPlaygroundEnabled: z.boolean().optional(),
1806
2154
  name: z.string().min(1).max(100).optional(),
@@ -1808,7 +2156,7 @@ const upsertPlaygroundContractV1 = oc.route({
1808
2156
  headers: z.array(playgroundHeaderSchema).optional(),
1809
2157
  examplePrompts: z.array(playgroundExamplePromptSchema).max(5).optional()
1810
2158
  })).output(playgroundOutputSchema);
1811
- const createBeaconContractV1 = oc.route({
2159
+ const createBeaconContractV1 = base.route({
1812
2160
  path: "/v1/beacon/audits",
1813
2161
  method: "POST",
1814
2162
  summary: "Create a beacon audit",
@@ -1817,7 +2165,6 @@ const createBeaconContractV1 = oc.route({
1817
2165
  successDescription: "The audit has been created"
1818
2166
  }).errors({
1819
2167
  NOT_FOUND: {},
1820
- BAD_REQUEST: {},
1821
2168
  DNS_RESOLUTION_FAILED: { status: 400 }
1822
2169
  }).input(z.object({
1823
2170
  targetUrl: z.url().describe("The HTTPS URL of the MCP server to audit"),
@@ -1825,7 +2172,7 @@ const createBeaconContractV1 = oc.route({
1825
2172
  projectId: z.string().optional().describe("The project ID to associate the audit with"),
1826
2173
  excludeCategories: z.array(checkCategorySchema).optional().describe("Check categories to exclude from the audit")
1827
2174
  })).output(z.object({ id: z.string() }));
1828
- const getBeaconContractV1 = oc.route({
2175
+ const getBeaconContractV1 = base.route({
1829
2176
  path: "/v1/beacon/audits/{auditId}",
1830
2177
  method: "GET",
1831
2178
  summary: "Get a beacon audit",
@@ -1841,8 +2188,21 @@ const getBeaconContractV1 = oc.route({
1841
2188
  report: auditReportWithScreenshotsSchema.nullable()
1842
2189
  }));
1843
2190
  const contract = {
1844
- teams: { list: { v1: listTeamsContractV1 } },
2191
+ teams: {
2192
+ list: { v1: listTeamsContractV1 },
2193
+ getUsage: { v1: getTeamUsageContractV1 }
2194
+ },
1845
2195
  analytics: { get: { v1: getProjectAnalyticsContractV1 } },
2196
+ intents: { list: { v1: listIntentsContractV1 } },
2197
+ intentCategories: {
2198
+ list: { v1: listIntentCategoriesContractV1 },
2199
+ create: { v1: createIntentCategoryContractV1 },
2200
+ update: { v1: updateIntentCategoryContractV1 },
2201
+ delete: { v1: deleteIntentCategoryContractV1 },
2202
+ link: { v1: linkIntentCategoryContractV1 },
2203
+ unlink: { v1: unlinkIntentCategoryContractV1 }
2204
+ },
2205
+ feedbacks: { list: { v1: listFeedbacksContractV1 } },
1846
2206
  deployments: {
1847
2207
  list: { v1: listDeploymentsContractV1 },
1848
2208
  get: { v1: getDeploymentContractV1 },
@@ -1883,5 +2243,10 @@ const contract = {
1883
2243
  get: { v1: getBeaconContractV1 }
1884
2244
  }
1885
2245
  };
2246
+ const { uploadArtifact: _discard, ...deploymentsForDocs } = contract.deployments;
2247
+ const contractForDocs = {
2248
+ ...contract,
2249
+ deployments: deploymentsForDocs
2250
+ };
1886
2251
  //#endregion
1887
- export { AUTH_SCOPE_ANY, AUTH_SCOPE_USER, PLATFORM_LABELS, buildSettingsSchema, contract, createEnvironmentContractV1, deploymentStatusSchema, environmentVariableSchema, environmentVariablesSchema, playgroundExamplePromptSchema, playgroundHeaderSchema, runtimeSchema, serverFieldsSchema, transportSchema, updateEnvironmentVariableSchema };
2252
+ 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 };