@corca-org/ceal-host-linux-arm64 1.0.15 → 1.0.17

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.
@@ -2,10 +2,6 @@
2
2
  import { createRequire as __cealCreateRequire } from "node:module";
3
3
  const require = __cealCreateRequire(import.meta.url);
4
4
 
5
- // host/codex/src/codex-hook-runner.ts
6
- import { homedir as homedir3 } from "node:os";
7
- import { join as join6 } from "node:path";
8
-
9
5
  // host/codex/src/codex-adapter.ts
10
6
  import { homedir } from "node:os";
11
7
  import { isAbsolute as isAbsolute3, join as join3, relative, resolve as resolve2 } from "node:path";
@@ -142,7 +138,7 @@ var client_wire_contract_default = {
142
138
  "prompt"
143
139
  ],
144
140
  discovery_command: "discovery",
145
- discovery_manifest_schema_version: "ceal.discovery_manifest.v2",
141
+ discovery_manifest_schema_version: "ceal.discovery_manifest.v1",
146
142
  discovery_manifest_document_fields: [
147
143
  "discovery_manifest"
148
144
  ],
@@ -216,10 +212,11 @@ var CEAL_AUDIT_OUTCOMES = vocabulary(["succeeded", "denied", "failed"]);
216
212
  var CEAL_GATEWAY_PROVIDER_STEP_OUTCOMES = vocabulary(["completed", "rejected", "throttled", "failed"]);
217
213
  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"]);
218
214
  var CEAL_GATEWAY_READ_REUSE_UNAVAILABLE_REASONS = vocabulary(["not_reported", "storage_unavailable", "coverage_incomplete", "freshness_refresh_required", "not_reusable", "bypassed"]);
215
+ var CEAL_GATEWAY_DERIVED_STORE_FAILURE_CLASSES = vocabulary(["storage_unavailable", "decode_mismatch", "write_conflict", "quota", "store_error"]);
219
216
  var CEAL_POLICY_DECISIONS = vocabulary(["allowed", "denied", "not_evaluated"]);
220
217
  var CEAL_CONNECTOR_ROUTE_PHASES = vocabulary(["scope_observation", "target_selection", "route_resolution"]);
221
218
  var CEAL_CONNECTOR_ROUTE_CAUSES = vocabulary(["provider_throttled", "provider_unavailable", "binding_invalid", "scope_limit_exceeded"]);
222
- var CEAL_WRITE_SOURCE_KINDS = vocabulary(["authenticated_registered_client", "agent_lease_admission", "provider_authenticated_event"]);
219
+ var CEAL_WRITE_SOURCE_KINDS = vocabulary(["authenticated_registered_client", "provider_authenticated_event"]);
223
220
  var CEAL_REFRESH_DELIVERIES = vocabulary(["initial", "recovery", "replay", "terminal_failure", "recovery_unavailable"]);
224
221
  var CEAL_CLIENT_OPERATIONS = vocabulary(["handshake", "discover", "call", "readback"]);
225
222
  var CEAL_WRITE_IDEMPOTENCY_POSTURES = vocabulary(["required", "optional", "not_required"]);
