@alpic-ai/api 0.0.0-dev.gdf1c8f7 → 0.0.0-dev.gdf37760
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 +4779 -53
- package/dist/index.mjs +329 -45
- package/package.json +8 -8
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,7 +430,8 @@ 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
436
|
const feedbackSchema = z.object({
|
|
406
437
|
id: z.string(),
|
|
@@ -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,33 +1464,81 @@ 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]);
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
pro: 2e5,
|
|
1404
|
-
business: 2e6,
|
|
1405
|
-
enterprise: null
|
|
1406
|
-
}).free;
|
|
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;
|
|
1407
1542
|
z.literal([
|
|
1408
1543
|
100,
|
|
1409
1544
|
75,
|
|
@@ -1420,18 +1555,72 @@ const customerCreditsSchema = z.object({
|
|
|
1420
1555
|
expiresAt: z.number().nullable(),
|
|
1421
1556
|
currency: z.string()
|
|
1422
1557
|
});
|
|
1423
|
-
const customerUsageSchema = z.object({
|
|
1424
|
-
amountInCents: z.number(),
|
|
1425
|
-
currency: z.string(),
|
|
1426
|
-
periodEnd: z.number()
|
|
1427
|
-
});
|
|
1428
1558
|
const partnerDiscountSchema = z.object({ endsAt: z.number() });
|
|
1429
|
-
z.object({ balanceInNanoUSD: z.number() });
|
|
1430
1559
|
z.object({
|
|
1431
1560
|
customerCredits: customerCreditsSchema.nullable(),
|
|
1432
|
-
customerUsage: customerUsageSchema.nullable(),
|
|
1433
1561
|
partnerDiscount: partnerDiscountSchema.nullable()
|
|
1434
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
|
+
conversationId: z.string().nullable().optional(),
|
|
1570
|
+
durationMs: z.number().int(),
|
|
1571
|
+
outputTokens: z.number().int().nullable(),
|
|
1572
|
+
errorType: z.enum([
|
|
1573
|
+
"mcp_error",
|
|
1574
|
+
"tool_error",
|
|
1575
|
+
"timeout"
|
|
1576
|
+
]).nullable(),
|
|
1577
|
+
errorCode: z.number().int().nullable()
|
|
1578
|
+
});
|
|
1579
|
+
z.object({
|
|
1580
|
+
v: z.literal(1),
|
|
1581
|
+
envId: z.string(),
|
|
1582
|
+
events: z.array(metricsQueueEventSchema)
|
|
1583
|
+
});
|
|
1584
|
+
z.object({ v: z.number() });
|
|
1585
|
+
const telemetrySignalSchema = z.enum([
|
|
1586
|
+
"logs",
|
|
1587
|
+
"metrics",
|
|
1588
|
+
"traces"
|
|
1589
|
+
]);
|
|
1590
|
+
const otlpProtocolSchema = z.enum(["http/protobuf", "http/json"]);
|
|
1591
|
+
const otlpEndpointSchema = z.string().trim().min(1).max(2048);
|
|
1592
|
+
const OTLP_HEADER_VALUE_MAX_LENGTH = 2048;
|
|
1593
|
+
const otlpHeaderNameSchema = z.string().trim().min(1, "Enter a header name").max(128).regex(/^[A-Za-z0-9!#$%&'*+\-.^_`|~]+$/, "Use letters, digits and !#$%&'*+-.^_`|~ only");
|
|
1594
|
+
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");
|
|
1595
|
+
const telemetryDestinationHeaderSchema = z.object({
|
|
1596
|
+
id: z.string(),
|
|
1597
|
+
name: otlpHeaderNameSchema,
|
|
1598
|
+
value: otlpHeaderValueSchema,
|
|
1599
|
+
isSecret: z.boolean()
|
|
1600
|
+
});
|
|
1601
|
+
const otlpPushFailureReasonSchema = z.enum([
|
|
1602
|
+
"credentials",
|
|
1603
|
+
"wrong-path",
|
|
1604
|
+
"wrong-protocol",
|
|
1605
|
+
"invalid-payload",
|
|
1606
|
+
"partial-rejection",
|
|
1607
|
+
"blocked-target",
|
|
1608
|
+
"timeout",
|
|
1609
|
+
"unreachable",
|
|
1610
|
+
"receiver-error",
|
|
1611
|
+
"unexpected-status"
|
|
1612
|
+
]);
|
|
1613
|
+
const telemetryDestinationStatusSchema = z.enum(["active", "suspended"]);
|
|
1614
|
+
z.object({
|
|
1615
|
+
id: z.string(),
|
|
1616
|
+
signal: telemetrySignalSchema,
|
|
1617
|
+
endpoint: otlpEndpointSchema,
|
|
1618
|
+
protocol: otlpProtocolSchema,
|
|
1619
|
+
headers: z.array(telemetryDestinationHeaderSchema),
|
|
1620
|
+
status: telemetryDestinationStatusSchema,
|
|
1621
|
+
lastFailureReason: otlpPushFailureReasonSchema.nullable(),
|
|
1622
|
+
isScopedToIntentionalRequestsOnly: z.boolean()
|
|
1623
|
+
});
|
|
1435
1624
|
//#endregion
|
|
1436
1625
|
//#region src/auth-scope.ts
|
|
1437
1626
|
/** Accepts an API key or OAuth access token (default for most routes). */
|
|
@@ -1530,6 +1719,14 @@ const serverFieldsSchema = z.object({
|
|
|
1530
1719
|
});
|
|
1531
1720
|
//#endregion
|
|
1532
1721
|
//#region src/api.contract.ts
|
|
1722
|
+
const isValidIanaTimeZone = (timeZone) => {
|
|
1723
|
+
try {
|
|
1724
|
+
new Intl.DateTimeFormat("en-US", { timeZone });
|
|
1725
|
+
return true;
|
|
1726
|
+
} catch {
|
|
1727
|
+
return false;
|
|
1728
|
+
}
|
|
1729
|
+
};
|
|
1533
1730
|
const deploymentStatusSchema = z.enum([
|
|
1534
1731
|
"ongoing",
|
|
1535
1732
|
"deployed",
|
|
@@ -1600,6 +1797,14 @@ const getEnvironmentContractV1 = base.route({
|
|
|
1600
1797
|
createdAt: z.coerce.date(),
|
|
1601
1798
|
projectId: z.string()
|
|
1602
1799
|
}));
|
|
1800
|
+
const deleteEnvironmentContractV1 = base.route({
|
|
1801
|
+
path: "/v1/environments/{environmentId}",
|
|
1802
|
+
method: "DELETE",
|
|
1803
|
+
summary: "Delete an environment",
|
|
1804
|
+
description: "All environments can be deleted except the production environment. This operation is not reversible: associated logs, analytics, and metrics are deleted as well.",
|
|
1805
|
+
tags: ["environments"],
|
|
1806
|
+
successDescription: "The environment has been deleted successfully"
|
|
1807
|
+
}).errors({ NOT_FOUND: {} }).input(z.object({ environmentId: z.string().describe("The ID of the environment") })).output(z.object({ success: z.literal(true) }));
|
|
1603
1808
|
const domainSchema = z.object({
|
|
1604
1809
|
domain: z.string(),
|
|
1605
1810
|
status: z.enum([
|
|
@@ -1849,7 +2054,7 @@ const getLogsContractV1 = base.route({
|
|
|
1849
2054
|
"WARNING",
|
|
1850
2055
|
"DEBUG"
|
|
1851
2056
|
])).optional().describe("Filter by log level"),
|
|
1852
|
-
search:
|
|
2057
|
+
search: logSearchSchema.optional().describe("Term to search for in log content"),
|
|
1853
2058
|
nextToken: z.string().optional().describe("Pagination token from a previous response")
|
|
1854
2059
|
})).output(z.object({
|
|
1855
2060
|
logs: z.array(logEntrySchema),
|
|
@@ -1871,7 +2076,7 @@ const getLatestLogsContractV1 = base.route({
|
|
|
1871
2076
|
"WARNING",
|
|
1872
2077
|
"DEBUG"
|
|
1873
2078
|
])).optional().describe("Filter by log level"),
|
|
1874
|
-
search:
|
|
2079
|
+
search: logSearchSchema.optional().describe("Term to search for in log content")
|
|
1875
2080
|
})).output(z.object({ logs: z.array(logEntrySchema) }));
|
|
1876
2081
|
const getDeploymentLogsContractV1 = base.route({
|
|
1877
2082
|
path: "/v1/deployments/{deploymentId}/logs",
|
|
@@ -1912,7 +2117,7 @@ const getProjectAnalyticsContractV1 = base.route({
|
|
|
1912
2117
|
startTimestamp: z.coerce.number().describe("Start timestamp in milliseconds"),
|
|
1913
2118
|
endTimestamp: z.coerce.number().describe("End timestamp in milliseconds"),
|
|
1914
2119
|
timeZone: z.string().describe("IANA timezone (e.g. Europe/Paris)")
|
|
1915
|
-
}).refine(({ startTimestamp, endTimestamp }) => endTimestamp - startTimestamp > 0, { message: "End date must be after start date" }).refine(({ startTimestamp, endTimestamp }) => endTimestamp - startTimestamp <=
|
|
2120
|
+
}).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({
|
|
1916
2121
|
metadata: z.object({
|
|
1917
2122
|
startTimestamp: z.number(),
|
|
1918
2123
|
endTimestamp: z.number(),
|
|
@@ -2182,6 +2387,57 @@ const getBeaconContractV1 = base.route({
|
|
|
2182
2387
|
createdAt: z.coerce.date(),
|
|
2183
2388
|
report: auditReportWithScreenshotsSchema.nullable()
|
|
2184
2389
|
}));
|
|
2390
|
+
const PLATFORM_DESCRIPTION = "The directory the package targets: `chatgpt` for the OpenAI App Directory, `claudeai` for the Anthropic MCP Directory";
|
|
2391
|
+
const submissionIdSchema = z.string().describe("The ID of the submission package");
|
|
2392
|
+
const claudeSubmissionUpdateSchema = claudeSubmissionDraftSchema.strict();
|
|
2393
|
+
const chatgptSubmissionUpdateSchema = chatgptSubmissionDraftSchema.strict();
|
|
2394
|
+
const createSubmissionContractV1 = base.route({
|
|
2395
|
+
path: "/v1/submissions",
|
|
2396
|
+
method: "POST",
|
|
2397
|
+
summary: "Create a submission package",
|
|
2398
|
+
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.",
|
|
2399
|
+
tags: ["submissions"],
|
|
2400
|
+
successDescription: "The created submission package, with its prefilled fields"
|
|
2401
|
+
}).errors({ NOT_FOUND: {} }).input(z.object({
|
|
2402
|
+
environmentId: z.string().describe("The ID of the environment to build the package from"),
|
|
2403
|
+
platform: platformSchema.describe(PLATFORM_DESCRIPTION)
|
|
2404
|
+
})).output(submissionSchema);
|
|
2405
|
+
const listSubmissionsContractV1 = base.route({
|
|
2406
|
+
path: "/v1/projects/{projectId}/submissions",
|
|
2407
|
+
method: "GET",
|
|
2408
|
+
summary: "List submission packages",
|
|
2409
|
+
description: "List the submission packages of a project, grouped by directory and most recently updated first, optionally narrowed to one environment or one directory",
|
|
2410
|
+
tags: ["submissions"],
|
|
2411
|
+
successDescription: "The list of submission packages"
|
|
2412
|
+
}).errors({ NOT_FOUND: {} }).input(z.object({
|
|
2413
|
+
projectId: z.string().describe("The ID of the project"),
|
|
2414
|
+
environmentId: z.string().optional().describe("Filter by environment ID"),
|
|
2415
|
+
platform: platformSchema.optional().describe(PLATFORM_DESCRIPTION)
|
|
2416
|
+
})).output(z.array(submissionSchema));
|
|
2417
|
+
const getSubmissionContractV1 = base.route({
|
|
2418
|
+
path: "/v1/submissions/{submissionId}",
|
|
2419
|
+
method: "GET",
|
|
2420
|
+
summary: "Get a submission package",
|
|
2421
|
+
description: "Get a submission package by ID, including its form data and the prefill it started from",
|
|
2422
|
+
tags: ["submissions"],
|
|
2423
|
+
successDescription: "The submission package"
|
|
2424
|
+
}).errors({ NOT_FOUND: {} }).input(z.object({ submissionId: submissionIdSchema })).output(submissionSchema);
|
|
2425
|
+
const updateSubmissionContractV1 = base.route({
|
|
2426
|
+
path: "/v1/submissions/{submissionId}",
|
|
2427
|
+
method: "PUT",
|
|
2428
|
+
summary: "Update a submission package",
|
|
2429
|
+
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.",
|
|
2430
|
+
tags: ["submissions"],
|
|
2431
|
+
successDescription: "The updated submission package"
|
|
2432
|
+
}).errors({ NOT_FOUND: {} }).input(z.discriminatedUnion("platform", [z.object({
|
|
2433
|
+
submissionId: submissionIdSchema,
|
|
2434
|
+
platform: z.literal("claudeai").describe(PLATFORM_DESCRIPTION),
|
|
2435
|
+
formData: claudeSubmissionUpdateSchema
|
|
2436
|
+
}), z.object({
|
|
2437
|
+
submissionId: submissionIdSchema,
|
|
2438
|
+
platform: z.literal("chatgpt").describe(PLATFORM_DESCRIPTION),
|
|
2439
|
+
formData: chatgptSubmissionUpdateSchema
|
|
2440
|
+
})])).output(submissionSchema);
|
|
2185
2441
|
const contract = {
|
|
2186
2442
|
teams: {
|
|
2187
2443
|
list: { v1: listTeamsContractV1 },
|
|
@@ -2207,6 +2463,7 @@ const contract = {
|
|
|
2207
2463
|
environments: {
|
|
2208
2464
|
create: { v1: createEnvironmentContractV1 },
|
|
2209
2465
|
get: { v1: getEnvironmentContractV1 },
|
|
2466
|
+
delete: { v1: deleteEnvironmentContractV1 },
|
|
2210
2467
|
deploy: { v1: deployEnvironmentContractV1 },
|
|
2211
2468
|
getLogs: { v1: getLogsContractV1 },
|
|
2212
2469
|
getLatestLogs: { v1: getLatestLogsContractV1 }
|
|
@@ -2236,6 +2493,12 @@ const contract = {
|
|
|
2236
2493
|
beacon: {
|
|
2237
2494
|
create: { v1: createBeaconContractV1 },
|
|
2238
2495
|
get: { v1: getBeaconContractV1 }
|
|
2496
|
+
},
|
|
2497
|
+
submissions: {
|
|
2498
|
+
create: { v1: createSubmissionContractV1 },
|
|
2499
|
+
list: { v1: listSubmissionsContractV1 },
|
|
2500
|
+
get: { v1: getSubmissionContractV1 },
|
|
2501
|
+
update: { v1: updateSubmissionContractV1 }
|
|
2239
2502
|
}
|
|
2240
2503
|
};
|
|
2241
2504
|
const { uploadArtifact: _discard, ...deploymentsForDocs } = contract.deployments;
|
|
@@ -2243,5 +2506,26 @@ const contractForDocs = {
|
|
|
2243
2506
|
...contract,
|
|
2244
2507
|
deployments: deploymentsForDocs
|
|
2245
2508
|
};
|
|
2509
|
+
/** Shared by the served `openapi.json` and the snapshot test that guards it, so the two cannot drift. */
|
|
2510
|
+
const OPENAPI_DOC_OPTIONS = {
|
|
2511
|
+
info: {
|
|
2512
|
+
title: "Alpic API",
|
|
2513
|
+
version: "1.0.0"
|
|
2514
|
+
},
|
|
2515
|
+
servers: [{ url: "https://api.alpic.ai" }],
|
|
2516
|
+
security: [{ bearerAuth: [] }],
|
|
2517
|
+
components: { securitySchemes: { bearerAuth: {
|
|
2518
|
+
type: "http",
|
|
2519
|
+
description: "Bearer token for authentication. Use an API key from the API Keys page in team settings, or an OAuth access token.",
|
|
2520
|
+
scheme: "bearer"
|
|
2521
|
+
} } },
|
|
2522
|
+
commonSchemas: {
|
|
2523
|
+
Submission: { schema: submissionSchema },
|
|
2524
|
+
ClaudeSubmissionFormData: { schema: claudeSubmissionDraftSchema },
|
|
2525
|
+
ChatgptSubmissionFormData: { schema: chatgptSubmissionDraftSchema },
|
|
2526
|
+
ClaudeSubmissionFormDataUpdate: { schema: claudeSubmissionUpdateSchema },
|
|
2527
|
+
ChatgptSubmissionFormDataUpdate: { schema: chatgptSubmissionUpdateSchema }
|
|
2528
|
+
}
|
|
2529
|
+
};
|
|
2246
2530
|
//#endregion
|
|
2247
|
-
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 };
|
|
2531
|
+
export { AI_PLATFORMS, AUTH_SCOPE_ANY, AUTH_SCOPE_USER, INTENT_CATEGORY_COLORS, OPENAPI_DOC_OPTIONS, PLATFORM_LABELS, buildSettingsSchema, chatgptSubmissionUpdateSchema, claudeSubmissionUpdateSchema, contract, contractForDocs, createEnvironmentContractV1, deploymentStatusSchema, environmentVariableSchema, environmentVariablesSchema, intentCategoryColorSchema, playgroundExamplePromptSchema, playgroundHeaderSchema, runtimeSchema, serverFieldsSchema, transportSchema, updateEnvironmentVariableSchema };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alpic-ai/api",
|
|
3
|
-
"version": "0.0.0-dev.
|
|
3
|
+
"version": "0.0.0-dev.gdf37760",
|
|
4
4
|
"description": "Contract for the Alpic API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.mjs",
|
|
@@ -33,20 +33,20 @@
|
|
|
33
33
|
"author": "Alpic",
|
|
34
34
|
"license": "ISC",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@orpc/contract": "^1.15.
|
|
36
|
+
"@orpc/contract": "^1.15.4",
|
|
37
37
|
"ms": "^2.1.3",
|
|
38
|
-
"zod": "^4.4
|
|
38
|
+
"zod": "^4.5.4"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@
|
|
42
|
-
"@orpc/
|
|
41
|
+
"@alpic-ai/domains": "0.0.0",
|
|
42
|
+
"@orpc/openapi": "^1.15.4",
|
|
43
|
+
"@orpc/zod": "^1.15.4",
|
|
43
44
|
"@total-typescript/tsconfig": "^1.0.4",
|
|
44
45
|
"@types/ms": "^2.1.0",
|
|
45
46
|
"shx": "^0.4.0",
|
|
46
|
-
"tsdown": "^0.
|
|
47
|
+
"tsdown": "^0.23.0",
|
|
47
48
|
"typescript": "^6.0.3",
|
|
48
|
-
"vitest": "^
|
|
49
|
-
"@alpic-ai/domains": "0.0.0"
|
|
49
|
+
"vitest": "^5.0.3"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"build": "shx rm -rf dist && tsdown",
|