@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.
- package/bin/ceal-host.exe +0 -0
- package/libexec/ceal-host/ceal-host-background.exe +0 -0
- package/libexec/ceal-host/claude-hook.mjs +288 -250
- package/libexec/ceal-host/claude-invocation-authentication.mjs +336 -266
- package/libexec/ceal-host/claude-producer.mjs +89 -51
- package/libexec/ceal-host/codex-hook.mjs +270 -250
- package/libexec/ceal-host/codex-invocation-authentication.mjs +320 -267
- package/libexec/ceal-host/codex-producer.mjs +72 -52
- package/libexec/ceal-host/control.mjs +134 -80
- package/libexec/ceal-host/relay.mjs +60 -46
- 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);
|
|
@@ -230,8 +239,11 @@ var client_wire_contract_default = {
|
|
|
230
239
|
"ok",
|
|
231
240
|
"code",
|
|
232
241
|
"reason",
|
|
233
|
-
"gateway_status"
|
|
242
|
+
"gateway_status",
|
|
243
|
+
"retry_after_ms"
|
|
234
244
|
],
|
|
245
|
+
refusal_required_fields: ["schema_version", "ok", "code", "reason"],
|
|
246
|
+
refusal_optional_fields: ["gateway_status", "retry_after_ms"],
|
|
235
247
|
client_nonce: {
|
|
236
248
|
character_class_source: "A-Za-z0-9_-",
|
|
237
249
|
encoded_characters: 43
|
|
@@ -450,11 +462,6 @@ var CEAL_OPERATION_WITHHELD_NEXT_ACTIONS = Object.freeze({
|
|
|
450
462
|
personal_authorization_required: "connect_personal_account"
|
|
451
463
|
});
|
|
452
464
|
|
|
453
|
-
// packages/ceal-client-protocol/src/vocabulary.ts
|
|
454
|
-
function vocabulary(words) {
|
|
455
|
-
return Object.freeze(words);
|
|
456
|
-
}
|
|
457
|
-
|
|
458
465
|
// packages/ceal-client-protocol/src/gateway-response-types.ts
|
|
459
466
|
var CEAL_OPERATION_READINESS_VALUES = vocabulary(["ready", "degraded", "unavailable", "unknown"]);
|
|
460
467
|
var CEAL_TARGET_REQUIREMENTS = vocabulary(["required", "optional", "none"]);
|
|
@@ -853,7 +860,7 @@ var GATEWAY_TRANSPORT_UNAVAILABLE = "The Gateway transport is unavailable; ask a
|
|
|
853
860
|
var HOST_AUTHENTICATION_UNAVAILABLE = "The Host could not authenticate this invocation; report this as a gap.";
|
|
854
861
|
var CLIENT_HOST_RELEASE_MISMATCH = "Install or upgrade the Ceal CLI and Host Relay to the same release as the Gateway, then retry.";
|
|
855
862
|
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
|
|
863
|
+
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
864
|
var SESSION_CONTEXT_UNAVAILABLE = "The local Gateway session context is unavailable.";
|
|
858
865
|
function guidance(message, next_action, http_status, retryable = false, redaction_class = "model_safe") {
|
|
859
866
|
return Object.freeze({ message, next_action, http_status, retryable, redaction_class });
|
|
@@ -905,14 +912,12 @@ var CEAL_FAILURE_GUIDANCE_TABLE = Object.freeze({
|
|
|
905
912
|
// `gateway_internal_error` guidance (decided with the operator 2026-10-13).
|
|
906
913
|
internal_error: guidance("The Gateway failed without exposing internal state.", "answer_with_gap", 500),
|
|
907
914
|
// Owned by the Gateway canonical adapter (`gateway/core/src/gateway-canonical-operation-http-adapter.ts`):
|
|
908
|
-
// the client variant
|
|
915
|
+
// the static client variant was retired when the client started reading this table.
|
|
909
916
|
request_body_too_large: guidance("The Gateway request body exceeds its bounded limit.", "reduce_request_size", 413),
|
|
910
917
|
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
|
-
// forbids the safe read retry the sentence exists to allow.
|
|
915
|
-
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),
|
|
918
|
+
// The safe move varies by request. Keep the sentence conditional on the
|
|
919
|
+
// same `retryable` and `next_action` facts the response exposes.
|
|
920
|
+
unknown_outcome: guidance("The transport outcome is unknown; use retryable and next_action to decide whether it can be repeated.", "answer_with_gap", 500),
|
|
916
921
|
// Restored verbatim from the retired `localFailureText`
|
|
917
922
|
// `refresh_unknown_outcome` case: a refresh that ends unknown leaves the
|
|
918
923
|
// session context unavailable, so the caller repairs or adopts the
|
|
@@ -993,8 +998,8 @@ var CEAL_FAILURE_GUIDANCE_TABLE = Object.freeze({
|
|
|
993
998
|
// Host mint classifications. The CLI emits `invocation_authentication_unavailable` with the classification
|
|
994
999
|
// in its detail fact; rows without their own sentence share that code's moved sentence, while `next_action`
|
|
995
1000
|
// is moved from `canonicalHostAuthenticationNextActions` (generated from `CEAL_HOST_AUTHENTICATION_POLICY`)
|
|
996
|
-
// and `retryable` from `hostAuthenticationFailureForCause` (
|
|
997
|
-
// sentences carry the
|
|
1001
|
+
// and `retryable` from `hostAuthenticationFailureForCause` (the table's explicit retry verdict). Cause-specific
|
|
1002
|
+
// sentences carry only remedies proved by the Host or Relay cause; generic Gateway refusals do not prove a release mismatch.
|
|
998
1003
|
// Statuses are the
|
|
999
1004
|
// Gateway-owned mapping decided with the operator 2026-10-13. This covers every wire cause the maps at
|
|
1000
1005
|
// `host/invocation-authentication-command.ts:217-242` emit, through their policy classifications.
|
|
@@ -1004,21 +1009,23 @@ var CEAL_FAILURE_GUIDANCE_TABLE = Object.freeze({
|
|
|
1004
1009
|
// The bounded Host reason does not prove ephemerality. A Host refusal never
|
|
1005
1010
|
// changes mode; standalone remains the separate Client authority path.
|
|
1006
1011
|
host_context_unavailable: guidance(HOST_CONTEXT_UNAVAILABLE, "answer_with_gap", 401),
|
|
1007
|
-
|
|
1008
|
-
|
|
1012
|
+
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),
|
|
1013
|
+
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),
|
|
1014
|
+
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
1015
|
host_source_refused: guidance(HOST_AUTHENTICATION_UNAVAILABLE, "answer_with_gap", 403),
|
|
1010
1016
|
host_registration_credential_refused: guidance(HOST_AUTHENTICATION_UNAVAILABLE, "ask_admin", 403),
|
|
1011
1017
|
host_mint_gateway_unavailable: guidance(HOST_AUTHENTICATION_UNAVAILABLE, "ask_admin", 503),
|
|
1012
1018
|
host_mint_gateway_rate_limited: guidance(HOST_AUTHENTICATION_UNAVAILABLE, "answer_with_gap", 429),
|
|
1013
|
-
host_mint_gateway_refused: guidance(
|
|
1019
|
+
host_mint_gateway_refused: guidance(HOST_AUTHENTICATION_UNAVAILABLE, "answer_with_gap", 502),
|
|
1014
1020
|
host_mint_gateway_response_invalid: guidance(HOST_AUTHENTICATION_UNAVAILABLE, "answer_with_gap", 502),
|
|
1021
|
+
host_contract_mismatch: guidance(CLIENT_HOST_RELEASE_MISMATCH, "upgrade_ceal_client", 502),
|
|
1015
1022
|
// Moved from the retired `CEAL_HOST_AUTHENTICATION_POLICY` remedy: the
|
|
1016
1023
|
// producer-frame fault names the administrator repair step.
|
|
1017
1024
|
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
1025
|
// Moved from the retired `CEAL_HOST_AUTHENTICATION_POLICY` remedy: the
|
|
1019
1026
|
// sandboxed Relay socket names the run-alone retry.
|
|
1020
1027
|
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(
|
|
1028
|
+
host_relay_unavailable: guidance(HOST_AUTHENTICATION_UNAVAILABLE, "answer_with_gap", 503),
|
|
1022
1029
|
host_mint_transient_retryable: guidance(HOST_AUTHENTICATION_UNAVAILABLE, "retry", 503, true),
|
|
1023
1030
|
host_mint_failed: guidance(HOST_AUTHENTICATION_UNAVAILABLE, "answer_with_gap", 500),
|
|
1024
1031
|
host_relay_failed: guidance(HOST_INSTALL_REPAIR, "install_ceal_host", 502),
|
|
@@ -1056,7 +1063,7 @@ var UNKNOWN_OUTCOMES = vocabulary(["reconcile", "operator_action", "excluded"]);
|
|
|
1056
1063
|
var RECOVERY_OWNERS = vocabulary(["gateway", "connector", "operator"]);
|
|
1057
1064
|
var CEAL_OPERATION_ADMISSION_STATES = vocabulary(["proposed", "refused", "admitted"]);
|
|
1058
1065
|
var CEAL_OPERATION_EXECUTION_STATES = vocabulary(["not_started", "started", "completed"]);
|
|
1059
|
-
var CEAL_OPERATION_PROVIDER_HANDOFF_STATES = vocabulary(["not_offered", "offered", "accepted", "rejected", "unknown"]);
|
|
1066
|
+
var CEAL_OPERATION_PROVIDER_HANDOFF_STATES = vocabulary(["not_applicable", "not_offered", "offered", "accepted", "rejected", "unknown"]);
|
|
1060
1067
|
var CEAL_OPERATION_EFFECT_STATES = vocabulary(["none", "applied", "failed", "unknown", "compensated"]);
|
|
1061
1068
|
var CEAL_OPERATION_OBSERVATION_STATES = vocabulary(["not_started", "not_required", "pending", "observed", "unavailable"]);
|
|
1062
1069
|
var CEAL_OPERATION_RECOVERY_KINDS = vocabulary(["none", "reconcile", "compensate", "operator_action"]);
|
|
@@ -1227,6 +1234,7 @@ var CEAL_OPERATION_ACCESS_CLASSES = vocabulary(["read", "write"]);
|
|
|
1227
1234
|
// packages/ceal-client-protocol/src/domain-vocabulary.ts
|
|
1228
1235
|
var CEAL_CONNECTOR_STATUSES = vocabulary(["active", "disabled", "disconnected"]);
|
|
1229
1236
|
var CEAL_CONNECTOR_CUSTODIES = vocabulary(["organization", "personal"]);
|
|
1237
|
+
var CEAL_PROVIDER_BOUNDARY_FIELDS = vocabulary(["provider_boundary_ref", "provider_boundary_kind", "provider_boundary_label", "provider_native_id", "provider_boundary_evidence"]);
|
|
1230
1238
|
var CEAL_PERSONAL_ACCESS_CEILINGS = vocabulary(["disabled", "read", "read_write"]);
|
|
1231
1239
|
var CEAL_TARGET_REF_PATTERN = "^[^\\p{Cc}]+$";
|
|
1232
1240
|
var TARGET_REF = new RegExp(CEAL_TARGET_REF_PATTERN, "u");
|
|
@@ -1272,7 +1280,7 @@ var JSON_DESCRIPTION_CONTROL_CHARACTER = new RegExp("\\p{Cc}", "u");
|
|
|
1272
1280
|
var CEAL_OPERATION_AUTHORITY_POLICY_KEYS = Object.freeze(["access_group", "instance_binding", "target", "admission_recheck"]);
|
|
1273
1281
|
var MAX_OPERATION_INPUT_RESOLVER_BINDINGS = 96;
|
|
1274
1282
|
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"]);
|
|
1283
|
+
var CEAL_OPERATION_DESCRIPTOR_OPTIONAL_ENVELOPE_KEYS = Object.freeze(["input_resolution", "summary", "standard_names"]);
|
|
1276
1284
|
|
|
1277
1285
|
// packages/ceal-client-protocol/src/operation-catalog.ts
|
|
1278
1286
|
var CEAL_OPERATION_CATALOG_SCHEMA_VERSION = "ceal.catalog.v3";
|
|
@@ -1368,6 +1376,7 @@ var CEAL_BOUNDED_SERIES_CATALOG = Object.freeze({
|
|
|
1368
1376
|
gateway_access_group_connector_activity_scope_audit: (root) => join(root, "profile-connector-activity-scope-audit.jsonl"),
|
|
1369
1377
|
gateway_access_group_connector_calendar_scope_audit: (root) => join(root, "profile-connector-calendar-scope-audit.jsonl"),
|
|
1370
1378
|
gateway_access_group_connector_readiness_audit: (root) => join(root, "profile-connector-readiness.audit.jsonl"),
|
|
1379
|
+
gateway_deployment_events: (root) => join(root, "gateway-deployments.jsonl"),
|
|
1371
1380
|
gateway_organization_audit_ledger: (root) => join(root, "organization-ledger.jsonl"),
|
|
1372
1381
|
gateway_personal_client_audit: (root) => join(root, "audit.jsonl"),
|
|
1373
1382
|
gateway_personal_client_access_audit: (root) => join(root, "access-audit.jsonl")
|
|
@@ -1394,6 +1403,11 @@ var CEAL_HOST_INSTALLATION_REF_PATTERN = new RegExp(`^host-installation:${CEAL_L
|
|
|
1394
1403
|
var CEAL_HOST_SOURCE_REF_PATTERN = new RegExp(`^host-source:${CEAL_LOWERCASE_UUID_PATTERN}$`, "u");
|
|
1395
1404
|
var CEAL_HOST_ACCESS_TOKEN_PATTERN = /^ceal_host_[A-Za-z0-9_-]{43}$/u;
|
|
1396
1405
|
|
|
1406
|
+
// packages/ceal-client-protocol/src/resource-read-result.ts
|
|
1407
|
+
var CEAL_RESOURCE_GET_NOTION_CONTENT_GAP_KINDS = Object.freeze(["subtree", "media", "property_schema", "properties"]);
|
|
1408
|
+
var CEAL_RESOURCE_SEARCH_PROVIDER_STATUSES = vocabulary(["done", "pending", "deferred"]);
|
|
1409
|
+
var CEAL_RESOURCE_GET_COVERAGE_NEXT_ACTIONS = vocabulary(["reduce_request_size", "read_resource_again"]);
|
|
1410
|
+
|
|
1397
1411
|
// packages/ceal-client-protocol/src/operation-result-completeness.ts
|
|
1398
1412
|
var CEAL_READ_VALUE_CONTINUATION_KEYS = vocabulary(["continuation", "continuation_ref", "next_cursor"]);
|
|
1399
1413
|
|
|
@@ -1478,6 +1492,7 @@ var PROVIDER_LINK_CONFORMANCE_TABLE = Object.freeze([
|
|
|
1478
1492
|
{ 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
1493
|
{ 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
1494
|
{ 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" },
|
|
1495
|
+
{ 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
1496
|
{ 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
1497
|
{ 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
1498
|
{ 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" },
|
|
@@ -1647,6 +1662,7 @@ var RESOURCE_ROW_KEY_RULES = Object.freeze({
|
|
|
1647
1662
|
created_at: { required: false, timestamp: true },
|
|
1648
1663
|
created_at_local: { required: false, timestamp: true },
|
|
1649
1664
|
modified_at: { required: false, timestamp: true },
|
|
1665
|
+
observed_at: { required: false, timestamp: true },
|
|
1650
1666
|
modified_at_local: { required: false, timestamp: true },
|
|
1651
1667
|
viewed_by_me_at: { required: false, timestamp: true },
|
|
1652
1668
|
modified_by_me_at: { required: false, timestamp: true },
|
|
@@ -1674,9 +1690,6 @@ var RESOURCE_ROW_REQUIRED_KEYS = Object.entries(RESOURCE_ROW_KEY_RULES).flatMap(
|
|
|
1674
1690
|
var RESOURCE_ROW_KEYS = new Set(Object.keys(RESOURCE_ROW_KEY_RULES));
|
|
1675
1691
|
var RESOURCE_ROW_TIMESTAMP_KEYS = Object.entries(RESOURCE_ROW_KEY_RULES).flatMap(([key, rule]) => rule.timestamp ? [key] : []);
|
|
1676
1692
|
|
|
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
1693
|
// packages/ceal-client-protocol/src/excluded-target-coverage.ts
|
|
1681
1694
|
var CEAL_EXCLUDED_TARGET_COVERAGE_MAX_ENTRIES = 64;
|
|
1682
1695
|
function cealExcludedTargetCoverageJsonSchema() {
|
|
@@ -1983,7 +1996,7 @@ function validateBatchContents(value) {
|
|
|
1983
1996
|
if (facts.length === 0 && gaps.length === 0 || facts.length > 0 && value.source_ranges.length === 0) invalid("Ceal Host usage coverage is invalid.");
|
|
1984
1997
|
const sourceFiles = new Set(value.source_ranges.map((range) => sourceRangeFileRef(range)));
|
|
1985
1998
|
for (const fact of facts) {
|
|
1986
|
-
|
|
1999
|
+
validateCealHostUsageFact(fact, value.host_session_ref);
|
|
1987
2000
|
if (!sourceFiles.has(fact.source_file_ref)) invalid("Ceal Host usage fact is outside its source ranges.");
|
|
1988
2001
|
}
|
|
1989
2002
|
for (const gap of gaps) {
|
|
@@ -2016,7 +2029,7 @@ function hostUsageSourceFileReference(producer, hostSourceRef, hostSessionRef, d
|
|
|
2016
2029
|
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
2030
|
return `host-source-file:${sha256(JSON.stringify({ producer, host_source_ref: hostSourceRef, host_session_ref: hostSessionRef, device, inode }))}`;
|
|
2018
2031
|
}
|
|
2019
|
-
function
|
|
2032
|
+
function validateCealHostUsageFact(value, sessionRef) {
|
|
2020
2033
|
if (!isOperationRecord(value)) invalid("Ceal Host usage fact is invalid.");
|
|
2021
2034
|
requireFactByteLimit(value);
|
|
2022
2035
|
if (value.producer === "codex_transcript") validateCodexFact(value);
|
|
@@ -2080,7 +2093,7 @@ function validCorrectionSemantics(value) {
|
|
|
2080
2093
|
}
|
|
2081
2094
|
function validateCodexUsageCounts(value) {
|
|
2082
2095
|
if (!isOperationRecord(value)) invalid("Ceal Codex usage fields are invalid.");
|
|
2083
|
-
requireExactOperationKeys(value,
|
|
2096
|
+
requireExactOperationKeys(value, CEAL_CODEX_USAGE_COUNT_FIELDS);
|
|
2084
2097
|
for (const key of Object.keys(value)) if (!safeInteger(value[key])) invalid("Ceal Codex usage fields are invalid.");
|
|
2085
2098
|
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
2099
|
}
|
|
@@ -2348,6 +2361,7 @@ var CEAL_HOST_AUTHENTICATION_CAUSES = vocabulary([
|
|
|
2348
2361
|
"options_invalid",
|
|
2349
2362
|
"session_unavailable",
|
|
2350
2363
|
"context_unavailable",
|
|
2364
|
+
"activation_wait_exhausted",
|
|
2351
2365
|
"context_replaced",
|
|
2352
2366
|
"no_binding",
|
|
2353
2367
|
"context_expired",
|
|
@@ -2383,22 +2397,23 @@ var CEAL_HOST_AUTHENTICATION_POLICY = Object.freeze({
|
|
|
2383
2397
|
// This reason cannot distinguish a Codex side conversation from a missing
|
|
2384
2398
|
// context in a regular session, so guidance must leave that choice to the caller.
|
|
2385
2399
|
context_unavailable: Object.freeze({ classification: "host_context_unavailable", next_action: "answer_with_gap" }),
|
|
2386
|
-
|
|
2400
|
+
activation_wait_exhausted: Object.freeze({ classification: "host_context_activation_wait_exhausted", next_action: "retry_after" }),
|
|
2401
|
+
context_replaced: Object.freeze({ classification: "host_invocation_context_stale", next_action: "answer_with_gap" }),
|
|
2387
2402
|
// `no_binding` now means the producer has no real current Host session. The
|
|
2388
2403
|
// Host Relay never uses it for an uncreated Gateway Request; there is no
|
|
2389
2404
|
// useful retry until the consumer is running inside a Host session.
|
|
2390
2405
|
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: "
|
|
2406
|
+
context_expired: Object.freeze({ classification: "host_invocation_context_expired", next_action: "answer_with_gap" }),
|
|
2392
2407
|
host_source_refused: Object.freeze({ classification: "host_source_refused", next_action: "answer_with_gap" }),
|
|
2393
2408
|
host_credential_refused: Object.freeze({ classification: "host_registration_credential_refused", next_action: "ask_admin" }),
|
|
2394
2409
|
gateway_unavailable: Object.freeze({ classification: "host_mint_gateway_unavailable", next_action: "ask_admin" }),
|
|
2395
2410
|
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: "
|
|
2411
|
+
contract_mismatch: Object.freeze({ classification: "host_contract_mismatch", next_action: "upgrade_ceal_client" }),
|
|
2412
|
+
gateway_refused: Object.freeze({ classification: "host_mint_gateway_refused", next_action: "answer_with_gap" }),
|
|
2398
2413
|
gateway_response_invalid: Object.freeze({ classification: "host_mint_gateway_response_invalid", next_action: "answer_with_gap" }),
|
|
2399
2414
|
producer_frame_invalid: Object.freeze({ classification: "host_producer_frame_invalid", next_action: "ask_admin" }),
|
|
2400
2415
|
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: "
|
|
2416
|
+
relay_unavailable: Object.freeze({ classification: "host_relay_unavailable", next_action: "answer_with_gap" }),
|
|
2402
2417
|
transient_retryable: Object.freeze({ classification: "host_mint_transient_retryable", next_action: "retry" }),
|
|
2403
2418
|
mint_failed: Object.freeze({ classification: "host_mint_failed", next_action: "answer_with_gap" }),
|
|
2404
2419
|
relay_failed: Object.freeze({ classification: "host_relay_failed", next_action: "install_ceal_host" }),
|
|
@@ -2446,7 +2461,7 @@ function isCealHostServiceDiagnosticCause(value, event) {
|
|
|
2446
2461
|
// packages/ceal-client-protocol/src/client-result-materialization.ts
|
|
2447
2462
|
var CEAL_UNREAD_REASONS = vocabulary(["blocked", "unavailable", "too_large", "unsupported", "download_failed", "permission_denied"]);
|
|
2448
2463
|
var REQUIRED_FIELDS2 = Object.freeze(["schema_version", "operation_id", "path", "sha256"]);
|
|
2449
|
-
var FIELDS = /* @__PURE__ */ new Set([...REQUIRED_FIELDS2, "
|
|
2464
|
+
var FIELDS = /* @__PURE__ */ new Set([...REQUIRED_FIELDS2, "local_result_root", "request_context_argv", "how_to_read"]);
|
|
2450
2465
|
|
|
2451
2466
|
// packages/ceal-client-protocol/src/discovery-manifest.ts
|
|
2452
2467
|
var DISCOVERY_MANIFEST_KEYS = CEAL_CLIENT_WIRE_CONTRACT.command_response.discovery_manifest_fields;
|
|
@@ -2674,7 +2689,7 @@ async function runSecurefsCommand(args, maxBytes, custody, stdin) {
|
|
|
2674
2689
|
const executable = custody.securefs_executable ?? resolveInstalledHostExecutable(process.platform);
|
|
2675
2690
|
const processArgs = [...custody.securefs_args_prefix ?? [], ...args];
|
|
2676
2691
|
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) => {
|
|
2692
|
+
const child = execFile(executable, processArgs, { encoding: "buffer", windowsHide: true, timeout: WINDOWS_SECUREFS_TIMEOUT_MS, maxBuffer: maxBytes + WINDOWS_SECUREFS_DIAGNOSTIC_BYTES }, (error, stdout, stderr) => {
|
|
2678
2693
|
const exitCode = error === null ? 0 : typeof error.code === "number" ? error.code : null;
|
|
2679
2694
|
if (exitCode === null) {
|
|
2680
2695
|
reject(new SecureFileCustodyError("unavailable", "The installed Windows Host securefs command could not run."));
|
|
@@ -2765,21 +2780,21 @@ function decodeHostProducerConfigText(descriptor, text, platform = process.platf
|
|
|
2765
2780
|
const { extra_paths: extras, ...core } = decoded;
|
|
2766
2781
|
return Object.freeze(descriptor.config({ schema_version: descriptor.schema, ...core }, extras));
|
|
2767
2782
|
}
|
|
2768
|
-
async function serveHostProducer(descriptor, config, signal, dependencies
|
|
2783
|
+
async function serveHostProducer(descriptor, config, signal, dependencies) {
|
|
2769
2784
|
const runtimeOptions = descriptor.runtime_options(config);
|
|
2770
2785
|
const serving = serveProducer(runtimeOptions, config, signal, dependencies.drain ?? descriptor.drain, dependencies.wait);
|
|
2771
2786
|
if (descriptor.background === void 0 || dependencies.drain !== void 0) {
|
|
2772
2787
|
await serving;
|
|
2773
2788
|
return;
|
|
2774
2789
|
}
|
|
2775
|
-
const background = descriptor.background(config, signal);
|
|
2790
|
+
const background = descriptor.background(config, signal, dependencies);
|
|
2776
2791
|
await Promise.all([serving, background]);
|
|
2777
2792
|
}
|
|
2778
2793
|
function hostProducerRegistrationStateFile(outboxDirectory, platform = process.platform) {
|
|
2779
2794
|
const path = platform === "win32" ? win324 : posix3;
|
|
2780
2795
|
return path.join(path.resolve(outboxDirectory, "../../../../.."), "registration.json");
|
|
2781
2796
|
}
|
|
2782
|
-
async function runHostProducerCli(descriptor, args, signal, dependencies
|
|
2797
|
+
async function runHostProducerCli(descriptor, args, signal, dependencies) {
|
|
2783
2798
|
await serveHostProducer(descriptor, await readHostProducerConfig(descriptor, parseHostProducerServeArgs(args)), signal, dependencies);
|
|
2784
2799
|
}
|
|
2785
2800
|
function hostProducerError(code2, message = code2) {
|
|
@@ -4065,7 +4080,7 @@ var HostUsageFactsUploader = class {
|
|
|
4065
4080
|
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
4081
|
const timeout = AbortSignal.timeout(this.options.timeout_ms ?? 5e3);
|
|
4067
4082
|
const requestSignal = signal === void 0 ? timeout : AbortSignal.any([signal, timeout]);
|
|
4068
|
-
const response2 = await
|
|
4083
|
+
const response2 = await this.options.fetch(`${registration.gateway_request_origin}${CEAL_HOST_USAGE_INGRESS_PATH}`, {
|
|
4069
4084
|
method: "POST",
|
|
4070
4085
|
headers: { authorization: `Bearer ${registration.host_access_token}`, "content-type": "application/json" },
|
|
4071
4086
|
body: JSON.stringify(candidate.batch),
|
|
@@ -4213,7 +4228,7 @@ function createTranscriptWatcherBase(options, owner) {
|
|
|
4213
4228
|
outboxRetentionMs: options.retention_ms ?? owner.default_retention_ms,
|
|
4214
4229
|
now: options.now ?? (() => /* @__PURE__ */ new Date()),
|
|
4215
4230
|
log: options.log ?? ((line) => {
|
|
4216
|
-
|
|
4231
|
+
writeHostServiceLogLine(`${line}
|
|
4217
4232
|
`);
|
|
4218
4233
|
}),
|
|
4219
4234
|
producerInstallationRef: options.producer_installation_ref
|
|
@@ -4253,7 +4268,13 @@ var HostTranscriptWatcher = class {
|
|
|
4253
4268
|
}
|
|
4254
4269
|
async scanRegistration(registration) {
|
|
4255
4270
|
return this.openTranscript(registration, (handle) => this.scanOpened(handle, registration), {
|
|
4256
|
-
missing: () =>
|
|
4271
|
+
missing: async () => {
|
|
4272
|
+
try {
|
|
4273
|
+
return await this.retireMissing(registration);
|
|
4274
|
+
} catch (error) {
|
|
4275
|
+
return this.scanFailed(void 0, registration, error);
|
|
4276
|
+
}
|
|
4277
|
+
},
|
|
4257
4278
|
failed: (handle, error) => this.scanFailed(handle, registration, error)
|
|
4258
4279
|
});
|
|
4259
4280
|
}
|
|
@@ -5112,11 +5133,13 @@ var ClaudeTranscriptWatcher = class extends HostTranscriptWatcher {
|
|
|
5112
5133
|
}
|
|
5113
5134
|
async scanOpened(handle, registration) {
|
|
5114
5135
|
const { size, device, inode } = await ownedClaudeTranscriptFile(handle);
|
|
5115
|
-
const
|
|
5136
|
+
const preflight = await this.preflight(registration, handle, size, device, inode);
|
|
5137
|
+
const cursor = preflight.cursor;
|
|
5116
5138
|
if (cursor === null) return { records: 0, enqueued: 0, quarantined: true };
|
|
5117
5139
|
if (cursor.status === "quarantined") {
|
|
5118
5140
|
return { records: 0, enqueued: 0, quarantined: true };
|
|
5119
5141
|
}
|
|
5142
|
+
if (preflight.checkpointPending) await this.store.writeTranscriptCursor({ ...cursor, updated_at: this.stamp() });
|
|
5120
5143
|
const draft = mutableCursor(cursor);
|
|
5121
5144
|
await this.scanOpenedTranscript(registration, handle, draft, size, device, inode);
|
|
5122
5145
|
return { records: draft.consumed, enqueued: draft.enqueued, quarantined: false };
|
|
@@ -5129,6 +5152,15 @@ var ClaudeTranscriptWatcher = class extends HostTranscriptWatcher {
|
|
|
5129
5152
|
return { records: 0, enqueued: 0, quarantined: true };
|
|
5130
5153
|
}
|
|
5131
5154
|
async retireMissing(registration) {
|
|
5155
|
+
const observedAt = this.stamp();
|
|
5156
|
+
if (Date.parse(registration.expires_at) <= Date.parse(observedAt)) return this.retireTranscript(registration);
|
|
5157
|
+
const cursor = await this.store.readTranscriptCursor(registration);
|
|
5158
|
+
if (cursor !== null && isUnmaterializedCursor(cursor, this.sha(Buffer.alloc(0)))) {
|
|
5159
|
+
return { records: 0, enqueued: 0, quarantined: false };
|
|
5160
|
+
}
|
|
5161
|
+
return this.retireTranscript(registration);
|
|
5162
|
+
}
|
|
5163
|
+
retireTranscript(registration) {
|
|
5132
5164
|
return this.retireMissingTranscript(registration.transcript_path, "Claude", () => this.store.retireTranscriptRegistration(registration));
|
|
5133
5165
|
}
|
|
5134
5166
|
initialCursor(registration) {
|
|
@@ -5158,16 +5190,18 @@ var ClaudeTranscriptWatcher = class extends HostTranscriptWatcher {
|
|
|
5158
5190
|
}
|
|
5159
5191
|
async preflight(registration, handle, size, device, inode) {
|
|
5160
5192
|
const existing = await this.store.readTranscriptCursor(registration);
|
|
5161
|
-
if (existing?.status === "quarantined") return existing;
|
|
5193
|
+
if (existing?.status === "quarantined") return { cursor: existing, checkpointPending: false };
|
|
5162
5194
|
const cursor = existing ?? this.initialCursor(registration);
|
|
5163
5195
|
if (cursor.device === void 0) {
|
|
5164
|
-
|
|
5165
|
-
|
|
5196
|
+
const pinned = { ...cursor, device, inode, human_message_window: cursor.human_message_window ?? { messages: [], truncated: false } };
|
|
5197
|
+
const reason2 = this.cursorIdentityReason(pinned, registration.transcript_path, device, inode);
|
|
5198
|
+
if (cursor.offset !== 0 || reason2 !== null) return { cursor: await this.quarantineStored(cursor, device, inode, "transcript_replaced"), checkpointPending: false };
|
|
5199
|
+
return { cursor: pinned, checkpointPending: true };
|
|
5166
5200
|
}
|
|
5167
5201
|
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) };
|
|
5202
|
+
if (reason !== null) return { cursor: await this.quarantineStored(cursor, device, inode, reason), checkpointPending: false };
|
|
5203
|
+
if (cursor.human_message_window !== void 0) return { cursor, checkpointPending: false };
|
|
5204
|
+
return { cursor: { ...cursor, human_message_window: await this.readHumanMessageProjection(registration, handle, cursor.offset) }, checkpointPending: true };
|
|
5171
5205
|
}
|
|
5172
5206
|
async readHumanMessageProjection(registration, handle, watermark) {
|
|
5173
5207
|
let offset = 0;
|
|
@@ -5464,6 +5498,9 @@ var ClaudeTranscriptWatcher = class extends HostTranscriptWatcher {
|
|
|
5464
5498
|
return await this.store.readTranscriptCursor(registration).catch(() => null) ?? this.initialCursor(registration);
|
|
5465
5499
|
}
|
|
5466
5500
|
};
|
|
5501
|
+
function isUnmaterializedCursor(cursor, emptyAnchorSha256) {
|
|
5502
|
+
return cursor.status === "active" && cursor.device === void 0 && cursor.inode === void 0 && cursor.offset === 0 && cursor.anchor_start === 0 && cursor.anchor_sha256 === emptyAnchorSha256;
|
|
5503
|
+
}
|
|
5467
5504
|
function mutableCursor(cursor) {
|
|
5468
5505
|
return {
|
|
5469
5506
|
offset: cursor.offset,
|
|
@@ -5990,6 +6027,7 @@ function sha2563(value) {
|
|
|
5990
6027
|
}
|
|
5991
6028
|
|
|
5992
6029
|
// host/claude/src/claude-producer-service.ts
|
|
6030
|
+
var CLAUDE_PRODUCER_COMMAND_SCHEMA = "ceal.claude_producer_command.v1";
|
|
5993
6031
|
var CLAUDE_PRODUCER_CONFIG_SCHEMA = "ceal.claude_producer_config.v1";
|
|
5994
6032
|
var CLAUDE_TRANSCRIPTS_ROOT = "claude_transcripts_root";
|
|
5995
6033
|
var CLAUDE_PRODUCER_DESCRIPTOR = {
|
|
@@ -5999,12 +6037,12 @@ var CLAUDE_PRODUCER_DESCRIPTOR = {
|
|
|
5999
6037
|
config: (shared, extras) => ({ ...shared, claude_transcripts_root: hostProducerExtraPath(extras, CLAUDE_TRANSCRIPTS_ROOT) }),
|
|
6000
6038
|
runtime_options: (config) => Object.freeze({ outbox_dir: config.outbox_dir }),
|
|
6001
6039
|
drain: drainClaudeProducerOnce,
|
|
6002
|
-
background: (config, signal) => {
|
|
6040
|
+
background: (config, signal, dependencies) => {
|
|
6003
6041
|
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);
|
|
6042
|
+
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
6043
|
}
|
|
6006
6044
|
};
|
|
6007
|
-
function runClaudeProducerCli(args, signal, dependencies
|
|
6045
|
+
function runClaudeProducerCli(args, signal, dependencies) {
|
|
6008
6046
|
return runHostProducerCli(CLAUDE_PRODUCER_DESCRIPTOR, args, signal, dependencies);
|
|
6009
6047
|
}
|
|
6010
6048
|
|
|
@@ -6031,4 +6069,4 @@ async function runProducerCommand(schemaVersion, run) {
|
|
|
6031
6069
|
}
|
|
6032
6070
|
|
|
6033
6071
|
// host/claude/bin/ceal-claude-producer.ts
|
|
6034
|
-
await runProducerCommand(
|
|
6072
|
+
await runProducerCommand(CLAUDE_PRODUCER_COMMAND_SCHEMA, (args, signal) => runClaudeProducerCli(args, signal, { fetch: globalThis.fetch }));
|