@m6d/cortex 0.13.0 → 0.14.0

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.js CHANGED
@@ -16,7 +16,7 @@ import {
16
16
  datasetCatalogOf,
17
17
  checkDatasetQuery,
18
18
  boundDatasetResult
19
- } from "./index-j0kpmpfv.js";
19
+ } from "./index-4n21s4ns.js";
20
20
  import { createRequire } from "node:module";
21
21
  var __create = Object.create;
22
22
  var __getProtoOf = Object.getPrototypeOf;
@@ -13632,7 +13632,7 @@ var serverToolSchema = z3.object({
13632
13632
  name: declaredToolNameSchema,
13633
13633
  displayName: displayNameSchema.optional(),
13634
13634
  description: z3.string().trim().min(1).max(SERVER_MANIFEST_LIMITS.description),
13635
- inputSchema: jsonSchemaSchema.refine((schema) => schema.type === "object", "a tool's input is an object"),
13635
+ inputSchema: jsonSchemaSchema.refine((schema) => schema["type"] === "object", "a tool's input is an object"),
13636
13636
  outputSchema: jsonSchemaSchema.optional(),
13637
13637
  readOnly: z3.boolean(),
13638
13638
  requiresApproval: z3.boolean().optional()
@@ -13666,11 +13666,11 @@ function pointedAt(root, ref) {
13666
13666
  return ref.startsWith("#") ? readJsonPointer(root, ref) : undefined;
13667
13667
  }
13668
13668
  function namesApprovalTitle(node) {
13669
- const required = node.required;
13670
- return isRecord(node.properties) && Object.hasOwn(node.properties, APPROVAL_TITLE_FIELD) || Array.isArray(required) && required.includes(APPROVAL_TITLE_FIELD);
13669
+ const required = node["required"];
13670
+ return isRecord(node["properties"]) && Object.hasOwn(node["properties"], APPROVAL_TITLE_FIELD) || Array.isArray(required) && required.includes(APPROVAL_TITLE_FIELD);
13671
13671
  }
13672
13672
  function sameObjectSchemas(node, root) {
13673
- const schemas = typeof node.$ref === "string" ? [pointedAt(root, node.$ref)] : [];
13673
+ const schemas = typeof node["$ref"] === "string" ? [pointedAt(root, node["$ref"])] : [];
13674
13674
  for (const keyword of ["allOf", "anyOf", "oneOf"]) {
13675
13675
  const members = node[keyword];
13676
13676
  if (!Array.isArray(members))
@@ -13693,7 +13693,7 @@ function sameObjectNodes(inputSchema) {
13693
13693
  return nodes;
13694
13694
  }
13695
13695
  function closed(node) {
13696
- return node.additionalProperties === false || node.unevaluatedProperties === false;
13696
+ return node["additionalProperties"] === false || node["unevaluatedProperties"] === false;
13697
13697
  }
13698
13698
  function blocksApprovalTitle(inputSchema) {
13699
13699
  return sameObjectNodes(inputSchema).some((node) => namesApprovalTitle(node) || node !== inputSchema && closed(node));
@@ -14111,6 +14111,7 @@ var managementProcedureKinds = {
14111
14111
  "observability.listSkillMisses": "query",
14112
14112
  "observability.listSkillUsage": "query",
14113
14113
  "observability.listToolHealth": "query",
14114
+ "observability.listUsageUsers": "query",
14114
14115
  "observability.unhealthyToolIds": "query",
14115
14116
  "observability.unusedSkillIds": "query",
14116
14117
  "observability.updateSchemaDrift": "mutation",
@@ -14303,81 +14304,14 @@ function createManagementClient(target) {
14303
14304
  }
14304
14305
  return client;
14305
14306
  }
14306
- // ../../internal/contracts/src/manifest/index.ts
14307
- import { z as z7 } from "zod";
14307
+ // ../../internal/contracts/src/manifest/manifest.ts
14308
+ import { z as z19 } from "zod";
14308
14309
 
14309
- // ../../internal/contracts/src/egress-policy/url.ts
14310
- function isLoopback(hostname) {
14311
- return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1";
14312
- }
14313
- function normalizeHost(hostname) {
14314
- const bare = hostname.toLowerCase().replace(/\.$/, "").replace(/^\[(.*)]$/, "$1");
14315
- if (!bare.includes(":"))
14316
- return bare;
14317
- try {
14318
- return new URL(`http://[${bare}]`).hostname.replace(/^\[(.*)]$/, "$1");
14319
- } catch {
14320
- return bare;
14321
- }
14322
- }
14323
- function egressAllowedHosts() {
14324
- return (globalThis.process?.env?.EGRESS_ALLOWED_HOSTS ?? "").split(",").map((host) => host.trim()).filter(Boolean);
14325
- }
14326
- function isEgressAllowedHost(hostname, allowed = egressAllowedHosts()) {
14327
- const wanted = normalizeHost(hostname);
14328
- return allowed.some((host) => host === "*" || normalizeHost(host) === wanted);
14329
- }
14330
- function canCarrySecret(url, allowed = egressAllowedHosts()) {
14331
- try {
14332
- const { protocol, hostname } = new URL(url);
14333
- if (protocol === "https:")
14334
- return true;
14335
- if (protocol !== "http:")
14336
- return false;
14337
- return isLoopback(normalizeHost(hostname)) || isEgressAllowedHost(hostname, allowed);
14338
- } catch {
14339
- return false;
14340
- }
14341
- }
14342
- // ../../internal/contracts/src/schedule/index.ts
14343
- var import_cron_parser = __toESM(require_dist(), 1);
14344
- import { z as z6 } from "zod";
14345
- function isTimeZone(timeZone) {
14346
- try {
14347
- new Intl.DateTimeFormat("en", { timeZone });
14348
- return true;
14349
- } catch {
14350
- return false;
14351
- }
14352
- }
14353
- function isCron(cron) {
14354
- if (cron.split(/\s+/).length !== 5 || /\bH\b/i.test(cron))
14355
- return false;
14356
- try {
14357
- import_cron_parser.CronExpressionParser.parse(cron);
14358
- return true;
14359
- } catch {
14360
- return false;
14361
- }
14362
- }
14363
- function triggerScheduleSchemaWith(messages) {
14364
- return z6.object({
14365
- cron: z6.string().trim().refine(isCron, { error: messages.cron }),
14366
- timeZone: z6.string().trim().refine(isTimeZone, { error: messages.timeZone })
14367
- });
14368
- }
14369
- var triggerScheduleSchema = triggerScheduleSchemaWith({
14370
- cron: () => "is not a cron of five fields: minute, hour, day of month, month, day of week",
14371
- timeZone: () => "is not an IANA time zone, such as Asia/Dubai"
14372
- });
14310
+ // ../../internal/contracts/src/manifest/agents.ts
14311
+ import { z as z7 } from "zod";
14373
14312
 
14374
- // ../../internal/contracts/src/manifest/index.ts
14313
+ // ../../internal/contracts/src/manifest/bounds.ts
14375
14314
  var TOOL_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE"];
14376
- var RESPONSE_WRAPS = ["items", "value"];
14377
- var QUERY_STYLES = ["form", "spaceDelimited", "pipeDelimited", "deepObject"];
14378
- var PATH_STYLES = ["simple", "label", "matrix"];
14379
- var SOAP_VERSIONS = ["1.1", "1.2"];
14380
- var jsonPointerSchema = z7.string().regex(/^\//).max(256);
14381
14315
  var SETTING_BOUNDS = {
14382
14316
  tool: {
14383
14317
  timeoutMs: { min: 100, max: 120000, default: 30000 },
@@ -14403,9 +14337,6 @@ var SETTING_BOUNDS = {
14403
14337
  triggerChecksPerMinute: { min: 1, max: 1e4, default: 60 }
14404
14338
  }
14405
14339
  };
14406
- function setting({ min, max, default: fallback }) {
14407
- return z7.number().int().min(min).max(max).default(fallback);
14408
- }
14409
14340
  var RATE_LIMITS = {
14410
14341
  agent: {
14411
14342
  messagesPerMinute: { max: 1e4, allUsers: 600, perUser: 20 },
@@ -14414,112 +14345,25 @@ var RATE_LIMITS = {
14414
14345
  tool: { callsPerMinute: { max: 1e4, allUsers: 60, perUser: 20 } },
14415
14346
  datasetHost: { queriesPerMinute: { max: 1e4, allUsers: 60, perUser: 20 } }
14416
14347
  };
14417
- function rateLimit(bound, users) {
14418
- return z7.number().int().min(1).max(bound.max).nullable().default(bound[users]);
14419
- }
14420
- function overridable(fields) {
14421
- return z7.array(z7.enum(fields)).refine((listed) => new Set(listed).size === listed.length, "a field repeats").default([]);
14422
- }
14348
+ var TOOL_TYPE_NAMES = ["http", "embedded", "soap", "native", "client"];
14349
+ var MCP_CONNECTION_OWNERS = ["shared", "endUser"];
14350
+ var RESPONSE_WRAPS = ["items", "value"];
14351
+ var QUERY_STYLES = ["form", "spaceDelimited", "pipeDelimited", "deepObject"];
14352
+ var PATH_STYLES = ["simple", "label", "matrix"];
14353
+ var SOAP_VERSIONS = ["1.1", "1.2"];
14423
14354
  var HOSTNAME_PATTERN = /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?(\.[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/;
14424
14355
  var FETCH_IMAGE_HOSTS_LIMIT = 20;
14425
14356
  var A2A_PUSH_HOSTS_LIMIT = 20;
14426
14357
  var SUGGESTION_LIMITS = { perLocale: 6, titleLength: 120, promptLength: 2000 };
14427
- var trimmedText = (max) => z7.string().min(1).max(max).refine((text) => text === text.trim(), "text has surrounding whitespace");
14428
- var suggestionsSchema = z7.record(localeSchema, z7.array(z7.object({
14429
- title: trimmedText(SUGGESTION_LIMITS.titleLength),
14430
- prompt: trimmedText(SUGGESTION_LIMITS.promptLength)
14431
- })).max(SUGGESTION_LIMITS.perLocale));
14432
14358
  var GREETING_MAX_LENGTH = 200;
14433
- var greetingSchema = z7.record(localeSchema, z7.string().max(GREETING_MAX_LENGTH).refine((text) => text === text.trim(), "greeting has surrounding whitespace"));
14434
- var toolTagsSchema = z7.array(z7.string().trim().min(1).max(60).regex(/^[^,]*$/, "a tag holds no comma")).max(20);
14435
- var tlsUrlSchema = z7.url().refine((url) => canCarrySecret(url, []));
14436
- var embedOriginSchema = tlsUrlSchema.transform((value) => new URL(value).origin);
14437
- var soapActionSchema = z7.string().regex(/^[^"\\\u0000-\u001f\u007f]*$/);
14438
- var envelopeTemplateSchema = z7.string().refine((template) => template.trim().length > 0);
14439
14359
  var FORM_MEDIA_TYPES = [
14440
14360
  "application/x-www-form-urlencoded",
14441
14361
  "multipart/form-data"
14442
14362
  ];
14443
- var toolConfigByType = {
14444
- http: z7.object({
14445
- responseWrap: z7.enum(RESPONSE_WRAPS).optional(),
14446
- requestMediaType: z7.enum(FORM_MEDIA_TYPES).optional(),
14447
- resultPath: jsonPointerSchema.optional()
14448
- }),
14449
- embedded: z7.object({ embedOrigin: embedOriginSchema, surface: z7.enum(TOOL_SURFACES) }),
14450
- soap: z7.object({
14451
- soapVersion: z7.enum(SOAP_VERSIONS),
14452
- soapAction: soapActionSchema,
14453
- envelopeTemplate: envelopeTemplateSchema,
14454
- tokenCall: z7.object({
14455
- envelopeTemplate: envelopeTemplateSchema,
14456
- soapAction: soapActionSchema,
14457
- tokenPath: z7.string().trim().min(1)
14458
- }).optional()
14459
- }),
14460
- native: z7.object({}),
14461
- client: z7.object({})
14462
- };
14463
- var TOOL_TYPE_NAMES = ["http", "embedded", "soap", "native", "client"];
14464
- var TOOL_TYPES = {
14465
- http: {
14466
- kind: "server",
14467
- calls: true,
14468
- approval: true,
14469
- sources: true,
14470
- targets: true,
14471
- creatable: true
14472
- },
14473
- embedded: {
14474
- kind: "client",
14475
- calls: true,
14476
- approval: false,
14477
- sources: true,
14478
- targets: false,
14479
- creatable: true,
14480
- readOnly: false
14481
- },
14482
- soap: {
14483
- kind: "server",
14484
- calls: true,
14485
- approval: true,
14486
- sources: true,
14487
- targets: true,
14488
- creatable: true,
14489
- method: "POST"
14490
- },
14491
- native: {
14492
- kind: "server",
14493
- calls: true,
14494
- approval: true,
14495
- sources: false,
14496
- targets: false,
14497
- creatable: false,
14498
- method: "POST"
14499
- },
14500
- client: {
14501
- kind: "client",
14502
- calls: false,
14503
- approval: false,
14504
- sources: false,
14505
- targets: false,
14506
- creatable: true,
14507
- readOnly: true
14508
- }
14509
- };
14510
- var CREATABLE_TOOL_TYPES = TOOL_TYPE_NAMES.filter((type) => TOOL_TYPES[type].creatable);
14511
14363
  var ENDPOINT_PARAM_PATTERN = /\{([^{}]+)\}/g;
14512
- function confinesEndpointParams(url) {
14513
- const origin = /^[^:/?#]*:[/\\]*[^/\\?#]*/.exec(url)?.[0] ?? "";
14514
- const hash = url.indexOf("#", origin.length);
14515
- const fragment = hash < 0 ? "" : url.slice(hash);
14516
- return ![origin, fragment].some((part) => part.match(ENDPOINT_PARAM_PATTERN));
14517
- }
14518
- var upstreamUrlSchema = z7.url({ protocol: /^https?$/ });
14519
14364
  var HEADER_LIMITS = { headerLength: 120, prefixLength: 40, headers: 8 };
14520
14365
  var HEADER_NAME_PATTERN = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
14521
14366
  var HEADER_VALUE_PATTERN = /^[\t\x20-\x7e\x80-\xff]*$/;
14522
- var headerNameSchema = z7.string().trim().min(1).max(HEADER_LIMITS.headerLength).regex(HEADER_NAME_PATTERN);
14523
14367
  var transportSetHeaders = ["accept", "content-type", "content-length", "host"];
14524
14368
  var transportForbiddenHeaders = [
14525
14369
  "connection",
@@ -14539,133 +14383,516 @@ var transportOwnedHeaders = new Set([
14539
14383
  ...transportSetHeaders,
14540
14384
  ...transportForbiddenHeaders
14541
14385
  ]);
14542
- function repeatedHeaders(entries) {
14543
- const seen = new Set;
14544
- return entries.flatMap((entry, index) => {
14545
- const name = entry.header.toLowerCase();
14546
- const repeated = seen.has(name);
14547
- seen.add(name);
14548
- return repeated ? [index] : [];
14549
- });
14386
+ var SCALAR_TYPES = ["string", "number", "integer", "boolean"];
14387
+ var FIELD_LIMITS = { nameLength: 120, descriptionLength: 500, enumValues: 50 };
14388
+ var MODEL_PROVIDER_LIMITS = { urlLength: 2048, modelLength: 200, models: 100 };
14389
+ var SERVICE_LIMITS = { descriptionLength: 4000 };
14390
+ var SKILL_LIMITS = { descriptionLength: 500 };
14391
+ var TRIGGER_LIMITS = { descriptionLength: 500, instructionsLength: 20000 };
14392
+ var COLLECTION_LIMITS = { descriptionLength: 2000, documents: 100 };
14393
+ var DOCUMENT_LIMITS = { nameLength: 255, bytes: 10 * 1024 * 1024 };
14394
+ var DOCX_MIME_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
14395
+ var AUTH_JWT_SECRET_ALGORITHMS = ["HS256", "HS384", "HS512"];
14396
+ var MANIFEST_KINDS = [
14397
+ "agents",
14398
+ "services",
14399
+ "tools",
14400
+ "skills",
14401
+ "triggers",
14402
+ "datasetHosts",
14403
+ "mcpServers",
14404
+ "webhooks",
14405
+ "collections"
14406
+ ];
14407
+
14408
+ // ../../internal/contracts/src/manifest/fields.ts
14409
+ import { z as z6 } from "zod";
14410
+
14411
+ // ../../internal/contracts/src/egress-policy/url.ts
14412
+ function isLoopback(hostname) {
14413
+ return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1";
14550
14414
  }
14551
- var presentedHeaderSchema = headerNameSchema.refine((name) => !transportOwnedHeaders.has(name.toLowerCase()), "a header the transport sets");
14552
- function headerListSchema(entry, repeated) {
14553
- return z7.array(entry).max(HEADER_LIMITS.headers).superRefine((entries, context) => {
14554
- for (const index of repeatedHeaders(entries)) {
14555
- context.addIssue({
14556
- code: "custom",
14557
- path: [index, "header"],
14558
- message: repeated()
14559
- });
14560
- }
14561
- });
14415
+ function normalizeHost(hostname) {
14416
+ const bare = hostname.toLowerCase().replace(/\.$/, "").replace(/^\[(.*)]$/, "$1");
14417
+ if (!bare.includes(":"))
14418
+ return bare;
14419
+ try {
14420
+ return new URL(`http://[${bare}]`).hostname.replace(/^\[(.*)]$/, "$1");
14421
+ } catch {
14422
+ return bare;
14423
+ }
14562
14424
  }
14563
- var variableSourceSchema = z7.object({
14564
- kind: z7.literal("variable"),
14565
- name: z7.string().trim().min(1).max(64)
14566
- });
14567
- var credentialSourceSchema = z7.object({
14568
- kind: z7.literal("credential"),
14569
- name: nameSchema
14570
- });
14571
- var constantHeaderSourceSchema = z7.object({
14572
- kind: z7.literal("constant"),
14573
- value: z7.string().max(4000)
14574
- });
14575
- var headerSourceSchema = z7.discriminatedUnion("kind", [
14576
- credentialSourceSchema,
14577
- z7.object({ kind: z7.literal("runToken") }),
14578
- variableSourceSchema,
14579
- constantHeaderSourceSchema
14580
- ]);
14581
- var runlessHeaderSourceSchema = z7.discriminatedUnion("kind", [
14582
- credentialSourceSchema,
14583
- constantHeaderSourceSchema
14584
- ]);
14585
- function declaredHeadersSchema(header, from) {
14586
- return headerListSchema(z7.strictObject({
14587
- header,
14588
- prefix: z7.string().max(HEADER_LIMITS.prefixLength).regex(HEADER_VALUE_PATTERN, "a prefix a header cannot carry").default(""),
14589
- from
14590
- }).refine((entry) => entry.from.kind !== "constant" || HEADER_VALUE_PATTERN.test(entry.from.value), { path: ["from", "value"], message: "a value a header cannot carry" }), () => "a header declared twice").default([]);
14425
+ function egressAllowedHosts() {
14426
+ return (globalThis.process?.env?.EGRESS_ALLOWED_HOSTS ?? "").split(",").map((host) => host.trim()).filter(Boolean);
14591
14427
  }
14592
- var headersSchema = declaredHeadersSchema(presentedHeaderSchema, headerSourceSchema);
14593
- var fieldSourceSchema = z7.discriminatedUnion("kind", [
14594
- variableSourceSchema,
14595
- z7.object({ kind: z7.literal("secret"), name: nameSchema }),
14596
- z7.object({
14597
- kind: z7.literal("constant"),
14598
- value: z7.union([z7.string().max(4000), z7.number(), z7.boolean()])
14599
- }),
14600
- z7.object({ kind: z7.literal("endUserToken") })
14601
- ]);
14602
- function sourceFits(source, field) {
14603
- switch (source.kind) {
14604
- case "variable":
14428
+ function isEgressAllowedHost(hostname, allowed = egressAllowedHosts()) {
14429
+ const wanted = normalizeHost(hostname);
14430
+ return allowed.some((host) => host === "*" || normalizeHost(host) === wanted);
14431
+ }
14432
+ function canCarrySecret(url, allowed = egressAllowedHosts()) {
14433
+ try {
14434
+ const { protocol, hostname } = new URL(url);
14435
+ if (protocol === "https:")
14605
14436
  return true;
14606
- case "secret":
14607
- case "endUserToken":
14608
- return field.type === "string";
14609
- case "constant": {
14610
- const { value } = source;
14611
- if (field.enum)
14612
- return typeof value === "string" && field.enum.includes(value);
14613
- if (field.type === "boolean")
14614
- return typeof value === "boolean";
14615
- if (field.type === "number")
14616
- return typeof value === "number" && Number.isFinite(value);
14617
- if (field.type === "integer")
14618
- return Number.isInteger(value);
14619
- return field.type === "string" && typeof value === "string";
14620
- }
14437
+ if (protocol !== "http:")
14438
+ return false;
14439
+ return isLoopback(normalizeHost(hostname)) || isEgressAllowedHost(hostname, allowed);
14440
+ } catch {
14441
+ return false;
14621
14442
  }
14622
14443
  }
14623
- var fieldTargetSchema = z7.discriminatedUnion("kind", [
14444
+ // ../../internal/contracts/src/manifest/fields.ts
14445
+ var jsonPointerSchema = z6.string().regex(/^\//).max(256);
14446
+ function setting({ min, max, default: fallback }) {
14447
+ return z6.number().int().min(min).max(max).default(fallback);
14448
+ }
14449
+ function rateLimit(bound, users) {
14450
+ return z6.number().int().min(1).max(bound.max).nullable().default(bound[users]);
14451
+ }
14452
+ function overridable(fields) {
14453
+ return z6.array(z6.enum(fields)).refine((listed) => new Set(listed).size === listed.length, "a field repeats").default([]);
14454
+ }
14455
+ var tlsUrlSchema = z6.url().refine((url) => canCarrySecret(url, []));
14456
+ var upstreamUrlSchema = z6.url({ protocol: /^https?$/ });
14457
+ var audienceSchema = z6.union([
14458
+ z6.literal("all"),
14459
+ z6.strictObject({ server: nameSchema }),
14460
+ z6.strictObject({
14461
+ agents: z6.array(nameSchema).min(1).refine((names) => new Set(names).size === names.length, "an agent repeats")
14462
+ })
14463
+ ]);
14464
+ var modelSchema = z6.strictObject({
14465
+ provider: nameSchema,
14466
+ model: z6.string().trim().min(1).max(MODEL_PROVIDER_LIMITS.modelLength),
14467
+ effort: z6.string().trim().min(1).max(64).optional()
14468
+ });
14469
+
14470
+ // ../../internal/contracts/src/manifest/agents.ts
14471
+ var trimmedText = (max) => z7.string().min(1).max(max).refine((text) => text === text.trim(), "text has surrounding whitespace");
14472
+ var suggestionsSchema = z7.record(localeSchema, z7.array(z7.object({
14473
+ title: trimmedText(SUGGESTION_LIMITS.titleLength),
14474
+ prompt: trimmedText(SUGGESTION_LIMITS.promptLength)
14475
+ })).max(SUGGESTION_LIMITS.perLocale));
14476
+ var greetingSchema = z7.record(localeSchema, z7.string().max(GREETING_MAX_LENGTH).refine((text) => text === text.trim(), "greeting has surrounding whitespace"));
14477
+ var issuerSchema = z7.string().trim().min(1).max(2048);
14478
+ var tokenAudienceSchema = z7.string().trim().min(1).max(2048).optional();
14479
+ var agentAuthSchema = z7.discriminatedUnion("kind", [
14624
14480
  z7.strictObject({
14625
- kind: z7.literal("body"),
14626
- contentType: z7.enum(["application/json", "text/plain"]).optional(),
14627
- style: z7.enum(QUERY_STYLES).optional(),
14628
- explode: z7.boolean().optional()
14481
+ kind: z7.literal("jwks"),
14482
+ jwksUri: tlsUrlSchema,
14483
+ issuer: issuerSchema,
14484
+ audience: tokenAudienceSchema
14629
14485
  }),
14630
14486
  z7.strictObject({
14631
- kind: z7.literal("query"),
14632
- name: z7.string().trim().min(1).max(120).optional(),
14633
- style: z7.enum(QUERY_STYLES).optional(),
14634
- explode: z7.boolean().optional()
14487
+ kind: z7.literal("jwt-secret"),
14488
+ secret: nameSchema,
14489
+ algorithm: z7.enum(AUTH_JWT_SECRET_ALGORITHMS),
14490
+ issuer: issuerSchema,
14491
+ audience: tokenAudienceSchema
14635
14492
  }),
14636
14493
  z7.strictObject({
14637
- kind: z7.literal("path"),
14638
- name: z7.string().trim().min(1).max(120).optional(),
14639
- style: z7.enum(PATH_STYLES).optional(),
14640
- explode: z7.boolean().optional()
14494
+ kind: z7.literal("anonymous"),
14495
+ recaptcha: z7.strictObject({
14496
+ siteKey: z7.string().trim().min(1).max(200),
14497
+ projectId: z7.string().trim().min(1).max(200),
14498
+ secret: nameSchema,
14499
+ minScore: z7.number().min(SETTING_BOUNDS.recaptcha.minScore.min).max(SETTING_BOUNDS.recaptcha.minScore.max).default(SETTING_BOUNDS.recaptcha.minScore.default)
14500
+ }).optional()
14641
14501
  }),
14642
- z7.strictObject({
14643
- kind: z7.literal("header"),
14502
+ z7.strictObject({ kind: z7.literal("server") })
14503
+ ]);
14504
+ var { agentContext, agentLimits } = SETTING_BOUNDS;
14505
+ var { agent: agentRateLimits } = RATE_LIMITS;
14506
+ var agentSettingsSchema = z7.strictObject({
14507
+ ragEnabled: z7.boolean().default(false),
14508
+ toolRegistryEnabled: z7.boolean().default(false),
14509
+ serviceRegistryEnabled: z7.boolean().default(false),
14510
+ subagentsEnabled: z7.boolean().default(false),
14511
+ checkBacksEnabled: z7.boolean().default(false),
14512
+ attachmentsEnabled: z7.boolean().default(true),
14513
+ fetchImageHostnames: z7.array(z7.string().max(253).regex(HOSTNAME_PATTERN)).max(FETCH_IMAGE_HOSTS_LIMIT).default([]),
14514
+ locationPicker: z7.boolean().default(false),
14515
+ media: z7.array(z7.enum(MEDIA_FORMS)).default([...DEFAULT_MEDIA_FORMS]),
14516
+ messages: z7.boolean().default(true),
14517
+ whileBusy: z7.enum(WHILE_BUSY).default("refuse"),
14518
+ a2a: z7.boolean().default(false),
14519
+ a2aPushHostnames: z7.array(z7.string().max(253).regex(HOSTNAME_PATTERN)).max(A2A_PUSH_HOSTS_LIMIT).default([]),
14520
+ description: z7.string().trim().max(1000).default(""),
14521
+ defaultLocale: localeSchema.default(BASE_LOCALE),
14522
+ context: z7.strictObject({
14523
+ maxContextTokens: setting(agentContext.maxContextTokens),
14524
+ summarizationThreshold: z7.number().min(agentContext.summarizationThreshold.min).max(agentContext.summarizationThreshold.max).default(agentContext.summarizationThreshold.default),
14525
+ toolResultMaxTokens: setting(agentContext.toolResultMaxTokens),
14526
+ recentMessagesToKeep: setting(agentContext.recentMessagesToKeep)
14527
+ }).prefault({}),
14528
+ limits: z7.strictObject({
14529
+ resolveTokenBudget: setting(agentLimits.resolveTokenBudget),
14530
+ executeTimeoutMs: setting(agentLimits.executeTimeoutMs),
14531
+ maxResponseBytes: setting(agentLimits.maxResponseBytes)
14532
+ }).prefault({})
14533
+ });
14534
+ var manifestAgentSchema = z7.strictObject({
14535
+ name: nameSchema,
14536
+ displayName: displayNameSchema.default({}),
14537
+ server: nameSchema.optional(),
14538
+ prompt: z7.string().trim().min(1),
14539
+ auth: agentAuthSchema,
14540
+ models: z7.strictObject({
14541
+ chat: modelSchema.optional(),
14542
+ vision: modelSchema.omit({ effort: true }).optional(),
14543
+ summarization: modelSchema.omit({ effort: true }).optional()
14544
+ }).default({}),
14545
+ settings: agentSettingsSchema.prefault({}),
14546
+ rateLimits: z7.strictObject({
14547
+ allUsers: z7.strictObject({
14548
+ messagesPerMinute: rateLimit(agentRateLimits.messagesPerMinute, "allUsers"),
14549
+ tokensPerDay: rateLimit(agentRateLimits.tokensPerDay, "allUsers")
14550
+ }).prefault({}),
14551
+ perUser: z7.strictObject({
14552
+ messagesPerMinute: rateLimit(agentRateLimits.messagesPerMinute, "perUser"),
14553
+ tokensPerDay: rateLimit(agentRateLimits.tokensPerDay, "perUser")
14554
+ }).prefault({})
14555
+ }).prefault({}),
14556
+ suggestions: suggestionsSchema.default(() => byLocale(() => [])),
14557
+ greeting: greetingSchema.default(() => byLocale(() => "")),
14558
+ overridable: overridable([
14559
+ "displayName",
14560
+ "prompt",
14561
+ "models",
14562
+ "settings",
14563
+ "rateLimits",
14564
+ "suggestions",
14565
+ "greeting"
14566
+ ])
14567
+ }).superRefine((agent, context) => {
14568
+ if (agent.server !== undefined)
14569
+ return;
14570
+ if (agent.auth.kind === "server") {
14571
+ context.addIssue({
14572
+ code: "custom",
14573
+ path: ["auth"],
14574
+ message: "server auth needs a server"
14575
+ });
14576
+ }
14577
+ if (agent.models.chat === undefined) {
14578
+ context.addIssue({
14579
+ code: "custom",
14580
+ path: ["models", "chat"],
14581
+ message: "an agent with no server names its own chat model"
14582
+ });
14583
+ }
14584
+ });
14585
+
14586
+ // ../../internal/contracts/src/manifest/datasets.ts
14587
+ import { z as z9 } from "zod";
14588
+
14589
+ // ../../internal/contracts/src/manifest/headers.ts
14590
+ import { z as z8 } from "zod";
14591
+ var headerNameSchema = z8.string().trim().min(1).max(HEADER_LIMITS.headerLength).regex(HEADER_NAME_PATTERN);
14592
+ function repeatedHeaders(entries) {
14593
+ const seen = new Set;
14594
+ return entries.flatMap((entry, index) => {
14595
+ const name = entry.header.toLowerCase();
14596
+ const repeated = seen.has(name);
14597
+ seen.add(name);
14598
+ return repeated ? [index] : [];
14599
+ });
14600
+ }
14601
+ var presentedHeaderSchema = headerNameSchema.refine((name) => !transportOwnedHeaders.has(name.toLowerCase()), "a header the transport sets");
14602
+ function headerListSchema(entry, repeated) {
14603
+ return z8.array(entry).max(HEADER_LIMITS.headers).superRefine((entries, context) => {
14604
+ for (const index of repeatedHeaders(entries)) {
14605
+ context.addIssue({
14606
+ code: "custom",
14607
+ path: [index, "header"],
14608
+ message: repeated()
14609
+ });
14610
+ }
14611
+ });
14612
+ }
14613
+ var variableSourceSchema = z8.object({
14614
+ kind: z8.literal("variable"),
14615
+ name: z8.string().trim().min(1).max(64)
14616
+ });
14617
+ var credentialSourceSchema = z8.object({
14618
+ kind: z8.literal("credential"),
14619
+ name: nameSchema
14620
+ });
14621
+ var constantHeaderSourceSchema = z8.object({
14622
+ kind: z8.literal("constant"),
14623
+ value: z8.string().max(4000)
14624
+ });
14625
+ var headerSourceSchema = z8.discriminatedUnion("kind", [
14626
+ credentialSourceSchema,
14627
+ z8.object({ kind: z8.literal("runToken") }),
14628
+ variableSourceSchema,
14629
+ constantHeaderSourceSchema
14630
+ ]);
14631
+ var runlessHeaderSourceSchema = z8.discriminatedUnion("kind", [
14632
+ credentialSourceSchema,
14633
+ constantHeaderSourceSchema
14634
+ ]);
14635
+ function declaredHeadersSchema(header, from) {
14636
+ return headerListSchema(z8.strictObject({
14637
+ header,
14638
+ prefix: z8.string().max(HEADER_LIMITS.prefixLength).regex(HEADER_VALUE_PATTERN, "a prefix a header cannot carry").default(""),
14639
+ from
14640
+ }).refine((entry) => entry.from.kind !== "constant" || HEADER_VALUE_PATTERN.test(entry.from.value), { path: ["from", "value"], message: "a value a header cannot carry" }), () => "a header declared twice").default([]);
14641
+ }
14642
+ var headersSchema = declaredHeadersSchema(presentedHeaderSchema, headerSourceSchema);
14643
+
14644
+ // ../../internal/contracts/src/manifest/datasets.ts
14645
+ function unexposedPins(host) {
14646
+ const exposed = new Set(host.expose);
14647
+ return host.pinned.filter((name) => !exposed.has(name));
14648
+ }
14649
+ var { datasetHost: datasetHostRateLimits } = RATE_LIMITS;
14650
+ var manifestDatasetHostSchema = z9.strictObject({
14651
+ name: datasetIdentifierSchema,
14652
+ displayName: displayNameSchema.default({}),
14653
+ url: upstreamUrlSchema,
14654
+ headers: headersSchema,
14655
+ timeoutMs: setting(SETTING_BOUNDS.datasetHost.timeoutMs),
14656
+ rateLimits: z9.strictObject({
14657
+ allUsers: z9.strictObject({
14658
+ queriesPerMinute: rateLimit(datasetHostRateLimits.queriesPerMinute, "allUsers")
14659
+ }).prefault({}),
14660
+ perUser: z9.strictObject({
14661
+ queriesPerMinute: rateLimit(datasetHostRateLimits.queriesPerMinute, "perUser")
14662
+ }).prefault({})
14663
+ }).prefault({}),
14664
+ expose: z9.array(datasetIdentifierSchema).min(1).max(500),
14665
+ pinned: z9.array(datasetIdentifierSchema).max(50).default([]),
14666
+ audience: audienceSchema,
14667
+ overridable: overridable(["displayName", "timeoutMs", "rateLimits", "headers"])
14668
+ }).superRefine((host, context) => {
14669
+ const unexposed = unexposedPins(host);
14670
+ if (unexposed.length > 0) {
14671
+ context.addIssue({
14672
+ code: "custom",
14673
+ path: ["pinned"],
14674
+ message: `not exposed: ${unexposed.join(", ")}`
14675
+ });
14676
+ }
14677
+ });
14678
+
14679
+ // ../../internal/contracts/src/manifest/knowledge.ts
14680
+ import { z as z10 } from "zod";
14681
+ var mimeTypeByExtension = new Map([
14682
+ ["md", "text/markdown"],
14683
+ ["txt", "text/plain"],
14684
+ ["html", "text/html"],
14685
+ ["htm", "text/html"],
14686
+ ["pdf", "application/pdf"],
14687
+ ["docx", DOCX_MIME_TYPE]
14688
+ ]);
14689
+ function documentType(name) {
14690
+ const dot = name.lastIndexOf(".");
14691
+ return dot === -1 ? undefined : mimeTypeByExtension.get(name.slice(dot + 1).toLowerCase());
14692
+ }
14693
+ function base64Bytes(data) {
14694
+ const padding = data.endsWith("==") ? 2 : data.endsWith("=") ? 1 : 0;
14695
+ return data.length / 4 * 3 - padding;
14696
+ }
14697
+ var documentNameSchema = z10.string().trim().min(1).max(DOCUMENT_LIMITS.nameLength);
14698
+ var textDocumentSchema = z10.strictObject({
14699
+ name: documentNameSchema,
14700
+ text: z10.string().min(1).refine((text) => new TextEncoder().encode(text).byteLength <= DOCUMENT_LIMITS.bytes, `larger than ${DOCUMENT_LIMITS.bytes} bytes`)
14701
+ });
14702
+ var pathDocumentSchema = z10.strictObject({
14703
+ path: z10.string().trim().min(1),
14704
+ name: documentNameSchema.optional()
14705
+ });
14706
+ var urlDocumentSchema = z10.strictObject({
14707
+ url: upstreamUrlSchema,
14708
+ name: documentNameSchema.optional()
14709
+ });
14710
+ var dataDocumentSchema = z10.strictObject({
14711
+ name: documentNameSchema,
14712
+ data: z10.base64().refine((data) => base64Bytes(data) <= DOCUMENT_LIMITS.bytes, `larger than ${DOCUMENT_LIMITS.bytes} bytes`)
14713
+ });
14714
+ function documentName(document) {
14715
+ if (document.name !== undefined)
14716
+ return document.name;
14717
+ if (document.path !== undefined)
14718
+ return document.path.split(/[/\\]/).pop() ?? "";
14719
+ const segment = new URL(document.url ?? "", "https://x").pathname.split("/").pop() ?? "";
14720
+ try {
14721
+ return decodeURIComponent(segment);
14722
+ } catch {
14723
+ return segment;
14724
+ }
14725
+ }
14726
+ function documentsSchema(document) {
14727
+ return z10.array(document).max(COLLECTION_LIMITS.documents).superRefine((documents, ctx) => {
14728
+ const names = documents.map(documentName);
14729
+ names.forEach((name, index) => {
14730
+ if (documentType(name) === undefined) {
14731
+ ctx.addIssue({
14732
+ code: "custom",
14733
+ path: [index, "name"],
14734
+ message: "a document's name ends in .md, .txt, .html, .htm, .pdf or .docx"
14735
+ });
14736
+ } else if (names.indexOf(name) !== index) {
14737
+ ctx.addIssue({
14738
+ code: "custom",
14739
+ path: [index, "name"],
14740
+ message: "a name repeats"
14741
+ });
14742
+ }
14743
+ });
14744
+ }).default([]);
14745
+ }
14746
+ function collectionSchema(document) {
14747
+ return z10.strictObject({
14748
+ name: nameSchema,
14749
+ displayName: displayNameSchema.default({}),
14750
+ description: z10.string().trim().max(COLLECTION_LIMITS.descriptionLength).default(""),
14751
+ service: nameSchema.optional(),
14752
+ citable: z10.boolean().default(true),
14753
+ documents: documentsSchema(document),
14754
+ audience: audienceSchema,
14755
+ overridable: overridable(["displayName", "description", "documents"])
14756
+ });
14757
+ }
14758
+ var manifestDocumentSchema = z10.union([textDocumentSchema, pathDocumentSchema, urlDocumentSchema]);
14759
+ var manifestCollectionSchema = collectionSchema(manifestDocumentSchema);
14760
+ var resolvedCollectionSchema = collectionSchema(z10.union([textDocumentSchema, dataDocumentSchema, urlDocumentSchema]));
14761
+
14762
+ // ../../internal/contracts/src/manifest/mcp-servers.ts
14763
+ import { z as z11 } from "zod";
14764
+ var mcpToolNamesSchema = z11.array(z11.string().trim().min(1).max(128).regex(/^[^,]*$/, "a tool name holds no comma")).max(200);
14765
+ var mcpSignInSchema = z11.strictObject({
14766
+ connects: z11.enum(MCP_CONNECTION_OWNERS),
14767
+ scope: z11.string().trim().min(1).max(1000).optional(),
14768
+ credential: nameSchema.optional()
14769
+ });
14770
+ function authorizationBesideSignIn(server) {
14771
+ return server.signIn ? server.headers.findIndex((entry) => entry.header.toLowerCase() === "authorization") : -1;
14772
+ }
14773
+ var manifestMcpServerSchema = z11.strictObject({
14774
+ name: identifierSchema,
14775
+ displayName: displayNameSchema.default({}),
14776
+ url: upstreamUrlSchema,
14777
+ headers: declaredHeadersSchema(presentedHeaderSchema.refine((name) => !mcpTransportHeaders.has(name.toLowerCase()), "a header the MCP transport sets"), headerSourceSchema),
14778
+ signIn: mcpSignInSchema.optional(),
14779
+ include: mcpToolNamesSchema.default([]),
14780
+ exclude: mcpToolNamesSchema.default([]),
14781
+ audience: audienceSchema,
14782
+ overridable: overridable(["displayName", "include", "exclude", "headers", "signIn"])
14783
+ }).superRefine((server, context) => {
14784
+ const index = authorizationBesideSignIn(server);
14785
+ if (index >= 0) {
14786
+ context.addIssue({
14787
+ code: "custom",
14788
+ path: ["headers", index, "header"],
14789
+ message: "the sign-in's token travels under Authorization"
14790
+ });
14791
+ }
14792
+ });
14793
+
14794
+ // ../../internal/contracts/src/manifest/services.ts
14795
+ import { z as z12 } from "zod";
14796
+ var localizedTextSchema = z12.record(localeSchema, z12.string().trim().min(1).max(SERVICE_LIMITS.descriptionLength));
14797
+ var manifestServiceSchema = z12.strictObject({
14798
+ name: nameSchema,
14799
+ displayName: displayNameSchema.default({}),
14800
+ description: localizedTextSchema,
14801
+ audience: audienceSchema,
14802
+ overridable: overridable(["displayName", "description"])
14803
+ });
14804
+
14805
+ // ../../internal/contracts/src/manifest/skills.ts
14806
+ import { z as z13 } from "zod";
14807
+ var manifestSkillSchema = z13.strictObject({
14808
+ name: nameSchema,
14809
+ displayName: displayNameSchema.default({}),
14810
+ description: z13.string().trim().min(1).max(SKILL_LIMITS.descriptionLength),
14811
+ body: z13.string().trim().min(1),
14812
+ service: nameSchema.optional(),
14813
+ audience: audienceSchema,
14814
+ overridable: overridable(["displayName", "description", "body"])
14815
+ });
14816
+
14817
+ // ../../internal/contracts/src/manifest/tools.ts
14818
+ import { z as z15 } from "zod";
14819
+
14820
+ // ../../internal/contracts/src/manifest/json-schema.ts
14821
+ import { z as z14 } from "zod";
14822
+ var fieldSourceSchema = z14.discriminatedUnion("kind", [
14823
+ variableSourceSchema,
14824
+ z14.object({ kind: z14.literal("secret"), name: nameSchema }),
14825
+ z14.object({
14826
+ kind: z14.literal("constant"),
14827
+ value: z14.union([z14.string().max(4000), z14.number(), z14.boolean()])
14828
+ }),
14829
+ z14.object({ kind: z14.literal("endUserToken") })
14830
+ ]);
14831
+ function sourceFits(source, field) {
14832
+ switch (source.kind) {
14833
+ case "variable":
14834
+ return true;
14835
+ case "secret":
14836
+ case "endUserToken":
14837
+ return field.type === "string";
14838
+ case "constant": {
14839
+ const { value } = source;
14840
+ if (field.enum)
14841
+ return typeof value === "string" && field.enum.includes(value);
14842
+ if (field.type === "boolean")
14843
+ return typeof value === "boolean";
14844
+ if (field.type === "number")
14845
+ return typeof value === "number" && Number.isFinite(value);
14846
+ if (field.type === "integer")
14847
+ return Number.isInteger(value);
14848
+ return field.type === "string" && typeof value === "string";
14849
+ }
14850
+ }
14851
+ }
14852
+ var fieldTargetSchema = z14.discriminatedUnion("kind", [
14853
+ z14.strictObject({
14854
+ kind: z14.literal("body"),
14855
+ contentType: z14.enum(["application/json", "text/plain"]).optional(),
14856
+ style: z14.enum(QUERY_STYLES).optional(),
14857
+ explode: z14.boolean().optional()
14858
+ }),
14859
+ z14.strictObject({
14860
+ kind: z14.literal("query"),
14861
+ name: z14.string().trim().min(1).max(120).optional(),
14862
+ style: z14.enum(QUERY_STYLES).optional(),
14863
+ explode: z14.boolean().optional()
14864
+ }),
14865
+ z14.strictObject({
14866
+ kind: z14.literal("path"),
14867
+ name: z14.string().trim().min(1).max(120).optional(),
14868
+ style: z14.enum(PATH_STYLES).optional(),
14869
+ explode: z14.boolean().optional()
14870
+ }),
14871
+ z14.strictObject({
14872
+ kind: z14.literal("header"),
14644
14873
  name: headerNameSchema.optional(),
14645
- explode: z7.boolean().optional()
14874
+ explode: z14.boolean().optional()
14646
14875
  }),
14647
- z7.strictObject({ kind: z7.literal("cookie"), name: headerNameSchema.optional() })
14876
+ z14.strictObject({ kind: z14.literal("cookie"), name: headerNameSchema.optional() })
14648
14877
  ]);
14649
- var SCALAR_TYPES = ["string", "number", "integer", "boolean"];
14650
- var schemaTypeSchema = z7.enum([...SCALAR_TYPES, "object", "array"]);
14651
- var FIELD_LIMITS = { nameLength: 120, descriptionLength: 500, enumValues: 50 };
14652
- var propertyNameSchema = z7.string().min(1).max(FIELD_LIMITS.nameLength).refine((name) => name === name.trim(), "no surrounding spaces");
14653
- var propertyOrderSchema = z7.array(z7.string()).refine((names) => new Set(names).size === names.length, "a name repeats").optional();
14654
- var countSchema = z7.number().int().min(0).optional();
14655
- var valueKeywordsSchema = z7.strictObject({
14656
- pattern: z7.string().min(1).max(1000).refine((pattern) => linearPattern(pattern) !== undefined, "a pattern Cortex cannot match").optional(),
14878
+ var schemaTypeSchema = z14.enum([...SCALAR_TYPES, "object", "array"]);
14879
+ var propertyNameSchema = z14.string().min(1).max(FIELD_LIMITS.nameLength).refine((name) => name === name.trim(), "no surrounding spaces");
14880
+ var propertyOrderSchema = z14.array(z14.string()).refine((names) => new Set(names).size === names.length, "a name repeats").optional();
14881
+ var countSchema = z14.number().int().min(0).optional();
14882
+ var valueKeywordsSchema = z14.strictObject({
14883
+ pattern: z14.string().min(1).max(1000).refine((pattern) => linearPattern(pattern) !== undefined, "a pattern Cortex cannot match").optional(),
14657
14884
  minLength: countSchema,
14658
14885
  maxLength: countSchema,
14659
- format: z7.string().trim().min(1).max(100).optional(),
14660
- minimum: z7.number().optional(),
14661
- maximum: z7.number().optional(),
14662
- exclusiveMinimum: z7.number().optional(),
14663
- exclusiveMaximum: z7.number().optional(),
14664
- multipleOf: z7.number().positive().optional(),
14886
+ format: z14.string().trim().min(1).max(100).optional(),
14887
+ minimum: z14.number().optional(),
14888
+ maximum: z14.number().optional(),
14889
+ exclusiveMinimum: z14.number().optional(),
14890
+ exclusiveMaximum: z14.number().optional(),
14891
+ multipleOf: z14.number().positive().optional(),
14665
14892
  minItems: countSchema,
14666
14893
  maxItems: countSchema,
14667
- uniqueItems: z7.boolean().optional(),
14668
- const: z7.union([z7.string().max(4000), z7.number(), z7.boolean()]).optional()
14894
+ uniqueItems: z14.boolean().optional(),
14895
+ const: z14.union([z14.string().max(4000), z14.number(), z14.boolean()]).optional()
14669
14896
  });
14670
14897
  var NUMERIC_TYPES = ["number", "integer"];
14671
14898
  var VALUE_KEYWORD_TYPES = {
@@ -14683,18 +14910,18 @@ var VALUE_KEYWORD_TYPES = {
14683
14910
  uniqueItems: ["array"],
14684
14911
  const: SCALAR_TYPES
14685
14912
  };
14686
- var ruleTypeSchema = z7.enum([...SCALAR_TYPES, "object", "array", "null"]);
14687
- var conditionSchema = z7.lazy(() => z7.strictObject({
14688
- type: z7.union([ruleTypeSchema, z7.array(ruleTypeSchema).min(1)]).optional(),
14689
- enum: z7.array(z7.union([z7.string(), z7.number(), z7.boolean(), z7.null()])).min(1).optional(),
14913
+ var ruleTypeSchema = z14.enum([...SCALAR_TYPES, "object", "array", "null"]);
14914
+ var conditionSchema = z14.lazy(() => z14.strictObject({
14915
+ type: z14.union([ruleTypeSchema, z14.array(ruleTypeSchema).min(1)]).optional(),
14916
+ enum: z14.array(z14.union([z14.string(), z14.number(), z14.boolean(), z14.null()])).min(1).optional(),
14690
14917
  ...valueKeywordsSchema.shape,
14691
- required: z7.array(z7.string()).optional(),
14692
- properties: z7.record(z7.string(), conditionSchema).optional(),
14918
+ required: z14.array(z14.string()).optional(),
14919
+ properties: z14.record(z14.string(), conditionSchema).optional(),
14693
14920
  items: conditionSchema.optional(),
14694
14921
  ...objectRulesSchema.shape
14695
14922
  })).meta({ id: "SchemaCondition" });
14696
- var conditionsSchema = z7.array(conditionSchema).min(1).meta({ id: "SchemaConditions" });
14697
- var objectRulesSchema = z7.strictObject({
14923
+ var conditionsSchema = z14.array(conditionSchema).min(1).meta({ id: "SchemaConditions" });
14924
+ var objectRulesSchema = z14.strictObject({
14698
14925
  anyOf: conditionsSchema.optional(),
14699
14926
  oneOf: conditionsSchema.optional(),
14700
14927
  allOf: conditionsSchema.optional(),
@@ -14702,8 +14929,8 @@ var objectRulesSchema = z7.strictObject({
14702
14929
  if: conditionSchema.optional(),
14703
14930
  then: conditionSchema.optional(),
14704
14931
  else: conditionSchema.optional(),
14705
- dependentRequired: z7.record(z7.string(), z7.array(z7.string())).optional(),
14706
- dependentSchemas: z7.record(z7.string(), conditionSchema).optional(),
14932
+ dependentRequired: z14.record(z14.string(), z14.array(z14.string())).optional(),
14933
+ dependentSchemas: z14.record(z14.string(), conditionSchema).optional(),
14707
14934
  minProperties: countSchema,
14708
14935
  maxProperties: countSchema
14709
14936
  });
@@ -14740,26 +14967,27 @@ function ruleNames(rule) {
14740
14967
  ...Object.keys(keyed(node.dependentSchemas))
14741
14968
  ]).filter((name) => typeof name === "string");
14742
14969
  }
14743
- var itemTypeSchema = z7.enum([...SCALAR_TYPES, "object"]);
14744
- var enumSchema = z7.array(z7.union([z7.string().trim().min(1), z7.null()])).min(1).max(FIELD_LIMITS.enumValues + 1).optional();
14745
- var itemsSchema = z7.lazy(() => z7.strictObject({
14746
- type: z7.union([itemTypeSchema, z7.tuple([itemTypeSchema, z7.literal("null")])]),
14970
+ var itemTypeSchema = z14.enum([...SCALAR_TYPES, "object"]);
14971
+ var enumSchema = z14.array(z14.union([z14.string().trim().min(1), z14.null()])).min(1).max(FIELD_LIMITS.enumValues + 1).optional();
14972
+ var itemsSchema = z14.lazy(() => z14.strictObject({
14973
+ type: z14.union([itemTypeSchema, z14.tuple([itemTypeSchema, z14.literal("null")])]),
14747
14974
  enum: enumSchema,
14748
- properties: z7.record(propertyNameSchema, schemaPropertySchema).optional(),
14749
- required: z7.array(z7.string()).optional(),
14975
+ properties: z14.record(propertyNameSchema, schemaPropertySchema).optional(),
14976
+ required: z14.array(z14.string()).optional(),
14750
14977
  "x-order": propertyOrderSchema,
14751
14978
  ...valueKeywordsSchema.shape,
14752
14979
  ...objectRulesSchema.shape
14753
14980
  }));
14754
- var schemaPropertySchema = z7.lazy(() => z7.strictObject({
14755
- type: z7.union([schemaTypeSchema, z7.tuple([schemaTypeSchema, z7.literal("null")])]),
14756
- description: z7.string().trim().max(FIELD_LIMITS.descriptionLength).optional(),
14981
+ var schemaPropertySchema = z14.lazy(() => z14.strictObject({
14982
+ type: z14.union([schemaTypeSchema, z14.tuple([schemaTypeSchema, z14.literal("null")])]),
14983
+ description: z14.string().trim().max(FIELD_LIMITS.descriptionLength).optional(),
14757
14984
  enum: enumSchema,
14758
- properties: z7.record(propertyNameSchema, schemaPropertySchema).optional(),
14759
- required: z7.array(z7.string()).optional(),
14985
+ properties: z14.record(propertyNameSchema, schemaPropertySchema).optional(),
14986
+ required: z14.array(z14.string()).optional(),
14760
14987
  "x-order": propertyOrderSchema,
14761
14988
  items: itemsSchema.optional(),
14762
- "x-sensitive": z7.boolean().optional(),
14989
+ "x-sensitive": z14.boolean().optional(),
14990
+ "x-displayName": displayNameSchema.optional(),
14763
14991
  "x-source": fieldSourceSchema.optional(),
14764
14992
  "x-target": fieldTargetSchema.optional(),
14765
14993
  ...valueKeywordsSchema.shape,
@@ -14867,10 +15095,10 @@ function heldByRows(node, context, path, bindings) {
14867
15095
  }
14868
15096
  }
14869
15097
  function objectJsonSchemaOf(bindings) {
14870
- return z7.strictObject({
14871
- type: z7.literal("object"),
14872
- properties: z7.record(propertyNameSchema, schemaPropertySchema).optional(),
14873
- required: z7.array(z7.string()).optional(),
15098
+ return z14.strictObject({
15099
+ type: z14.literal("object"),
15100
+ properties: z14.record(propertyNameSchema, schemaPropertySchema).optional(),
15101
+ required: z14.array(z14.string()).optional(),
14874
15102
  "x-order": propertyOrderSchema,
14875
15103
  ...objectRulesSchema.shape
14876
15104
  }).superRefine((schema, context) => {
@@ -14890,23 +15118,85 @@ function objectJsonSchemaOf(bindings) {
14890
15118
  }
14891
15119
  var objectSchema = objectJsonSchemaOf();
14892
15120
  var EMPTY_OBJECT = { type: "object" };
14893
- var audienceSchema = z7.union([
14894
- z7.literal("all"),
14895
- z7.strictObject({ server: nameSchema }),
14896
- z7.strictObject({
14897
- agents: z7.array(nameSchema).min(1).refine((names) => new Set(names).size === names.length, "an agent repeats")
14898
- })
14899
- ]);
14900
- var MODEL_PROVIDER_LIMITS = { urlLength: 2048, modelLength: 200, models: 100 };
14901
- var modelSchema = z7.strictObject({
14902
- provider: nameSchema,
14903
- model: z7.string().trim().min(1).max(MODEL_PROVIDER_LIMITS.modelLength),
14904
- effort: z7.string().trim().min(1).max(64).optional()
14905
- });
14906
- var SERVICE_LIMITS = { descriptionLength: 4000 };
14907
- var localizedTextSchema = z7.record(localeSchema, z7.string().trim().min(1).max(SERVICE_LIMITS.descriptionLength));
14908
- var { tool: toolBounds } = SETTING_BOUNDS;
14909
- var { tool: toolRateLimits, datasetHost: datasetHostRateLimits } = RATE_LIMITS;
15121
+
15122
+ // ../../internal/contracts/src/manifest/tools.ts
15123
+ var toolTagsSchema = z15.array(z15.string().trim().min(1).max(60).regex(/^[^,]*$/, "a tag holds no comma")).max(20);
15124
+ var embedOriginSchema = tlsUrlSchema.transform((value) => new URL(value).origin);
15125
+ var soapActionSchema = z15.string().regex(/^[^"\\\u0000-\u001f\u007f]*$/);
15126
+ var envelopeTemplateSchema = z15.string().refine((template) => template.trim().length > 0);
15127
+ var toolConfigByType = {
15128
+ http: z15.object({
15129
+ responseWrap: z15.enum(RESPONSE_WRAPS).optional(),
15130
+ requestMediaType: z15.enum(FORM_MEDIA_TYPES).optional(),
15131
+ resultPath: jsonPointerSchema.optional()
15132
+ }),
15133
+ embedded: z15.object({ embedOrigin: embedOriginSchema, surface: z15.enum(TOOL_SURFACES) }),
15134
+ soap: z15.object({
15135
+ soapVersion: z15.enum(SOAP_VERSIONS),
15136
+ soapAction: soapActionSchema,
15137
+ envelopeTemplate: envelopeTemplateSchema,
15138
+ tokenCall: z15.object({
15139
+ envelopeTemplate: envelopeTemplateSchema,
15140
+ soapAction: soapActionSchema,
15141
+ tokenPath: z15.string().trim().min(1)
15142
+ }).optional()
15143
+ }),
15144
+ native: z15.object({}),
15145
+ client: z15.object({})
15146
+ };
15147
+ var TOOL_TYPES = {
15148
+ http: {
15149
+ kind: "server",
15150
+ calls: true,
15151
+ approval: true,
15152
+ sources: true,
15153
+ targets: true,
15154
+ creatable: true
15155
+ },
15156
+ embedded: {
15157
+ kind: "client",
15158
+ calls: true,
15159
+ approval: false,
15160
+ sources: true,
15161
+ targets: false,
15162
+ creatable: true,
15163
+ readOnly: false
15164
+ },
15165
+ soap: {
15166
+ kind: "server",
15167
+ calls: true,
15168
+ approval: true,
15169
+ sources: true,
15170
+ targets: true,
15171
+ creatable: true,
15172
+ method: "POST"
15173
+ },
15174
+ native: {
15175
+ kind: "server",
15176
+ calls: true,
15177
+ approval: true,
15178
+ sources: false,
15179
+ targets: false,
15180
+ creatable: false,
15181
+ method: "POST"
15182
+ },
15183
+ client: {
15184
+ kind: "client",
15185
+ calls: false,
15186
+ approval: false,
15187
+ sources: false,
15188
+ targets: false,
15189
+ creatable: true,
15190
+ readOnly: true
15191
+ }
15192
+ };
15193
+ var CREATABLE_TOOL_TYPES = TOOL_TYPE_NAMES.filter((type) => TOOL_TYPES[type].creatable);
15194
+ function confinesEndpointParams(url) {
15195
+ const origin = /^[^:/?#]*:[/\\]*[^/\\?#]*/.exec(url)?.[0] ?? "";
15196
+ const hash = url.indexOf("#", origin.length);
15197
+ const fragment = hash < 0 ? "" : url.slice(hash);
15198
+ return ![origin, fragment].some((part) => part.match(ENDPOINT_PARAM_PATTERN));
15199
+ }
14910
15200
  function toolInputSchemaOf(type) {
14911
15201
  const { sources, targets } = TOOL_TYPES[type];
14912
15202
  return objectJsonSchemaOf([
@@ -14924,23 +15214,25 @@ var TOOL_OVERRIDABLES = [
14924
15214
  "tags"
14925
15215
  ];
14926
15216
  var CALLED_TOOL_OVERRIDABLES = [...TOOL_OVERRIDABLES, "headers"];
14927
- var toolBaseSchema = z7.strictObject({
15217
+ var { tool: toolBounds } = SETTING_BOUNDS;
15218
+ var { tool: toolRateLimits } = RATE_LIMITS;
15219
+ var toolBaseSchema = z15.strictObject({
14928
15220
  ...serverToolSchema.pick({ name: true, description: true }).shape,
14929
15221
  displayName: displayNameSchema.default({}),
14930
15222
  inputSchema: toolInputSchemaOf("client"),
14931
15223
  outputSchema: objectSchema.default(EMPTY_OBJECT),
14932
15224
  timeoutMs: setting(toolBounds.timeoutMs),
14933
15225
  maxResponseBytes: setting(toolBounds.maxResponseBytes),
14934
- rateLimits: z7.strictObject({
14935
- allUsers: z7.strictObject({
15226
+ rateLimits: z15.strictObject({
15227
+ allUsers: z15.strictObject({
14936
15228
  callsPerMinute: rateLimit(toolRateLimits.callsPerMinute, "allUsers")
14937
15229
  }).prefault({}),
14938
- perUser: z7.strictObject({
15230
+ perUser: z15.strictObject({
14939
15231
  callsPerMinute: rateLimit(toolRateLimits.callsPerMinute, "perUser")
14940
15232
  }).prefault({})
14941
15233
  }).prefault({}),
14942
- projectOutput: z7.boolean().default(false),
14943
- pinned: z7.boolean().default(false),
15234
+ projectOutput: z15.boolean().default(false),
15235
+ pinned: z15.boolean().default(false),
14944
15236
  tags: toolTagsSchema.default([]),
14945
15237
  audience: audienceSchema,
14946
15238
  overridable: overridable(TOOL_OVERRIDABLES)
@@ -14948,68 +15240,88 @@ var toolBaseSchema = z7.strictObject({
14948
15240
  var calledToolSchema = toolBaseSchema.extend({
14949
15241
  url: upstreamUrlSchema.refine(confinesEndpointParams, "a {parameter} outside the path or query"),
14950
15242
  headers: headersSchema,
14951
- requiresApproval: z7.boolean().default(false),
15243
+ requiresApproval: z15.boolean().default(false),
14952
15244
  overridable: overridable(CALLED_TOOL_OVERRIDABLES)
14953
15245
  });
14954
- var manifestToolSchema = z7.discriminatedUnion("type", [
15246
+ var manifestToolSchema = z15.discriminatedUnion("type", [
14955
15247
  calledToolSchema.extend({
14956
- type: z7.literal("http"),
15248
+ type: z15.literal("http"),
14957
15249
  inputSchema: toolInputSchemaOf("http"),
14958
- method: z7.enum(TOOL_METHODS),
14959
- readOnly: z7.boolean(),
15250
+ method: z15.enum(TOOL_METHODS),
15251
+ readOnly: z15.boolean(),
14960
15252
  ...toolConfigByType.http.shape
14961
15253
  }),
14962
15254
  calledToolSchema.omit({ requiresApproval: true }).extend({
14963
- type: z7.literal("embedded"),
15255
+ type: z15.literal("embedded"),
14964
15256
  inputSchema: toolInputSchemaOf("embedded"),
14965
- method: z7.enum(TOOL_METHODS),
15257
+ method: z15.enum(TOOL_METHODS),
14966
15258
  ...toolConfigByType.embedded.shape
14967
15259
  }),
14968
15260
  calledToolSchema.extend({
14969
- type: z7.literal("soap"),
15261
+ type: z15.literal("soap"),
14970
15262
  inputSchema: toolInputSchemaOf("soap"),
14971
- readOnly: z7.boolean(),
15263
+ readOnly: z15.boolean(),
14972
15264
  ...toolConfigByType.soap.shape
14973
15265
  }),
14974
- toolBaseSchema.extend({ type: z7.literal("client") })
15266
+ toolBaseSchema.extend({ type: z15.literal("client") })
14975
15267
  ]).superRefine((tool, context) => refuseBlockedApprovalTitle(tool, context, []));
14976
- var toolNamesSchema = z7.array(serverToolSchema.shape.name).max(500).default([]);
14977
- var manifestOpenApiSchema = z7.strictObject({
15268
+ var toolNamesSchema = z15.array(serverToolSchema.shape.name).max(500).default([]);
15269
+ var manifestOpenApiSchema = z15.strictObject({
14978
15270
  name: nameSchema,
14979
15271
  url: upstreamUrlSchema,
14980
15272
  headers: headersSchema,
14981
15273
  resultPath: jsonPointerSchema.optional(),
14982
15274
  pinned: toolNamesSchema,
14983
- approval: z7.strictObject({ never: toolNamesSchema, always: toolNamesSchema }).prefault({}).refine(({ never, always }) => !never.some((name) => always.includes(name)), "a tool both never and always needs approval"),
15275
+ approval: z15.strictObject({ never: toolNamesSchema, always: toolNamesSchema }).prefault({}).refine(({ never, always }) => !never.some((name) => always.includes(name)), "a tool both never and always needs approval"),
14984
15276
  audience: audienceSchema,
14985
15277
  overridable: overridable(CALLED_TOOL_OVERRIDABLES)
14986
15278
  });
14987
- var manifestServiceSchema = z7.strictObject({
14988
- name: nameSchema,
14989
- displayName: displayNameSchema.default({}),
14990
- description: localizedTextSchema,
14991
- audience: audienceSchema,
14992
- overridable: overridable(["displayName", "description"])
14993
- });
14994
- var SKILL_LIMITS = { descriptionLength: 500 };
14995
- var manifestSkillSchema = z7.strictObject({
14996
- name: nameSchema,
14997
- displayName: displayNameSchema.default({}),
14998
- description: z7.string().trim().min(1).max(SKILL_LIMITS.descriptionLength),
14999
- body: z7.string().trim().min(1),
15000
- service: nameSchema.optional(),
15001
- audience: audienceSchema,
15002
- overridable: overridable(["displayName", "description", "body"])
15279
+
15280
+ // ../../internal/contracts/src/manifest/triggers.ts
15281
+ import { z as z17 } from "zod";
15282
+
15283
+ // ../../internal/contracts/src/schedule/index.ts
15284
+ var import_cron_parser = __toESM(require_dist(), 1);
15285
+ import { z as z16 } from "zod";
15286
+ function isTimeZone(timeZone) {
15287
+ try {
15288
+ new Intl.DateTimeFormat("en", { timeZone });
15289
+ return true;
15290
+ } catch {
15291
+ return false;
15292
+ }
15293
+ }
15294
+ function isCron(cron) {
15295
+ if (cron.split(/\s+/).length !== 5 || /\bH\b/i.test(cron))
15296
+ return false;
15297
+ try {
15298
+ import_cron_parser.CronExpressionParser.parse(cron);
15299
+ return true;
15300
+ } catch {
15301
+ return false;
15302
+ }
15303
+ }
15304
+ function triggerScheduleSchemaWith(messages) {
15305
+ return z16.object({
15306
+ cron: z16.string().trim().refine(isCron, { error: messages.cron }),
15307
+ timeZone: z16.string().trim().refine(isTimeZone, { error: messages.timeZone })
15308
+ });
15309
+ }
15310
+ var triggerScheduleSchema = triggerScheduleSchemaWith({
15311
+ cron: () => "is not a cron of five fields: minute, hour, day of month, month, day of week",
15312
+ timeZone: () => "is not an IANA time zone, such as Asia/Dubai"
15003
15313
  });
15004
- var triggerThreadPolicySchema = z7.discriminatedUnion("policy", [
15005
- z7.object({ policy: z7.literal("single") }),
15006
- z7.object({ policy: z7.literal("per-input") }),
15007
- z7.object({ policy: z7.literal("ephemeral") }),
15008
- z7.object({ policy: z7.literal("keyed"), key: jsonPointerSchema }),
15009
- z7.object({
15010
- policy: z7.literal("thread"),
15314
+
15315
+ // ../../internal/contracts/src/manifest/triggers.ts
15316
+ var triggerThreadPolicySchema = z17.discriminatedUnion("policy", [
15317
+ z17.object({ policy: z17.literal("single") }),
15318
+ z17.object({ policy: z17.literal("per-input") }),
15319
+ z17.object({ policy: z17.literal("ephemeral") }),
15320
+ z17.object({ policy: z17.literal("keyed"), key: jsonPointerSchema }),
15321
+ z17.object({
15322
+ policy: z17.literal("thread"),
15011
15323
  key: jsonPointerSchema,
15012
- wake: z7.boolean()
15324
+ wake: z17.boolean()
15013
15325
  })
15014
15326
  ]);
15015
15327
  function threadFromPayload(policy) {
@@ -15024,17 +15336,16 @@ function scheduledTriggerIssues(trigger) {
15024
15336
  threadFromPayload(trigger.threadPolicy) && "threadPolicy"
15025
15337
  ].filter((issue) => issue !== false);
15026
15338
  }
15027
- var TRIGGER_LIMITS = { descriptionLength: 500, instructionsLength: 20000 };
15028
- var manifestTriggerSchema = z7.strictObject({
15339
+ var manifestTriggerSchema = z17.strictObject({
15029
15340
  name: nameSchema,
15030
15341
  displayName: displayNameSchema.default({}),
15031
- description: z7.string().trim().min(1).max(TRIGGER_LIMITS.descriptionLength),
15342
+ description: z17.string().trim().min(1).max(TRIGGER_LIMITS.descriptionLength),
15032
15343
  inputSchema: objectSchema.default(EMPTY_OBJECT),
15033
15344
  outputSchema: objectSchema.refine((schema) => Object.keys(schema.properties ?? {}).length > 0, "declares a property; leave it out for a free-text answer").optional(),
15034
- instructions: z7.string().trim().min(1).max(TRIGGER_LIMITS.instructionsLength),
15345
+ instructions: z17.string().trim().min(1).max(TRIGGER_LIMITS.instructionsLength),
15035
15346
  threadPolicy: triggerThreadPolicySchema.default({ policy: "single" }),
15036
- whileBusy: z7.enum(WHILE_BUSY).default("queue"),
15037
- budgetPerDay: z7.number().int().positive().optional(),
15347
+ whileBusy: z17.enum(WHILE_BUSY).default("queue"),
15348
+ budgetPerDay: z17.number().int().positive().optional(),
15038
15349
  disableAfterFailures: setting(SETTING_BOUNDS.trigger.disableAfterFailures),
15039
15350
  credential: nameSchema.optional(),
15040
15351
  fireCredential: nameSchema.optional(),
@@ -15074,286 +15385,26 @@ var manifestTriggerSchema = z7.strictObject({
15074
15385
  context.addIssue({ code: "custom", path: [path], message });
15075
15386
  }
15076
15387
  });
15077
- function unexposedPins(host) {
15078
- const exposed = new Set(host.expose);
15079
- return host.pinned.filter((name) => !exposed.has(name));
15080
- }
15081
- var manifestDatasetHostSchema = z7.strictObject({
15082
- name: datasetIdentifierSchema,
15083
- displayName: displayNameSchema.default({}),
15084
- url: upstreamUrlSchema,
15085
- headers: headersSchema,
15086
- timeoutMs: setting(SETTING_BOUNDS.datasetHost.timeoutMs),
15087
- rateLimits: z7.strictObject({
15088
- allUsers: z7.strictObject({
15089
- queriesPerMinute: rateLimit(datasetHostRateLimits.queriesPerMinute, "allUsers")
15090
- }).prefault({}),
15091
- perUser: z7.strictObject({
15092
- queriesPerMinute: rateLimit(datasetHostRateLimits.queriesPerMinute, "perUser")
15093
- }).prefault({})
15094
- }).prefault({}),
15095
- expose: z7.array(datasetIdentifierSchema).min(1).max(500),
15096
- pinned: z7.array(datasetIdentifierSchema).max(50).default([]),
15097
- audience: audienceSchema,
15098
- overridable: overridable(["displayName", "timeoutMs", "rateLimits", "headers"])
15099
- }).superRefine((host, context) => {
15100
- const unexposed = unexposedPins(host);
15101
- if (unexposed.length > 0) {
15102
- context.addIssue({
15103
- code: "custom",
15104
- path: ["pinned"],
15105
- message: `not exposed: ${unexposed.join(", ")}`
15106
- });
15107
- }
15108
- });
15109
- var mcpToolNamesSchema = z7.array(z7.string().trim().min(1).max(128).regex(/^[^,]*$/, "a tool name holds no comma")).max(200);
15110
- var MCP_CONNECTION_OWNERS = ["shared", "endUser"];
15111
- var mcpSignInSchema = z7.strictObject({
15112
- connects: z7.enum(MCP_CONNECTION_OWNERS),
15113
- scope: z7.string().trim().min(1).max(1000).optional(),
15114
- credential: nameSchema.optional()
15115
- });
15116
- function authorizationBesideSignIn(server) {
15117
- return server.signIn ? server.headers.findIndex((entry) => entry.header.toLowerCase() === "authorization") : -1;
15118
- }
15119
- var manifestMcpServerSchema = z7.strictObject({
15120
- name: identifierSchema,
15121
- displayName: displayNameSchema.default({}),
15122
- url: upstreamUrlSchema,
15123
- headers: declaredHeadersSchema(presentedHeaderSchema.refine((name) => !mcpTransportHeaders.has(name.toLowerCase()), "a header the MCP transport sets"), headerSourceSchema),
15124
- signIn: mcpSignInSchema.optional(),
15125
- include: mcpToolNamesSchema.default([]),
15126
- exclude: mcpToolNamesSchema.default([]),
15127
- audience: audienceSchema,
15128
- overridable: overridable(["displayName", "include", "exclude", "headers", "signIn"])
15129
- }).superRefine((server, context) => {
15130
- const index = authorizationBesideSignIn(server);
15131
- if (index >= 0) {
15132
- context.addIssue({
15133
- code: "custom",
15134
- path: ["headers", index, "header"],
15135
- message: "the sign-in's token travels under Authorization"
15136
- });
15137
- }
15138
- });
15139
- var manifestWebhookSchema = z7.strictObject({
15388
+
15389
+ // ../../internal/contracts/src/manifest/webhooks.ts
15390
+ import { z as z18 } from "zod";
15391
+ var manifestWebhookSchema = z18.strictObject({
15140
15392
  name: nameSchema,
15141
15393
  displayName: displayNameSchema.default({}),
15142
- description: z7.string().trim().max(500).default(""),
15143
- event: z7.enum(SERVER_EVENTS),
15394
+ description: z18.string().trim().max(500).default(""),
15395
+ event: z18.enum(SERVER_EVENTS),
15144
15396
  url: upstreamUrlSchema,
15145
15397
  headers: declaredHeadersSchema(presentedHeaderSchema.refine((name) => name.toLowerCase() !== EVENT_HEADER.toLowerCase(), "the header that names the event"), runlessHeaderSourceSchema),
15146
15398
  timeoutMs: setting(SETTING_BOUNDS.webhook.timeoutMs),
15147
15399
  audience: audienceSchema,
15148
15400
  overridable: overridable(["displayName", "description", "timeoutMs", "headers"])
15149
15401
  });
15150
- var COLLECTION_LIMITS = { descriptionLength: 2000, documents: 100 };
15151
- var DOCUMENT_LIMITS = { nameLength: 255, bytes: 10 * 1024 * 1024 };
15152
- var DOCX_MIME_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
15153
- var mimeTypeByExtension = new Map([
15154
- ["md", "text/markdown"],
15155
- ["txt", "text/plain"],
15156
- ["html", "text/html"],
15157
- ["htm", "text/html"],
15158
- ["pdf", "application/pdf"],
15159
- ["docx", DOCX_MIME_TYPE]
15160
- ]);
15161
- function documentType(name) {
15162
- const dot = name.lastIndexOf(".");
15163
- return dot === -1 ? undefined : mimeTypeByExtension.get(name.slice(dot + 1).toLowerCase());
15164
- }
15165
- function base64Bytes(data) {
15166
- const padding = data.endsWith("==") ? 2 : data.endsWith("=") ? 1 : 0;
15167
- return data.length / 4 * 3 - padding;
15168
- }
15169
- var documentNameSchema = z7.string().trim().min(1).max(DOCUMENT_LIMITS.nameLength);
15170
- var textDocumentSchema = z7.strictObject({
15171
- name: documentNameSchema,
15172
- text: z7.string().min(1).refine((text) => new TextEncoder().encode(text).byteLength <= DOCUMENT_LIMITS.bytes, `larger than ${DOCUMENT_LIMITS.bytes} bytes`)
15173
- });
15174
- var pathDocumentSchema = z7.strictObject({
15175
- path: z7.string().trim().min(1),
15176
- name: documentNameSchema.optional()
15177
- });
15178
- var urlDocumentSchema = z7.strictObject({
15179
- url: upstreamUrlSchema,
15180
- name: documentNameSchema.optional()
15181
- });
15182
- var dataDocumentSchema = z7.strictObject({
15183
- name: documentNameSchema,
15184
- data: z7.base64().refine((data) => base64Bytes(data) <= DOCUMENT_LIMITS.bytes, `larger than ${DOCUMENT_LIMITS.bytes} bytes`)
15185
- });
15186
- function documentName(document) {
15187
- if (document.name !== undefined)
15188
- return document.name;
15189
- if (document.path !== undefined)
15190
- return document.path.split(/[/\\]/).pop() ?? "";
15191
- const segment = new URL(document.url ?? "", "https://x").pathname.split("/").pop() ?? "";
15192
- try {
15193
- return decodeURIComponent(segment);
15194
- } catch {
15195
- return segment;
15196
- }
15197
- }
15198
- function documentsSchema(document) {
15199
- return z7.array(document).max(COLLECTION_LIMITS.documents).superRefine((documents, ctx) => {
15200
- const names = documents.map(documentName);
15201
- names.forEach((name, index) => {
15202
- if (documentType(name) === undefined) {
15203
- ctx.addIssue({
15204
- code: "custom",
15205
- path: [index, "name"],
15206
- message: "a document's name ends in .md, .txt, .html, .htm, .pdf or .docx"
15207
- });
15208
- } else if (names.indexOf(name) !== index) {
15209
- ctx.addIssue({
15210
- code: "custom",
15211
- path: [index, "name"],
15212
- message: "a name repeats"
15213
- });
15214
- }
15215
- });
15216
- }).default([]);
15217
- }
15218
- function collectionSchema(document) {
15219
- return z7.strictObject({
15220
- name: nameSchema,
15221
- displayName: displayNameSchema.default({}),
15222
- description: z7.string().trim().max(COLLECTION_LIMITS.descriptionLength).default(""),
15223
- service: nameSchema.optional(),
15224
- citable: z7.boolean().default(true),
15225
- documents: documentsSchema(document),
15226
- audience: audienceSchema,
15227
- overridable: overridable(["displayName", "description", "documents"])
15228
- });
15229
- }
15230
- var manifestDocumentSchema = z7.union([textDocumentSchema, pathDocumentSchema, urlDocumentSchema]);
15231
- var manifestCollectionSchema = collectionSchema(manifestDocumentSchema);
15232
- var resolvedCollectionSchema = collectionSchema(z7.union([textDocumentSchema, dataDocumentSchema, urlDocumentSchema]));
15233
- var AUTH_JWT_SECRET_ALGORITHMS = ["HS256", "HS384", "HS512"];
15234
- var issuerSchema = z7.string().trim().min(1).max(2048);
15235
- var tokenAudienceSchema = z7.string().trim().min(1).max(2048).optional();
15236
- var agentAuthSchema = z7.discriminatedUnion("kind", [
15237
- z7.strictObject({
15238
- kind: z7.literal("jwks"),
15239
- jwksUri: tlsUrlSchema,
15240
- issuer: issuerSchema,
15241
- audience: tokenAudienceSchema
15242
- }),
15243
- z7.strictObject({
15244
- kind: z7.literal("jwt-secret"),
15245
- secret: nameSchema,
15246
- algorithm: z7.enum(AUTH_JWT_SECRET_ALGORITHMS),
15247
- issuer: issuerSchema,
15248
- audience: tokenAudienceSchema
15249
- }),
15250
- z7.strictObject({
15251
- kind: z7.literal("anonymous"),
15252
- recaptcha: z7.strictObject({
15253
- siteKey: z7.string().trim().min(1).max(200),
15254
- projectId: z7.string().trim().min(1).max(200),
15255
- secret: nameSchema,
15256
- minScore: z7.number().min(SETTING_BOUNDS.recaptcha.minScore.min).max(SETTING_BOUNDS.recaptcha.minScore.max).default(SETTING_BOUNDS.recaptcha.minScore.default)
15257
- }).optional()
15258
- }),
15259
- z7.strictObject({ kind: z7.literal("server") })
15260
- ]);
15261
- var { agentContext, agentLimits } = SETTING_BOUNDS;
15262
- var { agent: agentRateLimits } = RATE_LIMITS;
15263
- var agentSettingsSchema = z7.strictObject({
15264
- ragEnabled: z7.boolean().default(false),
15265
- toolRegistryEnabled: z7.boolean().default(false),
15266
- serviceRegistryEnabled: z7.boolean().default(false),
15267
- subagentsEnabled: z7.boolean().default(false),
15268
- checkBacksEnabled: z7.boolean().default(false),
15269
- attachmentsEnabled: z7.boolean().default(true),
15270
- fetchImageHostnames: z7.array(z7.string().max(253).regex(HOSTNAME_PATTERN)).max(FETCH_IMAGE_HOSTS_LIMIT).default([]),
15271
- locationPicker: z7.boolean().default(false),
15272
- media: z7.array(z7.enum(MEDIA_FORMS)).default([...DEFAULT_MEDIA_FORMS]),
15273
- messages: z7.boolean().default(true),
15274
- whileBusy: z7.enum(WHILE_BUSY).default("refuse"),
15275
- a2a: z7.boolean().default(false),
15276
- a2aPushHostnames: z7.array(z7.string().max(253).regex(HOSTNAME_PATTERN)).max(A2A_PUSH_HOSTS_LIMIT).default([]),
15277
- description: z7.string().trim().max(1000).default(""),
15278
- defaultLocale: localeSchema.default(BASE_LOCALE),
15279
- context: z7.strictObject({
15280
- maxContextTokens: setting(agentContext.maxContextTokens),
15281
- summarizationThreshold: z7.number().min(agentContext.summarizationThreshold.min).max(agentContext.summarizationThreshold.max).default(agentContext.summarizationThreshold.default),
15282
- toolResultMaxTokens: setting(agentContext.toolResultMaxTokens),
15283
- recentMessagesToKeep: setting(agentContext.recentMessagesToKeep)
15284
- }).prefault({}),
15285
- limits: z7.strictObject({
15286
- resolveTokenBudget: setting(agentLimits.resolveTokenBudget),
15287
- executeTimeoutMs: setting(agentLimits.executeTimeoutMs),
15288
- maxResponseBytes: setting(agentLimits.maxResponseBytes)
15289
- }).prefault({})
15290
- });
15291
- var manifestAgentSchema = z7.strictObject({
15292
- name: nameSchema,
15293
- displayName: displayNameSchema.default({}),
15294
- server: nameSchema.optional(),
15295
- prompt: z7.string().trim().min(1),
15296
- auth: agentAuthSchema,
15297
- models: z7.strictObject({
15298
- chat: modelSchema.optional(),
15299
- vision: modelSchema.omit({ effort: true }).optional(),
15300
- summarization: modelSchema.omit({ effort: true }).optional()
15301
- }).default({}),
15302
- settings: agentSettingsSchema.prefault({}),
15303
- rateLimits: z7.strictObject({
15304
- allUsers: z7.strictObject({
15305
- messagesPerMinute: rateLimit(agentRateLimits.messagesPerMinute, "allUsers"),
15306
- tokensPerDay: rateLimit(agentRateLimits.tokensPerDay, "allUsers")
15307
- }).prefault({}),
15308
- perUser: z7.strictObject({
15309
- messagesPerMinute: rateLimit(agentRateLimits.messagesPerMinute, "perUser"),
15310
- tokensPerDay: rateLimit(agentRateLimits.tokensPerDay, "perUser")
15311
- }).prefault({})
15312
- }).prefault({}),
15313
- suggestions: suggestionsSchema.default(() => byLocale(() => [])),
15314
- greeting: greetingSchema.default(() => byLocale(() => "")),
15315
- overridable: overridable([
15316
- "displayName",
15317
- "prompt",
15318
- "models",
15319
- "settings",
15320
- "rateLimits",
15321
- "suggestions",
15322
- "greeting"
15323
- ])
15324
- }).superRefine((agent, context) => {
15325
- if (agent.server !== undefined)
15326
- return;
15327
- if (agent.auth.kind === "server") {
15328
- context.addIssue({
15329
- code: "custom",
15330
- path: ["auth"],
15331
- message: "server auth needs a server"
15332
- });
15333
- }
15334
- if (agent.models.chat === undefined) {
15335
- context.addIssue({
15336
- code: "custom",
15337
- path: ["models", "chat"],
15338
- message: "an agent with no server names its own chat model"
15339
- });
15340
- }
15341
- });
15342
- var MANIFEST_KINDS = [
15343
- "agents",
15344
- "services",
15345
- "tools",
15346
- "skills",
15347
- "triggers",
15348
- "datasetHosts",
15349
- "mcpServers",
15350
- "webhooks",
15351
- "collections"
15352
- ];
15402
+
15403
+ // ../../internal/contracts/src/manifest/manifest.ts
15353
15404
  function listOf(entry) {
15354
- return z7.array(entry).refine((entries) => new Set(entries.map((value) => value.name)).size === entries.length, "a name repeats").default([]);
15405
+ return z19.array(entry).refine((entries) => new Set(entries.map((value) => value.name)).size === entries.length, "a name repeats").default([]);
15355
15406
  }
15356
- var manifestSchema = z7.strictObject({
15407
+ var manifestSchema = z19.strictObject({
15357
15408
  id: nameSchema,
15358
15409
  agents: listOf(manifestAgentSchema),
15359
15410
  tools: listOf(manifestToolSchema),
@@ -15369,29 +15420,29 @@ var manifestSchema = z7.strictObject({
15369
15420
  var resolvedManifestSchema = manifestSchema.extend({
15370
15421
  collections: listOf(resolvedCollectionSchema)
15371
15422
  });
15372
- var manifestKindSchema = z7.enum(MANIFEST_KINDS);
15373
- var namesByKindSchema = z7.record(manifestKindSchema, z7.array(z7.string()));
15374
- var manifestChangesSchema = z7.object({
15423
+ var manifestKindSchema = z19.enum(MANIFEST_KINDS);
15424
+ var namesByKindSchema = z19.record(manifestKindSchema, z19.array(z19.string()));
15425
+ var manifestChangesSchema = z19.object({
15375
15426
  create: namesByKindSchema,
15376
15427
  update: namesByKindSchema,
15377
15428
  delete: namesByKindSchema
15378
15429
  });
15379
- var manifestConflictSchema = z7.strictObject({
15430
+ var manifestConflictSchema = z19.strictObject({
15380
15431
  kind: manifestKindSchema,
15381
- name: z7.string(),
15382
- field: z7.string(),
15383
- key: z7.string().optional()
15432
+ name: z19.string(),
15433
+ field: z19.string(),
15434
+ key: z19.string().optional()
15384
15435
  });
15385
- var conflictSideSchema = z7.enum(["live", "manifest"]);
15436
+ var conflictSideSchema = z19.enum(["live", "manifest"]);
15386
15437
  var manifestApplyInputSchema = resolvedManifestSchema.extend({
15387
15438
  prefer: conflictSideSchema.optional(),
15388
- resolutions: z7.array(manifestConflictSchema.extend({ keep: conflictSideSchema })).default([])
15439
+ resolutions: z19.array(manifestConflictSchema.extend({ keep: conflictSideSchema })).default([])
15389
15440
  });
15390
15441
  var manifestPreviewSchema = manifestChangesSchema.extend({
15391
- conflicts: z7.array(manifestConflictSchema)
15442
+ conflicts: z19.array(manifestConflictSchema)
15392
15443
  });
15393
15444
  var appliedManifestSchema = manifestChangesSchema.extend({
15394
- triggerSecrets: z7.record(z7.string(), z7.string())
15445
+ triggerSecrets: z19.record(z19.string(), z19.string())
15395
15446
  });
15396
15447
  function defineManifest(manifest) {
15397
15448
  return manifest;