@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.
@@ -134,7 +134,7 @@ var client_wire_contract_default = {
134
134
  "prompt"
135
135
  ],
136
136
  discovery_command: "discovery",
137
- discovery_manifest_schema_version: "ceal.discovery_manifest.v2",
137
+ discovery_manifest_schema_version: "ceal.discovery_manifest.v1",
138
138
  discovery_manifest_document_fields: [
139
139
  "discovery_manifest"
140
140
  ],
@@ -208,10 +208,11 @@ var CEAL_AUDIT_OUTCOMES = vocabulary(["succeeded", "denied", "failed"]);
208
208
  var CEAL_GATEWAY_PROVIDER_STEP_OUTCOMES = vocabulary(["completed", "rejected", "throttled", "failed"]);
209
209
  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"]);
210
210
  var CEAL_GATEWAY_READ_REUSE_UNAVAILABLE_REASONS = vocabulary(["not_reported", "storage_unavailable", "coverage_incomplete", "freshness_refresh_required", "not_reusable", "bypassed"]);
211
+ var CEAL_GATEWAY_DERIVED_STORE_FAILURE_CLASSES = vocabulary(["storage_unavailable", "decode_mismatch", "write_conflict", "quota", "store_error"]);
211
212
  var CEAL_POLICY_DECISIONS = vocabulary(["allowed", "denied", "not_evaluated"]);
212
213
  var CEAL_CONNECTOR_ROUTE_PHASES = vocabulary(["scope_observation", "target_selection", "route_resolution"]);
213
214
  var CEAL_CONNECTOR_ROUTE_CAUSES = vocabulary(["provider_throttled", "provider_unavailable", "binding_invalid", "scope_limit_exceeded"]);
214
- var CEAL_WRITE_SOURCE_KINDS = vocabulary(["authenticated_registered_client", "agent_lease_admission", "provider_authenticated_event"]);
215
+ var CEAL_WRITE_SOURCE_KINDS = vocabulary(["authenticated_registered_client", "provider_authenticated_event"]);
215
216
  var CEAL_REFRESH_DELIVERIES = vocabulary(["initial", "recovery", "replay", "terminal_failure", "recovery_unavailable"]);
216
217
  var CEAL_CLIENT_OPERATIONS = vocabulary(["handshake", "discover", "call", "readback"]);
217
218
  var CEAL_WRITE_IDEMPOTENCY_POSTURES = vocabulary(["required", "optional", "not_required"]);
