@corca-org/ceal-host-win32-x64 1.0.22 → 1.0.24
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.
- package/bin/ceal-host.exe +0 -0
- package/libexec/ceal-host/ceal-host-background.exe +0 -0
- package/libexec/ceal-host/claude-hook.mjs +682 -331
- package/libexec/ceal-host/claude-invocation-authentication.mjs +730 -349
- package/libexec/ceal-host/claude-producer.mjs +472 -125
- package/libexec/ceal-host/codex-hook.mjs +604 -317
- package/libexec/ceal-host/codex-invocation-authentication.mjs +653 -333
- package/libexec/ceal-host/codex-producer.mjs +396 -109
- package/libexec/ceal-host/control.mjs +589 -206
- package/libexec/ceal-host/relay.mjs +113 -61
- package/package.json +1 -1
- package/share/ceal-host/bundle-manifest.json +22 -12
- package/share/ceal-host/bundle-manifest.sigstore.json +1 -1
|
@@ -56,6 +56,15 @@ function assertHostProducerSourcePaths(stateRoot, config, producer, platform = p
|
|
|
56
56
|
import { constants as constants2 } from "node:fs";
|
|
57
57
|
import { lstat as lstat2 } from "node:fs/promises";
|
|
58
58
|
|
|
59
|
+
// packages/ceal-client-protocol/src/vocabulary.ts
|
|
60
|
+
function vocabulary(words) {
|
|
61
|
+
return Object.freeze(words);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// packages/ceal-client-protocol/src/host-usage-fields.ts
|
|
65
|
+
var CEAL_CODEX_USAGE_COUNT_FIELDS = vocabulary(["input_tokens", "cached_input_tokens", "cache_write_input_tokens", "output_tokens", "reasoning_output_tokens", "total_tokens"]);
|
|
66
|
+
var CEAL_CLAUDE_USAGE_COUNT_FIELDS = vocabulary(["input_tokens", "cache_read_input_tokens", "cache_creation_input_tokens", "output_tokens"]);
|
|
67
|
+
|
|
59
68
|
// packages/ceal-client-protocol/src/canonical-json.ts
|
|
60
69
|
function cealCanonicalJson(value) {
|
|
61
70
|
if (value === null || typeof value === "string" || typeof value === "boolean") return JSON.stringify(value);
|
|
@@ -130,7 +139,7 @@ var client_wire_contract_default = {
|
|
|
130
139
|
},
|
|
131
140
|
command_request: {
|
|
132
141
|
schema_name: "ceal.command_request",
|
|
133
|
-
fields: ["schema_version", "argv", "operation", "client_nonce", "context_token", "request_context"],
|
|
142
|
+
fields: ["schema_version", "argv", "operation", "client_nonce", "context_token", "request_context", "materialize_result"],
|
|
134
143
|
absolute_transport_max_bytes: 65536
|
|
135
144
|
},
|
|
136
145
|
command_resolution: {
|
|
@@ -176,7 +185,7 @@ var client_wire_contract_default = {
|
|
|
176
185
|
},
|
|
177
186
|
command_response: {
|
|
178
187
|
schema_name: "ceal.command_response",
|
|
179
|
-
fields: ["schema_version", "exit_code", "document", "operation_id", "visible_output_max_bytes", "local_delivery", "verified_artifact", "request_context"],
|
|
188
|
+
fields: ["schema_version", "exit_code", "document", "operation_id", "visible_output_max_bytes", "local_delivery", "verified_artifact", "request_context", "result_file"],
|
|
180
189
|
descriptor_field: "verified_artifact",
|
|
181
190
|
request_context_field: "request_context",
|
|
182
191
|
required_fields: [
|
|
@@ -189,7 +198,8 @@ var client_wire_contract_default = {
|
|
|
189
198
|
"visible_output_max_bytes",
|
|
190
199
|
"local_delivery",
|
|
191
200
|
"verified_artifact",
|
|
192
|
-
"request_context"
|
|
201
|
+
"request_context",
|
|
202
|
+
"result_file"
|
|
193
203
|
],
|
|
194
204
|
bare_document_fields: [
|
|
195
205
|
"invocation",
|
|
@@ -230,8 +240,11 @@ var client_wire_contract_default = {
|
|
|
230
240
|
"ok",
|
|
231
241
|
"code",
|
|
232
242
|
"reason",
|
|
233
|
-
"gateway_status"
|
|
243
|
+
"gateway_status",
|
|
244
|
+
"retry_after_ms"
|
|
234
245
|
],
|
|
246
|
+
refusal_required_fields: ["schema_version", "ok", "code", "reason"],
|
|
247
|
+
refusal_optional_fields: ["gateway_status", "retry_after_ms"],
|
|
235
248
|
client_nonce: {
|
|
236
249
|
character_class_source: "A-Za-z0-9_-",
|
|
237
250
|
encoded_characters: 43
|
|
@@ -450,16 +463,14 @@ var CEAL_OPERATION_WITHHELD_NEXT_ACTIONS = Object.freeze({
|
|
|
450
463
|
personal_authorization_required: "connect_personal_account"
|
|
451
464
|
});
|
|
452
465
|
|
|
453
|
-
// packages/ceal-client-protocol/src/vocabulary.ts
|
|
454
|
-
function vocabulary(words) {
|
|
455
|
-
return Object.freeze(words);
|
|
456
|
-
}
|
|
457
|
-
|
|
458
466
|
// packages/ceal-client-protocol/src/gateway-response-types.ts
|
|
459
467
|
var CEAL_OPERATION_READINESS_VALUES = vocabulary(["ready", "degraded", "unavailable", "unknown"]);
|
|
460
468
|
var CEAL_TARGET_REQUIREMENTS = vocabulary(["required", "optional", "none"]);
|
|
461
469
|
var CEAL_AUDIT_OUTCOMES = vocabulary(["succeeded", "denied", "failed"]);
|
|
462
470
|
var CEAL_GATEWAY_PROVIDER_STEP_OUTCOMES = vocabulary(["completed", "rejected", "throttled", "failed"]);
|
|
471
|
+
var CEAL_GATEWAY_CORPUS_READ_PROVIDERS = vocabulary(["slack", "google_drive", "notion"]);
|
|
472
|
+
var CEAL_GATEWAY_CORPUS_READ_OUTCOMES = vocabulary(["answered_from_corpus", "live_fallback"]);
|
|
473
|
+
var CEAL_GATEWAY_CORPUS_READ_FALLBACK_REASONS = vocabulary(["uncovered_window", "stale", "not_organization_public", "partition_missing"]);
|
|
463
474
|
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"]);
|
|
464
475
|
var CEAL_GATEWAY_READ_REUSE_UNAVAILABLE_REASONS = vocabulary(["not_reported", "storage_unavailable", "coverage_incomplete", "freshness_refresh_required", "not_reusable", "bypassed"]);
|
|
465
476
|
var CEAL_GATEWAY_DERIVED_STORE_FAILURE_CLASSES = vocabulary(["storage_unavailable", "decode_mismatch", "write_conflict", "quota", "store_error"]);
|
|
@@ -500,6 +511,21 @@ var CEAL_GATEWAY_ORGANIZATION_ROUTE_FACT_CALL_KEYS = Object.freeze([
|
|
|
500
511
|
]);
|
|
501
512
|
|
|
502
513
|
// packages/ceal-client-protocol/src/gateway-validation-primitives.ts
|
|
514
|
+
var POSIX_HOME_ROOTS = [["/", "home"].join(""), ["/", "Users"].join("")];
|
|
515
|
+
var WINDOWS_HOME_ROOT = ["C:", "\\", "Users"].join("");
|
|
516
|
+
var USER_SEGMENT_BODY = "[^/\\\\ \\t\\r\\n\"'`${}]+";
|
|
517
|
+
var POSIX_SEGMENT_END = "(?:/|$|(?=[\\s\"'`]))";
|
|
518
|
+
var WINDOWS_SEGMENT_END = "(?:\\\\+|$|(?=[\\s\"'`]))";
|
|
519
|
+
var WINDOWS_USER_SEGMENT_BODY = "[^\\\\ \\t\\r\\n\"'`${}]+";
|
|
520
|
+
var ABSOLUTE_PATH_BOUNDARY = "(?<![A-Za-z0-9_])";
|
|
521
|
+
function escapePathPattern(value) {
|
|
522
|
+
return value.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
523
|
+
}
|
|
524
|
+
function machineHomePathPatterns(flags) {
|
|
525
|
+
const posix5 = `${ABSOLUTE_PATH_BOUNDARY}(?:${POSIX_HOME_ROOTS.map(escapePathPattern).join("|")})/${USER_SEGMENT_BODY}${POSIX_SEGMENT_END}`;
|
|
526
|
+
const windows = `${ABSOLUTE_PATH_BOUNDARY}${escapePathPattern(WINDOWS_HOME_ROOT)}\\\\+${WINDOWS_USER_SEGMENT_BODY}${WINDOWS_SEGMENT_END}`;
|
|
527
|
+
return [new RegExp(posix5, flags), new RegExp(windows, flags)];
|
|
528
|
+
}
|
|
503
529
|
var CealProtocolValidationError = class extends Error {
|
|
504
530
|
name = "CealProtocolValidationError";
|
|
505
531
|
code;
|
|
@@ -853,8 +879,9 @@ var GATEWAY_TRANSPORT_UNAVAILABLE = "The Gateway transport is unavailable; ask a
|
|
|
853
879
|
var HOST_AUTHENTICATION_UNAVAILABLE = "The Host could not authenticate this invocation; report this as a gap.";
|
|
854
880
|
var CLIENT_HOST_RELEASE_MISMATCH = "Install or upgrade the Ceal CLI and Host Relay to the same release as the Gateway, then retry.";
|
|
855
881
|
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.";
|
|
856
|
-
var HOST_CONTEXT_UNAVAILABLE = "The Host could not select
|
|
882
|
+
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.";
|
|
857
883
|
var SESSION_CONTEXT_UNAVAILABLE = "The local Gateway session context is unavailable.";
|
|
884
|
+
var SESSION_ADOPT_RECOVERY = "The refresh Session is no longer usable. Run `ceal session adopt --gateway <origin> --email <email>` to complete mailbox-confirmed recovery.";
|
|
858
885
|
function guidance(message, next_action, http_status, retryable = false, redaction_class = "model_safe") {
|
|
859
886
|
return Object.freeze({ message, next_action, http_status, retryable, redaction_class });
|
|
860
887
|
}
|
|
@@ -875,13 +902,18 @@ var CEAL_FAILURE_GUIDANCE_TABLE = Object.freeze({
|
|
|
875
902
|
context_not_selected: guidance(SESSION_CONTEXT_UNAVAILABLE, "repair_or_adopt_session", 401),
|
|
876
903
|
context_store_invalid: guidance(SESSION_CONTEXT_UNAVAILABLE, "repair_or_adopt_session", 401),
|
|
877
904
|
context_store_conflict: guidance(SESSION_CONTEXT_UNAVAILABLE, "repair_or_adopt_session", 401),
|
|
878
|
-
refresh_invalid: guidance(
|
|
879
|
-
refresh_expired: guidance(
|
|
880
|
-
refresh_replayed: guidance(
|
|
881
|
-
refresh_revoked: guidance(
|
|
882
|
-
person_inactive: guidance("The Person is inactive, so the Gateway refused this refresh without revoking the Session family.", "ask_admin", 403),
|
|
883
|
-
principal_inactive: guidance("The Principal is inactive, so the Gateway refused this refresh without revoking the Session family.", "ask_admin", 403),
|
|
884
|
-
|
|
905
|
+
refresh_invalid: guidance(SESSION_ADOPT_RECOVERY, "repair_or_adopt_session", 401),
|
|
906
|
+
refresh_expired: guidance(SESSION_ADOPT_RECOVERY, "repair_or_adopt_session", 401),
|
|
907
|
+
refresh_replayed: guidance(SESSION_ADOPT_RECOVERY, "repair_or_adopt_session", 401),
|
|
908
|
+
refresh_revoked: guidance(SESSION_ADOPT_RECOVERY, "repair_or_adopt_session", 401),
|
|
909
|
+
person_inactive: guidance("The Person is inactive, so the Gateway refused this refresh without revoking the Session family. Ask an Admin to reactivate the Person, then retry this same session refresh.", "ask_admin", 403),
|
|
910
|
+
principal_inactive: guidance("The Principal is inactive, so the Gateway refused this refresh without revoking the Session family. Ask an Admin to reactivate the Principal, then retry this same session refresh.", "ask_admin", 403),
|
|
911
|
+
authority_replaced: guidance("The Gateway authority has been replaced; this session is no longer valid here. Run `ceal session adopt --gateway <origin> --email <email>` against the current Gateway to complete mailbox-confirmed recovery.", "repair_or_adopt_session", 409),
|
|
912
|
+
refresh_inactive: guidance(SESSION_ADOPT_RECOVERY, "repair_or_adopt_session", 410),
|
|
913
|
+
refresh_recovery_unavailable: guidance("The Gateway's durable refresh-recovery key is unavailable. Retry the same refresh attempt after the key is available.", "retry", 503, true),
|
|
914
|
+
refresh_recovery_outcome_unavailable: guidance("The Gateway could not safely recover the outcome of a prior refresh. Ask an administrator to inspect the Gateway session state before retrying or adopting this session.", "ask_admin", 503),
|
|
915
|
+
refresh_state_unavailable: guidance("The Gateway session state store is temporarily unavailable; retry the same refresh attempt when it is available.", "retry", 503, true),
|
|
916
|
+
refresh_recovery_expired: guidance(SESSION_ADOPT_RECOVERY, "repair_or_adopt_session", 410),
|
|
885
917
|
refresh_custody_invalid: guidance(SESSION_CONTEXT_UNAVAILABLE, "repair_or_adopt_session", 401),
|
|
886
918
|
session_store_unwritable: guidance("The Ceal client could not write its local session store; the operating system refused the write (EACCES, EPERM, or EROFS). rerun_outside_agent_sandbox reruns it with escalated execution.", "rerun_outside_agent_sandbox", 500),
|
|
887
919
|
local_output_exists: guidance("The selected local output path already exists; nothing was written to it.", "choose_new_output_path", 400),
|
|
@@ -896,23 +928,21 @@ var CEAL_FAILURE_GUIDANCE_TABLE = Object.freeze({
|
|
|
896
928
|
resource_stream_failed: guidance("The provider resource stream failed; ask an administrator to inspect the Gateway failure log.", "ask_admin", 500),
|
|
897
929
|
gateway_unavailable: guidance(GATEWAY_TRANSPORT_UNAVAILABLE, "ask_admin", 503, true),
|
|
898
930
|
contract_mismatch: guidance(CLIENT_HOST_RELEASE_MISMATCH, "upgrade_ceal_client", 409),
|
|
899
|
-
//
|
|
900
|
-
|
|
901
|
-
// when the wait ends still unserved, moved from the `localFailureText` default branch.
|
|
902
|
-
[CEAL_GATEWAY_STARTING_FAILURE_CODE]: guidance(LOCAL_TRANSPORT_INCOMPLETE, "answer_with_gap", 503, true),
|
|
931
|
+
// The serving gate answers before refresh execution, so retrying the same attempt is safe.
|
|
932
|
+
[CEAL_GATEWAY_STARTING_FAILURE_CODE]: guidance("The Gateway is still starting; the refresh was not attempted and the refresh token was not consumed. Retry the same refresh attempt after the Gateway is serving.", "retry", 503, true),
|
|
903
933
|
gateway_internal_error: guidance("The Gateway failed without exposing internal state; report this as a gap.", "answer_with_gap", 500),
|
|
904
934
|
// The serving gate emits this code with no message; the sentence is the owner-normalized form of the
|
|
905
935
|
// `gateway_internal_error` guidance (decided with the operator 2026-10-13).
|
|
906
936
|
internal_error: guidance("The Gateway failed without exposing internal state.", "answer_with_gap", 500),
|
|
907
937
|
// Owned by the Gateway canonical adapter (`gateway/core/src/gateway-canonical-operation-http-adapter.ts`):
|
|
908
|
-
// the client variant
|
|
938
|
+
// the static client variant was retired when the client started reading this table.
|
|
909
939
|
request_body_too_large: guidance("The Gateway request body exceeds its bounded limit.", "reduce_request_size", 413),
|
|
910
940
|
gateway_response_too_large: guidance("The Gateway response exceeds its bounded limit; reduce the requested page or result size.", "reduce_request_size", 500),
|
|
911
|
-
//
|
|
912
|
-
//
|
|
913
|
-
|
|
914
|
-
//
|
|
915
|
-
|
|
941
|
+
// The safe move varies by request. Keep the sentence conditional on the
|
|
942
|
+
// same `retryable` and `next_action` facts the response exposes.
|
|
943
|
+
unknown_outcome: guidance("The transport outcome is unknown; use retryable and next_action to decide whether it can be repeated.", "answer_with_gap", 500),
|
|
944
|
+
// A provider write the Gateway command deadline cut after its dispatch: the write left and its receipt is still settling, so the caller reads the receipt instead of repeating the write.
|
|
945
|
+
write_in_progress: guidance("The provider write was dispatched but the Gateway command deadline cut the wait before its outcome settled. Do not repeat the write; read the durable receipt named by write_request_ref with write_receipt.get.", "write_receipt.get", 500),
|
|
916
946
|
// Restored verbatim from the retired `localFailureText`
|
|
917
947
|
// `refresh_unknown_outcome` case: a refresh that ends unknown leaves the
|
|
918
948
|
// session context unavailable, so the caller repairs or adopts the
|
|
@@ -993,8 +1023,8 @@ var CEAL_FAILURE_GUIDANCE_TABLE = Object.freeze({
|
|
|
993
1023
|
// Host mint classifications. The CLI emits `invocation_authentication_unavailable` with the classification
|
|
994
1024
|
// in its detail fact; rows without their own sentence share that code's moved sentence, while `next_action`
|
|
995
1025
|
// is moved from `canonicalHostAuthenticationNextActions` (generated from `CEAL_HOST_AUTHENTICATION_POLICY`)
|
|
996
|
-
// and `retryable` from `hostAuthenticationFailureForCause` (
|
|
997
|
-
// sentences carry the
|
|
1026
|
+
// and `retryable` from `hostAuthenticationFailureForCause` (the table's explicit retry verdict). Cause-specific
|
|
1027
|
+
// sentences carry only remedies proved by the Host or Relay cause; generic Gateway refusals do not prove a release mismatch.
|
|
998
1028
|
// Statuses are the
|
|
999
1029
|
// Gateway-owned mapping decided with the operator 2026-10-13. This covers every wire cause the maps at
|
|
1000
1030
|
// `host/invocation-authentication-command.ts:217-242` emit, through their policy classifications.
|
|
@@ -1004,21 +1034,23 @@ var CEAL_FAILURE_GUIDANCE_TABLE = Object.freeze({
|
|
|
1004
1034
|
// The bounded Host reason does not prove ephemerality. A Host refusal never
|
|
1005
1035
|
// changes mode; standalone remains the separate Client authority path.
|
|
1006
1036
|
host_context_unavailable: guidance(HOST_CONTEXT_UNAVAILABLE, "answer_with_gap", 401),
|
|
1007
|
-
|
|
1008
|
-
|
|
1037
|
+
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),
|
|
1038
|
+
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),
|
|
1039
|
+
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),
|
|
1009
1040
|
host_source_refused: guidance(HOST_AUTHENTICATION_UNAVAILABLE, "answer_with_gap", 403),
|
|
1010
1041
|
host_registration_credential_refused: guidance(HOST_AUTHENTICATION_UNAVAILABLE, "ask_admin", 403),
|
|
1011
1042
|
host_mint_gateway_unavailable: guidance(HOST_AUTHENTICATION_UNAVAILABLE, "ask_admin", 503),
|
|
1012
1043
|
host_mint_gateway_rate_limited: guidance(HOST_AUTHENTICATION_UNAVAILABLE, "answer_with_gap", 429),
|
|
1013
|
-
host_mint_gateway_refused: guidance(
|
|
1044
|
+
host_mint_gateway_refused: guidance(HOST_AUTHENTICATION_UNAVAILABLE, "answer_with_gap", 502),
|
|
1014
1045
|
host_mint_gateway_response_invalid: guidance(HOST_AUTHENTICATION_UNAVAILABLE, "answer_with_gap", 502),
|
|
1046
|
+
host_contract_mismatch: guidance(CLIENT_HOST_RELEASE_MISMATCH, "upgrade_ceal_client", 502),
|
|
1015
1047
|
// Moved from the retired `CEAL_HOST_AUTHENTICATION_POLICY` remedy: the
|
|
1016
1048
|
// producer-frame fault names the administrator repair step.
|
|
1017
1049
|
host_producer_frame_invalid: guidance("Ask an administrator to inspect and repair the producer frame, then start a fresh Host turn.", "ask_admin", 400),
|
|
1018
1050
|
// Moved from the retired `CEAL_HOST_AUTHENTICATION_POLICY` remedy: the
|
|
1019
1051
|
// sandboxed Relay socket names the run-alone retry.
|
|
1020
1052
|
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),
|
|
1021
|
-
host_relay_unavailable: guidance(
|
|
1053
|
+
host_relay_unavailable: guidance(HOST_AUTHENTICATION_UNAVAILABLE, "answer_with_gap", 503),
|
|
1022
1054
|
host_mint_transient_retryable: guidance(HOST_AUTHENTICATION_UNAVAILABLE, "retry", 503, true),
|
|
1023
1055
|
host_mint_failed: guidance(HOST_AUTHENTICATION_UNAVAILABLE, "answer_with_gap", 500),
|
|
1024
1056
|
host_relay_failed: guidance(HOST_INSTALL_REPAIR, "install_ceal_host", 502),
|
|
@@ -1056,7 +1088,7 @@ var UNKNOWN_OUTCOMES = vocabulary(["reconcile", "operator_action", "excluded"]);
|
|
|
1056
1088
|
var RECOVERY_OWNERS = vocabulary(["gateway", "connector", "operator"]);
|
|
1057
1089
|
var CEAL_OPERATION_ADMISSION_STATES = vocabulary(["proposed", "refused", "admitted"]);
|
|
1058
1090
|
var CEAL_OPERATION_EXECUTION_STATES = vocabulary(["not_started", "started", "completed"]);
|
|
1059
|
-
var CEAL_OPERATION_PROVIDER_HANDOFF_STATES = vocabulary(["not_offered", "offered", "accepted", "rejected", "unknown"]);
|
|
1091
|
+
var CEAL_OPERATION_PROVIDER_HANDOFF_STATES = vocabulary(["not_applicable", "not_offered", "offered", "accepted", "rejected", "unknown"]);
|
|
1060
1092
|
var CEAL_OPERATION_EFFECT_STATES = vocabulary(["none", "applied", "failed", "unknown", "compensated"]);
|
|
1061
1093
|
var CEAL_OPERATION_OBSERVATION_STATES = vocabulary(["not_started", "not_required", "pending", "observed", "unavailable"]);
|
|
1062
1094
|
var CEAL_OPERATION_RECOVERY_KINDS = vocabulary(["none", "reconcile", "compensate", "operator_action"]);
|
|
@@ -1227,6 +1259,7 @@ var CEAL_OPERATION_ACCESS_CLASSES = vocabulary(["read", "write"]);
|
|
|
1227
1259
|
// packages/ceal-client-protocol/src/domain-vocabulary.ts
|
|
1228
1260
|
var CEAL_CONNECTOR_STATUSES = vocabulary(["active", "disabled", "disconnected"]);
|
|
1229
1261
|
var CEAL_CONNECTOR_CUSTODIES = vocabulary(["organization", "personal"]);
|
|
1262
|
+
var CEAL_PROVIDER_BOUNDARY_FIELDS = vocabulary(["provider_boundary_ref", "provider_boundary_kind", "provider_boundary_label", "provider_native_id", "provider_boundary_evidence"]);
|
|
1230
1263
|
var CEAL_PERSONAL_ACCESS_CEILINGS = vocabulary(["disabled", "read", "read_write"]);
|
|
1231
1264
|
var CEAL_TARGET_REF_PATTERN = "^[^\\p{Cc}]+$";
|
|
1232
1265
|
var TARGET_REF = new RegExp(CEAL_TARGET_REF_PATTERN, "u");
|
|
@@ -1272,7 +1305,7 @@ var JSON_DESCRIPTION_CONTROL_CHARACTER = new RegExp("\\p{Cc}", "u");
|
|
|
1272
1305
|
var CEAL_OPERATION_AUTHORITY_POLICY_KEYS = Object.freeze(["access_group", "instance_binding", "target", "admission_recheck"]);
|
|
1273
1306
|
var MAX_OPERATION_INPUT_RESOLVER_BINDINGS = 96;
|
|
1274
1307
|
var CEAL_OPERATION_DESCRIPTOR_REQUIRED_ENVELOPE_KEYS = Object.freeze(["schema_version", "id", "input_contract", "result_contract", "policy"]);
|
|
1275
|
-
var CEAL_OPERATION_DESCRIPTOR_OPTIONAL_ENVELOPE_KEYS = Object.freeze(["input_resolution", "summary"]);
|
|
1308
|
+
var CEAL_OPERATION_DESCRIPTOR_OPTIONAL_ENVELOPE_KEYS = Object.freeze(["input_resolution", "summary", "standard_names"]);
|
|
1276
1309
|
|
|
1277
1310
|
// packages/ceal-client-protocol/src/operation-catalog.ts
|
|
1278
1311
|
var CEAL_OPERATION_CATALOG_SCHEMA_VERSION = "ceal.catalog.v3";
|
|
@@ -1368,6 +1401,7 @@ var CEAL_BOUNDED_SERIES_CATALOG = Object.freeze({
|
|
|
1368
1401
|
gateway_access_group_connector_activity_scope_audit: (root) => join(root, "profile-connector-activity-scope-audit.jsonl"),
|
|
1369
1402
|
gateway_access_group_connector_calendar_scope_audit: (root) => join(root, "profile-connector-calendar-scope-audit.jsonl"),
|
|
1370
1403
|
gateway_access_group_connector_readiness_audit: (root) => join(root, "profile-connector-readiness.audit.jsonl"),
|
|
1404
|
+
gateway_deployment_events: (root) => join(root, "gateway-deployments.jsonl"),
|
|
1371
1405
|
gateway_organization_audit_ledger: (root) => join(root, "organization-ledger.jsonl"),
|
|
1372
1406
|
gateway_personal_client_audit: (root) => join(root, "audit.jsonl"),
|
|
1373
1407
|
gateway_personal_client_access_audit: (root) => join(root, "access-audit.jsonl")
|
|
@@ -1394,6 +1428,11 @@ var CEAL_HOST_INSTALLATION_REF_PATTERN = new RegExp(`^host-installation:${CEAL_L
|
|
|
1394
1428
|
var CEAL_HOST_SOURCE_REF_PATTERN = new RegExp(`^host-source:${CEAL_LOWERCASE_UUID_PATTERN}$`, "u");
|
|
1395
1429
|
var CEAL_HOST_ACCESS_TOKEN_PATTERN = /^ceal_host_[A-Za-z0-9_-]{43}$/u;
|
|
1396
1430
|
|
|
1431
|
+
// packages/ceal-client-protocol/src/resource-read-result.ts
|
|
1432
|
+
var CEAL_RESOURCE_GET_NOTION_CONTENT_GAP_KINDS = Object.freeze(["subtree", "media", "property_schema", "properties"]);
|
|
1433
|
+
var CEAL_RESOURCE_SEARCH_PROVIDER_STATUSES = vocabulary(["done", "pending", "deferred"]);
|
|
1434
|
+
var CEAL_RESOURCE_GET_COVERAGE_NEXT_ACTIONS = vocabulary(["reduce_request_size", "read_resource_again"]);
|
|
1435
|
+
|
|
1397
1436
|
// packages/ceal-client-protocol/src/operation-result-completeness.ts
|
|
1398
1437
|
var CEAL_READ_VALUE_CONTINUATION_KEYS = vocabulary(["continuation", "continuation_ref", "next_cursor"]);
|
|
1399
1438
|
|
|
@@ -1478,6 +1517,7 @@ var PROVIDER_LINK_CONFORMANCE_TABLE = Object.freeze([
|
|
|
1478
1517
|
{ 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" },
|
|
1479
1518
|
{ 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" },
|
|
1480
1519
|
{ 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" },
|
|
1520
|
+
{ 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" },
|
|
1481
1521
|
{ 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" },
|
|
1482
1522
|
{ 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" },
|
|
1483
1523
|
{ 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" },
|
|
@@ -1552,6 +1592,8 @@ var CEAL_ACTIVITY_TIMESTAMP_BASES = vocabulary([
|
|
|
1552
1592
|
"review_submitted",
|
|
1553
1593
|
"comment_created",
|
|
1554
1594
|
"reaction_created",
|
|
1595
|
+
"pull_request_merged",
|
|
1596
|
+
"release_published",
|
|
1555
1597
|
"ceal_write_completed",
|
|
1556
1598
|
"event_start",
|
|
1557
1599
|
"all_day_start",
|
|
@@ -1563,7 +1605,7 @@ var CEAL_ACTIVITY_TIMESTAMP_BASES = vocabulary([
|
|
|
1563
1605
|
"page_last_edited",
|
|
1564
1606
|
"resource_modified"
|
|
1565
1607
|
]);
|
|
1566
|
-
var CEAL_ACTIVITY_CONNECTOR_KINDS = vocabulary(["slack", "github", "google-calendar", "google-drive", "notion"]);
|
|
1608
|
+
var CEAL_ACTIVITY_CONNECTOR_KINDS = vocabulary(["slack", "github", "google-calendar", "google-drive", "google-mail", "notion"]);
|
|
1567
1609
|
var CEAL_ACTIVITY_UNSUPPORTED_EVENT_KIND_CODE = "unsupported_event_kind";
|
|
1568
1610
|
var CEAL_ACTIVITY_GAP_CODES = vocabulary([
|
|
1569
1611
|
"provider_page_budget",
|
|
@@ -1584,6 +1626,8 @@ var CEAL_ACTIVITY_EVENT_KINDS = vocabulary([
|
|
|
1584
1626
|
"github.pull_request.opened",
|
|
1585
1627
|
"github.issue.edited",
|
|
1586
1628
|
"github.pull_request.edited",
|
|
1629
|
+
"github.pull_request.merged",
|
|
1630
|
+
"github.release.published",
|
|
1587
1631
|
"github.review.submitted",
|
|
1588
1632
|
"github.issue_comment.created",
|
|
1589
1633
|
"github.review_comment.created",
|
|
@@ -1597,6 +1641,7 @@ var CEAL_ACTIVITY_EVENT_KINDS = vocabulary([
|
|
|
1597
1641
|
"drive.file.created",
|
|
1598
1642
|
"drive.file.modified",
|
|
1599
1643
|
"drive.file.viewed",
|
|
1644
|
+
"mail.sent",
|
|
1600
1645
|
"notion.page.created",
|
|
1601
1646
|
"notion.page.edited"
|
|
1602
1647
|
]);
|
|
@@ -1610,6 +1655,8 @@ var CEAL_ACTIVITY_EVENT_TIMESTAMP_BASIS_MAP = Object.freeze({
|
|
|
1610
1655
|
"github.review_comment.created": "comment_created",
|
|
1611
1656
|
"github.issue.opened": "resource_created",
|
|
1612
1657
|
"github.pull_request.opened": "resource_created",
|
|
1658
|
+
"github.pull_request.merged": "pull_request_merged",
|
|
1659
|
+
"github.release.published": "release_published",
|
|
1613
1660
|
"github.issue.edited": "resource_modified",
|
|
1614
1661
|
"github.pull_request.edited": "resource_modified",
|
|
1615
1662
|
"github.reaction.created": "reaction_created",
|
|
@@ -1620,6 +1667,7 @@ var CEAL_ACTIVITY_EVENT_TIMESTAMP_BASIS_MAP = Object.freeze({
|
|
|
1620
1667
|
"drive.file.created": "file_created",
|
|
1621
1668
|
"drive.file.modified": "file_modified_by_me",
|
|
1622
1669
|
"drive.file.viewed": "file_viewed_by_me",
|
|
1670
|
+
"mail.sent": "message_created",
|
|
1623
1671
|
"notion.page.created": "page_created",
|
|
1624
1672
|
"notion.page.edited": "page_last_edited"
|
|
1625
1673
|
});
|
|
@@ -1647,6 +1695,7 @@ var RESOURCE_ROW_KEY_RULES = Object.freeze({
|
|
|
1647
1695
|
created_at: { required: false, timestamp: true },
|
|
1648
1696
|
created_at_local: { required: false, timestamp: true },
|
|
1649
1697
|
modified_at: { required: false, timestamp: true },
|
|
1698
|
+
observed_at: { required: false, timestamp: true },
|
|
1650
1699
|
modified_at_local: { required: false, timestamp: true },
|
|
1651
1700
|
viewed_by_me_at: { required: false, timestamp: true },
|
|
1652
1701
|
modified_by_me_at: { required: false, timestamp: true },
|
|
@@ -1674,9 +1723,6 @@ var RESOURCE_ROW_REQUIRED_KEYS = Object.entries(RESOURCE_ROW_KEY_RULES).flatMap(
|
|
|
1674
1723
|
var RESOURCE_ROW_KEYS = new Set(Object.keys(RESOURCE_ROW_KEY_RULES));
|
|
1675
1724
|
var RESOURCE_ROW_TIMESTAMP_KEYS = Object.entries(RESOURCE_ROW_KEY_RULES).flatMap(([key, rule]) => rule.timestamp ? [key] : []);
|
|
1676
1725
|
|
|
1677
|
-
// packages/ceal-client-protocol/src/resource-read-result.ts
|
|
1678
|
-
var CEAL_RESOURCE_GET_COVERAGE_NEXT_ACTIONS = vocabulary(["reduce_request_size", "read_resource_again"]);
|
|
1679
|
-
|
|
1680
1726
|
// packages/ceal-client-protocol/src/excluded-target-coverage.ts
|
|
1681
1727
|
var CEAL_EXCLUDED_TARGET_COVERAGE_MAX_ENTRIES = 64;
|
|
1682
1728
|
function cealExcludedTargetCoverageJsonSchema() {
|
|
@@ -1732,6 +1778,8 @@ var CEAL_REFRESH_FAILURE_CODES = vocabulary([
|
|
|
1732
1778
|
"principal_inactive",
|
|
1733
1779
|
"authority_replaced",
|
|
1734
1780
|
"refresh_recovery_unavailable",
|
|
1781
|
+
"refresh_recovery_outcome_unavailable",
|
|
1782
|
+
"refresh_state_unavailable",
|
|
1735
1783
|
"refresh_recovery_expired",
|
|
1736
1784
|
// The serving gate answers this while the Gateway is still starting and the
|
|
1737
1785
|
// refresh was never attempted; the same attempt stays retryable. It is never
|
|
@@ -1983,7 +2031,7 @@ function validateBatchContents(value) {
|
|
|
1983
2031
|
if (facts.length === 0 && gaps.length === 0 || facts.length > 0 && value.source_ranges.length === 0) invalid("Ceal Host usage coverage is invalid.");
|
|
1984
2032
|
const sourceFiles = new Set(value.source_ranges.map((range) => sourceRangeFileRef(range)));
|
|
1985
2033
|
for (const fact of facts) {
|
|
1986
|
-
|
|
2034
|
+
validateCealHostUsageFact(fact, value.host_session_ref);
|
|
1987
2035
|
if (!sourceFiles.has(fact.source_file_ref)) invalid("Ceal Host usage fact is outside its source ranges.");
|
|
1988
2036
|
}
|
|
1989
2037
|
for (const gap of gaps) {
|
|
@@ -2016,7 +2064,7 @@ function hostUsageSourceFileReference(producer, hostSourceRef, hostSessionRef, d
|
|
|
2016
2064
|
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.");
|
|
2017
2065
|
return `host-source-file:${sha256(JSON.stringify({ producer, host_source_ref: hostSourceRef, host_session_ref: hostSessionRef, device, inode }))}`;
|
|
2018
2066
|
}
|
|
2019
|
-
function
|
|
2067
|
+
function validateCealHostUsageFact(value, sessionRef) {
|
|
2020
2068
|
if (!isOperationRecord(value)) invalid("Ceal Host usage fact is invalid.");
|
|
2021
2069
|
requireFactByteLimit(value);
|
|
2022
2070
|
if (value.producer === "codex_transcript") validateCodexFact(value);
|
|
@@ -2080,7 +2128,7 @@ function validCorrectionSemantics(value) {
|
|
|
2080
2128
|
}
|
|
2081
2129
|
function validateCodexUsageCounts(value) {
|
|
2082
2130
|
if (!isOperationRecord(value)) invalid("Ceal Codex usage fields are invalid.");
|
|
2083
|
-
requireExactOperationKeys(value,
|
|
2131
|
+
requireExactOperationKeys(value, CEAL_CODEX_USAGE_COUNT_FIELDS);
|
|
2084
2132
|
for (const key of Object.keys(value)) if (!safeInteger(value[key])) invalid("Ceal Codex usage fields are invalid.");
|
|
2085
2133
|
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.");
|
|
2086
2134
|
}
|
|
@@ -2348,6 +2396,7 @@ var CEAL_HOST_AUTHENTICATION_CAUSES = vocabulary([
|
|
|
2348
2396
|
"options_invalid",
|
|
2349
2397
|
"session_unavailable",
|
|
2350
2398
|
"context_unavailable",
|
|
2399
|
+
"activation_wait_exhausted",
|
|
2351
2400
|
"context_replaced",
|
|
2352
2401
|
"no_binding",
|
|
2353
2402
|
"context_expired",
|
|
@@ -2383,22 +2432,23 @@ var CEAL_HOST_AUTHENTICATION_POLICY = Object.freeze({
|
|
|
2383
2432
|
// This reason cannot distinguish a Codex side conversation from a missing
|
|
2384
2433
|
// context in a regular session, so guidance must leave that choice to the caller.
|
|
2385
2434
|
context_unavailable: Object.freeze({ classification: "host_context_unavailable", next_action: "answer_with_gap" }),
|
|
2386
|
-
|
|
2435
|
+
activation_wait_exhausted: Object.freeze({ classification: "host_context_activation_wait_exhausted", next_action: "retry_after" }),
|
|
2436
|
+
context_replaced: Object.freeze({ classification: "host_invocation_context_stale", next_action: "answer_with_gap" }),
|
|
2387
2437
|
// `no_binding` now means the producer has no real current Host session. The
|
|
2388
2438
|
// Host Relay never uses it for an uncreated Gateway Request; there is no
|
|
2389
2439
|
// useful retry until the consumer is running inside a Host session.
|
|
2390
2440
|
no_binding: Object.freeze({ classification: "host_session_unavailable", next_action: "answer_with_gap" }),
|
|
2391
|
-
context_expired: Object.freeze({ classification: "host_invocation_context_expired", next_action: "
|
|
2441
|
+
context_expired: Object.freeze({ classification: "host_invocation_context_expired", next_action: "answer_with_gap" }),
|
|
2392
2442
|
host_source_refused: Object.freeze({ classification: "host_source_refused", next_action: "answer_with_gap" }),
|
|
2393
2443
|
host_credential_refused: Object.freeze({ classification: "host_registration_credential_refused", next_action: "ask_admin" }),
|
|
2394
2444
|
gateway_unavailable: Object.freeze({ classification: "host_mint_gateway_unavailable", next_action: "ask_admin" }),
|
|
2395
2445
|
gateway_rate_limited: Object.freeze({ classification: "host_mint_gateway_rate_limited", next_action: "answer_with_gap" }),
|
|
2396
|
-
contract_mismatch: Object.freeze({ classification: "
|
|
2397
|
-
gateway_refused: Object.freeze({ classification: "host_mint_gateway_refused", next_action: "
|
|
2446
|
+
contract_mismatch: Object.freeze({ classification: "host_contract_mismatch", next_action: "upgrade_ceal_client" }),
|
|
2447
|
+
gateway_refused: Object.freeze({ classification: "host_mint_gateway_refused", next_action: "answer_with_gap" }),
|
|
2398
2448
|
gateway_response_invalid: Object.freeze({ classification: "host_mint_gateway_response_invalid", next_action: "answer_with_gap" }),
|
|
2399
2449
|
producer_frame_invalid: Object.freeze({ classification: "host_producer_frame_invalid", next_action: "ask_admin" }),
|
|
2400
2450
|
relay_permission_denied: Object.freeze({ classification: "host_relay_permission_denied", next_action: "rerun_outside_agent_sandbox" }),
|
|
2401
|
-
relay_unavailable: Object.freeze({ classification: "host_relay_unavailable", next_action: "
|
|
2451
|
+
relay_unavailable: Object.freeze({ classification: "host_relay_unavailable", next_action: "answer_with_gap" }),
|
|
2402
2452
|
transient_retryable: Object.freeze({ classification: "host_mint_transient_retryable", next_action: "retry" }),
|
|
2403
2453
|
mint_failed: Object.freeze({ classification: "host_mint_failed", next_action: "answer_with_gap" }),
|
|
2404
2454
|
relay_failed: Object.freeze({ classification: "host_relay_failed", next_action: "install_ceal_host" }),
|
|
@@ -2446,7 +2496,7 @@ function isCealHostServiceDiagnosticCause(value, event) {
|
|
|
2446
2496
|
// packages/ceal-client-protocol/src/client-result-materialization.ts
|
|
2447
2497
|
var CEAL_UNREAD_REASONS = vocabulary(["blocked", "unavailable", "too_large", "unsupported", "download_failed", "permission_denied"]);
|
|
2448
2498
|
var REQUIRED_FIELDS2 = Object.freeze(["schema_version", "operation_id", "path", "sha256"]);
|
|
2449
|
-
var FIELDS = /* @__PURE__ */ new Set([...REQUIRED_FIELDS2, "
|
|
2499
|
+
var FIELDS = /* @__PURE__ */ new Set([...REQUIRED_FIELDS2, "local_result_root", "request_context_argv", "how_to_read"]);
|
|
2450
2500
|
|
|
2451
2501
|
// packages/ceal-client-protocol/src/discovery-manifest.ts
|
|
2452
2502
|
var DISCOVERY_MANIFEST_KEYS = CEAL_CLIENT_WIRE_CONTRACT.command_response.discovery_manifest_fields;
|
|
@@ -2488,6 +2538,211 @@ var CEAL_SUPPORTED_GATEWAY_PROTOCOL_RANGE = Object.freeze({
|
|
|
2488
2538
|
maximum: CEAL_PROTOCOL_VERSION
|
|
2489
2539
|
});
|
|
2490
2540
|
|
|
2541
|
+
// packages/ceal-client-protocol/src/operator-diagnostic.ts
|
|
2542
|
+
var OPERATOR_DIAGNOSTIC_MAX_BYTES = 2048;
|
|
2543
|
+
var OPERATOR_DIAGNOSTIC_MAX_CAUSES = 8;
|
|
2544
|
+
var OPERATOR_DIAGNOSTIC_CAUSE_MESSAGE_LIMIT = 512;
|
|
2545
|
+
var OPERATOR_DIAGNOSTIC_PATH_LIMIT = 1024;
|
|
2546
|
+
var OPERATOR_DIAGNOSTIC_STREAM_TAIL_LIMIT = 256;
|
|
2547
|
+
var OPERATOR_DIAGNOSTIC_HOME_PATHS = machineHomePathPatterns("gu");
|
|
2548
|
+
function redactOperatorDiagnosticSecrets(value) {
|
|
2549
|
+
return value.replace(/\bBearer\s+[A-Za-z0-9._~+/=-]+/giu, "Bearer [redacted]").replace(/(["']?(?:authorization|[A-Za-z0-9_-]*(?:token|secret|credential|password|key))["']?\s*[:=]\s*)(?!(?:"unknown"|'unknown'|unknown\b))(?:"[^"]*"|'[^']*'|[^\s,;}]+)/giu, "$1[redacted]");
|
|
2550
|
+
}
|
|
2551
|
+
function redactOperatorDiagnosticText(value) {
|
|
2552
|
+
const normalized = normalizeCealSingleLineText(value);
|
|
2553
|
+
return normalizeCealSingleLineText(redactOperatorDiagnosticSecrets(redactFilePaths(redactHomePaths(redactUrls(normalized)))));
|
|
2554
|
+
}
|
|
2555
|
+
function renderOperatorDiagnostic(value) {
|
|
2556
|
+
const state = collectDiagnosticState(value);
|
|
2557
|
+
const fields = [
|
|
2558
|
+
state.status === void 0 ? void 0 : `status=${JSON.stringify(safeDiagnosticText(state.status))}`,
|
|
2559
|
+
state.exitCode === void 0 ? void 0 : `exit_code=${state.exitCode}`,
|
|
2560
|
+
state.stdout === void 0 ? void 0 : `stdout_tail=${JSON.stringify(tail(state.stdout))}`,
|
|
2561
|
+
state.stderr === void 0 ? void 0 : `stderr_tail=${JSON.stringify(tail(state.stderr))}`,
|
|
2562
|
+
state.causes.length === 0 ? void 0 : `causes=${state.causes.map(formatCause).join(" <- ")}`
|
|
2563
|
+
].filter((field) => field !== void 0);
|
|
2564
|
+
const rendered = fields.length === 0 ? "unknown_failure" : fields.join(" ");
|
|
2565
|
+
return truncateUtf8(rendered, OPERATOR_DIAGNOSTIC_MAX_BYTES);
|
|
2566
|
+
}
|
|
2567
|
+
function collectDiagnosticState(value) {
|
|
2568
|
+
const state = { causes: [], status: void 0, exitCode: void 0, stdout: void 0, stderr: void 0 };
|
|
2569
|
+
const visited = /* @__PURE__ */ new Set(), pending = [value];
|
|
2570
|
+
while (pending.length > 0 && state.causes.length < OPERATOR_DIAGNOSTIC_MAX_CAUSES) {
|
|
2571
|
+
const current = pending.shift();
|
|
2572
|
+
if (current !== void 0) visitDiagnosticNode(current, state, pending, visited);
|
|
2573
|
+
}
|
|
2574
|
+
return state;
|
|
2575
|
+
}
|
|
2576
|
+
function visitDiagnosticNode(current, state, pending, visited) {
|
|
2577
|
+
if (isObject(current)) {
|
|
2578
|
+
if (visited.has(current)) return;
|
|
2579
|
+
visited.add(current);
|
|
2580
|
+
}
|
|
2581
|
+
captureProcessEvidence(current, state);
|
|
2582
|
+
appendCause(current, state.causes);
|
|
2583
|
+
enqueueCauseChildren(current, state.causes.length, pending);
|
|
2584
|
+
}
|
|
2585
|
+
function captureProcessEvidence(current, state) {
|
|
2586
|
+
if (state.status === void 0) state.status = safeStatus(read(current, "status"));
|
|
2587
|
+
if (state.exitCode === void 0) state.exitCode = safeExitCode(read(current, "exitCode")) ?? safeExitCode(read(current, "status")) ?? safeExitCode(read(current, "code"));
|
|
2588
|
+
if (state.stdout === void 0) state.stdout = outputText(read(current, "stdout"));
|
|
2589
|
+
if (state.stderr === void 0) state.stderr = outputText(read(current, "stderr"));
|
|
2590
|
+
}
|
|
2591
|
+
function appendCause(current, causes) {
|
|
2592
|
+
const errors = read(current, "errors");
|
|
2593
|
+
if (current instanceof Error && (!(current instanceof AggregateError) || !Array.isArray(errors) || errors.length === 0)) {
|
|
2594
|
+
causes.push(errorCause(current));
|
|
2595
|
+
return;
|
|
2596
|
+
}
|
|
2597
|
+
if (!isObject(current)) {
|
|
2598
|
+
const message = safeText(current);
|
|
2599
|
+
if (message !== void 0) causes.push(Object.freeze({ error_class: typeof current, message }));
|
|
2600
|
+
}
|
|
2601
|
+
}
|
|
2602
|
+
function errorCause(error) {
|
|
2603
|
+
const name = safeText(read(error, "name")) ?? "Error";
|
|
2604
|
+
const message = safeText(read(error, "message"));
|
|
2605
|
+
const codeValue = read(error, "code");
|
|
2606
|
+
const code2 = typeof codeValue === "number" && Number.isFinite(codeValue) ? codeValue : safeText(codeValue);
|
|
2607
|
+
const errnoValue = read(error, "errno");
|
|
2608
|
+
const errno = typeof errnoValue === "number" && Number.isSafeInteger(errnoValue) ? errnoValue : void 0;
|
|
2609
|
+
const syscall = safeText(read(error, "syscall"));
|
|
2610
|
+
const path = safePath(read(error, "path"));
|
|
2611
|
+
return Object.freeze({ error_class: name, ...message === void 0 ? {} : { message }, ...code2 === void 0 ? {} : { code: code2 }, ...errno === void 0 ? {} : { errno }, ...syscall === void 0 ? {} : { syscall }, ...path === void 0 ? {} : { path } });
|
|
2612
|
+
}
|
|
2613
|
+
function enqueueCauseChildren(current, causeCount, pending) {
|
|
2614
|
+
const cause = read(current, "cause");
|
|
2615
|
+
if (cause !== void 0) pending.push(cause);
|
|
2616
|
+
const errors = read(current, "errors");
|
|
2617
|
+
if (Array.isArray(errors)) pending.push(...errors.slice(0, OPERATOR_DIAGNOSTIC_MAX_CAUSES - causeCount));
|
|
2618
|
+
}
|
|
2619
|
+
function isObject(value) {
|
|
2620
|
+
return typeof value === "object" && value !== null;
|
|
2621
|
+
}
|
|
2622
|
+
function formatCause(cause) {
|
|
2623
|
+
const fields = [
|
|
2624
|
+
cause.error_class,
|
|
2625
|
+
cause.code === void 0 ? void 0 : `code=${JSON.stringify(safeDiagnosticText(cause.code))}`,
|
|
2626
|
+
cause.errno === void 0 ? void 0 : `errno=${cause.errno}`,
|
|
2627
|
+
cause.syscall === void 0 ? void 0 : `syscall=${JSON.stringify(cause.syscall)}`,
|
|
2628
|
+
cause.path === void 0 ? void 0 : `path=${JSON.stringify(cause.path)}`,
|
|
2629
|
+
cause.message === void 0 ? void 0 : `message=${cause.message}`
|
|
2630
|
+
].filter((field) => field !== void 0);
|
|
2631
|
+
return fields.join(" ");
|
|
2632
|
+
}
|
|
2633
|
+
function tail(value) {
|
|
2634
|
+
const clipped = value.length <= OPERATOR_DIAGNOSTIC_STREAM_TAIL_LIMIT ? value : `…${value.slice(-OPERATOR_DIAGNOSTIC_STREAM_TAIL_LIMIT)}`;
|
|
2635
|
+
return safeDiagnosticText(clipped);
|
|
2636
|
+
}
|
|
2637
|
+
function safeText(value) {
|
|
2638
|
+
if (typeof value !== "string") return void 0;
|
|
2639
|
+
const safe = safeDiagnosticText(value);
|
|
2640
|
+
if (safe.length === 0) return void 0;
|
|
2641
|
+
if (safe.length <= OPERATOR_DIAGNOSTIC_CAUSE_MESSAGE_LIMIT) return safe;
|
|
2642
|
+
const head = Math.floor(OPERATOR_DIAGNOSTIC_CAUSE_MESSAGE_LIMIT / 2);
|
|
2643
|
+
const tail2 = OPERATOR_DIAGNOSTIC_CAUSE_MESSAGE_LIMIT - head - 1;
|
|
2644
|
+
return `${safe.slice(0, head)}…${safe.slice(-tail2)}`;
|
|
2645
|
+
}
|
|
2646
|
+
function safePath(value) {
|
|
2647
|
+
if (typeof value !== "string") return void 0;
|
|
2648
|
+
const safe = safeDiagnosticText(value);
|
|
2649
|
+
if (safe.length === 0) return void 0;
|
|
2650
|
+
if (safe.length <= OPERATOR_DIAGNOSTIC_PATH_LIMIT) return safe;
|
|
2651
|
+
const head = Math.floor(OPERATOR_DIAGNOSTIC_PATH_LIMIT / 2);
|
|
2652
|
+
const tail2 = OPERATOR_DIAGNOSTIC_PATH_LIMIT - head - 1;
|
|
2653
|
+
return `${safe.slice(0, head)}…${safe.slice(-tail2)}`;
|
|
2654
|
+
}
|
|
2655
|
+
function safeDiagnosticText(value) {
|
|
2656
|
+
return redactOperatorDiagnosticText(String(value));
|
|
2657
|
+
}
|
|
2658
|
+
function outputText(value) {
|
|
2659
|
+
if (typeof value === "string") return redactOperatorDiagnosticText(value);
|
|
2660
|
+
if (value instanceof Uint8Array) {
|
|
2661
|
+
try {
|
|
2662
|
+
return redactOperatorDiagnosticText(new TextDecoder().decode(value));
|
|
2663
|
+
} catch {
|
|
2664
|
+
return void 0;
|
|
2665
|
+
}
|
|
2666
|
+
}
|
|
2667
|
+
return void 0;
|
|
2668
|
+
}
|
|
2669
|
+
function safeStatus(value) {
|
|
2670
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
2671
|
+
return typeof value === "string" ? safeText(value) : void 0;
|
|
2672
|
+
}
|
|
2673
|
+
function safeExitCode(value) {
|
|
2674
|
+
return typeof value === "number" && Number.isSafeInteger(value) ? value : void 0;
|
|
2675
|
+
}
|
|
2676
|
+
function read(value, key) {
|
|
2677
|
+
if (typeof value !== "object" && typeof value !== "function" || value === null) return void 0;
|
|
2678
|
+
try {
|
|
2679
|
+
return Reflect.get(value, key);
|
|
2680
|
+
} catch {
|
|
2681
|
+
return void 0;
|
|
2682
|
+
}
|
|
2683
|
+
}
|
|
2684
|
+
function redactHomePaths(value) {
|
|
2685
|
+
const paths = [
|
|
2686
|
+
...OPERATOR_DIAGNOSTIC_HOME_PATHS.flatMap((pattern) => [...value.matchAll(pattern)].map((match) => homePathRange(value, match, matchedHomePrefixLength(match[0])))),
|
|
2687
|
+
...configuredHomePathPatterns().flatMap(({ pattern, prefixLength }) => [...value.matchAll(pattern)].map((match) => homePathRange(value, match, prefixLength)))
|
|
2688
|
+
];
|
|
2689
|
+
paths.sort((left, right) => left.start - right.start || right.end - left.end);
|
|
2690
|
+
let output = "";
|
|
2691
|
+
let cursor = 0;
|
|
2692
|
+
for (const path of paths) {
|
|
2693
|
+
if (path.start < cursor) continue;
|
|
2694
|
+
output += `${value.slice(cursor, path.start)}[home path redacted]${value.slice(path.prefixEnd, path.end)}`;
|
|
2695
|
+
cursor = path.end;
|
|
2696
|
+
}
|
|
2697
|
+
return output + value.slice(cursor);
|
|
2698
|
+
}
|
|
2699
|
+
function configuredHomePathPatterns() {
|
|
2700
|
+
const homes = [...new Set([process.env.HOME, process.env.USERPROFILE].filter((home) => home !== void 0 && home.length > 0))];
|
|
2701
|
+
return homes.flatMap((home) => {
|
|
2702
|
+
const root = home.replace(/[\\/]+$/gu, "");
|
|
2703
|
+
if (root.length === 0 || root === "/" || /^[A-Za-z]:$/u.test(root)) return [];
|
|
2704
|
+
const pattern = new RegExp(`(?<![A-Za-z0-9_])${escapePathPattern(root)}(?=$|[\\\\/\\s"'\`<>(){}\\[\\],;])`, /^[A-Za-z]:[\\/]/u.test(root) ? "giu" : "gu");
|
|
2705
|
+
return [{ pattern, prefixLength: root.length }];
|
|
2706
|
+
});
|
|
2707
|
+
}
|
|
2708
|
+
function matchedHomePrefixLength(value) {
|
|
2709
|
+
let separators = 0;
|
|
2710
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
2711
|
+
if (value[index] !== "/" && value[index] !== "\\") continue;
|
|
2712
|
+
separators += 1;
|
|
2713
|
+
if (separators === 3) return index;
|
|
2714
|
+
}
|
|
2715
|
+
return value.length;
|
|
2716
|
+
}
|
|
2717
|
+
function redactUrls(value) {
|
|
2718
|
+
return value.replaceAll(/https?:\/\/[^\s"'<>]+/giu, "[url redacted]");
|
|
2719
|
+
}
|
|
2720
|
+
function redactFilePaths(value) {
|
|
2721
|
+
return value.replaceAll(/(?<![A-Za-z0-9._-]|\[home path redacted\])(?:[A-Za-z]:[\\/]|\\\\[^\\\s]+\\|\/)[^:\r\n"'<>]*?(?=:\d+(?::\d+)?(?:[:\s]|$)|[\r\n]|["'])/gu, "[path redacted]");
|
|
2722
|
+
}
|
|
2723
|
+
function homePathRange(value, match, prefixLength) {
|
|
2724
|
+
const index = match.index;
|
|
2725
|
+
if (index === void 0) return { start: value.length, end: value.length, prefixEnd: value.length };
|
|
2726
|
+
const start = index;
|
|
2727
|
+
let end = start + match[0].length;
|
|
2728
|
+
const quote = start > 0 && (value[start - 1] === "'" || value[start - 1] === '"') ? value[start - 1] : void 0;
|
|
2729
|
+
if (quote !== void 0) {
|
|
2730
|
+
const closing = value.indexOf(quote, end);
|
|
2731
|
+
if (closing >= 0) end = closing;
|
|
2732
|
+
}
|
|
2733
|
+
while (end < value.length && !/[\s"'`<>(){}[\],;]/u.test(value[end] ?? "")) end += 1;
|
|
2734
|
+
return { start, end, prefixEnd: Math.min(start + prefixLength, end) };
|
|
2735
|
+
}
|
|
2736
|
+
function truncateUtf8(value, maxBytes) {
|
|
2737
|
+
if (byteLength(value) <= maxBytes) return value;
|
|
2738
|
+
let output = "";
|
|
2739
|
+
for (const character of value) {
|
|
2740
|
+
if (byteLength(`${output}${character}…`) > maxBytes) break;
|
|
2741
|
+
output += character;
|
|
2742
|
+
}
|
|
2743
|
+
return `${output}…`;
|
|
2744
|
+
}
|
|
2745
|
+
|
|
2491
2746
|
// packages/ceal-client-protocol/src/admin-projection-vocabulary.ts
|
|
2492
2747
|
var ADMIN_PROJECTION_STATES = vocabulary(["ready", "empty", "partial", "unknown"]);
|
|
2493
2748
|
var ADMIN_VIEW_KINDS = vocabulary(["request_detail", "resource_access_timeline", "weekly_usage"]);
|
|
@@ -2674,7 +2929,7 @@ async function runSecurefsCommand(args, maxBytes, custody, stdin) {
|
|
|
2674
2929
|
const executable = custody.securefs_executable ?? resolveInstalledHostExecutable(process.platform);
|
|
2675
2930
|
const processArgs = [...custody.securefs_args_prefix ?? [], ...args];
|
|
2676
2931
|
return await new Promise((resolve, reject) => {
|
|
2677
|
-
const child = execFile(executable, processArgs, { encoding: "buffer", timeout: WINDOWS_SECUREFS_TIMEOUT_MS, maxBuffer: maxBytes + WINDOWS_SECUREFS_DIAGNOSTIC_BYTES }, (error, stdout, stderr) => {
|
|
2932
|
+
const child = execFile(executable, processArgs, { encoding: "buffer", windowsHide: true, timeout: WINDOWS_SECUREFS_TIMEOUT_MS, maxBuffer: maxBytes + WINDOWS_SECUREFS_DIAGNOSTIC_BYTES }, (error, stdout, stderr) => {
|
|
2678
2933
|
const exitCode = error === null ? 0 : typeof error.code === "number" ? error.code : null;
|
|
2679
2934
|
if (exitCode === null) {
|
|
2680
2935
|
reject(new SecureFileCustodyError("unavailable", "The installed Windows Host securefs command could not run."));
|
|
@@ -2765,21 +3020,21 @@ function decodeHostProducerConfigText(descriptor, text, platform = process.platf
|
|
|
2765
3020
|
const { extra_paths: extras, ...core } = decoded;
|
|
2766
3021
|
return Object.freeze(descriptor.config({ schema_version: descriptor.schema, ...core }, extras));
|
|
2767
3022
|
}
|
|
2768
|
-
async function serveHostProducer(descriptor, config, signal, dependencies
|
|
3023
|
+
async function serveHostProducer(descriptor, config, signal, dependencies) {
|
|
2769
3024
|
const runtimeOptions = descriptor.runtime_options(config);
|
|
2770
3025
|
const serving = serveProducer(runtimeOptions, config, signal, dependencies.drain ?? descriptor.drain, dependencies.wait);
|
|
2771
3026
|
if (descriptor.background === void 0 || dependencies.drain !== void 0) {
|
|
2772
3027
|
await serving;
|
|
2773
3028
|
return;
|
|
2774
3029
|
}
|
|
2775
|
-
const background = descriptor.background(config, signal);
|
|
3030
|
+
const background = descriptor.background(config, signal, dependencies);
|
|
2776
3031
|
await Promise.all([serving, background]);
|
|
2777
3032
|
}
|
|
2778
3033
|
function hostProducerRegistrationStateFile(outboxDirectory, platform = process.platform) {
|
|
2779
3034
|
const path = platform === "win32" ? win324 : posix3;
|
|
2780
3035
|
return path.join(path.resolve(outboxDirectory, "../../../../.."), "registration.json");
|
|
2781
3036
|
}
|
|
2782
|
-
async function runHostProducerCli(descriptor, args, signal, dependencies
|
|
3037
|
+
async function runHostProducerCli(descriptor, args, signal, dependencies) {
|
|
2783
3038
|
await serveHostProducer(descriptor, await readHostProducerConfig(descriptor, parseHostProducerServeArgs(args)), signal, dependencies);
|
|
2784
3039
|
}
|
|
2785
3040
|
function hostProducerError(code2, message = code2) {
|
|
@@ -2919,7 +3174,7 @@ function parseCanonicalJson(text, error) {
|
|
|
2919
3174
|
if (canonical !== text.trim()) throw new Error(`noncanonical: ${refusalFacts([{ name: "config_bytes", value: Buffer.byteLength(text.trim(), "utf8"), expected: `the ${Buffer.byteLength(canonical, "utf8")} bytes of its canonical form` }, { name: "first_difference_index", value: firstDifferenceIndex(text.trim(), canonical) }])}`);
|
|
2920
3175
|
return value;
|
|
2921
3176
|
} catch (parseError) {
|
|
2922
|
-
throw error("invalid_config",
|
|
3177
|
+
throw error("invalid_config", `parse_error=${renderOperatorDiagnostic(parseError)}; ${refusalFact("config_bytes", Buffer.byteLength(text, "utf8"), "canonical JSON")}`);
|
|
2923
3178
|
}
|
|
2924
3179
|
}
|
|
2925
3180
|
function firstDifferenceIndex(left, right) {
|
|
@@ -3534,14 +3789,14 @@ var HostUsageFactsStore = class {
|
|
|
3534
3789
|
const gate = new Promise((resolve) => {
|
|
3535
3790
|
release = resolve;
|
|
3536
3791
|
});
|
|
3537
|
-
const
|
|
3538
|
-
SESSION_TRANSITION_TAILS.set(key,
|
|
3792
|
+
const tail2 = previous.then(() => gate);
|
|
3793
|
+
SESSION_TRANSITION_TAILS.set(key, tail2);
|
|
3539
3794
|
await previous;
|
|
3540
3795
|
try {
|
|
3541
3796
|
return await run();
|
|
3542
3797
|
} finally {
|
|
3543
3798
|
release?.();
|
|
3544
|
-
if (SESSION_TRANSITION_TAILS.get(key) ===
|
|
3799
|
+
if (SESSION_TRANSITION_TAILS.get(key) === tail2) SESSION_TRANSITION_TAILS.delete(key);
|
|
3545
3800
|
}
|
|
3546
3801
|
}
|
|
3547
3802
|
sessionPath(producer, hostSourceRef, hostSessionRef) {
|
|
@@ -4065,7 +4320,7 @@ var HostUsageFactsUploader = class {
|
|
|
4065
4320
|
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);
|
|
4066
4321
|
const timeout = AbortSignal.timeout(this.options.timeout_ms ?? 5e3);
|
|
4067
4322
|
const requestSignal = signal === void 0 ? timeout : AbortSignal.any([signal, timeout]);
|
|
4068
|
-
const response2 = await
|
|
4323
|
+
const response2 = await this.options.fetch(`${registration.gateway_request_origin}${CEAL_HOST_USAGE_INGRESS_PATH}`, {
|
|
4069
4324
|
method: "POST",
|
|
4070
4325
|
headers: { authorization: `Bearer ${registration.host_access_token}`, "content-type": "application/json" },
|
|
4071
4326
|
body: JSON.stringify(candidate.batch),
|
|
@@ -4154,9 +4409,9 @@ async function readTranscriptCompleteChunk(handle, offset, size) {
|
|
|
4154
4409
|
let lastNewline = -1;
|
|
4155
4410
|
while (position < size) {
|
|
4156
4411
|
const buffer = Buffer.alloc(Math.min(HOST_TRANSCRIPT_READ_CHUNK_BYTES, size - position));
|
|
4157
|
-
const
|
|
4158
|
-
if (
|
|
4159
|
-
const chunk = buffer.subarray(0,
|
|
4412
|
+
const read2 = await handle.read(buffer, 0, buffer.length, position);
|
|
4413
|
+
if (read2.bytesRead === 0) break;
|
|
4414
|
+
const chunk = buffer.subarray(0, read2.bytesRead);
|
|
4160
4415
|
chunks.push(chunk);
|
|
4161
4416
|
const newline = chunk.lastIndexOf(10);
|
|
4162
4417
|
if (newline >= 0) lastNewline = total + newline;
|
|
@@ -4213,7 +4468,7 @@ function createTranscriptWatcherBase(options, owner) {
|
|
|
4213
4468
|
outboxRetentionMs: options.retention_ms ?? owner.default_retention_ms,
|
|
4214
4469
|
now: options.now ?? (() => /* @__PURE__ */ new Date()),
|
|
4215
4470
|
log: options.log ?? ((line) => {
|
|
4216
|
-
|
|
4471
|
+
writeHostServiceLogLine(`${line}
|
|
4217
4472
|
`);
|
|
4218
4473
|
}),
|
|
4219
4474
|
producerInstallationRef: options.producer_installation_ref
|
|
@@ -4253,7 +4508,13 @@ var HostTranscriptWatcher = class {
|
|
|
4253
4508
|
}
|
|
4254
4509
|
async scanRegistration(registration) {
|
|
4255
4510
|
return this.openTranscript(registration, (handle) => this.scanOpened(handle, registration), {
|
|
4256
|
-
missing: () =>
|
|
4511
|
+
missing: async () => {
|
|
4512
|
+
try {
|
|
4513
|
+
return await this.retireMissing(registration);
|
|
4514
|
+
} catch (error) {
|
|
4515
|
+
return this.scanFailed(void 0, registration, error);
|
|
4516
|
+
}
|
|
4517
|
+
},
|
|
4257
4518
|
failed: (handle, error) => this.scanFailed(handle, registration, error)
|
|
4258
4519
|
});
|
|
4259
4520
|
}
|
|
@@ -4323,15 +4584,15 @@ var HostProducerDrainCore = class {
|
|
|
4323
4584
|
return run;
|
|
4324
4585
|
}
|
|
4325
4586
|
async drainLocked() {
|
|
4326
|
-
const
|
|
4587
|
+
const read2 = await this.host.listEnvelopes();
|
|
4327
4588
|
let removed = 0;
|
|
4328
4589
|
let expired = 0;
|
|
4329
|
-
for (const envelope of
|
|
4590
|
+
for (const envelope of read2.entries) {
|
|
4330
4591
|
if (Date.parse(this.host.expiresAtOf(envelope)) <= this.now().getTime()) expired += 1;
|
|
4331
4592
|
else removed += 1;
|
|
4332
4593
|
await this.host.removeEnvelope(envelope);
|
|
4333
4594
|
}
|
|
4334
|
-
return { removed, expired, malformed:
|
|
4595
|
+
return { removed, expired, malformed: read2.malformed };
|
|
4335
4596
|
}
|
|
4336
4597
|
};
|
|
4337
4598
|
|
|
@@ -4415,29 +4676,46 @@ var HostUsageTranscriptSourceError = class extends Error {
|
|
|
4415
4676
|
this.name = "HostUsageTranscriptSourceError";
|
|
4416
4677
|
}
|
|
4417
4678
|
};
|
|
4418
|
-
async function readHostUsageTranscriptSource(
|
|
4679
|
+
async function readHostUsageTranscriptSource(read2) {
|
|
4419
4680
|
try {
|
|
4420
|
-
return await
|
|
4681
|
+
return await read2();
|
|
4421
4682
|
} catch (error) {
|
|
4422
4683
|
throw new HostUsageTranscriptSourceError({ cause: error });
|
|
4423
4684
|
}
|
|
4424
4685
|
}
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4686
|
+
var HostUsageRegistrationCapture = class {
|
|
4687
|
+
nextIndex = 0;
|
|
4688
|
+
producer;
|
|
4689
|
+
diagnosticSink;
|
|
4690
|
+
constructor(producer, diagnosticSink) {
|
|
4691
|
+
this.producer = producer;
|
|
4692
|
+
this.diagnosticSink = diagnosticSink;
|
|
4693
|
+
}
|
|
4694
|
+
async captureNext(registrations, capture) {
|
|
4695
|
+
let failed = false;
|
|
4696
|
+
let captured = false;
|
|
4697
|
+
const onFailure = () => {
|
|
4436
4698
|
failed = true;
|
|
4699
|
+
};
|
|
4700
|
+
for (let attempt = 0; attempt < registrations.length; attempt += 1) {
|
|
4701
|
+
const index = (this.nextIndex + attempt) % registrations.length;
|
|
4702
|
+
const registration = registrations[index];
|
|
4703
|
+
if (registration === void 0) continue;
|
|
4704
|
+
try {
|
|
4705
|
+
captured = await capture(registration, onFailure);
|
|
4706
|
+
if (captured) {
|
|
4707
|
+
this.nextIndex = (index + 1) % registrations.length;
|
|
4708
|
+
break;
|
|
4709
|
+
}
|
|
4710
|
+
} catch (error) {
|
|
4711
|
+
if (!(error instanceof HostUsageTranscriptSourceError)) throw error;
|
|
4712
|
+
onFailure();
|
|
4713
|
+
}
|
|
4437
4714
|
}
|
|
4715
|
+
if (failed) writeHostServiceDiagnostic(this.producer, "usage_capture_failed", void 0, "capture_failed", this.diagnosticSink);
|
|
4716
|
+
return captured;
|
|
4438
4717
|
}
|
|
4439
|
-
|
|
4440
|
-
}
|
|
4718
|
+
};
|
|
4441
4719
|
async function openHostUsageTranscriptCursor(input) {
|
|
4442
4720
|
const handle = await readHostUsageTranscriptSource(() => openNoFollow(input.path, constants5.O_RDONLY));
|
|
4443
4721
|
let source;
|
|
@@ -4736,6 +5014,13 @@ var ClaudeOutboxStore = class {
|
|
|
4736
5014
|
await this.removeStateFile(this.registrationPath(registration.host_source_ref, registration.host_session_ref));
|
|
4737
5015
|
await this.removeStateFile(this.cursorPath(registration.host_source_ref, registration.host_session_ref));
|
|
4738
5016
|
}
|
|
5017
|
+
async readTranscriptRegistration(hostSourceRef, hostSessionRef) {
|
|
5018
|
+
if (!SAFE_REF3.test(hostSourceRef) || !SAFE_REF3.test(hostSessionRef)) throw new ClaudeHostError("invalid_input", "Claude transcript session identity is invalid.");
|
|
5019
|
+
await this.prepare();
|
|
5020
|
+
const registration = await this.readRegistrationFile(this.registrationPath(hostSourceRef, hostSessionRef));
|
|
5021
|
+
if (registration !== null && (registration.host_source_ref !== hostSourceRef || registration.host_session_ref !== hostSessionRef)) throw new ClaudeHostError("storage", "Claude transcript registration identity does not match its session.");
|
|
5022
|
+
return registration;
|
|
5023
|
+
}
|
|
4739
5024
|
async listTranscriptRegistrations() {
|
|
4740
5025
|
await this.prepare();
|
|
4741
5026
|
const registrations = [];
|
|
@@ -5005,6 +5290,7 @@ var ClaudeProducer = class {
|
|
|
5005
5290
|
|
|
5006
5291
|
// host/claude/src/claude-transcript-watcher.ts
|
|
5007
5292
|
import { readdir as readdir2 } from "node:fs/promises";
|
|
5293
|
+
import { isDeepStrictEqual } from "node:util";
|
|
5008
5294
|
import { join as join5 } from "node:path";
|
|
5009
5295
|
|
|
5010
5296
|
// host/claude/src/claude-decoder.ts
|
|
@@ -5090,10 +5376,39 @@ function record4(value) {
|
|
|
5090
5376
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
5091
5377
|
}
|
|
5092
5378
|
|
|
5379
|
+
// host/claude/src/claude-subagent-overflow-checkpoint.ts
|
|
5380
|
+
var ClaudeSubagentOverflowCheckpoint = class {
|
|
5381
|
+
observed = /* @__PURE__ */ new Map();
|
|
5382
|
+
prune(registrations) {
|
|
5383
|
+
const current = new Set(registrations.map(registrationKey));
|
|
5384
|
+
for (const key of this.observed.keys()) if (!current.has(key)) this.observed.delete(key);
|
|
5385
|
+
}
|
|
5386
|
+
clear(registration) {
|
|
5387
|
+
this.observed.delete(registrationKey(registration));
|
|
5388
|
+
}
|
|
5389
|
+
/** Names follow the producer's sorted inventory; only omitted names define overflow. */
|
|
5390
|
+
async observe(registration, names, report) {
|
|
5391
|
+
const key = registrationKey(registration);
|
|
5392
|
+
if (names.length <= CLAUDE_TRANSCRIPT_MAX_SUBAGENT_FILES) {
|
|
5393
|
+
this.clear(registration);
|
|
5394
|
+
return false;
|
|
5395
|
+
}
|
|
5396
|
+
const digest = transcriptObjectSha256(names.slice(CLAUDE_TRANSCRIPT_MAX_SUBAGENT_FILES));
|
|
5397
|
+
if (this.observed.get(key) === digest) return false;
|
|
5398
|
+
if (!await report()) return false;
|
|
5399
|
+
this.observed.set(key, digest);
|
|
5400
|
+
return true;
|
|
5401
|
+
}
|
|
5402
|
+
};
|
|
5403
|
+
function registrationKey(registration) {
|
|
5404
|
+
return JSON.stringify([registration.host_source_ref, registration.host_session_ref, registration.transcript_path]);
|
|
5405
|
+
}
|
|
5406
|
+
|
|
5093
5407
|
// host/claude/src/claude-transcript-watcher.ts
|
|
5094
5408
|
var TOKEN_OBSERVATION_SOURCE = "claude_transcript.message.usage";
|
|
5095
5409
|
var ClaudeTranscriptWatcher = class extends HostTranscriptWatcher {
|
|
5096
5410
|
store;
|
|
5411
|
+
overflow = new ClaudeSubagentOverflowCheckpoint();
|
|
5097
5412
|
diagnostic;
|
|
5098
5413
|
constructor(options) {
|
|
5099
5414
|
super(options, {
|
|
@@ -5108,17 +5423,21 @@ var ClaudeTranscriptWatcher = class extends HostTranscriptWatcher {
|
|
|
5108
5423
|
return registration.transcript_path;
|
|
5109
5424
|
}
|
|
5110
5425
|
async listRegistrations() {
|
|
5111
|
-
|
|
5426
|
+
const registrations = await this.store.listTranscriptRegistrations();
|
|
5427
|
+
this.overflow.prune(registrations);
|
|
5428
|
+
return registrations;
|
|
5112
5429
|
}
|
|
5113
5430
|
async scanOpened(handle, registration) {
|
|
5114
5431
|
const { size, device, inode } = await ownedClaudeTranscriptFile(handle);
|
|
5115
|
-
const
|
|
5432
|
+
const preflight = await this.preflight(registration, handle, size, device, inode);
|
|
5433
|
+
const cursor = preflight.cursor;
|
|
5116
5434
|
if (cursor === null) return { records: 0, enqueued: 0, quarantined: true };
|
|
5117
5435
|
if (cursor.status === "quarantined") {
|
|
5118
5436
|
return { records: 0, enqueued: 0, quarantined: true };
|
|
5119
5437
|
}
|
|
5438
|
+
if (preflight.checkpointPending) await this.store.writeTranscriptCursor({ ...cursor, updated_at: this.stamp() });
|
|
5120
5439
|
const draft = mutableCursor(cursor);
|
|
5121
|
-
await this.scanOpenedTranscript(registration, handle, draft, size, device, inode);
|
|
5440
|
+
await this.scanOpenedTranscript(registration, handle, cursor, draft, size, device, inode);
|
|
5122
5441
|
return { records: draft.consumed, enqueued: draft.enqueued, quarantined: false };
|
|
5123
5442
|
}
|
|
5124
5443
|
async scanFailed(handle, registration, error) {
|
|
@@ -5129,6 +5448,15 @@ var ClaudeTranscriptWatcher = class extends HostTranscriptWatcher {
|
|
|
5129
5448
|
return { records: 0, enqueued: 0, quarantined: true };
|
|
5130
5449
|
}
|
|
5131
5450
|
async retireMissing(registration) {
|
|
5451
|
+
const observedAt = this.stamp();
|
|
5452
|
+
if (Date.parse(registration.expires_at) <= Date.parse(observedAt)) return this.retireTranscript(registration);
|
|
5453
|
+
const cursor = await this.store.readTranscriptCursor(registration);
|
|
5454
|
+
if (cursor !== null && isUnmaterializedCursor(cursor, this.sha(Buffer.alloc(0)))) {
|
|
5455
|
+
return { records: 0, enqueued: 0, quarantined: false };
|
|
5456
|
+
}
|
|
5457
|
+
return this.retireTranscript(registration);
|
|
5458
|
+
}
|
|
5459
|
+
retireTranscript(registration) {
|
|
5132
5460
|
return this.retireMissingTranscript(registration.transcript_path, "Claude", () => this.store.retireTranscriptRegistration(registration));
|
|
5133
5461
|
}
|
|
5134
5462
|
initialCursor(registration) {
|
|
@@ -5146,7 +5474,7 @@ var ClaudeTranscriptWatcher = class extends HostTranscriptWatcher {
|
|
|
5146
5474
|
updated_at: this.stamp()
|
|
5147
5475
|
};
|
|
5148
5476
|
}
|
|
5149
|
-
async scanOpenedTranscript(registration, handle, draft, size, device, inode) {
|
|
5477
|
+
async scanOpenedTranscript(registration, handle, previous, draft, size, device, inode) {
|
|
5150
5478
|
const main = await this.readChunk(handle, draft.offset, size);
|
|
5151
5479
|
if (main !== "empty" && main !== "partial") {
|
|
5152
5480
|
await this.consumeMainChunk(registration, main, draft);
|
|
@@ -5154,20 +5482,22 @@ var ClaudeTranscriptWatcher = class extends HostTranscriptWatcher {
|
|
|
5154
5482
|
}
|
|
5155
5483
|
draft.consumed += await this.consumeSubagents(registration, draft);
|
|
5156
5484
|
await this.emitOpenTerminal(registration, draft);
|
|
5157
|
-
await this.commitCursor(registration, handle, draft, device, inode);
|
|
5485
|
+
await this.commitCursor(registration, handle, previous, draft, device, inode);
|
|
5158
5486
|
}
|
|
5159
5487
|
async preflight(registration, handle, size, device, inode) {
|
|
5160
5488
|
const existing = await this.store.readTranscriptCursor(registration);
|
|
5161
|
-
if (existing?.status === "quarantined") return existing;
|
|
5489
|
+
if (existing?.status === "quarantined") return { cursor: existing, checkpointPending: false };
|
|
5162
5490
|
const cursor = existing ?? this.initialCursor(registration);
|
|
5163
5491
|
if (cursor.device === void 0) {
|
|
5164
|
-
|
|
5165
|
-
|
|
5492
|
+
const pinned = { ...cursor, device, inode, human_message_window: cursor.human_message_window ?? { messages: [], truncated: false } };
|
|
5493
|
+
const reason2 = this.cursorIdentityReason(pinned, registration.transcript_path, device, inode);
|
|
5494
|
+
if (cursor.offset !== 0 || reason2 !== null) return { cursor: await this.quarantineStored(cursor, device, inode, "transcript_replaced"), checkpointPending: false };
|
|
5495
|
+
return { cursor: pinned, checkpointPending: true };
|
|
5166
5496
|
}
|
|
5167
5497
|
const reason = this.cursorIdentityReason(cursor, registration.transcript_path, device, inode) ?? await this.cursorBoundsReason(handle, cursor, size);
|
|
5168
|
-
if (reason !== null) return await this.quarantineStored(cursor, device, inode, reason);
|
|
5169
|
-
if (cursor.human_message_window !== void 0) return cursor;
|
|
5170
|
-
return { ...cursor, human_message_window: await this.readHumanMessageProjection(registration, handle, cursor.offset) };
|
|
5498
|
+
if (reason !== null) return { cursor: await this.quarantineStored(cursor, device, inode, reason), checkpointPending: false };
|
|
5499
|
+
if (cursor.human_message_window !== void 0) return { cursor, checkpointPending: false };
|
|
5500
|
+
return { cursor: { ...cursor, human_message_window: await this.readHumanMessageProjection(registration, handle, cursor.offset) }, checkpointPending: true };
|
|
5171
5501
|
}
|
|
5172
5502
|
async readHumanMessageProjection(registration, handle, watermark) {
|
|
5173
5503
|
let offset = 0;
|
|
@@ -5312,15 +5642,24 @@ var ClaudeTranscriptWatcher = class extends HostTranscriptWatcher {
|
|
|
5312
5642
|
try {
|
|
5313
5643
|
names = (await readdir2(directory)).filter((name) => name.endsWith(".jsonl") && !name.endsWith(".meta.json")).sort();
|
|
5314
5644
|
} catch (error) {
|
|
5315
|
-
if (isMissingTranscriptError(error) || isNotDirectory(error))
|
|
5645
|
+
if (isMissingTranscriptError(error) || isNotDirectory(error)) {
|
|
5646
|
+
this.overflow.clear(registration);
|
|
5647
|
+
return 0;
|
|
5648
|
+
}
|
|
5316
5649
|
throw new ClaudeHostError("payload_rejected", "Claude subagent transcript directory is unavailable.");
|
|
5317
5650
|
}
|
|
5318
5651
|
const listed = new Set(names);
|
|
5319
5652
|
for (const name of Object.keys(draft.subagents)) if (!listed.has(name)) delete draft.subagents[name];
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
|
|
5653
|
+
await this.overflow.observe(registration, names, () => {
|
|
5654
|
+
const line = `Claude ignored subagent transcripts past its file bound: transcript_path=${JSON.stringify(registration.transcript_path)}, files=${names.length}.`;
|
|
5655
|
+
try {
|
|
5656
|
+
this.log(line);
|
|
5657
|
+
} catch {
|
|
5658
|
+
return false;
|
|
5659
|
+
}
|
|
5660
|
+
return true;
|
|
5661
|
+
});
|
|
5662
|
+
names = names.slice(0, CLAUDE_TRANSCRIPT_MAX_SUBAGENT_FILES);
|
|
5324
5663
|
let consumed = 0;
|
|
5325
5664
|
for (const name of names) {
|
|
5326
5665
|
consumed += await this.consumeSubagentFile(draft, directory, name);
|
|
@@ -5409,9 +5748,9 @@ var ClaudeTranscriptWatcher = class extends HostTranscriptWatcher {
|
|
|
5409
5748
|
expires_at: this.expire(this.outboxRetentionMs)
|
|
5410
5749
|
});
|
|
5411
5750
|
}
|
|
5412
|
-
async commitCursor(registration, handle, draft, device, inode) {
|
|
5751
|
+
async commitCursor(registration, handle, previous, draft, device, inode) {
|
|
5413
5752
|
const anchor = await this.readAnchor(handle, draft.offset, CLAUDE_TRANSCRIPT_ANCHOR_BYTES);
|
|
5414
|
-
|
|
5753
|
+
const cursor = {
|
|
5415
5754
|
schema_version: CLAUDE_TRANSCRIPT_CURSOR_SCHEMA_VERSION,
|
|
5416
5755
|
host_source_ref: registration.host_source_ref,
|
|
5417
5756
|
host_session_ref: registration.host_session_ref,
|
|
@@ -5428,7 +5767,9 @@ var ClaudeTranscriptWatcher = class extends HostTranscriptWatcher {
|
|
|
5428
5767
|
...draft.session_observed ? { session_observed: true } : {},
|
|
5429
5768
|
status: "active",
|
|
5430
5769
|
updated_at: this.stamp()
|
|
5431
|
-
}
|
|
5770
|
+
};
|
|
5771
|
+
if (sameCursorContent(cursor, previous)) return;
|
|
5772
|
+
await this.store.writeTranscriptCursor(cursor);
|
|
5432
5773
|
}
|
|
5433
5774
|
async activateContext(identity, promptRef, turnGenerationRef, expiresAt) {
|
|
5434
5775
|
try {
|
|
@@ -5464,6 +5805,9 @@ var ClaudeTranscriptWatcher = class extends HostTranscriptWatcher {
|
|
|
5464
5805
|
return await this.store.readTranscriptCursor(registration).catch(() => null) ?? this.initialCursor(registration);
|
|
5465
5806
|
}
|
|
5466
5807
|
};
|
|
5808
|
+
function isUnmaterializedCursor(cursor, emptyAnchorSha256) {
|
|
5809
|
+
return cursor.status === "active" && cursor.device === void 0 && cursor.inode === void 0 && cursor.offset === 0 && cursor.anchor_start === 0 && cursor.anchor_sha256 === emptyAnchorSha256;
|
|
5810
|
+
}
|
|
5467
5811
|
function mutableCursor(cursor) {
|
|
5468
5812
|
return {
|
|
5469
5813
|
offset: cursor.offset,
|
|
@@ -5476,6 +5820,9 @@ function mutableCursor(cursor) {
|
|
|
5476
5820
|
enqueued: 0
|
|
5477
5821
|
};
|
|
5478
5822
|
}
|
|
5823
|
+
function sameCursorContent(left, right) {
|
|
5824
|
+
return isDeepStrictEqual({ ...left, updated_at: void 0 }, { ...right, updated_at: void 0 });
|
|
5825
|
+
}
|
|
5479
5826
|
function zeroCounts() {
|
|
5480
5827
|
return { input: 0, cached_input: 0, cache_write_input: 0, output: 0 };
|
|
5481
5828
|
}
|
|
@@ -5606,11 +5953,14 @@ function isSymlinkTranscript(error) {
|
|
|
5606
5953
|
}
|
|
5607
5954
|
|
|
5608
5955
|
// host/claude/src/claude-producer-runtime.ts
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
outbox_dir:
|
|
5956
|
+
function createClaudeProducerWatcher(outboxDir) {
|
|
5957
|
+
return new ClaudeTranscriptWatcher({
|
|
5958
|
+
outbox_dir: outboxDir,
|
|
5612
5959
|
diagnostic: (event, failure_kind, cause) => writeHostServiceDiagnostic("claude", event, failure_kind, cause)
|
|
5613
|
-
})
|
|
5960
|
+
});
|
|
5961
|
+
}
|
|
5962
|
+
async function drainClaudeProducerOnce(options) {
|
|
5963
|
+
const scan = await (options.watcher ?? createClaudeProducerWatcher(options.outbox_dir)).scanOnce().catch((error) => {
|
|
5614
5964
|
writeHostServiceDiagnostic("claude", "watcher_scan_failed", claudeTranscriptScanFailureKind(error), claudeTranscriptScanCause(void 0, error));
|
|
5615
5965
|
throw error;
|
|
5616
5966
|
});
|
|
@@ -5627,25 +5977,20 @@ var ClaudeUsageFactsCapturer = class {
|
|
|
5627
5977
|
sources;
|
|
5628
5978
|
usage;
|
|
5629
5979
|
now;
|
|
5630
|
-
|
|
5631
|
-
nextRegistrationIndex = 0;
|
|
5980
|
+
registrations;
|
|
5632
5981
|
nextSourceSlot = "main";
|
|
5633
5982
|
nextSubagentIndex = 0;
|
|
5983
|
+
overflow = new ClaudeSubagentOverflowCheckpoint();
|
|
5634
5984
|
constructor(options) {
|
|
5635
5985
|
this.sources = new ClaudeOutboxStore(options.outbox_dir);
|
|
5636
5986
|
this.usage = new HostUsageFactsStore({ outbox_dir: options.outbox_dir, ...options.store_options });
|
|
5637
5987
|
this.now = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
5638
|
-
this.
|
|
5988
|
+
this.registrations = new HostUsageRegistrationCapture("claude", options.diagnostic_sink);
|
|
5639
5989
|
}
|
|
5640
5990
|
async captureNext() {
|
|
5641
5991
|
const registrations = await this.sources.listTranscriptRegistrations();
|
|
5642
|
-
|
|
5643
|
-
|
|
5644
|
-
failed = true;
|
|
5645
|
-
}));
|
|
5646
|
-
this.nextRegistrationIndex = result.nextIndex;
|
|
5647
|
-
if (failed || result.failed) writeHostServiceDiagnostic("claude", "usage_capture_failed", void 0, "capture_failed", this.diagnosticSink);
|
|
5648
|
-
return result.captured;
|
|
5992
|
+
this.overflow.prune(registrations);
|
|
5993
|
+
return await this.registrations.captureNext(registrations, (registration, onFailure) => this.captureRegistration(registration, onFailure));
|
|
5649
5994
|
}
|
|
5650
5995
|
async captureRegistration(registration, onFailure) {
|
|
5651
5996
|
const sources = this.nextSourceSlot === "main" ? ["main", "subagent"] : ["subagent", "main"];
|
|
@@ -5692,13 +6037,14 @@ var ClaudeUsageFactsCapturer = class {
|
|
|
5692
6037
|
}
|
|
5693
6038
|
async captureSubagent(registration, onFailure) {
|
|
5694
6039
|
const names = await readSubagentNames(registration);
|
|
6040
|
+
if (names.length <= CLAUDE_TRANSCRIPT_MAX_SUBAGENT_FILES) this.overflow.clear(registration);
|
|
5695
6041
|
let state = await this.usage.readState("claude", registration.host_source_ref, registration.host_session_ref);
|
|
5696
6042
|
if (state === null) return false;
|
|
5697
6043
|
state = await this.usage.recoverPending(state);
|
|
5698
6044
|
if (state.quarantined_reason !== void 0) return false;
|
|
5699
6045
|
if (await this.retireMissingSubagent(state, names)) return true;
|
|
5700
6046
|
if (await this.captureListedSubagents(registration, names, state, onFailure)) return true;
|
|
5701
|
-
return await this.recordExcessSubagentGap(state, names);
|
|
6047
|
+
return await this.recordExcessSubagentGap(registration, state, names);
|
|
5702
6048
|
}
|
|
5703
6049
|
async retireMissingSubagent(state, names) {
|
|
5704
6050
|
const liveSlots = new Set(names.slice(0, CLAUDE_TRANSCRIPT_MAX_SUBAGENT_FILES).map(subagentSlot));
|
|
@@ -5709,14 +6055,14 @@ var ClaudeUsageFactsCapturer = class {
|
|
|
5709
6055
|
}
|
|
5710
6056
|
return false;
|
|
5711
6057
|
}
|
|
5712
|
-
async recordExcessSubagentGap(state, names) {
|
|
5713
|
-
const excessCount = names.length - CLAUDE_TRANSCRIPT_MAX_SUBAGENT_FILES;
|
|
5714
|
-
if (excessCount <= 0) return false;
|
|
6058
|
+
async recordExcessSubagentGap(registration, state, names) {
|
|
5715
6059
|
const mainCursor = state.cursors.main;
|
|
5716
6060
|
if (mainCursor === void 0) return false;
|
|
5717
|
-
|
|
5718
|
-
|
|
5719
|
-
|
|
6061
|
+
return await this.overflow.observe(registration, names, async () => {
|
|
6062
|
+
const gap = { reason: "unsupported_source_shape", source_file_ref: null, start_offset: null, end_offset: null, omitted_count: names.length - CLAUDE_TRANSCRIPT_MAX_SUBAGENT_FILES };
|
|
6063
|
+
await this.usage.commitScanTransition(state, "main", mainCursor, mainCursor, null, [gap]);
|
|
6064
|
+
return true;
|
|
6065
|
+
});
|
|
5720
6066
|
}
|
|
5721
6067
|
async captureListedSubagents(registration, names, state, onFailure) {
|
|
5722
6068
|
const candidates = names.slice(0, CLAUDE_TRANSCRIPT_MAX_SUBAGENT_FILES);
|
|
@@ -5990,6 +6336,7 @@ function sha2563(value) {
|
|
|
5990
6336
|
}
|
|
5991
6337
|
|
|
5992
6338
|
// host/claude/src/claude-producer-service.ts
|
|
6339
|
+
var CLAUDE_PRODUCER_COMMAND_SCHEMA = "ceal.claude_producer_command.v1";
|
|
5993
6340
|
var CLAUDE_PRODUCER_CONFIG_SCHEMA = "ceal.claude_producer_config.v1";
|
|
5994
6341
|
var CLAUDE_TRANSCRIPTS_ROOT = "claude_transcripts_root";
|
|
5995
6342
|
var CLAUDE_PRODUCER_DESCRIPTOR = {
|
|
@@ -5997,14 +6344,14 @@ var CLAUDE_PRODUCER_DESCRIPTOR = {
|
|
|
5997
6344
|
producer_id: "claude",
|
|
5998
6345
|
extra_paths: [CLAUDE_TRANSCRIPTS_ROOT],
|
|
5999
6346
|
config: (shared, extras) => ({ ...shared, claude_transcripts_root: hostProducerExtraPath(extras, CLAUDE_TRANSCRIPTS_ROOT) }),
|
|
6000
|
-
runtime_options: (config) => Object.freeze({ outbox_dir: config.outbox_dir }),
|
|
6347
|
+
runtime_options: (config) => Object.freeze({ outbox_dir: config.outbox_dir, watcher: createClaudeProducerWatcher(config.outbox_dir) }),
|
|
6001
6348
|
drain: drainClaudeProducerOnce,
|
|
6002
|
-
background: (config, signal) => {
|
|
6349
|
+
background: (config, signal, dependencies) => {
|
|
6003
6350
|
const capturer = new ClaudeUsageFactsCapturer({ outbox_dir: config.outbox_dir });
|
|
6004
|
-
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);
|
|
6351
|
+
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);
|
|
6005
6352
|
}
|
|
6006
6353
|
};
|
|
6007
|
-
function runClaudeProducerCli(args, signal, dependencies
|
|
6354
|
+
function runClaudeProducerCli(args, signal, dependencies) {
|
|
6008
6355
|
return runHostProducerCli(CLAUDE_PRODUCER_DESCRIPTOR, args, signal, dependencies);
|
|
6009
6356
|
}
|
|
6010
6357
|
|
|
@@ -6031,4 +6378,4 @@ async function runProducerCommand(schemaVersion, run) {
|
|
|
6031
6378
|
}
|
|
6032
6379
|
|
|
6033
6380
|
// host/claude/bin/ceal-claude-producer.ts
|
|
6034
|
-
await runProducerCommand(
|
|
6381
|
+
await runProducerCommand(CLAUDE_PRODUCER_COMMAND_SCHEMA, (args, signal) => runClaudeProducerCli(args, signal, { fetch: globalThis.fetch }));
|