@constal/sdk 3.10.0 → 4.0.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/publish/index.js CHANGED
@@ -222,7 +222,7 @@ function validatePartitionSpec(spec) {
222
222
  return;
223
223
  }
224
224
  if ("key" in spec) {
225
- if (typeof spec.key !== "string" || spec.key.length === 0 || !positiveSafeInteger(spec.buckets) || spec.buckets > 1024) {
225
+ if (typeof spec.key !== "string" || spec.key.length === 0 || !positiveSafeInteger(spec.buckets)) {
226
226
  throw new TypeError("partition.key requires a non-empty field and 1..1024 buckets");
227
227
  }
228
228
  return;
@@ -292,7 +292,7 @@ function analyticsEvent(definition) {
292
292
  if (RESERVED.has(definition.id.split(/[.-]/u)[0])) throw new TypeError("analytics event id uses a reserved namespace");
293
293
  if (typeof definition.version !== "string" || !VERSION.test(definition.version)) throw new TypeError("analytics event version is invalid");
294
294
  for (const [kind, fields] of [["dimensions", definition.dimensions], ["metrics", definition.metrics]]) {
295
- if (!Array.isArray(fields) || fields.length > 16 || fields.some((field2) => typeof field2 !== "string" || !FIELD_ID.test(field2))) throw new TypeError(`analytics event ${kind} are invalid`);
295
+ if (!Array.isArray(fields) || fields.some((field2) => typeof field2 !== "string" || !FIELD_ID.test(field2))) throw new TypeError(`analytics event ${kind} are invalid`);
296
296
  if (new Set(fields).size !== fields.length) throw new TypeError(`analytics event ${kind} must be unique`);
297
297
  }
298
298
  const metricNames = new Set(definition.metrics);
@@ -338,7 +338,6 @@ var TYPES = /* @__PURE__ */ new Set(["null", "boolean", "object", "array", "numb
338
338
  function validateJsonSchemaDefinition(schema, path = "$schema", depth = 0) {
339
339
  if (schema === true || schema === false) return null;
340
340
  if (!schema || typeof schema !== "object" || Array.isArray(schema)) return `${path} must be an object or boolean schema`;
341
- if (depth > 32) return `${path} exceeds the schema depth limit`;
342
341
  const rule = schema;
343
342
  const unknown = Object.keys(rule).find((key) => !KEYWORDS.has(key) && !key.startsWith("x-"));
344
343
  if (unknown) return `${path}.${unknown} is not supported`;
@@ -371,7 +370,7 @@ function validateJsonSchemaDefinition(schema, path = "$schema", depth = 0) {
371
370
  if (error) return error;
372
371
  }
373
372
  if (rule.anyOf !== void 0) {
374
- if (!Array.isArray(rule.anyOf) || rule.anyOf.length === 0 || rule.anyOf.length > 32) return `${path}.anyOf is invalid`;
373
+ if (!Array.isArray(rule.anyOf) || rule.anyOf.length === 0) return `${path}.anyOf is invalid`;
375
374
  for (const [index, child] of rule.anyOf.entries()) {
376
375
  const error = validateJsonSchemaDefinition(child, `${path}.anyOf[${index}]`, depth + 1);
377
376
  if (error) return error;
@@ -451,9 +450,6 @@ var RESOURCE_IDENTITY_LABELS = {
451
450
  kind: "constal.ai/kind",
452
451
  version: "constal.ai/version"
453
452
  };
454
- var MAX_LABELS = 64;
455
- var MAX_EXPRESSIONS = 64;
456
- var MAX_VALUES = 64;
457
453
  var NAME = /^[A-Za-z0-9](?:[-_.A-Za-z0-9]{0,61}[A-Za-z0-9])?$/u;
458
454
  var DNS_LABEL = /^[a-z0-9](?:[-a-z0-9]{0,61}[a-z0-9])?$/u;
459
455
  function record(value) {
@@ -476,7 +472,7 @@ function selectorValue(key, value) {
476
472
  }
477
473
  function resourceLabelMap(value, options = {}) {
478
474
  const source = record(value);
479
- if (!source || Object.keys(source).length > MAX_LABELS) throw new TypeError("Resource labels are invalid");
475
+ if (!source) throw new TypeError("Resource labels are invalid");
480
476
  const entries = Object.entries(source);
481
477
  for (const [key, candidate] of entries) {
482
478
  if (!labelKey(key) || !(options.allowProtected ? selectorValue(key, candidate) : labelValue(candidate)) || !options.allowProtected && key.startsWith(PROTECTED_RESOURCE_LABEL_PREFIX)) throw new TypeError(`Resource label ${key || "<empty>"} is invalid`);
@@ -490,7 +486,7 @@ function labelSelector(value) {
490
486
  }
491
487
  const matchLabels = source.matchLabels === void 0 ? {} : resourceLabelMap(source.matchLabels, { allowProtected: true });
492
488
  const rawExpressions = source.matchExpressions === void 0 ? [] : source.matchExpressions;
493
- if (!Array.isArray(rawExpressions) || rawExpressions.length > MAX_EXPRESSIONS) throw new TypeError("Label selector expressions are invalid");
489
+ if (!Array.isArray(rawExpressions)) throw new TypeError("Label selector expressions are invalid");
494
490
  const matchExpressions = rawExpressions.map((raw, index) => {
495
491
  const expression = record(raw);
496
492
  const operator = expression?.operator;
@@ -499,7 +495,7 @@ function labelSelector(value) {
499
495
  throw new TypeError(`Label selector expression ${index} is invalid`);
500
496
  }
501
497
  if (operator === "In" || operator === "NotIn") {
502
- if (!Array.isArray(values) || values.length === 0 || values.length > MAX_VALUES || values.some((item) => !selectorValue(expression.key, item))) {
498
+ if (!Array.isArray(values) || values.length === 0 || values.some((item) => !selectorValue(expression.key, item))) {
503
499
  throw new TypeError(`Label selector expression ${index} values are invalid`);
504
500
  }
505
501
  return { key: expression.key, operator, values: [...new Set(values)].sort() };
@@ -600,10 +596,10 @@ function resolveBindingOwner(scope2, context, required2 = true) {
600
596
  return scope2 === "principal" ? { kind: "principal", principal: name } : { kind: "customer", customer: name };
601
597
  }
602
598
  function agentSetupRequirements(value, options = {}) {
603
- if (!Array.isArray(value) || value.length < 1 || value.length > 64) throw new TypeError("Agent setup requirements are invalid");
599
+ if (!Array.isArray(value) || value.length < 1) throw new TypeError("Agent setup requirements are invalid");
604
600
  const requirements = value.map((raw) => {
605
601
  const item = record2(raw);
606
- if (!item || typeof item.id !== "string" || !NAME2.test(item.id) || typeof item.title !== "string" || !item.title.trim() || item.title.length > 128 || item.description !== void 0 && (typeof item.description !== "string" || item.description.length > 4096) || item.optional !== void 0 && typeof item.optional !== "boolean" || Object.keys(item).some((key) => !["id", "title", "description", "optional", "resourceKind", "selector", "binding"].includes(key))) {
602
+ if (!item || typeof item.id !== "string" || !NAME2.test(item.id) || typeof item.title !== "string" || !item.title.trim() || item.description !== void 0 && typeof item.description !== "string" || item.optional !== void 0 && typeof item.optional !== "boolean" || Object.keys(item).some((key) => !["id", "title", "description", "optional", "resourceKind", "selector", "binding"].includes(key))) {
607
603
  throw new TypeError("Agent setup requirement is invalid");
608
604
  }
609
605
  const selection = resourceSelector({ resourceKind: item.resourceKind, selector: item.selector === void 0 ? {} : item.selector }, RESOURCE_KINDS);
@@ -668,9 +664,9 @@ function agentUiDeclaration(value) {
668
664
  if (!source) agentUiInvalid("expected an object");
669
665
  agentUiKeys(source, ["id", "displayName", "description", "source", "channel", "access", "execution", "limits", "labels"]);
670
666
  if (typeof source.id !== "string" || !AGENT_UI_ID.test(source.id)) agentUiInvalid("id");
671
- if (typeof source.displayName !== "string" || !source.displayName.trim() || source.displayName.length > 128) agentUiInvalid("displayName");
667
+ if (typeof source.displayName !== "string" || !source.displayName.trim()) agentUiInvalid("displayName");
672
668
  const description = source.description ?? "";
673
- if (typeof description !== "string" || description.length > 1024) agentUiInvalid("description");
669
+ if (typeof description !== "string") agentUiInvalid("description");
674
670
  const directory = source.source;
675
671
  if (typeof directory !== "string" || !directory || directory.length > 128 || directory.startsWith("/") || directory.includes("\\") || directory.split("/").some((part) => part === "" || part === "." || part === "..")) agentUiInvalid("source");
676
672
  if (AGENT_UI_RESERVED_SOURCE_ROOTS.includes(directory.split("/")[0])) agentUiInvalid("source is a reserved directory");
@@ -742,14 +738,14 @@ function channelTarget(value) {
742
738
  return { resourceKind: "channel", subscriptions: { provider: subscriptions.provider } };
743
739
  }
744
740
  var UI_RESOURCE_BOUNDS = Object.freeze({
745
- maximumRequestBodyBytes: 1048576,
746
- maximumResponseBodyBytes: 16777216,
747
- maximumCpuMs: 3e4,
748
- maximumSubrequests: 100,
749
- maximumDatabaseBytes: 1073741824,
750
- maximumRowsReadPerRequest: 1e6,
751
- maximumRowsWrittenPerRequest: 1e5,
752
- maximumSqlResultBytes: 1048576
741
+ maximumRequestBodyBytes: Number.MAX_SAFE_INTEGER,
742
+ maximumResponseBodyBytes: Number.MAX_SAFE_INTEGER,
743
+ maximumCpuMs: Number.MAX_SAFE_INTEGER,
744
+ maximumSubrequests: Number.MAX_SAFE_INTEGER,
745
+ maximumDatabaseBytes: Number.MAX_SAFE_INTEGER,
746
+ maximumRowsReadPerRequest: Number.MAX_SAFE_INTEGER,
747
+ maximumRowsWrittenPerRequest: Number.MAX_SAFE_INTEGER,
748
+ maximumSqlResultBytes: Number.MAX_SAFE_INTEGER
753
749
  });
754
750
  var ACTION_PATTERN = /^[a-z][a-z0-9-]{0,63}:[a-z][a-z0-9-]{0,63}$/u;
755
751
  var SEGMENT = /^[a-z0-9][a-z0-9._-]{0,127}$/u;
@@ -891,7 +887,7 @@ function resourceCredentialBinding(value) {
891
887
  function invocationCredentialUses(value) {
892
888
  if (value === void 0) return {};
893
889
  const source = record2(value);
894
- if (!source || Object.keys(source).length > 64) throw new TypeError("invocation Credential selections are invalid");
890
+ if (!source) throw new TypeError("invocation Credential selections are invalid");
895
891
  const result = {};
896
892
  for (const [slot, raw] of Object.entries(source).sort(([left], [right]) => left.localeCompare(right))) {
897
893
  const use = record2(raw), consumer = record2(use?.consumer);
@@ -1048,7 +1044,7 @@ function modelAdvertisedPricing(value) {
1048
1044
  return candidate;
1049
1045
  }
1050
1046
  function resourceNeed(need) {
1051
- if (!NAME2.test(need.binding) || !RESOURCE_KIND_SET.has(need.kind) || need.ops !== void 0 && (!Array.isArray(need.ops) || need.ops.length === 0 || need.ops.length > 256 || need.ops.some((op) => !OPERATION.test(op)))) throw new TypeError("resource need is invalid");
1047
+ if (!NAME2.test(need.binding) || !RESOURCE_KIND_SET.has(need.kind) || need.ops !== void 0 && (!Array.isArray(need.ops) || need.ops.length === 0 || need.ops.some((op) => !OPERATION.test(op)))) throw new TypeError("resource need is invalid");
1052
1048
  return need;
1053
1049
  }
1054
1050
  function ipv4(value) {
@@ -1075,7 +1071,7 @@ var RESERVED_IPV4 = [
1075
1071
  [ipv4("240.0.0.0"), 4]
1076
1072
  ];
1077
1073
  function normalizeCidrs(values, allowPrivate) {
1078
- if (!Array.isArray(values) || values.length === 0 || values.length > 10) throw new TypeError("sandbox network CIDRs must contain 1 to 10 entries");
1074
+ if (!Array.isArray(values) || values.length === 0) throw new TypeError("sandbox network CIDRs must contain at least one entry");
1079
1075
  const entries = values.map((raw) => {
1080
1076
  if (typeof raw !== "string") throw new TypeError("sandbox network CIDR is invalid");
1081
1077
  const match = raw.trim().match(/^([^/]+)\/(0|[1-9]|[12][0-9]|3[0-2])$/u);
@@ -1101,7 +1097,7 @@ function normalizeCidrs(values, allowPrivate) {
1101
1097
  return result.map((entry2) => entry2.text);
1102
1098
  }
1103
1099
  function normalizeDomains(values) {
1104
- if (!Array.isArray(values) || values.length === 0 || values.length > 20) throw new TypeError("sandbox network domains must contain 1 to 20 entries");
1100
+ if (!Array.isArray(values) || values.length === 0) throw new TypeError("sandbox network domains must contain at least one entry");
1105
1101
  const domains = values.map((raw) => {
1106
1102
  if (typeof raw !== "string" || raw !== raw.trim() || /[:/?#@]/u.test(raw)) throw new TypeError("sandbox network domain is invalid");
1107
1103
  const wildcard2 = raw.startsWith("*.");
@@ -1256,7 +1252,7 @@ function channel(definition) {
1256
1252
  definition.needs?.forEach(resourceNeed);
1257
1253
  const analytics = definition.analytics ?? [];
1258
1254
  analytics.forEach((event) => analyticsEvent(event));
1259
- if (analytics.length > 64 || new Set(analytics.map((event) => `${event.id}@${event.version}`)).size !== analytics.length) throw new TypeError("channel analytics definitions must be unique and contain at most 64 events");
1255
+ if (new Set(analytics.map((event) => `${event.id}@${event.version}`)).size !== analytics.length) throw new TypeError("channel analytics definitions must be unique");
1260
1256
  return definition;
1261
1257
  }
1262
1258
 
@@ -1443,7 +1439,7 @@ function channelSourceEvidence(value) {
1443
1439
  }
1444
1440
  function credentialEvidence(value) {
1445
1441
  const input = object2(value), provider = object2(input?.provider), claims = object2(input?.claims);
1446
- if (!input || typeof input.credential !== "string" || !provider || typeof provider.crn !== "string" || typeof provider.hash !== "string" || !/^[a-f0-9]{64}$/u.test(provider.hash) || !Number.isSafeInteger(input.version) || Number(input.version) < 1 || input.expiresAt !== null && (!Number.isSafeInteger(input.expiresAt) || Number(input.expiresAt) < 1) || !claims || Object.keys(claims).length > 32 || encoder3.encode(JSON.stringify(claims)).byteLength > 65536 || Object.entries(claims).some(([key, value2]) => !/^[A-Za-z0-9._-]{1,128}$/u.test(key) || !(typeof value2 === "string" && value2.length <= 2048 || typeof value2 === "boolean" || typeof value2 === "number" && Number.isFinite(value2) || Array.isArray(value2) && value2.length <= 500 && value2.every((item) => typeof item === "string" && item.length <= 256)))) {
1442
+ if (!input || typeof input.credential !== "string" || !provider || typeof provider.crn !== "string" || typeof provider.hash !== "string" || !/^[a-f0-9]{64}$/u.test(provider.hash) || !Number.isSafeInteger(input.version) || Number(input.version) < 1 || input.expiresAt !== null && (!Number.isSafeInteger(input.expiresAt) || Number(input.expiresAt) < 1) || !claims || Object.entries(claims).some(([key, value2]) => !/^[A-Za-z0-9._-]{1,128}$/u.test(key) || !(typeof value2 === "string" || typeof value2 === "boolean" || typeof value2 === "number" && Number.isFinite(value2) || Array.isArray(value2) && value2.every((item) => typeof item === "string")))) {
1447
1443
  throw new TypeError("Credential evidence is invalid");
1448
1444
  }
1449
1445
  if (parseResourceName(input.credential).kind !== "credential" || parseResourceName(provider.crn).kind !== "credential-provider") {
@@ -1470,7 +1466,7 @@ function channelSubscriptionRequest(value) {
1470
1466
  throw new TypeError("Channel subscription crosses the authenticated tenant");
1471
1467
  }
1472
1468
  const credentials = input.credentials ?? [];
1473
- if (!Array.isArray(credentials) || credentials.length > 32) throw new TypeError("Channel subscription Credentials are invalid");
1469
+ if (!Array.isArray(credentials)) throw new TypeError("Channel subscription Credentials are invalid");
1474
1470
  const proofs = credentials.map(credentialEvidence);
1475
1471
  for (const proof of proofs) {
1476
1472
  const owner = parseResourceName(proof.credential), provider = parseResourceName(proof.provider.crn);
@@ -1482,39 +1478,38 @@ function channelSubscriptionRequest(value) {
1482
1478
  }
1483
1479
  function channelIngressRequest(value) {
1484
1480
  const input = object2(value), headers = object2(input?.headers);
1485
- if (!input || !["GET", "POST", "PUT", "PATCH", "DELETE"].includes(String(input.method)) || typeof input.url !== "string" || !input.url || input.url.length > 2048 || !headers || Object.keys(headers).length > 128 || Object.entries(headers).some(([key, value2]) => !/^[a-z0-9-]{1,128}$/u.test(key) || typeof value2 !== "string" || value2.length > 8192) || input.bodyBase64 !== null && (typeof input.bodyBase64 !== "string" || input.bodyBase64.length > 5592408) || encoder3.encode(JSON.stringify(input)).byteLength > 6 * 1024 * 1024) throw new TypeError("Channel ingress request is invalid");
1481
+ if (!input || !["GET", "POST", "PUT", "PATCH", "DELETE"].includes(String(input.method)) || typeof input.url !== "string" || !input.url || input.url.length > 2048 || !headers || Object.entries(headers).some(([key, value2]) => !/^[a-z0-9-]{1,128}$/u.test(key) || typeof value2 !== "string" || value2.length > 8192) || input.bodyBase64 !== null && (typeof input.bodyBase64 !== "string" || input.bodyBase64.length > 5592408) || encoder3.encode(JSON.stringify(input)).byteLength > 6 * 1024 * 1024) throw new TypeError("Channel ingress request is invalid");
1486
1482
  return { method: input.method, url: input.url, headers, bodyBase64: input.bodyBase64 };
1487
1483
  }
1488
1484
 
1489
1485
  // packages/sdk/src/setup-workflow.ts
1490
1486
  var ID = /^[a-z0-9][a-z0-9-]{0,62}$/u;
1491
- var MAX_SCREEN_BYTES = 262144;
1492
1487
  function record3(value) {
1493
1488
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
1494
1489
  }
1495
- function text(value, maximum, allowEmpty = false) {
1496
- return typeof value === "string" && value.length <= maximum && (allowEmpty || value.trim().length > 0) ? value : null;
1490
+ function text(value, allowEmpty = false) {
1491
+ return typeof value === "string" && (allowEmpty || value.trim().length > 0) ? value : null;
1497
1492
  }
1498
1493
  function exact(value, fields) {
1499
1494
  return Object.keys(value).every((key) => fields.includes(key));
1500
1495
  }
1501
1496
  function action2(value) {
1502
1497
  const source = record3(value);
1503
- const id2 = text(source?.id, 63);
1504
- const label = text(source?.label, 128);
1498
+ const id2 = text(source?.id);
1499
+ const label = text(source?.label);
1505
1500
  if (!source || !id2 || !ID.test(id2) || !label || !["primary", "secondary", "danger"].includes(String(source.intent)) || !exact(source, ["id", "label", "intent"])) return null;
1506
1501
  return { id: id2, label, intent: source.intent };
1507
1502
  }
1508
1503
  function actions(value) {
1509
- if (!Array.isArray(value) || value.length > 8) return null;
1504
+ if (!Array.isArray(value)) return null;
1510
1505
  const parsed = value.map(action2);
1511
1506
  if (parsed.some((item) => !item) || new Set(parsed.map((item) => item.id)).size !== parsed.length) return null;
1512
1507
  return parsed;
1513
1508
  }
1514
1509
  function panelBase(source) {
1515
- const id2 = text(source.id, 63);
1516
- const title = text(source.title, 256);
1517
- const description = text(source.description, 4096, true);
1510
+ const id2 = text(source.id);
1511
+ const title = text(source.title);
1512
+ const description = text(source.description, true);
1518
1513
  const parsedActions = actions(source.actions);
1519
1514
  return id2 && ID.test(id2) && title && description !== null && parsedActions ? { id: id2, title, description, actions: parsedActions } : null;
1520
1515
  }
@@ -1526,12 +1521,12 @@ function panel(value) {
1526
1521
  if (source.kind === "form") {
1527
1522
  const schema = record3(source.schema);
1528
1523
  const initialValues = source.initialValues === void 0 ? void 0 : record3(source.initialValues);
1529
- if (!schema || validateJsonSchemaDefinition(schema, "$setup.current.schema") || schema.type !== "object" || schema.additionalProperties !== false || Object.keys(record3(schema.properties) ?? {}).length > 64 || initialValues === null || initialValues && validateJsonSchema(initialValues, schema) || !exact(source, ["kind", "id", "title", "description", "actions", "schema", "initialValues"])) return null;
1524
+ if (!schema || validateJsonSchemaDefinition(schema, "$setup.current.schema") || schema.type !== "object" || schema.additionalProperties !== false || initialValues === null || initialValues && validateJsonSchema(initialValues, schema) || !exact(source, ["kind", "id", "title", "description", "actions", "schema", "initialValues"])) return null;
1530
1525
  return { ...base, kind: "form", schema, ...initialValues ? { initialValues } : {} };
1531
1526
  }
1532
1527
  if (source.kind === "credential-interaction") {
1533
- const provider = text(source.provider, 1024);
1534
- const credentialId = text(source.credentialId, 63);
1528
+ const provider = text(source.provider);
1529
+ const credentialId = text(source.credentialId);
1535
1530
  if (!provider || !credentialId || !ID.test(credentialId) || !["connect", "reauthorize", "manage"].includes(String(source.operation)) || source.receipt !== void 0 && !["reference", "evidence"].includes(String(source.receipt)) || source.receipt !== void 0 && base.actions.filter((action3) => action3.intent === "primary").length !== 1 || (source.selection !== void 0 || source.configuration !== void 0) && source.receipt === void 0 || source.configuration !== void 0 && !record3(source.configuration) || !exact(source, ["kind", "id", "title", "description", "actions", "provider", "credentialId", "operation", "receipt", "selection", "configuration"])) return null;
1536
1531
  if (setupPanelProviderIsCrn(provider)) {
1537
1532
  try {
@@ -1569,18 +1564,18 @@ function panel(value) {
1569
1564
  };
1570
1565
  }
1571
1566
  if (source.kind === "review") {
1572
- if (!Array.isArray(source.sections) || source.sections.length > 32 || !exact(source, ["kind", "id", "title", "description", "actions", "sections"])) return null;
1567
+ if (!Array.isArray(source.sections) || !exact(source, ["kind", "id", "title", "description", "actions", "sections"])) return null;
1573
1568
  const sections = [];
1574
1569
  for (const rawSection of source.sections) {
1575
1570
  const section = record3(rawSection);
1576
- const id2 = text(section?.id, 63);
1577
- const title = text(section?.title, 256);
1578
- if (!section || !id2 || !ID.test(id2) || !title || !Array.isArray(section.rows) || section.rows.length > 64 || !exact(section, ["id", "title", "rows"])) return null;
1571
+ const id2 = text(section?.id);
1572
+ const title = text(section?.title);
1573
+ if (!section || !id2 || !ID.test(id2) || !title || !Array.isArray(section.rows) || !exact(section, ["id", "title", "rows"])) return null;
1579
1574
  const rows = [];
1580
1575
  for (const rawRow of section.rows) {
1581
1576
  const row = record3(rawRow);
1582
- const label = text(row?.label, 256);
1583
- const rowValue = text(row?.value, 8192, true);
1577
+ const label = text(row?.label);
1578
+ const rowValue = text(row?.value, true);
1584
1579
  if (!row || !label || rowValue === null || row.tone !== void 0 && !["default", "muted", "warning"].includes(String(row.tone)) || !exact(row, ["label", "value", "tone"])) return null;
1585
1580
  rows.push({ label, value: rowValue, ...row.tone ? { tone: row.tone } : {} });
1586
1581
  }
@@ -1589,27 +1584,27 @@ function panel(value) {
1589
1584
  return { ...base, kind: "review", sections };
1590
1585
  }
1591
1586
  if (source.kind === "progress") {
1592
- if (!Array.isArray(source.progress) || source.progress.length > 64 || !exact(source, ["kind", "id", "title", "description", "actions", "progress"])) return null;
1587
+ if (!Array.isArray(source.progress) || !exact(source, ["kind", "id", "title", "description", "actions", "progress"])) return null;
1593
1588
  const progress = [];
1594
1589
  for (const rawItem of source.progress) {
1595
1590
  const item = record3(rawItem);
1596
- const id2 = text(item?.id, 63);
1597
- const label = text(item?.label, 256);
1598
- const detail = item?.detail === void 0 ? void 0 : text(item.detail, 4096, true);
1591
+ const id2 = text(item?.id);
1592
+ const label = text(item?.label);
1593
+ const detail = item?.detail === void 0 ? void 0 : text(item.detail, true);
1599
1594
  if (!item || !id2 || !ID.test(id2) || !label || detail === null || !["pending", "running", "complete", "failed"].includes(String(item.status)) || !exact(item, ["id", "label", "status", "detail"])) return null;
1600
1595
  progress.push({ id: id2, label, status: item.status, ...detail === void 0 ? {} : { detail } });
1601
1596
  }
1602
1597
  return { ...base, kind: "progress", progress };
1603
1598
  }
1604
1599
  if (source.kind === "complete" || source.kind === "blocked") {
1605
- const summary = text(source.summary, 8192);
1600
+ const summary = text(source.summary);
1606
1601
  const details = source.details === void 0 ? [] : source.details;
1607
- if (!summary || !Array.isArray(details) || details.length > 64 || !exact(source, ["kind", "id", "title", "description", "actions", "summary", "details"])) return null;
1602
+ if (!summary || !Array.isArray(details) || !exact(source, ["kind", "id", "title", "description", "actions", "summary", "details"])) return null;
1608
1603
  const parsedDetails = [];
1609
1604
  for (const rawDetail of details) {
1610
1605
  const detail = record3(rawDetail);
1611
- const label = text(detail?.label, 256);
1612
- const detailValue = text(detail?.value, 8192, true);
1606
+ const label = text(detail?.label);
1607
+ const detailValue = text(detail?.value, true);
1613
1608
  if (!detail || !label || detailValue === null || !exact(detail, ["label", "value"])) return null;
1614
1609
  parsedDetails.push({ label, value: detailValue });
1615
1610
  }
@@ -1624,14 +1619,14 @@ function setupScreen(value) {
1624
1619
  const source = record3(value);
1625
1620
  const workflow = record3(source?.workflow);
1626
1621
  const current = panel(source?.current);
1627
- if (!source || source.object !== "constal.setup.screen" || source.version !== 1 || !workflow || !current || !ID.test(String(workflow.id ?? "")) || !text(workflow.version, 64) || !ID.test(String(workflow.targetAgent ?? "")) || !Number.isSafeInteger(source.revision) || Number(source.revision) < 1 || !["active", "blocked", "complete", "cancelled"].includes(String(source.status)) || !text(source.title, 256) || text(source.description, 4096, true) === null || !Array.isArray(source.steps) || source.steps.length < 1 || source.steps.length > 64 || source.waitLabel !== null && !text(source.waitLabel, 256) || !exact(workflow, ["id", "version", "targetAgent"]) || !exact(source, ["object", "version", "workflow", "revision", "status", "title", "description", "steps", "current", "waitLabel"])) {
1622
+ if (!source || source.object !== "constal.setup.screen" || source.version !== 1 || !workflow || !current || !ID.test(String(workflow.id ?? "")) || !text(workflow.version) || !ID.test(String(workflow.targetAgent ?? "")) || !Number.isSafeInteger(source.revision) || Number(source.revision) < 1 || !["active", "blocked", "complete", "cancelled"].includes(String(source.status)) || !text(source.title) || text(source.description, true) === null || !Array.isArray(source.steps) || source.steps.length < 1 || source.waitLabel !== null && !text(source.waitLabel) || !exact(workflow, ["id", "version", "targetAgent"]) || !exact(source, ["object", "version", "workflow", "revision", "status", "title", "description", "steps", "current", "waitLabel"])) {
1628
1623
  throw new TypeError("Setup screen is invalid");
1629
1624
  }
1630
1625
  const parsedSteps = [];
1631
1626
  for (const rawStep of source.steps) {
1632
1627
  const step = record3(rawStep);
1633
- const id2 = text(step?.id, 63);
1634
- const label = text(step?.label, 128);
1628
+ const id2 = text(step?.id);
1629
+ const label = text(step?.label);
1635
1630
  if (!step || !id2 || !ID.test(id2) || !label || !["pending", "current", "complete", "blocked"].includes(String(step.status)) || step.optional !== void 0 && typeof step.optional !== "boolean" || !exact(step, ["id", "label", "status", "optional"])) throw new TypeError("Setup screen step is invalid");
1636
1631
  parsedSteps.push({ id: id2, label, status: step.status, ...step.optional === void 0 ? {} : { optional: step.optional } });
1637
1632
  }
@@ -1648,7 +1643,6 @@ function setupScreen(value) {
1648
1643
  current,
1649
1644
  waitLabel: source.waitLabel === null ? null : String(source.waitLabel)
1650
1645
  };
1651
- if (new TextEncoder().encode(canonicalJson(normalized)).byteLength > MAX_SCREEN_BYTES) throw new TypeError("Setup screen exceeds 256 KiB");
1652
1646
  return normalized;
1653
1647
  }
1654
1648
  function setupSubmission(value, screen) {
@@ -1721,7 +1715,7 @@ function setupAwait(screen) {
1721
1715
  type: "object",
1722
1716
  additionalProperties: false,
1723
1717
  required: ["crn", "hash"],
1724
- properties: { crn: { type: "string", maxLength: 1024 }, hash: hash3 }
1718
+ properties: { crn: { type: "string" }, hash: hash3 }
1725
1719
  };
1726
1720
  const receipt = current.kind === "credential-interaction" && current.receipt !== void 0 ? {
1727
1721
  type: "object",
@@ -1736,21 +1730,21 @@ function setupAwait(screen) {
1736
1730
  additionalProperties: false,
1737
1731
  required: ["credential", "provider", "version", "expiresAt", "claims"],
1738
1732
  properties: {
1739
- credential: { type: "string", maxLength: 1024 },
1733
+ credential: { type: "string" },
1740
1734
  provider: {
1741
1735
  ...reference,
1742
- properties: { crn: setupPanelProviderIsCrn(current.provider) ? { const: current.provider } : { type: "string", maxLength: 1024 }, hash: hash3 }
1736
+ properties: { crn: setupPanelProviderIsCrn(current.provider) ? { const: current.provider } : { type: "string" }, hash: hash3 }
1743
1737
  },
1744
1738
  version: { type: "integer", minimum: 1 },
1745
1739
  expiresAt: { type: ["integer", "null"], minimum: 1 },
1746
- claims: { type: "object", maxProperties: 32 }
1740
+ claims: { type: "object" }
1747
1741
  }
1748
1742
  },
1749
1743
  binding: current.selection ? {
1750
1744
  type: "object",
1751
1745
  additionalProperties: false,
1752
1746
  required: ["crn", "headSeq", "revisionHash"],
1753
- properties: { crn: { type: "string", maxLength: 1024 }, headSeq: { type: "integer", minimum: 1 }, revisionHash: hash3 }
1747
+ properties: { crn: { type: "string" }, headSeq: { type: "integer", minimum: 1 }, revisionHash: hash3 }
1754
1748
  } : { type: "null" }
1755
1749
  }
1756
1750
  } : null;
@@ -1848,10 +1842,10 @@ var CONSTAL_API_OPERATIONS = [
1848
1842
  ];
1849
1843
  var CONSTAL_API_BOUNDS = {
1850
1844
  defaultPageSize: 50,
1851
- maximumPageSize: 200,
1852
- maximumRelationDepth: 3,
1853
- maximumPlanOperations: 64,
1854
- maximumInputBytes: 1048576,
1845
+ maximumPageSize: Number.MAX_SAFE_INTEGER,
1846
+ maximumRelationDepth: Number.MAX_SAFE_INTEGER,
1847
+ maximumPlanOperations: Number.MAX_SAFE_INTEGER,
1848
+ maximumInputBytes: Number.MAX_SAFE_INTEGER,
1855
1849
  planTtlMs: 15 * 6e4
1856
1850
  };
1857
1851
  var CONSTAL_API_QUERY_KINDS = [
@@ -1907,17 +1901,16 @@ var CONSTAL_API_GET_CRN_KINDS = [
1907
1901
  "deployment"
1908
1902
  ];
1909
1903
  var CONSTAL_API_OBJECT_REF_CRN_KINDS = [...CONSTAL_API_GET_CRN_KINDS, "customer"];
1910
- var boundedNameSchema = { type: "string", minLength: 1, maxLength: 128, pattern: "^[A-Za-z][A-Za-z0-9._-]{0,127}$" };
1904
+ var boundedNameSchema = { type: "string", minLength: 1, pattern: "^[A-Za-z][A-Za-z0-9._-]{0,127}$" };
1911
1905
  var namespaceSchema = {
1912
1906
  type: "string",
1913
1907
  minLength: 1,
1914
- maxLength: 128,
1915
1908
  pattern: "^[a-z0-9][a-z0-9._-]{0,127}$"
1916
1909
  };
1917
1910
  var actionSchema = { type: "string", pattern: ACTION_PATTERN.source };
1918
- var boundedIdSchema = { type: "string", minLength: 1, maxLength: 256, pattern: "^[A-Za-z0-9][A-Za-z0-9._~:-]{0,255}$" };
1911
+ var boundedIdSchema = { type: "string", minLength: 1, pattern: "^[A-Za-z0-9][A-Za-z0-9._~:-]{0,255}$" };
1919
1912
  var hashSchema = { type: "string", pattern: "^[a-f0-9]{64}$" };
1920
- var stringListSchema = { type: "array", maxItems: 128, items: { type: "string", minLength: 1, maxLength: 256 } };
1913
+ var stringListSchema = { type: "array", items: { type: "string", minLength: 1 } };
1921
1914
  var scopeSchema = { description: "Use namespace with an exact namespace allowed by the delegated Run authority. Use tenant only for an explicitly tenant-wide request.", anyOf: [
1922
1915
  {
1923
1916
  type: "object",
@@ -1933,25 +1926,22 @@ var scopeSchema = { description: "Use namespace with an exact namespace allowed
1933
1926
  var crnPattern = (kinds) => `^crn:constal:[a-z0-9][a-z0-9._-]{0,127}:[a-z0-9][a-z0-9._-]{0,127}:[a-z0-9][a-z0-9._-]{0,127}:(?:${kinds.join("|")})/[A-Za-z0-9._~/%-]{1,512}$`;
1934
1927
  var objectRefSchema = { type: "object", additionalProperties: false, properties: {
1935
1928
  kind: { enum: [...CONSTAL_API_GET_KINDS], description: "Exact lower-case object kind returned by a governed platform result." },
1936
- id: { type: "string", minLength: 1, maxLength: 512 },
1929
+ id: { type: "string", minLength: 1 },
1937
1930
  crn: { anyOf: [{ type: "null" }, {
1938
1931
  type: "string",
1939
1932
  minLength: 1,
1940
- maxLength: 2048,
1941
1933
  pattern: crnPattern(CONSTAL_API_OBJECT_REF_CRN_KINDS)
1942
1934
  }] },
1943
1935
  hash: { anyOf: [{ type: "null" }, hashSchema] },
1944
1936
  namespace: {
1945
1937
  type: ["string", "null"],
1946
- maxLength: 128,
1947
1938
  pattern: "^[a-z0-9][a-z0-9._-]{0,127}$"
1948
1939
  },
1949
- version: { type: ["string", "null"], maxLength: 128 }
1940
+ version: { type: ["string", "null"] }
1950
1941
  }, required: ["kind", "id", "namespace"] };
1951
1942
  var exactGetCrnSchema = {
1952
1943
  type: "string",
1953
1944
  minLength: 1,
1954
- maxLength: 2048,
1955
1945
  description: "Exact addressable CRN obtained from governed platform evidence.",
1956
1946
  pattern: crnPattern(CONSTAL_API_GET_CRN_KINDS)
1957
1947
  };
@@ -1962,11 +1952,10 @@ var CONSTAL_API_OPERATION_SCHEMAS = {
1962
1952
  operations: stringListSchema,
1963
1953
  include: {
1964
1954
  type: "array",
1965
- maxItems: 5,
1966
1955
  uniqueItems: true,
1967
1956
  items: { enum: ["objects", "operations", "relations", "schemas", "docs"] }
1968
1957
  },
1969
- cursor: { type: "string", maxLength: 4096 },
1958
+ cursor: { type: "string" },
1970
1959
  limit: { type: "integer", minimum: 1, maximum: CONSTAL_API_BOUNDS.maximumPageSize }
1971
1960
  } },
1972
1961
  query: {
@@ -1978,8 +1967,8 @@ var CONSTAL_API_OPERATION_SCHEMAS = {
1978
1967
  kind: { enum: [...CONSTAL_API_QUERY_KINDS], description: "Exact queryable kind. Never guess a kind or change its casing." },
1979
1968
  scope: scopeSchema,
1980
1969
  filter: { type: "object", description: "Optional catalog-advertised filter expression." },
1981
- search: { type: "string", maxLength: 512 },
1982
- order: { type: "array", maxItems: 8, items: {
1970
+ search: { type: "string" },
1971
+ order: { type: "array", items: {
1983
1972
  type: "object",
1984
1973
  required: ["field", "direction"],
1985
1974
  additionalProperties: false,
@@ -1987,7 +1976,7 @@ var CONSTAL_API_OPERATION_SCHEMAS = {
1987
1976
  } },
1988
1977
  fields: stringListSchema,
1989
1978
  limit: { type: "integer", minimum: 1, maximum: CONSTAL_API_BOUNDS.maximumPageSize },
1990
- cursor: { type: "string", maxLength: 4096 },
1979
+ cursor: { type: "string" },
1991
1980
  asOf: { type: "integer", minimum: 0 },
1992
1981
  range: { type: "object", required: ["start", "end"], additionalProperties: false, properties: {
1993
1982
  start: { type: "integer", minimum: 0 },
@@ -2012,8 +2001,8 @@ var CONSTAL_API_OPERATION_SCHEMAS = {
2012
2001
  },
2013
2002
  fields: stringListSchema,
2014
2003
  page: { type: "object", additionalProperties: false, properties: {
2015
- cursor: { type: "string", maxLength: 4096 },
2016
- limit: { type: "integer", minimum: 1, maximum: 500 }
2004
+ cursor: { type: "string" },
2005
+ limit: { type: "integer", minimum: 1 }
2017
2006
  } }
2018
2007
  }
2019
2008
  },
@@ -2022,35 +2011,33 @@ var CONSTAL_API_OPERATION_SCHEMAS = {
2022
2011
  type: "object",
2023
2012
  required: ["crn"],
2024
2013
  additionalProperties: false,
2025
- properties: { crn: { type: "string", minLength: 1, maxLength: 2048 }, hash: hashSchema }
2014
+ properties: { crn: { type: "string", minLength: 1 }, hash: hashSchema }
2026
2015
  }] },
2027
2016
  direction: { enum: ["outgoing", "incoming", "both"] },
2028
2017
  types: stringListSchema,
2029
2018
  depth: { type: "integer", minimum: 1, maximum: CONSTAL_API_BOUNDS.maximumRelationDepth },
2030
2019
  limit: { type: "integer", minimum: 1, maximum: CONSTAL_API_BOUNDS.maximumPageSize },
2031
- cursor: { type: "string", maxLength: 4096 }
2020
+ cursor: { type: "string" }
2032
2021
  } },
2033
2022
  explainPolicy: { type: "object", required: ["action", "resource"], additionalProperties: false, properties: {
2034
2023
  principal: { anyOf: [
2035
- { type: "string", maxLength: 2048 },
2024
+ { type: "string" },
2036
2025
  { type: "object", required: ["roles", "scopes"], additionalProperties: false, properties: {
2037
- name: { type: "string", maxLength: 2048 },
2026
+ name: { type: "string" },
2038
2027
  roles: {
2039
2028
  type: "array",
2040
- maxItems: 64,
2041
2029
  uniqueItems: true,
2042
- items: { type: "string", minLength: 1, maxLength: 2048 }
2030
+ items: { type: "string", minLength: 1 }
2043
2031
  },
2044
2032
  scopes: {
2045
2033
  type: "array",
2046
- maxItems: 256,
2047
2034
  uniqueItems: true,
2048
2035
  items: { type: "string", pattern: "^(?:\\*|[a-z][a-z0-9-]{0,63}:(?:[a-z][a-z0-9-]{0,63}|\\*))$" }
2049
2036
  }
2050
2037
  } }
2051
2038
  ] },
2052
2039
  action: actionSchema,
2053
- resource: { type: "string", minLength: 1, maxLength: 2048 },
2040
+ resource: { type: "string", minLength: 1 },
2054
2041
  context: { type: "object" },
2055
2042
  arguments: {},
2056
2043
  at: { type: "object", required: ["run"], additionalProperties: false, properties: {
@@ -2060,7 +2047,7 @@ var CONSTAL_API_OPERATION_SCHEMAS = {
2060
2047
  additionalProperties: false,
2061
2048
  properties: {
2062
2049
  namespace: boundedNameSchema,
2063
- agent: { type: "string", minLength: 1, maxLength: 63, pattern: "^[a-z0-9][a-z0-9-]{0,62}$" },
2050
+ agent: { type: "string", minLength: 1, pattern: "^[a-z0-9][a-z0-9-]{0,62}$" },
2064
2051
  session: boundedIdSchema,
2065
2052
  run: boundedIdSchema
2066
2053
  }
@@ -2068,7 +2055,7 @@ var CONSTAL_API_OPERATION_SCHEMAS = {
2068
2055
  } }
2069
2056
  } },
2070
2057
  plan: { type: "object", required: ["objective", "operations"], additionalProperties: false, properties: {
2071
- objective: { type: "string", minLength: 1, maxLength: 8192 },
2058
+ objective: { type: "string", minLength: 1 },
2072
2059
  validateOnly: { type: "boolean" },
2073
2060
  operations: {
2074
2061
  type: "array",
@@ -2077,10 +2064,10 @@ var CONSTAL_API_OPERATION_SCHEMAS = {
2077
2064
  items: { type: "object", required: ["operation", "input"], additionalProperties: false, properties: {
2078
2065
  id: boundedIdSchema,
2079
2066
  operation: boundedNameSchema,
2080
- target: { type: "string", maxLength: 2048 },
2067
+ target: { type: "string" },
2081
2068
  input: {},
2082
2069
  expectedCurrentHash: { anyOf: [{ type: "null" }, hashSchema] },
2083
- dependsOn: { type: "array", maxItems: 64, items: boundedIdSchema }
2070
+ dependsOn: { type: "array", items: boundedIdSchema }
2084
2071
  } }
2085
2072
  }
2086
2073
  } },
@@ -2096,53 +2083,58 @@ var CONSTAL_API_OPERATION_SCHEMAS = {
2096
2083
  observe: { type: "object", required: ["id"], additionalProperties: false, properties: { id: boundedIdSchema } }
2097
2084
  };
2098
2085
 
2099
- // packages/sdk/src/artifact-limits.ts
2100
- var ARTIFACT_MAX_BYTES = 5 * 1024 ** 3;
2101
-
2102
2086
  // packages/sdk/src/sandbox-policy-contract.ts
2103
2087
  var SANDBOX_CONTRACT_REF = {
2104
2088
  id: "constal.sandbox-pool",
2105
2089
  version: "2",
2106
- hash: "69157b4e169275334de93ce0d24ffcdfe982c021ca67499ece3a173db25f4d16"
2090
+ hash: "89c34a8870f861811e6548d8388eddfc2d9b74e642fabeaf37c89f6d21df1c8e"
2107
2091
  };
2108
2092
  var SANDBOX_CONTROLS_SCHEMA = {
2109
2093
  type: "object",
2110
2094
  additionalProperties: false,
2111
2095
  properties: {
2112
- command_timeout_ms: { type: "integer", minimum: 1e3, maximum: 216e5 },
2113
- cpu: { type: "number", exclusiveMinimum: 0, maximum: 64 },
2114
- disk_gib: { type: "number", minimum: 0, maximum: 1024 },
2115
- idle_stop_ms: { type: "integer", minimum: 1e3, maximum: 864e5 },
2116
- max_concurrent_commands: { type: "integer", minimum: 1, maximum: 1024 },
2117
- max_file_bytes: { type: "integer", minimum: 1, maximum: ARTIFACT_MAX_BYTES },
2118
- memory_gib: { type: "number", exclusiveMinimum: 0, maximum: 1024 },
2119
- network_cidrs: { type: "array", minItems: 1, maxItems: 1024, items: { type: "string" } },
2120
- network_domains: { type: "array", minItems: 1, maxItems: 1024, items: { type: "string" } },
2096
+ command_timeout_ms: { type: "integer", minimum: 1 },
2097
+ cpu: { type: "number", exclusiveMinimum: 0 },
2098
+ disk_gib: { type: "number", minimum: 0 },
2099
+ idle_stop_ms: { type: "integer", minimum: 1 },
2100
+ max_concurrent_commands: { type: "integer", minimum: 1 },
2101
+ max_file_bytes: { type: "integer", minimum: 1 },
2102
+ memory_gib: { type: "number", exclusiveMinimum: 0 },
2103
+ network_cidrs: { type: "array", minItems: 1, items: { type: "string" } },
2104
+ network_domains: { type: "array", minItems: 1, items: { type: "string" } },
2121
2105
  network_egress: { type: ["string", "null"] },
2122
2106
  network_mode: { enum: ["block-all", "cidr-allow", "domain-allow", "managed-http", "unrestricted"] },
2123
2107
  network_transport: { enum: [null, "bridge", "proxy"] },
2124
- permitted_paths: { type: "array", minItems: 1, maxItems: 1024, items: { type: "string" } }
2108
+ permitted_paths: { type: "array", minItems: 1, items: { type: "string" } }
2125
2109
  }
2126
2110
  };
2127
2111
 
2128
- // packages/sdk/src/policy-governance.ts
2129
- var SANDBOX_CONTRACT = SANDBOX_CONTRACT_REF;
2130
- var MODEL_CONTRACT = {
2112
+ // packages/sdk/src/model-policy-contract.ts
2113
+ var MODEL_CONTRACT_REF = {
2131
2114
  id: "constal.model",
2132
2115
  version: "1",
2133
- hash: "76dd0da40da46adabb6837f911b25ed6f675c965e5d4d919077ee9c3945fbca7"
2116
+ hash: "5f2d00a0ba630341c15725d26dec7ff31f48724328e21c1264d1f7f7cee048b8"
2117
+ };
2118
+ var MODEL_CONTROLS_SCHEMA = {
2119
+ type: "object",
2120
+ additionalProperties: false,
2121
+ properties: {
2122
+ max_input_tokens: { type: "integer", minimum: 1 },
2123
+ max_output_tokens: { type: "integer", minimum: 1 },
2124
+ temperature_max: { type: "number" }
2125
+ }
2134
2126
  };
2127
+
2128
+ // packages/sdk/src/policy-governance.ts
2129
+ var SANDBOX_CONTRACT = SANDBOX_CONTRACT_REF;
2130
+ var MODEL_CONTRACT = MODEL_CONTRACT_REF;
2135
2131
  var UI_CONTRACT = {
2136
2132
  id: "constal.ui",
2137
2133
  version: "1",
2138
2134
  hash: "133f0ab76ca2f1435dfbaa151652cfc79926ea5237c0892d0c4d3b96d7bb6f48"
2139
2135
  };
2140
2136
  var sandboxSchema = SANDBOX_CONTROLS_SCHEMA;
2141
- var modelSchema = { type: "object", additionalProperties: false, properties: {
2142
- max_input_tokens: { type: "integer", minimum: 1, maximum: 1048576 },
2143
- max_output_tokens: { type: "integer", minimum: 1, maximum: 1048576 },
2144
- temperature_max: { type: "number", minimum: 0, maximum: 2 }
2145
- } };
2137
+ var modelSchema = MODEL_CONTROLS_SCHEMA;
2146
2138
  function controls(contract, values, schema) {
2147
2139
  const error = validateJsonSchema(values, schema);
2148
2140
  if (error) throw new TypeError(`governance controls are invalid: ${error}`);
@@ -2178,17 +2170,14 @@ function validatePolicyGovernanceConstraint(value) {
2178
2170
  }
2179
2171
 
2180
2172
  // packages/sdk/src/authorization.ts
2181
- var MAX_CONSTRAINTS = 64;
2182
- var MAX_OUTCOME_BYTES = 65536;
2183
- var MAX_REASON_BYTES = 1024;
2184
2173
  var DENIAL_CODE = /^[a-z][a-z0-9._-]{0,127}$/u;
2185
2174
  var encoder4 = new TextEncoder();
2186
2175
  function record4(value) {
2187
2176
  return !!value && typeof value === "object" && !Array.isArray(value);
2188
2177
  }
2189
- function requiredString2(value, path, maximum = 1024) {
2190
- if (typeof value !== "string" || value.length === 0 || encoder4.encode(value).byteLength > maximum) {
2191
- throw new TypeError(`${path} must be a bounded non-empty string`);
2178
+ function requiredString2(value, path, _maximum) {
2179
+ if (typeof value !== "string" || value.length === 0) {
2180
+ throw new TypeError(`${path} must be a non-empty string`);
2192
2181
  }
2193
2182
  }
2194
2183
  function exactKeys2(value, allowed, required2, path) {
@@ -2200,7 +2189,7 @@ function scalar(value) {
2200
2189
  return value === null || typeof value === "string" || typeof value === "boolean" || typeof value === "number" && Number.isFinite(value);
2201
2190
  }
2202
2191
  function validateGrant(grant, path) {
2203
- if (!record4(grant) || !Array.isArray(grant.actions) || grant.actions.length === 0 || grant.actions.length > 256 || !Array.isArray(grant.resources) || grant.resources.length === 0 || grant.resources.length > 256 || !Number.isSafeInteger(grant.ttlMs) || grant.ttlMs < 1 || grant.ttlMs > 864e5) {
2192
+ if (!record4(grant) || !Array.isArray(grant.actions) || grant.actions.length === 0 || !Array.isArray(grant.resources) || grant.resources.length === 0 || !Number.isSafeInteger(grant.ttlMs) || grant.ttlMs < 1 || grant.ttlMs > 864e5) {
2204
2193
  throw new TypeError(`${path} is invalid`);
2205
2194
  }
2206
2195
  exactKeys2(grant, ["actions", "resources", "ttlMs"], ["actions", "resources", "ttlMs"], path);
@@ -2227,7 +2216,7 @@ function validatePolicyConstraint(constraint, path = "constraint") {
2227
2216
  }
2228
2217
  if (constraint.kind === "context") {
2229
2218
  exactKeys2(source, ["kind", "equals"], ["kind", "equals"], path);
2230
- if (!record4(constraint.equals) || Object.keys(constraint.equals).length === 0 || Object.keys(constraint.equals).length > 64 || Object.entries(constraint.equals).some(([key, value]) => !key || key.length > 256 || !scalar(value))) {
2219
+ if (!record4(constraint.equals) || Object.keys(constraint.equals).length === 0 || Object.entries(constraint.equals).some(([key, value]) => !key || key.length > 256 || !scalar(value))) {
2231
2220
  throw new TypeError(`${path}.equals is invalid`);
2232
2221
  }
2233
2222
  return;
@@ -2242,7 +2231,7 @@ function validatePolicyConstraint(constraint, path = "constraint") {
2242
2231
  }
2243
2232
  function validateConstraints(value, path, required2) {
2244
2233
  if (value === void 0 && !required2) return [];
2245
- if (!Array.isArray(value) || required2 && value.length === 0 || value.length > MAX_CONSTRAINTS) {
2234
+ if (!Array.isArray(value) || required2 && value.length === 0) {
2246
2235
  throw new TypeError(`${path} is invalid`);
2247
2236
  }
2248
2237
  value.forEach((constraint, index) => validatePolicyConstraint(constraint, `${path}[${index}]`));
@@ -2254,7 +2243,7 @@ function policyOutcome(value) {
2254
2243
  else if (value.kind === "deny") {
2255
2244
  exactKeys2(value, ["kind", "code", "reason"], ["kind", "code"], "Policy deny outcome");
2256
2245
  if (typeof value.code !== "string" || !DENIAL_CODE.test(value.code)) throw new TypeError("Policy denial code is invalid");
2257
- if (value.reason !== void 0) requiredString2(value.reason, "Policy denial reason", MAX_REASON_BYTES);
2246
+ if (value.reason !== void 0) requiredString2(value.reason, "Policy denial reason");
2258
2247
  } else if (value.kind === "constrain") {
2259
2248
  exactKeys2(value, ["kind", "constraints"], ["kind", "constraints"], "Policy constrain outcome");
2260
2249
  validateConstraints(value.constraints, "Policy constraints", true);
@@ -2264,13 +2253,13 @@ function policyOutcome(value) {
2264
2253
  validateConstraints(value.constraints, "Policy constraints", false);
2265
2254
  } else if (value.kind === "require-approval") {
2266
2255
  exactKeys2(value, ["kind", "reason", "constraints"], ["kind"], "Policy approval outcome");
2267
- if (value.reason !== void 0) requiredString2(value.reason, "Policy approval reason", MAX_REASON_BYTES);
2256
+ if (value.reason !== void 0) requiredString2(value.reason, "Policy approval reason");
2268
2257
  validateConstraints(value.constraints, "Policy constraints", false);
2269
2258
  } else if (value.kind === "grant") {
2270
2259
  exactKeys2(value, ["kind", "grant"], ["kind", "grant"], "Policy grant outcome");
2271
2260
  validateGrant(value.grant, "Policy grant");
2272
2261
  } else throw new TypeError("Policy outcome kind is invalid");
2273
- if (encoder4.encode(canonicalJson(value)).byteLength > MAX_OUTCOME_BYTES) throw new TypeError("Policy outcome is oversized");
2262
+ canonicalJson(value);
2274
2263
  return value;
2275
2264
  }
2276
2265
 
@@ -2290,7 +2279,7 @@ var identifier = { type: "string", pattern: "^[a-zA-Z_][a-zA-Z0-9_.-]{0,127}$",
2290
2279
  var tableName = { type: "string", pattern: "^[a-z0-9][a-z0-9._-]{0,127}$", maxLength: 128 };
2291
2280
  var branchName = { type: "string", pattern: "^[a-z0-9][a-z0-9._/-]{0,127}$", maxLength: 128 };
2292
2281
  var hash2 = { type: "string", pattern: "^[a-f0-9]{64}$" };
2293
- var scalar2 = { type: ["string", "number", "integer", "boolean", "null"], maxLength: 4096 };
2282
+ var scalar2 = { type: ["string", "number", "integer", "boolean", "null"] };
2294
2283
  var TABLE_DESCRIBE_SCHEMA = {
2295
2284
  type: "object",
2296
2285
  required: ["table"],
@@ -2300,7 +2289,7 @@ var TABLE_DESCRIBE_SCHEMA = {
2300
2289
  branch: branchName,
2301
2290
  snapshot: hash2,
2302
2291
  stageId: hash2,
2303
- waitMs: { type: "integer", minimum: 0, maximum: 25e3 }
2292
+ waitMs: { type: "integer", minimum: 0 }
2304
2293
  }
2305
2294
  };
2306
2295
  var filterSchema = {
@@ -2310,7 +2299,7 @@ var filterSchema = {
2310
2299
  properties: {
2311
2300
  field: identifier,
2312
2301
  op: { type: "string", enum: ["eq", "ne", "gt", "gte", "lt", "lte", "in", "between"] },
2313
- value: { anyOf: [scalar2, { type: "array", minItems: 1, maxItems: 100, items: scalar2 }] }
2302
+ value: { anyOf: [scalar2, { type: "array", minItems: 1, items: scalar2 }] }
2314
2303
  }
2315
2304
  };
2316
2305
  var TABLE_QUERY_SCHEMA = {
@@ -2325,10 +2314,10 @@ var TABLE_QUERY_SCHEMA = {
2325
2314
  type: "object",
2326
2315
  additionalProperties: false,
2327
2316
  properties: {
2328
- select: { type: "array", maxItems: 64, uniqueItems: true, items: identifier },
2329
- where: { type: "array", maxItems: 32, items: filterSchema },
2330
- groupBy: { type: "array", maxItems: 16, uniqueItems: true, items: identifier },
2331
- aggregates: { type: "array", maxItems: 32, items: {
2317
+ select: { type: "array", uniqueItems: true, items: identifier },
2318
+ where: { type: "array", items: filterSchema },
2319
+ groupBy: { type: "array", uniqueItems: true, items: identifier },
2320
+ aggregates: { type: "array", items: {
2332
2321
  type: "object",
2333
2322
  required: ["fn", "as"],
2334
2323
  additionalProperties: false,
@@ -2338,13 +2327,13 @@ var TABLE_QUERY_SCHEMA = {
2338
2327
  as: identifier
2339
2328
  }
2340
2329
  } },
2341
- orderBy: { type: "array", maxItems: 8, items: {
2330
+ orderBy: { type: "array", items: {
2342
2331
  type: "object",
2343
2332
  required: ["field", "direction"],
2344
2333
  additionalProperties: false,
2345
2334
  properties: { field: identifier, direction: { type: "string", enum: ["asc", "desc"] } }
2346
2335
  } },
2347
- limit: { type: "integer", minimum: 1, maximum: 1e3 }
2336
+ limit: { type: "integer", minimum: 1 }
2348
2337
  }
2349
2338
  }
2350
2339
  }
@@ -2358,7 +2347,7 @@ function validateStageOutputSpec(value, path = "$.output") {
2358
2347
  const schemaError = validateJsonSchemaDefinition(output.schema, `${path}.schema`);
2359
2348
  if (schemaError) return schemaError;
2360
2349
  const sortOrder = output.sortOrder ?? [];
2361
- if (!Array.isArray(sortOrder) || sortOrder.length > 64) return `${path}.sortOrder is invalid`;
2350
+ if (!Array.isArray(sortOrder)) return `${path}.sortOrder is invalid`;
2362
2351
  const keys = /* @__PURE__ */ new Set();
2363
2352
  for (const [index, raw] of sortOrder.entries()) {
2364
2353
  if (!raw || typeof raw !== "object" || Array.isArray(raw)) return `${path}.sortOrder[${index}] is invalid`;
@@ -2479,8 +2468,8 @@ var WEB_FETCH_ARGUMENT_SCHEMA = {
2479
2468
  required: ["url"],
2480
2469
  additionalProperties: false,
2481
2470
  properties: {
2482
- url: { type: "string", minLength: 1, maxLength: 2048 },
2483
- accept: { type: "string", maxLength: 256 }
2471
+ url: { type: "string", minLength: 1 },
2472
+ accept: { type: "string" }
2484
2473
  }
2485
2474
  };
2486
2475
  var WEB_SEARCH_ARGUMENT_SCHEMA = {
@@ -2491,42 +2480,36 @@ var WEB_SEARCH_ARGUMENT_SCHEMA = {
2491
2480
  query: {
2492
2481
  type: "string",
2493
2482
  minLength: 1,
2494
- maxLength: 4096,
2495
2483
  description: "A self-contained description of the information to find."
2496
2484
  },
2497
2485
  searchQueries: {
2498
2486
  type: "array",
2499
2487
  minItems: 1,
2500
- maxItems: 3,
2501
2488
  uniqueItems: true,
2502
2489
  description: "Optional concise keyword queries that narrow the search.",
2503
- items: { type: "string", minLength: 1, maxLength: 256 }
2490
+ items: { type: "string", minLength: 1 }
2504
2491
  },
2505
2492
  maximumResults: {
2506
2493
  type: "integer",
2507
2494
  minimum: 1,
2508
- maximum: 20,
2509
2495
  description: "Maximum number of sources to return."
2510
2496
  },
2511
2497
  maximumCharacters: {
2512
2498
  type: "integer",
2513
- minimum: 1e3,
2514
- maximum: 6e4,
2499
+ minimum: 1,
2515
2500
  description: "Maximum total excerpt characters to return."
2516
2501
  },
2517
2502
  includeDomains: {
2518
2503
  type: "array",
2519
- maxItems: 50,
2520
2504
  uniqueItems: true,
2521
2505
  description: "Optional domains to restrict results to.",
2522
- items: { type: "string", minLength: 1, maxLength: 253 }
2506
+ items: { type: "string", minLength: 1 }
2523
2507
  },
2524
2508
  excludeDomains: {
2525
2509
  type: "array",
2526
- maxItems: 50,
2527
2510
  uniqueItems: true,
2528
2511
  description: "Optional domains to omit.",
2529
- items: { type: "string", minLength: 1, maxLength: 253 }
2512
+ items: { type: "string", minLength: 1 }
2530
2513
  },
2531
2514
  afterDate: {
2532
2515
  type: "string",
@@ -2577,8 +2560,8 @@ var casTool = {
2577
2560
 
2578
2561
  // packages/sdk/src/memory.ts
2579
2562
  var id = { type: "string", pattern: "^[A-Za-z0-9._~-]{1,256}$", maxLength: 256 };
2580
- var content = { type: "string", minLength: 1, maxLength: 65536 };
2581
- var metadata2 = { type: "object", maxProperties: 64 };
2563
+ var content = { type: "string", minLength: 1 };
2564
+ var metadata2 = { type: "object" };
2582
2565
  var scope = { type: "string", pattern: "^[a-f0-9]{64}$", maxLength: 64 };
2583
2566
  var record5 = {
2584
2567
  type: "object",
@@ -2611,13 +2594,13 @@ var MEMORY_OPERATION_DECLARATIONS = [
2611
2594
  type: "object",
2612
2595
  required: ["query"],
2613
2596
  additionalProperties: false,
2614
- properties: { query: { type: "string", minLength: 1, maxLength: 8192 }, limit: { type: "integer", minimum: 1, maximum: 100 }, scope }
2597
+ properties: { query: { type: "string", minLength: 1 }, limit: { type: "integer", minimum: 1 }, scope }
2615
2598
  },
2616
2599
  resultSchema: {
2617
2600
  type: "object",
2618
2601
  required: ["hits"],
2619
2602
  additionalProperties: false,
2620
- properties: { hits: { type: "array", maxItems: 100, items: {
2603
+ properties: { hits: { type: "array", items: {
2621
2604
  ...record5,
2622
2605
  required: [...record5.required, "score"],
2623
2606
  properties: { ...record5.properties, score: { type: "number", minimum: 0, maximum: 1 } }
@@ -2693,13 +2676,13 @@ var TerminalIntegrationFailure = class extends Error {
2693
2676
  var OPERATION3 = /^[A-Za-z][A-Za-z0-9._-]{0,127}$/u;
2694
2677
  function integrationEgressPolicy(value) {
2695
2678
  const source = value && typeof value === "object" && !Array.isArray(value) ? value : null;
2696
- if (!source || !Array.isArray(source.rules) || source.rules.length > 128 || Object.keys(source).some((key) => key !== "rules")) {
2679
+ if (!source || !Array.isArray(source.rules) || Object.keys(source).some((key) => key !== "rules")) {
2697
2680
  throw new TypeError("integration egress policy is invalid");
2698
2681
  }
2699
2682
  const rules = source.rules.map((raw) => {
2700
2683
  const rule = raw && typeof raw === "object" && !Array.isArray(raw) ? raw : null;
2701
2684
  const paths = Number(rule?.pathPrefix !== void 0) + Number(rule?.pathExact !== void 0);
2702
- if (!rule || !Array.isArray(rule.operations) || rule.operations.length === 0 || rule.operations.length > 128 || rule.operations.some((operation) => typeof operation !== "string" || operation !== "*" && !OPERATION3.test(operation)) || typeof rule.origin !== "string" || paths !== 1 || !Array.isArray(rule.methods) || rule.methods.length === 0 || rule.methods.length > 8 || rule.methods.some((method) => typeof method !== "string" || !/^(?:GET|POST|PUT|PATCH|DELETE)$/u.test(method)) || Object.keys(rule).some((key) => !["operations", "origin", "pathPrefix", "pathExact", "methods"].includes(key))) {
2685
+ if (!rule || !Array.isArray(rule.operations) || rule.operations.length === 0 || rule.operations.some((operation) => typeof operation !== "string" || operation !== "*" && !OPERATION3.test(operation)) || typeof rule.origin !== "string" || paths !== 1 || !Array.isArray(rule.methods) || rule.methods.length === 0 || rule.methods.length > 8 || rule.methods.some((method) => typeof method !== "string" || !/^(?:GET|POST|PUT|PATCH|DELETE)$/u.test(method)) || Object.keys(rule).some((key) => !["operations", "origin", "pathPrefix", "pathExact", "methods"].includes(key))) {
2703
2686
  throw new TypeError("integration egress rule is invalid");
2704
2687
  }
2705
2688
  let origin;
@@ -2860,7 +2843,7 @@ function absoluteSandboxPath(value) {
2860
2843
  return `/${segments.join("/")}`;
2861
2844
  }
2862
2845
  function normalizeSandboxWorkspacePath(path, cwd = WORKSPACE_ROOT) {
2863
- if (typeof path !== "string" || !path || typeof cwd !== "string" || !cwd || new TextEncoder().encode(path).byteLength > 4096 || new TextEncoder().encode(cwd).byteLength > 4096 || /[\u0000-\u001f\u007f]/u.test(path) || /[\u0000-\u001f\u007f]/u.test(cwd)) {
2846
+ if (typeof path !== "string" || !path || typeof cwd !== "string" || !cwd || /[\u0000-\u001f\u007f]/u.test(path) || /[\u0000-\u001f\u007f]/u.test(cwd)) {
2864
2847
  throw new TypeError("sandbox workspace path is invalid");
2865
2848
  }
2866
2849
  const base = absoluteSandboxPath(cwd.startsWith("/") ? cwd : `${WORKSPACE_ROOT}/${cwd}`);
@@ -2890,14 +2873,14 @@ var TRAINING_PROVIDER_CAPABILITY = {
2890
2873
  function record6(value) {
2891
2874
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
2892
2875
  }
2893
- function integer(value, field2, minimum, maximum) {
2894
- if (!Number.isSafeInteger(value) || Number(value) < minimum || Number(value) > maximum) {
2876
+ function integer(value, field2, minimum) {
2877
+ if (!Number.isSafeInteger(value) || Number(value) < minimum) {
2895
2878
  throw new TypeError(`${field2} is invalid`);
2896
2879
  }
2897
2880
  return Number(value);
2898
2881
  }
2899
- function finite(value, field2, minimum, maximum) {
2900
- if (typeof value !== "number" || !Number.isFinite(value) || value < minimum || value > maximum) {
2882
+ function finite(value, field2, minimum) {
2883
+ if (typeof value !== "number" || !Number.isFinite(value) || value < minimum) {
2901
2884
  throw new TypeError(`${field2} is invalid`);
2902
2885
  }
2903
2886
  return value;
@@ -2920,7 +2903,7 @@ function resumePoint(value) {
2920
2903
  function trainingProviderMetadata(value) {
2921
2904
  const candidate = record6(value);
2922
2905
  const checkpoints = record6(candidate?.checkpoints);
2923
- if (!candidate || candidate.lifecycleVersion !== 1 || !Array.isArray(candidate.methods) || candidate.methods.length === 0 || candidate.methods.length > 2 || candidate.methods.some((method) => method !== "sft" && method !== "rl") || new Set(candidate.methods).size !== candidate.methods.length || !Array.isArray(candidate.models) || candidate.models.length > 512 || !checkpoints || !Array.isArray(checkpoints.formats) || checkpoints.formats.length === 0 || checkpoints.formats.length > 32 || checkpoints.formats.some((format) => typeof format !== "string" || !/^[a-z0-9][a-z0-9._+-]{0,63}$/u.test(format)) || new Set(checkpoints.formats).size !== checkpoints.formats.length || typeof checkpoints.resume !== "boolean" || typeof checkpoints.fork !== "boolean" || Object.keys(checkpoints).some((key) => !["formats", "resume", "fork"].includes(key)) || Object.keys(candidate).some((key) => !["lifecycleVersion", "methods", "models", "checkpoints"].includes(key))) {
2906
+ if (!candidate || candidate.lifecycleVersion !== 1 || !Array.isArray(candidate.methods) || candidate.methods.length === 0 || candidate.methods.length > 2 || candidate.methods.some((method) => method !== "sft" && method !== "rl") || new Set(candidate.methods).size !== candidate.methods.length || !Array.isArray(candidate.models) || !checkpoints || !Array.isArray(checkpoints.formats) || checkpoints.formats.length === 0 || checkpoints.formats.some((format) => typeof format !== "string" || !/^[a-z0-9][a-z0-9._+-]{0,63}$/u.test(format)) || new Set(checkpoints.formats).size !== checkpoints.formats.length || typeof checkpoints.resume !== "boolean" || typeof checkpoints.fork !== "boolean" || Object.keys(checkpoints).some((key) => !["formats", "resume", "fork"].includes(key)) || Object.keys(candidate).some((key) => !["lifecycleVersion", "methods", "models", "checkpoints"].includes(key))) {
2924
2907
  throw new TypeError("Training Provider metadata is invalid");
2925
2908
  }
2926
2909
  const models = candidate.models.map((raw) => {
@@ -2976,25 +2959,25 @@ function trainingRecipe(value) {
2976
2959
  "maxSampleTokens",
2977
2960
  "budgetMicroUsd"
2978
2961
  ];
2979
- if (!candidate || candidate.method !== "sft" && candidate.method !== "rl" || typeof candidate.baseModel !== "string" || !PROVIDER_MODEL_ID.test(candidate.baseModel) || !Array.isArray(candidate.scorers) || candidate.scorers.length > 32 || candidate.method === "rl" && candidate.scorers.length === 0 || Object.keys(candidate).some((key) => !allowed.includes(key))) throw new TypeError("training recipe is invalid");
2962
+ if (!candidate || candidate.method !== "sft" && candidate.method !== "rl" || typeof candidate.baseModel !== "string" || !PROVIDER_MODEL_ID.test(candidate.baseModel) || !Array.isArray(candidate.scorers) || candidate.method === "rl" && candidate.scorers.length === 0 || Object.keys(candidate).some((key) => !allowed.includes(key))) throw new TypeError("training recipe is invalid");
2980
2963
  const recipe = {
2981
2964
  method: candidate.method,
2982
2965
  baseModel: candidate.baseModel,
2983
2966
  dataset: datasetRef(candidate.dataset, "training dataset"),
2984
2967
  validationDataset: candidate.validationDataset === null ? null : datasetRef(candidate.validationDataset, "validation dataset"),
2985
2968
  scorers: candidate.scorers.map((scorer, index) => scorerRef(scorer, `training scorer ${index}`)),
2986
- loraRank: integer(candidate.loraRank, "LoRA rank", 1, 256),
2987
- learningRate: finite(candidate.learningRate, "learning rate", Number.MIN_VALUE, 1),
2988
- epochs: integer(candidate.epochs, "epochs", 1, 100),
2989
- batchSize: integer(candidate.batchSize, "batch size", 1, 256),
2990
- groupSize: integer(candidate.groupSize, "group size", 1, 32),
2991
- temperature: finite(candidate.temperature, "temperature", 0, 2),
2992
- seed: integer(candidate.seed, "seed", 0, 2147483647),
2993
- checkpointEvery: integer(candidate.checkpointEvery, "checkpoint interval", 1, 1e6),
2994
- evalEvery: integer(candidate.evalEvery, "evaluation interval", 1, 1e6),
2995
- maxTrainTokens: integer(candidate.maxTrainTokens, "training token limit", 1, 1e10),
2996
- maxSampleTokens: integer(candidate.maxSampleTokens, "sample token limit", 1, 1e9),
2997
- budgetMicroUsd: integer(candidate.budgetMicroUsd, "training budget", 1, 1e10)
2969
+ loraRank: integer(candidate.loraRank, "LoRA rank", 1),
2970
+ learningRate: finite(candidate.learningRate, "learning rate", Number.MIN_VALUE),
2971
+ epochs: integer(candidate.epochs, "epochs", 1),
2972
+ batchSize: integer(candidate.batchSize, "batch size", 1),
2973
+ groupSize: integer(candidate.groupSize, "group size", 1),
2974
+ temperature: finite(candidate.temperature, "temperature", 0),
2975
+ seed: integer(candidate.seed, "seed", 0),
2976
+ checkpointEvery: integer(candidate.checkpointEvery, "checkpoint interval", 1),
2977
+ evalEvery: integer(candidate.evalEvery, "evaluation interval", 1),
2978
+ maxTrainTokens: integer(candidate.maxTrainTokens, "training token limit", 1),
2979
+ maxSampleTokens: integer(candidate.maxSampleTokens, "sample token limit", 1),
2980
+ budgetMicroUsd: integer(candidate.budgetMicroUsd, "training budget", 1)
2998
2981
  };
2999
2982
  if (recipe.method === "sft" && recipe.groupSize !== 1) throw new TypeError("SFT group size must be 1");
3000
2983
  return recipe;
@@ -3034,11 +3017,11 @@ var MODEL_EVALUATION_CAPABILITY = {
3034
3017
  };
3035
3018
  function modelGenerationOptions(source) {
3036
3019
  const { maxOutputTokens, temperature, effort } = source;
3037
- if (maxOutputTokens !== void 0 && (!Number.isSafeInteger(maxOutputTokens) || maxOutputTokens < 1 || maxOutputTokens > 1048576)) {
3038
- throw new TypeError("maxOutputTokens must be an integer from 1 to 1048576");
3020
+ if (maxOutputTokens !== void 0 && (!Number.isSafeInteger(maxOutputTokens) || maxOutputTokens < 1)) {
3021
+ throw new TypeError("maxOutputTokens must be a positive safe integer");
3039
3022
  }
3040
- if (temperature !== void 0 && (typeof temperature !== "number" || !Number.isFinite(temperature) || temperature < 0 || temperature > 2)) {
3041
- throw new TypeError("temperature must be a finite number from 0 to 2");
3023
+ if (temperature !== void 0 && (typeof temperature !== "number" || !Number.isFinite(temperature))) {
3024
+ throw new TypeError("temperature must be a finite number");
3042
3025
  }
3043
3026
  if (effort !== void 0 && (typeof effort !== "string" || !effort.trim())) {
3044
3027
  throw new TypeError("effort must be a nonempty model-supported string");
@@ -3063,12 +3046,12 @@ function credentialHeader(value, name) {
3063
3046
  }
3064
3047
  function normalizeModelGatewayConfig(value) {
3065
3048
  const source = record7(value);
3066
- if (!source || typeof source.baseUrl !== "string" || source.baseUrl.length > 2048 || source.protocol !== "anthropic" && source.protocol !== "openai" || typeof source.model !== "string" || source.model.length === 0 || source.model.length > 256) {
3049
+ if (!source || typeof source.baseUrl !== "string" || source.protocol !== "anthropic" && source.protocol !== "openai" || typeof source.model !== "string" || source.model.length === 0) {
3067
3050
  throw new TypeError("model gateway config is invalid");
3068
3051
  }
3069
- const maxOutputTokens = source.maxOutputTokens === void 0 ? 256 : Number(source.maxOutputTokens);
3052
+ const maxOutputTokens = source.maxOutputTokens === void 0 ? null : Number(source.maxOutputTokens);
3070
3053
  const temperature = source.temperature === void 0 ? null : Number(source.temperature);
3071
- if (!Number.isSafeInteger(maxOutputTokens) || maxOutputTokens < 1 || maxOutputTokens > 8192 || temperature !== null && (!Number.isFinite(temperature) || temperature < 0 || temperature > 2)) {
3054
+ if (maxOutputTokens !== null && (!Number.isSafeInteger(maxOutputTokens) || maxOutputTokens < 1) || temperature !== null && !Number.isFinite(temperature)) {
3072
3055
  throw new TypeError("model gateway generation limits are invalid");
3073
3056
  }
3074
3057
  const normalized = {
@@ -3156,7 +3139,7 @@ function modelProtocolRequest(protocol, model, maxOutputTokens, temperature, arg
3156
3139
  model,
3157
3140
  system: args.system ?? "",
3158
3141
  messages: alternating(messages),
3159
- max_tokens: maxOutputTokens,
3142
+ ...maxOutputTokens === null ? {} : { max_tokens: maxOutputTokens },
3160
3143
  ...effort === void 0 ? {} : { output_config: { effort } },
3161
3144
  ...temperature === null ? {} : { temperature },
3162
3145
  ...args.tools?.length ? { tools: args.tools.map((tool) => ({ name: tool.name, description: tool.description, input_schema: tool.schema })) } : {},
@@ -3168,7 +3151,7 @@ function modelProtocolRequest(protocol, model, maxOutputTokens, temperature, arg
3168
3151
  ...args.system ? [{ role: "developer", content: args.system }] : [],
3169
3152
  ...messages
3170
3153
  ],
3171
- max_completion_tokens: maxOutputTokens,
3154
+ ...maxOutputTokens === null ? {} : { max_completion_tokens: maxOutputTokens },
3172
3155
  ...effort === void 0 ? {} : { reasoning_effort: effort },
3173
3156
  ...temperature === null ? {} : { temperature },
3174
3157
  ...args.tools?.length ? { tools: args.tools.map((tool) => ({
@@ -3271,11 +3254,10 @@ function httpsUrl(value, field2) {
3271
3254
  function slotMetadata(value) {
3272
3255
  if (!value || typeof value !== "object" || Array.isArray(value)) throw new TypeError("Gateway Credential slots are invalid");
3273
3256
  const entries = Object.entries(value);
3274
- if (entries.length > 32) throw new TypeError("Gateway Credential slots are invalid");
3275
3257
  const output = {};
3276
3258
  for (const [slot, raw] of entries) {
3277
3259
  const item = raw && typeof raw === "object" && !Array.isArray(raw) ? raw : null;
3278
- if (!SLOT.test(slot) || !item || typeof item.title !== "string" || !item.title || item.title.length > 128 || item.description !== void 0 && (typeof item.description !== "string" || item.description.length > 1024) || item.required !== void 0 && typeof item.required !== "boolean" || item.provider !== void 0 && (typeof item.provider !== "string" || !SLOT.test(item.provider)) || Object.keys(item).some((key) => !["title", "description", "documentationUrl", "required", "provider"].includes(key))) {
3260
+ if (!SLOT.test(slot) || !item || typeof item.title !== "string" || !item.title || item.description !== void 0 && typeof item.description !== "string" || item.required !== void 0 && typeof item.required !== "boolean" || item.provider !== void 0 && (typeof item.provider !== "string" || !SLOT.test(item.provider)) || Object.keys(item).some((key) => !["title", "description", "documentationUrl", "required", "provider"].includes(key))) {
3279
3261
  throw new TypeError("Gateway Credential slots are invalid");
3280
3262
  }
3281
3263
  httpsUrl(item.documentationUrl, "Gateway Credential slot documentation URL");
@@ -3285,10 +3267,10 @@ function slotMetadata(value) {
3285
3267
  }
3286
3268
  function configEgressBindings(value) {
3287
3269
  if (value === void 0) return [];
3288
- if (!Array.isArray(value) || value.length > 16) throw new TypeError("Gateway config egress bindings are invalid");
3270
+ if (!Array.isArray(value)) throw new TypeError("Gateway config egress bindings are invalid");
3289
3271
  return value.map((raw) => {
3290
3272
  const item = raw && typeof raw === "object" && !Array.isArray(raw) ? raw : null;
3291
- if (!item || !SLOT.test(String(item.urlProperty ?? "")) || !Array.isArray(item.operations) || item.operations.length === 0 || item.operations.length > 128 || item.operations.some((operation) => typeof operation !== "string" || operation !== "*" && !/^[A-Za-z][A-Za-z0-9._-]{0,127}$/u.test(operation)) || !Array.isArray(item.methods) || item.methods.length === 0 || item.methods.length > 8 || item.methods.some((method) => typeof method !== "string" || !/^(?:GET|POST|PUT|PATCH|DELETE)$/u.test(method)) || Object.keys(item).some((key) => !["urlProperty", "operations", "methods"].includes(key))) {
3273
+ if (!item || !SLOT.test(String(item.urlProperty ?? "")) || !Array.isArray(item.operations) || item.operations.length === 0 || item.operations.some((operation) => typeof operation !== "string" || operation !== "*" && !/^[A-Za-z][A-Za-z0-9._-]{0,127}$/u.test(operation)) || !Array.isArray(item.methods) || item.methods.length === 0 || item.methods.some((method) => typeof method !== "string" || !/^(?:GET|POST|PUT|PATCH|DELETE)$/u.test(method)) || Object.keys(item).some((key) => !["urlProperty", "operations", "methods"].includes(key))) {
3292
3274
  throw new TypeError("Gateway config egress bindings are invalid");
3293
3275
  }
3294
3276
  return {
@@ -3308,7 +3290,7 @@ function discoverySetup(value) {
3308
3290
  }
3309
3291
  function checkpointImportMetadata(value) {
3310
3292
  const source = value && typeof value === "object" && !Array.isArray(value) ? value : null;
3311
- if (!source || source.lifecycleVersion !== 1 || !Array.isArray(source.formats) || source.formats.length === 0 || source.formats.length > 32 || source.formats.some((format) => typeof format !== "string" || !/^[a-z0-9][a-z0-9._+-]{0,63}$/u.test(format)) || new Set(source.formats).size !== source.formats.length || Object.keys(source).some((key) => !["lifecycleVersion", "formats"].includes(key))) {
3293
+ if (!source || source.lifecycleVersion !== 1 || !Array.isArray(source.formats) || source.formats.length === 0 || source.formats.some((format) => typeof format !== "string" || !/^[a-z0-9][a-z0-9._+-]{0,63}$/u.test(format)) || new Set(source.formats).size !== source.formats.length || Object.keys(source).some((key) => !["lifecycleVersion", "formats"].includes(key))) {
3312
3294
  throw new TypeError("Gateway checkpoint import metadata is invalid");
3313
3295
  }
3314
3296
  return { lifecycleVersion: 1, formats: [...source.formats] };
@@ -3321,11 +3303,11 @@ function checkpointImportRequest(value) {
3321
3303
  const artifact = source?.artifact && typeof source.artifact === "object" && !Array.isArray(source.artifact) ? source.artifact : null;
3322
3304
  const artifactValue = artifact?.value && typeof artifact.value === "object" && !Array.isArray(artifact.value) ? artifact.value : null;
3323
3305
  const model = source?.model && typeof source.model === "object" && !Array.isArray(source.model) ? source.model : null;
3324
- if (!source || typeof source.deploymentId !== "string" || !/^[a-z0-9][a-z0-9._-]{0,127}$/u.test(source.deploymentId) || !provenance || !provider || typeof provider.crn !== "string" || typeof provider.hash !== "string" || !HASH3.test(provider.hash) || Object.keys(provider).some((key) => !["crn", "hash"].includes(key)) || typeof provenance.job !== "string" || !/^[a-z0-9][a-z0-9._-]{0,127}$/u.test(provenance.job) || typeof provenance.baseModel !== "string" || !provenance.baseModel || provenance.baseModel.length > 512 || !checkpoint || !Number.isSafeInteger(checkpoint.step) || Number(checkpoint.step) < 0 || typeof checkpoint.ref !== "string" || !HASH3.test(checkpoint.ref) || typeof checkpoint.format !== "string" || !/^[a-z0-9][a-z0-9._+-]{0,63}$/u.test(checkpoint.format) || checkpoint.createdAt !== null && (!Number.isSafeInteger(checkpoint.createdAt) || Number(checkpoint.createdAt) < 0) || Object.keys(checkpoint).some((key) => !["step", "ref", "format", "createdAt"].includes(key)) || Object.keys(provenance).some((key) => !["provider", "job", "baseModel", "checkpoint"].includes(key)) || !artifact || artifact.ref !== checkpoint.ref || !artifactValue || Object.keys(artifact).some((key) => !["ref", "value"].includes(key)) || !model || typeof model.id !== "string" || !MODEL_RESOURCE_ID.test(model.id) || typeof model.displayName !== "string" || !model.displayName || model.displayName.length > 128 || typeof model.temperature !== "number" || !Number.isFinite(model.temperature) || model.temperature < 0 || model.temperature > 2 || Object.keys(model).some((key) => !["id", "displayName", "temperature"].includes(key)) || Object.keys(source).some((key) => !["deploymentId", "source", "artifact", "model"].includes(key))) {
3306
+ if (!source || typeof source.deploymentId !== "string" || !/^[a-z0-9][a-z0-9._-]{0,127}$/u.test(source.deploymentId) || !provenance || !provider || typeof provider.crn !== "string" || typeof provider.hash !== "string" || !HASH3.test(provider.hash) || Object.keys(provider).some((key) => !["crn", "hash"].includes(key)) || typeof provenance.job !== "string" || !/^[a-z0-9][a-z0-9._-]{0,127}$/u.test(provenance.job) || typeof provenance.baseModel !== "string" || !provenance.baseModel || provenance.baseModel.length > 512 || !checkpoint || !Number.isSafeInteger(checkpoint.step) || Number(checkpoint.step) < 0 || typeof checkpoint.ref !== "string" || !HASH3.test(checkpoint.ref) || typeof checkpoint.format !== "string" || !/^[a-z0-9][a-z0-9._+-]{0,63}$/u.test(checkpoint.format) || checkpoint.createdAt !== null && (!Number.isSafeInteger(checkpoint.createdAt) || Number(checkpoint.createdAt) < 0) || Object.keys(checkpoint).some((key) => !["step", "ref", "format", "createdAt"].includes(key)) || Object.keys(provenance).some((key) => !["provider", "job", "baseModel", "checkpoint"].includes(key)) || !artifact || artifact.ref !== checkpoint.ref || !artifactValue || Object.keys(artifact).some((key) => !["ref", "value"].includes(key)) || !model || typeof model.id !== "string" || !MODEL_RESOURCE_ID.test(model.id) || typeof model.displayName !== "string" || !model.displayName || typeof model.temperature !== "number" || !Number.isFinite(model.temperature) || model.temperature < 0 || model.temperature > 2 || Object.keys(model).some((key) => !["id", "displayName", "temperature"].includes(key)) || Object.keys(source).some((key) => !["deploymentId", "source", "artifact", "model"].includes(key))) {
3325
3307
  throw new TypeError("checkpoint import request is invalid");
3326
3308
  }
3327
3309
  try {
3328
- if (new TextEncoder().encode(canonicalJson(artifactValue)).byteLength > 65536) throw new TypeError();
3310
+ canonicalJson(artifactValue);
3329
3311
  } catch {
3330
3312
  throw new TypeError("checkpoint import request is invalid");
3331
3313
  }
@@ -3352,7 +3334,7 @@ function checkpointDeploymentRequest(value) {
3352
3334
  var MODEL_ID_CONTROL = /[\u0000-\u001f\u007f]/u;
3353
3335
  function gatewayModelOffer(value) {
3354
3336
  const source = value && typeof value === "object" && !Array.isArray(value) ? value : null;
3355
- if (!source || typeof source.id !== "string" || !source.id || source.id.length > 512 || source.id !== source.id.trim() || MODEL_ID_CONTROL.test(source.id) || typeof source.displayName !== "string" || !source.displayName || source.displayName.length > 128 || !Number.isSafeInteger(source.contextTokens) || Number(source.contextTokens) <= 0 || !Number.isSafeInteger(source.maxOutputTokens) || Number(source.maxOutputTokens) <= 0 || Number(source.maxOutputTokens) > Number(source.contextTokens) || !Object.hasOwn(source, "pricing") || Object.keys(source).some((key) => ![
3337
+ if (!source || typeof source.id !== "string" || !source.id || source.id.length > 512 || source.id !== source.id.trim() || MODEL_ID_CONTROL.test(source.id) || typeof source.displayName !== "string" || !source.displayName || !Number.isSafeInteger(source.contextTokens) || Number(source.contextTokens) <= 0 || !Number.isSafeInteger(source.maxOutputTokens) || Number(source.maxOutputTokens) <= 0 || Number(source.maxOutputTokens) > Number(source.contextTokens) || !Object.hasOwn(source, "pricing") || Object.keys(source).some((key) => ![
3356
3338
  "id",
3357
3339
  "displayName",
3358
3340
  "contextTokens",
@@ -3366,7 +3348,7 @@ function gatewayModelOffer(value) {
3366
3348
  const modalities = (field2) => {
3367
3349
  const values = source[field2];
3368
3350
  if (values === void 0) return void 0;
3369
- if (!Array.isArray(values) || values.length === 0 || values.length > 16 || values.some((item) => typeof item !== "string" || !SLOT.test(item)) || new Set(values).size !== values.length) {
3351
+ if (!Array.isArray(values) || values.length === 0 || values.some((item) => typeof item !== "string" || !SLOT.test(item)) || new Set(values).size !== values.length) {
3370
3352
  throw new TypeError("Gateway Model offer is invalid");
3371
3353
  }
3372
3354
  return values;
@@ -3399,7 +3381,7 @@ function assertNonSecretGatewayConfig(value, field2 = "config") {
3399
3381
  }
3400
3382
  function gatewayPackageMetadata(value) {
3401
3383
  const source = value && typeof value === "object" && !Array.isArray(value) ? value : null;
3402
- if (!source || source.lifecycleVersion !== 1 || typeof source.displayName !== "string" || !source.displayName || source.displayName.length > 128 || typeof source.description !== "string" || !source.description || source.description.length > 1024 || source.service !== void 0 && (typeof source.service !== "string" || !source.service || source.service.length > 128) || !Array.isArray(source.capabilities) || source.capabilities.length === 0 || source.capabilities.length > 32 || !source.billing || typeof source.billing !== "object" || Array.isArray(source.billing) || !["platform", "tenant"].includes(String(source.billing.upstreamPayer ?? ""))) {
3384
+ if (!source || source.lifecycleVersion !== 1 || typeof source.displayName !== "string" || !source.displayName || typeof source.description !== "string" || !source.description || source.service !== void 0 && (typeof source.service !== "string" || !source.service || source.service.length > 128) || !Array.isArray(source.capabilities) || source.capabilities.length === 0 || !source.billing || typeof source.billing !== "object" || Array.isArray(source.billing) || !["platform", "tenant"].includes(String(source.billing.upstreamPayer ?? ""))) {
3403
3385
  throw new TypeError("Gateway package metadata is invalid");
3404
3386
  }
3405
3387
  httpsUrl(source.documentationUrl, "Gateway documentation URL");
@@ -3407,7 +3389,7 @@ function gatewayPackageMetadata(value) {
3407
3389
  const modelOffers = source.modelOffers === void 0 ? [] : Array.isArray(source.modelOffers) ? source.modelOffers.map(gatewayModelOffer) : (() => {
3408
3390
  throw new TypeError("Gateway Model offers are invalid");
3409
3391
  })();
3410
- if (modelOffers.length > 512 || new Set(modelOffers.map((offer) => offer.id)).size !== modelOffers.length) {
3392
+ if (new Set(modelOffers.map((offer) => offer.id)).size !== modelOffers.length) {
3411
3393
  throw new TypeError("Gateway Model offers are invalid");
3412
3394
  }
3413
3395
  const capabilities = source.capabilities.map(capabilityContractRef);
@@ -3565,8 +3547,8 @@ function interactionRecord(value) {
3565
3547
  function exactKeys3(value, allowed) {
3566
3548
  return Object.keys(value).every((key) => allowed.includes(key));
3567
3549
  }
3568
- function boundedText(value, maximum) {
3569
- return typeof value === "string" && value.length > 0 && value.length <= maximum;
3550
+ function nonemptyText(value) {
3551
+ return typeof value === "string" && value.length > 0;
3570
3552
  }
3571
3553
  function interactionExpiry(value, sessionExpiresAt) {
3572
3554
  if (value === void 0 || value === null) return null;
@@ -3580,26 +3562,27 @@ function credentialInteractionEvent(value) {
3580
3562
  if (event.kind === "callback") {
3581
3563
  const parameters = interactionRecord(event.parameters);
3582
3564
  const headers = interactionRecord(event.headers);
3583
- if (!exactKeys3(event, ["kind", "method", "parameters", "headers", "bodyBase64"]) || !["GET", "POST"].includes(String(event.method ?? "")) || !parameters || Object.keys(parameters).length > 32 || Object.entries(parameters).some(([key, item]) => key.length > 128 || typeof item !== "string" || item.length > 4096) || !headers || Object.keys(headers).length > 64 || Object.entries(headers).some(([key, item]) => key.length > 128 || typeof item !== "string" || item.length > 8192) || event.bodyBase64 !== null && (typeof event.bodyBase64 !== "string" || event.bodyBase64.length > 35e4 || !/^[A-Za-z0-9+/]*={0,2}$/u.test(event.bodyBase64))) {
3565
+ if (!exactKeys3(event, ["kind", "method", "parameters", "headers", "bodyBase64"]) || !["GET", "POST"].includes(String(event.method ?? "")) || !parameters || Object.entries(parameters).some(([key, item]) => typeof item !== "string") || !headers || Object.entries(headers).some(([key, item]) => typeof item !== "string") || event.bodyBase64 !== null && (typeof event.bodyBase64 !== "string" || !/^[A-Za-z0-9+/]*={0,2}$/u.test(event.bodyBase64))) {
3584
3566
  throw new TypeError("credential interaction callback is invalid");
3585
3567
  }
3586
3568
  } else if (event.kind === "submit") {
3587
- if (!exactKeys3(event, ["kind", "value"]) || new TextEncoder().encode(canonicalJson(event.value)).byteLength > 65536) {
3569
+ if (!exactKeys3(event, ["kind", "value"])) {
3588
3570
  throw new TypeError("credential interaction submission is invalid");
3589
3571
  }
3572
+ canonicalJson(event.value);
3590
3573
  } else if (!exactKeys3(event, ["kind"])) throw new TypeError("credential interaction event is invalid");
3591
3574
  return event;
3592
3575
  }
3593
3576
  function credentialInteractionPrimaryAction(value, origins) {
3594
3577
  const action3 = interactionRecord(value);
3595
3578
  const event = interactionRecord(action3?.event);
3596
- if (!action3 || !event || !boundedText(action3.label, 64) || !exactKeys3(event, ["kind"]) || event.kind !== "continue") {
3579
+ if (!action3 || !event || !nonemptyText(action3.label) || !exactKeys3(event, ["kind"]) || event.kind !== "continue") {
3597
3580
  throw new TypeError("credential interaction primary action is invalid");
3598
3581
  }
3599
3582
  if (action3.kind === "continue") {
3600
3583
  if (!exactKeys3(action3, ["kind", "label", "event"])) throw new TypeError("credential interaction primary action is invalid");
3601
3584
  } else if (action3.kind === "open-url") {
3602
- if (!exactKeys3(action3, ["kind", "label", "url", "event"]) || !boundedText(action3.url, 4096)) {
3585
+ if (!exactKeys3(action3, ["kind", "label", "url", "event"]) || !nonemptyText(action3.url)) {
3603
3586
  throw new TypeError("credential interaction primary action is invalid");
3604
3587
  }
3605
3588
  let url;
@@ -3622,7 +3605,7 @@ function credentialInteractionAction(value, origins, state, sessionExpiresAt) {
3622
3605
  const expiresAt = action3.kind === "complete" ? null : interactionExpiry(action3.expiresAt, sessionExpiresAt);
3623
3606
  if (Number.isNaN(expiresAt)) throw new TypeError("credential interaction action expiry is invalid");
3624
3607
  if (action3.kind === "redirect") {
3625
- if (!exactKeys3(action3, ["kind", "url", "expiresAt"]) || !boundedText(action3.url, 4096)) {
3608
+ if (!exactKeys3(action3, ["kind", "url", "expiresAt"]) || !nonemptyText(action3.url)) {
3626
3609
  throw new TypeError("credential interaction redirect is invalid");
3627
3610
  }
3628
3611
  let url;
@@ -3635,16 +3618,16 @@ function credentialInteractionAction(value, origins, state, sessionExpiresAt) {
3635
3618
  throw new TypeError("credential interaction redirect is not authorized");
3636
3619
  }
3637
3620
  } else if (action3.kind === "form") {
3638
- if (!exactKeys3(action3, ["kind", "schema", "title", "description", "submitLabel", "expiresAt"]) || action3.title !== void 0 && !boundedText(action3.title, 128) || action3.description !== void 0 && !boundedText(action3.description, 1024) || action3.submitLabel !== void 0 && !boundedText(action3.submitLabel, 64)) {
3621
+ if (!exactKeys3(action3, ["kind", "schema", "title", "description", "submitLabel", "expiresAt"]) || action3.title !== void 0 && !nonemptyText(action3.title) || action3.description !== void 0 && !nonemptyText(action3.description) || action3.submitLabel !== void 0 && !nonemptyText(action3.submitLabel)) {
3639
3622
  throw new TypeError("credential interaction form is invalid");
3640
3623
  }
3641
3624
  const schemaError = validateJsonSchemaDefinition(action3.schema, "$interaction.form.schema");
3642
3625
  const formSchema = interactionRecord(action3.schema);
3643
- if (schemaError || !formSchema || formSchema.type !== "object" || formSchema.additionalProperties !== false || new TextEncoder().encode(canonicalJson(action3.schema)).byteLength > 65536) {
3626
+ if (schemaError || !formSchema || formSchema.type !== "object" || formSchema.additionalProperties !== false) {
3644
3627
  throw new TypeError(`credential interaction form schema is invalid${schemaError ? `: ${schemaError}` : ""}`);
3645
3628
  }
3646
3629
  } else if (action3.kind === "display") {
3647
- if (!exactKeys3(action3, ["kind", "instructions", "title", "userCode", "primaryAction", "expiresAt"]) || !boundedText(action3.instructions, 4096) || action3.title !== void 0 && !boundedText(action3.title, 128) || action3.userCode !== void 0 && !boundedText(action3.userCode, 512)) {
3630
+ if (!exactKeys3(action3, ["kind", "instructions", "title", "userCode", "primaryAction", "expiresAt"]) || !nonemptyText(action3.instructions) || action3.title !== void 0 && !nonemptyText(action3.title) || action3.userCode !== void 0 && !nonemptyText(action3.userCode)) {
3648
3631
  throw new TypeError("credential interaction display is invalid");
3649
3632
  }
3650
3633
  credentialInteractionPrimaryAction(action3.primaryAction, origins);
@@ -3653,7 +3636,7 @@ function credentialInteractionAction(value, origins, state, sessionExpiresAt) {
3653
3636
  throw new TypeError("credential interaction wait action is invalid");
3654
3637
  }
3655
3638
  } else {
3656
- if (!exactKeys3(action3, ["kind", "material", "expiresAt"]) || !boundedText(action3.material, 1048576) || action3.expiresAt !== void 0 && action3.expiresAt !== null && (!Number.isSafeInteger(action3.expiresAt) || Number(action3.expiresAt) <= Date.now())) {
3639
+ if (!exactKeys3(action3, ["kind", "material", "expiresAt"]) || !nonemptyText(action3.material) || action3.expiresAt !== void 0 && action3.expiresAt !== null && (!Number.isSafeInteger(action3.expiresAt) || Number(action3.expiresAt) <= Date.now())) {
3657
3640
  throw new TypeError("credential interaction completion is invalid");
3658
3641
  }
3659
3642
  }
@@ -3663,7 +3646,7 @@ function credentialInteractionResult(value, origins, state, sessionExpiresAt) {
3663
3646
  const result = interactionRecord(value);
3664
3647
  if (!result || !exactKeys3(result, ["action", "privateState"])) throw new TypeError("credential interaction result is invalid");
3665
3648
  const privateState = result.privateState;
3666
- if (privateState !== void 0 && privateState !== null && (typeof privateState !== "string" || new TextEncoder().encode(privateState).byteLength > 1048576)) throw new TypeError("credential interaction private state is invalid");
3649
+ if (privateState !== void 0 && privateState !== null && typeof privateState !== "string") throw new TypeError("credential interaction private state is invalid");
3667
3650
  return {
3668
3651
  action: credentialInteractionAction(result.action, origins, state, sessionExpiresAt),
3669
3652
  ...privateState === void 0 ? {} : { privateState }
@@ -3688,7 +3671,7 @@ function credentialProviderSetupMetadata(value, slots) {
3688
3671
  }
3689
3672
  const slot = declaration;
3690
3673
  const slotAllowed = /* @__PURE__ */ new Set(["title", "description", "documentationUrl", "input", "accept"]);
3691
- if (Object.keys(slot).some((key) => !slotAllowed.has(key)) || typeof slot.title !== "string" || !slot.title || slot.title.length > 128 || slot.description !== void 0 && (typeof slot.description !== "string" || !slot.description || slot.description.length > 512) || slot.input !== void 0 && !["secret", "multiline", "file"].includes(String(slot.input))) {
3674
+ if (Object.keys(slot).some((key) => !slotAllowed.has(key)) || typeof slot.title !== "string" || !slot.title || slot.description !== void 0 && (typeof slot.description !== "string" || !slot.description) || slot.input !== void 0 && !["secret", "multiline", "file"].includes(String(slot.input))) {
3692
3675
  throw new TypeError("credential provider setup Credential slots are invalid");
3693
3676
  }
3694
3677
  if (slot.documentationUrl !== void 0) {
@@ -3702,7 +3685,7 @@ function credentialProviderSetupMetadata(value, slots) {
3702
3685
  throw new TypeError("credential provider setup Credential slot documentation URL is invalid");
3703
3686
  }
3704
3687
  }
3705
- if (slot.accept !== void 0 && (!Array.isArray(slot.accept) || slot.accept.length > 16 || slot.accept.some((item) => typeof item !== "string" || !item || item.length > 64))) {
3688
+ if (slot.accept !== void 0 && (!Array.isArray(slot.accept) || slot.accept.some((item) => typeof item !== "string" || !item || item.length > 64))) {
3706
3689
  throw new TypeError("credential provider setup Credential slot file types are invalid");
3707
3690
  }
3708
3691
  }
@@ -3710,7 +3693,7 @@ function credentialProviderSetupMetadata(value, slots) {
3710
3693
  return value;
3711
3694
  }
3712
3695
  function credentialProvider(definition) {
3713
- if (!/^[a-z0-9][a-z0-9._-]{0,127}$/u.test(definition.id) || !/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/u.test(definition.version) || !definition.displayName || definition.displayName.length > 128 || !definition.description || definition.description.length > 1024 || typeof definition.mint !== "function" || definition.verify !== void 0 && typeof definition.verify !== "function" || definition.destroy !== void 0 && typeof definition.destroy !== "function") {
3696
+ if (!/^[a-z0-9][a-z0-9._-]{0,127}$/u.test(definition.id) || !/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/u.test(definition.version) || !definition.displayName || !definition.description || typeof definition.mint !== "function" || definition.verify !== void 0 && typeof definition.verify !== "function" || definition.destroy !== void 0 && typeof definition.destroy !== "function") {
3714
3697
  throw new TypeError("credential provider metadata is invalid");
3715
3698
  }
3716
3699
  if (definition.documentationUrl !== void 0) {
@@ -3728,12 +3711,12 @@ function credentialProvider(definition) {
3728
3711
  credentialRotationDefaults(definition.rotation);
3729
3712
  credentialProviderConfigSchema(definition.configSchema);
3730
3713
  credentialProviderConfigSchema(definition.credentialConfigSchema);
3731
- if (!Array.isArray(definition.credentialSlots) || definition.credentialSlots.length > 32 || new Set(definition.credentialSlots).size !== definition.credentialSlots.length || definition.credentialSlots.some((slot) => typeof slot !== "string" || !/^[a-z0-9][a-z0-9._-]{0,127}$/u.test(slot))) {
3714
+ if (!Array.isArray(definition.credentialSlots) || new Set(definition.credentialSlots).size !== definition.credentialSlots.length || definition.credentialSlots.some((slot) => typeof slot !== "string" || !/^[a-z0-9][a-z0-9._-]{0,127}$/u.test(slot))) {
3732
3715
  throw new TypeError("credential provider bootstrap slots are invalid");
3733
3716
  }
3734
3717
  const setup = credentialProviderSetupMetadata(definition.setup, definition.credentialSlots);
3735
3718
  const interaction = definition.interaction ?? null;
3736
- if (interaction && (!Array.isArray(interaction.origins) || interaction.origins.length === 0 || interaction.origins.length > 16 || new Set(interaction.origins).size !== interaction.origins.length || interaction.origins.some((origin) => {
3719
+ if (interaction && (!Array.isArray(interaction.origins) || interaction.origins.length === 0 || new Set(interaction.origins).size !== interaction.origins.length || interaction.origins.some((origin) => {
3737
3720
  try {
3738
3721
  const url = new URL(origin);
3739
3722
  return url.protocol !== "https:" || url.origin !== origin;
@@ -3767,35 +3750,36 @@ function credentialProvider(definition) {
3767
3750
 
3768
3751
  // packages/sdk/src/evaluation.ts
3769
3752
  var EVALUATION_LIMITS = {
3770
- maxQuestions: 512,
3771
- maxChoiceOptions: 512,
3772
- maxScoreLevels: 128,
3773
- maxDepth: 32,
3774
- /** Bytes of the canonical request body; evaluation models bound state and questions jointly by tokens. */
3775
- maxRequestBytes: 1048576
3753
+ maxQuestions: Number.MAX_SAFE_INTEGER,
3754
+ maxChoiceOptions: Number.MAX_SAFE_INTEGER,
3755
+ maxScoreLevels: Number.MAX_SAFE_INTEGER,
3756
+ maxDepth: Number.MAX_SAFE_INTEGER,
3757
+ /** Compatibility numeric domains, not request quotas; provider limits are reported by the provider. */
3758
+ maxRequestBytes: Number.MAX_SAFE_INTEGER
3776
3759
  };
3777
3760
  var QUESTION_ID = /^[A-Za-z0-9_][A-Za-z0-9_.:-]{0,127}$/u;
3778
3761
  var MODEL = /^[a-z0-9][a-z0-9._\/-]{0,255}$/u;
3779
3762
  function record8(value) {
3780
3763
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
3781
3764
  }
3782
- function entry(value, field2, depth = 0) {
3783
- if (depth > EVALUATION_LIMITS.maxDepth) throw new TypeError(`${field2} nests too deeply`);
3765
+ function entry(value, field2, ancestors = /* @__PURE__ */ new WeakSet()) {
3784
3766
  if (value === null || typeof value === "string" || typeof value === "boolean") return value;
3785
3767
  if (typeof value === "number") {
3786
3768
  if (!Number.isFinite(value)) throw new TypeError(`${field2} must be a finite number`);
3787
3769
  return value;
3788
3770
  }
3789
- if (Array.isArray(value)) return value.map((item, index) => entry(item, `${field2}[${index}]`, depth + 1));
3790
- const source = record8(value);
3771
+ const array = Array.isArray(value);
3772
+ const source = array ? value : record8(value);
3791
3773
  const prototype = source ? Object.getPrototypeOf(source) : void 0;
3792
- if (!source || prototype !== Object.prototype && prototype !== null) throw new TypeError(`${field2} must be JSON text or structure`);
3793
- const output = {};
3794
- for (const [key, item] of Object.entries(source)) {
3795
- if (item === void 0) continue;
3796
- output[key] = entry(item, `${field2}.${key}`, depth + 1);
3774
+ if (!source || !array && prototype !== Object.prototype && prototype !== null) throw new TypeError(`${field2} must be JSON text or structure`);
3775
+ if (ancestors.has(source)) throw new TypeError(`${field2} contains a JSON cycle`);
3776
+ ancestors.add(source);
3777
+ try {
3778
+ if (array) return value.map((item, index) => entry(item, `${field2}[${index}]`, ancestors));
3779
+ return Object.fromEntries(Object.entries(source).filter(([, item]) => item !== void 0).map(([key, item]) => [key, entry(item, `${field2}.${key}`, ancestors)]));
3780
+ } finally {
3781
+ ancestors.delete(source);
3797
3782
  }
3798
- return output;
3799
3783
  }
3800
3784
  function question(id2, value) {
3801
3785
  const source = record8(value);
@@ -3810,14 +3794,12 @@ function question(id2, value) {
3810
3794
  const criteria2 = record8(source.criteria);
3811
3795
  const options = criteria2 ? Object.keys(criteria2) : [];
3812
3796
  if (!criteria2 || options.length < 2) throw new TypeError(`choice question ${id2} needs at least two options`);
3813
- if (options.length > EVALUATION_LIMITS.maxChoiceOptions) throw new TypeError(`choice question ${id2} offers too many options`);
3814
- if (options.some((option) => !option.trim() || option.length > 256)) throw new TypeError(`choice question ${id2} has an invalid option key`);
3797
+ if (options.some((option) => !option.trim())) throw new TypeError(`choice question ${id2} has an invalid option key`);
3815
3798
  return { type, instructions, criteria: Object.fromEntries(options.map((option) => [option, entry(criteria2[option], `choice question ${id2} option ${option}`)])) };
3816
3799
  }
3817
3800
  if (type === "score") {
3818
3801
  const criteria2 = source.criteria;
3819
3802
  if (!Array.isArray(criteria2) || criteria2.length < 2) throw new TypeError(`score question ${id2} needs at least two ordered levels`);
3820
- if (criteria2.length > EVALUATION_LIMITS.maxScoreLevels) throw new TypeError(`score question ${id2} has too many levels`);
3821
3803
  return { type, instructions, criteria: criteria2.map((level, index) => entry(level, `score question ${id2} level ${index}`)) };
3822
3804
  }
3823
3805
  if (source.criteria === void 0) return { type, instructions };
@@ -3838,8 +3820,7 @@ function evaluationArguments(value) {
3838
3820
  const questionSource = record8(source.questions);
3839
3821
  const ids = questionSource ? Object.keys(questionSource) : [];
3840
3822
  if (!questionSource || ids.length === 0) throw new TypeError("evaluation requires at least one question");
3841
- if (ids.length > EVALUATION_LIMITS.maxQuestions) throw new TypeError("evaluation asks too many questions");
3842
- const questions = {};
3823
+ const questions = /* @__PURE__ */ Object.create(null);
3843
3824
  for (const id2 of ids) {
3844
3825
  if (!QUESTION_ID.test(id2)) throw new TypeError(`question id is invalid: ${id2}`);
3845
3826
  questions[id2] = question(id2, questionSource[id2]);
@@ -3852,8 +3833,6 @@ function evaluationArguments(value) {
3852
3833
  model = source.model;
3853
3834
  }
3854
3835
  const output = { ...model === void 0 ? {} : { model }, state, questions };
3855
- const bytes = new TextEncoder().encode(JSON.stringify({ state, questions })).byteLength;
3856
- if (bytes > EVALUATION_LIMITS.maxRequestBytes) throw new TypeError("evaluation state and questions exceed the request size limit");
3857
3836
  return output;
3858
3837
  }
3859
3838
  function evaluationProtocolRequest(protocol, model, args) {
@@ -4082,9 +4061,9 @@ function exactKeys4(value, allowed) {
4082
4061
  }
4083
4062
  function scorerRule(value, depth, state) {
4084
4063
  const rule = record10(value);
4085
- if (!rule || depth > 32 || ++state.rules > 1024 || typeof rule.op !== "string") throw new TypeError("Code Scorer IR is invalid");
4064
+ if (!rule || typeof rule.op !== "string") throw new TypeError("Code Scorer IR is invalid");
4086
4065
  if (rule.op === "all" || rule.op === "any") {
4087
- if (!exactKeys4(rule, ["op", "rules"]) || !Array.isArray(rule.rules) || rule.rules.length < 1 || rule.rules.length > 128) {
4066
+ if (!exactKeys4(rule, ["op", "rules"]) || !Array.isArray(rule.rules) || rule.rules.length < 1) {
4088
4067
  throw new TypeError("Code Scorer logical rule is invalid");
4089
4068
  }
4090
4069
  return { op: rule.op, rules: rule.rules.map((child) => scorerRule(child, depth + 1, state)) };
@@ -4119,7 +4098,7 @@ function scorerRule(value, depth, state) {
4119
4098
  return rule;
4120
4099
  }
4121
4100
  if (rule.op === "tool-sequence") {
4122
- if (!exactKeys4(rule, ["op", "path", "expected", "mode"]) || !validPointer(rule.path) || !Array.isArray(rule.expected) || rule.expected.length > 256 || rule.expected.some((item) => typeof item !== "string" || !/^[A-Za-z0-9._-]{1,128}$/u.test(item)) || rule.mode !== "exact" && rule.mode !== "ordered-subsequence") throw new TypeError("Code Scorer tool sequence rule is invalid");
4101
+ if (!exactKeys4(rule, ["op", "path", "expected", "mode"]) || !validPointer(rule.path) || !Array.isArray(rule.expected) || rule.expected.some((item) => typeof item !== "string" || !/^[A-Za-z0-9._-]{1,128}$/u.test(item)) || rule.mode !== "exact" && rule.mode !== "ordered-subsequence") throw new TypeError("Code Scorer tool sequence rule is invalid");
4123
4102
  return rule;
4124
4103
  }
4125
4104
  if (rule.op === "citations-in-source") {