@@ -221,6 +222,17 @@ var CEAL_WRITE_RECEIPT_PROVIDER_STATES = vocabulary(["outcome_unknown", "verifie
221
222
  var CEAL_WRITE_RECEIPT_PROVIDER_READBACKS = vocabulary(["outcome_unknown", "verified", "not_applied"]);
222
223
  var CEAL_PROTOCOL_VERSION = "1.4.0";
223
224
  var CEAL_OPERATION_ACCESS_SCHEMA_VERSION = "ceal.operation_access.v1";
225
+ var CEAL_GATEWAY_ACTIVE_CALL_PHASES = vocabulary([
226
+ "audited_call_pending",
227
+ "continuation_read_pending",
228
+ "continuation_write_pending",
229
+ "provider_pacing_pending",
230
+ "corpus_replay_pending",
231
+ "corpus_append_pending",
232
+ "corpus_fence_pending",
233
+ "corpus_content_pending",
234
+ "corpus_transaction_pending"
235
+ ]);
224
236
  var CEAL_CONNECTOR_ROUTE_FAILURE_KEYS = vocabulary(["connector_kind", "phase", "schema_version"]);
225
237
  var CEAL_CLASSIFIED_CONNECTOR_ROUTE_FAILURE_KEYS = vocabulary(["cause", ...CEAL_CONNECTOR_ROUTE_FAILURE_KEYS]);
226
238
  var CEAL_UNCLASSIFIED_CONNECTOR_ROUTE_FAILURE_KEYS = vocabulary(["connector_kind", "error_class", "phase", "schema_version"]);
@@ -230,10 +242,130 @@ var CEAL_GATEWAY_ORGANIZATION_ROUTE_FACT_CALL_KEYS = Object.freeze([
230
242
  "policy_decision_revision"
231
243
  ]);
232
244
 
245
+ // packages/ceal-client-protocol/src/operation-next-actions.ts
246
+ var CEAL_REPEAT_REQUEST_NEXT_ACTION = "repeat_request";
247
+ var CEAL_INSPECT_RECEIPT_NEXT_ACTION = "inspect_receipt";
248
+ var CALLER_RECOVERABLE_NEXT_ACTION_VALUES = [
249
+ "select_did_you_mean",
250
+ "choose_new_output_path",
251
+ "choose_new_idempotency_key",
252
+ "restart_search",
253
+ "repeat_original_arguments",
254
+ // The occurrence this call addressed is settled and cannot move again -- a
255
+ // denied effect approval, an expired continuation -- so the caller runs the
256
+ // same call again as a new request. The refusal names the re-request; this
257
+ // word is the re-request.
258
+ CEAL_REPEAT_REQUEST_NEXT_ACTION,
259
+ "choose_new_request_identity",
260
+ // A refusal that names the argument (invalid_argument with `property`) tells the caller exactly what to change.
261
+ "correct_argument",
262
+ // A resolver-owned input must move from caller operands into the declared
263
+ // resolver selection field.
264
+ "supply_resolver_selections",
265
+ // The graph names an upstream node whose Operation produces the resolver's
266
+ // occurrence, and it has not produced one yet. The caller runs that node
267
+ // first; the refusal used to share a code with a malformed resolver result,
268
+ // which is not fixable, so neither could carry a remedy.
269
+ "run_resolver_dependency",
270
+ // A replay carries the input the occurrence durably admitted, and this one
271
+ // carries a different one. The caller fixes it by presenting the original
272
+ // invocation, so it is a remedy; the coordinator minted the word at the
273
+ // replay guard and never declared it, which read as unguided to the scorer.
274
+ "use_original_input",
275
+ // The same mismatch on the Request binding rather than the input: the
276
+ // occurrence was admitted under one binding and the replay presents another.
277
+ "use_original_request_binding",
278
+ // The client's own filesystem write was refused -- EACCES, EPERM, or a
279
+ // read-only mount -- which is how an agent sandbox fences writes outside its
280
+ // workspace. The caller reruns the same command with unsandboxed or escalated
281
+ // execution; re-adopting the session cannot help, because the sandbox refuses
282
+ // that write too.
283
+ "rerun_outside_agent_sandbox",
284
+ // The refusal names the one Operation to read next in `describe_command`:
285
+ // an absent Operation id with a sole catalog-ranked candidate, or a known
286
+ // Operation invoked without its input. Describing only reads the verified
287
+ // contract and dispatches nothing, and the caller then retries with the
288
+ // named Operation or input, so it is guidance the scorer counts.
289
+ "describe_operation",
290
+ // The refusal names the caller's own personal connect Operation in
291
+ // `required_action_sequence`: the Operation asked for, or the credential
292
+ // the call ran on, needs a personal connection the caller does not hold
293
+ // (never connected, revoked, or expired). The caller runs that exact
294
+ // Operation, completes the consent it hands back, and retries the same call.
295
+ "connect_personal_account",
296
+ // The provider or Gateway named a bounded wait; the caller waits that long
297
+ // and submits the same read again.
298
+ "retry_after",
299
+ // The ref names a container of rows (a Notion database or data source), which
300
+ // has no body of its own; the caller searches its rows instead of reading it.
301
+ "search_container_rows"
302
+ ];
303
+ var CEAL_CALLER_RECOVERABLE_NEXT_ACTIONS = Object.freeze(CALLER_RECOVERABLE_NEXT_ACTION_VALUES);
304
+ var NON_REMEDY_NEXT_ACTION_VALUES = [
305
+ // Only an administrator can take the named step -- approving a place for an
306
+ // Operation, granting a withheld capability -- so a non-administrator asks
307
+ // one. The refusal names the administrator step; this word is the ask.
308
+ "ask_admin",
309
+ "await_pending_approval",
310
+ "check_gateway",
311
+ "inspect_context_store",
312
+ "inspect_gateway",
313
+ "inspect_local_cache",
314
+ // The thin client prints these on its own behalf, before or after the wire.
315
+ // They were declared only as `CealClientLocalRemedy` keys and, for two of
316
+ // them, only as Go string literals -- a second and third vocabulary for one
317
+ // thing. `CealClientLocalRemedy` derives from this list now, so the client's
318
+ // remedies cannot drift from the words the protocol knows.
319
+ "inspect_local_client",
320
+ "inspect_local_command",
321
+ "inspect_local_output",
322
+ "inspect_local_route",
323
+ CEAL_INSPECT_RECEIPT_NEXT_ACTION,
324
+ "inspect_request",
325
+ "none",
326
+ // The provider refused because of its own configuration -- an API not
327
+ // enabled, an app scope missing -- which an operator changes in that
328
+ // provider's console. No caller edit and no retry fixes it.
329
+ "operator_action",
330
+ "recover",
331
+ "reconcile",
332
+ // Reconciliation of one named occurrence, not of the deployment: an
333
+ // occurrence with no admitted input commitment cannot be replayed safely and
334
+ // no edit to the call changes that. `reconcile` is the deployment-wide word.
335
+ "reconcile_occurrence",
336
+ "reduce_request_size",
337
+ // The Host's invocation context for this turn is stale or expired at the
338
+ // Gateway. The Host's next turn rebinds it and the same call then succeeds;
339
+ // nothing in the call changes, so it is not a remedy the scorer may count.
340
+ "refresh_host_invocation_context",
341
+ "repair_or_adopt_session",
342
+ "retry",
343
+ // The owner -- a correlation hook, an approval hook -- is not serving right
344
+ // now. The caller changes nothing and the same call succeeds once the owner
345
+ // is back, so this is not a remedy the scorer may count as guidance.
346
+ "retry_after_owner_recovery",
347
+ "retry_same_receipt_read",
348
+ "run_file_search_again",
349
+ "select_exact_approval"
350
+ ];
351
+ var CEAL_NON_REMEDY_NEXT_ACTIONS = Object.freeze(NON_REMEDY_NEXT_ACTION_VALUES);
352
+ var DECLARED = /* @__PURE__ */ new Set([...CEAL_CALLER_RECOVERABLE_NEXT_ACTIONS, ...CEAL_NON_REMEDY_NEXT_ACTIONS]);
353
+ var RETRY_PROMISE_NEXT_ACTIONS = ["retry", "retry_after"];
354
+ var RETRY_PROMISE = new Set(RETRY_PROMISE_NEXT_ACTIONS);
355
+ var RECOVERABLE = new Set(CEAL_CALLER_RECOVERABLE_NEXT_ACTIONS);
356
+ var CEAL_OPERATION_WITHHELD_NEXT_ACTIONS = Object.freeze({
357
+ provider_permission: "ask_admin",
358
+ access_level: "ask_admin",
359
+ personal_authorization_required: "connect_personal_account"
360
+ });
361
+
362
+ // packages/ceal-client-protocol/src/operation-withheld-cause.ts
363
+ var CEAL_OPERATION_WITHHELD_CAUSES = vocabulary(["provider_permission", "access_level", "personal_authorization_required"]);
364
+
233
365
  // packages/ceal-client-protocol/src/operation-contract-types.ts
234
366
  var CEAL_JSON_SCHEMA_2020_12 = "https://json-schema.org/draft/2020-12/schema";
235
367
  var CEAL_OPERATION_ERROR_SCHEMA_VERSION = "ceal.operation_error.v1";
236
- var CEAL_OPERATION_WITHHELD_CAUSES = vocabulary(["provider_permission", "access_level", "personal_authorization_required"]);
368
+ var CEAL_ARTIFACT_STAGE_TERMINALS = vocabulary(["chunk_accepted", "artifact_ready", "idempotency_replayed"]);
237
369
  var CEAL_RETRY_AFTER_MAX_MS = 60 * 60 * 1e3;
238
370
  var CEAL_JSON_SCHEMA_TYPES = vocabulary(["object", "array", "string", "integer", "number", "boolean", "null"]);
239
371
  var OBSERVATION_POSTURES = vocabulary(["direct_readback", "approved_no_readback", "operator_mediated", "excluded"]);
@@ -497,6 +629,8 @@ var CEAL_PROVIDER_BOUNDARY_KINDS = vocabulary([
497
629
  var CEAL_PROVIDER_BOUNDARY_EVIDENCE = vocabulary(["provider_readback", "operator_stated"]);
498
630
  var CEAL_ACCESS_LEVELS = vocabulary(["none", "read", "read_write"]);
499
631
  var CEAL_PERSONAL_ACCESS_CEILINGS = vocabulary(["disabled", "read", "read_write"]);
632
+ var CEAL_TARGET_REF_PATTERN = "^[^\\p{Cc}]+$";
633
+ var TARGET_REF = new RegExp(CEAL_TARGET_REF_PATTERN, "u");
500
634
  var CEAL_TARGET_VISIBILITIES = vocabulary(["public", "private"]);
501
635
  var CEAL_PRINCIPAL_KINDS = vocabulary(["human", "service", "runtime"]);
502
636
  var CEAL_ORGANIZATION_ROLES = vocabulary(["member", "admin"]);
@@ -605,8 +739,6 @@ var CEAL_OPERATION_AUTHORITY_POLICY_KEYS = Object.freeze(["access_group", "insta
605
739
  var MAX_OPERATION_INPUT_RESOLVER_BINDINGS = 96;
606
740
  var CEAL_OPERATION_DESCRIPTOR_REQUIRED_ENVELOPE_KEYS = Object.freeze(["schema_version", "id", "input_contract", "result_contract", "policy"]);
607
741
  var CEAL_OPERATION_DESCRIPTOR_OPTIONAL_ENVELOPE_KEYS = Object.freeze(["input_resolution", "summary"]);
608
- var CEAL_OPERATION_RESULT_KEYS = vocabulary(["ok", "operation_id", "operation_receipt", "schema_version", "value"]);
609
- var CEAL_OPERATION_COMPACT_RESULT_KEYS = vocabulary(["ok", "operation_evidence", "operation_id", "schema_version", "value"]);
610
742
 
611
743
  // packages/ceal-client-protocol/src/operation-catalog.ts
612
744
  var CEAL_OPERATION_CATALOG_SCHEMA_VERSION = "ceal.catalog.v3";
@@ -618,8 +750,8 @@ var CEAL_SCHEMA_LITERALS = [
618
750
  "ceal.activation_transport.v1",
619
751
  CEAL_OPERATION_ACCESS_SCHEMA_VERSION,
620
752
  CEAL_OPERATION_CATALOG_SCHEMA_VERSION,
621
- "ceal.client_refresh_request.v2",
622
- "ceal.client_refresh_result.v2",
753
+ "ceal.client_refresh_request.v1",
754
+ "ceal.client_refresh_result.v1",
623
755
  "ceal.client_revoke_request.v1",
624
756
  "ceal.client_revoke_result.v1",
625
757
  CEAL_COMMAND_REQUEST_SCHEMA_VERSION,
@@ -648,7 +780,7 @@ var CEAL_SCHEMA_LITERALS = [
648
780
  "ceal.gateway_call_result.v1",
649
781
  CEAL_GATEWAY_COMMAND_RESOLUTION_SCHEMA_VERSION,
650
782
  "ceal.gateway_connector_route_failure.v1",
651
- "ceal.gateway_discovery.v3",
783
+ "ceal.gateway_discovery.v1",
652
784
  "ceal.gateway_handshake.v1",
653
785
  "ceal.gateway_installation_activation_code_issue_request.v1",
654
786
  "ceal.gateway_installation_activation_code_issue_result.v1",
@@ -670,10 +802,6 @@ var CEAL_SCHEMA_LITERALS = [
670
802
  "ceal.host_observation.v1",
671
803
  "ceal.host_registration_request.v1",
672
804
  "ceal.host_registration_result.v1",
673
- "ceal.leased-resource-stream.v2",
674
- "ceal.leased_consumer_attachment_stream_frame.v2",
675
- "ceal.leased_consumer_attachment_stream_request.v2",
676
- "ceal.leased_consumer_attachment_stream_transport.v2",
677
805
  "ceal.operation_descriptor.v1",
678
806
  "ceal.operation_error.v1",
679
807
  "ceal.operation_failure.v1",
@@ -681,7 +809,7 @@ var CEAL_SCHEMA_LITERALS = [
681
809
  "ceal.operation_receipt.v1",
682
810
  "ceal.operation_result.v1",
683
811
  "ceal.operation_result.compact.v1",
684
- "ceal.local_result_materialization.v2",
812
+ "ceal.local_result_materialization.v1",
685
813
  "ceal.local_result_root.v1",
686
814
  "ceal.owner_bootstrap_exchange_request.v1",
687
815
  "ceal.owner_bootstrap_exchange_result.v1",
@@ -699,12 +827,6 @@ var CEAL_SCHEMA_LITERAL_SET = new Set(CEAL_SCHEMA_LITERALS);
699
827
  // packages/ceal-client-protocol/src/bounded-series.ts
700
828
  import { join } from "node:path";
701
829
  var CEAL_BOUNDED_SERIES_CATALOG = Object.freeze({
702
- usage_record: (root) => join(root, "run-usage.jsonl"),
703
- control_commit: (root) => join(root, "control-auto-commit.jsonl"),
704
- engagement_signal: (root) => join(root, "runtime-state", "slack-feedback.jsonl"),
705
- runtime_error: (root) => join(root, "runtime-state", "runtime-errors.jsonl"),
706
- turn_bridge_request: (root) => join(root, ".ceal", "turn-bridge", "requests.jsonl"),
707
- thread_run_events: (root) => join(root, "run-events.jsonl"),
708
830
  bounded_store_sidecar: (root) => `${root}.jsonl`,
709
831
  gateway_audit_archive: (root) => `${root}.jsonl`,
710
832
  gateway_access_group_connector_control_audit: (root) => `${root}.audit.jsonl`,
@@ -738,146 +860,8 @@ var CEAL_HOST_INSTALLATION_REF_PATTERN = new RegExp(`^host-installation:${CEAL_L
738
860
  var CEAL_HOST_SOURCE_REF_PATTERN = new RegExp(`^host-source:${CEAL_LOWERCASE_UUID_PATTERN}$`, "u");
739
861
  var CEAL_HOST_ACCESS_TOKEN_PATTERN = /^ceal_host_[A-Za-z0-9_-]{43}$/u;
740
862
 
741
- // packages/ceal-client-protocol/src/agent-session-handoff.ts
742
- var CEAL_AGENT_ADMISSION_PHASES = vocabulary([
743
- "incumbent_admitted",
744
- "incumbent_draining",
745
- "drained",
746
- "candidate_admitted",
747
- "candidate_draining",
748
- "rollback_admitted"
749
- ]);
750
- var CEAL_AGENT_SERVICE_SESSION_RECORD_KEYS = vocabulary([
751
- "admission_fence",
752
- "admission_state",
753
- "admission_state_generation",
754
- "bearer",
755
- "consumer_ref",
756
- "credential_generation",
757
- "expires_at",
758
- "gateway_instance",
759
- "gateway_origin",
760
- "gateway_serving_generation",
761
- "issued_at",
762
- "record_sha256",
763
- "renew_after",
764
- "renew_by",
765
- "schema_version",
766
- "session_revision"
767
- ]);
768
- var CEAL_AGENT_SESSION_COMMIT_KEYS = vocabulary(["attempt_ref", "expected_session_revision", "session_revision"]);
769
-
770
- // packages/ceal-client-protocol/src/operation-next-actions.ts
771
- var CEAL_REPEAT_REQUEST_NEXT_ACTION = "repeat_request";
772
- var CEAL_INSPECT_RECEIPT_NEXT_ACTION = "inspect_receipt";
773
- var CALLER_RECOVERABLE_NEXT_ACTION_VALUES = [
774
- "select_did_you_mean",
775
- "choose_new_output_path",
776
- "choose_new_idempotency_key",
777
- "restart_search",
778
- "repeat_original_arguments",
779
- // The occurrence this call addressed is settled and cannot move again -- a
780
- // denied effect approval, an expired continuation -- so the caller runs the
781
- // same call again as a new request. The refusal names the re-request; this
782
- // word is the re-request.
783
- CEAL_REPEAT_REQUEST_NEXT_ACTION,
784
- "choose_new_request_identity",
785
- // A refusal that names the argument (invalid_argument with `property`) tells the caller exactly what to change.
786
- "correct_argument",
787
- // A resolver-owned input must move from caller operands into the declared
788
- // resolver selection field.
789
- "supply_resolver_selections",
790
- // The graph names an upstream node whose Operation produces the resolver's
791
- // occurrence, and it has not produced one yet. The caller runs that node
792
- // first; the refusal used to share a code with a malformed resolver result,
793
- // which is not fixable, so neither could carry a remedy.
794
- "run_resolver_dependency",
795
- // A replay carries the input the occurrence durably admitted, and this one
796
- // carries a different one. The caller fixes it by presenting the original
797
- // invocation, so it is a remedy; the coordinator minted the word at the
798
- // replay guard and never declared it, which read as unguided to the scorer.
799
- "use_original_input",
800
- // The same mismatch on the Request binding rather than the input: the
801
- // occurrence was admitted under one binding and the replay presents another.
802
- "use_original_request_binding",
803
- // The client's own filesystem write was refused -- EACCES, EPERM, or a
804
- // read-only mount -- which is how an agent sandbox fences writes outside its
805
- // workspace. The caller reruns the same command with unsandboxed or escalated
806
- // execution; re-adopting the session cannot help, because the sandbox refuses
807
- // that write too.
808
- "rerun_outside_agent_sandbox",
809
- // The refusal names the one Operation to read next in `describe_command`:
810
- // an absent Operation id with a sole catalog-ranked candidate, or a known
811
- // Operation invoked without its input. Describing only reads the verified
812
- // contract and dispatches nothing, and the caller then retries with the
813
- // named Operation or input, so it is guidance the scorer counts.
814
- "describe_operation",
815
- // The refusal names the caller's own personal connect Operation in
816
- // `required_action_sequence`: the Operation asked for, or the credential
817
- // the call ran on, needs a personal connection the caller does not hold
818
- // (never connected, revoked, or expired). The caller runs that exact
819
- // Operation, completes the consent it hands back, and retries the same call.
820
- "connect_personal_account",
821
- // The provider or Gateway named a bounded wait; the caller waits that long
822
- // and submits the same read again.
823
- "retry_after"
824
- ];
825
- var CEAL_CALLER_RECOVERABLE_NEXT_ACTIONS = Object.freeze(CALLER_RECOVERABLE_NEXT_ACTION_VALUES);
826
- var NON_REMEDY_NEXT_ACTION_VALUES = [
827
- // Only an administrator can take the named step -- approving a place for an
828
- // Operation, granting a withheld capability -- so a non-administrator asks
829
- // one. The refusal names the administrator step; this word is the ask.
830
- "ask_admin",
831
- "await_pending_approval",
832
- "check_gateway",
833
- "inspect_context_store",
834
- "inspect_gateway",
835
- "inspect_local_cache",
836
- // The thin client prints these on its own behalf, before or after the wire.
837
- // They were declared only as `CealClientLocalRemedy` keys and, for two of
838
- // them, only as Go string literals -- a second and third vocabulary for one
839
- // thing. `CealClientLocalRemedy` derives from this list now, so the client's
840
- // remedies cannot drift from the words the protocol knows.
841
- "inspect_local_client",
842
- "inspect_local_command",
843
- "inspect_local_output",
844
- "inspect_local_route",
845
- CEAL_INSPECT_RECEIPT_NEXT_ACTION,
846
- "inspect_request",
847
- "none",
848
- // The provider refused because of its own configuration -- an API not
849
- // enabled, an app scope missing -- which an operator changes in that
850
- // provider's console. No caller edit and no retry fixes it.
851
- "operator_action",
852
- "recover",
853
- "reconcile",
854
- // Reconciliation of one named occurrence, not of the deployment: an
855
- // occurrence with no admitted input commitment cannot be replayed safely and
856
- // no edit to the call changes that. `reconcile` is the deployment-wide word.
857
- "reconcile_occurrence",
858
- "reduce_request_size",
859
- // The Host's invocation context for this turn is stale or expired at the
860
- // Gateway. The Host's next turn rebinds it and the same call then succeeds;
861
- // nothing in the call changes, so it is not a remedy the scorer may count.
862
- "refresh_host_invocation_context",
863
- "repair_or_adopt_session",
864
- "retry",
865
- // The owner -- a correlation hook, an approval hook -- is not serving right
866
- // now. The caller changes nothing and the same call succeeds once the owner
867
- // is back, so this is not a remedy the scorer may count as guidance.
868
- "retry_after_owner_recovery",
869
- "retry_same_receipt_read",
870
- "run_file_search_again",
871
- "select_exact_approval"
872
- ];
873
- var CEAL_NON_REMEDY_NEXT_ACTIONS = Object.freeze(NON_REMEDY_NEXT_ACTION_VALUES);
874
- var DECLARED = /* @__PURE__ */ new Set([...CEAL_CALLER_RECOVERABLE_NEXT_ACTIONS, ...CEAL_NON_REMEDY_NEXT_ACTIONS]);
875
- var RECOVERABLE = new Set(CEAL_CALLER_RECOVERABLE_NEXT_ACTIONS);
876
- var CEAL_OPERATION_WITHHELD_NEXT_ACTIONS = Object.freeze({
877
- provider_permission: "ask_admin",
878
- access_level: "ask_admin",
879
- personal_authorization_required: "connect_personal_account"
880
- });
863
+ // packages/ceal-client-protocol/src/operation-result-completeness.ts
864
+ var CEAL_READ_VALUE_CONTINUATION_KEYS = vocabulary(["continuation", "continuation_ref", "next_cursor"]);
881
865
 
882
866
  // packages/ceal-client-protocol/src/operation-contract-artifact.ts
883
867
  var CATALOG_REVISION = new RegExp(CEAL_VERIFIED_ARTIFACT_CATALOG_REVISION_PATTERN, "u");
@@ -886,7 +870,9 @@ var CEAL_OPERATION_INVOKE_COMMAND = "invoke";
886
870
  var CEAL_OPERATION_INPUT_FLAG = "--input";
887
871
  var CEAL_OPERATION_ID_PLACEHOLDER = "<operation-id>";
888
872
  var CEAL_OPERATION_INPUT_PLACEHOLDER = "<json-object>";
889
- var CEAL_MODEL_INVOCATION_ARGUMENTS = [CEAL_OPERATION_INVOKE_COMMAND, CEAL_OPERATION_ID_PLACEHOLDER, CEAL_OPERATION_INPUT_FLAG, shellSingleQuoted(CEAL_OPERATION_INPUT_PLACEHOLDER)].join(" ");
873
+ var MODEL_INVOCATION_BASE_ARGUMENTS = [CEAL_OPERATION_INVOKE_COMMAND, CEAL_OPERATION_ID_PLACEHOLDER].join(" ");
874
+ var CEAL_MODEL_INVOCATION_ARGUMENTS = [MODEL_INVOCATION_BASE_ARGUMENTS, CEAL_OPERATION_INPUT_FLAG, shellSingleQuoted(CEAL_OPERATION_INPUT_PLACEHOLDER)].join(" ");
875
+ 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.`;
890
876
  function shellSingleQuoted(value) {
891
877
  return `'${value.replaceAll("'", "'\\''")}'`;
892
878
  }
@@ -918,76 +904,7 @@ var CEAL_VERIFIED_ARTIFACT_DESCRIPTOR_JSON_SCHEMA = Object.freeze({
918
904
  }
919
905
  });
920
906
 
921
- // packages/ceal-client-protocol/src/bare-document.ts
922
- var REQUIRED_FIELDS = CEAL_CLIENT_WIRE_CONTRACT.command_response.bare_document_fields;
923
- var OPTIONAL_FIELDS = CEAL_CLIENT_WIRE_CONTRACT.command_response.bare_document_optional_fields;
924
-
925
- // packages/ceal-client-protocol/src/leased-consumer-vocabulary.ts
926
- var CEAL_TERMINAL_DISPOSITIONS = vocabulary(["completed", "failed", "cancelled"]);
927
- var CEAL_LEASE_DISPOSITIONS = vocabulary([...CEAL_TERMINAL_DISPOSITIONS, "deferred"]);
928
- var CEAL_AUTOMATIC_FEEDBACK_INTENTS = vocabulary(["initial"]);
929
- var CEAL_LEASED_MESSAGE_DELIVERY_OPERATION_IDS = vocabulary(["message.send", "message.update", "message.delete"]);
930
- var CEAL_REPOSITORY_VISIBILITIES = vocabulary(["public", "private", "internal"]);
931
- var CEAL_RESULT_DELIVERY_OFFERS = vocabulary(["pending", "offered", "transport_lost"]);
932
- var CEAL_RESULT_DELIVERY_STATES = vocabulary(["unavailable", ...CEAL_RESULT_DELIVERY_OFFERS]);
933
- var CEAL_PROVIDER_OUTCOMES = vocabulary(["not_attempted", "outcome_unknown", "verified"]);
934
- var CEAL_ACTIVITY_GAP_CODES = vocabulary([
935
- "provider_page_budget",
936
- "call_deadline",
937
- "related_item_budget",
938
- "provider_cursor_unavailable",
939
- "malformed_provider_page",
940
- "visibility_incomplete",
941
- "unsupported_event_kind"
942
- ]);
943
- var CEAL_ACTIVITY_CONNECTOR_KINDS = vocabulary(["slack", "github", "google-calendar", "google-drive", "notion"]);
944
- var CEAL_ACTIVITY_COVERAGE_STATUSES = vocabulary(["complete_for_target", "continuation_required", "blocked"]);
945
- var CEAL_ACTIVITY_EVENT_KINDS = vocabulary([
946
- "slack.message",
947
- "slack.reply",
948
- "slack.direct_message",
949
- "github.commit.authored",
950
- "github.issue.opened",
951
- "github.pull_request.opened",
952
- "github.review.submitted",
953
- "github.issue_comment.created",
954
- "github.review_comment.created",
955
- "calendar.organized",
956
- "calendar.accepted_invite",
957
- "calendar.recorded",
958
- "drive.file.created",
959
- "drive.file.modified",
960
- "drive.file.viewed",
961
- "notion.page.created",
962
- "notion.page.edited"
963
- ]);
964
- var CEAL_ACTIVITY_TIMESTAMP_BASES = vocabulary([
965
- "message_created",
966
- "commit_authored",
967
- "resource_created",
968
- "review_submitted",
969
- "comment_created",
970
- "event_start",
971
- "all_day_start",
972
- "file_created",
973
- "file_modified",
974
- "file_modified_by_me",
975
- "file_viewed_by_me",
976
- "page_created",
977
- "page_last_edited",
978
- "resource_modified"
979
- ]);
980
- var CEAL_ACTIVITY_V3_KINDS = vocabulary(["authored", "edited", "messaged", "responded"]);
981
- var CEAL_RESOURCE_TIME_BASES = vocabulary(["created", "modified", "viewed"]);
982
- var CEAL_RESOURCE_SEARCH_ORDERS = vocabulary(["relevance", "modified", "viewed", "created"]);
983
- var CEAL_RESOURCE_SEARCH_DIRECTIONS = vocabulary(["ascending", "descending"]);
984
- 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"]);
985
- var CEAL_ARTIFACT_STAGE_TERMINALS = vocabulary(["chunk_accepted", "artifact_ready", "idempotency_replayed"]);
986
- var CEAL_READ_ITEM_KINDS = vocabulary(["conversation", "identity", "usergroup", "message", "file", "document"]);
987
- var CEAL_LEASED_MESSAGE_SEARCH_COMPLETENESS = vocabulary(["complete", "continuation_available", "truncated"]);
988
- var CEAL_OPAQUE_HANDLE_KINDS = vocabulary(["target", "message", "thread", "artifact", "document", "object"]);
989
- var CEAL_WRITE_OBJECT_KINDS = vocabulary(["document", "comment", "cell_range"]);
990
- var CEAL_CONVERSATION_KINDS = vocabulary(["channel", "dm", "group"]);
907
+ // packages/ceal-client-protocol/src/provider-operation-vocabulary.ts
991
908
  var CEAL_FILE_TYPE_FAMILIES = vocabulary(["all", "image", "pdf"]);
992
909
  var CEAL_GITHUB_ISSUE_STATES = vocabulary(["open", "closed", "all"]);
993
910
  var CEAL_NOTION_UPDATABLE_BLOCK_TYPES = vocabulary([
@@ -1021,12 +938,92 @@ var CEAL_NOTION_IDENTITY_GAP_REASONS = vocabulary([
1021
938
  "identity_unlinked"
1022
939
  ]);
1023
940
  var CEAL_NOTION_STRING_VALUE_TYPES = vocabulary(["text", "select", "url", "email", "phone"]);
1024
- var CEAL_UNREAD_REASONS = vocabulary(["blocked", "unavailable", "too_large", "unsupported", "download_failed", "permission_denied"]);
1025
- var CEAL_PLAN_ITEM_STATUSES = vocabulary(["pending", "active", "completed"]);
1026
- var CEAL_FINAL_PRESENTATION_INTENTS = vocabulary(["final", "stop", "transient_notice"]);
1027
- var CEAL_PRESENTATION_INTENTS = vocabulary(["progress", ...CEAL_FINAL_PRESENTATION_INTENTS]);
941
+
942
+ // packages/ceal-client-protocol/src/opaque-reference.ts
943
+ var CEAL_OPAQUE_HANDLE_KINDS = vocabulary(["target", "message", "thread", "artifact", "document", "block", "object"]);
944
+ var CEAL_OPAQUE_REF_KINDS = vocabulary([...CEAL_OPAQUE_HANDLE_KINDS, "result", "operation-receipt", "reply-receipt", "field", "notion-data-source"]);
945
+
946
+ // packages/ceal-client-protocol/src/bare-document.ts
947
+ var REQUIRED_FIELDS = CEAL_CLIENT_WIRE_CONTRACT.command_response.bare_document_fields;
948
+ var OPTIONAL_FIELDS = CEAL_CLIENT_WIRE_CONTRACT.command_response.bare_document_optional_fields;
1028
949
 
1029
950
  // packages/ceal-client-protocol/src/resource-row.ts
951
+ var CEAL_RESOURCE_SEARCH_ORDERS = vocabulary(["relevance", "modified", "viewed", "created"]);
952
+ var CEAL_RESOURCE_SEARCH_DIRECTIONS = vocabulary(["ascending", "descending"]);
953
+ 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"]);
954
+ var CEAL_RESOURCE_TIME_BASES = vocabulary(["created", "modified", "viewed"]);
955
+ var CEAL_REPOSITORY_VISIBILITIES = vocabulary(["public", "private", "internal"]);
956
+ var CEAL_ACTIVITY_V3_KINDS = vocabulary(["authored", "edited", "messaged", "responded"]);
957
+ var CEAL_ACTIVITY_TIMESTAMP_BASES = vocabulary([
958
+ "message_created",
959
+ "commit_authored",
960
+ "resource_created",
961
+ "review_submitted",
962
+ "comment_created",
963
+ "event_start",
964
+ "all_day_start",
965
+ "file_created",
966
+ "file_modified",
967
+ "file_modified_by_me",
968
+ "file_viewed_by_me",
969
+ "page_created",
970
+ "page_last_edited",
971
+ "resource_modified"
972
+ ]);
973
+ var CEAL_ACTIVITY_CONNECTOR_KINDS = vocabulary(["slack", "github", "google-calendar", "google-drive", "notion"]);
974
+ var CEAL_ACTIVITY_GAP_CODES = vocabulary([
975
+ "provider_page_budget",
976
+ "call_deadline",
977
+ "related_item_budget",
978
+ "provider_cursor_unavailable",
979
+ "malformed_provider_page",
980
+ "visibility_incomplete",
981
+ "unsupported_event_kind",
982
+ "direct_messages_excluded"
983
+ ]);
984
+ var CEAL_ACTIVITY_EVENT_KINDS = vocabulary([
985
+ "slack.message",
986
+ "slack.reply",
987
+ "slack.direct_message",
988
+ "github.commit.authored",
989
+ "github.issue.opened",
990
+ "github.pull_request.opened",
991
+ "github.issue.edited",
992
+ "github.pull_request.edited",
993
+ "github.review.submitted",
994
+ "github.issue_comment.created",
995
+ "github.review_comment.created",
996
+ "calendar.organized",
997
+ "calendar.accepted_invite",
998
+ "calendar.recorded",
999
+ "drive.file.created",
1000
+ "drive.file.modified",
1001
+ "drive.file.viewed",
1002
+ "notion.page.created",
1003
+ "notion.page.edited"
1004
+ ]);
1005
+ var CEAL_ACTIVITY_EVENT_TIMESTAMP_BASIS_MAP = Object.freeze({
1006
+ "slack.message": "message_created",
1007
+ "slack.reply": "message_created",
1008
+ "slack.direct_message": "message_created",
1009
+ "github.commit.authored": "commit_authored",
1010
+ "github.review.submitted": "review_submitted",
1011
+ "github.issue_comment.created": "comment_created",
1012
+ "github.review_comment.created": "comment_created",
1013
+ "github.issue.opened": "resource_created",
1014
+ "github.pull_request.opened": "resource_created",
1015
+ "github.issue.edited": "resource_modified",
1016
+ "github.pull_request.edited": "resource_modified",
1017
+ "calendar.organized": "resource_created",
1018
+ "drive.file.created": "file_created",
1019
+ "drive.file.modified": "file_modified_by_me",
1020
+ "drive.file.viewed": "file_viewed_by_me",
1021
+ "notion.page.created": "page_created",
1022
+ "notion.page.edited": "page_last_edited"
1023
+ });
1024
+ var CEAL_DATED_NOTE_BASES = vocabulary(["recording", "calendar_event", "created_time"]);
1025
+ var CEAL_DATED_NOTE_TRANSCRIPT_STATES = vocabulary(["present", "absent", "unestablished"]);
1026
+ var CEAL_READ_SEARCH_COST_CLASSES = vocabulary(["native_index", "scan"]);
1030
1027
  var RESOURCE_ROW_KEY_RULES = Object.freeze({
1031
1028
  schema_version: { required: true, timestamp: false },
1032
1029
  ref: { required: true, timestamp: false },
@@ -1039,6 +1036,7 @@ var RESOURCE_ROW_KEY_RULES = Object.freeze({
1039
1036
  source: { required: true, timestamp: false },
1040
1037
  owner: { required: false, timestamp: false },
1041
1038
  counterparts: { required: false, timestamp: false },
1039
+ attachments: { required: false, timestamp: false },
1042
1040
  created_at: { required: false, timestamp: true },
1043
1041
  created_at_local: { required: false, timestamp: true },
1044
1042
  modified_at: { required: false, timestamp: true },
@@ -1049,6 +1047,7 @@ var RESOURCE_ROW_KEY_RULES = Object.freeze({
1049
1047
  end: { required: false, timestamp: false },
1050
1048
  status: { required: false, timestamp: false },
1051
1049
  snippet: { required: false, timestamp: false },
1050
+ dated_notes: { required: false, timestamp: false },
1052
1051
  state: { required: true, timestamp: false },
1053
1052
  timestamp_basis: { required: true, timestamp: false }
1054
1053
  });
@@ -1085,16 +1084,26 @@ var CEAL_WRITE_SAFETY_UNCHECKED_REASONS = vocabulary(["authority_unavailable"]);
1085
1084
  // packages/ceal-client-protocol/src/operation-occurrence.ts
1086
1085
  var MAX_RECEIPT_REVISION = Number.MAX_SAFE_INTEGER - 1;
1087
1086
 
1088
- // packages/ceal-client-protocol/src/leased-artifact-contract.ts
1089
- var CEAL_LEASED_CONSUMER_ARTIFACT_CHUNK_MAX_BYTES = 12 * 1024;
1090
-
1091
- // packages/ceal-client-protocol/src/leased-resource-stream.ts
1092
- var CEAL_LEASED_CONSUMER_ATTACHMENT_STREAM_MAGIC = new Uint8Array([67, 69, 65, 76, 82, 83, 50, 0]);
1093
- var CEAL_LEASED_CONSUMER_ATTACHMENT_STREAM_RECORD_PREFIX_BYTES = 8;
1094
- var CEAL_LEASED_CONSUMER_ATTACHMENT_STREAM_MAX_HEADER_BYTES = 16 * 1024;
1095
- var CEAL_LEASED_CONSUMER_ATTACHMENT_STREAM_CHUNK_BYTES = 64 * 1024;
1096
- 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;
1097
- var CEAL_ATTACHMENT_UNREAD_REASONS = vocabulary(["blocked", "unavailable", "too_large", "unsupported", "download_failed", "digest_mismatch"]);
1087
+ // packages/ceal-client-protocol/src/personal-client-vocabulary.ts
1088
+ var CEAL_PERSONAL_CLIENT_BINDING_KEYS = vocabulary([
1089
+ "access_group_ref",
1090
+ "membership_ref",
1091
+ "registration_ref",
1092
+ "client_ref",
1093
+ "subject_ref",
1094
+ "instance_ref"
1095
+ ]);
1096
+ var CEAL_ENROLLMENT_FAILURE_CODES = vocabulary(["enrollment_invalid", "enrollment_expired", "enrollment_used"]);
1097
+ var CEAL_REFRESH_FAILURE_CODES = vocabulary([
1098
+ "refresh_invalid",
1099
+ "refresh_expired",
1100
+ "refresh_inactive",
1101
+ "refresh_replayed",
1102
+ "refresh_revoked",
1103
+ "authority_replaced",
1104
+ "refresh_recovery_unavailable",
1105
+ "refresh_recovery_expired"
1106
+ ]);
1098
1107
 
1099
1108
  // packages/ceal-client-protocol/src/request-validation-primitives.ts
1100
1109
  import { createHash } from "node:crypto";
@@ -1180,7 +1189,7 @@ var CEAL_REQUEST_MAX_GRAPH_NODES = 128;
1180
1189
 
1181
1190
  // packages/ceal-client-protocol/src/request-run.ts
1182
1191
  var CEAL_REQUEST_NODE_STANDING_OCCURRENCE_SCHEMA_VERSION = "ceal.request_node_standing_occurrence.v1";
1183
- var CEAL_REQUEST_RUN_BATCH_SCHEMA_VERSION = "ceal.request_run_batch.v3";
1192
+ var CEAL_REQUEST_RUN_BATCH_SCHEMA_VERSION = "ceal.request_run_batch.v1";
1184
1193
  var REQUEST_ACTION_SAFE_REF_SCHEMA = { type: "string", minLength: 1, maxLength: 128, pattern: SAFE_REF.source };
1185
1194
  var REQUEST_ACTION_DIGEST_SCHEMA = { type: "string", minLength: 64, maxLength: 64, pattern: "^[a-f0-9]{64}$" };
1186
1195
  var REQUEST_NODE_STANDING_OCCURRENCE_SCHEMA = {
@@ -1262,6 +1271,10 @@ var CEAL_REQUEST_RUN_BATCH_JSON_SCHEMA = {
1262
1271
  };
1263
1272
 
1264
1273
  // packages/ceal-client-protocol/src/host-observation.ts
1274
+ var CEAL_HOST_INPUT_KINDS = vocabulary(["human", "host_automatic"]);
1275
+ function isCealHostInputKind(value) {
1276
+ return typeof value === "string" && CEAL_HOST_INPUT_KINDS.some((kind) => kind === value);
1277
+ }
1265
1278
  var CEAL_HOST_OBSERVATION_REF_PREFIX = "host-observation:";
1266
1279
  function validateCealHostObservationDraft(value) {
1267
1280
  const record6 = operationRecord(value, "Ceal Host observation draft is invalid.");
@@ -1318,12 +1331,6 @@ var OWNER_WRITE_STATES = Object.freeze(["attempt_started", "provider_acknowledge
1318
1331
  var OWNER_EFFECT_STATES = Object.freeze(["none", "applied", "failed", "unknown", "reconciled"]);
1319
1332
  var OWNER_RECEIPT_STATES = Object.freeze(["pending", "available", "failed", "unknown", "reconciled"]);
1320
1333
 
1321
- // packages/ceal-client-protocol/src/thread-excerpt.ts
1322
- var CEAL_THREAD_RECENT_WINDOW = 6;
1323
- var CEAL_THREAD_LAST_APP_MESSAGES_WINDOW = 3;
1324
- var CEAL_THREAD_OLDER_SUMMARY_WINDOW = 4;
1325
- var CEAL_FED_THREAD_MESSAGE_LIMIT = CEAL_THREAD_RECENT_WINDOW + CEAL_THREAD_OLDER_SUMMARY_WINDOW + CEAL_THREAD_LAST_APP_MESSAGES_WINDOW;
1326
-
1327
1334
  // packages/ceal-client-protocol/src/request-graph-readiness.ts
1328
1335
  var REQUEST_GRAPH_PRODUCER_TO_APPEND_SCHEMA = {
1329
1336
  type: "object",
@@ -1428,25 +1435,10 @@ function exactKeys(value, expected) {
1428
1435
  }
1429
1436
 
1430
1437
  // packages/ceal-client-protocol/src/client-result-materialization.ts
1438
+ var CEAL_UNREAD_REASONS = vocabulary(["blocked", "unavailable", "too_large", "unsupported", "download_failed", "permission_denied"]);
1431
1439
  var CEAL_MODEL_VISIBLE_COMMAND_OUTPUT_MAX_BYTES = 32 * 1024;
1432
- var REQUIRED_FIELDS2 = Object.freeze(["schema_version", "operation_id", "read_argv"]);
1433
- var FIELDS = /* @__PURE__ */ new Set([...REQUIRED_FIELDS2, "local_result_root", "continue_argv"]);
1434
-
1435
- // packages/ceal-client-protocol/src/session-start-affordance.ts
1436
- var CEAL_SESSION_ENTRY_INVOCATION = "ceal";
1437
- 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.`;
1438
-
1439
- // packages/ceal-client-protocol/src/conversation-contracts.ts
1440
- var CEAL_APPROVAL_POLICY_KINDS = vocabulary(["requester_only", "named_users", "role_based"]);
1441
- var CEAL_APPROVAL_TARGET_KINDS = vocabulary([
1442
- "repo_change",
1443
- "investigation",
1444
- "skill_creation",
1445
- "command_creation",
1446
- "connector_creation",
1447
- "generic"
1448
- ]);
1449
- var CEAL_PROGRESS_PHASES = vocabulary(["request_review", "information_gathering", "work_execution", "result_check"]);
1440
+ var REQUIRED_FIELDS2 = Object.freeze(["schema_version", "operation_id"]);
1441
+ var FIELDS = /* @__PURE__ */ new Set([...REQUIRED_FIELDS2, "read_argv", "local_result_root", "continue_argv", "model_disclosure", "item_read_argv"]);
1450
1442
 
1451
1443
  // packages/ceal-client-protocol/src/gateway-cache-origin-validation.ts
1452
1444
  var CEAL_MAX_CACHE_ORIGIN_AGE_MS = 30 * 24 * 60 * 60 * 1e3;
@@ -1530,27 +1522,6 @@ var ADMIN_LINEAGE_NODE_KINDS = vocabulary(["source_read", "synthesis_preview", "
1530
1522
  // packages/ceal-client-protocol/src/actor-kind.ts
1531
1523
  var CEAL_ACTOR_KINDS = vocabulary(["human", "bot", "app", "unknown"]);
1532
1524
 
1533
- // packages/ceal-client-protocol/src/personal-client-vocabulary.ts
1534
- var CEAL_PERSONAL_CLIENT_BINDING_KEYS = vocabulary([
1535
- "access_group_ref",
1536
- "membership_ref",
1537
- "registration_ref",
1538
- "client_ref",
1539
- "subject_ref",
1540
- "instance_ref"
1541
- ]);
1542
- var CEAL_ENROLLMENT_FAILURE_CODES = vocabulary(["enrollment_invalid", "enrollment_expired", "enrollment_used"]);
1543
- var CEAL_REFRESH_FAILURE_CODES = vocabulary([
1544
- "refresh_invalid",
1545
- "refresh_expired",
1546
- "refresh_inactive",
1547
- "refresh_replayed",
1548
- "refresh_revoked",
1549
- "authority_replaced",
1550
- "refresh_recovery_unavailable",
1551
- "refresh_recovery_expired"
1552
- ]);
1553
-
1554
1525
  // packages/ceal-client-protocol/src/device-enrollment.ts
1555
1526
  var CEAL_DEVICE_ENROLLMENT_POLL_FAILURE_CODES = Object.freeze(["unsupported_feature", "recovery_required", "expired", "denied"]);
1556
1527
  var POLL_RESULT_KEYS = Object.freeze(["retry_after_ms", "schema_version", "status"]);
@@ -1858,13 +1829,13 @@ function validTurn(value) {
1858
1829
  return exactOptional(value, ["local_session_ref", "local_turn_ref"], ["model", "observations"]) && safeRef(value.local_session_ref) && safeRef(value.local_turn_ref) && optionalText(value.model, 256) && validObservations(value.observations);
1859
1830
  }
1860
1831
  function validInput(value) {
1861
- return exactOptional(value, ["local_session_ref", "local_turn_ref", "local_input_ref", "origin_input", "observations"], ["decision", "local_turn_aliases", "context_expires_at"]) && safeRef(value.local_session_ref) && safeRef(value.local_turn_ref) && safeRef(value.local_input_ref) && validInputObservations(value.observations) && typeof value.origin_input === "boolean" && validInputOptionals(value);
1832
+ return exactOptional(value, ["local_session_ref", "local_turn_ref", "local_input_ref", "input_kind", "origin_input", "observations"], ["local_turn_aliases", "context_expires_at"]) && safeRef(value.local_session_ref) && safeRef(value.local_turn_ref) && safeRef(value.local_input_ref) && validInputObservations(value.observations) && isCealHostInputKind(value.input_kind) && typeof value.origin_input === "boolean" && validInputOptionals(value);
1862
1833
  }
1863
1834
  function validInputObservations(value) {
1864
1835
  return validObservations(value) && Array.isArray(value) && value.filter((item) => record(item) && item.observation_kind === "prompt").length === 1;
1865
1836
  }
1866
1837
  function validInputOptionals(value) {
1867
- return validDecision(value.decision) && optionalRefs(value.local_turn_aliases) && (value.context_expires_at === void 0 || timestamp(value.context_expires_at));
1838
+ return optionalRefs(value.local_turn_aliases) && (value.context_expires_at === void 0 || timestamp(value.context_expires_at));
1868
1839
  }
1869
1840
  function validTerminal(value) {
1870
1841
  return exactOptional(value, ["local_session_ref", "local_turn_ref", "terminal_state"], ["abort_reason", "duration_ms", "time_to_first_token_ms", "usage", "observations"]) && safeRef(value.local_session_ref) && safeRef(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);
@@ -1875,9 +1846,6 @@ function validTerminalDisposition(state, reason) {
1875
1846
  function validStatus(value) {
1876
1847
  return exactOptional(value, ["status", "reason_code"], ["detail"]) && ["ready", "degraded", "stopping"].includes(String(value.status)) && safeRef(value.reason_code) && optionalText(value.detail, 4096);
1877
1848
  }
1878
- function validDecision(value) {
1879
- return value === void 0 || record(value) && exactKeys2(value, ["decision", "approval_ref"]) && (value.decision === "approved" || value.decision === "denied") && safeRef(value.approval_ref);
1880
- }
1881
1849
  function optionalText(value, maxLength) {
1882
1850
  return value === void 0 || typeof value === "string" && value.length > 0 && value.length <= maxLength;
1883
1851
  }
@@ -2640,6 +2608,8 @@ var RelayGatewayBridge = class {
2640
2608
  }
2641
2609
  async deliverInput(state, input) {
2642
2610
  const prepared = prepareInput(state, input, this.hostSourceRef);
2611
+ const priorRefusal = refusedUnboundInput(prepared.turn);
2612
+ if (priorRefusal !== void 0) return priorRefusal;
2643
2613
  const outcome = await this.submit(prepared.submission);
2644
2614
  if ("refusal" in outcome) {
2645
2615
  if (outcome.refusal.definitive && prepared.turn !== void 0) await this.writeState({ ...state, turns: { ...state.turns, [prepared.refs.host_turn_ref]: { ...prepared.turn, input_refused: { code: outcome.refusal.code, message: outcome.refusal.message } } } });
@@ -2648,14 +2618,18 @@ var RelayGatewayBridge = class {
2648
2618
  const acknowledgement2 = outcome.acknowledgement;
2649
2619
  const nextTurn = bindInput(prepared, acknowledgement2.request_ref, input.submission_ref);
2650
2620
  await this.writeState({ ...state, turns: { ...state.turns, [prepared.refs.host_turn_ref]: nextTurn } });
2651
- const binding = { frame: structuredClone(input.frame), request_ref: acknowledgement2.request_ref, prompt_ref: prepared.promptRef, host_binding: {
2621
+ if (!bindsOriginInput(prepared)) return { status: "created" };
2622
+ const bindingRequestRef = nextTurn.request_ref ?? acknowledgement2.request_ref;
2623
+ const bindingPromptRef = nextTurn.prompt_ref ?? prepared.promptRef;
2624
+ const bindingInputRef = nextTurn.origin_host_input_ref ?? prepared.hostInputRef;
2625
+ const binding = { frame: structuredClone(input.frame), request_ref: bindingRequestRef, prompt_ref: bindingPromptRef, host_binding: {
2652
2626
  host_source_ref: prepared.submission.identity.host_source_ref,
2653
2627
  host_session_ref: prepared.submission.identity.host_session_ref,
2654
2628
  host_turn_ref: prepared.submission.identity.host_turn_ref,
2655
- host_input_ref: prepared.hostInputRef,
2656
- prompt_ref: prepared.promptRef
2629
+ host_input_ref: bindingInputRef,
2630
+ prompt_ref: bindingPromptRef
2657
2631
  } };
2658
- const context = createRelayRequestWorkContext({ request_ref: acknowledgement2.request_ref, host_binding: binding.host_binding });
2632
+ const context = createRelayRequestWorkContext({ request_ref: bindingRequestRef, host_binding: binding.host_binding });
2659
2633
  try {
2660
2634
  await this.onRequestBound(binding, context);
2661
2635
  } catch (error) {
@@ -2675,6 +2649,7 @@ var RelayGatewayBridge = class {
2675
2649
  const outcome = await this.submit({
2676
2650
  identity: { host_source_ref: this.hostSourceRef, host_session_ref: refs.host_session_ref, host_turn_ref: refs.host_turn_ref },
2677
2651
  host_input_ref: turn.origin_host_input_ref,
2652
+ input_kind: "host_automatic",
2678
2653
  prompt_ref: turn.prompt_ref,
2679
2654
  observations: payloadObservations(input.frame),
2680
2655
  request_ref: turn.request_ref,
@@ -2736,9 +2711,9 @@ function prepareInput(state, input, hostSourceRef) {
2736
2711
  const submission = compactSubmission({
2737
2712
  identity: { host_source_ref: hostSourceRef, host_session_ref: refs.host_session_ref, host_turn_ref: refs.host_turn_ref },
2738
2713
  host_input_ref: hostInputRef,
2714
+ input_kind: payloadInputKind(input.frame),
2739
2715
  prompt_ref: promptRef,
2740
2716
  observations,
2741
- decision: payloadDecision(input.frame),
2742
2717
  request_ref: turn?.request_ref,
2743
2718
  submission_ref: input.submission_ref
2744
2719
  });
@@ -2749,11 +2724,18 @@ function bindInput(prepared, requestRef, submissionRef) {
2749
2724
  host_session_ref: prepared.refs.host_session_ref,
2750
2725
  observations: prepared.turn?.observations ?? [],
2751
2726
  submission_ref: prepared.turn?.submission_ref ?? submissionRef,
2752
- request_ref: requestRef,
2753
- prompt_ref: prepared.promptRef,
2727
+ request_ref: prepared.turn?.request_ref ?? requestRef,
2728
+ prompt_ref: prepared.turn?.prompt_ref ?? prepared.promptRef,
2754
2729
  origin_host_input_ref: prepared.turn?.origin_host_input_ref ?? prepared.hostInputRef
2755
2730
  };
2756
2731
  }
2732
+ function refusedUnboundInput(turn) {
2733
+ if (turn?.request_ref !== void 0 || turn?.input_refused === void 0) return void 0;
2734
+ return { status: "refused", code: "origin_input_refused", message: `The input frame names a turn whose origin input was refused (${turn.input_refused.code}: ${turn.input_refused.message}).` };
2735
+ }
2736
+ function bindsOriginInput(prepared) {
2737
+ return prepared.turn?.request_ref === void 0 || prepared.turn.origin_host_input_ref === prepared.hostInputRef;
2738
+ }
2757
2739
  function payloadRef(frame, key) {
2758
2740
  const value = frame.payload[key];
2759
2741
  if (typeof value !== "string" || !SAFE_REF4.test(value)) throw new TypeError("Host Relay frame reference is invalid.");
@@ -2767,16 +2749,17 @@ function payloadPromptDigest(frame) {
2767
2749
  function payloadObservations(frame) {
2768
2750
  return Array.isArray(frame.payload.observations) ? frame.payload.observations.filter(isObservation) : [];
2769
2751
  }
2770
- function payloadDecision(frame) {
2771
- const value = frame.payload.decision;
2772
- return isRecord(value) && (value.decision === "approved" || value.decision === "denied") && typeof value.approval_ref === "string" ? { decision: value.decision, approval_ref: value.approval_ref } : void 0;
2752
+ function payloadInputKind(frame) {
2753
+ const value = frame.payload.input_kind;
2754
+ if (!isCealHostInputKind(value)) throw new TypeError("Host Relay input kind is invalid.");
2755
+ return value;
2773
2756
  }
2774
2757
  function uniqueObservations(values) {
2775
2758
  const seen = /* @__PURE__ */ new Set();
2776
2759
  return values.filter((value) => !seen.has(value.observation_ref) && Boolean(seen.add(value.observation_ref)));
2777
2760
  }
2778
2761
  function compactSubmission(value) {
2779
- return { identity: value.identity, host_input_ref: value.host_input_ref, prompt_ref: value.prompt_ref, observations: value.observations, submission_ref: value.submission_ref, ...value.decision === void 0 ? {} : { decision: value.decision }, ...value.request_ref === void 0 ? {} : { request_ref: value.request_ref } };
2762
+ return { identity: value.identity, host_input_ref: value.host_input_ref, input_kind: value.input_kind, prompt_ref: value.prompt_ref, observations: value.observations, submission_ref: value.submission_ref, ...value.request_ref === void 0 ? {} : { request_ref: value.request_ref } };
2780
2763
  }
2781
2764
  function isObservation(value) {
2782
2765
  try {
@@ -2842,6 +2825,7 @@ import { dirname as dirname2 } from "node:path";
2842
2825
  // host/gateway-http.ts
2843
2826
  var SAFE_HOST_REF = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u;
2844
2827
  function hostIngressBody(input, invalidEventTime) {
2828
+ if (!isCealHostInputKind(input.input_kind)) throw new TypeError("Host ingress input kind is invalid.");
2845
2829
  const prompt = input.observations.find((observation) => observation.observation_kind === "prompt");
2846
2830
  const observedAt = prompt?.observed_at ?? input.observations[0]?.observed_at;
2847
2831
  if (observedAt === void 0 || !Number.isFinite(Date.parse(observedAt))) throw invalidEventTime();
@@ -2851,11 +2835,11 @@ function hostIngressBody(input, invalidEventTime) {
2851
2835
  host_session_ref: input.identity.host_session_ref,
2852
2836
  host_turn_ref: input.identity.host_turn_ref,
2853
2837
  host_input_ref: input.host_input_ref,
2838
+ input_kind: input.input_kind,
2854
2839
  prompt_ref: input.prompt_ref,
2855
2840
  observed_at: observedAt,
2856
2841
  observations: input.observations,
2857
- ...input.request_ref === void 0 ? {} : { request_ref: input.request_ref },
2858
- ...input.decision === void 0 ? {} : { decision: input.decision.decision, approval_ref: input.decision.approval_ref }
2842
+ ...input.request_ref === void 0 ? {} : { request_ref: input.request_ref }
2859
2843
  };
2860
2844
  }
2861
2845
  async function responseJson(response2, invalidResponse2) {