@corca-org/ceal-host-win32-x64 1.0.7 → 1.0.9

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.
@@ -6,12 +6,6 @@ const require = __cealCreateRequire(import.meta.url);
6
6
  import { homedir as homedir3 } from "node:os";
7
7
  import { join as join6 } from "node:path";
8
8
 
9
- // host/session-start-affordance.ts
10
- var HOST_ENTRY_AFFORDANCE = "When the user asks to use Ceal or provides a link to information that may be available through installed organizational capabilities, first run the bare `ceal` shell command with no arguments; treat that link as a candidate Ceal resource rather than a public web-search target, and let the current Profile capability result supply the exact next steps.";
11
- function hostSessionStartEntryAffordance(hostName) {
12
- return `${HOST_ENTRY_AFFORDANCE} This text is the Ceal ${hostName} Host's own SessionStart hook running in this ${hostName} session. The Host owns this session's Request identity, and the generic client authenticates each call automatically; follow the required_action_sequence returned by bare \`ceal\`. Never run \`ceal request create\`, and never type, guess, or reuse --host-session-ref, --host-turn-ref, --prompt-ref, or any other session or turn reference.`;
13
- }
14
-
15
9
  // host/codex/src/codex-adapter.ts
16
10
  import { homedir } from "node:os";
17
11
  import { isAbsolute as isAbsolute3, join as join3, relative, resolve as resolve2 } from "node:path";
@@ -88,11 +82,28 @@ var client_wire_contract_default = {
88
82
  ],
89
83
  bare_document_fields: [
90
84
  "invocation",
91
- "next",
85
+ "required_action_sequence",
86
+ "entrypoints",
92
87
  "common_concepts",
93
88
  "operations",
94
89
  "catalog_revision"
95
90
  ],
91
+ prompt_field: "prompt",
92
+ prompt_schema_version: "ceal.prompt.v1",
93
+ focused_prompt_document_fields: [
94
+ "catalog_revision",
95
+ "prompt"
96
+ ],
97
+ focused_prompt_continuation_document_fields: [
98
+ "catalog_revision",
99
+ "remaining_work",
100
+ "prompt"
101
+ ],
102
+ discovery_command: "discovery",
103
+ discovery_manifest_schema_version: "ceal.discovery_manifest.v1",
104
+ discovery_manifest_document_fields: [
105
+ "discovery_manifest"
106
+ ],
96
107
  exit_code_max: 125,
97
108
  bare_document_max_bytes: 65536,
98
109
  complete_max_bytes: 66019,
@@ -119,8 +130,15 @@ var CEAL_VERIFIED_ARTIFACT_MAX_BYTES = artifact.max_bytes;
119
130
  var CEAL_VERIFIED_ARTIFACT_DESCRIPTOR_MAX_BYTES = artifact.envelope_max_bytes;
120
131
  var CEAL_COMMAND_REQUEST_SCHEMA_VERSION = request.schema_version;
121
132
  var CEAL_COMMAND_REQUEST_MAX_BYTES = request.absolute_transport_max_bytes;
122
- var CEAL_COMMAND_RESPONSE_BARE_DOCUMENT_FIELDS = response.bare_document_fields;
123
133
  var CEAL_COMMAND_RESPONSE_BARE_DOCUMENT_MAX_BYTES = response.bare_document_max_bytes;
134
+ var CEAL_COMMAND_RESPONSE_PROMPT_FIELD = response.prompt_field;
135
+ var CEAL_COMMAND_RESPONSE_PROMPT_SCHEMA_VERSION = response.prompt_schema_version;
136
+ var CEAL_COMMAND_RESPONSE_PROMPT_DOCUMENT_FIELDS = Object.freeze([...response.bare_document_fields, response.prompt_field]);
137
+ var CEAL_COMMAND_RESPONSE_FOCUSED_PROMPT_DOCUMENT_FIELDS = Object.freeze([...response.focused_prompt_document_fields]);
138
+ var CEAL_COMMAND_RESPONSE_FOCUSED_PROMPT_CONTINUATION_DOCUMENT_FIELDS = Object.freeze([...response.focused_prompt_continuation_document_fields]);
139
+ var CEAL_COMMAND_RESPONSE_DISCOVERY_COMMAND = response.discovery_command;
140
+ var CEAL_COMMAND_RESPONSE_DISCOVERY_MANIFEST_SCHEMA_VERSION = response.discovery_manifest_schema_version;
141
+ var CEAL_COMMAND_RESPONSE_DISCOVERY_MANIFEST_DOCUMENT_FIELDS = Object.freeze([...response.discovery_manifest_document_fields]);
124
142
  var CEAL_COMMAND_RESPONSE_MAX_BYTES = response.absolute_transport_max_bytes;
