@corca-org/ceal-host-win32-x64 1.0.4 → 1.0.6

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.
@@ -146,6 +146,7 @@ var CEAL_OPERATION_RECOVERY_KINDS = vocabulary(["none", "reconcile", "compensate
146
146
  var CEAL_OPERATION_RECOVERY_STATUSES = vocabulary(["not_started", "active", "completed"]);
147
147
  var CEAL_OPERATION_PROVIDER_READBACK_AVAILABILITY = vocabulary(["not_started", "not_applicable", "not_available", "pending", "available"]);
148
148
  var CEAL_OPERATION_OFFERED_HANDOFF_STATES = vocabulary(["accepted", "rejected", "unknown"]);
149
+ var CEAL_OPERATION_RECEIPT_AUTHORITY_KEYS = Object.freeze(["instance_ref", "profile_ref", "principal_ref", "execution_subject_ref", "authority_revision_ref"]);
149
150
  var CEAL_OPERATION_APPROVAL_DISPOSITIONS = vocabulary([
150
151
  "approval_not_required_by_policy",
151
152
  "interactive_pending",
@@ -402,7 +403,13 @@ var CEAL_OPERATION_JSON_SCHEMA_BUDGET = Object.freeze({
402
403
  max_string_length: OPERATION_SCHEMA_LITERAL_MAX_BYTES / 4,
403
404
  max_alternatives: 8,
404
405
  max_enum_values: 64,
405
- max_literal_bytes: OPERATION_SCHEMA_LITERAL_MAX_BYTES
406
+ max_literal_bytes: OPERATION_SCHEMA_LITERAL_MAX_BYTES,
407
+ /** @basis our_policy -- bounds explanatory schema prose carried in one catalog. */
408
+ max_description_characters: 1024,
409
+ /** @basis our_policy -- bounds regular-expression compilation input from one schema. */
410
+ max_pattern_characters: 256,
411
+ /** @basis our_policy -- bounds traversal work inside one already byte-bounded schema literal. */
412
+ max_literal_nodes: 512
406
413
  });
407
414
 
408
415
  // packages/ceal-client-protocol/src/operation-validation-primitives.ts
@@ -422,6 +429,9 @@ function requireIsoTimestamp(value, message) {
422
429
  if (typeof value !== "string" || !ISO_TIMESTAMP.test(value) || !Number.isFinite(Date.parse(value))) throw new TypeError(message);
423
430
  }
424
431
 
432
+ // packages/ceal-client-protocol/src/operation-json-schema.ts
433
+ var JSON_DESCRIPTION_CONTROL_CHARACTER = new RegExp("\\p{Cc}", "u");
434
+
425
435
  // packages/ceal-client-protocol/src/operation-contract-validation.ts
426
436
  var CEAL_OPERATION_AUTHORITY_POLICY_KEYS = Object.freeze(["profile", "instance_binding", "target", "admission_recheck"]);
427
437
  var MAX_OPERATION_INPUT_RESOLVER_BINDINGS = 96;
@@ -522,7 +532,6 @@ var CEAL_BOUNDED_SERIES_CATALOG = Object.freeze({
522
532
  control_commit: (root) => join(root, "control-auto-commit.jsonl"),
523
533
  engagement_signal: (root) => join(root, "runtime-state", "slack-feedback.jsonl"),
524
534
  runtime_error: (root) => join(root, "runtime-state", "runtime-errors.jsonl"),
525
- provider_retry: (root) => join(root, "observability", "provider-retry-queue", "queue.jsonl"),
526
535
  turn_bridge_request: (root) => join(root, ".ceal", "turn-bridge", "requests.jsonl"),
527
536
  channel_log: (root) => join(root, "log.jsonl"),
528
537
  thread_run_events: (root) => join(root, "run-events.jsonl"),
@@ -531,8 +540,6 @@ var CEAL_BOUNDED_SERIES_CATALOG = Object.freeze({
531
540
  gateway_capability_audit: (root) => join(root, "capability-audit.jsonl"),
532
541
  gateway_retrieval_waste_partition: (root) => `${root}.jsonl`,
533
542
  gateway_access_policy_publication: (root) => join(root, "access-policy-publications.jsonl"),
534
- gateway_event_lease_journal: (root) => `${root}.journal.jsonl`,
535
- gateway_control_audit: (root) => `${root}.control-audits.jsonl`,
536
543
  gateway_profile_connector_control_audit: (root) => `${root}.audit.jsonl`,
537
544
  gateway_profile_connector_scope_audit: (root) => join(root, "profile-connector-scope-audit.jsonl"),
538
545
  gateway_profile_connector_activity_scope_audit: (root) => join(root, "profile-connector-activity-scope-audit.jsonl"),
@@ -547,6 +554,11 @@ var CEAL_BOUNDED_SERIES_CATALOG = Object.freeze({
547
554
  gateway_admin_access_token: (root) => join(root, "access-tokens.jsonl")
548
555
  });
549
556
 
557
+ // packages/ceal-client-protocol/src/gateway-installation-activation.ts
558
+ var CEAL_GATEWAY_INSTALLATION_ACTIVATION_CODE_DATA_CHARACTERS = 32;
559
+ var CEAL_GATEWAY_INSTALLATION_ACTIVATION_CODE_CHECK_CHARACTERS = 8;
560
+ var CEAL_GATEWAY_INSTALLATION_ACTIVATION_CODE_COMPACT_CHARACTERS = CEAL_GATEWAY_INSTALLATION_ACTIVATION_CODE_DATA_CHARACTERS + CEAL_GATEWAY_INSTALLATION_ACTIVATION_CODE_CHECK_CHARACTERS;
561
+
550
562
  // packages/ceal-client-protocol/src/host-registration.ts
551
563
  var CEAL_HOST_REGISTRATION_RESULT_KEYS = Object.freeze(["credential_generation", "host_access_token", "host_installation_ref", "host_source_ref", "ok", "registration_attempt_ref", "schema_version", "status"]);
552
564
 
@@ -1115,7 +1127,7 @@ var CEAL_ACTOR_KINDS = vocabulary(["human", "bot", "app", "unknown"]);
1115
1127
  // packages/ceal-client-protocol/src/leased-consumer-vocabulary.ts
1116
1128
  var CEAL_TERMINAL_DISPOSITIONS = vocabulary(["completed", "failed", "cancelled"]);
1117
1129
  var CEAL_LEASE_DISPOSITIONS = vocabulary([...CEAL_TERMINAL_DISPOSITIONS, "deferred"]);
1118
- var CEAL_AUTOMATIC_FEEDBACK_INTENTS = vocabulary(["reaction", "progress_start", "progress_finish"]);
1130
+ var CEAL_AUTOMATIC_FEEDBACK_INTENTS = vocabulary(["initial"]);
1119
1131
  var CEAL_LEASED_MESSAGE_DELIVERY_CAPABILITY_IDS = vocabulary(["message.create", "message.update", "message.delete"]);
1120
1132
  var CEAL_REPOSITORY_VISIBILITIES = vocabulary(["public", "private", "internal"]);
1121
1133
  var CEAL_RESULT_DELIVERY_OFFERS = vocabulary(["pending", "offered", "transport_lost"]);
@@ -1255,6 +1267,7 @@ function isAbsoluteNormalizedNonRootPath(value, flavor = process.platform, allow
1255
1267
  // host/producer-service.ts
1256
1268
  var MAX_CONFIG_BYTES = 32 * 1024;
1257
1269
  var SAFE_REF2 = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u;
1270
+ var HOST_PRODUCER_SERVE_COMMAND_PREFIX = ["serve", "--config"];
1258
1271
  var HostProducerServiceError = class extends Error {
1259
1272
  code;
1260
1273
  constructor(code3, message = code3) {
@@ -1286,7 +1299,7 @@ function hostProducerError(code3, message = code3) {
1286
1299
  return new HostProducerServiceError(code3, message);
1287
1300
  }
1288
1301
  function parseProducerServeArgs(args, platform, error) {
1289
- if (args.length !== 3 || args[0] !== "serve" || args[1] !== "--config") throw error("invalid_arguments", refusalFact("args", args, "serve --config <absolute path>"));
1302
+ if (args.length !== HOST_PRODUCER_SERVE_COMMAND_PREFIX.length + 1 || args[0] !== HOST_PRODUCER_SERVE_COMMAND_PREFIX[0] || args[1] !== HOST_PRODUCER_SERVE_COMMAND_PREFIX[1]) throw error("invalid_arguments", refusalFact("args", args, "serve --config <absolute path>"));
1290
1303
  assertProducerAbsolutePath(args[2], platform, "config", error);
1291
1304
  return args[2];
1292
1305
  }
@@ -1420,6 +1433,7 @@ function boundedMilliseconds(value) {
1420
1433
  // host/relay/src/producer-frame.ts
1421
1434
  var HOST_PRODUCER_FRAME_SCHEMA = "ceal.host_producer_frame.v1";
1422
1435
  var HOST_PRODUCER_MAX_JSON_BYTES = 262144;
1436
+ var HOST_PRODUCER_FRAME_LENGTH_BYTES = Uint32Array.BYTES_PER_ELEMENT;
1423
1437
  var SAFE_REF3 = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u;
1424
1438
  var PRODUCERS = /* @__PURE__ */ new Set(["codex", "claude"]);
1425
1439
  var HOST_PRODUCER_FRAME_KINDS = ["session_started", "turn_started", "user_input", "turn_terminal", "producer_status"];
@@ -1438,18 +1452,18 @@ function encodeHostProducerFrame(frame) {
1438
1452
  validateFrame(frame);
1439
1453
  const json = Buffer.from(JSON.stringify(frame), "utf8");
1440
1454
  if (json.byteLength > HOST_PRODUCER_MAX_JSON_BYTES) throw new HostProducerFrameError("frame_too_large", `frame_too_large: ${refusalFact("frame_bytes", json.byteLength, `at most ${HOST_PRODUCER_MAX_JSON_BYTES}`)}`);
1441
- const result = Buffer.allocUnsafe(json.byteLength + 4);
1455
+ const result = Buffer.allocUnsafe(json.byteLength + HOST_PRODUCER_FRAME_LENGTH_BYTES);
1442
1456
  result.writeUInt32BE(json.byteLength, 0);
1443
- json.copy(result, 4);
1457
+ json.copy(result, HOST_PRODUCER_FRAME_LENGTH_BYTES);
1444
1458
  return result;
1445
1459
  }
1446
1460
  function decodeHostProducerFrame(input) {
1447
- if (input.byteLength < 4) throw new HostProducerFrameError("frame_truncated", `frame_truncated: ${refusalFact("frame_bytes", input.byteLength, "at least 4")}`);
1461
+ if (input.byteLength < HOST_PRODUCER_FRAME_LENGTH_BYTES) throw new HostProducerFrameError("frame_truncated", `frame_truncated: ${refusalFact("frame_bytes", input.byteLength, `at least ${HOST_PRODUCER_FRAME_LENGTH_BYTES}`)}`);
1448
1462
  const length = input.readUInt32BE(0);
1449
1463
  if (length > HOST_PRODUCER_MAX_JSON_BYTES) throw new HostProducerFrameError("frame_too_large", `frame_too_large: ${refusalFact("declared_bytes", length, `at most ${HOST_PRODUCER_MAX_JSON_BYTES}`)}`);
1450
1464
  if (length === 0) throw new HostProducerFrameError("invalid_frame_length");
1451
- if (input.byteLength !== length + 4) throw new HostProducerFrameError(input.byteLength < length + 4 ? "frame_truncated" : "invalid_frame_length");
1452
- const bytes = input.subarray(4);
1465
+ if (input.byteLength !== length + HOST_PRODUCER_FRAME_LENGTH_BYTES) throw new HostProducerFrameError(input.byteLength < length + HOST_PRODUCER_FRAME_LENGTH_BYTES ? "frame_truncated" : "invalid_frame_length");
1466
+ const bytes = input.subarray(HOST_PRODUCER_FRAME_LENGTH_BYTES);
1453
1467
  const text = new TextDecoder("utf-8", { fatal: true });
1454
1468
  let value;
1455
1469
  try {
@@ -1663,6 +1677,8 @@ var HOST_RELAY_REQUEST_BINDING_KEYS = Object.freeze([
1663
1677
  "host_input_ref"
1664
1678
  ]);
1665
1679
  var HOST_RELAY_IPC_RESPONSE_SCHEMA = "ceal.host_relay_admission.v1";
1680
+ var HOST_RELAY_IPC_LENGTH_BYTES = Uint32Array.BYTES_PER_ELEMENT;
1681
+ var HOST_RELAY_ADMISSION_RESPONSE_MAX_BYTES = 4096;
1666
1682
  var HostRelayIpcError = class extends Error {
1667
1683
  code;
1668
1684
  constructor(code3, message = code3) {
@@ -1716,12 +1732,12 @@ function exchange(endpoint, encoded, timeoutMs, decode) {
1716
1732
  });
1717
1733
  }
1718
1734
  function decodeHostRelayIpcResponse(input) {
1719
- if (input.length < 4) throw new HostRelayIpcError("relay_unavailable", `Host Relay IPC response is truncated: ${refusalFact("response_bytes", input.byteLength, "at least 4")}.`);
1735
+ if (input.length < HOST_RELAY_IPC_LENGTH_BYTES) throw new HostRelayIpcError("relay_unavailable", `Host Relay IPC response is truncated: ${refusalFact("response_bytes", input.byteLength, `at least ${HOST_RELAY_IPC_LENGTH_BYTES}`)}.`);
1720
1736
  const length = input.readUInt32BE(0);
1721
- if (length === 0 || length > 4096 || input.length !== length + 4) throw new HostRelayIpcError("relay_unavailable", `Host Relay IPC response length is invalid: ${refusalFacts([{ name: "declared_bytes", value: length, expected: "between 1 and 4096" }, { name: "received_bytes", value: input.byteLength, expected: `exactly ${length + 4}` }])}.`);
1737
+ if (length === 0 || length > HOST_RELAY_ADMISSION_RESPONSE_MAX_BYTES || input.length !== length + HOST_RELAY_IPC_LENGTH_BYTES) throw new HostRelayIpcError("relay_unavailable", `Host Relay IPC response length is invalid: ${refusalFacts([{ name: "declared_bytes", value: length, expected: `between 1 and ${HOST_RELAY_ADMISSION_RESPONSE_MAX_BYTES}` }, { name: "received_bytes", value: input.byteLength, expected: `exactly ${length + HOST_RELAY_IPC_LENGTH_BYTES}` }])}.`);
1722
1738
  let value;
1723
1739
  try {
1724
- value = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(input.subarray(4)));
1740
+ value = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(input.subarray(HOST_RELAY_IPC_LENGTH_BYTES)));
1725
1741
  } catch {
1726
1742
  throw new HostRelayIpcError("relay_unavailable", "Host Relay IPC response is invalid.");
1727
1743
  }
@@ -1744,11 +1760,11 @@ function record2(value) {
1744
1760
  return value !== null && typeof value === "object" && !Array.isArray(value);
1745
1761
  }
1746
1762
  function decodeResponseBuffer(buffer) {
1747
- if (buffer.length < 4) return null;
1763
+ if (buffer.length < HOST_RELAY_IPC_LENGTH_BYTES) return null;
1748
1764
  const length = buffer.readUInt32BE(0);
1749
- if (length === 0 || length > 4096) throw new HostRelayIpcError("relay_unavailable", `Host Relay IPC response length is invalid: ${refusalFact("declared_bytes", length, "between 1 and 4096")}.`);
1750
- if (buffer.length < length + 4) return null;
1751
- if (buffer.length !== length + 4) throw new HostRelayIpcError("relay_unavailable", `Host Relay IPC returned trailing bytes: ${refusalFacts([{ name: "declared_bytes", value: length, expected: "the received message length minus 4" }, { name: "received_bytes", value: buffer.byteLength, expected: `exactly ${length + 4}` }])}.`);
1765
+ if (length === 0 || length > HOST_RELAY_ADMISSION_RESPONSE_MAX_BYTES) throw new HostRelayIpcError("relay_unavailable", `Host Relay IPC response length is invalid: ${refusalFact("declared_bytes", length, `between 1 and ${HOST_RELAY_ADMISSION_RESPONSE_MAX_BYTES}`)}.`);
1766
+ if (buffer.length < length + HOST_RELAY_IPC_LENGTH_BYTES) return null;
1767
+ if (buffer.length !== length + HOST_RELAY_IPC_LENGTH_BYTES) throw new HostRelayIpcError("relay_unavailable", `Host Relay IPC returned trailing bytes: ${refusalFacts([{ name: "declared_bytes", value: length, expected: `the received message length minus ${HOST_RELAY_IPC_LENGTH_BYTES}` }, { name: "received_bytes", value: buffer.byteLength, expected: `exactly ${length + HOST_RELAY_IPC_LENGTH_BYTES}` }])}.`);
1752
1768
  return decodeHostRelayIpcResponse(buffer);
1753
1769
  }
1754
1770
 
@@ -156,6 +156,7 @@ var CEAL_OPERATION_RECOVERY_KINDS = vocabulary(["none", "reconcile", "compensate
156
156
  var CEAL_OPERATION_RECOVERY_STATUSES = vocabulary(["not_started", "active", "completed"]);
157
157
  var CEAL_OPERATION_PROVIDER_READBACK_AVAILABILITY = vocabulary(["not_started", "not_applicable", "not_available", "pending", "available"]);
158
158
  var CEAL_OPERATION_OFFERED_HANDOFF_STATES = vocabulary(["accepted", "rejected", "unknown"]);
159
+ var CEAL_OPERATION_RECEIPT_AUTHORITY_KEYS = Object.freeze(["instance_ref", "profile_ref", "principal_ref", "execution_subject_ref", "authority_revision_ref"]);
159
160
  var CEAL_OPERATION_APPROVAL_DISPOSITIONS = vocabulary([
160
161
  "approval_not_required_by_policy",
161
162
  "interactive_pending",
@@ -412,7 +413,13 @@ var CEAL_OPERATION_JSON_SCHEMA_BUDGET = Object.freeze({
412
413
  max_string_length: OPERATION_SCHEMA_LITERAL_MAX_BYTES / 4,
413
414
  max_alternatives: 8,
414
415
  max_enum_values: 64,
415
- max_literal_bytes: OPERATION_SCHEMA_LITERAL_MAX_BYTES
416
+ max_literal_bytes: OPERATION_SCHEMA_LITERAL_MAX_BYTES,
417
+ /** @basis our_policy -- bounds explanatory schema prose carried in one catalog. */
418
+ max_description_characters: 1024,
419
+ /** @basis our_policy -- bounds regular-expression compilation input from one schema. */
420
+ max_pattern_characters: 256,
421
+ /** @basis our_policy -- bounds traversal work inside one already byte-bounded schema literal. */
422
+ max_literal_nodes: 512
416
423
  });
417
424
 
418
425
  // packages/ceal-client-protocol/src/operation-validation-primitives.ts
@@ -432,6 +439,9 @@ function requireIsoTimestamp(value, message) {
432
439
  if (typeof value !== "string" || !ISO_TIMESTAMP.test(value) || !Number.isFinite(Date.parse(value))) throw new TypeError(message);
433
440
  }
434
441
 
442
+ // packages/ceal-client-protocol/src/operation-json-schema.ts
443
+ var JSON_DESCRIPTION_CONTROL_CHARACTER = new RegExp("\\p{Cc}", "u");
444
+
435
445
  // packages/ceal-client-protocol/src/operation-contract-validation.ts
436
446
  var CEAL_OPERATION_AUTHORITY_POLICY_KEYS = Object.freeze(["profile", "instance_binding", "target", "admission_recheck"]);
437
447
  var MAX_OPERATION_INPUT_RESOLVER_BINDINGS = 96;
@@ -532,7 +542,6 @@ var CEAL_BOUNDED_SERIES_CATALOG = Object.freeze({
532
542
  control_commit: (root) => join(root, "control-auto-commit.jsonl"),
533
543
  engagement_signal: (root) => join(root, "runtime-state", "slack-feedback.jsonl"),
534
544
  runtime_error: (root) => join(root, "runtime-state", "runtime-errors.jsonl"),
535
- provider_retry: (root) => join(root, "observability", "provider-retry-queue", "queue.jsonl"),
536
545
  turn_bridge_request: (root) => join(root, ".ceal", "turn-bridge", "requests.jsonl"),
537
546
  channel_log: (root) => join(root, "log.jsonl"),
538
547
  thread_run_events: (root) => join(root, "run-events.jsonl"),
@@ -541,8 +550,6 @@ var CEAL_BOUNDED_SERIES_CATALOG = Object.freeze({
541
550
  gateway_capability_audit: (root) => join(root, "capability-audit.jsonl"),
542
551
  gateway_retrieval_waste_partition: (root) => `${root}.jsonl`,
543
552
  gateway_access_policy_publication: (root) => join(root, "access-policy-publications.jsonl"),
544
- gateway_event_lease_journal: (root) => `${root}.journal.jsonl`,
545
- gateway_control_audit: (root) => `${root}.control-audits.jsonl`,
546
553
  gateway_profile_connector_control_audit: (root) => `${root}.audit.jsonl`,
547
554
  gateway_profile_connector_scope_audit: (root) => join(root, "profile-connector-scope-audit.jsonl"),
548
555
  gateway_profile_connector_activity_scope_audit: (root) => join(root, "profile-connector-activity-scope-audit.jsonl"),
@@ -557,6 +564,11 @@ var CEAL_BOUNDED_SERIES_CATALOG = Object.freeze({
557
564
  gateway_admin_access_token: (root) => join(root, "access-tokens.jsonl")
558
565
  });
559
566
 
567
+ // packages/ceal-client-protocol/src/gateway-installation-activation.ts
568
+ var CEAL_GATEWAY_INSTALLATION_ACTIVATION_CODE_DATA_CHARACTERS = 32;
569
+ var CEAL_GATEWAY_INSTALLATION_ACTIVATION_CODE_CHECK_CHARACTERS = 8;
570
+ var CEAL_GATEWAY_INSTALLATION_ACTIVATION_CODE_COMPACT_CHARACTERS = CEAL_GATEWAY_INSTALLATION_ACTIVATION_CODE_DATA_CHARACTERS + CEAL_GATEWAY_INSTALLATION_ACTIVATION_CODE_CHECK_CHARACTERS;
571
+
560
572
  // packages/ceal-client-protocol/src/host-registration.ts
561
573
  var CEAL_HOST_REGISTRATION_RESULT_KEYS = Object.freeze(["credential_generation", "host_access_token", "host_installation_ref", "host_source_ref", "ok", "registration_attempt_ref", "schema_version", "status"]);
562
574
 
@@ -1131,7 +1143,7 @@ var CEAL_ACTOR_KINDS = vocabulary(["human", "bot", "app", "unknown"]);
1131
1143
  // packages/ceal-client-protocol/src/leased-consumer-vocabulary.ts
1132
1144
  var CEAL_TERMINAL_DISPOSITIONS = vocabulary(["completed", "failed", "cancelled"]);
1133
1145
  var CEAL_LEASE_DISPOSITIONS = vocabulary([...CEAL_TERMINAL_DISPOSITIONS, "deferred"]);
1134
- var CEAL_AUTOMATIC_FEEDBACK_INTENTS = vocabulary(["reaction", "progress_start", "progress_finish"]);
1146
+ var CEAL_AUTOMATIC_FEEDBACK_INTENTS = vocabulary(["initial"]);
1135
1147
  var CEAL_LEASED_MESSAGE_DELIVERY_CAPABILITY_IDS = vocabulary(["message.create", "message.update", "message.delete"]);
1136
1148
  var CEAL_REPOSITORY_VISIBILITIES = vocabulary(["public", "private", "internal"]);
1137
1149
  var CEAL_RESULT_DELIVERY_OFFERS = vocabulary(["pending", "offered", "transport_lost"]);
@@ -1477,6 +1489,7 @@ function isRecord2(value) {
1477
1489
 
1478
1490
  // host/codex/src/codex-outbox.ts
1479
1491
  var SAFE_REF3 = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u;
1492
+ var CODEX_TRANSCRIPT_PATH_MAX_CHARACTERS = 4096;
1480
1493
  var CodexOutboxStore = class {
1481
1494
  directory;
1482
1495
  entriesDirectory;
@@ -1843,13 +1856,13 @@ function validateRegistration(value) {
1843
1856
  }
1844
1857
  function validateRegistrationFields(value) {
1845
1858
  if (![value.host_source_ref, value.host_session_ref, value.codex_session_id].every((candidate) => typeof candidate === "string" && SAFE_REF3.test(candidate))) throw storageError(`Codex transcript registration references are malformed (${refusalFacts([{ name: "host_source_ref", value: value.host_source_ref }, { name: "host_session_ref", value: value.host_session_ref }, { name: "codex_session_id", value: value.codex_session_id }])}).`);
1846
- if (!validRegistrationCwd(value.cwd)) throw storageError(`Codex transcript registration working directory is malformed (${refusalFact("cwd_characters", typeof value.cwd === "string" ? value.cwd.length : 0, "an absolute path of at most 4096 characters")}).`);
1859
+ if (!validRegistrationCwd(value.cwd)) throw storageError(`Codex transcript registration working directory is malformed (${refusalFact("cwd_characters", typeof value.cwd === "string" ? value.cwd.length : 0, `an absolute path of at most ${CODEX_TRANSCRIPT_PATH_MAX_CHARACTERS} characters`)}).`);
1847
1860
  if (typeof value.transcript_path !== "string") throw storageError(`Codex transcript registration path is malformed (${refusalFact("kind", typeof value.transcript_path, "string")}).`);
1848
- if (value.transcript_path.length === 0 || value.transcript_path.length > 4096) throw storageError(`Codex transcript registration path is malformed (${refusalFact("characters", value.transcript_path.length, "from 1 through 4096")}).`);
1861
+ if (value.transcript_path.length === 0 || value.transcript_path.length > CODEX_TRANSCRIPT_PATH_MAX_CHARACTERS) throw storageError(`Codex transcript registration path is malformed (${refusalFact("characters", value.transcript_path.length, `from 1 through ${CODEX_TRANSCRIPT_PATH_MAX_CHARACTERS}`)}).`);
1849
1862
  if (!isTimestamp(value.registered_at) || !isTimestamp(value.expires_at)) throw storageError(`Codex transcript registration timestamps are malformed (${refusalFacts([{ name: "registered_at", value: value.registered_at }, { name: "expires_at", value: value.expires_at }])}).`);
1850
1863
  }
1851
1864
  function validRegistrationCwd(value) {
1852
- return value === void 0 || typeof value === "string" && isAbsolute2(value) && value.length <= 4096 && !value.includes("\0");
1865
+ return value === void 0 || typeof value === "string" && isAbsolute2(value) && value.length <= CODEX_TRANSCRIPT_PATH_MAX_CHARACTERS && !value.includes("\0");
1853
1866
  }
1854
1867
  function validateCursor(value) {
1855
1868
  if (!isRecord3(value)) throw storageError("Codex transcript cursor is malformed.");
@@ -1968,6 +1981,7 @@ var DEFAULT_PORT = {
1968
1981
  // host/relay/src/producer-frame.ts
1969
1982
  var HOST_PRODUCER_FRAME_SCHEMA = "ceal.host_producer_frame.v1";
1970
1983
  var HOST_PRODUCER_MAX_JSON_BYTES = 262144;
1984
+ var HOST_PRODUCER_FRAME_LENGTH_BYTES = Uint32Array.BYTES_PER_ELEMENT;
1971
1985
  var SAFE_REF4 = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u;
1972
1986
  var DIGEST2 = /^[a-f0-9]{64}$/u;
1973
1987
  var PRODUCERS = /* @__PURE__ */ new Set(["codex", "claude"]);
@@ -1987,18 +2001,18 @@ function encodeHostProducerFrame(frame) {
1987
2001
  validateFrame(frame);
1988
2002
  const json = Buffer.from(JSON.stringify(frame), "utf8");
1989
2003
  if (json.byteLength > HOST_PRODUCER_MAX_JSON_BYTES) throw new HostProducerFrameError("frame_too_large", `frame_too_large: ${refusalFact("frame_bytes", json.byteLength, `at most ${HOST_PRODUCER_MAX_JSON_BYTES}`)}`);
1990
- const result = Buffer.allocUnsafe(json.byteLength + 4);
2004
+ const result = Buffer.allocUnsafe(json.byteLength + HOST_PRODUCER_FRAME_LENGTH_BYTES);
1991
2005
  result.writeUInt32BE(json.byteLength, 0);
1992
- json.copy(result, 4);
2006
+ json.copy(result, HOST_PRODUCER_FRAME_LENGTH_BYTES);
1993
2007
  return result;
1994
2008
  }
1995
2009
  function decodeHostProducerFrame(input) {
1996
- if (input.byteLength < 4) throw new HostProducerFrameError("frame_truncated", `frame_truncated: ${refusalFact("frame_bytes", input.byteLength, "at least 4")}`);
2010
+ if (input.byteLength < HOST_PRODUCER_FRAME_LENGTH_BYTES) throw new HostProducerFrameError("frame_truncated", `frame_truncated: ${refusalFact("frame_bytes", input.byteLength, `at least ${HOST_PRODUCER_FRAME_LENGTH_BYTES}`)}`);
1997
2011
  const length = input.readUInt32BE(0);
1998
2012
  if (length > HOST_PRODUCER_MAX_JSON_BYTES) throw new HostProducerFrameError("frame_too_large", `frame_too_large: ${refusalFact("declared_bytes", length, `at most ${HOST_PRODUCER_MAX_JSON_BYTES}`)}`);
1999
2013
  if (length === 0) throw new HostProducerFrameError("invalid_frame_length");
2000
- if (input.byteLength !== length + 4) throw new HostProducerFrameError(input.byteLength < length + 4 ? "frame_truncated" : "invalid_frame_length");
2001
- const bytes = input.subarray(4);
2014
+ if (input.byteLength !== length + HOST_PRODUCER_FRAME_LENGTH_BYTES) throw new HostProducerFrameError(input.byteLength < length + HOST_PRODUCER_FRAME_LENGTH_BYTES ? "frame_truncated" : "invalid_frame_length");
2015
+ const bytes = input.subarray(HOST_PRODUCER_FRAME_LENGTH_BYTES);
2002
2016
  const text = new TextDecoder("utf-8", { fatal: true });
2003
2017
  let value;
2004
2018
  try {
@@ -2117,6 +2131,7 @@ function isHostGatewayAcknowledgementDisposition(value) {
2117
2131
  var SAFE_REF5 = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u;
2118
2132
  var DEFAULT_TIMEOUT_MS = 5e3;
2119
2133
  var ORIGIN_DELIVERY_CONCURRENCY = 8;
2134
+ var CODEX_RELAY_TIMEOUT_MAX_MS = 1e4;
2120
2135
  function createCodexHostObservationAdapter(options) {
2121
2136
  validateOptions(options);
2122
2137
  const now = options.now ?? (() => /* @__PURE__ */ new Date());
@@ -2304,7 +2319,7 @@ function validateAdapterOwner(options) {
2304
2319
  if (options.codex_sessions_root !== void 0 && !isAbsolute3(options.codex_sessions_root)) throw new CodexHostAdapterError("configuration", "Codex sessions root is invalid.");
2305
2320
  }
2306
2321
  function validateAdapterBehavior(options) {
2307
- if (options.timeout_ms !== void 0 && (!Number.isSafeInteger(options.timeout_ms) || options.timeout_ms < 1 || options.timeout_ms > 1e4)) throw new CodexHostAdapterError("configuration", `Codex relay timeout is invalid (${refusalFact("timeout_ms", options.timeout_ms, "an integer from 1 through 10000")}).`);
2322
+ if (options.timeout_ms !== void 0 && (!Number.isSafeInteger(options.timeout_ms) || options.timeout_ms < 1 || options.timeout_ms > CODEX_RELAY_TIMEOUT_MAX_MS)) throw new CodexHostAdapterError("configuration", `Codex relay timeout is invalid (${refusalFact("timeout_ms", options.timeout_ms, `an integer from 1 through ${CODEX_RELAY_TIMEOUT_MAX_MS}`)}).`);
2308
2323
  if (options.retention_ms !== void 0 && (!Number.isSafeInteger(options.retention_ms) || options.retention_ms < 1)) throw new CodexHostAdapterError("configuration", `Codex retention is invalid (${refusalFact("retention_ms", options.retention_ms, "a positive integer")}).`);
2309
2324
  }
2310
2325
  function safeReason(error) {
@@ -2506,6 +2521,8 @@ var HOST_RELAY_REQUEST_BINDING_KEYS = Object.freeze([
2506
2521
  "host_input_ref"
2507
2522
  ]);
2508
2523
  var HOST_RELAY_IPC_RESPONSE_SCHEMA = "ceal.host_relay_admission.v1";
2524
+ var HOST_RELAY_IPC_LENGTH_BYTES = Uint32Array.BYTES_PER_ELEMENT;
2525
+ var HOST_RELAY_ADMISSION_RESPONSE_MAX_BYTES = 4096;
2509
2526
  var HostRelayIpcError = class extends Error {
2510
2527
  code;
2511
2528
  constructor(code, message = code) {
@@ -2559,12 +2576,12 @@ function exchange(endpoint, encoded, timeoutMs, decode) {
2559
2576
  });
2560
2577
  }
2561
2578
  function decodeHostRelayIpcResponse(input) {
2562
- if (input.length < 4) throw new HostRelayIpcError("relay_unavailable", `Host Relay IPC response is truncated: ${refusalFact("response_bytes", input.byteLength, "at least 4")}.`);
2579
+ if (input.length < HOST_RELAY_IPC_LENGTH_BYTES) throw new HostRelayIpcError("relay_unavailable", `Host Relay IPC response is truncated: ${refusalFact("response_bytes", input.byteLength, `at least ${HOST_RELAY_IPC_LENGTH_BYTES}`)}.`);
2563
2580
  const length = input.readUInt32BE(0);
2564
- if (length === 0 || length > 4096 || input.length !== length + 4) throw new HostRelayIpcError("relay_unavailable", `Host Relay IPC response length is invalid: ${refusalFacts([{ name: "declared_bytes", value: length, expected: "between 1 and 4096" }, { name: "received_bytes", value: input.byteLength, expected: `exactly ${length + 4}` }])}.`);
2581
+ if (length === 0 || length > HOST_RELAY_ADMISSION_RESPONSE_MAX_BYTES || input.length !== length + HOST_RELAY_IPC_LENGTH_BYTES) throw new HostRelayIpcError("relay_unavailable", `Host Relay IPC response length is invalid: ${refusalFacts([{ name: "declared_bytes", value: length, expected: `between 1 and ${HOST_RELAY_ADMISSION_RESPONSE_MAX_BYTES}` }, { name: "received_bytes", value: input.byteLength, expected: `exactly ${length + HOST_RELAY_IPC_LENGTH_BYTES}` }])}.`);
2565
2582
  let value;
2566
2583
  try {
2567
- value = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(input.subarray(4)));
2584
+ value = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(input.subarray(HOST_RELAY_IPC_LENGTH_BYTES)));
2568
2585
  } catch {
2569
2586
  throw new HostRelayIpcError("relay_unavailable", "Host Relay IPC response is invalid.");
2570
2587
  }
@@ -2587,11 +2604,11 @@ function record2(value) {
2587
2604
  return value !== null && typeof value === "object" && !Array.isArray(value);
2588
2605
  }
2589
2606
  function decodeResponseBuffer(buffer) {
2590
- if (buffer.length < 4) return null;
2607
+ if (buffer.length < HOST_RELAY_IPC_LENGTH_BYTES) return null;
2591
2608
  const length = buffer.readUInt32BE(0);
2592
- if (length === 0 || length > 4096) throw new HostRelayIpcError("relay_unavailable", `Host Relay IPC response length is invalid: ${refusalFact("declared_bytes", length, "between 1 and 4096")}.`);
2593
- if (buffer.length < length + 4) return null;
2594
- if (buffer.length !== length + 4) throw new HostRelayIpcError("relay_unavailable", `Host Relay IPC returned trailing bytes: ${refusalFacts([{ name: "declared_bytes", value: length, expected: "the received message length minus 4" }, { name: "received_bytes", value: buffer.byteLength, expected: `exactly ${length + 4}` }])}.`);
2609
+ if (length === 0 || length > HOST_RELAY_ADMISSION_RESPONSE_MAX_BYTES) throw new HostRelayIpcError("relay_unavailable", `Host Relay IPC response length is invalid: ${refusalFact("declared_bytes", length, `between 1 and ${HOST_RELAY_ADMISSION_RESPONSE_MAX_BYTES}`)}.`);
2610
+ if (buffer.length < length + HOST_RELAY_IPC_LENGTH_BYTES) return null;
2611
+ if (buffer.length !== length + HOST_RELAY_IPC_LENGTH_BYTES) throw new HostRelayIpcError("relay_unavailable", `Host Relay IPC returned trailing bytes: ${refusalFacts([{ name: "declared_bytes", value: length, expected: `the received message length minus ${HOST_RELAY_IPC_LENGTH_BYTES}` }, { name: "received_bytes", value: buffer.byteLength, expected: `exactly ${length + HOST_RELAY_IPC_LENGTH_BYTES}` }])}.`);
2595
2612
  return decodeHostRelayIpcResponse(buffer);
2596
2613
  }
2597
2614
 
@@ -142,6 +142,7 @@ var CEAL_OPERATION_RECOVERY_KINDS = vocabulary(["none", "reconcile", "compensate
142
142
  var CEAL_OPERATION_RECOVERY_STATUSES = vocabulary(["not_started", "active", "completed"]);
143
143
  var CEAL_OPERATION_PROVIDER_READBACK_AVAILABILITY = vocabulary(["not_started", "not_applicable", "not_available", "pending", "available"]);
144
144
  var CEAL_OPERATION_OFFERED_HANDOFF_STATES = vocabulary(["accepted", "rejected", "unknown"]);
145
+ var CEAL_OPERATION_RECEIPT_AUTHORITY_KEYS = Object.freeze(["instance_ref", "profile_ref", "principal_ref", "execution_subject_ref", "authority_revision_ref"]);
145
146
  var CEAL_OPERATION_APPROVAL_DISPOSITIONS = vocabulary([
146
147
  "approval_not_required_by_policy",
147
148
  "interactive_pending",
@@ -398,7 +399,13 @@ var CEAL_OPERATION_JSON_SCHEMA_BUDGET = Object.freeze({
398
399
  max_string_length: OPERATION_SCHEMA_LITERAL_MAX_BYTES / 4,
399
400
  max_alternatives: 8,
400
401
  max_enum_values: 64,
401
- max_literal_bytes: OPERATION_SCHEMA_LITERAL_MAX_BYTES
402
+ max_literal_bytes: OPERATION_SCHEMA_LITERAL_MAX_BYTES,
403
+ /** @basis our_policy -- bounds explanatory schema prose carried in one catalog. */
404
+ max_description_characters: 1024,
405
+ /** @basis our_policy -- bounds regular-expression compilation input from one schema. */
406
+ max_pattern_characters: 256,
407
+ /** @basis our_policy -- bounds traversal work inside one already byte-bounded schema literal. */
408
+ max_literal_nodes: 512
402
409
  });
403
410
 
404
411
  // packages/ceal-client-protocol/src/operation-validation-primitives.ts
@@ -418,6 +425,9 @@ function requireIsoTimestamp(value, message) {
418
425
  if (typeof value !== "string" || !ISO_TIMESTAMP.test(value) || !Number.isFinite(Date.parse(value))) throw new TypeError(message);
419
426
  }
420
427
 
428
+ // packages/ceal-client-protocol/src/operation-json-schema.ts
429
+ var JSON_DESCRIPTION_CONTROL_CHARACTER = new RegExp("\\p{Cc}", "u");
430
+
421
431
  // packages/ceal-client-protocol/src/operation-contract-validation.ts
422
432
  var CEAL_OPERATION_AUTHORITY_POLICY_KEYS = Object.freeze(["profile", "instance_binding", "target", "admission_recheck"]);
423
433
  var MAX_OPERATION_INPUT_RESOLVER_BINDINGS = 96;
@@ -518,7 +528,6 @@ var CEAL_BOUNDED_SERIES_CATALOG = Object.freeze({
518
528
  control_commit: (root) => join(root, "control-auto-commit.jsonl"),
519
529
  engagement_signal: (root) => join(root, "runtime-state", "slack-feedback.jsonl"),
520
530
  runtime_error: (root) => join(root, "runtime-state", "runtime-errors.jsonl"),
521
- provider_retry: (root) => join(root, "observability", "provider-retry-queue", "queue.jsonl"),
522
531
  turn_bridge_request: (root) => join(root, ".ceal", "turn-bridge", "requests.jsonl"),
523
532
  channel_log: (root) => join(root, "log.jsonl"),
524
533
  thread_run_events: (root) => join(root, "run-events.jsonl"),
@@ -527,8 +536,6 @@ var CEAL_BOUNDED_SERIES_CATALOG = Object.freeze({
527
536
  gateway_capability_audit: (root) => join(root, "capability-audit.jsonl"),
528
537
  gateway_retrieval_waste_partition: (root) => `${root}.jsonl`,
529
538
  gateway_access_policy_publication: (root) => join(root, "access-policy-publications.jsonl"),
530
- gateway_event_lease_journal: (root) => `${root}.journal.jsonl`,
531
- gateway_control_audit: (root) => `${root}.control-audits.jsonl`,
532
539
  gateway_profile_connector_control_audit: (root) => `${root}.audit.jsonl`,
533
540
  gateway_profile_connector_scope_audit: (root) => join(root, "profile-connector-scope-audit.jsonl"),
534
541
  gateway_profile_connector_activity_scope_audit: (root) => join(root, "profile-connector-activity-scope-audit.jsonl"),
@@ -543,6 +550,11 @@ var CEAL_BOUNDED_SERIES_CATALOG = Object.freeze({
543
550
  gateway_admin_access_token: (root) => join(root, "access-tokens.jsonl")
544
551
  });
545
552
 
553
+ // packages/ceal-client-protocol/src/gateway-installation-activation.ts
554
+ var CEAL_GATEWAY_INSTALLATION_ACTIVATION_CODE_DATA_CHARACTERS = 32;
555
+ var CEAL_GATEWAY_INSTALLATION_ACTIVATION_CODE_CHECK_CHARACTERS = 8;
556
+ var CEAL_GATEWAY_INSTALLATION_ACTIVATION_CODE_COMPACT_CHARACTERS = CEAL_GATEWAY_INSTALLATION_ACTIVATION_CODE_DATA_CHARACTERS + CEAL_GATEWAY_INSTALLATION_ACTIVATION_CODE_CHECK_CHARACTERS;
557
+
546
558
  // packages/ceal-client-protocol/src/host-registration.ts
547
559
  var CEAL_HOST_REGISTRATION_RESULT_KEYS = Object.freeze(["credential_generation", "host_access_token", "host_installation_ref", "host_source_ref", "ok", "registration_attempt_ref", "schema_version", "status"]);
548
560
 
@@ -1159,7 +1171,7 @@ var CEAL_ACTOR_KINDS = vocabulary(["human", "bot", "app", "unknown"]);
1159
1171
  // packages/ceal-client-protocol/src/leased-consumer-vocabulary.ts
1160
1172
  var CEAL_TERMINAL_DISPOSITIONS = vocabulary(["completed", "failed", "cancelled"]);
1161
1173
  var CEAL_LEASE_DISPOSITIONS = vocabulary([...CEAL_TERMINAL_DISPOSITIONS, "deferred"]);
1162
- var CEAL_AUTOMATIC_FEEDBACK_INTENTS = vocabulary(["reaction", "progress_start", "progress_finish"]);
1174
+ var CEAL_AUTOMATIC_FEEDBACK_INTENTS = vocabulary(["initial"]);
1163
1175
  var CEAL_LEASED_MESSAGE_DELIVERY_CAPABILITY_IDS = vocabulary(["message.create", "message.update", "message.delete"]);
1164
1176
  var CEAL_REPOSITORY_VISIBILITIES = vocabulary(["public", "private", "internal"]);
1165
1177
  var CEAL_RESULT_DELIVERY_OFFERS = vocabulary(["pending", "offered", "transport_lost"]);
@@ -1544,6 +1556,7 @@ async function doctorCodexClient(options = {}) {
1544
1556
  // host/relay/src/producer-frame.ts
1545
1557
  var HOST_PRODUCER_FRAME_SCHEMA = "ceal.host_producer_frame.v1";
1546
1558
  var HOST_PRODUCER_MAX_JSON_BYTES = 262144;
1559
+ var HOST_PRODUCER_FRAME_LENGTH_BYTES = Uint32Array.BYTES_PER_ELEMENT;
1547
1560
  var SAFE_REF3 = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u;
1548
1561
  var DIGEST2 = /^[a-f0-9]{64}$/u;
1549
1562
  var PRODUCERS = /* @__PURE__ */ new Set(["codex", "claude"]);
@@ -1563,18 +1576,18 @@ function encodeHostProducerFrame(frame) {
1563
1576
  validateFrame(frame);
1564
1577
  const json = Buffer.from(JSON.stringify(frame), "utf8");
1565
1578
  if (json.byteLength > HOST_PRODUCER_MAX_JSON_BYTES) throw new HostProducerFrameError("frame_too_large", `frame_too_large: ${refusalFact("frame_bytes", json.byteLength, `at most ${HOST_PRODUCER_MAX_JSON_BYTES}`)}`);
1566
- const result = Buffer.allocUnsafe(json.byteLength + 4);
1579
+ const result = Buffer.allocUnsafe(json.byteLength + HOST_PRODUCER_FRAME_LENGTH_BYTES);
1567
1580
  result.writeUInt32BE(json.byteLength, 0);
1568
- json.copy(result, 4);
1581
+ json.copy(result, HOST_PRODUCER_FRAME_LENGTH_BYTES);
1569
1582
  return result;
1570
1583
  }
1571
1584
  function decodeHostProducerFrame(input) {
1572
- if (input.byteLength < 4) throw new HostProducerFrameError("frame_truncated", `frame_truncated: ${refusalFact("frame_bytes", input.byteLength, "at least 4")}`);
1585
+ if (input.byteLength < HOST_PRODUCER_FRAME_LENGTH_BYTES) throw new HostProducerFrameError("frame_truncated", `frame_truncated: ${refusalFact("frame_bytes", input.byteLength, `at least ${HOST_PRODUCER_FRAME_LENGTH_BYTES}`)}`);
1573
1586
  const length = input.readUInt32BE(0);
1574
1587
  if (length > HOST_PRODUCER_MAX_JSON_BYTES) throw new HostProducerFrameError("frame_too_large", `frame_too_large: ${refusalFact("declared_bytes", length, `at most ${HOST_PRODUCER_MAX_JSON_BYTES}`)}`);
1575
1588
  if (length === 0) throw new HostProducerFrameError("invalid_frame_length");
1576
- if (input.byteLength !== length + 4) throw new HostProducerFrameError(input.byteLength < length + 4 ? "frame_truncated" : "invalid_frame_length");
1577
- const bytes = input.subarray(4);
1589
+ if (input.byteLength !== length + HOST_PRODUCER_FRAME_LENGTH_BYTES) throw new HostProducerFrameError(input.byteLength < length + HOST_PRODUCER_FRAME_LENGTH_BYTES ? "frame_truncated" : "invalid_frame_length");
1590
+ const bytes = input.subarray(HOST_PRODUCER_FRAME_LENGTH_BYTES);
1578
1591
  const text = new TextDecoder("utf-8", { fatal: true });
1579
1592
  let value;
1580
1593
  try {
@@ -1725,6 +1738,9 @@ var HOST_RELAY_BINDING_QUERY_SCHEMA = "ceal.host_relay_binding_query.v1";
1725
1738
  var HOST_RELAY_BINDING_RESULT_SCHEMA = "ceal.host_relay_binding_result.v1";
1726
1739
  var HOST_RELAY_INVOCATION_CONTEXT_QUERY_SCHEMA = "ceal.host_relay_invocation_context_query.v1";
1727
1740
  var HOST_RELAY_INVOCATION_CONTEXT_RESULT_SCHEMA = "ceal.host_relay_invocation_context_result.v1";
1741
+ var HOST_RELAY_IPC_LENGTH_BYTES = Uint32Array.BYTES_PER_ELEMENT;
1742
+ var HOST_RELAY_ADMISSION_RESPONSE_MAX_BYTES = 4096;
1743
+ var HOST_RELAY_QUERY_RESPONSE_MAX_BYTES = 8192;
1728
1744
  var HostRelayIpcError = class extends Error {
1729
1745
  code;
1730
1746
  constructor(code, message = code) {
@@ -1805,12 +1821,12 @@ function exchange(endpoint, encoded, timeoutMs, decode) {
1805
1821
  });
1806
1822
  }
1807
1823
  function decodeHostRelayIpcResponse(input) {
1808
- if (input.length < 4) throw new HostRelayIpcError("relay_unavailable", `Host Relay IPC response is truncated: ${refusalFact("response_bytes", input.byteLength, "at least 4")}.`);
1824
+ if (input.length < HOST_RELAY_IPC_LENGTH_BYTES) throw new HostRelayIpcError("relay_unavailable", `Host Relay IPC response is truncated: ${refusalFact("response_bytes", input.byteLength, `at least ${HOST_RELAY_IPC_LENGTH_BYTES}`)}.`);
1809
1825
  const length = input.readUInt32BE(0);
1810
- if (length === 0 || length > 4096 || input.length !== length + 4) throw new HostRelayIpcError("relay_unavailable", `Host Relay IPC response length is invalid: ${refusalFacts([{ name: "declared_bytes", value: length, expected: "between 1 and 4096" }, { name: "received_bytes", value: input.byteLength, expected: `exactly ${length + 4}` }])}.`);
1826
+ if (length === 0 || length > HOST_RELAY_ADMISSION_RESPONSE_MAX_BYTES || input.length !== length + HOST_RELAY_IPC_LENGTH_BYTES) throw new HostRelayIpcError("relay_unavailable", `Host Relay IPC response length is invalid: ${refusalFacts([{ name: "declared_bytes", value: length, expected: `between 1 and ${HOST_RELAY_ADMISSION_RESPONSE_MAX_BYTES}` }, { name: "received_bytes", value: input.byteLength, expected: `exactly ${length + HOST_RELAY_IPC_LENGTH_BYTES}` }])}.`);
1811
1827
  let value;
1812
1828
  try {
1813
- value = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(input.subarray(4)));
1829
+ value = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(input.subarray(HOST_RELAY_IPC_LENGTH_BYTES)));
1814
1830
  } catch {
1815
1831
  throw new HostRelayIpcError("relay_unavailable", "Host Relay IPC response is invalid.");
1816
1832
  }
@@ -1833,21 +1849,21 @@ function record2(value) {
1833
1849
  return value !== null && typeof value === "object" && !Array.isArray(value);
1834
1850
  }
1835
1851
  function decodeResponseBuffer(buffer) {
1836
- if (buffer.length < 4) return null;
1852
+ if (buffer.length < HOST_RELAY_IPC_LENGTH_BYTES) return null;
1837
1853
  const length = buffer.readUInt32BE(0);
1838
- if (length === 0 || length > 4096) throw new HostRelayIpcError("relay_unavailable", `Host Relay IPC response length is invalid: ${refusalFact("declared_bytes", length, "between 1 and 4096")}.`);
1839
- if (buffer.length < length + 4) return null;
1840
- if (buffer.length !== length + 4) throw new HostRelayIpcError("relay_unavailable", `Host Relay IPC returned trailing bytes: ${refusalFacts([{ name: "declared_bytes", value: length, expected: "the received message length minus 4" }, { name: "received_bytes", value: buffer.byteLength, expected: `exactly ${length + 4}` }])}.`);
1854
+ if (length === 0 || length > HOST_RELAY_ADMISSION_RESPONSE_MAX_BYTES) throw new HostRelayIpcError("relay_unavailable", `Host Relay IPC response length is invalid: ${refusalFact("declared_bytes", length, `between 1 and ${HOST_RELAY_ADMISSION_RESPONSE_MAX_BYTES}`)}.`);
1855
+ if (buffer.length < length + HOST_RELAY_IPC_LENGTH_BYTES) return null;
1856
+ if (buffer.length !== length + HOST_RELAY_IPC_LENGTH_BYTES) throw new HostRelayIpcError("relay_unavailable", `Host Relay IPC returned trailing bytes: ${refusalFacts([{ name: "declared_bytes", value: length, expected: `the received message length minus ${HOST_RELAY_IPC_LENGTH_BYTES}` }, { name: "received_bytes", value: buffer.byteLength, expected: `exactly ${length + HOST_RELAY_IPC_LENGTH_BYTES}` }])}.`);
1841
1857
  return decodeHostRelayIpcResponse(buffer);
1842
1858
  }
1843
1859
  function decodeBindingResponseBuffer(buffer) {
1844
- const value = decodeLengthPrefixedJson(buffer, 8192);
1860
+ const value = decodeLengthPrefixedJson(buffer, HOST_RELAY_QUERY_RESPONSE_MAX_BYTES);
1845
1861
  if (value === null) return null;
1846
1862
  const decoded = decodeHostRelayBindingQueryResult(value);
1847
1863
  return decoded.status === "no_binding" ? { schema_version: HOST_RELAY_BINDING_RESULT_SCHEMA, status: "no_binding" } : { schema_version: HOST_RELAY_BINDING_RESULT_SCHEMA, status: "ready", binding: decoded.binding };
1848
1864
  }
1849
1865
  function decodeInvocationContextResponseBuffer(buffer) {
1850
- const value = decodeLengthPrefixedJson(buffer, 8192);
1866
+ const value = decodeLengthPrefixedJson(buffer, HOST_RELAY_QUERY_RESPONSE_MAX_BYTES);
1851
1867
  if (value === null) return null;
1852
1868
  if (!validInvocationContextResponse(value)) throw new HostRelayIpcError("relay_unavailable", "Host Relay invocation context response is invalid.");
1853
1869
  return value;
@@ -1901,22 +1917,22 @@ function validWireBindingTimes(value) {
1901
1917
  return validTimestamp(value.bound_at) && (value.context_expires_at === void 0 || validTimestamp(value.context_expires_at));
1902
1918
  }
1903
1919
  function decodeLengthPrefixedJson(input, maximum) {
1904
- if (input.length < 4) return null;
1920
+ if (input.length < HOST_RELAY_IPC_LENGTH_BYTES) return null;
1905
1921
  const length = input.readUInt32BE(0);
1906
1922
  if (length === 0 || length > maximum) throw new HostRelayIpcError("relay_unavailable", `Host Relay IPC message length is invalid: ${refusalFact("declared_bytes", length, `between 1 and ${maximum}`)}.`);
1907
- if (input.length < length + 4) return null;
1908
- if (input.length !== length + 4) throw new HostRelayIpcError("relay_unavailable", `Host Relay IPC message has trailing bytes: ${refusalFacts([{ name: "declared_bytes", value: length, expected: "the received message length minus 4" }, { name: "received_bytes", value: input.byteLength, expected: `exactly ${length + 4}` }])}.`);
1923
+ if (input.length < length + HOST_RELAY_IPC_LENGTH_BYTES) return null;
1924
+ if (input.length !== length + HOST_RELAY_IPC_LENGTH_BYTES) throw new HostRelayIpcError("relay_unavailable", `Host Relay IPC message has trailing bytes: ${refusalFacts([{ name: "declared_bytes", value: length, expected: `the received message length minus ${HOST_RELAY_IPC_LENGTH_BYTES}` }, { name: "received_bytes", value: input.byteLength, expected: `exactly ${length + HOST_RELAY_IPC_LENGTH_BYTES}` }])}.`);
1909
1925
  try {
1910
- return JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(input.subarray(4)));
1926
+ return JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(input.subarray(HOST_RELAY_IPC_LENGTH_BYTES)));
1911
1927
  } catch {
1912
1928
  throw new HostRelayIpcError("relay_unavailable", "Host Relay IPC message is invalid.");
1913
1929
  }
1914
1930
  }
1915
1931
  function encodeLengthPrefixed(value) {
1916
1932
  const body = Buffer.from(JSON.stringify(value), "utf8");
1917
- const output = Buffer.allocUnsafe(body.length + 4);
1933
+ const output = Buffer.allocUnsafe(body.length + HOST_RELAY_IPC_LENGTH_BYTES);
1918
1934
  output.writeUInt32BE(body.length, 0);
1919
- body.copy(output, 4);
1935
+ body.copy(output, HOST_RELAY_IPC_LENGTH_BYTES);
1920
1936
  return output;
1921
1937
  }
1922
1938
  function exactKeys3(value, keys) {
@@ -1930,6 +1946,7 @@ function validTimestamp(value) {
1930
1946
  }
1931
1947
 
1932
1948
  // host/invocation-authentication-command.ts
1949
+ var HOST_INVOCATION_AUTHENTICATION_COMMAND_PREFIX = ["authenticate", "--client-nonce"];
1933
1950
  function installedHostInvocationAuthenticationCommandOptions(config) {
1934
1951
  const port = new HostRelayRequestBindingPort(config.relay_endpoint, config.ipc_timeout_ms);
1935
1952
  return {
@@ -1952,7 +1969,7 @@ async function runHostInvocationAuthenticationCommand(descriptor, args, options)
1952
1969
  }
1953
1970
  }
1954
1971
  async function authenticateHostInvocation(descriptor, input, options) {
1955
- if (input.length !== 3 || input[0] !== "authenticate" || input[1] !== "--client-nonce") throw new TypeError("invalid arguments");
1972
+ if (input.length !== HOST_INVOCATION_AUTHENTICATION_COMMAND_PREFIX.length + 1 || input[0] !== HOST_INVOCATION_AUTHENTICATION_COMMAND_PREFIX[0] || input[1] !== HOST_INVOCATION_AUTHENTICATION_COMMAND_PREFIX[1]) throw new TypeError("invalid arguments");
1956
1973
  const request2 = decodeCealHostInvocationAuthenticationRequest({ schema_version: CEAL_HOST_INVOCATION_AUTHENTICATION_REQUEST_SCHEMA, client_nonce: input[2] });
1957
1974
  const config = validateOptions(options, descriptor.command_name);
1958
1975
  const now = (config.now ?? (() => /* @__PURE__ */ new Date()))();
@@ -2338,6 +2355,7 @@ function isRecord3(value) {
2338
2355
 
2339
2356
  // host/codex/src/codex-outbox.ts
2340
2357
  var SAFE_REF6 = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u;
2358
+ var CODEX_TRANSCRIPT_PATH_MAX_CHARACTERS = 4096;
2341
2359
  var CodexOutboxStore = class {
2342
2360
  directory;
2343
2361
  entriesDirectory;
@@ -2704,13 +2722,13 @@ function validateRegistration(value) {
2704
2722
  }
2705
2723
  function validateRegistrationFields(value) {
2706
2724
  if (![value.host_source_ref, value.host_session_ref, value.codex_session_id].every((candidate) => typeof candidate === "string" && SAFE_REF6.test(candidate))) throw storageError(`Codex transcript registration references are malformed (${refusalFacts([{ name: "host_source_ref", value: value.host_source_ref }, { name: "host_session_ref", value: value.host_session_ref }, { name: "codex_session_id", value: value.codex_session_id }])}).`);
2707
- if (!validRegistrationCwd(value.cwd)) throw storageError(`Codex transcript registration working directory is malformed (${refusalFact("cwd_characters", typeof value.cwd === "string" ? value.cwd.length : 0, "an absolute path of at most 4096 characters")}).`);
2725
+ if (!validRegistrationCwd(value.cwd)) throw storageError(`Codex transcript registration working directory is malformed (${refusalFact("cwd_characters", typeof value.cwd === "string" ? value.cwd.length : 0, `an absolute path of at most ${CODEX_TRANSCRIPT_PATH_MAX_CHARACTERS} characters`)}).`);
2708
2726
  if (typeof value.transcript_path !== "string") throw storageError(`Codex transcript registration path is malformed (${refusalFact("kind", typeof value.transcript_path, "string")}).`);
2709
- if (value.transcript_path.length === 0 || value.transcript_path.length > 4096) throw storageError(`Codex transcript registration path is malformed (${refusalFact("characters", value.transcript_path.length, "from 1 through 4096")}).`);
2727
+ if (value.transcript_path.length === 0 || value.transcript_path.length > CODEX_TRANSCRIPT_PATH_MAX_CHARACTERS) throw storageError(`Codex transcript registration path is malformed (${refusalFact("characters", value.transcript_path.length, `from 1 through ${CODEX_TRANSCRIPT_PATH_MAX_CHARACTERS}`)}).`);
2710
2728
  if (!isTimestamp(value.registered_at) || !isTimestamp(value.expires_at)) throw storageError(`Codex transcript registration timestamps are malformed (${refusalFacts([{ name: "registered_at", value: value.registered_at }, { name: "expires_at", value: value.expires_at }])}).`);
2711
2729
  }
2712
2730
  function validRegistrationCwd(value) {
2713
- return value === void 0 || typeof value === "string" && isAbsolute2(value) && value.length <= 4096 && !value.includes("\0");
2731
+ return value === void 0 || typeof value === "string" && isAbsolute2(value) && value.length <= CODEX_TRANSCRIPT_PATH_MAX_CHARACTERS && !value.includes("\0");
2714
2732
  }
2715
2733
  function validateCursor(value) {
2716
2734
  if (!isRecord4(value)) throw storageError("Codex transcript cursor is malformed.");