@corca-org/ceal-host-win32-x64 1.0.22 → 1.0.23

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.
@@ -2124,6 +2124,15 @@ import { lstat, mkdir, unlink } from "node:fs/promises";
2124
2124
  import { createConnection } from "node:net";
2125
2125
  import { dirname } from "node:path";
2126
2126
 
2127
+ // packages/ceal-client-protocol/src/vocabulary.ts
2128
+ function vocabulary(words) {
2129
+ return Object.freeze(words);
2130
+ }
2131
+
2132
+ // packages/ceal-client-protocol/src/host-usage-fields.ts
2133
+ var CEAL_CODEX_USAGE_COUNT_FIELDS = vocabulary(["input_tokens", "cached_input_tokens", "cache_write_input_tokens", "output_tokens", "reasoning_output_tokens", "total_tokens"]);
2134
+ var CEAL_CLAUDE_USAGE_COUNT_FIELDS = vocabulary(["input_tokens", "cache_read_input_tokens", "cache_creation_input_tokens", "output_tokens"]);
2135
+
2127
2136
  // packages/ceal-client-protocol/src/canonical-json.ts
2128
2137
  function cealCanonicalJson(value) {
2129
2138
  if (value === null || typeof value === "string" || typeof value === "boolean") return JSON.stringify(value);
@@ -2298,8 +2307,11 @@ var client_wire_contract_default = {
2298
2307
  "ok",
2299
2308
  "code",
2300
2309
  "reason",
2301
- "gateway_status"
2310
+ "gateway_status",
2311
+ "retry_after_ms"
2302
2312
  ],
2313
+ refusal_required_fields: ["schema_version", "ok", "code", "reason"],
2314
+ refusal_optional_fields: ["gateway_status", "retry_after_ms"],
2303
2315
  client_nonce: {
2304
2316
  character_class_source: "A-Za-z0-9_-",
2305
2317
  encoded_characters: 43
@@ -2518,11 +2530,6 @@ var CEAL_OPERATION_WITHHELD_NEXT_ACTIONS = Object.freeze({
2518
2530
  personal_authorization_required: "connect_personal_account"
2519
2531
  });
2520
2532
 
2521
- // packages/ceal-client-protocol/src/vocabulary.ts
2522
- function vocabulary(words) {
2523
- return Object.freeze(words);
2524
- }
2525
-
2526
2533
  // packages/ceal-client-protocol/src/gateway-response-types.ts
2527
2534
  var CEAL_OPERATION_READINESS_VALUES = vocabulary(["ready", "degraded", "unavailable", "unknown"]);
2528
2535
  var CEAL_TARGET_REQUIREMENTS = vocabulary(["required", "optional", "none"]);
@@ -2921,7 +2928,7 @@ var GATEWAY_TRANSPORT_UNAVAILABLE = "The Gateway transport is unavailable; ask a
2921
2928
  var HOST_AUTHENTICATION_UNAVAILABLE = "The Host could not authenticate this invocation; report this as a gap.";
2922
2929
  var CLIENT_HOST_RELEASE_MISMATCH = "Install or upgrade the Ceal CLI and Host Relay to the same release as the Gateway, then retry.";
2923
2930
  var HOST_INSTALL_REPAIR = "The local Host or Relay is missing, stale, or unavailable. Run `ceal-host install`, then `ceal-host discovery sync`, and retry from a new producer conversation.";
2924
- var HOST_CONTEXT_UNAVAILABLE = "The Host could not select or activate the current recorded turn. This does not explain why or prove ephemerality. For an independently identified ephemeral Codex side conversation, invoke the command as `ceal --standalone ...`; it uses the local Ceal session and Gateway permissions without Host session/turn audit linkage. Host refusal never switches modes. For intended Host calls, restart the producer and start a new conversation; report the error if it persists.";
2931
+ var HOST_CONTEXT_UNAVAILABLE = "The Host could not select this turn; reason uncertain. Host mode is unavailable in an ephemeral side conversation. When you know you are in one, `ceal --standalone ...` uses your configured Ceal session/Gateway permissions, without Host session/turn correlation or Host usage attribution. Unknown-outcome `repeat_request` needs the same Host turn or explicit `--request-context`. Otherwise return to the original regular conversation. Host refusal never switches modes; report intended Host calls as a gap.";
2925
2932
  var SESSION_CONTEXT_UNAVAILABLE = "The local Gateway session context is unavailable.";
2926
2933
  function guidance(message, next_action, http_status, retryable = false, redaction_class = "model_safe") {
2927
2934
  return Object.freeze({ message, next_action, http_status, retryable, redaction_class });
@@ -2973,14 +2980,12 @@ var CEAL_FAILURE_GUIDANCE_TABLE = Object.freeze({
2973
2980
  // `gateway_internal_error` guidance (decided with the operator 2026-10-13).
2974
2981
  internal_error: guidance("The Gateway failed without exposing internal state.", "answer_with_gap", 500),
2975
2982
  // Owned by the Gateway canonical adapter (`gateway/core/src/gateway-canonical-operation-http-adapter.ts`):
2976
- // the client variant of this sentence in `localFailureText` was retired when the client started reading this table.
2983
+ // the static client variant was retired when the client started reading this table.
2977
2984
  request_body_too_large: guidance("The Gateway request body exceeds its bounded limit.", "reduce_request_size", 413),
2978
2985
  gateway_response_too_large: guidance("The Gateway response exceeds its bounded limit; reduce the requested page or result size.", "reduce_request_size", 500),
2979
- // Restored verbatim from the retired `localFailureText` `unknown_outcome`
2980
- // case: the outcome is unknown, so a read may be retried while a write
2981
- // must receipt-check first. Collapsing both to "do not repeat the call"
2982
- // forbids the safe read retry the sentence exists to allow.
2983
- unknown_outcome: guidance("The transport outcome is unknown: a read may be retried; for a write, check write_receipt.get before repeating.", "answer_with_gap", 500),
2986
+ // The safe move varies by request. Keep the sentence conditional on the
2987
+ // same `retryable` and `next_action` facts the response exposes.
2988
+ unknown_outcome: guidance("The transport outcome is unknown; use retryable and next_action to decide whether it can be repeated.", "answer_with_gap", 500),
2984
2989
  // Restored verbatim from the retired `localFailureText`
2985
2990
  // `refresh_unknown_outcome` case: a refresh that ends unknown leaves the
2986
2991
  // session context unavailable, so the caller repairs or adopts the
@@ -3061,8 +3066,8 @@ var CEAL_FAILURE_GUIDANCE_TABLE = Object.freeze({
3061
3066
  // Host mint classifications. The CLI emits `invocation_authentication_unavailable` with the classification
3062
3067
  // in its detail fact; rows without their own sentence share that code's moved sentence, while `next_action`
3063
3068
  // is moved from `canonicalHostAuthenticationNextActions` (generated from `CEAL_HOST_AUTHENTICATION_POLICY`)
3064
- // and `retryable` from `hostAuthenticationFailureForCause` (`failure.nextAction == "retry"`). Cause-specific
3065
- // sentences carry the retired policy remedies; `gateway_refused` reuses the release-upgrade guidance above.
3069
+ // and `retryable` from `hostAuthenticationFailureForCause` (the table's explicit retry verdict). Cause-specific
3070
+ // sentences carry only remedies proved by the Host or Relay cause; generic Gateway refusals do not prove a release mismatch.
3066
3071
  // Statuses are the
3067
3072
  // Gateway-owned mapping decided with the operator 2026-10-13. This covers every wire cause the maps at
3068
3073
  // `host/invocation-authentication-command.ts:217-242` emit, through their policy classifications.
@@ -3072,21 +3077,23 @@ var CEAL_FAILURE_GUIDANCE_TABLE = Object.freeze({
3072
3077
  // The bounded Host reason does not prove ephemerality. A Host refusal never
3073
3078
  // changes mode; standalone remains the separate Client authority path.
3074
3079
  host_context_unavailable: guidance(HOST_CONTEXT_UNAVAILABLE, "answer_with_gap", 401),
3075
- host_invocation_context_stale: guidance(HOST_AUTHENTICATION_UNAVAILABLE, "retry", 401, true),
3076
- host_invocation_context_expired: guidance(HOST_AUTHENTICATION_UNAVAILABLE, "retry", 401, true),
3080
+ host_context_activation_wait_exhausted: guidance("The Host selected this turn, but its invocation context did not activate before the bounded wait ended. Wait for the supplied retry_after_ms value, then retry the same command.", "retry_after", 401, true),
3081
+ host_invocation_context_stale: guidance("The Host turn changed while this invocation was authenticating. Its command cannot be rebound safely; report this invocation as a gap.", "answer_with_gap", 401),
3082
+ host_invocation_context_expired: guidance("The Host invocation context expired before authentication completed. This invocation cannot be retried in the expired turn; report it as a gap.", "answer_with_gap", 401),
3077
3083
  host_source_refused: guidance(HOST_AUTHENTICATION_UNAVAILABLE, "answer_with_gap", 403),
3078
3084
  host_registration_credential_refused: guidance(HOST_AUTHENTICATION_UNAVAILABLE, "ask_admin", 403),
3079
3085
  host_mint_gateway_unavailable: guidance(HOST_AUTHENTICATION_UNAVAILABLE, "ask_admin", 503),
3080
3086
  host_mint_gateway_rate_limited: guidance(HOST_AUTHENTICATION_UNAVAILABLE, "answer_with_gap", 429),
3081
- host_mint_gateway_refused: guidance(CLIENT_HOST_RELEASE_MISMATCH, "upgrade_ceal_client", 502),
3087
+ host_mint_gateway_refused: guidance(HOST_AUTHENTICATION_UNAVAILABLE, "answer_with_gap", 502),
3082
3088
  host_mint_gateway_response_invalid: guidance(HOST_AUTHENTICATION_UNAVAILABLE, "answer_with_gap", 502),
3089
+ host_contract_mismatch: guidance(CLIENT_HOST_RELEASE_MISMATCH, "upgrade_ceal_client", 502),
3083
3090
  // Moved from the retired `CEAL_HOST_AUTHENTICATION_POLICY` remedy: the
3084
3091
  // producer-frame fault names the administrator repair step.
3085
3092
  host_producer_frame_invalid: guidance("Ask an administrator to inspect and repair the producer frame, then start a fresh Host turn.", "ask_admin", 400),
3086
3093
  // Moved from the retired `CEAL_HOST_AUTHENTICATION_POLICY` remedy: the
3087
3094
  // sandboxed Relay socket names the run-alone retry.
3088
3095
  host_relay_permission_denied: guidance("An agent sandbox denied the Host Relay socket; run `ceal` as the only command, with no pipe, redirect, or `&&`, so the Host allow rule runs it outside the sandbox.", "rerun_outside_agent_sandbox", 403),
3089
- host_relay_unavailable: guidance(HOST_INSTALL_REPAIR, "install_ceal_host", 503),
3096
+ host_relay_unavailable: guidance(HOST_AUTHENTICATION_UNAVAILABLE, "answer_with_gap", 503),
3090
3097
  host_mint_transient_retryable: guidance(HOST_AUTHENTICATION_UNAVAILABLE, "retry", 503, true),
3091
3098
  host_mint_failed: guidance(HOST_AUTHENTICATION_UNAVAILABLE, "answer_with_gap", 500),
3092
3099
  host_relay_failed: guidance(HOST_INSTALL_REPAIR, "install_ceal_host", 502),
@@ -3124,7 +3131,7 @@ var UNKNOWN_OUTCOMES = vocabulary(["reconcile", "operator_action", "excluded"]);
3124
3131
  var RECOVERY_OWNERS = vocabulary(["gateway", "connector", "operator"]);
3125
3132
  var CEAL_OPERATION_ADMISSION_STATES = vocabulary(["proposed", "refused", "admitted"]);
3126
3133
  var CEAL_OPERATION_EXECUTION_STATES = vocabulary(["not_started", "started", "completed"]);
3127
- var CEAL_OPERATION_PROVIDER_HANDOFF_STATES = vocabulary(["not_offered", "offered", "accepted", "rejected", "unknown"]);
3134
+ var CEAL_OPERATION_PROVIDER_HANDOFF_STATES = vocabulary(["not_applicable", "not_offered", "offered", "accepted", "rejected", "unknown"]);
3128
3135
  var CEAL_OPERATION_EFFECT_STATES = vocabulary(["none", "applied", "failed", "unknown", "compensated"]);
3129
3136
  var CEAL_OPERATION_OBSERVATION_STATES = vocabulary(["not_started", "not_required", "pending", "observed", "unavailable"]);
3130
3137
  var CEAL_OPERATION_RECOVERY_KINDS = vocabulary(["none", "reconcile", "compensate", "operator_action"]);
@@ -3295,6 +3302,7 @@ var CEAL_OPERATION_ACCESS_CLASSES = vocabulary(["read", "write"]);
3295
3302
  // packages/ceal-client-protocol/src/domain-vocabulary.ts
3296
3303
  var CEAL_CONNECTOR_STATUSES = vocabulary(["active", "disabled", "disconnected"]);
3297
3304
  var CEAL_CONNECTOR_CUSTODIES = vocabulary(["organization", "personal"]);
3305
+ var CEAL_PROVIDER_BOUNDARY_FIELDS = vocabulary(["provider_boundary_ref", "provider_boundary_kind", "provider_boundary_label", "provider_native_id", "provider_boundary_evidence"]);
3298
3306
  var CEAL_PERSONAL_ACCESS_CEILINGS = vocabulary(["disabled", "read", "read_write"]);
3299
3307
  var CEAL_TARGET_REF_PATTERN = "^[^\\p{Cc}]+$";
3300
3308
  var TARGET_REF = new RegExp(CEAL_TARGET_REF_PATTERN, "u");
@@ -3340,7 +3348,7 @@ var JSON_DESCRIPTION_CONTROL_CHARACTER = new RegExp("\\p{Cc}", "u");
3340
3348
  var CEAL_OPERATION_AUTHORITY_POLICY_KEYS = Object.freeze(["access_group", "instance_binding", "target", "admission_recheck"]);
3341
3349
  var MAX_OPERATION_INPUT_RESOLVER_BINDINGS = 96;
3342
3350
  var CEAL_OPERATION_DESCRIPTOR_REQUIRED_ENVELOPE_KEYS = Object.freeze(["schema_version", "id", "input_contract", "result_contract", "policy"]);
3343
- var CEAL_OPERATION_DESCRIPTOR_OPTIONAL_ENVELOPE_KEYS = Object.freeze(["input_resolution", "summary"]);
3351
+ var CEAL_OPERATION_DESCRIPTOR_OPTIONAL_ENVELOPE_KEYS = Object.freeze(["input_resolution", "summary", "standard_names"]);
3344
3352
 
3345
3353
  // packages/ceal-client-protocol/src/operation-catalog.ts
3346
3354
  var CEAL_OPERATION_CATALOG_SCHEMA_VERSION = "ceal.catalog.v3";
@@ -3436,6 +3444,7 @@ var CEAL_BOUNDED_SERIES_CATALOG = Object.freeze({
3436
3444
  gateway_access_group_connector_activity_scope_audit: (root) => join(root, "profile-connector-activity-scope-audit.jsonl"),
3437
3445
  gateway_access_group_connector_calendar_scope_audit: (root) => join(root, "profile-connector-calendar-scope-audit.jsonl"),
3438
3446
  gateway_access_group_connector_readiness_audit: (root) => join(root, "profile-connector-readiness.audit.jsonl"),
3447
+ gateway_deployment_events: (root) => join(root, "gateway-deployments.jsonl"),
3439
3448
  gateway_organization_audit_ledger: (root) => join(root, "organization-ledger.jsonl"),
3440
3449
  gateway_personal_client_audit: (root) => join(root, "audit.jsonl"),
3441
3450
  gateway_personal_client_access_audit: (root) => join(root, "access-audit.jsonl")
@@ -3466,6 +3475,11 @@ var CEAL_HOST_INSTALLATION_REF_PATTERN = new RegExp(`^host-installation:${CEAL_L
3466
3475
  var CEAL_HOST_SOURCE_REF_PATTERN = new RegExp(`^host-source:${CEAL_LOWERCASE_UUID_PATTERN}$`, "u");
3467
3476
  var CEAL_HOST_ACCESS_TOKEN_PATTERN = /^ceal_host_[A-Za-z0-9_-]{43}$/u;
3468
3477
 
3478
+ // packages/ceal-client-protocol/src/resource-read-result.ts
3479
+ var CEAL_RESOURCE_GET_NOTION_CONTENT_GAP_KINDS = Object.freeze(["subtree", "media", "property_schema", "properties"]);
3480
+ var CEAL_RESOURCE_SEARCH_PROVIDER_STATUSES = vocabulary(["done", "pending", "deferred"]);
3481
+ var CEAL_RESOURCE_GET_COVERAGE_NEXT_ACTIONS = vocabulary(["reduce_request_size", "read_resource_again"]);
3482
+
3469
3483
  // packages/ceal-client-protocol/src/operation-result-completeness.ts
3470
3484
  var CEAL_READ_VALUE_CONTINUATION_KEYS = vocabulary(["continuation", "continuation_ref", "next_cursor"]);
3471
3485
 
@@ -3553,6 +3567,7 @@ var PROVIDER_LINK_CONFORMANCE_TABLE = Object.freeze([
3553
3567
  { provider: "google-workspace", result_kind: "calendar_event_read_row", field: "source_url", status: "required_when_provider_supplies", provider_shape: "htmlLink", source: "https://developers.google.com/workspace/calendar/api/v3/reference/events" },
3554
3568
  { provider: "google-workspace", result_kind: "drive_document_calendar_write_result", field: "user_openable_url", status: "required_when_provider_supplies", provider_shape: "verified readback webViewLink or htmlLink", source: "https://developers.google.com/workspace/drive/api/reference/rest/v3/files" },
3555
3569
  { provider: "google-workspace", result_kind: "drive_file_write_result", field: "user_openable_url", status: "required_when_provider_supplies", provider_shape: "verified readback webViewLink", source: "https://developers.google.com/workspace/drive/api/reference/rest/v3/files" },
3570
+ { provider: "google-workspace", result_kind: "form_write_result", field: "user_openable_url", status: "required_when_provider_supplies", provider_shape: "verified Forms responderUri", source: "https://developers.google.com/workspace/forms/api/reference/rest/v1/forms" },
3556
3571
  { provider: "google-workspace", result_kind: "spreadsheet_write_result", field: "spreadsheet_url", status: "required_when_provider_supplies", provider_shape: "verified readback webViewLink", source: "https://developers.google.com/workspace/drive/api/reference/rest/v3/files" },
3557
3572
  { provider: "google-workspace", result_kind: "calendar_meet_link_write_result", field: "meet_url", status: "required_when_provider_supplies", provider_shape: "verified conferenceData entryPoint uri", source: "https://developers.google.com/workspace/calendar/api/v3/reference/events" },
3558
3573
  { provider: "google-workspace", result_kind: "gmail_message_read_row", field: "source_url", status: "not_available", reason: "The Gmail API Message representation exposes id and threadId but no human UI URL; cite by title and date.", source: "https://developers.google.com/workspace/gmail/api/reference/rest/v1/users.messages#Message" },
@@ -3722,6 +3737,7 @@ var RESOURCE_ROW_KEY_RULES = Object.freeze({
3722
3737
  created_at: { required: false, timestamp: true },
3723
3738
  created_at_local: { required: false, timestamp: true },
3724
3739
  modified_at: { required: false, timestamp: true },
3740
+ observed_at: { required: false, timestamp: true },
3725
3741
  modified_at_local: { required: false, timestamp: true },
3726
3742
  viewed_by_me_at: { required: false, timestamp: true },
3727
3743
  modified_by_me_at: { required: false, timestamp: true },
@@ -3749,9 +3765,6 @@ var RESOURCE_ROW_REQUIRED_KEYS = Object.entries(RESOURCE_ROW_KEY_RULES).flatMap(
3749
3765
  var RESOURCE_ROW_KEYS = new Set(Object.keys(RESOURCE_ROW_KEY_RULES));
3750
3766
  var RESOURCE_ROW_TIMESTAMP_KEYS = Object.entries(RESOURCE_ROW_KEY_RULES).flatMap(([key, rule]) => rule.timestamp ? [key] : []);
3751
3767
 
3752
- // packages/ceal-client-protocol/src/resource-read-result.ts
3753
- var CEAL_RESOURCE_GET_COVERAGE_NEXT_ACTIONS = vocabulary(["reduce_request_size", "read_resource_again"]);
3754
-
3755
3768
  // packages/ceal-client-protocol/src/excluded-target-coverage.ts
3756
3769
  var CEAL_EXCLUDED_TARGET_COVERAGE_MAX_ENTRIES = 64;
3757
3770
  function cealExcludedTargetCoverageJsonSchema() {
@@ -4059,7 +4072,7 @@ function validateBatchContents(value) {
4059
4072
  if (facts.length === 0 && gaps.length === 0 || facts.length > 0 && value.source_ranges.length === 0) invalid("Ceal Host usage coverage is invalid.");
4060
4073
  const sourceFiles = new Set(value.source_ranges.map((range) => sourceRangeFileRef(range)));
4061
4074
  for (const fact of facts) {
4062
- validateFact(fact, value.host_session_ref);
4075
+ validateCealHostUsageFact(fact, value.host_session_ref);
4063
4076
  if (!sourceFiles.has(fact.source_file_ref)) invalid("Ceal Host usage fact is outside its source ranges.");
4064
4077
  }
4065
4078
  for (const gap of gaps) {
@@ -4092,7 +4105,7 @@ function hostUsageSourceFileReference(producer, hostSourceRef, hostSessionRef, d
4092
4105
  for (const part of [producer, hostSourceRef, hostSessionRef, device, inode]) if (typeof part !== "string" || part.length === 0 || part.length > 512) invalid("Ceal Host usage file identity is invalid.");
4093
4106
  return `host-source-file:${sha256(JSON.stringify({ producer, host_source_ref: hostSourceRef, host_session_ref: hostSessionRef, device, inode }))}`;
4094
4107
  }
4095
- function validateFact(value, sessionRef) {
4108
+ function validateCealHostUsageFact(value, sessionRef) {
4096
4109
  if (!isOperationRecord(value)) invalid("Ceal Host usage fact is invalid.");
4097
4110
  requireFactByteLimit(value);
4098
4111
  if (value.producer === "codex_transcript") validateCodexFact(value);
@@ -4156,7 +4169,7 @@ function validCorrectionSemantics(value) {
4156
4169
  }
4157
4170
  function validateCodexUsageCounts(value) {
4158
4171
  if (!isOperationRecord(value)) invalid("Ceal Codex usage fields are invalid.");
4159
- requireExactOperationKeys(value, ["input_tokens", "cached_input_tokens", "cache_write_input_tokens", "output_tokens", "reasoning_output_tokens", "total_tokens"]);
4172
+ requireExactOperationKeys(value, CEAL_CODEX_USAGE_COUNT_FIELDS);
4160
4173
  for (const key of Object.keys(value)) if (!safeInteger(value[key])) invalid("Ceal Codex usage fields are invalid.");
4161
4174
  if (Number(value.total_tokens) !== Number(value.input_tokens) + Number(value.output_tokens) || Number(value.cached_input_tokens) + Number(value.cache_write_input_tokens) > Number(value.input_tokens) || Number(value.reasoning_output_tokens) > Number(value.output_tokens)) invalid("Ceal Codex usage fields are inconsistent.");
4162
4175
  }
@@ -4424,6 +4437,7 @@ var CEAL_HOST_AUTHENTICATION_CAUSES = vocabulary([
4424
4437
  "options_invalid",
4425
4438
  "session_unavailable",
4426
4439
  "context_unavailable",
4440
+ "activation_wait_exhausted",
4427
4441
  "context_replaced",
4428
4442
  "no_binding",
4429
4443
  "context_expired",
@@ -4459,22 +4473,23 @@ var CEAL_HOST_AUTHENTICATION_POLICY = Object.freeze({
4459
4473
  // This reason cannot distinguish a Codex side conversation from a missing
4460
4474
  // context in a regular session, so guidance must leave that choice to the caller.
4461
4475
  context_unavailable: Object.freeze({ classification: "host_context_unavailable", next_action: "answer_with_gap" }),
4462
- context_replaced: Object.freeze({ classification: "host_invocation_context_stale", next_action: "retry" }),
4476
+ activation_wait_exhausted: Object.freeze({ classification: "host_context_activation_wait_exhausted", next_action: "retry_after" }),
4477
+ context_replaced: Object.freeze({ classification: "host_invocation_context_stale", next_action: "answer_with_gap" }),
4463
4478
  // `no_binding` now means the producer has no real current Host session. The
4464
4479
  // Host Relay never uses it for an uncreated Gateway Request; there is no
4465
4480
  // useful retry until the consumer is running inside a Host session.
4466
4481
  no_binding: Object.freeze({ classification: "host_session_unavailable", next_action: "answer_with_gap" }),
4467
- context_expired: Object.freeze({ classification: "host_invocation_context_expired", next_action: "retry" }),
4482
+ context_expired: Object.freeze({ classification: "host_invocation_context_expired", next_action: "answer_with_gap" }),
4468
4483
  host_source_refused: Object.freeze({ classification: "host_source_refused", next_action: "answer_with_gap" }),
4469
4484
  host_credential_refused: Object.freeze({ classification: "host_registration_credential_refused", next_action: "ask_admin" }),
4470
4485
  gateway_unavailable: Object.freeze({ classification: "host_mint_gateway_unavailable", next_action: "ask_admin" }),
4471
4486
  gateway_rate_limited: Object.freeze({ classification: "host_mint_gateway_rate_limited", next_action: "answer_with_gap" }),
4472
- contract_mismatch: Object.freeze({ classification: "host_relay_unavailable", next_action: "install_ceal_host" }),
4473
- gateway_refused: Object.freeze({ classification: "host_mint_gateway_refused", next_action: "upgrade_ceal_client" }),
4487
+ contract_mismatch: Object.freeze({ classification: "host_contract_mismatch", next_action: "upgrade_ceal_client" }),
4488
+ gateway_refused: Object.freeze({ classification: "host_mint_gateway_refused", next_action: "answer_with_gap" }),
4474
4489
  gateway_response_invalid: Object.freeze({ classification: "host_mint_gateway_response_invalid", next_action: "answer_with_gap" }),
4475
4490
  producer_frame_invalid: Object.freeze({ classification: "host_producer_frame_invalid", next_action: "ask_admin" }),
4476
4491
  relay_permission_denied: Object.freeze({ classification: "host_relay_permission_denied", next_action: "rerun_outside_agent_sandbox" }),
4477
- relay_unavailable: Object.freeze({ classification: "host_relay_unavailable", next_action: "install_ceal_host" }),
4492
+ relay_unavailable: Object.freeze({ classification: "host_relay_unavailable", next_action: "answer_with_gap" }),
4478
4493
  transient_retryable: Object.freeze({ classification: "host_mint_transient_retryable", next_action: "retry" }),
4479
4494
  mint_failed: Object.freeze({ classification: "host_mint_failed", next_action: "answer_with_gap" }),
4480
4495
  relay_failed: Object.freeze({ classification: "host_relay_failed", next_action: "install_ceal_host" }),
@@ -4522,11 +4537,10 @@ function isCealHostServiceDiagnosticCause(value, event) {
4522
4537
  // packages/ceal-client-protocol/src/client-result-materialization.ts
4523
4538
  var CEAL_UNREAD_REASONS = vocabulary(["blocked", "unavailable", "too_large", "unsupported", "download_failed", "permission_denied"]);
4524
4539
  var REQUIRED_FIELDS2 = Object.freeze(["schema_version", "operation_id", "path", "sha256"]);
4525
- var FIELDS = /* @__PURE__ */ new Set([...REQUIRED_FIELDS2, "items_path", "row_count", "result_complete", "coverage", "local_result_root", "model_disclosure", "continue_argv", "how_to_read"]);
4540
+ var FIELDS = /* @__PURE__ */ new Set([...REQUIRED_FIELDS2, "local_result_root", "request_context_argv", "how_to_read"]);
4526
4541
 
4527
4542
  // packages/ceal-client-protocol/src/session-start-affordance.ts
4528
4543
  var CEAL_SESSION_ENTRY_INVOCATION = "ceal";
4529
- var HOST_HOOK_TIMEOUT_SECONDS = 1;
4530
4544
 
4531
4545
  // packages/ceal-client-protocol/src/discovery-manifest.ts
4532
4546
  var DISCOVERY_MANIFEST_KEYS = CEAL_CLIENT_WIRE_CONTRACT.command_response.discovery_manifest_fields;
@@ -4982,7 +4996,7 @@ async function runSecurefsCommand(args, maxBytes, custody, stdin) {
4982
4996
  const executable = custody.securefs_executable ?? resolveInstalledHostExecutable(process.platform);
4983
4997
  const processArgs = [...custody.securefs_args_prefix ?? [], ...args];
4984
4998
  return await new Promise((resolve, reject2) => {
4985
- const child = execFile(executable, processArgs, { encoding: "buffer", timeout: WINDOWS_SECUREFS_TIMEOUT_MS, maxBuffer: maxBytes + WINDOWS_SECUREFS_DIAGNOSTIC_BYTES }, (error, stdout, stderr) => {
4999
+ const child = execFile(executable, processArgs, { encoding: "buffer", windowsHide: true, timeout: WINDOWS_SECUREFS_TIMEOUT_MS, maxBuffer: maxBytes + WINDOWS_SECUREFS_DIAGNOSTIC_BYTES }, (error, stdout, stderr) => {
4986
5000
  const exitCode = error === null ? 0 : typeof error.code === "number" ? error.code : null;
4987
5001
  if (exitCode === null) {
4988
5002
  reject2(new SecureFileCustodyError("unavailable", "The installed Windows Host securefs command could not run."));
@@ -6357,7 +6371,7 @@ var HostUsageFactsUploader = class {
6357
6371
  const registration = await readHostRegistrationAuthority(this.options.registration_state_file, this.options.host_source_ref, this.options.store_options?.platform, this.options.store_options?.secure_file_custody);
6358
6372
  const timeout = AbortSignal.timeout(this.options.timeout_ms ?? 5e3);
6359
6373
  const requestSignal = signal === void 0 ? timeout : AbortSignal.any([signal, timeout]);
6360
- const response2 = await (this.options.fetch ?? fetch)(`${registration.gateway_request_origin}${CEAL_HOST_USAGE_INGRESS_PATH}`, {
6374
+ const response2 = await this.options.fetch(`${registration.gateway_request_origin}${CEAL_HOST_USAGE_INGRESS_PATH}`, {
6361
6375
  method: "POST",
6362
6376
  headers: { authorization: `Bearer ${registration.host_access_token}`, "content-type": "application/json" },
6363
6377
  body: JSON.stringify(candidate.batch),
@@ -6505,7 +6519,7 @@ function createTranscriptWatcherBase(options, owner) {
6505
6519
  outboxRetentionMs: options.retention_ms ?? owner.default_retention_ms,
6506
6520
  now: options.now ?? (() => /* @__PURE__ */ new Date()),
6507
6521
  log: options.log ?? ((line) => {
6508
- process.stderr.write(`${line}
6522
+ writeHostServiceLogLine(`${line}
6509
6523
  `);
6510
6524
  }),
6511
6525
  producerInstallationRef: options.producer_installation_ref
@@ -6545,7 +6559,13 @@ var HostTranscriptWatcher = class {
6545
6559
  }
6546
6560
  async scanRegistration(registration) {
6547
6561
  return this.openTranscript(registration, (handle) => this.scanOpened(handle, registration), {
6548
- missing: () => this.retireMissing(registration),
6562
+ missing: async () => {
6563
+ try {
6564
+ return await this.retireMissing(registration);
6565
+ } catch (error) {
6566
+ return this.scanFailed(void 0, registration, error);
6567
+ }
6568
+ },
6549
6569
  failed: (handle, error) => this.scanFailed(handle, registration, error)
6550
6570
  });
6551
6571
  }
@@ -6821,6 +6841,7 @@ var HOST_RELAY_IPC_LENGTH_BYTES = Uint32Array.BYTES_PER_ELEMENT;
6821
6841
  // host/claude/src/claude-types.ts
6822
6842
  var CLAUDE_HOOK_EVENTS = ["SessionStart", "UserPromptSubmit"];
6823
6843
  var CLAUDE_PRIOR_HOOK_EVENTS = ["SessionStart", "UserPromptSubmit", "Stop", "StopFailure"];
6844
+ var CLAUDE_SESSION_ID_ENVIRONMENT = "CLAUDE_CODE_SESSION_ID";
6824
6845
  var CLAUDE_HOST_ERROR_CODES = ["invalid_input", "payload_rejected", "storage", "configuration"];
6825
6846
  function isClaudeHostErrorCode(value) {
6826
6847
  return typeof value === "string" && CLAUDE_HOST_ERROR_CODES.some((code2) => code2 === value);
@@ -7410,11 +7431,13 @@ var ClaudeTranscriptWatcher = class extends HostTranscriptWatcher {
7410
7431
  }
7411
7432
  async scanOpened(handle, registration) {
7412
7433
  const { size, device, inode } = await ownedClaudeTranscriptFile(handle);
7413
- const cursor = await this.preflight(registration, handle, size, device, inode);
7434
+ const preflight = await this.preflight(registration, handle, size, device, inode);
7435
+ const cursor = preflight.cursor;
7414
7436
  if (cursor === null) return { records: 0, enqueued: 0, quarantined: true };
7415
7437
  if (cursor.status === "quarantined") {
7416
7438
  return { records: 0, enqueued: 0, quarantined: true };
7417
7439
  }
7440
+ if (preflight.checkpointPending) await this.store.writeTranscriptCursor({ ...cursor, updated_at: this.stamp() });
7418
7441
  const draft = mutableCursor(cursor);
7419
7442
  await this.scanOpenedTranscript(registration, handle, draft, size, device, inode);
7420
7443
  return { records: draft.consumed, enqueued: draft.enqueued, quarantined: false };
@@ -7427,6 +7450,15 @@ var ClaudeTranscriptWatcher = class extends HostTranscriptWatcher {
7427
7450
  return { records: 0, enqueued: 0, quarantined: true };
7428
7451
  }
7429
7452
  async retireMissing(registration) {
7453
+ const observedAt = this.stamp();
7454
+ if (Date.parse(registration.expires_at) <= Date.parse(observedAt)) return this.retireTranscript(registration);
7455
+ const cursor = await this.store.readTranscriptCursor(registration);
7456
+ if (cursor !== null && isUnmaterializedCursor(cursor, this.sha(Buffer.alloc(0)))) {
7457
+ return { records: 0, enqueued: 0, quarantined: false };
7458
+ }
7459
+ return this.retireTranscript(registration);
7460
+ }
7461
+ retireTranscript(registration) {
7430
7462
  return this.retireMissingTranscript(registration.transcript_path, "Claude", () => this.store.retireTranscriptRegistration(registration));
7431
7463
  }
7432
7464
  initialCursor(registration) {
@@ -7456,16 +7488,18 @@ var ClaudeTranscriptWatcher = class extends HostTranscriptWatcher {
7456
7488
  }
7457
7489
  async preflight(registration, handle, size, device, inode) {
7458
7490
  const existing = await this.store.readTranscriptCursor(registration);
7459
- if (existing?.status === "quarantined") return existing;
7491
+ if (existing?.status === "quarantined") return { cursor: existing, checkpointPending: false };
7460
7492
  const cursor = existing ?? this.initialCursor(registration);
7461
7493
  if (cursor.device === void 0) {
7462
- if (cursor.offset !== 0) return await this.quarantineStored(cursor, device, inode, "transcript_replaced");
7463
- return { ...cursor, device, inode, human_message_window: cursor.human_message_window ?? { messages: [], truncated: false } };
7494
+ const pinned = { ...cursor, device, inode, human_message_window: cursor.human_message_window ?? { messages: [], truncated: false } };
7495
+ const reason2 = this.cursorIdentityReason(pinned, registration.transcript_path, device, inode);
7496
+ if (cursor.offset !== 0 || reason2 !== null) return { cursor: await this.quarantineStored(cursor, device, inode, "transcript_replaced"), checkpointPending: false };
7497
+ return { cursor: pinned, checkpointPending: true };
7464
7498
  }
7465
7499
  const reason = this.cursorIdentityReason(cursor, registration.transcript_path, device, inode) ?? await this.cursorBoundsReason(handle, cursor, size);
7466
- if (reason !== null) return await this.quarantineStored(cursor, device, inode, reason);
7467
- if (cursor.human_message_window !== void 0) return cursor;
7468
- return { ...cursor, human_message_window: await this.readHumanMessageProjection(registration, handle, cursor.offset) };
7500
+ if (reason !== null) return { cursor: await this.quarantineStored(cursor, device, inode, reason), checkpointPending: false };
7501
+ if (cursor.human_message_window !== void 0) return { cursor, checkpointPending: false };
7502
+ return { cursor: { ...cursor, human_message_window: await this.readHumanMessageProjection(registration, handle, cursor.offset) }, checkpointPending: true };
7469
7503
  }
7470
7504
  async readHumanMessageProjection(registration, handle, watermark) {
7471
7505
  let offset = 0;
@@ -7762,6 +7796,9 @@ var ClaudeTranscriptWatcher = class extends HostTranscriptWatcher {
7762
7796
  return await this.store.readTranscriptCursor(registration).catch(() => null) ?? this.initialCursor(registration);
7763
7797
  }
7764
7798
  };
7799
+ function isUnmaterializedCursor(cursor, emptyAnchorSha256) {
7800
+ return cursor.status === "active" && cursor.device === void 0 && cursor.inode === void 0 && cursor.offset === 0 && cursor.anchor_start === 0 && cursor.anchor_sha256 === emptyAnchorSha256;
7801
+ }
7765
7802
  function mutableCursor(cursor) {
7766
7803
  return {
7767
7804
  offset: cursor.offset,
@@ -8297,9 +8334,9 @@ var CLAUDE_PRODUCER_DESCRIPTOR = {
8297
8334
  config: (shared, extras) => ({ ...shared, claude_transcripts_root: hostProducerExtraPath(extras, CLAUDE_TRANSCRIPTS_ROOT) }),
8298
8335
  runtime_options: (config) => Object.freeze({ outbox_dir: config.outbox_dir }),
8299
8336
  drain: drainClaudeProducerOnce,
8300
- background: (config, signal) => {
8337
+ background: (config, signal, dependencies) => {
8301
8338
  const capturer = new ClaudeUsageFactsCapturer({ outbox_dir: config.outbox_dir });
8302
- return runHostUsageFactsUploader({ producer: "claude", outbox_dir: config.outbox_dir, host_source_ref: config.host_source_ref, registration_state_file: hostProducerRegistrationStateFile(config.outbox_dir), capture_next: () => capturer.captureNext() }, signal);
8339
+ return runHostUsageFactsUploader({ producer: "claude", outbox_dir: config.outbox_dir, host_source_ref: config.host_source_ref, registration_state_file: hostProducerRegistrationStateFile(config.outbox_dir), capture_next: () => capturer.captureNext(), fetch: dependencies.fetch }, signal);
8303
8340
  }
8304
8341
  };
8305
8342
 
@@ -9139,9 +9176,9 @@ var CodexTranscriptWatcher = class extends HostTranscriptWatcher {
9139
9176
  const { size, device, inode } = await ownedCodexTranscriptFile(handle);
9140
9177
  const preflight = await this.preflight(registration, handle, size, device, inode);
9141
9178
  if (preflight.cursor === null) return preflight.result;
9179
+ if (preflight.checkpointPending) await this.commitCursor(registration, handle, preflight.cursor, 0, device, inode, preflight.cursor.last_ordinal, preflight.cursor.active_task, preflight.cursor.human_message_window ?? { messages: [], truncated: false });
9142
9180
  const complete = await this.readChunk(handle, preflight.cursor.offset, size);
9143
9181
  if (complete === "empty" || complete === "partial") {
9144
- if (preflight.projectionInitialized) await this.commitCursor(registration, handle, preflight.cursor, 0, device, inode, preflight.cursor.last_ordinal, preflight.cursor.active_task, preflight.cursor.human_message_window ?? { messages: [], truncated: false });
9145
9182
  return { records: 0, enqueued: 0, quarantined: false };
9146
9183
  }
9147
9184
  return await this.consumeCompleteChunk(registration, handle, preflight.cursor, complete, device, inode);
@@ -9158,17 +9195,17 @@ var CodexTranscriptWatcher = class extends HostTranscriptWatcher {
9158
9195
  const existing = await this.store.readTranscriptCursor(registration);
9159
9196
  let cursor = existing ?? codexTranscriptInitialCursor(registration, device, inode, this.now);
9160
9197
  if (cursor.status === "quarantined") {
9161
- return { cursor: null, projectionInitialized: false, result: { records: 0, enqueued: 0, quarantined: true } };
9198
+ return { cursor: null, checkpointPending: false, result: { records: 0, enqueued: 0, quarantined: true } };
9162
9199
  }
9163
9200
  const reason = this.cursorIdentityReason(cursor, registration.transcript_path, device, inode) ?? await this.cursorBoundsReason(handle, cursor, size);
9164
9201
  if (reason === null) {
9165
- if (cursor.human_message_window !== void 0) return { cursor, projectionInitialized: false, result: { records: 0, enqueued: 0, quarantined: false } };
9202
+ if (cursor.human_message_window !== void 0) return { cursor, checkpointPending: existing === null, result: { records: 0, enqueued: 0, quarantined: false } };
9166
9203
  const humanWindow = await this.readHumanMessageProjection(handle, registration, cursor);
9167
- return { cursor: { ...cursor, human_message_window: humanWindow }, projectionInitialized: existing !== null, result: { records: 0, enqueued: 0, quarantined: false } };
9204
+ return { cursor: { ...cursor, human_message_window: humanWindow }, checkpointPending: true, result: { records: 0, enqueued: 0, quarantined: false } };
9168
9205
  }
9169
9206
  await this.quarantine(registration, cursor, device, inode, reason);
9170
9207
  this.diagnostic("watcher_scan_failed", "other", `cursor_${reason}`);
9171
- return { cursor: null, projectionInitialized: false, result: { records: 0, enqueued: 0, quarantined: true } };
9208
+ return { cursor: null, checkpointPending: false, result: { records: 0, enqueued: 0, quarantined: true } };
9172
9209
  }
9173
9210
  async readHumanMessageProjection(handle, registration, cursor) {
9174
9211
  return readCodexHumanMessageProjection(registration, cursor, (offset, size) => this.readChunk(handle, offset, size));
@@ -9662,12 +9699,11 @@ function normalizedCounts(selected) {
9662
9699
  function nullCounts() {
9663
9700
  return { input: null, output: null, total: null, cached_input: null, cache_write_input: null, reasoning_output: null };
9664
9701
  }
9665
- var USAGE_COUNT_FIELDS = ["input_tokens", "cached_input_tokens", "cache_write_input_tokens", "output_tokens", "reasoning_output_tokens", "total_tokens"];
9666
9702
  function isRegression(current, previous) {
9667
- return USAGE_COUNT_FIELDS.some((key) => current[key] < previous[key]);
9703
+ return CEAL_CODEX_USAGE_COUNT_FIELDS.some((key) => current[key] < previous[key]);
9668
9704
  }
9669
9705
  function sameCounts(left, right) {
9670
- return USAGE_COUNT_FIELDS.every((key) => left[key] === right[key]);
9706
+ return CEAL_CODEX_USAGE_COUNT_FIELDS.every((key) => left[key] === right[key]);
9671
9707
  }
9672
9708
  function buildCoverageGaps(sourceFileRef2, startOffset, endOffset, counts) {
9673
9709
  return [...counts].map(([reason, omittedCount]) => coverageGap(reason, sourceFileRef2, startOffset, endOffset, omittedCount));
@@ -9716,9 +9752,9 @@ var CODEX_PRODUCER_DESCRIPTOR = {
9716
9752
  config: (shared, extras) => ({ ...shared, codex_sessions_root: hostProducerExtraPath(extras, CODEX_SESSIONS_ROOT) }),
9717
9753
  runtime_options: (config) => Object.freeze({ outbox_dir: config.outbox_dir }),
9718
9754
  drain: drainCodexProducerOnce,
9719
- background: (config, signal) => {
9755
+ background: (config, signal, dependencies) => {
9720
9756
  const capturer = new CodexUsageFactsCapturer({ outbox_dir: config.outbox_dir });
9721
- return runHostUsageFactsUploader({ producer: "codex", outbox_dir: config.outbox_dir, host_source_ref: config.host_source_ref, registration_state_file: hostProducerRegistrationStateFile(config.outbox_dir), capture_next: () => capturer.captureNext() }, signal);
9757
+ return runHostUsageFactsUploader({ producer: "codex", outbox_dir: config.outbox_dir, host_source_ref: config.host_source_ref, registration_state_file: hostProducerRegistrationStateFile(config.outbox_dir), capture_next: () => capturer.captureNext(), fetch: dependencies.fetch }, signal);
9722
9758
  }
9723
9759
  };
9724
9760
 
@@ -9948,6 +9984,7 @@ var HOST_BUNDLE_COMPONENTS = Object.freeze(["lifecycle", "relay", "codex", "clau
9948
9984
  var HOST_BUNDLE_PRODUCERS = Object.freeze(["codex", "claude"]);
9949
9985
  var HOST_RUNTIME_COMPONENTS = Object.freeze(["relay", "codex", "claude"]);
9950
9986
  var HOST_BUNDLE_PRIVATE_RUNTIME_ROOT = "libexec/ceal-host";
9987
+ var HOST_WINDOWS_BACKGROUND_RELATIVE_PATH = `${HOST_BUNDLE_PRIVATE_RUNTIME_ROOT}/ceal-host-background.exe`;
9951
9988
  var HOST_BUNDLE_FILE_KEYS = Object.freeze(["executable", "owners", "path", "sha256"]);
9952
9989
  var HOST_BUNDLE_SUPPORTED_REQUIRED_FEATURES = Object.freeze([]);
9953
9990
  var HOST_BUNDLE_REFERENCE_STATUS = Object.freeze({ authority: "non_authoritative", transaction: "incomplete" });
@@ -10588,26 +10625,31 @@ function renderLauncher(targets, platform) {
10588
10625
  "setlocal DisableDelayedExpansion",
10589
10626
  `set "CEAL_RUNTIME=${batchLiteral(targets.runtime)}"`,
10590
10627
  `set "CEAL_SERVICES=${batchLiteral(targets.services)}"`,
10591
- 'if "%~1"=="" exit /b 64',
10592
- 'if not "%~1"=="%~nx1" exit /b 64',
10628
+ 'if "%~1"=="" goto ceal_refuse_arguments',
10629
+ 'if not "%~1"=="%~nx1" goto ceal_refuse_arguments',
10593
10630
  'set "CEAL_MODULE=%~1"',
10631
+ 'if "%~2"=="" goto ceal_refuse_arguments',
10632
+ 'set "CEAL_FLAG="',
10633
+ 'set "CEAL_CONFIG="',
10594
10634
  'for /f "tokens=1,* delims==" %%A in ("%~2") do (',
10595
10635
  ' set "CEAL_FLAG=%%A"',
10596
10636
  ' set "CEAL_CONFIG=%%B"',
10597
10637
  ")",
10598
- 'if /i not "%CEAL_FLAG%"=="--ceal-host-config" exit /b 64',
10599
- 'if "%CEAL_CONFIG%"=="" exit /b 64',
10600
- 'for %%A in ("%CEAL_CONFIG%") do if not "%%~nxA"=="%CEAL_CONFIG%" exit /b 64',
10638
+ 'if /i not "%CEAL_FLAG%"=="--ceal-host-config" goto ceal_refuse_arguments',
10639
+ 'if "%CEAL_CONFIG%"=="" goto ceal_refuse_arguments',
10640
+ 'for %%A in ("%CEAL_CONFIG%") do if not "%%~nxA"=="%CEAL_CONFIG%" goto ceal_refuse_arguments',
10601
10641
  'set "CEAL_FORWARD="',
10602
10642
  ":ceal_forward_arguments",
10603
10643
  'if "%~3"=="" goto ceal_launch',
10604
10644
  'set "CEAL_ARGUMENT=%~3"',
10645
+ "if not defined SystemRoot goto ceal_refuse_validator",
10646
+ 'if not exist "%SystemRoot%\\System32\\findstr.exe" goto ceal_refuse_validator',
10605
10647
  "setlocal EnableDelayedExpansion",
10606
- `echo(!CEAL_ARGUMENT!|findstr /r /c:"${WINDOWS_FIXED_CMD_ARGUMENT_REFUSAL_PATTERN}" >nul`,
10607
- "if errorlevel 2 exit /b 64",
10608
- "if not errorlevel 1 exit /b 64",
10648
+ `echo(!CEAL_ARGUMENT!|"%SystemRoot%\\System32\\findstr.exe" /r /c:"${WINDOWS_FIXED_CMD_ARGUMENT_REFUSAL_PATTERN}" >nul 2>nul`,
10649
+ "if errorlevel 2 goto ceal_refuse_validator",
10650
+ "if not errorlevel 1 goto ceal_refuse_arguments",
10609
10651
  "endlocal",
10610
- 'if not "%CEAL_ARGUMENT:!=%"=="%CEAL_ARGUMENT%" exit /b 64',
10652
+ 'if not "%CEAL_ARGUMENT:!=%"=="%CEAL_ARGUMENT%" goto ceal_refuse_arguments',
10611
10653
  'call :ceal_append_argument "%~3"',
10612
10654
  "shift",
10613
10655
  "goto ceal_forward_arguments",
@@ -10617,6 +10659,12 @@ function renderLauncher(targets, platform) {
10617
10659
  ":ceal_launch",
10618
10660
  '"%CEAL_RUNTIME%\\node\\bin\\node.exe" "%CEAL_RUNTIME%\\%CEAL_MODULE%" "%CEAL_FLAG%=%CEAL_SERVICES%\\%CEAL_CONFIG%" %CEAL_FORWARD%',
10619
10661
  "exit /b %ERRORLEVEL%",
10662
+ ":ceal_refuse_arguments",
10663
+ "echo ceal_host_entry_launcher_refused:invalid_arguments 1>&2",
10664
+ "exit /b 64",
10665
+ ":ceal_refuse_validator",
10666
+ "echo ceal_host_entry_launcher_refused:validator_unavailable 1>&2",
10667
+ "exit /b 64",
10620
10668
  ""
10621
10669
  ].join("\r\n");
10622
10670
  }
@@ -10964,7 +11012,7 @@ function resolveClaudeConfigHome(environment, home) {
10964
11012
  // host/claude/src/claude-installer.ts
10965
11013
  var OWNER = "ceal-claude-host-observation-v1";
10966
11014
  var ACTIVE_CLAUDE_HOOK_EVENTS = new Set(CLAUDE_HOOK_EVENTS);
10967
- var CLAUDE_LOCAL_CAPABILITY_ACTIVATION = Object.freeze({ environment: "CLAUDE_CODE_ENTRYPOINT", value: "cli" });
11015
+ var CLAUDE_LOCAL_CAPABILITY_ACTIVATION = Object.freeze({ environment: CLAUDE_SESSION_ID_ENVIRONMENT, value: Object.freeze({ environment: CLAUDE_SESSION_ID_ENVIRONMENT }) });
10968
11016
  var CLAUDE_CLIENT_ALLOW_RULE = `Bash(${CEAL_SESSION_ENTRY_INVOCATION}:*)`;
10969
11017
  var PERMISSION_OWNERSHIP_SCHEMA = "ceal.claude_permission_ownership.v1";
10970
11018
  function resolveClaudeSettingsPath(claudeHome, environment = process.env) {
@@ -11135,7 +11183,9 @@ function removeOwnedHooks(settings) {
11135
11183
  return Object.keys(nextHooks).length === 0 ? withoutKey(settings, "hooks") : { ...settings, hooks: nextHooks };
11136
11184
  }
11137
11185
  function managedEntry(command, event) {
11138
- return { hooks: [{ type: "command", command: formatHostCommand({ ...command, args: [...command.args, `--ceal-hook-owner=${OWNER}`, `--ceal-hook-event=${event}`] }, process.platform === "win32" ? "windows" : "posix"), timeout: HOST_HOOK_TIMEOUT_SECONDS }] };
11186
+ const args = [...command.args, `--ceal-hook-owner=${OWNER}`, `--ceal-hook-event=${event}`];
11187
+ if (process.platform === "win32" && command.executable.toLowerCase().endsWith(".cmd")) return { hooks: [{ type: "command", command: formatWindowsPowerShellCmdScriptCommand(command.executable, args), shell: "powershell" }] };
11188
+ return { hooks: [{ type: "command", command: formatHostCommand({ ...command, args }, process.platform === "win32" ? "windows" : "posix") }] };
11139
11189
  }
11140
11190
  function ownedEntries(settings, event, command) {
11141
11191
  return eventEntries(hooksRecord(settings), event).filter((entry) => JSON.stringify(entry) === JSON.stringify(managedEntry(command, event)));
@@ -11213,7 +11263,9 @@ function validateOptions(options) {
11213
11263
  const settingsPath = options.settings_path ?? resolveClaudeSettingsPath(options.claude_home);
11214
11264
  if (!isAbsolute7(settingsPath) || !isAbsolute7(options.permission_ownership_path) || !isAbsolute7(options.hook_executable) || options.hook_executable.includes("\0") || options.hook_executable.includes("\n") || options.hook_executable.includes('"')) throw new ClaudeHostError("configuration", "Claude installer paths must be absolute and shell-safe.");
11215
11265
  try {
11216
- validateHostCommandVector(resolveHookCommand(options));
11266
+ const command = resolveHookCommand(options);
11267
+ validateHostCommandVector(command);
11268
+ managedEntry(command, "SessionStart");
11217
11269
  } catch (error) {
11218
11270
  throw new ClaudeHostError("configuration", `Claude hook command vector is invalid or unsafe: ${refusalFact("error", error)}.`);
11219
11271
  }
@@ -11658,7 +11710,7 @@ function normalizeHookGroups(entries) {
11658
11710
  return groups;
11659
11711
  }
11660
11712
  function ownedHookEntry(command, event) {
11661
- return { type: "command", command: hookCommand(command, event, "posix"), commandWindows: hookCommand(command, event, "windows"), timeout: HOST_HOOK_TIMEOUT_SECONDS, async: false };
11713
+ return { type: "command", command: hookCommand(command, event, "posix"), commandWindows: hookCommand(command, event, "windows"), async: false };
11662
11714
  }
11663
11715
  function mergeOwnedHooks2(config, command) {
11664
11716
  const hooks = isRecord10(config.hooks) ? { ...config.hooks } : {};
@@ -12790,7 +12842,7 @@ function createWindowsHostRuntimeServiceAdapter(input) {
12790
12842
  schema_version: WINDOWS_SERVICE_REQUEST_SCHEMA,
12791
12843
  operation: "reconcile",
12792
12844
  prefix: target.prefix,
12793
- target_services: target.services.map((service) => wireService(service, logDirectory))
12845
+ target_services: target.services.map((service) => wireService(target.prefix, service, logDirectory))
12794
12846
  });
12795
12847
  },
12796
12848
  async restart({ target, service }) {
@@ -12805,7 +12857,7 @@ function createWindowsHostRuntimeServiceAdapter(input) {
12805
12857
  schema_version: WINDOWS_SERVICE_REQUEST_SCHEMA,
12806
12858
  operation: "restart",
12807
12859
  prefix: target.prefix,
12808
- service: wireService(service, logDirectory)
12860
+ service: wireService(target.prefix, service, logDirectory)
12809
12861
  });
12810
12862
  },
12811
12863
  async quiesce({ previous }) {
@@ -12815,7 +12867,7 @@ function createWindowsHostRuntimeServiceAdapter(input) {
12815
12867
  schema_version: WINDOWS_SERVICE_REQUEST_SCHEMA,
12816
12868
  operation: "quiesce",
12817
12869
  prefix: previous.prefix,
12818
- target_services: previous.services.map((service) => wireService(service, logDirectory))
12870
+ target_services: previous.services.map((service) => wireService(previous.prefix, service, logDirectory))
12819
12871
  });
12820
12872
  },
12821
12873
  async inspect({ target, timeout_ms }) {
@@ -12824,7 +12876,7 @@ function createWindowsHostRuntimeServiceAdapter(input) {
12824
12876
  schema_version: WINDOWS_SERVICE_REQUEST_SCHEMA,
12825
12877
  operation: "inspect",
12826
12878
  prefix: target.prefix,
12827
- target_services: target.services.map((service) => wireService(service, logDirectory))
12879
+ target_services: target.services.map((service) => wireService(target.prefix, service, logDirectory))
12828
12880
  }, timeout_ms);
12829
12881
  return parseObservations(result, target);
12830
12882
  },
@@ -12848,24 +12900,26 @@ function resolveWindowsPowerShell(windowsDirectory) {
12848
12900
  }
12849
12901
  return win3211.join(windowsDirectory, "System32", "WindowsPowerShell", "v1.0", "powershell.exe");
12850
12902
  }
12851
- function wireService(service, logDirectory) {
12852
- validateWindowsService(service);
12903
+ function wireService(prefix, service, logDirectory) {
12904
+ validateWindowsService(prefix, service);
12853
12905
  const argumentsWithLog = logDirectory === void 0 ? [...service.command.args] : [...service.command.args, HOST_SERVICE_LOG_ARGUMENT, hostServiceLogPath(win3211, logDirectory, service.component)];
12854
12906
  return {
12855
12907
  component: service.component,
12856
- executable: service.command.executable,
12908
+ executable: win3211.join(prefix, ...HOST_WINDOWS_BACKGROUND_RELATIVE_PATH.split("/")),
12857
12909
  // Task Scheduler ExecAction launches the executable directly, never
12858
12910
  // through cmd.exe, so `%` and `!` in user paths stay literal here.
12859
- arguments: argumentsWithLog.map(quoteWindowsExecArgument).join(" ")
12911
+ arguments: [service.command.executable, ...argumentsWithLog].map(quoteWindowsExecArgument).join(" ")
12860
12912
  };
12861
12913
  }
12862
- function validateWindowsService(service) {
12914
+ function validateWindowsService(prefix, service) {
12863
12915
  try {
12864
12916
  validateHostCommandVector(service.command, "direct-exec");
12865
12917
  } catch (error) {
12866
12918
  throw invalidServiceSet(`Windows service command vectors must satisfy the Host command contract: ${refusalFact("error", error)}.`);
12867
12919
  }
12868
12920
  if (!win3211.isAbsolute(service.command.executable) || win3211.normalize(service.command.executable) !== service.command.executable) throw invalidServiceSet("Windows service executables must be absolute normalized paths.");
12921
+ const expectedNode = win3211.join(prefix, ...HOST_BUNDLE_PRIVATE_RUNTIME_ROOT.split("/"), "node", "bin", "node.exe");
12922
+ if (service.command.executable.toLowerCase() !== expectedNode.toLowerCase()) throw invalidServiceSet("Windows services must use the installation's exact private Node executable.");
12869
12923
  }
12870
12924
  function assertWindowsServiceSets(previous, target) {
12871
12925
  assertWindowsServiceSet(previous);
@@ -12877,7 +12931,7 @@ function assertWindowsServiceSet(set) {
12877
12931
  if (new Set(set.services.map(({ component }) => component)).size !== set.services.length) throw invalidServiceSet("Windows service sets cannot contain duplicate components.");
12878
12932
  for (const service of set.services) {
12879
12933
  if (!HOST_RUNTIME_SERVICE_COMPONENTS.includes(service.component)) throw invalidServiceSet("Windows service sets contain an unsupported component.");
12880
- validateWindowsService(service);
12934
+ validateWindowsService(set.prefix, service);
12881
12935
  }
12882
12936
  }
12883
12937
  async function invoke(runner, powershell, request2, timeout_ms = HOST_RUNTIME_SERVICE_COMMAND_TIMEOUT_MS) {