@constal/sdk 3.11.0 → 4.0.1

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);
@@ -450,9 +450,6 @@ var RESOURCE_IDENTITY_LABELS = {
450
450
  kind: "constal.ai/kind",
451
451
  version: "constal.ai/version"
452
452
  };
453
- var MAX_LABELS = 64;
454
- var MAX_EXPRESSIONS = 64;
455
- var MAX_VALUES = 64;
456
453
  var NAME = /^[A-Za-z0-9](?:[-_.A-Za-z0-9]{0,61}[A-Za-z0-9])?$/u;
457
454
  var DNS_LABEL = /^[a-z0-9](?:[-a-z0-9]{0,61}[a-z0-9])?$/u;
458
455
  function record(value) {
@@ -475,7 +472,7 @@ function selectorValue(key, value) {
475
472
  }
476
473
  function resourceLabelMap(value, options = {}) {
477
474
  const source = record(value);
478
- 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");
479
476
  const entries = Object.entries(source);
480
477
  for (const [key, candidate] of entries) {
481
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`);
@@ -489,7 +486,7 @@ function labelSelector(value) {
489
486
  }
490
487
  const matchLabels = source.matchLabels === void 0 ? {} : resourceLabelMap(source.matchLabels, { allowProtected: true });
491
488
  const rawExpressions = source.matchExpressions === void 0 ? [] : source.matchExpressions;
492
- 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");
493
490
  const matchExpressions = rawExpressions.map((raw, index) => {
494
491
  const expression = record(raw);
495
492
  const operator = expression?.operator;
@@ -498,7 +495,7 @@ function labelSelector(value) {
498
495
  throw new TypeError(`Label selector expression ${index} is invalid`);
499
496
  }
500
497
  if (operator === "In" || operator === "NotIn") {
501
- 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))) {
502
499
  throw new TypeError(`Label selector expression ${index} values are invalid`);
503
500
  }
504
501
  return { key: expression.key, operator, values: [...new Set(values)].sort() };
@@ -741,14 +738,14 @@ function channelTarget(value) {
741
738
  return { resourceKind: "channel", subscriptions: { provider: subscriptions.provider } };
742
739
  }
743
740
  var UI_RESOURCE_BOUNDS = Object.freeze({
744
- maximumRequestBodyBytes: 1048576,
745
- maximumResponseBodyBytes: 16777216,
746
- maximumCpuMs: 3e4,
747
- maximumSubrequests: 100,
748
- maximumDatabaseBytes: 1073741824,
749
- maximumRowsReadPerRequest: 1e6,
750
- maximumRowsWrittenPerRequest: 1e5,
751
- 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
752
749
  });
753
750
  var ACTION_PATTERN = /^[a-z][a-z0-9-]{0,63}:[a-z][a-z0-9-]{0,63}$/u;
754
751
  var SEGMENT = /^[a-z0-9][a-z0-9._-]{0,127}$/u;
@@ -1255,7 +1252,7 @@ function channel(definition) {
1255
1252
  definition.needs?.forEach(resourceNeed);
1256
1253
  const analytics = definition.analytics ?? [];
1257
1254
  analytics.forEach((event) => analyticsEvent(event));
1258
- 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");
1259
1256
  return definition;
1260
1257
  }
1261
1258
 
@@ -1442,7 +1439,7 @@ function channelSourceEvidence(value) {
1442
1439
  }
1443
1440
  function credentialEvidence(value) {
1444
1441
  const input = object2(value), provider = object2(input?.provider), claims = object2(input?.claims);
1445
- 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")))) {
1446
1443
  throw new TypeError("Credential evidence is invalid");
1447
1444
  }
1448
1445
  if (parseResourceName(input.credential).kind !== "credential" || parseResourceName(provider.crn).kind !== "credential-provider") {
@@ -1469,7 +1466,7 @@ function channelSubscriptionRequest(value) {
1469
1466
  throw new TypeError("Channel subscription crosses the authenticated tenant");
1470
1467
  }
1471
1468
  const credentials = input.credentials ?? [];
1472
- 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");
1473
1470
  const proofs = credentials.map(credentialEvidence);
1474
1471
  for (const proof of proofs) {
1475
1472
  const owner = parseResourceName(proof.credential), provider = parseResourceName(proof.provider.crn);
@@ -1481,7 +1478,7 @@ function channelSubscriptionRequest(value) {
1481
1478
  }
1482
1479
  function channelIngressRequest(value) {
1483
1480
  const input = object2(value), headers = object2(input?.headers);
1484
- 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");
1485
1482
  return { method: input.method, url: input.url, headers, bodyBase64: input.bodyBase64 };
1486
1483
  }
1487
1484
 
@@ -1718,7 +1715,7 @@ function setupAwait(screen) {
1718
1715
  type: "object",
1719
1716
  additionalProperties: false,
1720
1717
  required: ["crn", "hash"],
1721
- properties: { crn: { type: "string", maxLength: 1024 }, hash: hash3 }
1718
+ properties: { crn: { type: "string" }, hash: hash3 }
1722
1719
  };
1723
1720
  const receipt = current.kind === "credential-interaction" && current.receipt !== void 0 ? {
1724
1721
  type: "object",
@@ -1733,21 +1730,21 @@ function setupAwait(screen) {
1733
1730
  additionalProperties: false,
1734
1731
  required: ["credential", "provider", "version", "expiresAt", "claims"],
1735
1732
  properties: {
1736
- credential: { type: "string", maxLength: 1024 },
1733
+ credential: { type: "string" },
1737
1734
  provider: {
1738
1735
  ...reference,
1739
- 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 }
1740
1737
  },
1741
1738
  version: { type: "integer", minimum: 1 },
1742
1739
  expiresAt: { type: ["integer", "null"], minimum: 1 },
1743
- claims: { type: "object", maxProperties: 32 }
1740
+ claims: { type: "object" }
1744
1741
  }
1745
1742
  },
1746
1743
  binding: current.selection ? {
1747
1744
  type: "object",
1748
1745
  additionalProperties: false,
1749
1746
  required: ["crn", "headSeq", "revisionHash"],
1750
- 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 }
1751
1748
  } : { type: "null" }
1752
1749
  }
1753
1750
  } : null;
@@ -1845,10 +1842,10 @@ var CONSTAL_API_OPERATIONS = [
1845
1842
  ];
1846
1843
  var CONSTAL_API_BOUNDS = {
1847
1844
  defaultPageSize: 50,
1848
- maximumPageSize: 200,
1849
- maximumRelationDepth: 3,
1850
- maximumPlanOperations: 64,
1851
- 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,
1852
1849
  planTtlMs: 15 * 6e4
1853
1850
  };
1854
1851
  var CONSTAL_API_QUERY_KINDS = [
@@ -1904,17 +1901,16 @@ var CONSTAL_API_GET_CRN_KINDS = [
1904
1901
  "deployment"
1905
1902
  ];
1906
1903
  var CONSTAL_API_OBJECT_REF_CRN_KINDS = [...CONSTAL_API_GET_CRN_KINDS, "customer"];
1907
- 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}$" };
1908
1905
  var namespaceSchema = {
1909
1906
  type: "string",
1910
1907
  minLength: 1,
1911
- maxLength: 128,
1912
1908
  pattern: "^[a-z0-9][a-z0-9._-]{0,127}$"
1913
1909
  };
1914
1910
  var actionSchema = { type: "string", pattern: ACTION_PATTERN.source };
1915
- 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}$" };
1916
1912
  var hashSchema = { type: "string", pattern: "^[a-f0-9]{64}$" };
1917
- var stringListSchema = { type: "array", maxItems: 128, items: { type: "string", minLength: 1, maxLength: 256 } };
1913
+ var stringListSchema = { type: "array", items: { type: "string", minLength: 1 } };
1918
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: [
1919
1915
  {
1920
1916
  type: "object",
@@ -1930,25 +1926,22 @@ var scopeSchema = { description: "Use namespace with an exact namespace allowed
1930
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}$`;
1931
1927
  var objectRefSchema = { type: "object", additionalProperties: false, properties: {
1932
1928
  kind: { enum: [...CONSTAL_API_GET_KINDS], description: "Exact lower-case object kind returned by a governed platform result." },
1933
- id: { type: "string", minLength: 1, maxLength: 512 },
1929
+ id: { type: "string", minLength: 1 },
1934
1930
  crn: { anyOf: [{ type: "null" }, {
1935
1931
  type: "string",
1936
1932
  minLength: 1,
1937
- maxLength: 2048,
1938
1933
  pattern: crnPattern(CONSTAL_API_OBJECT_REF_CRN_KINDS)
1939
1934
  }] },
1940
1935
  hash: { anyOf: [{ type: "null" }, hashSchema] },
1941
1936
  namespace: {
1942
1937
  type: ["string", "null"],
1943
- maxLength: 128,
1944
1938
  pattern: "^[a-z0-9][a-z0-9._-]{0,127}$"
1945
1939
  },
1946
- version: { type: ["string", "null"], maxLength: 128 }
1940
+ version: { type: ["string", "null"] }
1947
1941
  }, required: ["kind", "id", "namespace"] };
1948
1942
  var exactGetCrnSchema = {
1949
1943
  type: "string",
1950
1944
  minLength: 1,
1951
- maxLength: 2048,
1952
1945
  description: "Exact addressable CRN obtained from governed platform evidence.",
1953
1946
  pattern: crnPattern(CONSTAL_API_GET_CRN_KINDS)
1954
1947
  };
@@ -1959,11 +1952,10 @@ var CONSTAL_API_OPERATION_SCHEMAS = {
1959
1952
  operations: stringListSchema,
1960
1953
  include: {
1961
1954
  type: "array",
1962
- maxItems: 5,
1963
1955
  uniqueItems: true,
1964
1956
  items: { enum: ["objects", "operations", "relations", "schemas", "docs"] }
1965
1957
  },
1966
- cursor: { type: "string", maxLength: 4096 },
1958
+ cursor: { type: "string" },
1967
1959
  limit: { type: "integer", minimum: 1, maximum: CONSTAL_API_BOUNDS.maximumPageSize }
1968
1960
  } },
1969
1961
  query: {
@@ -1975,8 +1967,8 @@ var CONSTAL_API_OPERATION_SCHEMAS = {
1975
1967
  kind: { enum: [...CONSTAL_API_QUERY_KINDS], description: "Exact queryable kind. Never guess a kind or change its casing." },
1976
1968
  scope: scopeSchema,
1977
1969
  filter: { type: "object", description: "Optional catalog-advertised filter expression." },
1978
- search: { type: "string", maxLength: 512 },
1979
- order: { type: "array", maxItems: 8, items: {
1970
+ search: { type: "string" },
1971
+ order: { type: "array", items: {
1980
1972
  type: "object",
1981
1973
  required: ["field", "direction"],
1982
1974
  additionalProperties: false,
@@ -1984,7 +1976,7 @@ var CONSTAL_API_OPERATION_SCHEMAS = {
1984
1976
  } },
1985
1977
  fields: stringListSchema,
1986
1978
  limit: { type: "integer", minimum: 1, maximum: CONSTAL_API_BOUNDS.maximumPageSize },
1987
- cursor: { type: "string", maxLength: 4096 },
1979
+ cursor: { type: "string" },
1988
1980
  asOf: { type: "integer", minimum: 0 },
1989
1981
  range: { type: "object", required: ["start", "end"], additionalProperties: false, properties: {
1990
1982
  start: { type: "integer", minimum: 0 },
@@ -2009,8 +2001,8 @@ var CONSTAL_API_OPERATION_SCHEMAS = {
2009
2001
  },
2010
2002
  fields: stringListSchema,
2011
2003
  page: { type: "object", additionalProperties: false, properties: {
2012
- cursor: { type: "string", maxLength: 4096 },
2013
- limit: { type: "integer", minimum: 1, maximum: 500 }
2004
+ cursor: { type: "string" },
2005
+ limit: { type: "integer", minimum: 1 }
2014
2006
  } }
2015
2007
  }
2016
2008
  },
@@ -2019,35 +2011,33 @@ var CONSTAL_API_OPERATION_SCHEMAS = {
2019
2011
  type: "object",
2020
2012
  required: ["crn"],
2021
2013
  additionalProperties: false,
2022
- properties: { crn: { type: "string", minLength: 1, maxLength: 2048 }, hash: hashSchema }
2014
+ properties: { crn: { type: "string", minLength: 1 }, hash: hashSchema }
2023
2015
  }] },
2024
2016
  direction: { enum: ["outgoing", "incoming", "both"] },
2025
2017
  types: stringListSchema,
2026
2018
  depth: { type: "integer", minimum: 1, maximum: CONSTAL_API_BOUNDS.maximumRelationDepth },
2027
2019
  limit: { type: "integer", minimum: 1, maximum: CONSTAL_API_BOUNDS.maximumPageSize },
2028
- cursor: { type: "string", maxLength: 4096 }
2020
+ cursor: { type: "string" }
2029
2021
  } },
2030
2022
  explainPolicy: { type: "object", required: ["action", "resource"], additionalProperties: false, properties: {
2031
2023
  principal: { anyOf: [
2032
- { type: "string", maxLength: 2048 },
2024
+ { type: "string" },
2033
2025
  { type: "object", required: ["roles", "scopes"], additionalProperties: false, properties: {
2034
- name: { type: "string", maxLength: 2048 },
2026
+ name: { type: "string" },
2035
2027
  roles: {
2036
2028
  type: "array",
2037
- maxItems: 64,
2038
2029
  uniqueItems: true,
2039
- items: { type: "string", minLength: 1, maxLength: 2048 }
2030
+ items: { type: "string", minLength: 1 }
2040
2031
  },
2041
2032
  scopes: {
2042
2033
  type: "array",
2043
- maxItems: 256,
2044
2034
  uniqueItems: true,
2045
2035
  items: { type: "string", pattern: "^(?:\\*|[a-z][a-z0-9-]{0,63}:(?:[a-z][a-z0-9-]{0,63}|\\*))$" }
2046
2036
  }
2047
2037
  } }
2048
2038
  ] },
2049
2039
  action: actionSchema,
2050
- resource: { type: "string", minLength: 1, maxLength: 2048 },
2040
+ resource: { type: "string", minLength: 1 },
2051
2041
  context: { type: "object" },
2052
2042
  arguments: {},
2053
2043
  at: { type: "object", required: ["run"], additionalProperties: false, properties: {
@@ -2057,7 +2047,7 @@ var CONSTAL_API_OPERATION_SCHEMAS = {
2057
2047
  additionalProperties: false,
2058
2048
  properties: {
2059
2049
  namespace: boundedNameSchema,
2060
- 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}$" },
2061
2051
  session: boundedIdSchema,
2062
2052
  run: boundedIdSchema
2063
2053
  }
@@ -2065,7 +2055,7 @@ var CONSTAL_API_OPERATION_SCHEMAS = {
2065
2055
  } }
2066
2056
  } },
2067
2057
  plan: { type: "object", required: ["objective", "operations"], additionalProperties: false, properties: {
2068
- objective: { type: "string", minLength: 1, maxLength: 8192 },
2058
+ objective: { type: "string", minLength: 1 },
2069
2059
  validateOnly: { type: "boolean" },
2070
2060
  operations: {
2071
2061
  type: "array",
@@ -2074,10 +2064,10 @@ var CONSTAL_API_OPERATION_SCHEMAS = {
2074
2064
  items: { type: "object", required: ["operation", "input"], additionalProperties: false, properties: {
2075
2065
  id: boundedIdSchema,
2076
2066
  operation: boundedNameSchema,
2077
- target: { type: "string", maxLength: 2048 },
2067
+ target: { type: "string" },
2078
2068
  input: {},
2079
2069
  expectedCurrentHash: { anyOf: [{ type: "null" }, hashSchema] },
2080
- dependsOn: { type: "array", maxItems: 64, items: boundedIdSchema }
2070
+ dependsOn: { type: "array", items: boundedIdSchema }
2081
2071
  } }
2082
2072
  }
2083
2073
  } },
@@ -2093,53 +2083,58 @@ var CONSTAL_API_OPERATION_SCHEMAS = {
2093
2083
  observe: { type: "object", required: ["id"], additionalProperties: false, properties: { id: boundedIdSchema } }
2094
2084
  };
2095
2085
 
2096
- // packages/sdk/src/artifact-limits.ts
2097
- var ARTIFACT_MAX_BYTES = 5 * 1024 ** 3;
2098
-
2099
2086
  // packages/sdk/src/sandbox-policy-contract.ts
2100
2087
  var SANDBOX_CONTRACT_REF = {
2101
2088
  id: "constal.sandbox-pool",
2102
2089
  version: "2",
2103
- hash: "69157b4e169275334de93ce0d24ffcdfe982c021ca67499ece3a173db25f4d16"
2090
+ hash: "89c34a8870f861811e6548d8388eddfc2d9b74e642fabeaf37c89f6d21df1c8e"
2104
2091
  };
2105
2092
  var SANDBOX_CONTROLS_SCHEMA = {
2106
2093
  type: "object",
2107
2094
  additionalProperties: false,
2108
2095
  properties: {
2109
- command_timeout_ms: { type: "integer", minimum: 1e3, maximum: 216e5 },
2110
- cpu: { type: "number", exclusiveMinimum: 0, maximum: 64 },
2111
- disk_gib: { type: "number", minimum: 0, maximum: 1024 },
2112
- idle_stop_ms: { type: "integer", minimum: 1e3, maximum: 864e5 },
2113
- max_concurrent_commands: { type: "integer", minimum: 1, maximum: 1024 },
2114
- max_file_bytes: { type: "integer", minimum: 1, maximum: ARTIFACT_MAX_BYTES },
2115
- memory_gib: { type: "number", exclusiveMinimum: 0, maximum: 1024 },
2116
- network_cidrs: { type: "array", minItems: 1, maxItems: 1024, items: { type: "string" } },
2117
- 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" } },
2118
2105
  network_egress: { type: ["string", "null"] },
2119
2106
  network_mode: { enum: ["block-all", "cidr-allow", "domain-allow", "managed-http", "unrestricted"] },
2120
2107
  network_transport: { enum: [null, "bridge", "proxy"] },
2121
- permitted_paths: { type: "array", minItems: 1, maxItems: 1024, items: { type: "string" } }
2108
+ permitted_paths: { type: "array", minItems: 1, items: { type: "string" } }
2122
2109
  }
2123
2110
  };
2124
2111
 
2125
- // packages/sdk/src/policy-governance.ts
2126
- var SANDBOX_CONTRACT = SANDBOX_CONTRACT_REF;
2127
- var MODEL_CONTRACT = {
2112
+ // packages/sdk/src/model-policy-contract.ts
2113
+ var MODEL_CONTRACT_REF = {
2128
2114
  id: "constal.model",
2129
2115
  version: "1",
2130
- hash: "76dd0da40da46adabb6837f911b25ed6f675c965e5d4d919077ee9c3945fbca7"
2116
+ hash: "5f2d00a0ba630341c15725d26dec7ff31f48724328e21c1264d1f7f7cee048b8"
2131
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
+ }
2126
+ };
2127
+
2128
+ // packages/sdk/src/policy-governance.ts
2129
+ var SANDBOX_CONTRACT = SANDBOX_CONTRACT_REF;
2130
+ var MODEL_CONTRACT = MODEL_CONTRACT_REF;
2132
2131
  var UI_CONTRACT = {
2133
2132
  id: "constal.ui",
2134
2133
  version: "1",
2135
2134
  hash: "133f0ab76ca2f1435dfbaa151652cfc79926ea5237c0892d0c4d3b96d7bb6f48"
2136
2135
  };
2137
2136
  var sandboxSchema = SANDBOX_CONTROLS_SCHEMA;
2138
- var modelSchema = { type: "object", additionalProperties: false, properties: {
2139
- max_input_tokens: { type: "integer", minimum: 1, maximum: 1048576 },
2140
- max_output_tokens: { type: "integer", minimum: 1, maximum: 1048576 },
2141
- temperature_max: { type: "number", minimum: 0, maximum: 2 }
2142
- } };
2137
+ var modelSchema = MODEL_CONTROLS_SCHEMA;
2143
2138
  function controls(contract, values, schema) {
2144
2139
  const error = validateJsonSchema(values, schema);
2145
2140
  if (error) throw new TypeError(`governance controls are invalid: ${error}`);
@@ -2175,17 +2170,14 @@ function validatePolicyGovernanceConstraint(value) {
2175
2170
  }
2176
2171
 
2177
2172
  // packages/sdk/src/authorization.ts
2178
- var MAX_CONSTRAINTS = 64;
2179
- var MAX_OUTCOME_BYTES = 65536;
2180
- var MAX_REASON_BYTES = 1024;
2181
2173
  var DENIAL_CODE = /^[a-z][a-z0-9._-]{0,127}$/u;
2182
2174
  var encoder4 = new TextEncoder();
2183
2175
  function record4(value) {
2184
2176
  return !!value && typeof value === "object" && !Array.isArray(value);
2185
2177
  }
2186
- function requiredString2(value, path, maximum = 1024) {
2187
- if (typeof value !== "string" || value.length === 0 || encoder4.encode(value).byteLength > maximum) {
2188
- 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`);
2189
2181
  }
2190
2182
  }
2191
2183
  function exactKeys2(value, allowed, required2, path) {
@@ -2197,7 +2189,7 @@ function scalar(value) {
2197
2189
  return value === null || typeof value === "string" || typeof value === "boolean" || typeof value === "number" && Number.isFinite(value);
2198
2190
  }
2199
2191
  function validateGrant(grant, path) {
2200
- 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) {
2201
2193
  throw new TypeError(`${path} is invalid`);
2202
2194
  }
2203
2195
  exactKeys2(grant, ["actions", "resources", "ttlMs"], ["actions", "resources", "ttlMs"], path);
@@ -2224,7 +2216,7 @@ function validatePolicyConstraint(constraint, path = "constraint") {
2224
2216
  }
2225
2217
  if (constraint.kind === "context") {
2226
2218
  exactKeys2(source, ["kind", "equals"], ["kind", "equals"], path);
2227
- 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))) {
2228
2220
  throw new TypeError(`${path}.equals is invalid`);
2229
2221
  }
2230
2222
  return;
@@ -2239,7 +2231,7 @@ function validatePolicyConstraint(constraint, path = "constraint") {
2239
2231
  }
2240
2232
  function validateConstraints(value, path, required2) {
2241
2233
  if (value === void 0 && !required2) return [];
2242
- if (!Array.isArray(value) || required2 && value.length === 0 || value.length > MAX_CONSTRAINTS) {
2234
+ if (!Array.isArray(value) || required2 && value.length === 0) {
2243
2235
  throw new TypeError(`${path} is invalid`);
2244
2236
  }
2245
2237
  value.forEach((constraint, index) => validatePolicyConstraint(constraint, `${path}[${index}]`));
@@ -2251,7 +2243,7 @@ function policyOutcome(value) {
2251
2243
  else if (value.kind === "deny") {
2252
2244
  exactKeys2(value, ["kind", "code", "reason"], ["kind", "code"], "Policy deny outcome");
2253
2245
  if (typeof value.code !== "string" || !DENIAL_CODE.test(value.code)) throw new TypeError("Policy denial code is invalid");
2254
- 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");
2255
2247
  } else if (value.kind === "constrain") {
2256
2248
  exactKeys2(value, ["kind", "constraints"], ["kind", "constraints"], "Policy constrain outcome");
2257
2249
  validateConstraints(value.constraints, "Policy constraints", true);
@@ -2261,13 +2253,13 @@ function policyOutcome(value) {
2261
2253
  validateConstraints(value.constraints, "Policy constraints", false);
2262
2254
  } else if (value.kind === "require-approval") {
2263
2255
  exactKeys2(value, ["kind", "reason", "constraints"], ["kind"], "Policy approval outcome");
2264
- 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");
2265
2257
  validateConstraints(value.constraints, "Policy constraints", false);
2266
2258
  } else if (value.kind === "grant") {
2267
2259
  exactKeys2(value, ["kind", "grant"], ["kind", "grant"], "Policy grant outcome");
2268
2260
  validateGrant(value.grant, "Policy grant");
2269
2261
  } else throw new TypeError("Policy outcome kind is invalid");
2270
- if (encoder4.encode(canonicalJson(value)).byteLength > MAX_OUTCOME_BYTES) throw new TypeError("Policy outcome is oversized");
2262
+ canonicalJson(value);
2271
2263
  return value;
2272
2264
  }
2273
2265
 
@@ -2287,7 +2279,7 @@ var identifier = { type: "string", pattern: "^[a-zA-Z_][a-zA-Z0-9_.-]{0,127}$",
2287
2279
  var tableName = { type: "string", pattern: "^[a-z0-9][a-z0-9._-]{0,127}$", maxLength: 128 };
2288
2280
  var branchName = { type: "string", pattern: "^[a-z0-9][a-z0-9._/-]{0,127}$", maxLength: 128 };
2289
2281
  var hash2 = { type: "string", pattern: "^[a-f0-9]{64}$" };
2290
- var scalar2 = { type: ["string", "number", "integer", "boolean", "null"], maxLength: 4096 };
2282
+ var scalar2 = { type: ["string", "number", "integer", "boolean", "null"] };
2291
2283
  var TABLE_DESCRIBE_SCHEMA = {
2292
2284
  type: "object",
2293
2285
  required: ["table"],
@@ -2297,7 +2289,7 @@ var TABLE_DESCRIBE_SCHEMA = {
2297
2289
  branch: branchName,
2298
2290
  snapshot: hash2,
2299
2291
  stageId: hash2,
2300
- waitMs: { type: "integer", minimum: 0, maximum: 25e3 }
2292
+ waitMs: { type: "integer", minimum: 0 }
2301
2293
  }
2302
2294
  };
2303
2295
  var filterSchema = {
@@ -2307,7 +2299,7 @@ var filterSchema = {
2307
2299
  properties: {
2308
2300
  field: identifier,
2309
2301
  op: { type: "string", enum: ["eq", "ne", "gt", "gte", "lt", "lte", "in", "between"] },
2310
- value: { anyOf: [scalar2, { type: "array", minItems: 1, maxItems: 100, items: scalar2 }] }
2302
+ value: { anyOf: [scalar2, { type: "array", minItems: 1, items: scalar2 }] }
2311
2303
  }
2312
2304
  };
2313
2305
  var TABLE_QUERY_SCHEMA = {
@@ -2322,10 +2314,10 @@ var TABLE_QUERY_SCHEMA = {
2322
2314
  type: "object",
2323
2315
  additionalProperties: false,
2324
2316
  properties: {
2325
- select: { type: "array", maxItems: 64, uniqueItems: true, items: identifier },
2326
- where: { type: "array", maxItems: 32, items: filterSchema },
2327
- groupBy: { type: "array", maxItems: 16, uniqueItems: true, items: identifier },
2328
- 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: {
2329
2321
  type: "object",
2330
2322
  required: ["fn", "as"],
2331
2323
  additionalProperties: false,
@@ -2335,13 +2327,13 @@ var TABLE_QUERY_SCHEMA = {
2335
2327
  as: identifier
2336
2328
  }
2337
2329
  } },
2338
- orderBy: { type: "array", maxItems: 8, items: {
2330
+ orderBy: { type: "array", items: {
2339
2331
  type: "object",
2340
2332
  required: ["field", "direction"],
2341
2333
  additionalProperties: false,
2342
2334
  properties: { field: identifier, direction: { type: "string", enum: ["asc", "desc"] } }
2343
2335
  } },
2344
- limit: { type: "integer", minimum: 1, maximum: 1e3 }
2336
+ limit: { type: "integer", minimum: 1 }
2345
2337
  }
2346
2338
  }
2347
2339
  }
@@ -2355,7 +2347,7 @@ function validateStageOutputSpec(value, path = "$.output") {
2355
2347
  const schemaError = validateJsonSchemaDefinition(output.schema, `${path}.schema`);
2356
2348
  if (schemaError) return schemaError;
2357
2349
  const sortOrder = output.sortOrder ?? [];
2358
- if (!Array.isArray(sortOrder) || sortOrder.length > 64) return `${path}.sortOrder is invalid`;
2350
+ if (!Array.isArray(sortOrder)) return `${path}.sortOrder is invalid`;
2359
2351
  const keys = /* @__PURE__ */ new Set();
2360
2352
  for (const [index, raw] of sortOrder.entries()) {
2361
2353
  if (!raw || typeof raw !== "object" || Array.isArray(raw)) return `${path}.sortOrder[${index}] is invalid`;
@@ -2476,8 +2468,8 @@ var WEB_FETCH_ARGUMENT_SCHEMA = {
2476
2468
  required: ["url"],
2477
2469
  additionalProperties: false,
2478
2470
  properties: {
2479
- url: { type: "string", minLength: 1, maxLength: 2048 },
2480
- accept: { type: "string", maxLength: 256 }
2471
+ url: { type: "string", minLength: 1 },
2472
+ accept: { type: "string" }
2481
2473
  }
2482
2474
  };
2483
2475
  var WEB_SEARCH_ARGUMENT_SCHEMA = {
@@ -2488,42 +2480,36 @@ var WEB_SEARCH_ARGUMENT_SCHEMA = {
2488
2480
  query: {
2489
2481
  type: "string",
2490
2482
  minLength: 1,
2491
- maxLength: 4096,
2492
2483
  description: "A self-contained description of the information to find."
2493
2484
  },
2494
2485
  searchQueries: {
2495
2486
  type: "array",
2496
2487
  minItems: 1,
2497
- maxItems: 3,
2498
2488
  uniqueItems: true,
2499
2489
  description: "Optional concise keyword queries that narrow the search.",
2500
- items: { type: "string", minLength: 1, maxLength: 256 }
2490
+ items: { type: "string", minLength: 1 }
2501
2491
  },
2502
2492
  maximumResults: {
2503
2493
  type: "integer",
2504
2494
  minimum: 1,
2505
- maximum: 20,
2506
2495
  description: "Maximum number of sources to return."
2507
2496
  },
2508
2497
  maximumCharacters: {
2509
2498
  type: "integer",
2510
- minimum: 1e3,
2511
- maximum: 6e4,
2499
+ minimum: 1,
2512
2500
  description: "Maximum total excerpt characters to return."
2513
2501
  },
2514
2502
  includeDomains: {
2515
2503
  type: "array",
2516
- maxItems: 50,
2517
2504
  uniqueItems: true,
2518
2505
  description: "Optional domains to restrict results to.",
2519
- items: { type: "string", minLength: 1, maxLength: 253 }
2506
+ items: { type: "string", minLength: 1 }
2520
2507
  },
2521
2508
  excludeDomains: {
2522
2509
  type: "array",
2523
- maxItems: 50,
2524
2510
  uniqueItems: true,
2525
2511
  description: "Optional domains to omit.",
2526
- items: { type: "string", minLength: 1, maxLength: 253 }
2512
+ items: { type: "string", minLength: 1 }
2527
2513
  },
2528
2514
  afterDate: {
2529
2515
  type: "string",
@@ -2574,8 +2560,8 @@ var casTool = {
2574
2560
 
2575
2561
  // packages/sdk/src/memory.ts
2576
2562
  var id = { type: "string", pattern: "^[A-Za-z0-9._~-]{1,256}$", maxLength: 256 };
2577
- var content = { type: "string", minLength: 1, maxLength: 65536 };
2578
- var metadata2 = { type: "object", maxProperties: 64 };
2563
+ var content = { type: "string", minLength: 1 };
2564
+ var metadata2 = { type: "object" };
2579
2565
  var scope = { type: "string", pattern: "^[a-f0-9]{64}$", maxLength: 64 };
2580
2566
  var record5 = {
2581
2567
  type: "object",
@@ -2608,13 +2594,13 @@ var MEMORY_OPERATION_DECLARATIONS = [
2608
2594
  type: "object",
2609
2595
  required: ["query"],
2610
2596
  additionalProperties: false,
2611
- 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 }
2612
2598
  },
2613
2599
  resultSchema: {
2614
2600
  type: "object",
2615
2601
  required: ["hits"],
2616
2602
  additionalProperties: false,
2617
- properties: { hits: { type: "array", maxItems: 100, items: {
2603
+ properties: { hits: { type: "array", items: {
2618
2604
  ...record5,
2619
2605
  required: [...record5.required, "score"],
2620
2606
  properties: { ...record5.properties, score: { type: "number", minimum: 0, maximum: 1 } }
@@ -2690,13 +2676,13 @@ var TerminalIntegrationFailure = class extends Error {
2690
2676
  var OPERATION3 = /^[A-Za-z][A-Za-z0-9._-]{0,127}$/u;
2691
2677
  function integrationEgressPolicy(value) {
2692
2678
  const source = value && typeof value === "object" && !Array.isArray(value) ? value : null;
2693
- 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")) {
2694
2680
  throw new TypeError("integration egress policy is invalid");
2695
2681
  }
2696
2682
  const rules = source.rules.map((raw) => {
2697
2683
  const rule = raw && typeof raw === "object" && !Array.isArray(raw) ? raw : null;
2698
2684
  const paths = Number(rule?.pathPrefix !== void 0) + Number(rule?.pathExact !== void 0);
2699
- 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))) {
2700
2686
  throw new TypeError("integration egress rule is invalid");
2701
2687
  }
2702
2688
  let origin;
@@ -2857,7 +2843,7 @@ function absoluteSandboxPath(value) {
2857
2843
  return `/${segments.join("/")}`;
2858
2844
  }
2859
2845
  function normalizeSandboxWorkspacePath(path, cwd = WORKSPACE_ROOT) {
2860
- 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)) {
2861
2847
  throw new TypeError("sandbox workspace path is invalid");
2862
2848
  }
2863
2849
  const base = absoluteSandboxPath(cwd.startsWith("/") ? cwd : `${WORKSPACE_ROOT}/${cwd}`);
@@ -2887,14 +2873,14 @@ var TRAINING_PROVIDER_CAPABILITY = {
2887
2873
  function record6(value) {
2888
2874
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
2889
2875
  }
2890
- function integer(value, field2, minimum, maximum) {
2891
- if (!Number.isSafeInteger(value) || Number(value) < minimum || Number(value) > maximum) {
2876
+ function integer(value, field2, minimum) {
2877
+ if (!Number.isSafeInteger(value) || Number(value) < minimum) {
2892
2878
  throw new TypeError(`${field2} is invalid`);
2893
2879
  }
2894
2880
  return Number(value);
2895
2881
  }
2896
- function finite(value, field2, minimum, maximum) {
2897
- 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) {
2898
2884
  throw new TypeError(`${field2} is invalid`);
2899
2885
  }
2900
2886
  return value;
@@ -2917,7 +2903,7 @@ function resumePoint(value) {
2917
2903
  function trainingProviderMetadata(value) {
2918
2904
  const candidate = record6(value);
2919
2905
  const checkpoints = record6(candidate?.checkpoints);
2920
- 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))) {
2921
2907
  throw new TypeError("Training Provider metadata is invalid");
2922
2908
  }
2923
2909
  const models = candidate.models.map((raw) => {
@@ -2973,25 +2959,25 @@ function trainingRecipe(value) {
2973
2959
  "maxSampleTokens",
2974
2960
  "budgetMicroUsd"
2975
2961
  ];
2976
- 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");
2977
2963
  const recipe = {
2978
2964
  method: candidate.method,
2979
2965
  baseModel: candidate.baseModel,
2980
2966
  dataset: datasetRef(candidate.dataset, "training dataset"),
2981
2967
  validationDataset: candidate.validationDataset === null ? null : datasetRef(candidate.validationDataset, "validation dataset"),
2982
2968
  scorers: candidate.scorers.map((scorer, index) => scorerRef(scorer, `training scorer ${index}`)),
2983
- loraRank: integer(candidate.loraRank, "LoRA rank", 1, 256),
2984
- learningRate: finite(candidate.learningRate, "learning rate", Number.MIN_VALUE, 1),
2985
- epochs: integer(candidate.epochs, "epochs", 1, 100),
2986
- batchSize: integer(candidate.batchSize, "batch size", 1, 256),
2987
- groupSize: integer(candidate.groupSize, "group size", 1, 32),
2988
- temperature: finite(candidate.temperature, "temperature", 0, 2),
2989
- seed: integer(candidate.seed, "seed", 0, 2147483647),
2990
- checkpointEvery: integer(candidate.checkpointEvery, "checkpoint interval", 1, 1e6),
2991
- evalEvery: integer(candidate.evalEvery, "evaluation interval", 1, 1e6),
2992
- maxTrainTokens: integer(candidate.maxTrainTokens, "training token limit", 1, 1e10),
2993
- maxSampleTokens: integer(candidate.maxSampleTokens, "sample token limit", 1, 1e9),
2994
- 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)
2995
2981
  };
2996
2982
  if (recipe.method === "sft" && recipe.groupSize !== 1) throw new TypeError("SFT group size must be 1");
2997
2983
  return recipe;
@@ -3189,16 +3175,21 @@ function costMetadata(usage) {
3189
3175
  };
3190
3176
  }
3191
3177
  function modelProtocolResult(protocol, raw, provider, model) {
3192
- const source = record7(raw) ?? {};
3178
+ const source = record7(raw);
3179
+ if (!source) throw new TypeError("model gateway response is invalid");
3193
3180
  const toolCalls = [];
3194
3181
  let content2 = "";
3182
+ let refusal;
3183
+ let reasoningContent;
3195
3184
  let usage;
3196
3185
  if (protocol === "anthropic") {
3197
- const blocks = Array.isArray(source.content) ? source.content : [];
3186
+ if (!Array.isArray(source.content)) throw new TypeError("Anthropic model response content is invalid");
3187
+ const blocks = source.content;
3198
3188
  content2 = blocks.map((candidate) => {
3199
3189
  const block = record7(candidate);
3200
3190
  if (block?.type === "text" && typeof block.text === "string") return block.text;
3201
- if (block?.type === "tool_use" && typeof block.id === "string" && typeof block.name === "string") {
3191
+ if (block?.type === "tool_use") {
3192
+ if (typeof block.id !== "string" || typeof block.name !== "string") throw new TypeError("Anthropic tool use is invalid");
3202
3193
  toolCalls.push({ id: block.id, name: block.name, args: block.input ?? {} });
3203
3194
  }
3204
3195
  return "";
@@ -3212,13 +3203,19 @@ function modelProtocolResult(protocol, raw, provider, model) {
3212
3203
  ...costMetadata(values)
3213
3204
  };
3214
3205
  } else if (protocol === "openai") {
3215
- const choice = record7(Array.isArray(source.choices) ? source.choices[0] : null) ?? {};
3216
- const message2 = record7(choice.message) ?? {};
3206
+ const choice = record7(Array.isArray(source.choices) ? source.choices[0] : null);
3207
+ const message2 = record7(choice?.message);
3208
+ if (!message2) throw new TypeError("OpenAI-compatible model response message is invalid");
3217
3209
  content2 = typeof message2.content === "string" ? message2.content : "";
3210
+ refusal = typeof message2.refusal === "string" ? message2.refusal : void 0;
3211
+ reasoningContent = typeof message2.reasoning_content === "string" ? message2.reasoning_content : void 0;
3212
+ if (message2.tool_calls !== void 0 && !Array.isArray(message2.tool_calls)) throw new TypeError("OpenAI-compatible tool calls are invalid");
3218
3213
  for (const candidate of Array.isArray(message2.tool_calls) ? message2.tool_calls : []) {
3219
3214
  const call = record7(candidate);
3220
3215
  const fn = record7(call?.function);
3221
- if (typeof call?.id !== "string" || typeof fn?.name !== "string" || typeof fn.arguments !== "string") continue;
3216
+ if (typeof call?.id !== "string" || typeof fn?.name !== "string" || typeof fn.arguments !== "string") {
3217
+ throw new TypeError("OpenAI-compatible tool call is invalid");
3218
+ }
3222
3219
  let args;
3223
3220
  try {
3224
3221
  args = JSON.parse(fn.arguments);
@@ -3235,8 +3232,16 @@ function modelProtocolResult(protocol, raw, provider, model) {
3235
3232
  ...costMetadata(values)
3236
3233
  };
3237
3234
  } else throw new TypeError("model gateway protocol is invalid");
3238
- if (!content2 && toolCalls.length === 0) throw new TypeError("model gateway response had no content or Tool calls");
3239
- return { content: content2, ...toolCalls.length ? { toolCalls } : {}, usage, provider, model, completion: modelCompletionStatus(protocol, raw) };
3235
+ return {
3236
+ content: content2,
3237
+ ...toolCalls.length ? { toolCalls } : {},
3238
+ ...refusal === void 0 ? {} : { refusal },
3239
+ ...reasoningContent === void 0 ? {} : { reasoningContent },
3240
+ usage,
3241
+ provider,
3242
+ model,
3243
+ completion: modelCompletionStatus(protocol, raw)
3244
+ };
3240
3245
  }
3241
3246
  function modelCompletionStatus(protocol, raw) {
3242
3247
  const source = record7(raw) ?? {};
@@ -3268,7 +3273,6 @@ function httpsUrl(value, field2) {
3268
3273
  function slotMetadata(value) {
3269
3274
  if (!value || typeof value !== "object" || Array.isArray(value)) throw new TypeError("Gateway Credential slots are invalid");
3270
3275
  const entries = Object.entries(value);
3271
- if (entries.length > 32) throw new TypeError("Gateway Credential slots are invalid");
3272
3276
  const output = {};
3273
3277
  for (const [slot, raw] of entries) {
3274
3278
  const item = raw && typeof raw === "object" && !Array.isArray(raw) ? raw : null;
@@ -3282,10 +3286,10 @@ function slotMetadata(value) {
3282
3286
  }
3283
3287
  function configEgressBindings(value) {
3284
3288
  if (value === void 0) return [];
3285
- if (!Array.isArray(value) || value.length > 16) throw new TypeError("Gateway config egress bindings are invalid");
3289
+ if (!Array.isArray(value)) throw new TypeError("Gateway config egress bindings are invalid");
3286
3290
  return value.map((raw) => {
3287
3291
  const item = raw && typeof raw === "object" && !Array.isArray(raw) ? raw : null;
3288
- 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))) {
3292
+ 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))) {
3289
3293
  throw new TypeError("Gateway config egress bindings are invalid");
3290
3294
  }
3291
3295
  return {
@@ -3305,7 +3309,7 @@ function discoverySetup(value) {
3305
3309
  }
3306
3310
  function checkpointImportMetadata(value) {
3307
3311
  const source = value && typeof value === "object" && !Array.isArray(value) ? value : null;
3308
- 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))) {
3312
+ 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))) {
3309
3313
  throw new TypeError("Gateway checkpoint import metadata is invalid");
3310
3314
  }
3311
3315
  return { lifecycleVersion: 1, formats: [...source.formats] };
@@ -3322,7 +3326,7 @@ function checkpointImportRequest(value) {
3322
3326
  throw new TypeError("checkpoint import request is invalid");
3323
3327
  }
3324
3328
  try {
3325
- if (new TextEncoder().encode(canonicalJson(artifactValue)).byteLength > 65536) throw new TypeError();
3329
+ canonicalJson(artifactValue);
3326
3330
  } catch {
3327
3331
  throw new TypeError("checkpoint import request is invalid");
3328
3332
  }
@@ -3363,7 +3367,7 @@ function gatewayModelOffer(value) {
3363
3367
  const modalities = (field2) => {
3364
3368
  const values = source[field2];
3365
3369
  if (values === void 0) return void 0;
3366
- 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) {
3370
+ if (!Array.isArray(values) || values.length === 0 || values.some((item) => typeof item !== "string" || !SLOT.test(item)) || new Set(values).size !== values.length) {
3367
3371
  throw new TypeError("Gateway Model offer is invalid");
3368
3372
  }
3369
3373
  return values;
@@ -3396,7 +3400,7 @@ function assertNonSecretGatewayConfig(value, field2 = "config") {
3396
3400
  }
3397
3401
  function gatewayPackageMetadata(value) {
3398
3402
  const source = value && typeof value === "object" && !Array.isArray(value) ? value : null;
3399
- 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.capabilities.length > 32 || !source.billing || typeof source.billing !== "object" || Array.isArray(source.billing) || !["platform", "tenant"].includes(String(source.billing.upstreamPayer ?? ""))) {
3403
+ 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 ?? ""))) {
3400
3404
  throw new TypeError("Gateway package metadata is invalid");
3401
3405
  }
3402
3406
  httpsUrl(source.documentationUrl, "Gateway documentation URL");
@@ -3404,7 +3408,7 @@ function gatewayPackageMetadata(value) {
3404
3408
  const modelOffers = source.modelOffers === void 0 ? [] : Array.isArray(source.modelOffers) ? source.modelOffers.map(gatewayModelOffer) : (() => {
3405
3409
  throw new TypeError("Gateway Model offers are invalid");
3406
3410
  })();
3407
- if (modelOffers.length > 512 || new Set(modelOffers.map((offer) => offer.id)).size !== modelOffers.length) {
3411
+ if (new Set(modelOffers.map((offer) => offer.id)).size !== modelOffers.length) {
3408
3412
  throw new TypeError("Gateway Model offers are invalid");
3409
3413
  }
3410
3414
  const capabilities = source.capabilities.map(capabilityContractRef);
@@ -3577,13 +3581,14 @@ function credentialInteractionEvent(value) {
3577
3581
  if (event.kind === "callback") {
3578
3582
  const parameters = interactionRecord(event.parameters);
3579
3583
  const headers = interactionRecord(event.headers);
3580
- 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))) {
3584
+ 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))) {
3581
3585
  throw new TypeError("credential interaction callback is invalid");
3582
3586
  }
3583
3587
  } else if (event.kind === "submit") {
3584
- if (!exactKeys3(event, ["kind", "value"]) || new TextEncoder().encode(canonicalJson(event.value)).byteLength > 65536) {
3588
+ if (!exactKeys3(event, ["kind", "value"])) {
3585
3589
  throw new TypeError("credential interaction submission is invalid");
3586
3590
  }
3591
+ canonicalJson(event.value);
3587
3592
  } else if (!exactKeys3(event, ["kind"])) throw new TypeError("credential interaction event is invalid");
3588
3593
  return event;
3589
3594
  }
@@ -3637,7 +3642,7 @@ function credentialInteractionAction(value, origins, state, sessionExpiresAt) {
3637
3642
  }
3638
3643
  const schemaError = validateJsonSchemaDefinition(action3.schema, "$interaction.form.schema");
3639
3644
  const formSchema = interactionRecord(action3.schema);
3640
- if (schemaError || !formSchema || formSchema.type !== "object" || formSchema.additionalProperties !== false || new TextEncoder().encode(canonicalJson(action3.schema)).byteLength > 65536) {
3645
+ if (schemaError || !formSchema || formSchema.type !== "object" || formSchema.additionalProperties !== false) {
3641
3646
  throw new TypeError(`credential interaction form schema is invalid${schemaError ? `: ${schemaError}` : ""}`);
3642
3647
  }
3643
3648
  } else if (action3.kind === "display") {
@@ -3660,7 +3665,7 @@ function credentialInteractionResult(value, origins, state, sessionExpiresAt) {
3660
3665
  const result = interactionRecord(value);
3661
3666
  if (!result || !exactKeys3(result, ["action", "privateState"])) throw new TypeError("credential interaction result is invalid");
3662
3667
  const privateState = result.privateState;
3663
- if (privateState !== void 0 && privateState !== null && (typeof privateState !== "string" || new TextEncoder().encode(privateState).byteLength > 1048576)) throw new TypeError("credential interaction private state is invalid");
3668
+ if (privateState !== void 0 && privateState !== null && typeof privateState !== "string") throw new TypeError("credential interaction private state is invalid");
3664
3669
  return {
3665
3670
  action: credentialInteractionAction(result.action, origins, state, sessionExpiresAt),
3666
3671
  ...privateState === void 0 ? {} : { privateState }
@@ -3699,7 +3704,7 @@ function credentialProviderSetupMetadata(value, slots) {
3699
3704
  throw new TypeError("credential provider setup Credential slot documentation URL is invalid");
3700
3705
  }
3701
3706
  }
3702
- if (slot.accept !== void 0 && (!Array.isArray(slot.accept) || slot.accept.length > 16 || slot.accept.some((item) => typeof item !== "string" || !item || item.length > 64))) {
3707
+ if (slot.accept !== void 0 && (!Array.isArray(slot.accept) || slot.accept.some((item) => typeof item !== "string" || !item || item.length > 64))) {
3703
3708
  throw new TypeError("credential provider setup Credential slot file types are invalid");
3704
3709
  }
3705
3710
  }
@@ -3725,12 +3730,12 @@ function credentialProvider(definition) {
3725
3730
  credentialRotationDefaults(definition.rotation);
3726
3731
  credentialProviderConfigSchema(definition.configSchema);
3727
3732
  credentialProviderConfigSchema(definition.credentialConfigSchema);
3728
- 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))) {
3733
+ 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))) {
3729
3734
  throw new TypeError("credential provider bootstrap slots are invalid");
3730
3735
  }
3731
3736
  const setup = credentialProviderSetupMetadata(definition.setup, definition.credentialSlots);
3732
3737
  const interaction = definition.interaction ?? null;
3733
- 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) => {
3738
+ if (interaction && (!Array.isArray(interaction.origins) || interaction.origins.length === 0 || new Set(interaction.origins).size !== interaction.origins.length || interaction.origins.some((origin) => {
3734
3739
  try {
3735
3740
  const url = new URL(origin);
3736
3741
  return url.protocol !== "https:" || url.origin !== origin;
@@ -3764,35 +3769,36 @@ function credentialProvider(definition) {
3764
3769
 
3765
3770
  // packages/sdk/src/evaluation.ts
3766
3771
  var EVALUATION_LIMITS = {
3767
- maxQuestions: 512,
3768
- maxChoiceOptions: 512,
3769
- maxScoreLevels: 128,
3770
- maxDepth: 32,
3771
- /** Bytes of the canonical request body; evaluation models bound state and questions jointly by tokens. */
3772
- maxRequestBytes: 1048576
3772
+ maxQuestions: Number.MAX_SAFE_INTEGER,
3773
+ maxChoiceOptions: Number.MAX_SAFE_INTEGER,
3774
+ maxScoreLevels: Number.MAX_SAFE_INTEGER,
3775
+ maxDepth: Number.MAX_SAFE_INTEGER,
3776
+ /** Compatibility numeric domains, not request quotas; provider limits are reported by the provider. */
3777
+ maxRequestBytes: Number.MAX_SAFE_INTEGER
3773
3778
  };
3774
3779
  var QUESTION_ID = /^[A-Za-z0-9_][A-Za-z0-9_.:-]{0,127}$/u;
3775
3780
  var MODEL = /^[a-z0-9][a-z0-9._\/-]{0,255}$/u;
3776
3781
  function record8(value) {
3777
3782
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
3778
3783
  }
3779
- function entry(value, field2, depth = 0) {
3780
- if (depth > EVALUATION_LIMITS.maxDepth) throw new TypeError(`${field2} nests too deeply`);
3784
+ function entry(value, field2, ancestors = /* @__PURE__ */ new WeakSet()) {
3781
3785
  if (value === null || typeof value === "string" || typeof value === "boolean") return value;
3782
3786
  if (typeof value === "number") {
3783
3787
  if (!Number.isFinite(value)) throw new TypeError(`${field2} must be a finite number`);
3784
3788
  return value;
3785
3789
  }
3786
- if (Array.isArray(value)) return value.map((item, index) => entry(item, `${field2}[${index}]`, depth + 1));
3787
- const source = record8(value);
3790
+ const array = Array.isArray(value);
3791
+ const source = array ? value : record8(value);
3788
3792
  const prototype = source ? Object.getPrototypeOf(source) : void 0;
3789
- if (!source || prototype !== Object.prototype && prototype !== null) throw new TypeError(`${field2} must be JSON text or structure`);
3790
- const output = {};
3791
- for (const [key, item] of Object.entries(source)) {
3792
- if (item === void 0) continue;
3793
- output[key] = entry(item, `${field2}.${key}`, depth + 1);
3793
+ if (!source || !array && prototype !== Object.prototype && prototype !== null) throw new TypeError(`${field2} must be JSON text or structure`);
3794
+ if (ancestors.has(source)) throw new TypeError(`${field2} contains a JSON cycle`);
3795
+ ancestors.add(source);
3796
+ try {
3797
+ if (array) return value.map((item, index) => entry(item, `${field2}[${index}]`, ancestors));
3798
+ return Object.fromEntries(Object.entries(source).filter(([, item]) => item !== void 0).map(([key, item]) => [key, entry(item, `${field2}.${key}`, ancestors)]));
3799
+ } finally {
3800
+ ancestors.delete(source);
3794
3801
  }
3795
- return output;
3796
3802
  }
3797
3803
  function question(id2, value) {
3798
3804
  const source = record8(value);
@@ -3807,14 +3813,12 @@ function question(id2, value) {
3807
3813
  const criteria2 = record8(source.criteria);
3808
3814
  const options = criteria2 ? Object.keys(criteria2) : [];
3809
3815
  if (!criteria2 || options.length < 2) throw new TypeError(`choice question ${id2} needs at least two options`);
3810
- if (options.length > EVALUATION_LIMITS.maxChoiceOptions) throw new TypeError(`choice question ${id2} offers too many options`);
3811
- if (options.some((option) => !option.trim() || option.length > 256)) throw new TypeError(`choice question ${id2} has an invalid option key`);
3816
+ if (options.some((option) => !option.trim())) throw new TypeError(`choice question ${id2} has an invalid option key`);
3812
3817
  return { type, instructions, criteria: Object.fromEntries(options.map((option) => [option, entry(criteria2[option], `choice question ${id2} option ${option}`)])) };
3813
3818
  }
3814
3819
  if (type === "score") {
3815
3820
  const criteria2 = source.criteria;
3816
3821
  if (!Array.isArray(criteria2) || criteria2.length < 2) throw new TypeError(`score question ${id2} needs at least two ordered levels`);
3817
- if (criteria2.length > EVALUATION_LIMITS.maxScoreLevels) throw new TypeError(`score question ${id2} has too many levels`);
3818
3822
  return { type, instructions, criteria: criteria2.map((level, index) => entry(level, `score question ${id2} level ${index}`)) };
3819
3823
  }
3820
3824
  if (source.criteria === void 0) return { type, instructions };
@@ -3835,8 +3839,7 @@ function evaluationArguments(value) {
3835
3839
  const questionSource = record8(source.questions);
3836
3840
  const ids = questionSource ? Object.keys(questionSource) : [];
3837
3841
  if (!questionSource || ids.length === 0) throw new TypeError("evaluation requires at least one question");
3838
- if (ids.length > EVALUATION_LIMITS.maxQuestions) throw new TypeError("evaluation asks too many questions");
3839
- const questions = {};
3842
+ const questions = /* @__PURE__ */ Object.create(null);
3840
3843
  for (const id2 of ids) {
3841
3844
  if (!QUESTION_ID.test(id2)) throw new TypeError(`question id is invalid: ${id2}`);
3842
3845
  questions[id2] = question(id2, questionSource[id2]);
@@ -3849,8 +3852,6 @@ function evaluationArguments(value) {
3849
3852
  model = source.model;
3850
3853
  }
3851
3854
  const output = { ...model === void 0 ? {} : { model }, state, questions };
3852
- const bytes = new TextEncoder().encode(JSON.stringify({ state, questions })).byteLength;
3853
- if (bytes > EVALUATION_LIMITS.maxRequestBytes) throw new TypeError("evaluation state and questions exceed the request size limit");
3854
3855
  return output;
3855
3856
  }
3856
3857
  function evaluationProtocolRequest(protocol, model, args) {
@@ -4079,9 +4080,9 @@ function exactKeys4(value, allowed) {
4079
4080
  }
4080
4081
  function scorerRule(value, depth, state) {
4081
4082
  const rule = record10(value);
4082
- if (!rule || depth > 32 || ++state.rules > 1024 || typeof rule.op !== "string") throw new TypeError("Code Scorer IR is invalid");
4083
+ if (!rule || typeof rule.op !== "string") throw new TypeError("Code Scorer IR is invalid");
4083
4084
  if (rule.op === "all" || rule.op === "any") {
4084
- if (!exactKeys4(rule, ["op", "rules"]) || !Array.isArray(rule.rules) || rule.rules.length < 1 || rule.rules.length > 128) {
4085
+ if (!exactKeys4(rule, ["op", "rules"]) || !Array.isArray(rule.rules) || rule.rules.length < 1) {
4085
4086
  throw new TypeError("Code Scorer logical rule is invalid");
4086
4087
  }
4087
4088
  return { op: rule.op, rules: rule.rules.map((child) => scorerRule(child, depth + 1, state)) };
@@ -4116,7 +4117,7 @@ function scorerRule(value, depth, state) {
4116
4117
  return rule;
4117
4118
  }
4118
4119
  if (rule.op === "tool-sequence") {
4119
- 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");
4120
+ 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");
4120
4121
  return rule;
4121
4122
  }
4122
4123
  if (rule.op === "citations-in-source") {