@constal/sdk 3.10.0 → 3.11.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constal/sdk",
3
- "version": "3.10.0",
3
+ "version": "3.11.0",
4
4
  "description": "Public TypeScript SDK for authoring Constal agents, integrations, policies, channels, and credential providers",
5
5
  "keywords": [
6
6
  "constal",
package/publish/api.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "package": "@constal/sdk",
3
- "version": "3.10.0",
3
+ "version": "3.11.0",
4
4
  "exports": [
5
5
  "AGENT_UI_DEFAULTS",
6
6
  "Action",
@@ -655,7 +655,7 @@ interface ModelGatewayConfig {
655
655
  providerAuth?: ModelCredentialHeader | null;
656
656
  }
657
657
  type NormalizedModelGatewayConfig = Omit<ModelGatewayConfig, "maxOutputTokens" | "temperature" | "gatewayAuth" | "providerAuth"> & {
658
- maxOutputTokens: number;
658
+ maxOutputTokens: number | null;
659
659
  temperature: number | null;
660
660
  gatewayAuth: ModelCredentialHeader | null;
661
661
  providerAuth: ModelCredentialHeader | null;
@@ -702,7 +702,7 @@ declare function modelPrompt(args: ModelInvocationArgs): string;
702
702
  /** The messages of one turn: the static objective and context first, then each earlier exchange as its own message, then
703
703
  * feedback about the previous attempt. Without history this is the single prompt message it always was. */
704
704
  declare function modelMessages(args: ModelInvocationArgs): ModelHistoryMessage[];
705
- declare function modelProtocolRequest(protocol: ModelGatewayProtocol, model: string, maxOutputTokens: number, temperature: number | null, args: ModelInvocationArgs): Record<string, unknown>;
705
+ declare function modelProtocolRequest(protocol: ModelGatewayProtocol, model: string, maxOutputTokens: number | null, temperature: number | null, args: ModelInvocationArgs): Record<string, unknown>;
706
706
  declare function modelProtocolResult(protocol: ModelGatewayProtocol, raw: unknown, provider: string, model: string): ModelInvocationResult;
707
707
 
708
708
  interface GatewayCredentialSlotSetup {
@@ -3271,7 +3271,7 @@ interface SetupSubmission {
3271
3271
  }
3272
3272
  /** A panel names its provider by CRN, or by a platform capability name the platform resolves to one published provider. */
3273
3273
  declare function setupPanelProviderIsCrn(provider: string): boolean;
3274
- /** Validates the bounded presentation artifact consumed by trusted Console renderers. */
3274
+ /** Validates the presentation artifact consumed by trusted Console renderers. */
3275
3275
  declare function setupScreen(value: unknown): SetupScreen;
3276
3276
  /** Validates one response against the exact open screen revision and form schema. */
3277
3277
  declare function setupSubmission(value: unknown, screen: SetupScreen): SetupSubmission;
package/publish/index.js CHANGED
@@ -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;
@@ -600,10 +599,10 @@ function resolveBindingOwner(scope2, context, required2 = true) {
600
599
  return scope2 === "principal" ? { kind: "principal", principal: name } : { kind: "customer", customer: name };
601
600
  }
602
601
  function agentSetupRequirements(value, options = {}) {
603
- if (!Array.isArray(value) || value.length < 1 || value.length > 64) throw new TypeError("Agent setup requirements are invalid");
602
+ if (!Array.isArray(value) || value.length < 1) throw new TypeError("Agent setup requirements are invalid");
604
603
  const requirements = value.map((raw) => {
605
604
  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))) {
605
+ 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
606
  throw new TypeError("Agent setup requirement is invalid");
608
607
  }
609
608
  const selection = resourceSelector({ resourceKind: item.resourceKind, selector: item.selector === void 0 ? {} : item.selector }, RESOURCE_KINDS);
@@ -668,9 +667,9 @@ function agentUiDeclaration(value) {
668
667
  if (!source) agentUiInvalid("expected an object");
669
668
  agentUiKeys(source, ["id", "displayName", "description", "source", "channel", "access", "execution", "limits", "labels"]);
670
669
  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");
670
+ if (typeof source.displayName !== "string" || !source.displayName.trim()) agentUiInvalid("displayName");
672
671
  const description = source.description ?? "";
673
- if (typeof description !== "string" || description.length > 1024) agentUiInvalid("description");
672
+ if (typeof description !== "string") agentUiInvalid("description");
674
673
  const directory = source.source;
675
674
  if (typeof directory !== "string" || !directory || directory.length > 128 || directory.startsWith("/") || directory.includes("\\") || directory.split("/").some((part) => part === "" || part === "." || part === "..")) agentUiInvalid("source");
676
675
  if (AGENT_UI_RESERVED_SOURCE_ROOTS.includes(directory.split("/")[0])) agentUiInvalid("source is a reserved directory");
@@ -891,7 +890,7 @@ function resourceCredentialBinding(value) {
891
890
  function invocationCredentialUses(value) {
892
891
  if (value === void 0) return {};
893
892
  const source = record2(value);
894
- if (!source || Object.keys(source).length > 64) throw new TypeError("invocation Credential selections are invalid");
893
+ if (!source) throw new TypeError("invocation Credential selections are invalid");
895
894
  const result = {};
896
895
  for (const [slot, raw] of Object.entries(source).sort(([left], [right]) => left.localeCompare(right))) {
897
896
  const use = record2(raw), consumer = record2(use?.consumer);
@@ -1048,7 +1047,7 @@ function modelAdvertisedPricing(value) {
1048
1047
  return candidate;
1049
1048
  }
1050
1049
  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");
1050
+ 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
1051
  return need;
1053
1052
  }
1054
1053
  function ipv4(value) {
@@ -1075,7 +1074,7 @@ var RESERVED_IPV4 = [
1075
1074
  [ipv4("240.0.0.0"), 4]
1076
1075
  ];
1077
1076
  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");
1077
+ if (!Array.isArray(values) || values.length === 0) throw new TypeError("sandbox network CIDRs must contain at least one entry");
1079
1078
  const entries = values.map((raw) => {
1080
1079
  if (typeof raw !== "string") throw new TypeError("sandbox network CIDR is invalid");
1081
1080
  const match = raw.trim().match(/^([^/]+)\/(0|[1-9]|[12][0-9]|3[0-2])$/u);
@@ -1101,7 +1100,7 @@ function normalizeCidrs(values, allowPrivate) {
1101
1100
  return result.map((entry2) => entry2.text);
1102
1101
  }
1103
1102
  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");
1103
+ if (!Array.isArray(values) || values.length === 0) throw new TypeError("sandbox network domains must contain at least one entry");
1105
1104
  const domains = values.map((raw) => {
1106
1105
  if (typeof raw !== "string" || raw !== raw.trim() || /[:/?#@]/u.test(raw)) throw new TypeError("sandbox network domain is invalid");
1107
1106
  const wildcard2 = raw.startsWith("*.");
@@ -1488,33 +1487,32 @@ function channelIngressRequest(value) {
1488
1487
 
1489
1488
  // packages/sdk/src/setup-workflow.ts
1490
1489
  var ID = /^[a-z0-9][a-z0-9-]{0,62}$/u;
1491
- var MAX_SCREEN_BYTES = 262144;
1492
1490
  function record3(value) {
1493
1491
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
1494
1492
  }
1495
- function text(value, maximum, allowEmpty = false) {
1496
- return typeof value === "string" && value.length <= maximum && (allowEmpty || value.trim().length > 0) ? value : null;
1493
+ function text(value, allowEmpty = false) {
1494
+ return typeof value === "string" && (allowEmpty || value.trim().length > 0) ? value : null;
1497
1495
  }
1498
1496
  function exact(value, fields) {
1499
1497
  return Object.keys(value).every((key) => fields.includes(key));
1500
1498
  }
1501
1499
  function action2(value) {
1502
1500
  const source = record3(value);
1503
- const id2 = text(source?.id, 63);
1504
- const label = text(source?.label, 128);
1501
+ const id2 = text(source?.id);
1502
+ const label = text(source?.label);
1505
1503
  if (!source || !id2 || !ID.test(id2) || !label || !["primary", "secondary", "danger"].includes(String(source.intent)) || !exact(source, ["id", "label", "intent"])) return null;
1506
1504
  return { id: id2, label, intent: source.intent };
1507
1505
  }
1508
1506
  function actions(value) {
1509
- if (!Array.isArray(value) || value.length > 8) return null;
1507
+ if (!Array.isArray(value)) return null;
1510
1508
  const parsed = value.map(action2);
1511
1509
  if (parsed.some((item) => !item) || new Set(parsed.map((item) => item.id)).size !== parsed.length) return null;
1512
1510
  return parsed;
1513
1511
  }
1514
1512
  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);
1513
+ const id2 = text(source.id);
1514
+ const title = text(source.title);
1515
+ const description = text(source.description, true);
1518
1516
  const parsedActions = actions(source.actions);
1519
1517
  return id2 && ID.test(id2) && title && description !== null && parsedActions ? { id: id2, title, description, actions: parsedActions } : null;
1520
1518
  }
@@ -1526,12 +1524,12 @@ function panel(value) {
1526
1524
  if (source.kind === "form") {
1527
1525
  const schema = record3(source.schema);
1528
1526
  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;
1527
+ 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
1528
  return { ...base, kind: "form", schema, ...initialValues ? { initialValues } : {} };
1531
1529
  }
1532
1530
  if (source.kind === "credential-interaction") {
1533
- const provider = text(source.provider, 1024);
1534
- const credentialId = text(source.credentialId, 63);
1531
+ const provider = text(source.provider);
1532
+ const credentialId = text(source.credentialId);
1535
1533
  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
1534
  if (setupPanelProviderIsCrn(provider)) {
1537
1535
  try {
@@ -1569,18 +1567,18 @@ function panel(value) {
1569
1567
  };
1570
1568
  }
1571
1569
  if (source.kind === "review") {
1572
- if (!Array.isArray(source.sections) || source.sections.length > 32 || !exact(source, ["kind", "id", "title", "description", "actions", "sections"])) return null;
1570
+ if (!Array.isArray(source.sections) || !exact(source, ["kind", "id", "title", "description", "actions", "sections"])) return null;
1573
1571
  const sections = [];
1574
1572
  for (const rawSection of source.sections) {
1575
1573
  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;
1574
+ const id2 = text(section?.id);
1575
+ const title = text(section?.title);
1576
+ if (!section || !id2 || !ID.test(id2) || !title || !Array.isArray(section.rows) || !exact(section, ["id", "title", "rows"])) return null;
1579
1577
  const rows = [];
1580
1578
  for (const rawRow of section.rows) {
1581
1579
  const row = record3(rawRow);
1582
- const label = text(row?.label, 256);
1583
- const rowValue = text(row?.value, 8192, true);
1580
+ const label = text(row?.label);
1581
+ const rowValue = text(row?.value, true);
1584
1582
  if (!row || !label || rowValue === null || row.tone !== void 0 && !["default", "muted", "warning"].includes(String(row.tone)) || !exact(row, ["label", "value", "tone"])) return null;
1585
1583
  rows.push({ label, value: rowValue, ...row.tone ? { tone: row.tone } : {} });
1586
1584
  }
@@ -1589,27 +1587,27 @@ function panel(value) {
1589
1587
  return { ...base, kind: "review", sections };
1590
1588
  }
1591
1589
  if (source.kind === "progress") {
1592
- if (!Array.isArray(source.progress) || source.progress.length > 64 || !exact(source, ["kind", "id", "title", "description", "actions", "progress"])) return null;
1590
+ if (!Array.isArray(source.progress) || !exact(source, ["kind", "id", "title", "description", "actions", "progress"])) return null;
1593
1591
  const progress = [];
1594
1592
  for (const rawItem of source.progress) {
1595
1593
  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);
1594
+ const id2 = text(item?.id);
1595
+ const label = text(item?.label);
1596
+ const detail = item?.detail === void 0 ? void 0 : text(item.detail, true);
1599
1597
  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
1598
  progress.push({ id: id2, label, status: item.status, ...detail === void 0 ? {} : { detail } });
1601
1599
  }
1602
1600
  return { ...base, kind: "progress", progress };
1603
1601
  }
1604
1602
  if (source.kind === "complete" || source.kind === "blocked") {
1605
- const summary = text(source.summary, 8192);
1603
+ const summary = text(source.summary);
1606
1604
  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;
1605
+ if (!summary || !Array.isArray(details) || !exact(source, ["kind", "id", "title", "description", "actions", "summary", "details"])) return null;
1608
1606
  const parsedDetails = [];
1609
1607
  for (const rawDetail of details) {
1610
1608
  const detail = record3(rawDetail);
1611
- const label = text(detail?.label, 256);
1612
- const detailValue = text(detail?.value, 8192, true);
1609
+ const label = text(detail?.label);
1610
+ const detailValue = text(detail?.value, true);
1613
1611
  if (!detail || !label || detailValue === null || !exact(detail, ["label", "value"])) return null;
1614
1612
  parsedDetails.push({ label, value: detailValue });
1615
1613
  }
@@ -1624,14 +1622,14 @@ function setupScreen(value) {
1624
1622
  const source = record3(value);
1625
1623
  const workflow = record3(source?.workflow);
1626
1624
  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"])) {
1625
+ 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
1626
  throw new TypeError("Setup screen is invalid");
1629
1627
  }
1630
1628
  const parsedSteps = [];
1631
1629
  for (const rawStep of source.steps) {
1632
1630
  const step = record3(rawStep);
1633
- const id2 = text(step?.id, 63);
1634
- const label = text(step?.label, 128);
1631
+ const id2 = text(step?.id);
1632
+ const label = text(step?.label);
1635
1633
  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
1634
  parsedSteps.push({ id: id2, label, status: step.status, ...step.optional === void 0 ? {} : { optional: step.optional } });
1637
1635
  }
@@ -1648,7 +1646,6 @@ function setupScreen(value) {
1648
1646
  current,
1649
1647
  waitLabel: source.waitLabel === null ? null : String(source.waitLabel)
1650
1648
  };
1651
- if (new TextEncoder().encode(canonicalJson(normalized)).byteLength > MAX_SCREEN_BYTES) throw new TypeError("Setup screen exceeds 256 KiB");
1652
1649
  return normalized;
1653
1650
  }
1654
1651
  function setupSubmission(value, screen) {
@@ -3034,11 +3031,11 @@ var MODEL_EVALUATION_CAPABILITY = {
3034
3031
  };
3035
3032
  function modelGenerationOptions(source) {
3036
3033
  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");
3034
+ if (maxOutputTokens !== void 0 && (!Number.isSafeInteger(maxOutputTokens) || maxOutputTokens < 1)) {
3035
+ throw new TypeError("maxOutputTokens must be a positive safe integer");
3039
3036
  }
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");
3037
+ if (temperature !== void 0 && (typeof temperature !== "number" || !Number.isFinite(temperature))) {
3038
+ throw new TypeError("temperature must be a finite number");
3042
3039
  }
3043
3040
  if (effort !== void 0 && (typeof effort !== "string" || !effort.trim())) {
3044
3041
  throw new TypeError("effort must be a nonempty model-supported string");
@@ -3063,12 +3060,12 @@ function credentialHeader(value, name) {
3063
3060
  }
3064
3061
  function normalizeModelGatewayConfig(value) {
3065
3062
  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) {
3063
+ if (!source || typeof source.baseUrl !== "string" || source.protocol !== "anthropic" && source.protocol !== "openai" || typeof source.model !== "string" || source.model.length === 0) {
3067
3064
  throw new TypeError("model gateway config is invalid");
3068
3065
  }
3069
- const maxOutputTokens = source.maxOutputTokens === void 0 ? 256 : Number(source.maxOutputTokens);
3066
+ const maxOutputTokens = source.maxOutputTokens === void 0 ? null : Number(source.maxOutputTokens);
3070
3067
  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)) {
3068
+ if (maxOutputTokens !== null && (!Number.isSafeInteger(maxOutputTokens) || maxOutputTokens < 1) || temperature !== null && !Number.isFinite(temperature)) {
3072
3069
  throw new TypeError("model gateway generation limits are invalid");
3073
3070
  }
3074
3071
  const normalized = {
@@ -3156,7 +3153,7 @@ function modelProtocolRequest(protocol, model, maxOutputTokens, temperature, arg
3156
3153
  model,
3157
3154
  system: args.system ?? "",
3158
3155
  messages: alternating(messages),
3159
- max_tokens: maxOutputTokens,
3156
+ ...maxOutputTokens === null ? {} : { max_tokens: maxOutputTokens },
3160
3157
  ...effort === void 0 ? {} : { output_config: { effort } },
3161
3158
  ...temperature === null ? {} : { temperature },
3162
3159
  ...args.tools?.length ? { tools: args.tools.map((tool) => ({ name: tool.name, description: tool.description, input_schema: tool.schema })) } : {},
@@ -3168,7 +3165,7 @@ function modelProtocolRequest(protocol, model, maxOutputTokens, temperature, arg
3168
3165
  ...args.system ? [{ role: "developer", content: args.system }] : [],
3169
3166
  ...messages
3170
3167
  ],
3171
- max_completion_tokens: maxOutputTokens,
3168
+ ...maxOutputTokens === null ? {} : { max_completion_tokens: maxOutputTokens },
3172
3169
  ...effort === void 0 ? {} : { reasoning_effort: effort },
3173
3170
  ...temperature === null ? {} : { temperature },
3174
3171
  ...args.tools?.length ? { tools: args.tools.map((tool) => ({
@@ -3275,7 +3272,7 @@ function slotMetadata(value) {
3275
3272
  const output = {};
3276
3273
  for (const [slot, raw] of entries) {
3277
3274
  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))) {
3275
+ 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
3276
  throw new TypeError("Gateway Credential slots are invalid");
3280
3277
  }
3281
3278
  httpsUrl(item.documentationUrl, "Gateway Credential slot documentation URL");
@@ -3321,7 +3318,7 @@ function checkpointImportRequest(value) {
3321
3318
  const artifact = source?.artifact && typeof source.artifact === "object" && !Array.isArray(source.artifact) ? source.artifact : null;
3322
3319
  const artifactValue = artifact?.value && typeof artifact.value === "object" && !Array.isArray(artifact.value) ? artifact.value : null;
3323
3320
  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))) {
3321
+ 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
3322
  throw new TypeError("checkpoint import request is invalid");
3326
3323
  }
3327
3324
  try {
@@ -3352,7 +3349,7 @@ function checkpointDeploymentRequest(value) {
3352
3349
  var MODEL_ID_CONTROL = /[\u0000-\u001f\u007f]/u;
3353
3350
  function gatewayModelOffer(value) {
3354
3351
  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) => ![
3352
+ 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
3353
  "id",
3357
3354
  "displayName",
3358
3355
  "contextTokens",
@@ -3399,7 +3396,7 @@ function assertNonSecretGatewayConfig(value, field2 = "config") {
3399
3396
  }
3400
3397
  function gatewayPackageMetadata(value) {
3401
3398
  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 ?? ""))) {
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
3400
  throw new TypeError("Gateway package metadata is invalid");
3404
3401
  }
3405
3402
  httpsUrl(source.documentationUrl, "Gateway documentation URL");
@@ -3565,8 +3562,8 @@ function interactionRecord(value) {
3565
3562
  function exactKeys3(value, allowed) {
3566
3563
  return Object.keys(value).every((key) => allowed.includes(key));
3567
3564
  }
3568
- function boundedText(value, maximum) {
3569
- return typeof value === "string" && value.length > 0 && value.length <= maximum;
3565
+ function nonemptyText(value) {
3566
+ return typeof value === "string" && value.length > 0;
3570
3567
  }
3571
3568
  function interactionExpiry(value, sessionExpiresAt) {
3572
3569
  if (value === void 0 || value === null) return null;
@@ -3593,13 +3590,13 @@ function credentialInteractionEvent(value) {
3593
3590
  function credentialInteractionPrimaryAction(value, origins) {
3594
3591
  const action3 = interactionRecord(value);
3595
3592
  const event = interactionRecord(action3?.event);
3596
- if (!action3 || !event || !boundedText(action3.label, 64) || !exactKeys3(event, ["kind"]) || event.kind !== "continue") {
3593
+ if (!action3 || !event || !nonemptyText(action3.label) || !exactKeys3(event, ["kind"]) || event.kind !== "continue") {
3597
3594
  throw new TypeError("credential interaction primary action is invalid");
3598
3595
  }
3599
3596
  if (action3.kind === "continue") {
3600
3597
  if (!exactKeys3(action3, ["kind", "label", "event"])) throw new TypeError("credential interaction primary action is invalid");
3601
3598
  } else if (action3.kind === "open-url") {
3602
- if (!exactKeys3(action3, ["kind", "label", "url", "event"]) || !boundedText(action3.url, 4096)) {
3599
+ if (!exactKeys3(action3, ["kind", "label", "url", "event"]) || !nonemptyText(action3.url)) {
3603
3600
  throw new TypeError("credential interaction primary action is invalid");
3604
3601
  }
3605
3602
  let url;
@@ -3622,7 +3619,7 @@ function credentialInteractionAction(value, origins, state, sessionExpiresAt) {
3622
3619
  const expiresAt = action3.kind === "complete" ? null : interactionExpiry(action3.expiresAt, sessionExpiresAt);
3623
3620
  if (Number.isNaN(expiresAt)) throw new TypeError("credential interaction action expiry is invalid");
3624
3621
  if (action3.kind === "redirect") {
3625
- if (!exactKeys3(action3, ["kind", "url", "expiresAt"]) || !boundedText(action3.url, 4096)) {
3622
+ if (!exactKeys3(action3, ["kind", "url", "expiresAt"]) || !nonemptyText(action3.url)) {
3626
3623
  throw new TypeError("credential interaction redirect is invalid");
3627
3624
  }
3628
3625
  let url;
@@ -3635,7 +3632,7 @@ function credentialInteractionAction(value, origins, state, sessionExpiresAt) {
3635
3632
  throw new TypeError("credential interaction redirect is not authorized");
3636
3633
  }
3637
3634
  } 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)) {
3635
+ 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
3636
  throw new TypeError("credential interaction form is invalid");
3640
3637
  }
3641
3638
  const schemaError = validateJsonSchemaDefinition(action3.schema, "$interaction.form.schema");
@@ -3644,7 +3641,7 @@ function credentialInteractionAction(value, origins, state, sessionExpiresAt) {
3644
3641
  throw new TypeError(`credential interaction form schema is invalid${schemaError ? `: ${schemaError}` : ""}`);
3645
3642
  }
3646
3643
  } 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)) {
3644
+ 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
3645
  throw new TypeError("credential interaction display is invalid");
3649
3646
  }
3650
3647
  credentialInteractionPrimaryAction(action3.primaryAction, origins);
@@ -3653,7 +3650,7 @@ function credentialInteractionAction(value, origins, state, sessionExpiresAt) {
3653
3650
  throw new TypeError("credential interaction wait action is invalid");
3654
3651
  }
3655
3652
  } 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())) {
3653
+ 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
3654
  throw new TypeError("credential interaction completion is invalid");
3658
3655
  }
3659
3656
  }
@@ -3688,7 +3685,7 @@ function credentialProviderSetupMetadata(value, slots) {
3688
3685
  }
3689
3686
  const slot = declaration;
3690
3687
  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))) {
3688
+ 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
3689
  throw new TypeError("credential provider setup Credential slots are invalid");
3693
3690
  }
3694
3691
  if (slot.documentationUrl !== void 0) {
@@ -3710,7 +3707,7 @@ function credentialProviderSetupMetadata(value, slots) {
3710
3707
  return value;
3711
3708
  }
3712
3709
  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") {
3710
+ 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
3711
  throw new TypeError("credential provider metadata is invalid");
3715
3712
  }
3716
3713
  if (definition.documentationUrl !== void 0) {