@@ -229,6 +226,17 @@ var CEAL_WRITE_RECEIPT_PROVIDER_STATES = vocabulary(["outcome_unknown", "verifie
229
226
  var CEAL_WRITE_RECEIPT_PROVIDER_READBACKS = vocabulary(["outcome_unknown", "verified", "not_applied"]);
230
227
  var CEAL_PROTOCOL_VERSION = "1.4.0";
231
228
  var CEAL_OPERATION_ACCESS_SCHEMA_VERSION = "ceal.operation_access.v1";
229
+ var CEAL_GATEWAY_ACTIVE_CALL_PHASES = vocabulary([
230
+ "audited_call_pending",
231
+ "continuation_read_pending",
232
+ "continuation_write_pending",
233
+ "provider_pacing_pending",
234
+ "corpus_replay_pending",
235
+ "corpus_append_pending",
236
+ "corpus_fence_pending",
237
+ "corpus_content_pending",
238
+ "corpus_transaction_pending"
239
+ ]);
232
240
  var CEAL_CONNECTOR_ROUTE_FAILURE_KEYS = vocabulary(["connector_kind", "phase", "schema_version"]);
233
241
  var CEAL_CLASSIFIED_CONNECTOR_ROUTE_FAILURE_KEYS = vocabulary(["cause", ...CEAL_CONNECTOR_ROUTE_FAILURE_KEYS]);
234
242
  var CEAL_UNCLASSIFIED_CONNECTOR_ROUTE_FAILURE_KEYS = vocabulary(["connector_kind", "error_class", "phase", "schema_version"]);
@@ -238,10 +246,130 @@ var CEAL_GATEWAY_ORGANIZATION_ROUTE_FACT_CALL_KEYS = Object.freeze([
238
246
  "policy_decision_revision"
239
247
  ]);
240
248
 
249
+ // packages/ceal-client-protocol/src/operation-next-actions.ts
250
+ var CEAL_REPEAT_REQUEST_NEXT_ACTION = "repeat_request";
251
+ var CEAL_INSPECT_RECEIPT_NEXT_ACTION = "inspect_receipt";
252
+ var CALLER_RECOVERABLE_NEXT_ACTION_VALUES = [
253
+ "select_did_you_mean",
254
+ "choose_new_output_path",
255
+ "choose_new_idempotency_key",
256
+ "restart_search",
257
+ "repeat_original_arguments",
258
+ // The occurrence this call addressed is settled and cannot move again -- a
259
+ // denied effect approval, an expired continuation -- so the caller runs the
260
+ // same call again as a new request. The refusal names the re-request; this
261
+ // word is the re-request.
262
+ CEAL_REPEAT_REQUEST_NEXT_ACTION,
263
+ "choose_new_request_identity",
264
+ // A refusal that names the argument (invalid_argument with `property`) tells the caller exactly what to change.
265
+ "correct_argument",
266
+ // A resolver-owned input must move from caller operands into the declared
267
+ // resolver selection field.
268
+ "supply_resolver_selections",
269
+ // The graph names an upstream node whose Operation produces the resolver's
270
+ // occurrence, and it has not produced one yet. The caller runs that node
271
+ // first; the refusal used to share a code with a malformed resolver result,
272
+ // which is not fixable, so neither could carry a remedy.
273
+ "run_resolver_dependency",
274
+ // A replay carries the input the occurrence durably admitted, and this one
275
+ // carries a different one. The caller fixes it by presenting the original
276
+ // invocation, so it is a remedy; the coordinator minted the word at the
277
+ // replay guard and never declared it, which read as unguided to the scorer.
278
+ "use_original_input",
279
+ // The same mismatch on the Request binding rather than the input: the
280
+ // occurrence was admitted under one binding and the replay presents another.
281
+ "use_original_request_binding",
282
+ // The client's own filesystem write was refused -- EACCES, EPERM, or a
283
+ // read-only mount -- which is how an agent sandbox fences writes outside its
284
+ // workspace. The caller reruns the same command with unsandboxed or escalated
285
+ // execution; re-adopting the session cannot help, because the sandbox refuses
286
+ // that write too.
287
+ "rerun_outside_agent_sandbox",
288
+ // The refusal names the one Operation to read next in `describe_command`:
289
+ // an absent Operation id with a sole catalog-ranked candidate, or a known
290
+ // Operation invoked without its input. Describing only reads the verified
291
+ // contract and dispatches nothing, and the caller then retries with the
292
+ // named Operation or input, so it is guidance the scorer counts.
293
+ "describe_operation",
294
+ // The refusal names the caller's own personal connect Operation in
295
+ // `required_action_sequence`: the Operation asked for, or the credential
296
+ // the call ran on, needs a personal connection the caller does not hold
297
+ // (never connected, revoked, or expired). The caller runs that exact
298
+ // Operation, completes the consent it hands back, and retries the same call.
299
+ "connect_personal_account",
300
+ // The provider or Gateway named a bounded wait; the caller waits that long
301
+ // and submits the same read again.
302
+ "retry_after",
303
+ // The ref names a container of rows (a Notion database or data source), which
304
+ // has no body of its own; the caller searches its rows instead of reading it.
305
+ "search_container_rows"
306
+ ];
307
+ var CEAL_CALLER_RECOVERABLE_NEXT_ACTIONS = Object.freeze(CALLER_RECOVERABLE_NEXT_ACTION_VALUES);
308
+ var NON_REMEDY_NEXT_ACTION_VALUES = [
309
+ // Only an administrator can take the named step -- approving a place for an
310
+ // Operation, granting a withheld capability -- so a non-administrator asks
311
+ // one. The refusal names the administrator step; this word is the ask.
312
+ "ask_admin",
313
+ "await_pending_approval",
314
+ "check_gateway",
315
+ "inspect_context_store",
316
+ "inspect_gateway",
317
+ "inspect_local_cache",
318
+ // The thin client prints these on its own behalf, before or after the wire.
319
+ // They were declared only as `CealClientLocalRemedy` keys and, for two of
320
+ // them, only as Go string literals -- a second and third vocabulary for one
321
+ // thing. `CealClientLocalRemedy` derives from this list now, so the client's
322
+ // remedies cannot drift from the words the protocol knows.
323
+ "inspect_local_client",
324
+ "inspect_local_command",
325
+ "inspect_local_output",
326
+ "inspect_local_route",
327
+ CEAL_INSPECT_RECEIPT_NEXT_ACTION,
328
+ "inspect_request",
329
+ "none",
330
+ // The provider refused because of its own configuration -- an API not
331
+ // enabled, an app scope missing -- which an operator changes in that
332
+ // provider's console. No caller edit and no retry fixes it.
333
+ "operator_action",
334
+ "recover",
335
+ "reconcile",
336
+ // Reconciliation of one named occurrence, not of the deployment: an
337
+ // occurrence with no admitted input commitment cannot be replayed safely and
338
+ // no edit to the call changes that. `reconcile` is the deployment-wide word.
339
+ "reconcile_occurrence",
340
+ "reduce_request_size",
341
+ // The Host's invocation context for this turn is stale or expired at the
342
+ // Gateway. The Host's next turn rebinds it and the same call then succeeds;
343
+ // nothing in the call changes, so it is not a remedy the scorer may count.
344
+ "refresh_host_invocation_context",
345
+ "repair_or_adopt_session",
346
+ "retry",
347
+ // The owner -- a correlation hook, an approval hook -- is not serving right
348
+ // now. The caller changes nothing and the same call succeeds once the owner
349
+ // is back, so this is not a remedy the scorer may count as guidance.
350
+ "retry_after_owner_recovery",
351
+ "retry_same_receipt_read",
352
+ "run_file_search_again",
353
+ "select_exact_approval"
354
+ ];
355
+ var CEAL_NON_REMEDY_NEXT_ACTIONS = Object.freeze(NON_REMEDY_NEXT_ACTION_VALUES);
356
+ var DECLARED = /* @__PURE__ */ new Set([...CEAL_CALLER_RECOVERABLE_NEXT_ACTIONS, ...CEAL_NON_REMEDY_NEXT_ACTIONS]);
357
+ var RETRY_PROMISE_NEXT_ACTIONS = ["retry", "retry_after"];
358
+ var RETRY_PROMISE = new Set(RETRY_PROMISE_NEXT_ACTIONS);
359
+ var RECOVERABLE = new Set(CEAL_CALLER_RECOVERABLE_NEXT_ACTIONS);
360
+ var CEAL_OPERATION_WITHHELD_NEXT_ACTIONS = Object.freeze({
361
+ provider_permission: "ask_admin",
362
+ access_level: "ask_admin",
363
+ personal_authorization_required: "connect_personal_account"
364
+ });
365
+
366
+ // packages/ceal-client-protocol/src/operation-withheld-cause.ts
367
+ var CEAL_OPERATION_WITHHELD_CAUSES = vocabulary(["provider_permission", "access_level", "personal_authorization_required"]);
368
+
241
369
  // packages/ceal-client-protocol/src/operation-contract-types.ts
242
370
  var CEAL_JSON_SCHEMA_2020_12 = "https://json-schema.org/draft/2020-12/schema";
243
371
  var CEAL_OPERATION_ERROR_SCHEMA_VERSION = "ceal.operation_error.v1";
244
- var CEAL_OPERATION_WITHHELD_CAUSES = vocabulary(["provider_permission", "access_level", "personal_authorization_required"]);
372
+ var CEAL_ARTIFACT_STAGE_TERMINALS = vocabulary(["chunk_accepted", "artifact_ready", "idempotency_replayed"]);
245
373
  var CEAL_RETRY_AFTER_MAX_MS = 60 * 60 * 1e3;
246
374
  var CEAL_JSON_SCHEMA_TYPES = vocabulary(["object", "array", "string", "integer", "number", "boolean", "null"]);
247
375
  var OBSERVATION_POSTURES = vocabulary(["direct_readback", "approved_no_readback", "operator_mediated", "excluded"]);
@@ -505,6 +633,8 @@ var CEAL_PROVIDER_BOUNDARY_KINDS = vocabulary([
505
633
  var CEAL_PROVIDER_BOUNDARY_EVIDENCE = vocabulary(["provider_readback", "operator_stated"]);
506
634
  var CEAL_ACCESS_LEVELS = vocabulary(["none", "read", "read_write"]);
507
635
  var CEAL_PERSONAL_ACCESS_CEILINGS = vocabulary(["disabled", "read", "read_write"]);
636
+ var CEAL_TARGET_REF_PATTERN = "^[^\\p{Cc}]+$";
637
+ var TARGET_REF = new RegExp(CEAL_TARGET_REF_PATTERN, "u");
508
638
  var CEAL_TARGET_VISIBILITIES = vocabulary(["public", "private"]);
509
639
  var CEAL_PRINCIPAL_KINDS = vocabulary(["human", "service", "runtime"]);
510
640
  var CEAL_ORGANIZATION_ROLES = vocabulary(["member", "admin"]);
@@ -613,8 +743,6 @@ var CEAL_OPERATION_AUTHORITY_POLICY_KEYS = Object.freeze(["access_group", "insta
613
743
  var MAX_OPERATION_INPUT_RESOLVER_BINDINGS = 96;
614
744
  var CEAL_OPERATION_DESCRIPTOR_REQUIRED_ENVELOPE_KEYS = Object.freeze(["schema_version", "id", "input_contract", "result_contract", "policy"]);
615
745
  var CEAL_OPERATION_DESCRIPTOR_OPTIONAL_ENVELOPE_KEYS = Object.freeze(["input_resolution", "summary"]);
616
- var CEAL_OPERATION_RESULT_KEYS = vocabulary(["ok", "operation_id", "operation_receipt", "schema_version", "value"]);
617
- var CEAL_OPERATION_COMPACT_RESULT_KEYS = vocabulary(["ok", "operation_evidence", "operation_id", "schema_version", "value"]);
618
746
 
619
747
  // packages/ceal-client-protocol/src/operation-catalog.ts
620
748
  var CEAL_OPERATION_CATALOG_SCHEMA_VERSION = "ceal.catalog.v3";
@@ -626,8 +754,8 @@ var CEAL_SCHEMA_LITERALS = [
626
754
  "ceal.activation_transport.v1",
627
755
  CEAL_OPERATION_ACCESS_SCHEMA_VERSION,
628
756
  CEAL_OPERATION_CATALOG_SCHEMA_VERSION,
629
- "ceal.client_refresh_request.v2",
630
- "ceal.client_refresh_result.v2",
757
+ "ceal.client_refresh_request.v1",
758
+ "ceal.client_refresh_result.v1",
631
759
  "ceal.client_revoke_request.v1",
632
760
  "ceal.client_revoke_result.v1",
633
761
  CEAL_COMMAND_REQUEST_SCHEMA_VERSION,
@@ -656,7 +784,7 @@ var CEAL_SCHEMA_LITERALS = [
656
784
  "ceal.gateway_call_result.v1",
657
785
  CEAL_GATEWAY_COMMAND_RESOLUTION_SCHEMA_VERSION,
658
786
  "ceal.gateway_connector_route_failure.v1",
659
- "ceal.gateway_discovery.v3",
787
+ "ceal.gateway_discovery.v1",
660
788
  "ceal.gateway_handshake.v1",
661
789
  "ceal.gateway_installation_activation_code_issue_request.v1",
662
790
  "ceal.gateway_installation_activation_code_issue_result.v1",
@@ -678,10 +806,6 @@ var CEAL_SCHEMA_LITERALS = [
678
806
  "ceal.host_observation.v1",
679
807
  "ceal.host_registration_request.v1",
680
808
  "ceal.host_registration_result.v1",
681
- "ceal.leased-resource-stream.v2",
682
- "ceal.leased_consumer_attachment_stream_frame.v2",
683
- "ceal.leased_consumer_attachment_stream_request.v2",
684
- "ceal.leased_consumer_attachment_stream_transport.v2",
685
809
  "ceal.operation_descriptor.v1",
686
810
  "ceal.operation_error.v1",
687
811
  "ceal.operation_failure.v1",
@@ -689,7 +813,7 @@ var CEAL_SCHEMA_LITERALS = [
689
813
  "ceal.operation_receipt.v1",
690
814
  "ceal.operation_result.v1",
691
815
  "ceal.operation_result.compact.v1",
692
- "ceal.local_result_materialization.v2",
816
+ "ceal.local_result_materialization.v1",
693
817
  "ceal.local_result_root.v1",
694
818
  "ceal.owner_bootstrap_exchange_request.v1",
695
819
  "ceal.owner_bootstrap_exchange_result.v1",
@@ -707,12 +831,6 @@ var CEAL_SCHEMA_LITERAL_SET = new Set(CEAL_SCHEMA_LITERALS);
707
831
  // packages/ceal-client-protocol/src/bounded-series.ts
708
832
  import { join } from "node:path";
709
833
  var CEAL_BOUNDED_SERIES_CATALOG = Object.freeze({
710
- usage_record: (root) => join(root, "run-usage.jsonl"),
711
- control_commit: (root) => join(root, "control-auto-commit.jsonl"),
712
- engagement_signal: (root) => join(root, "runtime-state", "slack-feedback.jsonl"),
713
- runtime_error: (root) => join(root, "runtime-state", "runtime-errors.jsonl"),
714
- turn_bridge_request: (root) => join(root, ".ceal", "turn-bridge", "requests.jsonl"),
715
- thread_run_events: (root) => join(root, "run-events.jsonl"),
716
834
  bounded_store_sidecar: (root) => `${root}.jsonl`,
717
835
  gateway_audit_archive: (root) => `${root}.jsonl`,
718
836
  gateway_access_group_connector_control_audit: (root) => `${root}.audit.jsonl`,
@@ -745,146 +863,8 @@ var CEAL_HOST_REGISTRATION_ATTEMPT_REF_PATTERN = new RegExp(`^host-registration-
745
863
  var CEAL_HOST_INSTALLATION_REF_PATTERN = new RegExp(`^host-installation:${CEAL_LOWERCASE_UUID_PATTERN}$`, "u");
746
864
  var CEAL_HOST_SOURCE_REF_PATTERN = new RegExp(`^host-source:${CEAL_LOWERCASE_UUID_PATTERN}$`, "u");
747
865
 
748
- // packages/ceal-client-protocol/src/agent-session-handoff.ts
749
- var CEAL_AGENT_ADMISSION_PHASES = vocabulary([
750
- "incumbent_admitted",
751
- "incumbent_draining",
752
- "drained",
753
- "candidate_admitted",
754
- "candidate_draining",
755
- "rollback_admitted"
756
- ]);
757
- var CEAL_AGENT_SERVICE_SESSION_RECORD_KEYS = vocabulary([
758
- "admission_fence",
759
- "admission_state",
760
- "admission_state_generation",
761
- "bearer",
762
- "consumer_ref",
763
- "credential_generation",
764
- "expires_at",
765
- "gateway_instance",
766
- "gateway_origin",
767
- "gateway_serving_generation",
768
- "issued_at",
769
- "record_sha256",
770
- "renew_after",
771
- "renew_by",
772
- "schema_version",
773
- "session_revision"
774
- ]);
775
- var CEAL_AGENT_SESSION_COMMIT_KEYS = vocabulary(["attempt_ref", "expected_session_revision", "session_revision"]);
776
-
777
- // packages/ceal-client-protocol/src/operation-next-actions.ts
778
- var CEAL_REPEAT_REQUEST_NEXT_ACTION = "repeat_request";
779
- var CEAL_INSPECT_RECEIPT_NEXT_ACTION = "inspect_receipt";
780
- var CALLER_RECOVERABLE_NEXT_ACTION_VALUES = [
781
- "select_did_you_mean",
782
- "choose_new_output_path",
783
- "choose_new_idempotency_key",
784
- "restart_search",
785
- "repeat_original_arguments",
786
- // The occurrence this call addressed is settled and cannot move again -- a
787
- // denied effect approval, an expired continuation -- so the caller runs the
788
- // same call again as a new request. The refusal names the re-request; this
789
- // word is the re-request.
790
- CEAL_REPEAT_REQUEST_NEXT_ACTION,
791
- "choose_new_request_identity",
792
- // A refusal that names the argument (invalid_argument with `property`) tells the caller exactly what to change.
793
- "correct_argument",
794
- // A resolver-owned input must move from caller operands into the declared
795
- // resolver selection field.
796
- "supply_resolver_selections",
797
- // The graph names an upstream node whose Operation produces the resolver's
798
- // occurrence, and it has not produced one yet. The caller runs that node
799
- // first; the refusal used to share a code with a malformed resolver result,
800
- // which is not fixable, so neither could carry a remedy.
801
- "run_resolver_dependency",
802
- // A replay carries the input the occurrence durably admitted, and this one
803
- // carries a different one. The caller fixes it by presenting the original
804
- // invocation, so it is a remedy; the coordinator minted the word at the
805
- // replay guard and never declared it, which read as unguided to the scorer.
806
- "use_original_input",
807
- // The same mismatch on the Request binding rather than the input: the
808
- // occurrence was admitted under one binding and the replay presents another.
809
- "use_original_request_binding",
810
- // The client's own filesystem write was refused -- EACCES, EPERM, or a
811
- // read-only mount -- which is how an agent sandbox fences writes outside its
812
- // workspace. The caller reruns the same command with unsandboxed or escalated
813
- // execution; re-adopting the session cannot help, because the sandbox refuses
814
- // that write too.
815
- "rerun_outside_agent_sandbox",
816
- // The refusal names the one Operation to read next in `describe_command`:
817
- // an absent Operation id with a sole catalog-ranked candidate, or a known
818
- // Operation invoked without its input. Describing only reads the verified
819
- // contract and dispatches nothing, and the caller then retries with the
820
- // named Operation or input, so it is guidance the scorer counts.
821
- "describe_operation",
822
- // The refusal names the caller's own personal connect Operation in
823
- // `required_action_sequence`: the Operation asked for, or the credential
824
- // the call ran on, needs a personal connection the caller does not hold
825
- // (never connected, revoked, or expired). The caller runs that exact
826
- // Operation, completes the consent it hands back, and retries the same call.
827
- "connect_personal_account",
828
- // The provider or Gateway named a bounded wait; the caller waits that long
829
- // and submits the same read again.
830
- "retry_after"
831
- ];
832
- var CEAL_CALLER_RECOVERABLE_NEXT_ACTIONS = Object.freeze(CALLER_RECOVERABLE_NEXT_ACTION_VALUES);
833
- var NON_REMEDY_NEXT_ACTION_VALUES = [
834
- // Only an administrator can take the named step -- approving a place for an
835
- // Operation, granting a withheld capability -- so a non-administrator asks
836
- // one. The refusal names the administrator step; this word is the ask.
837
- "ask_admin",
838
- "await_pending_approval",
839
- "check_gateway",
840
- "inspect_context_store",
841
- "inspect_gateway",
842
- "inspect_local_cache",
843
- // The thin client prints these on its own behalf, before or after the wire.
844
- // They were declared only as `CealClientLocalRemedy` keys and, for two of
845
- // them, only as Go string literals -- a second and third vocabulary for one
846
- // thing. `CealClientLocalRemedy` derives from this list now, so the client's
847
- // remedies cannot drift from the words the protocol knows.
848
- "inspect_local_client",
849
- "inspect_local_command",
850
- "inspect_local_output",
851
- "inspect_local_route",
852
- CEAL_INSPECT_RECEIPT_NEXT_ACTION,
853
- "inspect_request",
854
- "none",
855
- // The provider refused because of its own configuration -- an API not
856
- // enabled, an app scope missing -- which an operator changes in that
857
- // provider's console. No caller edit and no retry fixes it.
858
- "operator_action",
859
- "recover",
860
- "reconcile",
861
- // Reconciliation of one named occurrence, not of the deployment: an
862
- // occurrence with no admitted input commitment cannot be replayed safely and
863
- // no edit to the call changes that. `reconcile` is the deployment-wide word.
864
- "reconcile_occurrence",
865
- "reduce_request_size",
866
- // The Host's invocation context for this turn is stale or expired at the
867
- // Gateway. The Host's next turn rebinds it and the same call then succeeds;
868
- // nothing in the call changes, so it is not a remedy the scorer may count.
869
- "refresh_host_invocation_context",
870
- "repair_or_adopt_session",
871
- "retry",
872
- // The owner -- a correlation hook, an approval hook -- is not serving right
873
- // now. The caller changes nothing and the same call succeeds once the owner
874
- // is back, so this is not a remedy the scorer may count as guidance.
875
- "retry_after_owner_recovery",
876
- "retry_same_receipt_read",
877
- "run_file_search_again",
878
- "select_exact_approval"
879
- ];
880
- var CEAL_NON_REMEDY_NEXT_ACTIONS = Object.freeze(NON_REMEDY_NEXT_ACTION_VALUES);
881
- var DECLARED = /* @__PURE__ */ new Set([...CEAL_CALLER_RECOVERABLE_NEXT_ACTIONS, ...CEAL_NON_REMEDY_NEXT_ACTIONS]);
882
- var RECOVERABLE = new Set(CEAL_CALLER_RECOVERABLE_NEXT_ACTIONS);
883
- var CEAL_OPERATION_WITHHELD_NEXT_ACTIONS = Object.freeze({
884
- provider_permission: "ask_admin",
885
- access_level: "ask_admin",
886
- personal_authorization_required: "connect_personal_account"
887
- });
866
+ // packages/ceal-client-protocol/src/operation-result-completeness.ts
867
+ var CEAL_READ_VALUE_CONTINUATION_KEYS = vocabulary(["continuation", "continuation_ref", "next_cursor"]);
888
868
 
889
869
  // packages/ceal-client-protocol/src/operation-contract-artifact.ts
890
870
  var CATALOG_REVISION = new RegExp(CEAL_VERIFIED_ARTIFACT_CATALOG_REVISION_PATTERN, "u");
@@ -893,7 +873,9 @@ var CEAL_OPERATION_INVOKE_COMMAND = "invoke";
893
873
  var CEAL_OPERATION_INPUT_FLAG = "--input";
894
874
  var CEAL_OPERATION_ID_PLACEHOLDER = "<operation-id>";
895
875
  var CEAL_OPERATION_INPUT_PLACEHOLDER = "<json-object>";
896
- var CEAL_MODEL_INVOCATION_ARGUMENTS = [CEAL_OPERATION_INVOKE_COMMAND, CEAL_OPERATION_ID_PLACEHOLDER, CEAL_OPERATION_INPUT_FLAG, shellSingleQuoted(CEAL_OPERATION_INPUT_PLACEHOLDER)].join(" ");
876
+ var MODEL_INVOCATION_BASE_ARGUMENTS = [CEAL_OPERATION_INVOKE_COMMAND, CEAL_OPERATION_ID_PLACEHOLDER].join(" ");
877
+ var CEAL_MODEL_INVOCATION_ARGUMENTS = [MODEL_INVOCATION_BASE_ARGUMENTS, CEAL_OPERATION_INPUT_FLAG, shellSingleQuoted(CEAL_OPERATION_INPUT_PLACEHOLDER)].join(" ");
878
+ var CEAL_MODEL_INPUT_SOURCE_GUIDANCE = `For caller-owned fields, add ${CEAL_OPERATION_INPUT_FLAG} ${shellSingleQuoted(CEAL_OPERATION_INPUT_PLACEHOLDER)}. Use inline JSON for short input; for longer or generated input, put exactly one JSON object in a caller-owned regular non-symlink UTF-8 JSON file and pass --input @path; relative paths resolve from the command working directory.`;
897
879
  function shellSingleQuoted(value) {
898
880
  return `'${value.replaceAll("'", "'\\''")}'`;
899
881
  }
@@ -925,76 +907,7 @@ var CEAL_VERIFIED_ARTIFACT_DESCRIPTOR_JSON_SCHEMA = Object.freeze({
925
907
  }
926
908
  });
927
909
 
928
- // packages/ceal-client-protocol/src/bare-document.ts
929
- var REQUIRED_FIELDS = CEAL_CLIENT_WIRE_CONTRACT.command_response.bare_document_fields;
930
- var OPTIONAL_FIELDS = CEAL_CLIENT_WIRE_CONTRACT.command_response.bare_document_optional_fields;
931
-
932
- // packages/ceal-client-protocol/src/leased-consumer-vocabulary.ts
933
- var CEAL_TERMINAL_DISPOSITIONS = vocabulary(["completed", "failed", "cancelled"]);
934
- var CEAL_LEASE_DISPOSITIONS = vocabulary([...CEAL_TERMINAL_DISPOSITIONS, "deferred"]);
935
- var CEAL_AUTOMATIC_FEEDBACK_INTENTS = vocabulary(["initial"]);
936
- var CEAL_LEASED_MESSAGE_DELIVERY_OPERATION_IDS = vocabulary(["message.send", "message.update", "message.delete"]);
937
- var CEAL_REPOSITORY_VISIBILITIES = vocabulary(["public", "private", "internal"]);
938
- var CEAL_RESULT_DELIVERY_OFFERS = vocabulary(["pending", "offered", "transport_lost"]);
939
- var CEAL_RESULT_DELIVERY_STATES = vocabulary(["unavailable", ...CEAL_RESULT_DELIVERY_OFFERS]);
940
- var CEAL_PROVIDER_OUTCOMES = vocabulary(["not_attempted", "outcome_unknown", "verified"]);
941
- var CEAL_ACTIVITY_GAP_CODES = vocabulary([
942
- "provider_page_budget",
943
- "call_deadline",
944
- "related_item_budget",
945
- "provider_cursor_unavailable",
946
- "malformed_provider_page",
947
- "visibility_incomplete",
948
- "unsupported_event_kind"
949
- ]);
950
- var CEAL_ACTIVITY_CONNECTOR_KINDS = vocabulary(["slack", "github", "google-calendar", "google-drive", "notion"]);
951
- var CEAL_ACTIVITY_COVERAGE_STATUSES = vocabulary(["complete_for_target", "continuation_required", "blocked"]);
952
- var CEAL_ACTIVITY_EVENT_KINDS = vocabulary([
953
- "slack.message",
954
- "slack.reply",
955
- "slack.direct_message",
956
- "github.commit.authored",
957
- "github.issue.opened",
958
- "github.pull_request.opened",
959
- "github.review.submitted",
960
- "github.issue_comment.created",
961
- "github.review_comment.created",
962
- "calendar.organized",
963
- "calendar.accepted_invite",
964
- "calendar.recorded",
965
- "drive.file.created",
966
- "drive.file.modified",
967
- "drive.file.viewed",
968
- "notion.page.created",
969
- "notion.page.edited"
970
- ]);
971
- var CEAL_ACTIVITY_TIMESTAMP_BASES = vocabulary([
972
- "message_created",
973
- "commit_authored",
974
- "resource_created",
975
- "review_submitted",
976
- "comment_created",
977
- "event_start",
978
- "all_day_start",
979
- "file_created",
980
- "file_modified",
981
- "file_modified_by_me",
982
- "file_viewed_by_me",
983
- "page_created",
984
- "page_last_edited",
985
- "resource_modified"
986
- ]);
987
- var CEAL_ACTIVITY_V3_KINDS = vocabulary(["authored", "edited", "messaged", "responded"]);
988
- var CEAL_RESOURCE_TIME_BASES = vocabulary(["created", "modified", "viewed"]);
989
- var CEAL_RESOURCE_SEARCH_ORDERS = vocabulary(["relevance", "modified", "viewed", "created"]);
990
- var CEAL_RESOURCE_SEARCH_DIRECTIONS = vocabulary(["ascending", "descending"]);
991
- var CEAL_RESOURCE_SEARCH_FILTERS = vocabulary(["query", "modified_since", "since", "until", "authored_by_me", "include_replies", "kinds", "container_ref", "container_refs", "container_names", "addressed_to_me", "unread"]);
992
- var CEAL_ARTIFACT_STAGE_TERMINALS = vocabulary(["chunk_accepted", "artifact_ready", "idempotency_replayed"]);
993
- var CEAL_READ_ITEM_KINDS = vocabulary(["conversation", "identity", "usergroup", "message", "file", "document"]);
994
- var CEAL_LEASED_MESSAGE_SEARCH_COMPLETENESS = vocabulary(["complete", "continuation_available", "truncated"]);
995
- var CEAL_OPAQUE_HANDLE_KINDS = vocabulary(["target", "message", "thread", "artifact", "document", "object"]);
996
- var CEAL_WRITE_OBJECT_KINDS = vocabulary(["document", "comment", "cell_range"]);
997
- var CEAL_CONVERSATION_KINDS = vocabulary(["channel", "dm", "group"]);
910
+ // packages/ceal-client-protocol/src/provider-operation-vocabulary.ts
998
911
  var CEAL_FILE_TYPE_FAMILIES = vocabulary(["all", "image", "pdf"]);
999
912
  var CEAL_GITHUB_ISSUE_STATES = vocabulary(["open", "closed", "all"]);
1000
913
  var CEAL_NOTION_UPDATABLE_BLOCK_TYPES = vocabulary([
@@ -1028,12 +941,92 @@ var CEAL_NOTION_IDENTITY_GAP_REASONS = vocabulary([
1028
941
  "identity_unlinked"
1029
942
  ]);
1030
943
  var CEAL_NOTION_STRING_VALUE_TYPES = vocabulary(["text", "select", "url", "email", "phone"]);
1031
- var CEAL_UNREAD_REASONS = vocabulary(["blocked", "unavailable", "too_large", "unsupported", "download_failed", "permission_denied"]);
1032
- var CEAL_PLAN_ITEM_STATUSES = vocabulary(["pending", "active", "completed"]);
1033
- var CEAL_FINAL_PRESENTATION_INTENTS = vocabulary(["final", "stop", "transient_notice"]);
1034
- var CEAL_PRESENTATION_INTENTS = vocabulary(["progress", ...CEAL_FINAL_PRESENTATION_INTENTS]);
944
+
945
+ // packages/ceal-client-protocol/src/opaque-reference.ts
946
+ var CEAL_OPAQUE_HANDLE_KINDS = vocabulary(["target", "message", "thread", "artifact", "document", "block", "object"]);
947
+ var CEAL_OPAQUE_REF_KINDS = vocabulary([...CEAL_OPAQUE_HANDLE_KINDS, "result", "operation-receipt", "reply-receipt", "field", "notion-data-source"]);
948
+
949
+ // packages/ceal-client-protocol/src/bare-document.ts
950
+ var REQUIRED_FIELDS = CEAL_CLIENT_WIRE_CONTRACT.command_response.bare_document_fields;
951
+ var OPTIONAL_FIELDS = CEAL_CLIENT_WIRE_CONTRACT.command_response.bare_document_optional_fields;
1035
952
 
1036
953
  // packages/ceal-client-protocol/src/resource-row.ts
954
+ var CEAL_RESOURCE_SEARCH_ORDERS = vocabulary(["relevance", "modified", "viewed", "created"]);
955
+ var CEAL_RESOURCE_SEARCH_DIRECTIONS = vocabulary(["ascending", "descending"]);
956
+ var CEAL_RESOURCE_SEARCH_FILTERS = vocabulary(["query", "modified_since", "since", "until", "authored_by_me", "include_replies", "kinds", "container_ref", "container_refs", "container_names", "addressed_to_me", "unread"]);
957
+ var CEAL_RESOURCE_TIME_BASES = vocabulary(["created", "modified", "viewed"]);
958
+ var CEAL_REPOSITORY_VISIBILITIES = vocabulary(["public", "private", "internal"]);
959
+ var CEAL_ACTIVITY_V3_KINDS = vocabulary(["authored", "edited", "messaged", "responded"]);
960
+ var CEAL_ACTIVITY_TIMESTAMP_BASES = vocabulary([
961
+ "message_created",
962
+ "commit_authored",
963
+ "resource_created",
964
+ "review_submitted",
965
+ "comment_created",
966
+ "event_start",
967
+ "all_day_start",
968
+ "file_created",
969
+ "file_modified",
970
+ "file_modified_by_me",
971
+ "file_viewed_by_me",
972
+ "page_created",
973
+ "page_last_edited",
974
+ "resource_modified"
975
+ ]);
976
+ var CEAL_ACTIVITY_CONNECTOR_KINDS = vocabulary(["slack", "github", "google-calendar", "google-drive", "notion"]);
977
+ var CEAL_ACTIVITY_GAP_CODES = vocabulary([
978
+ "provider_page_budget",
979
+ "call_deadline",
980
+ "related_item_budget",
981
+ "provider_cursor_unavailable",
982
+ "malformed_provider_page",
983
+ "visibility_incomplete",
984
+ "unsupported_event_kind",
985
+ "direct_messages_excluded"
986
+ ]);
987
+ var CEAL_ACTIVITY_EVENT_KINDS = vocabulary([
988
+ "slack.message",
989
+ "slack.reply",
990
+ "slack.direct_message",
991
+ "github.commit.authored",
992
+ "github.issue.opened",
993
+ "github.pull_request.opened",
994
+ "github.issue.edited",
995
+ "github.pull_request.edited",
996
+ "github.review.submitted",
997
+ "github.issue_comment.created",
998
+ "github.review_comment.created",
999
+ "calendar.organized",
1000
+ "calendar.accepted_invite",
1001
+ "calendar.recorded",
1002
+ "drive.file.created",
1003
+ "drive.file.modified",
1004
+ "drive.file.viewed",
1005
+ "notion.page.created",
1006
+ "notion.page.edited"
1007
+ ]);
1008
+ var CEAL_ACTIVITY_EVENT_TIMESTAMP_BASIS_MAP = Object.freeze({
1009
+ "slack.message": "message_created",
1010
+ "slack.reply": "message_created",
1011
+ "slack.direct_message": "message_created",
1012
+ "github.commit.authored": "commit_authored",
1013
+ "github.review.submitted": "review_submitted",
1014
+ "github.issue_comment.created": "comment_created",
1015
+ "github.review_comment.created": "comment_created",
1016
+ "github.issue.opened": "resource_created",
1017
+ "github.pull_request.opened": "resource_created",
1018
+ "github.issue.edited": "resource_modified",
1019
+ "github.pull_request.edited": "resource_modified",
1020
+ "calendar.organized": "resource_created",
1021
+ "drive.file.created": "file_created",
1022
+ "drive.file.modified": "file_modified_by_me",
1023
+ "drive.file.viewed": "file_viewed_by_me",
1024
+ "notion.page.created": "page_created",
1025
+ "notion.page.edited": "page_last_edited"
1026
+ });
1027
+ var CEAL_DATED_NOTE_BASES = vocabulary(["recording", "calendar_event", "created_time"]);
1028
+ var CEAL_DATED_NOTE_TRANSCRIPT_STATES = vocabulary(["present", "absent", "unestablished"]);
1029
+ var CEAL_READ_SEARCH_COST_CLASSES = vocabulary(["native_index", "scan"]);
1037
1030
  var RESOURCE_ROW_KEY_RULES = Object.freeze({
1038
1031
  schema_version: { required: true, timestamp: false },
1039
1032
  ref: { required: true, timestamp: false },
@@ -1046,6 +1039,7 @@ var RESOURCE_ROW_KEY_RULES = Object.freeze({
1046
1039
  source: { required: true, timestamp: false },
1047
1040
  owner: { required: false, timestamp: false },
1048
1041
  counterparts: { required: false, timestamp: false },
1042
+ attachments: { required: false, timestamp: false },
1049
1043
  created_at: { required: false, timestamp: true },
1050
1044
  created_at_local: { required: false, timestamp: true },
1051
1045
  modified_at: { required: false, timestamp: true },
@@ -1056,6 +1050,7 @@ var RESOURCE_ROW_KEY_RULES = Object.freeze({
1056
1050
  end: { required: false, timestamp: false },
1057
1051
  status: { required: false, timestamp: false },
1058
1052
  snippet: { required: false, timestamp: false },
1053
+ dated_notes: { required: false, timestamp: false },
1059
1054
  state: { required: true, timestamp: false },
1060
1055
  timestamp_basis: { required: true, timestamp: false }
1061
1056
  });
@@ -1092,16 +1087,26 @@ var CEAL_WRITE_SAFETY_UNCHECKED_REASONS = vocabulary(["authority_unavailable"]);
1092
1087
  // packages/ceal-client-protocol/src/operation-occurrence.ts
1093
1088
  var MAX_RECEIPT_REVISION = Number.MAX_SAFE_INTEGER - 1;
1094
1089
 
1095
- // packages/ceal-client-protocol/src/leased-artifact-contract.ts
1096
- var CEAL_LEASED_CONSUMER_ARTIFACT_CHUNK_MAX_BYTES = 12 * 1024;
1097
-
1098
- // packages/ceal-client-protocol/src/leased-resource-stream.ts
1099
- var CEAL_LEASED_CONSUMER_ATTACHMENT_STREAM_MAGIC = new Uint8Array([67, 69, 65, 76, 82, 83, 50, 0]);
1100
- var CEAL_LEASED_CONSUMER_ATTACHMENT_STREAM_RECORD_PREFIX_BYTES = 8;
1101
- var CEAL_LEASED_CONSUMER_ATTACHMENT_STREAM_MAX_HEADER_BYTES = 16 * 1024;
1102
- var CEAL_LEASED_CONSUMER_ATTACHMENT_STREAM_CHUNK_BYTES = 64 * 1024;
1103
- var CEAL_LEASED_CONSUMER_ATTACHMENT_STREAM_MAX_RECORD_BYTES = CEAL_LEASED_CONSUMER_ATTACHMENT_STREAM_RECORD_PREFIX_BYTES + CEAL_LEASED_CONSUMER_ATTACHMENT_STREAM_MAX_HEADER_BYTES + CEAL_LEASED_CONSUMER_ATTACHMENT_STREAM_CHUNK_BYTES;
1104
- var CEAL_ATTACHMENT_UNREAD_REASONS = vocabulary(["blocked", "unavailable", "too_large", "unsupported", "download_failed", "digest_mismatch"]);
1090
+ // packages/ceal-client-protocol/src/personal-client-vocabulary.ts
1091
+ var CEAL_PERSONAL_CLIENT_BINDING_KEYS = vocabulary([
1092
+ "access_group_ref",
1093
+ "membership_ref",
1094
+ "registration_ref",
1095
+ "client_ref",
1096
+ "subject_ref",
1097
+ "instance_ref"
1098
+ ]);
1099
+ var CEAL_ENROLLMENT_FAILURE_CODES = vocabulary(["enrollment_invalid", "enrollment_expired", "enrollment_used"]);
1100
+ var CEAL_REFRESH_FAILURE_CODES = vocabulary([
1101
+ "refresh_invalid",
1102
+ "refresh_expired",
1103
+ "refresh_inactive",
1104
+ "refresh_replayed",
1105
+ "refresh_revoked",
1106
+ "authority_replaced",
1107
+ "refresh_recovery_unavailable",
1108
+ "refresh_recovery_expired"
1109
+ ]);
1105
1110
 
1106
1111
  // packages/ceal-client-protocol/src/request-validation-primitives.ts
1107
1112
  import { createHash } from "node:crypto";
@@ -1187,7 +1192,7 @@ var CEAL_REQUEST_MAX_GRAPH_NODES = 128;
1187
1192
 
1188
1193
  // packages/ceal-client-protocol/src/request-run.ts
1189
1194
  var CEAL_REQUEST_NODE_STANDING_OCCURRENCE_SCHEMA_VERSION = "ceal.request_node_standing_occurrence.v1";
1190
- var CEAL_REQUEST_RUN_BATCH_SCHEMA_VERSION = "ceal.request_run_batch.v3";
1195
+ var CEAL_REQUEST_RUN_BATCH_SCHEMA_VERSION = "ceal.request_run_batch.v1";
1191
1196
  var REQUEST_ACTION_SAFE_REF_SCHEMA = { type: "string", minLength: 1, maxLength: 128, pattern: SAFE_REF.source };
1192
1197
  var REQUEST_ACTION_DIGEST_SCHEMA = { type: "string", minLength: 64, maxLength: 64, pattern: "^[a-f0-9]{64}$" };
1193
1198
  var REQUEST_NODE_STANDING_OCCURRENCE_SCHEMA = {
@@ -1269,6 +1274,10 @@ var CEAL_REQUEST_RUN_BATCH_JSON_SCHEMA = {
1269
1274
  };
1270
1275
 
1271
1276
  // packages/ceal-client-protocol/src/host-observation.ts
1277
+ var CEAL_HOST_INPUT_KINDS = vocabulary(["human", "host_automatic"]);
1278
+ function isCealHostInputKind(value) {
1279
+ return typeof value === "string" && CEAL_HOST_INPUT_KINDS.some((kind) => kind === value);
1280
+ }
1272
1281
  var CEAL_HOST_OBSERVATION_REF_PREFIX = "host-observation:";
1273
1282
  var HOST_OBSERVATION_PRODUCER = /^[a-z][a-z0-9]{0,31}$/u;
1274
1283
  var HOST_OBSERVATION_DIGEST = /^[a-f0-9]{8,64}$/u;
@@ -1331,12 +1340,6 @@ var OWNER_WRITE_STATES = Object.freeze(["attempt_started", "provider_acknowledge
1331
1340
  var OWNER_EFFECT_STATES = Object.freeze(["none", "applied", "failed", "unknown", "reconciled"]);
1332
1341
  var OWNER_RECEIPT_STATES = Object.freeze(["pending", "available", "failed", "unknown", "reconciled"]);
1333
1342
 
1334
- // packages/ceal-client-protocol/src/thread-excerpt.ts
1335
- var CEAL_THREAD_RECENT_WINDOW = 6;
1336
- var CEAL_THREAD_LAST_APP_MESSAGES_WINDOW = 3;
1337
- var CEAL_THREAD_OLDER_SUMMARY_WINDOW = 4;
1338
- var CEAL_FED_THREAD_MESSAGE_LIMIT = CEAL_THREAD_RECENT_WINDOW + CEAL_THREAD_OLDER_SUMMARY_WINDOW + CEAL_THREAD_LAST_APP_MESSAGES_WINDOW;
1339
-
1340
1343
  // packages/ceal-client-protocol/src/request-graph-readiness.ts
1341
1344
  var REQUEST_GRAPH_PRODUCER_TO_APPEND_SCHEMA = {
1342
1345
  type: "object",
@@ -1425,25 +1428,10 @@ var CEAL_HOST_INVOCATION_AUTHENTICATION_RESULT_MAX_BYTES = new TextEncoder().enc
1425
1428
  `).byteLength;
1426
1429
 
1427
1430
  // packages/ceal-client-protocol/src/client-result-materialization.ts
1431
+ var CEAL_UNREAD_REASONS = vocabulary(["blocked", "unavailable", "too_large", "unsupported", "download_failed", "permission_denied"]);
1428
1432
  var CEAL_MODEL_VISIBLE_COMMAND_OUTPUT_MAX_BYTES = 32 * 1024;
1429
- var REQUIRED_FIELDS2 = Object.freeze(["schema_version", "operation_id", "read_argv"]);
1430
- var FIELDS = /* @__PURE__ */ new Set([...REQUIRED_FIELDS2, "local_result_root", "continue_argv"]);
1431
-
1432
- // packages/ceal-client-protocol/src/session-start-affordance.ts
1433
- var CEAL_SESSION_ENTRY_INVOCATION = "ceal";
1434
- 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.`;
1435
-
1436
- // packages/ceal-client-protocol/src/conversation-contracts.ts
1437
- var CEAL_APPROVAL_POLICY_KINDS = vocabulary(["requester_only", "named_users", "role_based"]);
1438
- var CEAL_APPROVAL_TARGET_KINDS = vocabulary([
1439
- "repo_change",
1440
- "investigation",
1441
- "skill_creation",
1442
- "command_creation",
1443
- "connector_creation",
1444
- "generic"
1445
- ]);
1446
- var CEAL_PROGRESS_PHASES = vocabulary(["request_review", "information_gathering", "work_execution", "result_check"]);
1433
+ var REQUIRED_FIELDS2 = Object.freeze(["schema_version", "operation_id"]);
1434
+ var FIELDS = /* @__PURE__ */ new Set([...REQUIRED_FIELDS2, "read_argv", "local_result_root", "continue_argv", "model_disclosure", "item_read_argv"]);
1447
1435
 
1448
1436
  // packages/ceal-client-protocol/src/gateway-cache-origin-validation.ts
1449
1437
  var CEAL_MAX_CACHE_ORIGIN_AGE_MS = 30 * 24 * 60 * 60 * 1e3;
@@ -1527,27 +1515,6 @@ var ADMIN_LINEAGE_NODE_KINDS = vocabulary(["source_read", "synthesis_preview", "
1527
1515
  // packages/ceal-client-protocol/src/actor-kind.ts
1528
1516
  var CEAL_ACTOR_KINDS = vocabulary(["human", "bot", "app", "unknown"]);
1529
1517
 
1530
- // packages/ceal-client-protocol/src/personal-client-vocabulary.ts
1531
- var CEAL_PERSONAL_CLIENT_BINDING_KEYS = vocabulary([
1532
- "access_group_ref",
1533
- "membership_ref",
1534
- "registration_ref",
1535
- "client_ref",
1536
- "subject_ref",
1537
- "instance_ref"
1538
- ]);
1539
- var CEAL_ENROLLMENT_FAILURE_CODES = vocabulary(["enrollment_invalid", "enrollment_expired", "enrollment_used"]);
1540
- var CEAL_REFRESH_FAILURE_CODES = vocabulary([
1541
- "refresh_invalid",
1542
- "refresh_expired",
1543
- "refresh_inactive",
1544
- "refresh_replayed",
1545
- "refresh_revoked",
1546
- "authority_replaced",
1547
- "refresh_recovery_unavailable",
1548
- "refresh_recovery_expired"
1549
- ]);
1550
-
1551
1518
  // packages/ceal-client-protocol/src/device-enrollment.ts
1552
1519
  var CEAL_DEVICE_ENROLLMENT_POLL_FAILURE_CODES = Object.freeze(["unsupported_feature", "recovery_required", "expired", "denied"]);
1553
1520
  var POLL_RESULT_KEYS = Object.freeze(["retry_after_ms", "schema_version", "status"]);
@@ -1943,10 +1910,6 @@ var CodexOutboxStore = class {
1943
1910
  await removeOwnerState(this.registrationPath(registration.host_source_ref, registration.host_session_ref), "registration");
1944
1911
  await removeOwnerState(this.cursorPath(registration.host_source_ref, registration.host_session_ref), "cursor");
1945
1912
  }
1946
- async relayWakeDirectories() {
1947
- await this.prepare();
1948
- return { entries: this.entriesDirectory, registrations: this.registrationsDirectory };
1949
- }
1950
1913
  async listTranscriptRegistrations() {
1951
1914
  await this.prepare();
1952
1915
  const registrations = [];
@@ -2136,7 +2099,7 @@ async function readPrivateFile(path) {
2136
2099
  }
2137
2100
  function validateEnvelope(value) {
2138
2101
  if (!isRecord3(value)) throw storageError("Codex outbox entry is malformed.");
2139
- if (!sameKeys(value, ["schema_version", "identity", "host_input_ref", "prompt_ref", "observations", "origin_input", "submission_ref", "created_at", "expires_at"], ["request_ref", "codex_turn_id"])) throw storageError(`Codex outbox entry key set is malformed (${refusalFact("keys", Object.keys(value), "exactly the outbox entry key set")}).`);
2102
+ if (!sameKeys(value, ["schema_version", "identity", "host_input_ref", "input_kind", "prompt_ref", "observations", "origin_input", "submission_ref", "created_at", "expires_at"], ["request_ref", "codex_turn_id"])) throw storageError(`Codex outbox entry key set is malformed (${refusalFact("keys", Object.keys(value), "exactly the outbox entry key set")}).`);
2140
2103
  if (value.schema_version !== CODEX_OUTBOX_SCHEMA_VERSION) throw storageError(`Codex outbox entry is malformed (${refusalFact("schema_version", value.schema_version, `expected ${CODEX_OUTBOX_SCHEMA_VERSION}`)}).`);
2141
2104
  validateIdentity2(value.identity);
2142
2105
  validateEnvelopeReferences(value);
@@ -2145,6 +2108,7 @@ function validateEnvelope(value) {
2145
2108
  }
2146
2109
  function validateEnvelopeReferences(value) {
2147
2110
  if (!SAFE_REF3.test(String(value.host_input_ref))) throw storageError("Codex outbox input reference is malformed.");
2111
+ if (!isCealHostInputKind(value.input_kind)) throw storageError("Codex outbox input provenance is malformed.");
2148
2112
  if (!SAFE_REF3.test(String(value.prompt_ref))) throw storageError("Codex outbox references are malformed.");
2149
2113
  if (!SAFE_REF3.test(String(value.submission_ref))) throw storageError("Codex outbox references are malformed.");
2150
2114
  if (value.request_ref !== void 0 && !SAFE_REF3.test(String(value.request_ref))) throw storageError("Codex outbox Request reference is malformed.");
@@ -2378,18 +2342,24 @@ function decodeTokenUsage(value) {
2378
2342
  function decodeResponseItem(payload, ordinal, timestamp6) {
2379
2343
  if (payload.type !== "message" || payload.role !== "user") return { kind: "ignored", ordinal, timestamp: timestamp6 };
2380
2344
  const metadata = userMessageMetadata(payload.internal_chat_message_metadata_passthrough);
2381
- const kinds = metadata.content_item_kinds;
2382
- if (kinds.length !== 1 || kinds[0] !== "user.text") return { kind: "ignored", ordinal, timestamp: timestamp6 };
2345
+ const inputKind = inputKindFromContentItems(metadata.content_item_kinds);
2346
+ if (inputKind === void 0) return { kind: "ignored", ordinal, timestamp: timestamp6 };
2383
2347
  const prompt = userTextContent(payload.content);
2384
2348
  return {
2385
2349
  kind: "user_text",
2386
2350
  ordinal,
2387
2351
  timestamp: timestamp6,
2388
2352
  prompt,
2353
+ input_kind: inputKind,
2389
2354
  message_id: safeRef2(payload.id, "Codex user message identity is invalid."),
2390
2355
  turn_id: safeRef2(metadata.turn_id, "Codex user message task identity is invalid.")
2391
2356
  };
2392
2357
  }
2358
+ function inputKindFromContentItems(kinds) {
2359
+ if (kinds.length !== 1) return void 0;
2360
+ if (kinds[0] === "user.text") return "human";
2361
+ return kinds[0] === "goal.internal_context" ? "host_automatic" : void 0;
2362
+ }
2393
2363
  function userMessageMetadata(value) {
2394
2364
  if (!isRecord4(value) || !Array.isArray(value.content_item_kinds)) reject2("Codex user message provenance is malformed.");
2395
2365
  return { ...value, content_item_kinds: value.content_item_kinds };
@@ -2674,13 +2644,13 @@ function validTurn(value) {
2674
2644
  return exactOptional(value, ["local_session_ref", "local_turn_ref"], ["model", "observations"]) && safeRef3(value.local_session_ref) && safeRef3(value.local_turn_ref) && optionalText(value.model, 256) && validObservations(value.observations);
2675
2645
  }
2676
2646
  function validInput(value) {
2677
- return exactOptional(value, ["local_session_ref", "local_turn_ref", "local_input_ref", "origin_input", "observations"], ["decision", "local_turn_aliases", "context_expires_at"]) && safeRef3(value.local_session_ref) && safeRef3(value.local_turn_ref) && safeRef3(value.local_input_ref) && validInputObservations(value.observations) && typeof value.origin_input === "boolean" && validInputOptionals(value);
2647
+ return exactOptional(value, ["local_session_ref", "local_turn_ref", "local_input_ref", "input_kind", "origin_input", "observations"], ["local_turn_aliases", "context_expires_at"]) && safeRef3(value.local_session_ref) && safeRef3(value.local_turn_ref) && safeRef3(value.local_input_ref) && validInputObservations(value.observations) && isCealHostInputKind(value.input_kind) && typeof value.origin_input === "boolean" && validInputOptionals(value);
2678
2648
  }
2679
2649
  function validInputObservations(value) {
2680
2650
  return validObservations(value) && Array.isArray(value) && value.filter((item) => record(item) && item.observation_kind === "prompt").length === 1;
2681
2651
  }
2682
2652
  function validInputOptionals(value) {
2683
- return validDecision(value.decision) && optionalRefs(value.local_turn_aliases) && (value.context_expires_at === void 0 || timestamp3(value.context_expires_at));
2653
+ return optionalRefs(value.local_turn_aliases) && (value.context_expires_at === void 0 || timestamp3(value.context_expires_at));
2684
2654
  }
2685
2655
  function validTerminal(value) {
2686
2656
  return exactOptional(value, ["local_session_ref", "local_turn_ref", "terminal_state"], ["abort_reason", "duration_ms", "time_to_first_token_ms", "usage", "observations"]) && safeRef3(value.local_session_ref) && safeRef3(value.local_turn_ref) && validTerminalDisposition(value.terminal_state, value.abort_reason) && optionalNonNegative(value.duration_ms) && optionalNonNegative(value.time_to_first_token_ms) && (value.usage === void 0 || jsonValue(value.usage)) && validObservations(value.observations);
@@ -2691,9 +2661,6 @@ function validTerminalDisposition(state, reason) {
2691
2661
  function validStatus(value) {
2692
2662
  return exactOptional(value, ["status", "reason_code"], ["detail"]) && ["ready", "degraded", "stopping"].includes(String(value.status)) && safeRef3(value.reason_code) && optionalText(value.detail, 4096);
2693
2663
  }
2694
- function validDecision(value) {
2695
- return value === void 0 || record(value) && exactKeys3(value, ["decision", "approval_ref"]) && (value.decision === "approved" || value.decision === "denied") && safeRef3(value.approval_ref);
2696
- }
2697
2664
  function optionalText(value, maxLength) {
2698
2665
  return value === void 0 || typeof value === "string" && value.length > 0 && value.length <= maxLength;
2699
2666
  }
@@ -2870,9 +2837,11 @@ function incrementDelivery(counts, outcome) {
2870
2837
  async function deliverPreparedEntry(entry, prepared, options, store, now, timeoutMs, signal) {
2871
2838
  try {
2872
2839
  const acknowledgement = await submitWithDeadline(options.gateway, gatewaySubmission(prepared), timeoutMs, signal);
2873
- const binding = bindingFor(prepared, acknowledgement, now);
2874
- await store.writeBinding(binding);
2875
- await store.bindInvocationContext(binding, now());
2840
+ if (prepared.request_ref === void 0) {
2841
+ const binding = bindingFor(prepared, acknowledgement, now);
2842
+ await store.writeBinding(binding);
2843
+ await store.bindInvocationContext(binding, now());
2844
+ }
2876
2845
  await store.remove(entry);
2877
2846
  return "delivered";
2878
2847
  } catch (error) {
@@ -2890,6 +2859,7 @@ function gatewaySubmission(envelope) {
2890
2859
  return {
2891
2860
  identity: envelope.identity,
2892
2861
  host_input_ref: envelope.host_input_ref,
2862
+ input_kind: envelope.input_kind,
2893
2863
  prompt_ref: envelope.prompt_ref,
2894
2864
  observations: envelope.observations,
2895
2865
  ...envelope.request_ref === void 0 ? {} : { request_ref: envelope.request_ref },
@@ -3512,6 +3482,7 @@ var CodexProducer = class {
3512
3482
  local_session_ref: envelope.identity.host_session_ref,
3513
3483
  local_turn_ref: localTurnRef(envelope),
3514
3484
  local_input_ref: envelope.host_input_ref,
3485
+ input_kind: envelope.input_kind,
3515
3486
  origin_input: envelope.origin_input,
3516
3487
  observations: [prompt],
3517
3488
  local_turn_aliases: envelope.codex_turn_id === void 0 ? void 0 : [envelope.codex_turn_id],
@@ -4102,6 +4073,7 @@ var CodexTranscriptWatcher = class {
4102
4073
  schema_version: "ceal.codex_observation_outbox.v1",
4103
4074
  identity,
4104
4075
  host_input_ref: hostInputRef,
4076
+ input_kind: record3.input_kind,
4105
4077
  prompt_ref: promptRef,
4106
4078
  observations,
4107
4079
  codex_turn_id: record3.turn_id,
@@ -4128,6 +4100,7 @@ var CodexTranscriptWatcher = class {
4128
4100
  schema_version: "ceal.codex_observation_outbox.v1",
4129
4101
  identity,
4130
4102
  host_input_ref: activeTask.origin_host_input_ref,
4103
+ input_kind: "host_automatic",
4131
4104
  prompt_ref: activeTask.prompt_ref,
4132
4105
  observations,
4133
4106
  codex_turn_id: record3.turn_id,
@@ -4318,84 +4291,6 @@ var CODEX_PRODUCER_DESCRIPTOR = {
4318
4291
  drain: drainCodexProducerOnce
4319
4292
  };
4320
4293
 
4321
- // host/codex/src/codex-relay.ts
4322
- import { O_NOFOLLOW as O_NOFOLLOW4, O_RDONLY as O_RDONLY5 } from "node:constants";
4323
- import { lstat as lstat4, mkdir as mkdir4, open as open6, readFile as readFile2, rename as rename4, unlink as unlink3 } from "node:fs/promises";
4324
- import { homedir as homedir2 } from "node:os";
4325
- import { dirname as dirname2, isAbsolute as isAbsolute4, join as join5 } from "node:path";
4326
- var CODEX_RELAY_CONFIG_SCHEMA_VERSION = "ceal.codex_relay_config.v1";
4327
- function resolveCodexRelayConfigPath(codexHome) {
4328
- const root = codexHome ?? (process.env.CODEX_HOME || join5(homedir2(), ".codex"));
4329
- if (typeof root !== "string" || root.length === 0) throw new CodexHostAdapterError("configuration", "Codex home is unavailable.");
4330
- return join5(root, ".ceal", "codex-relay.json");
4331
- }
4332
- async function readCodexRelayConfig(path = resolveCodexRelayConfigPath()) {
4333
- validateConfigPath(path);
4334
- const value = JSON.parse(await readPrivateFile2(path));
4335
- return normalizeRelayConfig(value);
4336
- }
4337
- function normalizeRelayConfig(value) {
4338
- if (!isRecord9(value)) throw new CodexHostAdapterError("configuration", "Codex relay configuration is malformed.");
4339
- if (!sameKeys2(value, ["schema_version", "gateway_origin", "credential_file", "host_source_ref", "outbox_dir"])) throw new CodexHostAdapterError("configuration", `Codex relay configuration key set is malformed (${refusalFact("keys", Object.keys(value), "exactly the relay configuration key set")}).`);
4340
- if (value.schema_version !== CODEX_RELAY_CONFIG_SCHEMA_VERSION) throw new CodexHostAdapterError("configuration", `Codex relay configuration schema is malformed (${refusalFact("schema_version", value.schema_version, `expected ${CODEX_RELAY_CONFIG_SCHEMA_VERSION}`)}).`);
4341
- if (!httpsOrigin(value.gateway_origin) || !absolutePath(value.credential_file) || !safeRef4(value.host_source_ref) || !absolutePath(value.outbox_dir)) {
4342
- throw new CodexHostAdapterError("configuration", `Codex relay configuration fields are malformed (${refusalFacts([
4343
- { name: "gateway_origin_valid", value: httpsOrigin(value.gateway_origin), expected: "true" },
4344
- { name: "credential_file_absolute", value: absolutePath(value.credential_file), expected: "true" },
4345
- { name: "host_source_ref", value: value.host_source_ref, expected: "a safe Host reference" },
4346
- { name: "outbox_dir_absolute", value: absolutePath(value.outbox_dir), expected: "true" }
4347
- ])}).`);
4348
- }
4349
- return {
4350
- schema_version: CODEX_RELAY_CONFIG_SCHEMA_VERSION,
4351
- gateway_origin: value.gateway_origin,
4352
- credential_file: value.credential_file,
4353
- host_source_ref: value.host_source_ref,
4354
- outbox_dir: value.outbox_dir
4355
- };
4356
- }
4357
- async function readPrivateFile2(path) {
4358
- let handle;
4359
- try {
4360
- handle = await open6(path, O_RDONLY5 | O_NOFOLLOW4);
4361
- const stats = await handle.stat();
4362
- const uid = typeof process.geteuid === "function" ? process.geteuid() : stats.uid;
4363
- if (!stats.isFile()) throw new CodexHostAdapterError("storage", `Codex relay state path is not a regular file (${refusalFact("mode", `0o${stats.mode.toString(8)}`, "a regular-file mode (0o100xxx)")}).`);
4364
- if ((stats.mode & 63) !== 0) throw new CodexHostAdapterError("storage", `Codex relay state file is readable beyond its owner (${refusalFact("permission_bits", `0o${(stats.mode & 511).toString(8)}`, "no group or other bits")}).`);
4365
- if (stats.uid !== uid) throw new CodexHostAdapterError("storage", `Codex relay state file is owned by another user (${refusalFact("uid", stats.uid, `expected ${uid}`)}).`);
4366
- return await handle.readFile("utf8");
4367
- } catch (error) {
4368
- if (error instanceof CodexHostAdapterError) throw error;
4369
- throw error;
4370
- } finally {
4371
- await handle?.close();
4372
- }
4373
- }
4374
- function validateConfigPath(path) {
4375
- if (!isAbsolute4(path)) throw new CodexHostAdapterError("configuration", "Codex relay config path must be absolute.");
4376
- }
4377
- function httpsOrigin(value) {
4378
- try {
4379
- const url = new URL(String(value));
4380
- return typeof value === "string" && url.protocol === "https:" && url.username === "" && url.password === "" && url.search === "" && url.hash === "";
4381
- } catch {
4382
- return false;
4383
- }
4384
- }
4385
- function absolutePath(value) {
4386
- return typeof value === "string" && isAbsolute4(value) && value.length <= 4096;
4387
- }
4388
- function safeRef4(value) {
4389
- return typeof value === "string" && /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u.test(value);
4390
- }
4391
- function isRecord9(value) {
4392
- return value !== null && typeof value === "object" && !Array.isArray(value);
4393
- }
4394
- function sameKeys2(value, required, optional = []) {
4395
- const keys = Object.keys(value);
4396
- return required.every((key) => Object.hasOwn(value, key)) && keys.every((key) => required.includes(key) || optional.includes(key));
4397
- }
4398
-
4399
4294
  // host/codex/src/codex-hook-runner.ts
4400
4295
  var MAX_STDIN_BYTES = 64 * 1024;
4401
4296
  async function runCodexHookFromStdin(event, stdin, options) {
@@ -4407,15 +4302,6 @@ function codexHookEventFromArgs(args) {
4407
4302
  const event = marker?.slice("--ceal-hook-event=".length);
4408
4303
  return isCodexHookEvent(event) ? event : null;
4409
4304
  }
4410
- function defaultCodexHookRunnerOptions(gateway) {
4411
- const codexHome = process.env.CODEX_HOME || join6(homedir3(), ".codex");
4412
- return {
4413
- host_source_ref: process.env.CEAL_CODEX_HOST_SOURCE_REF ?? "codex-host:local",
4414
- outbox_dir: process.env.CEAL_CODEX_OUTBOX_DIR ?? join6(codexHome, ".ceal", "codex-observation-outbox"),
4415
- codex_sessions_root: join6(codexHome, "sessions"),
4416
- gateway
4417
- };
4418
- }
4419
4305
  async function runCodexHookProcess(args, stdin, options) {
4420
4306
  const event = codexHookEventFromArgs(args);
4421
4307
  if (event === null) return 0;
@@ -4453,29 +4339,13 @@ async function runCodexHookCli() {
4453
4339
  }
4454
4340
  };
4455
4341
  const args = process.argv.slice(2);
4456
- const owner = hasHostConfigArgument(args) ? await installedCodexHookRunnerOptions(args, unavailableGateway) : await standaloneCodexHookRunnerOptions(unavailableGateway);
4342
+ const owner = await installedCodexHookRunnerOptions(args, unavailableGateway);
4457
4343
  return runCodexHookProcess(args, process.stdin, owner);
4458
4344
  }
4459
4345
  async function installedCodexHookRunnerOptions(args, gateway) {
4460
4346
  const config = await readHostProducerConfig(CODEX_PRODUCER_DESCRIPTOR, parseHostProducerConfigFlag(args));
4461
4347
  return { gateway, host_source_ref: config.host_source_ref, outbox_dir: config.outbox_dir, codex_sessions_root: config.codex_sessions_root };
4462
4348
  }
4463
- async function standaloneCodexHookRunnerOptions(gateway) {
4464
- const defaults = defaultCodexHookRunnerOptions(gateway);
4465
- try {
4466
- const config = await readCodexRelayConfig();
4467
- return { ...defaults, host_source_ref: config.host_source_ref, outbox_dir: config.outbox_dir };
4468
- } catch (error) {
4469
- if (!isNotFound2(error)) throw error;
4470
- return defaults;
4471
- }
4472
- }
4473
- function hasHostConfigArgument(args) {
4474
- return args.some((argument) => argument === HOST_PRODUCER_CONFIG_FLAG || argument.startsWith(`${HOST_PRODUCER_CONFIG_FLAG}=`));
4475
- }
4476
- function isNotFound2(error) {
4477
- return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
4478
- }
4479
4349
 
4480
4350
  // host/codex/bin/ceal-codex-hook.ts
4481
4351
  void runCodexHookCli().then((exitCode) => {