125
143
 
126
144
  // packages/ceal-client-protocol/src/vocabulary.ts
@@ -156,7 +174,7 @@ var CEAL_OPERATION_RECOVERY_KINDS = vocabulary(["none", "reconcile", "compensate
156
174
  var CEAL_OPERATION_RECOVERY_STATUSES = vocabulary(["not_started", "active", "completed"]);
157
175
  var CEAL_OPERATION_PROVIDER_READBACK_AVAILABILITY = vocabulary(["not_started", "not_applicable", "not_available", "pending", "available"]);
158
176
  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"]);
177
+ var CEAL_OPERATION_RECEIPT_AUTHORITY_KEYS = Object.freeze(["instance_ref", "access_group_ref", "principal_ref", "execution_subject_ref", "authority_revision_ref"]);
160
178
  var CEAL_OPERATION_APPROVAL_DISPOSITIONS = vocabulary([
161
179
  "approval_not_required_by_policy",
162
180
  "interactive_pending",
@@ -171,6 +189,8 @@ var CEAL_CAPABILITY_READINESS_VALUES = vocabulary(["ready", "degraded", "unavail
171
189
  var CEAL_TARGET_REQUIREMENTS = vocabulary(["required", "optional", "none"]);
172
190
  var CEAL_AUDIT_OUTCOMES = vocabulary(["succeeded", "denied", "failed"]);
173
191
  var CEAL_GATEWAY_PROVIDER_STEP_OUTCOMES = vocabulary(["completed", "rejected", "throttled", "failed"]);
192
+ var CEAL_GATEWAY_READ_REUSE_DISPOSITIONS = vocabulary(["response_cache_hit", "corpus_hit", "corpus_hit_after_revalidation", "corpus_partial_provider_supplement", "provider_direct", "provider_continuation", "reuse_unavailable"]);
193
+ var CEAL_GATEWAY_READ_REUSE_UNAVAILABLE_REASONS = vocabulary(["not_reported", "storage_unavailable", "coverage_incomplete", "freshness_refresh_required", "not_reusable", "bypassed"]);
174
194
  var CEAL_POLICY_DECISIONS = vocabulary(["allowed", "denied", "not_evaluated"]);
175
195
  var CEAL_CONNECTOR_ROUTE_PHASES = vocabulary(["scope_observation", "target_selection", "route_resolution"]);
176
196
  var CEAL_CONNECTOR_ROUTE_CAUSES = vocabulary(["provider_throttled", "provider_unavailable", "binding_invalid", "scope_limit_exceeded"]);
@@ -443,8 +463,10 @@ function requireIsoTimestamp(value, message) {
443
463
  var JSON_DESCRIPTION_CONTROL_CHARACTER = new RegExp("\\p{Cc}", "u");
444
464
 
445
465
  // packages/ceal-client-protocol/src/operation-contract-validation.ts
446
- var CEAL_OPERATION_AUTHORITY_POLICY_KEYS = Object.freeze(["profile", "instance_binding", "target", "admission_recheck"]);
466
+ var CEAL_OPERATION_AUTHORITY_POLICY_KEYS = Object.freeze(["access_group", "instance_binding", "target", "admission_recheck"]);
447
467
  var MAX_OPERATION_INPUT_RESOLVER_BINDINGS = 96;
468
+ var CEAL_OPERATION_DESCRIPTOR_REQUIRED_ENVELOPE_KEYS = Object.freeze(["schema_version", "id", "input_contract", "result_contract", "policy"]);
469
+ var CEAL_OPERATION_DESCRIPTOR_OPTIONAL_ENVELOPE_KEYS = Object.freeze(["input_resolution", "summary"]);
448
470
  var CEAL_OPERATION_RESULT_KEYS = vocabulary(["ok", "operation_id", "operation_receipt", "schema_version", "value"]);
449
471
  var CEAL_OPERATION_COMPACT_RESULT_KEYS = vocabulary(["ok", "operation_evidence", "operation_id", "schema_version", "value"]);
450
472
 
@@ -518,6 +540,7 @@ var CEAL_SCHEMA_LITERALS = [
518
540
  "ceal.operation_descriptor.v1",
519
541
  "ceal.operation_error.v1",
520
542
  "ceal.operation_failure.v1",
543
+ "ceal.operation_failure.compact.v1",
521
544
  "ceal.operation_receipt.v1",
522
545
  "ceal.operation_result.v1",
523
546
  "ceal.operation_result.compact.v1",
@@ -543,17 +566,16 @@ var CEAL_BOUNDED_SERIES_CATALOG = Object.freeze({
543
566
  engagement_signal: (root) => join(root, "runtime-state", "slack-feedback.jsonl"),
544
567
  runtime_error: (root) => join(root, "runtime-state", "runtime-errors.jsonl"),
545
568
  turn_bridge_request: (root) => join(root, ".ceal", "turn-bridge", "requests.jsonl"),
546
- channel_log: (root) => join(root, "log.jsonl"),
547
569
  thread_run_events: (root) => join(root, "run-events.jsonl"),
548
570
  bounded_store_sidecar: (root) => `${root}.jsonl`,
549
571
  gateway_audit_archive: (root) => `${root}.jsonl`,
550
572
  gateway_capability_audit: (root) => join(root, "capability-audit.jsonl"),
551
573
  gateway_retrieval_waste_partition: (root) => `${root}.jsonl`,
552
574
  gateway_access_policy_publication: (root) => join(root, "access-policy-publications.jsonl"),
553
- gateway_profile_connector_control_audit: (root) => `${root}.audit.jsonl`,
554
- gateway_profile_connector_scope_audit: (root) => join(root, "profile-connector-scope-audit.jsonl"),
555
- gateway_profile_connector_activity_scope_audit: (root) => join(root, "profile-connector-activity-scope-audit.jsonl"),
556
- gateway_profile_connector_readiness_audit: (root) => join(root, "profile-connector-readiness.audit.jsonl"),
575
+ gateway_access_group_connector_control_audit: (root) => `${root}.audit.jsonl`,
576
+ gateway_access_group_connector_scope_audit: (root) => join(root, "profile-connector-scope-audit.jsonl"),
577
+ gateway_access_group_connector_activity_scope_audit: (root) => join(root, "profile-connector-activity-scope-audit.jsonl"),
578
+ gateway_access_group_connector_readiness_audit: (root) => join(root, "profile-connector-readiness.audit.jsonl"),
557
579
  gateway_organization_audit_ledger: (root) => join(root, "organization-ledger.jsonl"),
558
580
  gateway_personal_client_audit: (root) => join(root, "audit.jsonl"),
559
581
  gateway_personal_client_access_audit: (root) => join(root, "access-audit.jsonl"),
@@ -604,12 +626,6 @@ var CEAL_AGENT_SESSION_COMMIT_KEYS = vocabulary(["attempt_ref", "expected_sessio
604
626
  // packages/ceal-client-protocol/src/operation-next-actions.ts
605
627
  var CALLER_RECOVERABLE_NEXT_ACTION_VALUES = [
606
628
  "select_did_you_mean",
607
- // The graph, not the argument list, is what the caller must change: the
608
- // resolver that owns this input has no producing node upstream, and no edit
609
- // to the invocation can conjure one. `resolver_dependency_absent` carried no
610
- // remedy at all rather than borrow a word that means something else, so the
611
- // scorer read a fully-diagnosed, caller-fixable refusal as a failed run.
612
- "request.graph.append",
613
629
  "choose_new_output_path",
614
630
  "choose_new_idempotency_key",
615
631
  "restart_search",
@@ -661,8 +677,6 @@ var NON_REMEDY_NEXT_ACTION_VALUES = [
661
677
  "reconcile_occurrence",
662
678
  "reduce_request_size",
663
679
  "repair_or_adopt_session",
664
- "request.effect_approval.read",
665
- "request.run",
666
680
  "retry",
667
681
  // The owner -- a correlation hook, an approval hook -- is not serving right
668
682
  // now. The caller changes nothing and the same call succeeds once the owner
@@ -759,12 +773,12 @@ var CEAL_REQUEST_JSON_SCHEMA = {
759
773
  additionalProperties: false,
760
774
  properties: {
761
775
  instance_ref: { type: "string", minLength: 1, maxLength: 128, pattern: SAFE_REF.source },
762
- profile_ref: { type: "string", minLength: 1, maxLength: 128, pattern: SAFE_REF.source },
776
+ access_group_ref: { type: "string", minLength: 1, maxLength: 128, pattern: SAFE_REF.source },
763
777
  principal_ref: { type: "string", minLength: 1, maxLength: 128, pattern: SAFE_REF.source },
764
778
  execution_subject_ref: { type: "string", minLength: 1, maxLength: 128, pattern: SAFE_REF.source },
765
779
  authority_revision_ref: { type: "string", minLength: 1, maxLength: 128, pattern: SAFE_REF.source }
766
780
  },
767
- required: ["instance_ref", "profile_ref", "principal_ref", "execution_subject_ref", "authority_revision_ref"]
781
+ required: ["instance_ref", "access_group_ref", "principal_ref", "execution_subject_ref", "authority_revision_ref"]
768
782
  },
769
783
  prompt_ref: { type: "string", minLength: 1, maxLength: 128, pattern: SAFE_REF.source },
770
784
  host_session_ref: { type: "string", minLength: 1, maxLength: 128, pattern: SAFE_REF.source },
@@ -896,7 +910,7 @@ var CEAL_HOST_OBSERVATION_KINDS = vocabulary(["prompt", "session", "turn", "mode
896
910
  function isCealHostPromptObservationValue(value) {
897
911
  return isOperationRecord(value) && Object.keys(value).length === 1 && isCealDigest(value.body_sha256);
898
912
  }
899
- var HOST_RESERVED_KEY = /^(?:admission|approval|audit|authorization|cancellation|capability|effect|grant|occurrence|operation|policy|profile|provider_readback|receipt|reconciliation|replay|target|write_request)(?:_|$)/iu;
913
+ var HOST_RESERVED_KEY = /^(?:access_group|admission|approval|audit|authorization|cancellation|capability|effect|grant|occurrence|operation|policy|profile|provider_readback|receipt|reconciliation|replay|target|write_request)(?:_|$)/iu;
900
914
  function assertHostObservationValue(value, kind) {
901
915
  if (value === void 0) invalid("Ceal Host observation value is invalid.");
902
916
  if (kind === "prompt" && !isCealHostPromptObservationValue(value)) invalid("Ceal Host prompt observation must contain only its body digest.");
@@ -916,6 +930,14 @@ function inspectHostKeys(value) {
916
930
  }
917
931
  }
918
932
 
933
+ // packages/ceal-client-protocol/src/host-prompt-ref.ts
934
+ var CEAL_HOST_PROMPT_DIGEST_PATTERN = "^[a-f0-9]{64}$";
935
+ var PROMPT_DIGEST = new RegExp(CEAL_HOST_PROMPT_DIGEST_PATTERN, "u");
936
+ function hostProducerPromptRef(promptSha256) {
937
+ if (!PROMPT_DIGEST.test(promptSha256)) throw new TypeError("Canonical Host prompt digest is invalid.");
938
+ return `ceal-host-prompt:${promptSha256}`;
939
+ }
940
+
919
941
  // packages/ceal-client-protocol/src/request-effect-approval.ts
920
942
  var CEAL_EFFECT_APPROVAL_DECISION_CHECK_PHRASES = Object.freeze([
921
943
  "observed after this approval was raised and before it expires",
@@ -931,6 +953,12 @@ var OWNER_WRITE_STATES = Object.freeze(["attempt_started", "provider_acknowledge
931
953
  var OWNER_EFFECT_STATES = Object.freeze(["none", "applied", "failed", "unknown", "reconciled"]);
932
954
  var OWNER_RECEIPT_STATES = Object.freeze(["pending", "available", "failed", "unknown", "reconciled"]);
933
955
 
956
+ // packages/ceal-client-protocol/src/thread-excerpt.ts
957
+ var CEAL_THREAD_RECENT_WINDOW = 6;
958
+ var CEAL_THREAD_LAST_APP_MESSAGES_WINDOW = 3;
959
+ var CEAL_THREAD_OLDER_SUMMARY_WINDOW = 4;
960
+ var CEAL_FED_THREAD_MESSAGE_LIMIT = CEAL_THREAD_RECENT_WINDOW + CEAL_THREAD_OLDER_SUMMARY_WINDOW + CEAL_THREAD_LAST_APP_MESSAGES_WINDOW;
961
+
934
962
  // packages/ceal-client-protocol/src/request-graph-readiness.ts
935
963
  var REQUEST_GRAPH_PRODUCER_TO_APPEND_SCHEMA = {
936
964
  type: "object",
@@ -1010,6 +1038,13 @@ var CEAL_REQUEST_GRAPH_NODE_PREPARE_READINESS_JSON_SCHEMA = {
1010
1038
  var REQUIRED_FIELDS = Object.freeze(["schema_version", "operation_id", "local_path", "content_json_pointer", "size_bytes", "sha256", "read_argv"]);
1011
1039
  var FIELDS = /* @__PURE__ */ new Set([...REQUIRED_FIELDS, "local_result_root", "model_disclosure"]);
1012
1040
 
1041
+ // packages/ceal-client-protocol/src/session-start-affordance.ts
1042
+ var CEAL_SESSION_ENTRY_INVOCATION = "ceal";
1043
+ var CEAL_LINK_RESOURCE_PRECEDENCE = `When the user asks to use Ceal or provides a link to information that may be available through installed organizational capabilities, run bare \`${CEAL_SESSION_ENTRY_INVOCATION}\`. The Host supplies the current user prompt without exposing it to the client command, and the Gateway returns the applicable entry in that one response. Treat a supplied link as a candidate Ceal resource rather than a public web-search target. Reach for a generic web fetch or web search only when the Gateway offered nothing.`;
1044
+
1045
+ // packages/ceal-client-protocol/src/discovery-manifest.ts
1046
+ var CEAL_DISCOVERY_MANIFEST_CONNECTOR_KINDS = vocabulary(["github", "google-workspace", "notion", "slack"]);
1047
+
1013
1048
  // packages/ceal-client-protocol/src/conversation-contracts.ts
1014
1049
  var CEAL_APPROVAL_POLICY_KINDS = vocabulary(["requester_only", "named_users", "role_based"]);
1015
1050
  var CEAL_APPROVAL_TARGET_KINDS = vocabulary([
@@ -1226,7 +1261,7 @@ var CEAL_PRESENTATION_INTENTS = vocabulary(["progress", ...CEAL_FINAL_PRESENTATI
1226
1261
 
1227
1262
  // packages/ceal-client-protocol/src/personal-client-vocabulary.ts
1228
1263
  var CEAL_PERSONAL_CLIENT_BINDING_KEYS = vocabulary([
1229
- "profile_ref",
1264
+ "access_group_ref",
1230
1265
  "membership_ref",
1231
1266
  "registration_ref",
1232
1267
  "client_ref",
@@ -1983,7 +2018,6 @@ var HOST_PRODUCER_FRAME_SCHEMA = "ceal.host_producer_frame.v1";
1983
2018
  var HOST_PRODUCER_MAX_JSON_BYTES = 262144;
1984
2019
  var HOST_PRODUCER_FRAME_LENGTH_BYTES = Uint32Array.BYTES_PER_ELEMENT;
1985
2020
  var SAFE_REF4 = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u;
1986
- var DIGEST2 = /^[a-f0-9]{64}$/u;
1987
2021
  var PRODUCERS = /* @__PURE__ */ new Set(["codex", "claude"]);
1988
2022
  var HOST_PRODUCER_FRAME_KINDS = ["session_started", "turn_started", "user_input", "turn_terminal", "producer_status"];
1989
2023
  var FRAME_KINDS = new Set(HOST_PRODUCER_FRAME_KINDS);
@@ -2024,10 +2058,6 @@ function decodeHostProducerFrame(input) {
2024
2058
  validateFrame(value);
2025
2059
  return value;
2026
2060
  }
2027
- function hostProducerPromptRef(promptSha256) {
2028
- if (!DIGEST2.test(promptSha256)) throw new TypeError("Canonical Host prompt digest is invalid.");
2029
- return `ceal-host-prompt:${promptSha256}`;
2030
- }
2031
2061
  function validateFrame(value) {
2032
2062
  if (!record(value)) throw new HostProducerFrameError("invalid_frame_shape");
2033
2063
  if (value.schema_version !== HOST_PRODUCER_FRAME_SCHEMA) throw new HostProducerFrameError("unsupported_frame_schema", `unsupported_frame_schema: ${refusalFact("schema_version", value.schema_version, HOST_PRODUCER_FRAME_SCHEMA)}`);
@@ -2502,9 +2532,16 @@ var RELAY_QUARANTINE_MAX_BYTES = 16 * 1024 * 1024;
2502
2532
 
2503
2533
  // host/relay/src/relay-admission-store.ts
2504
2534
  var DEFAULT_LIMITS = { global_count: 8192, global_bytes: 64 * 1024 * 1024, producer_count: 4096, producer_bytes: 32 * 1024 * 1024 };
2535
+ var RETRY_SECONDS = [1, 2, 4, 8, 16, 32, 60];
2536
+ var MAX_RETRYABLE_ATTEMPTS = RETRY_SECONDS.length + 10;
2505
2537
 
2506
2538
  // host/relay/src/relay-ipc.ts
2507
2539
  import { createConnection, createServer } from "node:net";
2540
+
2541
+ // host/relay/src/current-prompt-custody.ts
2542
+ var HOST_CURRENT_PROMPT_MAX_BYTES = 256 * 1024;
2543
+
2544
+ // host/relay/src/relay-ipc.ts
2508
2545
  var HOST_RELAY_REQUEST_BINDING_KEYS = Object.freeze([
2509
2546
  "schema_version",
2510
2547
  "producer_id",
@@ -2521,6 +2558,8 @@ var HOST_RELAY_REQUEST_BINDING_KEYS = Object.freeze([
2521
2558
  "host_input_ref"
2522
2559
  ]);
2523
2560
  var HOST_RELAY_IPC_RESPONSE_SCHEMA = "ceal.host_relay_admission.v1";
2561
+ var HOST_RELAY_CURRENT_PROMPT_REGISTER_SCHEMA = "ceal.host_relay_current_prompt_register.v1";
2562
+ var HOST_RELAY_CURRENT_PROMPT_RESULT_SCHEMA = "ceal.host_relay_current_prompt_result.v1";
2524
2563
  var HOST_RELAY_IPC_LENGTH_BYTES = Uint32Array.BYTES_PER_ELEMENT;
2525
2564
  var HOST_RELAY_ADMISSION_RESPONSE_MAX_BYTES = 4096;
2526
2565
  var HostRelayIpcError = class extends Error {
@@ -2543,22 +2582,42 @@ var HostRelayIpcAdmissionPort = class {
2543
2582
  return { code: response2.code, admitted_through_sequence: response2.admitted_through_sequence, delivered_through_sequence: response2.delivered_through_sequence };
2544
2583
  }
2545
2584
  };
2585
+ var HostRelayCurrentPromptPort = class {
2586
+ endpoint;
2587
+ timeout_ms;
2588
+ constructor(endpoint, timeoutMs = 5e3) {
2589
+ this.endpoint = endpoint;
2590
+ this.timeout_ms = timeoutMs;
2591
+ }
2592
+ async register(input) {
2593
+ const request2 = { schema_version: HOST_RELAY_CURRENT_PROMPT_REGISTER_SCHEMA, ...input };
2594
+ const response2 = await exchange(this.endpoint, encodeLengthPrefixed(request2), this.timeout_ms, decodeCurrentPromptResponseBuffer);
2595
+ if (response2.status !== "registered") throw new HostRelayIpcError("relay_unavailable", response2.status);
2596
+ }
2597
+ };
2546
2598
  function submitHostProducerFrame(endpoint, frame, timeoutMs = 5e3) {
2547
2599
  return exchange(endpoint, encodeHostProducerFrame(frame), timeoutMs, decodeResponseBuffer);
2548
2600
  }
2549
- function exchange(endpoint, encoded, timeoutMs, decode) {
2601
+ function exchange(endpoint, encoded, timeoutMs, decode, signal) {
2550
2602
  return new Promise((resolve3, reject3) => {
2551
2603
  const socket = createConnection(endpoint);
2552
2604
  let buffer = Buffer.alloc(0);
2553
2605
  let settled = false;
2606
+ const aborted = () => finish(new HostRelayIpcError("relay_unavailable", "Host Relay IPC was cancelled."));
2554
2607
  const finish = (error, response2) => {
2555
2608
  if (settled) return;
2556
2609
  settled = true;
2610
+ signal?.removeEventListener("abort", aborted);
2557
2611
  socket.destroy();
2558
2612
  if (error !== null) reject3(error);
2559
2613
  else if (response2 !== void 0) resolve3(response2);
2560
2614
  };
2561
- socket.setTimeout(timeoutMs, () => finish(new HostRelayIpcError("relay_unavailable", "Host Relay IPC timed out.")));
2615
+ if (timeoutMs !== void 0) socket.setTimeout(timeoutMs, () => finish(new HostRelayIpcError("relay_unavailable", "Host Relay IPC timed out.")));
2616
+ if (signal?.aborted === true) {
2617
+ aborted();
2618
+ return;
2619
+ }
2620
+ signal?.addEventListener("abort", aborted, { once: true });
2562
2621
  socket.once("error", () => finish(new HostRelayIpcError("relay_unavailable", "Host Relay IPC is unavailable.")));
2563
2622
  socket.once("connect", () => socket.write(encoded));
2564
2623
  socket.on("data", (chunk) => {
@@ -2611,6 +2670,34 @@ function decodeResponseBuffer(buffer) {
2611
2670
  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}` }])}.`);
2612
2671
  return decodeHostRelayIpcResponse(buffer);
2613
2672
  }
2673
+ function decodeCurrentPromptResponseBuffer(buffer) {
2674
+ const value = decodeLengthPrefixedJson(buffer, HOST_RELAY_ADMISSION_RESPONSE_MAX_BYTES);
2675
+ if (value === null) return null;
2676
+ if (!record2(value) || !exactKeys4(value, ["schema_version", "status"]) || value.schema_version !== HOST_RELAY_CURRENT_PROMPT_RESULT_SCHEMA || value.status !== "registered" && value.status !== "current_prompt_unavailable") throw new HostRelayIpcError("relay_unavailable");
2677
+ return { schema_version: HOST_RELAY_CURRENT_PROMPT_RESULT_SCHEMA, status: value.status };
2678
+ }
2679
+ function decodeLengthPrefixedJson(input, maximum) {
2680
+ if (input.length < HOST_RELAY_IPC_LENGTH_BYTES) return null;
2681
+ const length = input.readUInt32BE(0);
2682
+ 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}`)}.`);
2683
+ if (input.length < length + HOST_RELAY_IPC_LENGTH_BYTES) return null;
2684
+ 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}` }])}.`);
2685
+ try {
2686
+ return JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(input.subarray(HOST_RELAY_IPC_LENGTH_BYTES)));
2687
+ } catch {
2688
+ throw new HostRelayIpcError("relay_unavailable", "Host Relay IPC message is invalid.");
2689
+ }
2690
+ }
2691
+ function encodeLengthPrefixed(value) {
2692
+ const body = Buffer.from(JSON.stringify(value), "utf8");
2693
+ const output = Buffer.allocUnsafe(body.length + HOST_RELAY_IPC_LENGTH_BYTES);
2694
+ output.writeUInt32BE(body.length, 0);
2695
+ body.copy(output, HOST_RELAY_IPC_LENGTH_BYTES);
2696
+ return output;
2697
+ }
2698
+ function exactKeys4(value, keys) {
2699
+ return Object.keys(value).length === keys.length && keys.every((key) => Object.hasOwn(value, key));
2700
+ }
2614
2701
 
2615
2702
  // host/codex/src/codex-producer.ts
2616
2703
  import { createHash as createHash3 } from "node:crypto";
@@ -3353,6 +3440,8 @@ var CodexTranscriptWatcher = class {
3353
3440
  now;
3354
3441
  log;
3355
3442
  retriedMalformedQuarantines = /* @__PURE__ */ new Set();
3443
+ producerInstallationRef;
3444
+ registerCurrentPrompt;
3356
3445
  constructor(options) {
3357
3446
  if (typeof options.outbox_dir !== "string" || options.outbox_dir.length === 0) throw new CodexHostAdapterError("configuration", "Codex transcript watcher outbox is invalid.");
3358
3447
  this.store = new CodexOutboxStore(options.outbox_dir);
@@ -3362,6 +3451,8 @@ var CodexTranscriptWatcher = class {
3362
3451
  process.stderr.write(`${line}
3363
3452
  `);
3364
3453
  });
3454
+ this.producerInstallationRef = options.producer_installation_ref;
3455
+ this.registerCurrentPrompt = options.register_current_prompt;
3365
3456
  }
3366
3457
  async scanOnce() {
3367
3458
  const registrations = await this.store.listTranscriptRegistrations();
@@ -3506,10 +3597,15 @@ var CodexTranscriptWatcher = class {
3506
3597
  created_at: record3.timestamp,
3507
3598
  expires_at: expiration(this.now, this.outboxRetentionMs)
3508
3599
  };
3600
+ await this.registerPrompt(origin, registration, activeTask, currentPromptRef, record3.prompt, envelope.expires_at);
3509
3601
  await this.store.put(envelope);
3510
3602
  if (origin) await this.store.activateInvocationContext(identity, promptRef, envelope.expires_at);
3511
3603
  return { activeTask: { ...activeTask, origin_host_input_ref: activeTask.origin_host_input_ref ?? hostInputRef, prompt_ref: activeTask.prompt_ref ?? currentPromptRef }, enqueued: 1 };
3512
3604
  }
3605
+ async registerPrompt(origin, registration, activeTask, promptRef, prompt, expiresAt) {
3606
+ if (!origin || this.producerInstallationRef === void 0 || this.registerCurrentPrompt === void 0) return;
3607
+ await this.registerCurrentPrompt({ producer_id: "codex", producer_installation_ref: this.producerInstallationRef, local_session_ref: registration.host_session_ref, local_turn_ref: activeTask.host_turn_ref, prompt_ref: promptRef, current_prompt: prompt, context_expires_at: expiresAt });
3608
+ }
3513
3609
  async processTerminal(registration, activeTask, record3) {
3514
3610
  if (activeTask === void 0 || activeTask.codex_turn_id !== record3.turn_id || activeTask.origin_host_input_ref === void 0 || activeTask.prompt_ref === void 0) return { ...activeTask === void 0 ? {} : { activeTask }, enqueued: 0 };
3515
3611
  const identity = { host_source_ref: registration.host_source_ref, host_session_ref: registration.host_session_ref, host_turn_ref: activeTask.host_turn_ref };
@@ -3714,7 +3810,8 @@ function expiration(now, retentionMs) {
3714
3810
 
3715
3811
  // host/codex/src/codex-producer-runtime.ts
3716
3812
  async function drainCodexProducerOnce(options) {
3717
- const scan = await new CodexTranscriptWatcher({ outbox_dir: options.outbox_dir }).scanOnce();
3813
+ const promptPort = new HostRelayCurrentPromptPort(options.relay_endpoint, options.timeout_ms);
3814
+ const scan = await new CodexTranscriptWatcher({ outbox_dir: options.outbox_dir, producer_installation_ref: options.producer_installation_ref, register_current_prompt: (input) => promptPort.register(input) }).scanOnce();
3718
3815
  const producer = new CodexProducer({ outbox_dir: options.outbox_dir, producer_installation_ref: options.producer_installation_ref, relay: new HostRelayIpcAdmissionPort(options.relay_endpoint, options.timeout_ms), ...options.producer_epoch === void 0 ? {} : { producer_epoch: options.producer_epoch }, ...options.now === void 0 ? {} : { now: options.now } });
3719
3816
  return { scanned: scan.enqueued, ...await producer.drainOutbox() };
3720
3817
  }
@@ -3816,7 +3913,6 @@ function sameKeys2(value, required, optional = []) {
3816
3913
 
3817
3914
  // host/codex/src/codex-hook-runner.ts
3818
3915
  var MAX_STDIN_BYTES = 64 * 1024;
3819
- var CODEX_SESSION_START_ENTRY_AFFORDANCE = hostSessionStartEntryAffordance("Codex");
3820
3916
  async function runCodexHookFromStdin(event, stdin, options) {
3821
3917
  const adapter = createCodexHostObservationAdapter(options);
3822
3918
  return adapter.handle(event, await readStdin(stdin));
@@ -3838,17 +3934,21 @@ function defaultCodexHookRunnerOptions(gateway) {
3838
3934
  async function runCodexHookProcess(args, stdin, options) {
3839
3935
  const event = codexHookEventFromArgs(args);
3840
3936
  if (event === null) return 0;
3841
- const result = await runCodexHookFromStdin(event, stdin, options);
3842
- const additionalContext = codexHookAdditionalContext(result);
3843
- if (additionalContext !== null) process.stdout.write(`${codexHookOutput(result.event, additionalContext)}
3844
- `);
3845
- return 0;
3846
- }
3847
- function codexHookOutput(event, additionalContext) {
3848
- return JSON.stringify({ hookSpecificOutput: { hookEventName: event, additionalContext } });
3937
+ try {
3938
+ const result = await runCodexHookFromStdin(event, stdin, options);
3939
+ if (result.disposition === "rejected") writeCodexHookDiagnostic(result);
3940
+ return 0;
3941
+ } catch (error) {
3942
+ writeCodexHookDiagnostic({ event, disposition: "rejected", reason: error instanceof Error ? error.message.slice(0, 128) : "codex_hook_failed" });
3943
+ return 0;
3944
+ }
3849
3945
  }
3850
- function codexHookAdditionalContext(result) {
3851
- return result.event === "SessionStart" ? CODEX_SESSION_START_ENTRY_AFFORDANCE : null;
3946
+ function writeCodexHookDiagnostic(result) {
3947
+ try {
3948
+ process.stderr.write(`${JSON.stringify({ schema_version: "ceal.codex_sessionstart_diagnostic.v1", event: result.event, disposition: result.disposition, ...result.reason === void 0 ? {} : { reason: result.reason } })}
3949
+ `);
3950
+ } catch {
3951
+ }
3852
3952
  }
3853
3953
  async function readStdin(stdin) {
3854
3954
  const chunks = [];