@alpic-ai/api 0.0.0-dev.gf8a8743 → 0.0.0-dev.gf8c1cc3
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.d.mts +5725 -100
- package/dist/index.mjs +600 -45
- package/package.json +9 -9
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.
|
|
5
|
+
//#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.0_supports-color@7.2.0_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,6 +267,25 @@ z.object({
|
|
|
256
267
|
clientSecret: z.string(),
|
|
257
268
|
clientScopes: z.array(z.string())
|
|
258
269
|
});
|
|
270
|
+
const creditEntryReasonSchema = z.enum([
|
|
271
|
+
"free_seed",
|
|
272
|
+
"paid_conversion_floor",
|
|
273
|
+
"top_up",
|
|
274
|
+
"usage",
|
|
275
|
+
"admin_adjustment"
|
|
276
|
+
]);
|
|
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
|
+
});
|
|
259
289
|
const deploymentStatusSchema$1 = z.enum([
|
|
260
290
|
"ongoing",
|
|
261
291
|
"deployed",
|
|
@@ -400,9 +430,10 @@ z.object({
|
|
|
400
430
|
collectResponsePayload: z.boolean(),
|
|
401
431
|
collectErrorMessage: z.boolean(),
|
|
402
432
|
collectUserData: z.boolean(),
|
|
403
|
-
identityTraitKey: z.string().min(1).max(200).nullable()
|
|
433
|
+
identityTraitKey: z.string().min(1).max(200).nullable(),
|
|
434
|
+
leadEventName: z.string().min(1).max(200).nullable()
|
|
404
435
|
});
|
|
405
|
-
z.object({
|
|
436
|
+
const feedbackSchema = z.object({
|
|
406
437
|
id: z.string(),
|
|
407
438
|
createdAt: z.coerce.date(),
|
|
408
439
|
environmentId: z.string(),
|
|
@@ -424,7 +455,7 @@ const intentCategoryColorSchema = z.enum([
|
|
|
424
455
|
"pink",
|
|
425
456
|
"gray"
|
|
426
457
|
]);
|
|
427
|
-
intentCategoryColorSchema.options;
|
|
458
|
+
const INTENT_CATEGORY_COLORS = intentCategoryColorSchema.options;
|
|
428
459
|
const intentCategorySchema = z.object({
|
|
429
460
|
id: z.string(),
|
|
430
461
|
createdAt: z.coerce.date(),
|
|
@@ -432,7 +463,7 @@ const intentCategorySchema = z.object({
|
|
|
432
463
|
name: z.string(),
|
|
433
464
|
color: intentCategoryColorSchema
|
|
434
465
|
});
|
|
435
|
-
z.object({
|
|
466
|
+
const intentCategorySummarySchema = z.object({
|
|
436
467
|
id: z.string(),
|
|
437
468
|
name: z.string(),
|
|
438
469
|
color: intentCategoryColorSchema,
|
|
@@ -503,12 +534,30 @@ z.object({
|
|
|
503
534
|
createdAt: z.coerce.date(),
|
|
504
535
|
updatedAt: z.coerce.date()
|
|
505
536
|
});
|
|
537
|
+
const alpicMcpRequestLogSchema = z.object({
|
|
538
|
+
type: z.literal("mcp_request"),
|
|
539
|
+
method: z.string()
|
|
540
|
+
});
|
|
541
|
+
const alpicMcpErrorLogSchema = z.object({
|
|
542
|
+
type: z.literal("mcp_error"),
|
|
543
|
+
method: z.string(),
|
|
544
|
+
error: z.string()
|
|
545
|
+
});
|
|
546
|
+
z.union([alpicMcpRequestLogSchema, alpicMcpErrorLogSchema]);
|
|
506
547
|
z.enum([
|
|
507
548
|
"INFO",
|
|
508
549
|
"WARNING",
|
|
509
550
|
"DEBUG",
|
|
510
551
|
"ERROR"
|
|
511
552
|
]);
|
|
553
|
+
const LOG_SEARCH_MAX_ESCAPED_LENGTH = 960;
|
|
554
|
+
function escapeLogSearchTerm(search) {
|
|
555
|
+
return [...search].flatMap((character) => [...new TextEncoder().encode(character)]).map((byte) => {
|
|
556
|
+
const character = String.fromCharCode(byte);
|
|
557
|
+
return /^[a-zA-Z0-9]$/.test(character) ? character : `\\x${byte.toString(16).toUpperCase().padStart(2, "0")}`;
|
|
558
|
+
}).join("");
|
|
559
|
+
}
|
|
560
|
+
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");
|
|
512
561
|
/** Only names a vendor actually ships belong here: lookalikes like `claude-code-test` are customers' own scripts. */
|
|
513
562
|
const MCP_CLIENT_GROUPS = [
|
|
514
563
|
{
|
|
@@ -834,6 +883,10 @@ const clampStringField = (field) => {
|
|
|
834
883
|
const withMin = field.minLength === null ? clamped : clamped.min(field.minLength);
|
|
835
884
|
return field.description ? withMin.describe(field.description) : withMin;
|
|
836
885
|
};
|
|
886
|
+
const unboundedArrayField = (field) => {
|
|
887
|
+
const unbounded = z.array(field.element);
|
|
888
|
+
return field.description ? unbounded.describe(field.description) : unbounded;
|
|
889
|
+
};
|
|
837
890
|
const toolDefinitionSchema = z.object({
|
|
838
891
|
name: z.string(),
|
|
839
892
|
title: z.string().optional().describe("Human-friendly name for the tool, used in the UI. If not provided, `name` will be used."),
|
|
@@ -846,11 +899,22 @@ const toolDefinitionSchema = z.object({
|
|
|
846
899
|
}).optional()
|
|
847
900
|
});
|
|
848
901
|
const positiveTestCaseSchema = z.object({
|
|
849
|
-
scenario: z.string().describe("Short label for what this case demonstrates."),
|
|
850
|
-
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."),
|
|
902
|
+
scenario: z.string().min(1).describe("Short label for what this case demonstrates."),
|
|
903
|
+
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."),
|
|
851
904
|
toolTriggered: z.string().optional().describe("The tool this prompt should invoke."),
|
|
852
905
|
expectedOutput: z.string().optional().describe("What the user should see, including post-interaction behaviour where relevant.")
|
|
853
|
-
}).
|
|
906
|
+
}).describe("Each case: Scenario, User prompt, Tool triggered, Expected output.");
|
|
907
|
+
const positiveTestCaseDraftSchema = positiveTestCaseSchema.partial().extend({
|
|
908
|
+
scenario: z.string().optional(),
|
|
909
|
+
userPrompt: z.string().optional()
|
|
910
|
+
});
|
|
911
|
+
const blankPositiveTestCase = () => ({
|
|
912
|
+
scenario: "",
|
|
913
|
+
userPrompt: "",
|
|
914
|
+
toolTriggered: "",
|
|
915
|
+
expectedOutput: ""
|
|
916
|
+
});
|
|
917
|
+
const toFixedLength = (entries, length, blank) => Array.from({ length }, (_, index) => entries[index] ?? blank());
|
|
854
918
|
const screenshotEntrySchema = z.object({
|
|
855
919
|
prompt: z.string(),
|
|
856
920
|
url: z.url()
|
|
@@ -1163,9 +1227,18 @@ const chatgptTranslationLocaleSchema = z.enum([
|
|
|
1163
1227
|
"zh-TW"
|
|
1164
1228
|
]);
|
|
1165
1229
|
const negativeTestCaseSchema = z.object({
|
|
1166
|
-
scenario: z.string(),
|
|
1167
|
-
userPrompt: z.string()
|
|
1168
|
-
}).
|
|
1230
|
+
scenario: z.string().min(1),
|
|
1231
|
+
userPrompt: z.string().min(1)
|
|
1232
|
+
}).describe("Each case: Scenario + User prompt (the plugin should NOT trigger).");
|
|
1233
|
+
const negativeTestCaseDraftSchema = negativeTestCaseSchema.partial().extend({
|
|
1234
|
+
scenario: z.string().optional(),
|
|
1235
|
+
userPrompt: z.string().optional()
|
|
1236
|
+
});
|
|
1237
|
+
const blankNegativeTestCase = () => ({
|
|
1238
|
+
scenario: "",
|
|
1239
|
+
userPrompt: ""
|
|
1240
|
+
});
|
|
1241
|
+
const chatgptSkillSchema = z.object({ name: z.string() }).describe("A skill discovered on the MCP server, by name.");
|
|
1169
1242
|
const chatgptToolJustificationSchema = z.object({
|
|
1170
1243
|
toolName: z.string(),
|
|
1171
1244
|
readOnlyJustification: z.string().describe("One sentence on what the tool reads and returns."),
|
|
@@ -1185,27 +1258,28 @@ chatgptTranslationSchema.extend({ tagline: clampStringField(chatgptTaglineSchema
|
|
|
1185
1258
|
const chatgptSubmissionFormDataSchema = z.object({
|
|
1186
1259
|
logoLight: z.string().describe("Logo icon for light mode. Square PNG, no borders or rounded corners (clients apply circular cropping)."),
|
|
1187
1260
|
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."),
|
|
1188
|
-
appName: z.string().describe("The name users will see in ChatGPT and in the
|
|
1261
|
+
appName: z.string().describe("The name users will see in ChatGPT and in the Plugin Directory."),
|
|
1189
1262
|
tagline: chatgptTaglineSchema.describe("Plain-language phrase focused on function and user value, 30 chars max. Avoid generic superlatives like \"the best …\"."),
|
|
1190
|
-
description: chatgptDescriptionSchema.describe("Clear, engaging description highlighting what the
|
|
1263
|
+
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)."),
|
|
1191
1264
|
category: chatgptCategorySchema.describe("Category from the OpenAI taxonomy."),
|
|
1192
|
-
developerName: z.string().describe("Developer name shown publicly on the
|
|
1265
|
+
developerName: z.string().describe("Developer name shown publicly on the plugin's directory page."),
|
|
1193
1266
|
companyUrl: urlField.describe("Your company's main website URL."),
|
|
1194
1267
|
supportChannel: supportChannelSchema.describe("Customer support URL or email address."),
|
|
1195
1268
|
privacyPolicyUrl: urlField.describe("URL to your privacy policy."),
|
|
1196
|
-
termsOfServiceUrl: urlField.describe("URL to the
|
|
1197
|
-
demoRecordingUrl: urlField.describe("URL to a video demonstrating the
|
|
1198
|
-
appCommerceAndPurchasing: z.boolean().describe("Checkbox: 'My
|
|
1269
|
+
termsOfServiceUrl: urlField.describe("URL to the plugin's terms of service."),
|
|
1270
|
+
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."),
|
|
1271
|
+
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."),
|
|
1199
1272
|
serverUrl: urlField.describe("URL of the MCP server."),
|
|
1200
1273
|
authentication: chatgptAuthenticationSchema.describe("OAuth 2.0 or No auth. OAuth configuration is auto-discovered from the MCP server's metadata."),
|
|
1201
1274
|
tools: z.array(toolDefinitionSchema).describe("List of tools exposed by the MCP server (auto-populated from the production server's manifest)."),
|
|
1202
1275
|
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."),
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1276
|
+
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."),
|
|
1277
|
+
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."),
|
|
1278
|
+
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."),
|
|
1279
|
+
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."),
|
|
1206
1280
|
translations: z.array(chatgptTranslationSchema).describe("Per-locale translation of tagline + description. English (US) is the default."),
|
|
1207
1281
|
allowedCountries: chatgptAllowedCountriesSchema.describe("Availability: all supported countries, or an allow-list / block-list of specific ones (ISO alpha-2)."),
|
|
1208
|
-
releaseNotes: z.string().describe("Publicly displayed on the
|
|
1282
|
+
releaseNotes: z.string().describe("Publicly displayed on the plugin details page.")
|
|
1209
1283
|
});
|
|
1210
1284
|
const chatgptSubmissionDraftSchema = chatgptSubmissionFormDataSchema.partial().extend({
|
|
1211
1285
|
tagline: z.string().optional(),
|
|
@@ -1216,23 +1290,35 @@ const chatgptSubmissionDraftSchema = chatgptSubmissionFormDataSchema.partial().e
|
|
|
1216
1290
|
demoRecordingUrl: z.string().optional(),
|
|
1217
1291
|
serverUrl: z.string().optional(),
|
|
1218
1292
|
screenshots: z.array(screenshotDraftEntrySchema).optional(),
|
|
1293
|
+
testCases: z.array(positiveTestCaseDraftSchema).optional(),
|
|
1294
|
+
negativeTestCases: z.array(negativeTestCaseDraftSchema).optional(),
|
|
1219
1295
|
translations: z.array(chatgptTranslationSchema.extend({ tagline: z.string() })).optional()
|
|
1220
1296
|
});
|
|
1221
|
-
|
|
1297
|
+
/** Source of truth for the fields `SubmissionPrefillService.prefill({ platform: "chatgpt" })` can populate. */
|
|
1298
|
+
const chatgptPrefillFormDataSchema = chatgptSubmissionFormDataSchema.pick({
|
|
1222
1299
|
appName: true,
|
|
1223
1300
|
developerName: true,
|
|
1224
1301
|
serverUrl: true,
|
|
1225
1302
|
tools: true,
|
|
1303
|
+
skills: true,
|
|
1226
1304
|
authentication: true
|
|
1227
1305
|
});
|
|
1228
|
-
|
|
1306
|
+
/** Source of truth for `SubmissionPrefillService.generate({ platform: "chatgpt" })`. */
|
|
1307
|
+
const chatgptAiGeneratedFormDataSchema = chatgptSubmissionFormDataSchema.pick({
|
|
1229
1308
|
tagline: true,
|
|
1230
1309
|
description: true,
|
|
1231
1310
|
category: true,
|
|
1232
1311
|
testCases: true,
|
|
1233
1312
|
negativeTestCases: true,
|
|
1234
1313
|
toolJustifications: true
|
|
1235
|
-
}).extend({
|
|
1314
|
+
}).extend({
|
|
1315
|
+
testCases: unboundedArrayField(chatgptSubmissionFormDataSchema.shape.testCases),
|
|
1316
|
+
negativeTestCases: unboundedArrayField(chatgptSubmissionFormDataSchema.shape.negativeTestCases)
|
|
1317
|
+
}).extend({
|
|
1318
|
+
tagline: clampStringField(chatgptSubmissionFormDataSchema.shape.tagline),
|
|
1319
|
+
testCases: z.array(positiveTestCaseDraftSchema).transform((cases) => toFixedLength(cases, 5, blankPositiveTestCase)),
|
|
1320
|
+
negativeTestCases: z.array(negativeTestCaseDraftSchema).transform((cases) => toFixedLength(cases, 3, blankNegativeTestCase))
|
|
1321
|
+
});
|
|
1236
1322
|
const claudeCategorySchema = z.enum([
|
|
1237
1323
|
"Productivity",
|
|
1238
1324
|
"Communication",
|
|
@@ -1355,7 +1441,8 @@ const claudeSubmissionDraftSchema = claudeSubmissionFormDataSchema.partial().ext
|
|
|
1355
1441
|
categories: z.array(claudeCategorySchema).optional(),
|
|
1356
1442
|
screenshots: z.array(screenshotDraftEntrySchema).optional()
|
|
1357
1443
|
});
|
|
1358
|
-
|
|
1444
|
+
/** Source of truth for the fields `SubmissionPrefillService.prefill({ platform: "claudeai" })` can populate. */
|
|
1445
|
+
const claudePrefillFormDataSchema = claudeSubmissionFormDataSchema.pick({
|
|
1359
1446
|
serverUrl: true,
|
|
1360
1447
|
name: true,
|
|
1361
1448
|
slug: true,
|
|
@@ -1377,27 +1464,86 @@ const claudeAiGeneratedFormDataRawSchema = z.object({
|
|
|
1377
1464
|
categories: z.array(claudeCategorySchema).describe(claudeCategoryDescription),
|
|
1378
1465
|
primaryUseCases: claudeSubmissionFormDataSchema.shape.primaryUseCases
|
|
1379
1466
|
});
|
|
1380
|
-
claudeAiGeneratedFormDataRawSchema.extend({
|
|
1467
|
+
const claudeAiGeneratedFormDataSchema = claudeAiGeneratedFormDataRawSchema.extend({
|
|
1381
1468
|
oneLiner: clampStringField(claudeSubmissionFormDataSchema.shape.oneLiner),
|
|
1382
1469
|
categories: claudeAiGeneratedFormDataRawSchema.shape.categories.transform((categories) => categories.slice(0, 5))
|
|
1383
1470
|
});
|
|
1471
|
+
function provenanceByField(prefillShape, aiGeneratedShape) {
|
|
1472
|
+
const byField = {};
|
|
1473
|
+
for (const field of Object.keys(prefillShape)) byField[field] = "prefilled";
|
|
1474
|
+
for (const field of Object.keys(aiGeneratedShape)) byField[field] = "ai-generated";
|
|
1475
|
+
return byField;
|
|
1476
|
+
}
|
|
1477
|
+
provenanceByField(claudePrefillFormDataSchema.shape, claudeAiGeneratedFormDataSchema.shape), provenanceByField(chatgptPrefillFormDataSchema.shape, chatgptAiGeneratedFormDataSchema.shape);
|
|
1478
|
+
const urlVerificationOutcomeSchema = z.enum([
|
|
1479
|
+
"pass",
|
|
1480
|
+
"fail",
|
|
1481
|
+
"unverified"
|
|
1482
|
+
]);
|
|
1483
|
+
const VERIFIABLE_URL_FIELDS = {
|
|
1484
|
+
chatgpt: ["privacyPolicyUrl", "termsOfServiceUrl"],
|
|
1485
|
+
claudeai: ["privacyPolicy"]
|
|
1486
|
+
};
|
|
1487
|
+
const verifiableUrlFieldSchema = z.enum([...VERIFIABLE_URL_FIELDS.chatgpt, ...VERIFIABLE_URL_FIELDS.claudeai]);
|
|
1488
|
+
const policyDisclosureSchema = z.enum([
|
|
1489
|
+
"dataCategories",
|
|
1490
|
+
"purposesOfUse",
|
|
1491
|
+
"recipients",
|
|
1492
|
+
"retention"
|
|
1493
|
+
]);
|
|
1494
|
+
const urlVerificationFieldResultSchema = z.object({
|
|
1495
|
+
field: verifiableUrlFieldSchema,
|
|
1496
|
+
url: z.string(),
|
|
1497
|
+
outcome: urlVerificationOutcomeSchema,
|
|
1498
|
+
reason: z.string(),
|
|
1499
|
+
concerns: z.array(z.string()).optional(),
|
|
1500
|
+
scrapedWith: z.enum(["fetch", "firecrawl"]).optional()
|
|
1501
|
+
});
|
|
1502
|
+
const urlVerificationSchema = z.object({
|
|
1503
|
+
verifiedAt: z.coerce.date(),
|
|
1504
|
+
results: z.array(urlVerificationFieldResultSchema)
|
|
1505
|
+
});
|
|
1506
|
+
const pageKindSchema = z.enum([
|
|
1507
|
+
"expectedDocument",
|
|
1508
|
+
"errorPage",
|
|
1509
|
+
"loginWall",
|
|
1510
|
+
"parkedDomain",
|
|
1511
|
+
"comingSoon",
|
|
1512
|
+
"marketingPage",
|
|
1513
|
+
"unrelatedDocument"
|
|
1514
|
+
]);
|
|
1515
|
+
z.object({
|
|
1516
|
+
pageKind: pageKindSchema.describe("What the page actually is. Use 'expectedDocument' only when it is genuinely the document the field claims."),
|
|
1517
|
+
reason: z.string().max(200).describe("One sentence naming what the page is, addressed to the developer who entered the URL."),
|
|
1518
|
+
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.")
|
|
1519
|
+
});
|
|
1384
1520
|
const submissionMetaFieldsSchema = z.object({
|
|
1385
1521
|
id: z.string(),
|
|
1386
1522
|
environmentId: z.string(),
|
|
1387
1523
|
auditId: z.string().nullable(),
|
|
1524
|
+
urlVerification: urlVerificationSchema.nullable().default(null),
|
|
1388
1525
|
createdAt: z.coerce.date(),
|
|
1389
1526
|
updatedAt: z.coerce.date()
|
|
1390
1527
|
});
|
|
1391
1528
|
const claudeSubmissionSchemaInternal = submissionMetaFieldsSchema.extend({
|
|
1392
1529
|
platform: z.literal("claudeai"),
|
|
1393
|
-
formData: claudeSubmissionDraftSchema
|
|
1530
|
+
formData: claudeSubmissionDraftSchema,
|
|
1531
|
+
prefillSnapshot: claudeSubmissionDraftSchema.nullable().default(null)
|
|
1394
1532
|
});
|
|
1395
1533
|
const chatgptSubmissionSchemaInternal = submissionMetaFieldsSchema.extend({
|
|
1396
1534
|
platform: z.literal("chatgpt"),
|
|
1397
|
-
formData: chatgptSubmissionDraftSchema
|
|
1535
|
+
formData: chatgptSubmissionDraftSchema,
|
|
1536
|
+
prefillSnapshot: chatgptSubmissionDraftSchema.nullable().default(null)
|
|
1398
1537
|
});
|
|
1399
|
-
z.discriminatedUnion("platform", [claudeSubmissionSchemaInternal, chatgptSubmissionSchemaInternal]);
|
|
1538
|
+
const submissionSchemaInternal = z.discriminatedUnion("platform", [claudeSubmissionSchemaInternal, chatgptSubmissionSchemaInternal]);
|
|
1400
1539
|
z.union([claudeSubmissionDraftSchema, chatgptSubmissionDraftSchema]);
|
|
1540
|
+
/** Discriminated on `platform`, which pins the shape of `formData`: a Claude submission cannot carry chatgpt-only fields, and vice-versa. */
|
|
1541
|
+
const submissionSchema = submissionSchemaInternal;
|
|
1542
|
+
z.literal([
|
|
1543
|
+
100,
|
|
1544
|
+
75,
|
|
1545
|
+
50
|
|
1546
|
+
]);
|
|
1401
1547
|
const subscriptionPlanSchema = z.enum([
|
|
1402
1548
|
"pro",
|
|
1403
1549
|
"business",
|
|
@@ -1409,17 +1555,77 @@ const customerCreditsSchema = z.object({
|
|
|
1409
1555
|
expiresAt: z.number().nullable(),
|
|
1410
1556
|
currency: z.string()
|
|
1411
1557
|
});
|
|
1412
|
-
const customerUsageSchema = z.object({
|
|
1413
|
-
amountInCents: z.number(),
|
|
1414
|
-
currency: z.string(),
|
|
1415
|
-
periodEnd: z.number()
|
|
1416
|
-
});
|
|
1417
1558
|
const partnerDiscountSchema = z.object({ endsAt: z.number() });
|
|
1418
1559
|
z.object({
|
|
1419
1560
|
customerCredits: customerCreditsSchema.nullable(),
|
|
1420
|
-
customerUsage: customerUsageSchema.nullable(),
|
|
1421
1561
|
partnerDiscount: partnerDiscountSchema.nullable()
|
|
1422
1562
|
});
|
|
1563
|
+
const metricsQueueEventSchema = z.object({
|
|
1564
|
+
ts: z.number().int(),
|
|
1565
|
+
method: z.string(),
|
|
1566
|
+
tool: z.string().nullable(),
|
|
1567
|
+
client: z.string(),
|
|
1568
|
+
sessionId: z.string().nullable(),
|
|
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 = [
|
|
1585
|
+
"logs",
|
|
1586
|
+
"metrics",
|
|
1587
|
+
"traces"
|
|
1588
|
+
];
|
|
1589
|
+
const telemetrySignalSchema = z.enum(TELEMETRY_SIGNALS);
|
|
1590
|
+
const OTLP_PROTOCOLS = ["http/protobuf", "http/json"];
|
|
1591
|
+
const otlpProtocolSchema = z.enum(OTLP_PROTOCOLS);
|
|
1592
|
+
const otlpEndpointSchema = z.string().trim().min(1).max(2048);
|
|
1593
|
+
const OTLP_HEADER_VALUE_MAX_LENGTH = 2048;
|
|
1594
|
+
const otlpHeaderNameSchema = z.string().trim().min(1, "Enter a header name").max(128).regex(/^[A-Za-z0-9!#$%&'*+\-.^_`|~]+$/, "Use letters, digits and !#$%&'*+-.^_`|~ only");
|
|
1595
|
+
const otlpHeaderValueSchema = z.string().trim().max(OTLP_HEADER_VALUE_MAX_LENGTH).refine((value) => !/[\r\n]/.test(value), "Line breaks are not allowed in a header value");
|
|
1596
|
+
const telemetryDestinationHeaderSchema = z.object({
|
|
1597
|
+
id: z.string(),
|
|
1598
|
+
name: otlpHeaderNameSchema,
|
|
1599
|
+
value: otlpHeaderValueSchema,
|
|
1600
|
+
isSecret: z.boolean()
|
|
1601
|
+
});
|
|
1602
|
+
const otlpPushFailureReasonSchema = z.enum([
|
|
1603
|
+
"credentials",
|
|
1604
|
+
"wrong-path",
|
|
1605
|
+
"wrong-protocol",
|
|
1606
|
+
"invalid-payload",
|
|
1607
|
+
"partial-rejection",
|
|
1608
|
+
"blocked-target",
|
|
1609
|
+
"timeout",
|
|
1610
|
+
"unreachable",
|
|
1611
|
+
"receiver-error",
|
|
1612
|
+
"unexpected-status"
|
|
1613
|
+
]);
|
|
1614
|
+
const telemetryDestinationStatusSchema = z.enum(["active", "suspended"]);
|
|
1615
|
+
z.object({
|
|
1616
|
+
id: z.string(),
|
|
1617
|
+
signal: telemetrySignalSchema,
|
|
1618
|
+
endpoint: otlpEndpointSchema,
|
|
1619
|
+
protocol: otlpProtocolSchema,
|
|
1620
|
+
headers: z.array(telemetryDestinationHeaderSchema),
|
|
1621
|
+
status: telemetryDestinationStatusSchema,
|
|
1622
|
+
lastFailureReason: otlpPushFailureReasonSchema.nullable(),
|
|
1623
|
+
isScopedToIntentionalRequestsOnly: z.boolean()
|
|
1624
|
+
});
|
|
1625
|
+
const hasDuplicateHeaderNames = (headers) => {
|
|
1626
|
+
const names = headers.map(({ name }) => name.trim().toLowerCase());
|
|
1627
|
+
return new Set(names).size !== names.length;
|
|
1628
|
+
};
|
|
1423
1629
|
//#endregion
|
|
1424
1630
|
//#region src/auth-scope.ts
|
|
1425
1631
|
/** Accepts an API key or OAuth access token (default for most routes). */
|
|
@@ -1518,6 +1724,14 @@ const serverFieldsSchema = z.object({
|
|
|
1518
1724
|
});
|
|
1519
1725
|
//#endregion
|
|
1520
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
|
+
};
|
|
1521
1735
|
const deploymentStatusSchema = z.enum([
|
|
1522
1736
|
"ongoing",
|
|
1523
1737
|
"deployed",
|
|
@@ -1546,10 +1760,11 @@ const deploymentSchema = z.object({
|
|
|
1546
1760
|
isCurrent: z.boolean(),
|
|
1547
1761
|
deploymentPageUrl: z.url().nullable()
|
|
1548
1762
|
});
|
|
1549
|
-
const
|
|
1763
|
+
const isValidTimeInput = (value) => {
|
|
1550
1764
|
if (ms(value) !== void 0) return true;
|
|
1551
1765
|
return !Number.isNaN(new Date(value).getTime());
|
|
1552
1766
|
};
|
|
1767
|
+
const timeInputSchema = z.string().refine(isValidTimeInput, { message: "Invalid time. Use relative (1h, 30m, 2d) or ISO 8601 format." });
|
|
1553
1768
|
const base = oc.errors({ BAD_REQUEST: {} });
|
|
1554
1769
|
const createEnvironmentContractV1 = base.route({
|
|
1555
1770
|
path: "/v1/environments",
|
|
@@ -1587,6 +1802,14 @@ const getEnvironmentContractV1 = base.route({
|
|
|
1587
1802
|
createdAt: z.coerce.date(),
|
|
1588
1803
|
projectId: z.string()
|
|
1589
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) }));
|
|
1590
1813
|
const domainSchema = z.object({
|
|
1591
1814
|
domain: z.string(),
|
|
1592
1815
|
status: z.enum([
|
|
@@ -1693,6 +1916,100 @@ const environmentVariableOutputSchema = z.object({
|
|
|
1693
1916
|
isSecret: z.boolean(),
|
|
1694
1917
|
createdAt: z.coerce.date()
|
|
1695
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) }));
|
|
1696
2013
|
const listEnvironmentVariablesContractV1 = base.route({
|
|
1697
2014
|
path: "/v1/environments/{environmentId}/environment-variables",
|
|
1698
2015
|
method: "GET",
|
|
@@ -1827,8 +2144,8 @@ const getLogsContractV1 = base.route({
|
|
|
1827
2144
|
successDescription: "The logs"
|
|
1828
2145
|
}).errors({ NOT_FOUND: {} }).input(z.object({
|
|
1829
2146
|
environmentId: z.string().describe("The ID of the environment"),
|
|
1830
|
-
since:
|
|
1831
|
-
until:
|
|
2147
|
+
since: timeInputSchema.optional().describe("Start time — ISO 8601 (2024-01-01T00:00:00Z) or relative (1h, 30m, 2d)"),
|
|
2148
|
+
until: timeInputSchema.optional().describe("End time — ISO 8601 or relative"),
|
|
1832
2149
|
limit: z.coerce.number().int().min(1).max(1e3).default(1e3).describe("Maximum number of log entries to return."),
|
|
1833
2150
|
level: z.array(z.enum([
|
|
1834
2151
|
"INFO",
|
|
@@ -1836,7 +2153,7 @@ const getLogsContractV1 = base.route({
|
|
|
1836
2153
|
"WARNING",
|
|
1837
2154
|
"DEBUG"
|
|
1838
2155
|
])).optional().describe("Filter by log level"),
|
|
1839
|
-
search:
|
|
2156
|
+
search: logSearchSchema.optional().describe("Term to search for in log content"),
|
|
1840
2157
|
nextToken: z.string().optional().describe("Pagination token from a previous response")
|
|
1841
2158
|
})).output(z.object({
|
|
1842
2159
|
logs: z.array(logEntrySchema),
|
|
@@ -1858,7 +2175,7 @@ const getLatestLogsContractV1 = base.route({
|
|
|
1858
2175
|
"WARNING",
|
|
1859
2176
|
"DEBUG"
|
|
1860
2177
|
])).optional().describe("Filter by log level"),
|
|
1861
|
-
search:
|
|
2178
|
+
search: logSearchSchema.optional().describe("Term to search for in log content")
|
|
1862
2179
|
})).output(z.object({ logs: z.array(logEntrySchema) }));
|
|
1863
2180
|
const getDeploymentLogsContractV1 = base.route({
|
|
1864
2181
|
path: "/v1/deployments/{deploymentId}/logs",
|
|
@@ -1899,7 +2216,7 @@ const getProjectAnalyticsContractV1 = base.route({
|
|
|
1899
2216
|
startTimestamp: z.coerce.number().describe("Start timestamp in milliseconds"),
|
|
1900
2217
|
endTimestamp: z.coerce.number().describe("End timestamp in milliseconds"),
|
|
1901
2218
|
timeZone: z.string().describe("IANA timezone (e.g. Europe/Paris)")
|
|
1902
|
-
}).refine(({ startTimestamp, endTimestamp }) => endTimestamp - startTimestamp > 0, { message: "End date must be after start date" }).refine(({ startTimestamp, endTimestamp }) => endTimestamp - startTimestamp <=
|
|
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({
|
|
1903
2220
|
metadata: z.object({
|
|
1904
2221
|
startTimestamp: z.number(),
|
|
1905
2222
|
endTimestamp: z.number(),
|
|
@@ -1909,6 +2226,131 @@ const getProjectAnalyticsContractV1 = base.route({
|
|
|
1909
2226
|
}),
|
|
1910
2227
|
timeSeries: analyticsTimeSeriesSchema
|
|
1911
2228
|
}));
|
|
2229
|
+
const paginatedInsightsInputShape = {
|
|
2230
|
+
environmentId: z.string().describe("The ID of the environment"),
|
|
2231
|
+
since: timeInputSchema.default("7d").describe("Start time — ISO 8601 (2024-01-01T00:00:00Z) or relative (1h, 30m, 2d)"),
|
|
2232
|
+
until: timeInputSchema.optional().describe("End time — ISO 8601 or relative"),
|
|
2233
|
+
limit: z.coerce.number().int().min(1).max(200).default(50),
|
|
2234
|
+
offset: z.coerce.number().int().min(0).default(0),
|
|
2235
|
+
search: z.string().trim().min(1).max(200).optional()
|
|
2236
|
+
};
|
|
2237
|
+
const listIntentsContractV1 = base.route({
|
|
2238
|
+
path: "/v1/environments/{environmentId}/intents",
|
|
2239
|
+
method: "GET",
|
|
2240
|
+
summary: "List intents",
|
|
2241
|
+
description: "List grouped user intents for an environment over a time range",
|
|
2242
|
+
tags: ["insights"],
|
|
2243
|
+
successDescription: "The grouped user intents"
|
|
2244
|
+
}).errors({ NOT_FOUND: {} }).input(z.object({
|
|
2245
|
+
...paginatedInsightsInputShape,
|
|
2246
|
+
tools: z.array(z.string().trim().min(1)).min(1).max(100).optional(),
|
|
2247
|
+
clientIds: z.array(z.string().min(1)).min(1).max(100).optional(),
|
|
2248
|
+
categoryIds: z.array(z.string().trim().min(1)).min(1).max(100).optional(),
|
|
2249
|
+
sortDir: z.enum(["asc", "desc"]).default("desc")
|
|
2250
|
+
})).output(z.object({
|
|
2251
|
+
intents: z.array(z.object({
|
|
2252
|
+
id: z.string(),
|
|
2253
|
+
intentIds: z.array(z.string()).min(1),
|
|
2254
|
+
environmentId: z.string(),
|
|
2255
|
+
message: z.string(),
|
|
2256
|
+
toolName: z.string(),
|
|
2257
|
+
createdAt: z.coerce.date(),
|
|
2258
|
+
occurrenceCount: z.number().int().positive(),
|
|
2259
|
+
clientName: z.string().nullable(),
|
|
2260
|
+
clientId: z.string().nullable(),
|
|
2261
|
+
categories: z.array(z.object({
|
|
2262
|
+
id: z.string(),
|
|
2263
|
+
name: z.string(),
|
|
2264
|
+
color: intentCategoryColorSchema
|
|
2265
|
+
}))
|
|
2266
|
+
})),
|
|
2267
|
+
totalCount: z.number().int().nonnegative()
|
|
2268
|
+
}));
|
|
2269
|
+
const listFeedbacksContractV1 = base.route({
|
|
2270
|
+
path: "/v1/environments/{environmentId}/feedbacks",
|
|
2271
|
+
method: "GET",
|
|
2272
|
+
summary: "List feedbacks",
|
|
2273
|
+
description: "List user feedback for an environment over a time range",
|
|
2274
|
+
tags: ["insights"],
|
|
2275
|
+
successDescription: "The user feedback"
|
|
2276
|
+
}).errors({ NOT_FOUND: {} }).input(z.object({
|
|
2277
|
+
...paginatedInsightsInputShape,
|
|
2278
|
+
clientIds: z.array(z.string().min(1)).min(1).max(100).optional()
|
|
2279
|
+
})).output(z.object({
|
|
2280
|
+
feedbacks: z.array(feedbackSchema.extend({ clientId: z.string().nullable() })),
|
|
2281
|
+
totalCount: z.number().int().nonnegative()
|
|
2282
|
+
}));
|
|
2283
|
+
const intentCategoryNameSchema = z.string().trim().min(1).max(100).describe("The category name");
|
|
2284
|
+
const categorizableIntentIdsSchema = z.array(z.string().trim().min(1)).min(1).max(100).describe("IDs of the intents to categorize");
|
|
2285
|
+
const listIntentCategoriesContractV1 = base.route({
|
|
2286
|
+
path: "/v1/environments/{environmentId}/intent-categories",
|
|
2287
|
+
method: "GET",
|
|
2288
|
+
summary: "List intent categories",
|
|
2289
|
+
description: "List intent categories for an environment, including how many intents each category is linked to",
|
|
2290
|
+
tags: ["insights"],
|
|
2291
|
+
successDescription: "The intent categories"
|
|
2292
|
+
}).errors({ NOT_FOUND: {} }).input(z.object({ environmentId: z.string().describe("The ID of the environment") })).output(z.array(intentCategorySummarySchema));
|
|
2293
|
+
const createIntentCategoryContractV1 = base.route({
|
|
2294
|
+
path: "/v1/environments/{environmentId}/intent-categories",
|
|
2295
|
+
method: "POST",
|
|
2296
|
+
summary: "Create an intent category",
|
|
2297
|
+
description: "Create an intent category, optionally linking it to existing intents",
|
|
2298
|
+
tags: ["insights"],
|
|
2299
|
+
successDescription: "The created intent category"
|
|
2300
|
+
}).errors({ NOT_FOUND: {} }).input(z.object({
|
|
2301
|
+
environmentId: z.string().describe("The ID of the environment"),
|
|
2302
|
+
name: intentCategoryNameSchema,
|
|
2303
|
+
color: intentCategoryColorSchema.optional().describe("The category color; derived from the name when omitted"),
|
|
2304
|
+
intentIds: categorizableIntentIdsSchema.optional().describe("IDs of intents to link to the new category")
|
|
2305
|
+
})).output(intentCategorySchema);
|
|
2306
|
+
const updateIntentCategoryContractV1 = base.route({
|
|
2307
|
+
path: "/v1/environments/{environmentId}/intent-categories/{categoryId}",
|
|
2308
|
+
method: "PATCH",
|
|
2309
|
+
summary: "Update an intent category",
|
|
2310
|
+
description: "Rename or recolor an intent category",
|
|
2311
|
+
tags: ["insights"],
|
|
2312
|
+
successDescription: "The updated intent category"
|
|
2313
|
+
}).errors({ NOT_FOUND: {} }).input(z.object({
|
|
2314
|
+
environmentId: z.string().describe("The ID of the environment"),
|
|
2315
|
+
categoryId: z.string().describe("The ID of the category"),
|
|
2316
|
+
name: intentCategoryNameSchema.optional(),
|
|
2317
|
+
color: intentCategoryColorSchema.optional().describe("The category color")
|
|
2318
|
+
}).refine(({ name, color }) => name !== void 0 || color !== void 0, { message: "At least one of name or color must be provided" })).output(intentCategorySchema);
|
|
2319
|
+
const deleteIntentCategoryContractV1 = base.route({
|
|
2320
|
+
path: "/v1/environments/{environmentId}/intent-categories/{categoryId}",
|
|
2321
|
+
method: "DELETE",
|
|
2322
|
+
summary: "Delete an intent category",
|
|
2323
|
+
description: "Delete an intent category; its intents are unlinked but not deleted",
|
|
2324
|
+
tags: ["insights"],
|
|
2325
|
+
successDescription: "The intent category has been deleted successfully"
|
|
2326
|
+
}).errors({ NOT_FOUND: {} }).input(z.object({
|
|
2327
|
+
environmentId: z.string().describe("The ID of the environment"),
|
|
2328
|
+
categoryId: z.string().describe("The ID of the category")
|
|
2329
|
+
})).output(z.object({ success: z.literal(true) }));
|
|
2330
|
+
const linkIntentCategoryContractV1 = base.route({
|
|
2331
|
+
path: "/v1/environments/{environmentId}/intent-categories/{categoryId}/link",
|
|
2332
|
+
method: "POST",
|
|
2333
|
+
summary: "Link an intent category",
|
|
2334
|
+
description: "Link an intent category to intents; already linked intents are ignored",
|
|
2335
|
+
tags: ["insights"],
|
|
2336
|
+
successDescription: "The intents have been linked successfully"
|
|
2337
|
+
}).errors({ NOT_FOUND: {} }).input(z.object({
|
|
2338
|
+
environmentId: z.string().describe("The ID of the environment"),
|
|
2339
|
+
categoryId: z.string().describe("The ID of the category"),
|
|
2340
|
+
intentIds: categorizableIntentIdsSchema
|
|
2341
|
+
})).output(z.object({ success: z.literal(true) }));
|
|
2342
|
+
const unlinkIntentCategoryContractV1 = base.route({
|
|
2343
|
+
path: "/v1/environments/{environmentId}/intent-categories/{categoryId}/unlink",
|
|
2344
|
+
method: "POST",
|
|
2345
|
+
summary: "Unlink an intent category",
|
|
2346
|
+
description: "Unlink an intent category from intents; intents without the category are ignored",
|
|
2347
|
+
tags: ["insights"],
|
|
2348
|
+
successDescription: "The intents have been unlinked successfully"
|
|
2349
|
+
}).errors({ NOT_FOUND: {} }).input(z.object({
|
|
2350
|
+
environmentId: z.string().describe("The ID of the environment"),
|
|
2351
|
+
categoryId: z.string().describe("The ID of the category"),
|
|
2352
|
+
intentIds: categorizableIntentIdsSchema
|
|
2353
|
+
})).output(z.object({ success: z.literal(true) }));
|
|
1912
2354
|
const listTeamsContractV1 = base.route({
|
|
1913
2355
|
path: "/v1/teams",
|
|
1914
2356
|
method: "GET",
|
|
@@ -1922,6 +2364,21 @@ const listTeamsContractV1 = base.route({
|
|
|
1922
2364
|
createdAt: z.coerce.date(),
|
|
1923
2365
|
hasStripeAccount: z.boolean()
|
|
1924
2366
|
})));
|
|
2367
|
+
const getTeamUsageContractV1 = base.route({
|
|
2368
|
+
path: "/v1/teams/{teamId}/usage",
|
|
2369
|
+
method: "GET",
|
|
2370
|
+
summary: "Get team usage",
|
|
2371
|
+
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.",
|
|
2372
|
+
tags: ["teams"],
|
|
2373
|
+
successDescription: "The current billing window usage"
|
|
2374
|
+
}).errors({ NOT_FOUND: {} }).input(z.object({ teamId: z.string().describe("The ID of the team") })).output(z.object({
|
|
2375
|
+
teamId: z.string(),
|
|
2376
|
+
plan: subscriptionPlanSchema.nullable().describe("The plan in force for the window, null on the Free plan"),
|
|
2377
|
+
periodStart: z.coerce.date().describe("Start of the current billing window"),
|
|
2378
|
+
periodEnd: z.coerce.date().describe("End of the current billing window"),
|
|
2379
|
+
requestCount: z.number().int().describe("MCP requests settled during the current billing window"),
|
|
2380
|
+
includedRequests: z.number().int().nullable().describe("Requests included in the plan for one window, null when the allowance is contract-specific")
|
|
2381
|
+
}));
|
|
1925
2382
|
const getTunnelTicketContractV1 = base.route({
|
|
1926
2383
|
path: "/v1/tunnels/ticket",
|
|
1927
2384
|
method: "GET",
|
|
@@ -2029,9 +2486,73 @@ const getBeaconContractV1 = base.route({
|
|
|
2029
2486
|
createdAt: z.coerce.date(),
|
|
2030
2487
|
report: auditReportWithScreenshotsSchema.nullable()
|
|
2031
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);
|
|
2032
2540
|
const contract = {
|
|
2033
|
-
teams: {
|
|
2541
|
+
teams: {
|
|
2542
|
+
list: { v1: listTeamsContractV1 },
|
|
2543
|
+
getUsage: { v1: getTeamUsageContractV1 }
|
|
2544
|
+
},
|
|
2034
2545
|
analytics: { get: { v1: getProjectAnalyticsContractV1 } },
|
|
2546
|
+
intents: { list: { v1: listIntentsContractV1 } },
|
|
2547
|
+
intentCategories: {
|
|
2548
|
+
list: { v1: listIntentCategoriesContractV1 },
|
|
2549
|
+
create: { v1: createIntentCategoryContractV1 },
|
|
2550
|
+
update: { v1: updateIntentCategoryContractV1 },
|
|
2551
|
+
delete: { v1: deleteIntentCategoryContractV1 },
|
|
2552
|
+
link: { v1: linkIntentCategoryContractV1 },
|
|
2553
|
+
unlink: { v1: unlinkIntentCategoryContractV1 }
|
|
2554
|
+
},
|
|
2555
|
+
feedbacks: { list: { v1: listFeedbacksContractV1 } },
|
|
2035
2556
|
deployments: {
|
|
2036
2557
|
list: { v1: listDeploymentsContractV1 },
|
|
2037
2558
|
get: { v1: getDeploymentContractV1 },
|
|
@@ -2041,6 +2562,7 @@ const contract = {
|
|
|
2041
2562
|
environments: {
|
|
2042
2563
|
create: { v1: createEnvironmentContractV1 },
|
|
2043
2564
|
get: { v1: getEnvironmentContractV1 },
|
|
2565
|
+
delete: { v1: deleteEnvironmentContractV1 },
|
|
2044
2566
|
deploy: { v1: deployEnvironmentContractV1 },
|
|
2045
2567
|
getLogs: { v1: getLogsContractV1 },
|
|
2046
2568
|
getLatestLogs: { v1: getLatestLogsContractV1 }
|
|
@@ -2051,6 +2573,12 @@ const contract = {
|
|
|
2051
2573
|
update: { v1: updateEnvironmentVariableContractV1 },
|
|
2052
2574
|
delete: { v1: deleteEnvironmentVariableContractV1 }
|
|
2053
2575
|
},
|
|
2576
|
+
telemetryDestinations: {
|
|
2577
|
+
list: { v1: listTelemetryDestinationsContractV1 },
|
|
2578
|
+
create: { v1: createTelemetryDestinationContractV1 },
|
|
2579
|
+
update: { v1: updateTelemetryDestinationContractV1 },
|
|
2580
|
+
delete: { v1: deleteTelemetryDestinationContractV1 }
|
|
2581
|
+
},
|
|
2054
2582
|
projects: {
|
|
2055
2583
|
update: { v1: updateProjectContractV1 },
|
|
2056
2584
|
get: { v1: getProjectContractV1 },
|
|
@@ -2070,6 +2598,12 @@ const contract = {
|
|
|
2070
2598
|
beacon: {
|
|
2071
2599
|
create: { v1: createBeaconContractV1 },
|
|
2072
2600
|
get: { v1: getBeaconContractV1 }
|
|
2601
|
+
},
|
|
2602
|
+
submissions: {
|
|
2603
|
+
create: { v1: createSubmissionContractV1 },
|
|
2604
|
+
list: { v1: listSubmissionsContractV1 },
|
|
2605
|
+
get: { v1: getSubmissionContractV1 },
|
|
2606
|
+
update: { v1: updateSubmissionContractV1 }
|
|
2073
2607
|
}
|
|
2074
2608
|
};
|
|
2075
2609
|
const { uploadArtifact: _discard, ...deploymentsForDocs } = contract.deployments;
|
|
@@ -2077,5 +2611,26 @@ const contractForDocs = {
|
|
|
2077
2611
|
...contract,
|
|
2078
2612
|
deployments: deploymentsForDocs
|
|
2079
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
|
+
};
|
|
2080
2635
|
//#endregion
|
|
2081
|
-
export { AUTH_SCOPE_ANY, AUTH_SCOPE_USER, PLATFORM_LABELS, buildSettingsSchema, contract, contractForDocs, createEnvironmentContractV1, deploymentStatusSchema, environmentVariableSchema, environmentVariablesSchema, 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 };
|