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