@corca-org/ceal-host-linux-arm64 1.0.7 → 1.0.9
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 +0 -0
- package/libexec/ceal-host/claude-hook.mjs +147 -45
- package/libexec/ceal-host/claude-invocation-authentication.mjs +99 -124
- package/libexec/ceal-host/claude-producer.mjs +74 -23
- package/libexec/ceal-host/codex-hook.mjs +146 -46
- package/libexec/ceal-host/codex-invocation-authentication.mjs +132 -128
- package/libexec/ceal-host/codex-producer.mjs +134 -31
- package/libexec/ceal-host/control.mjs +154 -38
- package/libexec/ceal-host/relay.mjs +236 -55
- package/package.json +1 -1
- package/share/ceal-host/bundle-manifest.json +12 -12
- package/share/ceal-host/bundle-manifest.sigstore.json +1 -1
|
@@ -74,11 +74,28 @@ var client_wire_contract_default = {
|
|
|
74
74
|
],
|
|
75
75
|
bare_document_fields: [
|
|
76
76
|
"invocation",
|
|
77
|
-
"
|
|
77
|
+
"required_action_sequence",
|
|
78
|
+
"entrypoints",
|
|
78
79
|
"common_concepts",
|
|
79
80
|
"operations",
|
|
80
81
|
"catalog_revision"
|
|
81
82
|
],
|
|
83
|
+
prompt_field: "prompt",
|
|
84
|
+
prompt_schema_version: "ceal.prompt.v1",
|
|
85
|
+
focused_prompt_document_fields: [
|
|
86
|
+
"catalog_revision",
|
|
87
|
+
"prompt"
|
|
88
|
+
],
|
|
89
|
+
focused_prompt_continuation_document_fields: [
|
|
90
|
+
"catalog_revision",
|
|
91
|
+
"remaining_work",
|
|
92
|
+
"prompt"
|
|
93
|
+
],
|
|
94
|
+
discovery_command: "discovery",
|
|
95
|
+
discovery_manifest_schema_version: "ceal.discovery_manifest.v1",
|
|
96
|
+
discovery_manifest_document_fields: [
|
|
97
|
+
"discovery_manifest"
|
|
98
|
+
],
|
|
82
99
|
exit_code_max: 125,
|
|
83
100
|
bare_document_max_bytes: 65536,
|
|
84
101
|
complete_max_bytes: 66019,
|
|
@@ -105,8 +122,15 @@ var CEAL_VERIFIED_ARTIFACT_MAX_BYTES = artifact.max_bytes;
|
|
|
105
122
|
var CEAL_VERIFIED_ARTIFACT_DESCRIPTOR_MAX_BYTES = artifact.envelope_max_bytes;
|
|
106
123
|
var CEAL_COMMAND_REQUEST_SCHEMA_VERSION = request.schema_version;
|
|
107
124
|
var CEAL_COMMAND_REQUEST_MAX_BYTES = request.absolute_transport_max_bytes;
|
|
108
|
-
var CEAL_COMMAND_RESPONSE_BARE_DOCUMENT_FIELDS = response.bare_document_fields;
|
|
109
125
|
var CEAL_COMMAND_RESPONSE_BARE_DOCUMENT_MAX_BYTES = response.bare_document_max_bytes;
|
|
126
|
+
var CEAL_COMMAND_RESPONSE_PROMPT_FIELD = response.prompt_field;
|
|
127
|
+
var CEAL_COMMAND_RESPONSE_PROMPT_SCHEMA_VERSION = response.prompt_schema_version;
|
|
128
|
+
var CEAL_COMMAND_RESPONSE_PROMPT_DOCUMENT_FIELDS = Object.freeze([...response.bare_document_fields, response.prompt_field]);
|
|
129
|
+
var CEAL_COMMAND_RESPONSE_FOCUSED_PROMPT_DOCUMENT_FIELDS = Object.freeze([...response.focused_prompt_document_fields]);
|
|
130
|
+
var CEAL_COMMAND_RESPONSE_FOCUSED_PROMPT_CONTINUATION_DOCUMENT_FIELDS = Object.freeze([...response.focused_prompt_continuation_document_fields]);
|
|
131
|
+
var CEAL_COMMAND_RESPONSE_DISCOVERY_COMMAND = response.discovery_command;
|
|
132
|
+
var CEAL_COMMAND_RESPONSE_DISCOVERY_MANIFEST_SCHEMA_VERSION = response.discovery_manifest_schema_version;
|
|
133
|
+
var CEAL_COMMAND_RESPONSE_DISCOVERY_MANIFEST_DOCUMENT_FIELDS = Object.freeze([...response.discovery_manifest_document_fields]);
|
|
110
134
|
var CEAL_COMMAND_RESPONSE_MAX_BYTES = response.absolute_transport_max_bytes;
|
|
111
135
|
|
|
112
136
|
// packages/ceal-client-protocol/src/vocabulary.ts
|
|
@@ -142,7 +166,7 @@ var CEAL_OPERATION_RECOVERY_KINDS = vocabulary(["none", "reconcile", "compensate
|
|
|
142
166
|
var CEAL_OPERATION_RECOVERY_STATUSES = vocabulary(["not_started", "active", "completed"]);
|
|
143
167
|
var CEAL_OPERATION_PROVIDER_READBACK_AVAILABILITY = vocabulary(["not_started", "not_applicable", "not_available", "pending", "available"]);
|
|
144
168
|
var CEAL_OPERATION_OFFERED_HANDOFF_STATES = vocabulary(["accepted", "rejected", "unknown"]);
|
|
145
|
-
var CEAL_OPERATION_RECEIPT_AUTHORITY_KEYS = Object.freeze(["instance_ref", "
|
|
169
|
+
var CEAL_OPERATION_RECEIPT_AUTHORITY_KEYS = Object.freeze(["instance_ref", "access_group_ref", "principal_ref", "execution_subject_ref", "authority_revision_ref"]);
|
|
146
170
|
var CEAL_OPERATION_APPROVAL_DISPOSITIONS = vocabulary([
|
|
147
171
|
"approval_not_required_by_policy",
|
|
148
172
|
"interactive_pending",
|
|
@@ -157,6 +181,8 @@ var CEAL_CAPABILITY_READINESS_VALUES = vocabulary(["ready", "degraded", "unavail
|
|
|
157
181
|
var CEAL_TARGET_REQUIREMENTS = vocabulary(["required", "optional", "none"]);
|
|
158
182
|
var CEAL_AUDIT_OUTCOMES = vocabulary(["succeeded", "denied", "failed"]);
|
|
159
183
|
var CEAL_GATEWAY_PROVIDER_STEP_OUTCOMES = vocabulary(["completed", "rejected", "throttled", "failed"]);
|
|
184
|
+
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"]);
|
|
185
|
+
var CEAL_GATEWAY_READ_REUSE_UNAVAILABLE_REASONS = vocabulary(["not_reported", "storage_unavailable", "coverage_incomplete", "freshness_refresh_required", "not_reusable", "bypassed"]);
|
|
160
186
|
var CEAL_POLICY_DECISIONS = vocabulary(["allowed", "denied", "not_evaluated"]);
|
|
161
187
|
var CEAL_CONNECTOR_ROUTE_PHASES = vocabulary(["scope_observation", "target_selection", "route_resolution"]);
|
|
162
188
|
var CEAL_CONNECTOR_ROUTE_CAUSES = vocabulary(["provider_throttled", "provider_unavailable", "binding_invalid", "scope_limit_exceeded"]);
|
|
@@ -429,8 +455,10 @@ function requireIsoTimestamp(value, message) {
|
|
|
429
455
|
var JSON_DESCRIPTION_CONTROL_CHARACTER = new RegExp("\\p{Cc}", "u");
|
|
430
456
|
|
|
431
457
|
// packages/ceal-client-protocol/src/operation-contract-validation.ts
|
|
432
|
-
var CEAL_OPERATION_AUTHORITY_POLICY_KEYS = Object.freeze(["
|
|
458
|
+
var CEAL_OPERATION_AUTHORITY_POLICY_KEYS = Object.freeze(["access_group", "instance_binding", "target", "admission_recheck"]);
|
|
433
459
|
var MAX_OPERATION_INPUT_RESOLVER_BINDINGS = 96;
|
|
460
|
+
var CEAL_OPERATION_DESCRIPTOR_REQUIRED_ENVELOPE_KEYS = Object.freeze(["schema_version", "id", "input_contract", "result_contract", "policy"]);
|
|
461
|
+
var CEAL_OPERATION_DESCRIPTOR_OPTIONAL_ENVELOPE_KEYS = Object.freeze(["input_resolution", "summary"]);
|
|
434
462
|
var CEAL_OPERATION_RESULT_KEYS = vocabulary(["ok", "operation_id", "operation_receipt", "schema_version", "value"]);
|
|
435
463
|
var CEAL_OPERATION_COMPACT_RESULT_KEYS = vocabulary(["ok", "operation_evidence", "operation_id", "schema_version", "value"]);
|
|
436
464
|
|
|
@@ -504,6 +532,7 @@ var CEAL_SCHEMA_LITERALS = [
|
|
|
504
532
|
"ceal.operation_descriptor.v1",
|
|
505
533
|
"ceal.operation_error.v1",
|
|
506
534
|
"ceal.operation_failure.v1",
|
|
535
|
+
"ceal.operation_failure.compact.v1",
|
|
507
536
|
"ceal.operation_receipt.v1",
|
|
508
537
|
"ceal.operation_result.v1",
|
|
509
538
|
"ceal.operation_result.compact.v1",
|
|
@@ -529,17 +558,16 @@ var CEAL_BOUNDED_SERIES_CATALOG = Object.freeze({
|
|
|
529
558
|
engagement_signal: (root) => join(root, "runtime-state", "slack-feedback.jsonl"),
|
|
530
559
|
runtime_error: (root) => join(root, "runtime-state", "runtime-errors.jsonl"),
|
|
531
560
|
turn_bridge_request: (root) => join(root, ".ceal", "turn-bridge", "requests.jsonl"),
|
|
532
|
-
channel_log: (root) => join(root, "log.jsonl"),
|
|
533
561
|
thread_run_events: (root) => join(root, "run-events.jsonl"),
|
|
534
562
|
bounded_store_sidecar: (root) => `${root}.jsonl`,
|
|
535
563
|
gateway_audit_archive: (root) => `${root}.jsonl`,
|
|
536
564
|
gateway_capability_audit: (root) => join(root, "capability-audit.jsonl"),
|
|
537
565
|
gateway_retrieval_waste_partition: (root) => `${root}.jsonl`,
|
|
538
566
|
gateway_access_policy_publication: (root) => join(root, "access-policy-publications.jsonl"),
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
567
|
+
gateway_access_group_connector_control_audit: (root) => `${root}.audit.jsonl`,
|
|
568
|
+
gateway_access_group_connector_scope_audit: (root) => join(root, "profile-connector-scope-audit.jsonl"),
|
|
569
|
+
gateway_access_group_connector_activity_scope_audit: (root) => join(root, "profile-connector-activity-scope-audit.jsonl"),
|
|
570
|
+
gateway_access_group_connector_readiness_audit: (root) => join(root, "profile-connector-readiness.audit.jsonl"),
|
|
543
571
|
gateway_organization_audit_ledger: (root) => join(root, "organization-ledger.jsonl"),
|
|
544
572
|
gateway_personal_client_audit: (root) => join(root, "audit.jsonl"),
|
|
545
573
|
gateway_personal_client_access_audit: (root) => join(root, "access-audit.jsonl"),
|
|
@@ -590,12 +618,6 @@ var CEAL_AGENT_SESSION_COMMIT_KEYS = vocabulary(["attempt_ref", "expected_sessio
|
|
|
590
618
|
// packages/ceal-client-protocol/src/operation-next-actions.ts
|
|
591
619
|
var CALLER_RECOVERABLE_NEXT_ACTION_VALUES = [
|
|
592
620
|
"select_did_you_mean",
|
|
593
|
-
// The graph, not the argument list, is what the caller must change: the
|
|
594
|
-
// resolver that owns this input has no producing node upstream, and no edit
|
|
595
|
-
// to the invocation can conjure one. `resolver_dependency_absent` carried no
|
|
596
|
-
// remedy at all rather than borrow a word that means something else, so the
|
|
597
|
-
// scorer read a fully-diagnosed, caller-fixable refusal as a failed run.
|
|
598
|
-
"request.graph.append",
|
|
599
621
|
"choose_new_output_path",
|
|
600
622
|
"choose_new_idempotency_key",
|
|
601
623
|
"restart_search",
|
|
@@ -647,8 +669,6 @@ var NON_REMEDY_NEXT_ACTION_VALUES = [
|
|
|
647
669
|
"reconcile_occurrence",
|
|
648
670
|
"reduce_request_size",
|
|
649
671
|
"repair_or_adopt_session",
|
|
650
|
-
"request.effect_approval.read",
|
|
651
|
-
"request.run",
|
|
652
672
|
"retry",
|
|
653
673
|
// The owner -- a correlation hook, an approval hook -- is not serving right
|
|
654
674
|
// now. The caller changes nothing and the same call succeeds once the owner
|
|
@@ -745,12 +765,12 @@ var CEAL_REQUEST_JSON_SCHEMA = {
|
|
|
745
765
|
additionalProperties: false,
|
|
746
766
|
properties: {
|
|
747
767
|
instance_ref: { type: "string", minLength: 1, maxLength: 128, pattern: SAFE_REF.source },
|
|
748
|
-
|
|
768
|
+
access_group_ref: { type: "string", minLength: 1, maxLength: 128, pattern: SAFE_REF.source },
|
|
749
769
|
principal_ref: { type: "string", minLength: 1, maxLength: 128, pattern: SAFE_REF.source },
|
|
750
770
|
execution_subject_ref: { type: "string", minLength: 1, maxLength: 128, pattern: SAFE_REF.source },
|
|
751
771
|
authority_revision_ref: { type: "string", minLength: 1, maxLength: 128, pattern: SAFE_REF.source }
|
|
752
772
|
},
|
|
753
|
-
required: ["instance_ref", "
|
|
773
|
+
required: ["instance_ref", "access_group_ref", "principal_ref", "execution_subject_ref", "authority_revision_ref"]
|
|
754
774
|
},
|
|
755
775
|
prompt_ref: { type: "string", minLength: 1, maxLength: 128, pattern: SAFE_REF.source },
|
|
756
776
|
host_session_ref: { type: "string", minLength: 1, maxLength: 128, pattern: SAFE_REF.source },
|
|
@@ -876,7 +896,7 @@ var CEAL_HOST_OBSERVATION_KINDS = vocabulary(["prompt", "session", "turn", "mode
|
|
|
876
896
|
function isCealHostPromptObservationValue(value) {
|
|
877
897
|
return isOperationRecord(value) && Object.keys(value).length === 1 && isCealDigest(value.body_sha256);
|
|
878
898
|
}
|
|
879
|
-
var HOST_RESERVED_KEY = /^(?:admission|approval|audit|authorization|cancellation|capability|effect|grant|occurrence|operation|policy|profile|provider_readback|receipt|reconciliation|replay|target|write_request)(?:_|$)/iu;
|
|
899
|
+
var HOST_RESERVED_KEY = /^(?:access_group|admission|approval|audit|authorization|cancellation|capability|effect|grant|occurrence|operation|policy|profile|provider_readback|receipt|reconciliation|replay|target|write_request)(?:_|$)/iu;
|
|
880
900
|
function assertHostObservationValue(value, kind) {
|
|
881
901
|
if (value === void 0) invalid("Ceal Host observation value is invalid.");
|
|
882
902
|
if (kind === "prompt" && !isCealHostPromptObservationValue(value)) invalid("Ceal Host prompt observation must contain only its body digest.");
|
|
@@ -896,6 +916,10 @@ function inspectHostKeys(value) {
|
|
|
896
916
|
}
|
|
897
917
|
}
|
|
898
918
|
|
|
919
|
+
// packages/ceal-client-protocol/src/host-prompt-ref.ts
|
|
920
|
+
var CEAL_HOST_PROMPT_DIGEST_PATTERN = "^[a-f0-9]{64}$";
|
|
921
|
+
var PROMPT_DIGEST = new RegExp(CEAL_HOST_PROMPT_DIGEST_PATTERN, "u");
|
|
922
|
+
|
|
899
923
|
// packages/ceal-client-protocol/src/request-effect-approval.ts
|
|
900
924
|
var CEAL_EFFECT_APPROVAL_DECISION_CHECK_PHRASES = Object.freeze([
|
|
901
925
|
"observed after this approval was raised and before it expires",
|
|
@@ -911,6 +935,12 @@ var OWNER_WRITE_STATES = Object.freeze(["attempt_started", "provider_acknowledge
|
|
|
911
935
|
var OWNER_EFFECT_STATES = Object.freeze(["none", "applied", "failed", "unknown", "reconciled"]);
|
|
912
936
|
var OWNER_RECEIPT_STATES = Object.freeze(["pending", "available", "failed", "unknown", "reconciled"]);
|
|
913
937
|
|
|
938
|
+
// packages/ceal-client-protocol/src/thread-excerpt.ts
|
|
939
|
+
var CEAL_THREAD_RECENT_WINDOW = 6;
|
|
940
|
+
var CEAL_THREAD_LAST_APP_MESSAGES_WINDOW = 3;
|
|
941
|
+
var CEAL_THREAD_OLDER_SUMMARY_WINDOW = 4;
|
|
942
|
+
var CEAL_FED_THREAD_MESSAGE_LIMIT = CEAL_THREAD_RECENT_WINDOW + CEAL_THREAD_OLDER_SUMMARY_WINDOW + CEAL_THREAD_LAST_APP_MESSAGES_WINDOW;
|
|
943
|
+
|
|
914
944
|
// packages/ceal-client-protocol/src/request-graph-readiness.ts
|
|
915
945
|
var REQUEST_GRAPH_PRODUCER_TO_APPEND_SCHEMA = {
|
|
916
946
|
type: "object",
|
|
@@ -1016,21 +1046,12 @@ function exactKeys(value, expected) {
|
|
|
1016
1046
|
var REQUIRED_FIELDS = Object.freeze(["schema_version", "operation_id", "local_path", "content_json_pointer", "size_bytes", "sha256", "read_argv"]);
|
|
1017
1047
|
var FIELDS = /* @__PURE__ */ new Set([...REQUIRED_FIELDS, "local_result_root", "model_disclosure"]);
|
|
1018
1048
|
|
|
1019
|
-
// packages/ceal-client-protocol/src/
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
if (!isCealJsonRecord(authority) || typeof authority.instance_ref !== "string" || typeof authority.profile_ref !== "string") return null;
|
|
1026
|
-
return Object.freeze({ instance_ref: authority.instance_ref, profile_ref: authority.profile_ref });
|
|
1027
|
-
}
|
|
1028
|
-
function isProfileReadResult(value) {
|
|
1029
|
-
return isCealJsonRecord(value) && value.schema_version === "ceal.operation_result.v1" && value.ok === true && value.operation_id === "profile.read";
|
|
1030
|
-
}
|
|
1031
|
-
function isUnaffectingAvailableReceipt(value) {
|
|
1032
|
-
return isCealJsonRecord(value) && value.effect === "none" && value.provider_handoff === "not_offered" && isCealJsonRecord(value.terminal) && value.terminal.availability === "available";
|
|
1033
|
-
}
|
|
1049
|
+
// packages/ceal-client-protocol/src/session-start-affordance.ts
|
|
1050
|
+
var CEAL_SESSION_ENTRY_INVOCATION = "ceal";
|
|
1051
|
+
var CEAL_LINK_RESOURCE_PRECEDENCE = `When the user asks to use Ceal or provides a link to information that may be available through installed organizational capabilities, run bare \`${CEAL_SESSION_ENTRY_INVOCATION}\`. The Host supplies the current user prompt without exposing it to the client command, and the Gateway returns the applicable entry in that one response. Treat a supplied link as a candidate Ceal resource rather than a public web-search target. Reach for a generic web fetch or web search only when the Gateway offered nothing.`;
|
|
1052
|
+
|
|
1053
|
+
// packages/ceal-client-protocol/src/discovery-manifest.ts
|
|
1054
|
+
var CEAL_DISCOVERY_MANIFEST_CONNECTOR_KINDS = vocabulary(["github", "google-workspace", "notion", "slack"]);
|
|
1034
1055
|
|
|
1035
1056
|
// packages/ceal-client-protocol/src/conversation-contracts.ts
|
|
1036
1057
|
var CEAL_APPROVAL_POLICY_KINDS = vocabulary(["requester_only", "named_users", "role_based"]);
|
|
@@ -1248,7 +1269,7 @@ var CEAL_PRESENTATION_INTENTS = vocabulary(["progress", ...CEAL_FINAL_PRESENTATI
|
|
|
1248
1269
|
|
|
1249
1270
|
// packages/ceal-client-protocol/src/personal-client-vocabulary.ts
|
|
1250
1271
|
var CEAL_PERSONAL_CLIENT_BINDING_KEYS = vocabulary([
|
|
1251
|
-
"
|
|
1272
|
+
"access_group_ref",
|
|
1252
1273
|
"membership_ref",
|
|
1253
1274
|
"registration_ref",
|
|
1254
1275
|
"client_ref",
|
|
@@ -1588,12 +1609,19 @@ var RELAY_QUARANTINE_MAX_BYTES = 16 * 1024 * 1024;
|
|
|
1588
1609
|
|
|
1589
1610
|
// host/relay/src/relay-admission-store.ts
|
|
1590
1611
|
var DEFAULT_LIMITS = { global_count: 8192, global_bytes: 64 * 1024 * 1024, producer_count: 4096, producer_bytes: 32 * 1024 * 1024 };
|
|
1612
|
+
var RETRY_SECONDS = [1, 2, 4, 8, 16, 32, 60];
|
|
1613
|
+
var MAX_RETRYABLE_ATTEMPTS = RETRY_SECONDS.length + 10;
|
|
1591
1614
|
|
|
1592
1615
|
// host/relay/src/relay-request-binding-store.ts
|
|
1593
1616
|
var MAX_STATE_BYTES = 8 * 1024 * 1024;
|
|
1594
1617
|
|
|
1595
1618
|
// host/relay/src/relay-ipc.ts
|
|
1596
1619
|
import { createConnection, createServer } from "node:net";
|
|
1620
|
+
|
|
1621
|
+
// host/relay/src/current-prompt-custody.ts
|
|
1622
|
+
var HOST_CURRENT_PROMPT_MAX_BYTES = 256 * 1024;
|
|
1623
|
+
|
|
1624
|
+
// host/relay/src/relay-ipc.ts
|
|
1597
1625
|
var HOST_RELAY_REQUEST_BINDING_KEYS = Object.freeze([
|
|
1598
1626
|
"schema_version",
|
|
1599
1627
|
"producer_id",
|
|
@@ -1610,8 +1638,6 @@ var HOST_RELAY_REQUEST_BINDING_KEYS = Object.freeze([
|
|
|
1610
1638
|
"host_input_ref"
|
|
1611
1639
|
]);
|
|
1612
1640
|
var HOST_RELAY_IPC_RESPONSE_SCHEMA = "ceal.host_relay_admission.v1";
|
|
1613
|
-
var HOST_RELAY_BINDING_QUERY_SCHEMA = "ceal.host_relay_binding_query.v1";
|
|
1614
|
-
var HOST_RELAY_BINDING_RESULT_SCHEMA = "ceal.host_relay_binding_result.v1";
|
|
1615
1641
|
var HOST_RELAY_INVOCATION_CONTEXT_QUERY_SCHEMA = "ceal.host_relay_invocation_context_query.v1";
|
|
1616
1642
|
var HOST_RELAY_INVOCATION_CONTEXT_RESULT_SCHEMA = "ceal.host_relay_invocation_context_result.v1";
|
|
1617
1643
|
var HOST_RELAY_IPC_LENGTH_BYTES = Uint32Array.BYTES_PER_ELEMENT;
|
|
@@ -1624,18 +1650,13 @@ var HostRelayIpcError = class extends Error {
|
|
|
1624
1650
|
this.code = code3;
|
|
1625
1651
|
}
|
|
1626
1652
|
};
|
|
1627
|
-
var
|
|
1653
|
+
var HostRelayInvocationContextPort = class {
|
|
1628
1654
|
endpoint;
|
|
1629
|
-
|
|
1630
|
-
constructor(endpoint, timeoutMs = 5e3) {
|
|
1655
|
+
constructor(endpoint) {
|
|
1631
1656
|
this.endpoint = endpoint;
|
|
1632
|
-
this.timeout_ms = timeoutMs;
|
|
1633
1657
|
}
|
|
1634
|
-
|
|
1635
|
-
return
|
|
1636
|
-
}
|
|
1637
|
-
mintInvocationContext(input) {
|
|
1638
|
-
return queryHostRelayInvocationContext(this.endpoint, input, this.timeout_ms);
|
|
1658
|
+
mintInvocationContext(input, signal) {
|
|
1659
|
+
return queryHostRelayInvocationContext(this.endpoint, input, signal);
|
|
1639
1660
|
}
|
|
1640
1661
|
};
|
|
1641
1662
|
var HostRelayIpcAdmissionPort = class {
|
|
@@ -1654,32 +1675,29 @@ var HostRelayIpcAdmissionPort = class {
|
|
|
1654
1675
|
function submitHostProducerFrame(endpoint, frame, timeoutMs = 5e3) {
|
|
1655
1676
|
return exchange(endpoint, encodeHostProducerFrame(frame), timeoutMs, decodeResponseBuffer);
|
|
1656
1677
|
}
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
const response2 = await exchange(endpoint, request2, timeoutMs, decodeBindingResponseBuffer);
|
|
1660
|
-
if (response2.status === "no_binding") return { status: "no_binding" };
|
|
1661
|
-
return { status: "ready", binding: response2.binding };
|
|
1662
|
-
}
|
|
1663
|
-
function decodeHostRelayBindingQueryResult(value) {
|
|
1664
|
-
if (!validBindingResponse(value)) throw new HostRelayIpcError("relay_unavailable", "Host Relay binding response is invalid.");
|
|
1665
|
-
return value.status === "no_binding" ? { status: "no_binding" } : { status: "ready", binding: value.binding };
|
|
1678
|
+
function queryHostRelayInvocationContext(endpoint, query, signal) {
|
|
1679
|
+
return exchange(endpoint, encodeInvocationContextQuery(query), void 0, decodeInvocationContextResponseBuffer, signal);
|
|
1666
1680
|
}
|
|
1667
|
-
function
|
|
1668
|
-
return exchange(endpoint, encodeInvocationContextQuery(query), timeoutMs, decodeInvocationContextResponseBuffer);
|
|
1669
|
-
}
|
|
1670
|
-
function exchange(endpoint, encoded, timeoutMs, decode) {
|
|
1681
|
+
function exchange(endpoint, encoded, timeoutMs, decode, signal) {
|
|
1671
1682
|
return new Promise((resolve, reject) => {
|
|
1672
1683
|
const socket = createConnection(endpoint);
|
|
1673
1684
|
let buffer = Buffer.alloc(0);
|
|
1674
1685
|
let settled = false;
|
|
1686
|
+
const aborted = () => finish(new HostRelayIpcError("relay_unavailable", "Host Relay IPC was cancelled."));
|
|
1675
1687
|
const finish = (error, response2) => {
|
|
1676
1688
|
if (settled) return;
|
|
1677
1689
|
settled = true;
|
|
1690
|
+
signal?.removeEventListener("abort", aborted);
|
|
1678
1691
|
socket.destroy();
|
|
1679
1692
|
if (error !== null) reject(error);
|
|
1680
1693
|
else if (response2 !== void 0) resolve(response2);
|
|
1681
1694
|
};
|
|
1682
|
-
socket.setTimeout(timeoutMs, () => finish(new HostRelayIpcError("relay_unavailable", "Host Relay IPC timed out.")));
|
|
1695
|
+
if (timeoutMs !== void 0) socket.setTimeout(timeoutMs, () => finish(new HostRelayIpcError("relay_unavailable", "Host Relay IPC timed out.")));
|
|
1696
|
+
if (signal?.aborted === true) {
|
|
1697
|
+
aborted();
|
|
1698
|
+
return;
|
|
1699
|
+
}
|
|
1700
|
+
signal?.addEventListener("abort", aborted, { once: true });
|
|
1683
1701
|
socket.once("error", () => finish(new HostRelayIpcError("relay_unavailable", "Host Relay IPC is unavailable.")));
|
|
1684
1702
|
socket.once("connect", () => socket.write(encoded));
|
|
1685
1703
|
socket.on("data", (chunk) => {
|
|
@@ -1732,42 +1750,23 @@ function decodeResponseBuffer(buffer) {
|
|
|
1732
1750
|
if (buffer.length !== length + HOST_RELAY_IPC_LENGTH_BYTES) throw new HostRelayIpcError("relay_unavailable", `Host Relay IPC returned trailing bytes: ${refusalFacts([{ name: "declared_bytes", value: length, expected: `the received message length minus ${HOST_RELAY_IPC_LENGTH_BYTES}` }, { name: "received_bytes", value: buffer.byteLength, expected: `exactly ${length + HOST_RELAY_IPC_LENGTH_BYTES}` }])}.`);
|
|
1733
1751
|
return decodeHostRelayIpcResponse(buffer);
|
|
1734
1752
|
}
|
|
1735
|
-
function decodeBindingResponseBuffer(buffer) {
|
|
1736
|
-
const value = decodeLengthPrefixedJson(buffer, HOST_RELAY_QUERY_RESPONSE_MAX_BYTES);
|
|
1737
|
-
if (value === null) return null;
|
|
1738
|
-
const decoded = decodeHostRelayBindingQueryResult(value);
|
|
1739
|
-
return decoded.status === "no_binding" ? { schema_version: HOST_RELAY_BINDING_RESULT_SCHEMA, status: "no_binding" } : { schema_version: HOST_RELAY_BINDING_RESULT_SCHEMA, status: "ready", binding: decoded.binding };
|
|
1740
|
-
}
|
|
1741
1753
|
function decodeInvocationContextResponseBuffer(buffer) {
|
|
1742
1754
|
const value = decodeLengthPrefixedJson(buffer, HOST_RELAY_QUERY_RESPONSE_MAX_BYTES);
|
|
1743
1755
|
if (value === null) return null;
|
|
1744
1756
|
if (!validInvocationContextResponse(value)) throw new HostRelayIpcError("relay_unavailable", "Host Relay invocation context response is invalid.");
|
|
1745
1757
|
return value;
|
|
1746
1758
|
}
|
|
1747
|
-
function encodeBindingQuery(query) {
|
|
1748
|
-
const value = { schema_version: HOST_RELAY_BINDING_QUERY_SCHEMA, ...query };
|
|
1749
|
-
if (!validBindingQueryRequest(value)) throw new HostRelayIpcError("invalid_frame_shape", "Host Relay binding query is invalid.");
|
|
1750
|
-
return encodeLengthPrefixed(value);
|
|
1751
|
-
}
|
|
1752
1759
|
function encodeInvocationContextQuery(query) {
|
|
1753
1760
|
const value = { schema_version: HOST_RELAY_INVOCATION_CONTEXT_QUERY_SCHEMA, ...query };
|
|
1754
1761
|
if (!validInvocationContextQueryRequest(value)) throw new HostRelayIpcError("invalid_frame_shape");
|
|
1755
1762
|
return encodeLengthPrefixed(value);
|
|
1756
1763
|
}
|
|
1757
|
-
function validBindingQueryRequest(value) {
|
|
1758
|
-
return validQueryIdentity(value, HOST_RELAY_BINDING_QUERY_SCHEMA) && exactKeys3(value, ["schema_version", "producer_id", "producer_installation_ref", "local_session_ref", "local_turn_ref"]);
|
|
1759
|
-
}
|
|
1760
1764
|
function validInvocationContextQueryRequest(value) {
|
|
1761
1765
|
return validQueryIdentity(value, HOST_RELAY_INVOCATION_CONTEXT_QUERY_SCHEMA) && exactKeys3(value, ["schema_version", "producer_id", "producer_installation_ref", "local_session_ref", "local_turn_ref", "client_nonce"]) && typeof value.client_nonce === "string" && CEAL_HOST_CLIENT_NONCE_PATTERN.test(value.client_nonce);
|
|
1762
1766
|
}
|
|
1763
1767
|
function validQueryIdentity(value, schema) {
|
|
1764
1768
|
return record2(value) && value.schema_version === schema && (value.producer_id === "codex" || value.producer_id === "claude") && safeRef2(value.producer_installation_ref) && safeRef2(value.local_session_ref) && safeRef2(value.local_turn_ref);
|
|
1765
1769
|
}
|
|
1766
|
-
function validBindingResponse(value) {
|
|
1767
|
-
if (!record2(value) || value.schema_version !== HOST_RELAY_BINDING_RESULT_SCHEMA) return false;
|
|
1768
|
-
if (value.status === "no_binding") return Object.keys(value).length === 2;
|
|
1769
|
-
return value.status === "ready" && Object.keys(value).length === 3 && validWireBinding(value.binding);
|
|
1770
|
-
}
|
|
1771
1770
|
function validInvocationContextResponse(value) {
|
|
1772
1771
|
if (!record2(value) || value.schema_version !== HOST_RELAY_INVOCATION_CONTEXT_RESULT_SCHEMA) return false;
|
|
1773
1772
|
if (value.status === "no_binding") return Object.keys(value).length === 2;
|
|
@@ -1779,19 +1778,6 @@ function validInvocationContextResponse(value) {
|
|
|
1779
1778
|
return false;
|
|
1780
1779
|
}
|
|
1781
1780
|
}
|
|
1782
|
-
function validWireBinding(value) {
|
|
1783
|
-
if (!record2(value) || value.schema_version !== "ceal.host_relay_request_binding.v1" || value.producer_id !== "codex" && value.producer_id !== "claude") return false;
|
|
1784
|
-
const required = HOST_RELAY_REQUEST_BINDING_KEYS;
|
|
1785
|
-
const keys = Object.keys(value);
|
|
1786
|
-
return required.every((key) => Object.hasOwn(value, key)) && keys.every((key) => required.includes(key) || key === "context_expires_at") && validWireBindingRefs(value) && validWireBindingTimes(value);
|
|
1787
|
-
}
|
|
1788
|
-
function validWireBindingRefs(value) {
|
|
1789
|
-
const tuple = [value.host_source_ref, value.host_session_ref, value.host_turn_ref, value.host_input_ref];
|
|
1790
|
-
return [value.producer_installation_ref, value.local_session_ref, value.local_turn_ref, value.prompt_ref, value.request_ref].every(safeRef2) && Array.isArray(value.local_turn_aliases) && value.local_turn_aliases.length <= 16 && value.local_turn_aliases.every(safeRef2) && tuple.every(safeRef2);
|
|
1791
|
-
}
|
|
1792
|
-
function validWireBindingTimes(value) {
|
|
1793
|
-
return validTimestamp(value.bound_at) && (value.context_expires_at === void 0 || validTimestamp(value.context_expires_at));
|
|
1794
|
-
}
|
|
1795
1781
|
function decodeLengthPrefixedJson(input, maximum) {
|
|
1796
1782
|
if (input.length < HOST_RELAY_IPC_LENGTH_BYTES) return null;
|
|
1797
1783
|
const length = input.readUInt32BE(0);
|
|
@@ -1817,14 +1803,12 @@ function exactKeys3(value, keys) {
|
|
|
1817
1803
|
function safeRef2(value) {
|
|
1818
1804
|
return typeof value === "string" && /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u.test(value);
|
|
1819
1805
|
}
|
|
1820
|
-
function validTimestamp(value) {
|
|
1821
|
-
return typeof value === "string" && Number.isFinite(Date.parse(value));
|
|
1822
|
-
}
|
|
1823
1806
|
|
|
1824
1807
|
// host/invocation-authentication-command.ts
|
|
1825
1808
|
var HOST_INVOCATION_AUTHENTICATION_COMMAND_PREFIX = ["authenticate", "--client-nonce"];
|
|
1809
|
+
var REFUSAL_REASON_PATTERN = /^[a-z][a-z0-9_ ]{0,63}$/u;
|
|
1826
1810
|
function installedHostInvocationAuthenticationCommandOptions(config) {
|
|
1827
|
-
const port = new
|
|
1811
|
+
const port = new HostRelayInvocationContextPort(config.relay_endpoint);
|
|
1828
1812
|
return {
|
|
1829
1813
|
host_source_ref: config.host_source_ref,
|
|
1830
1814
|
outbox_dir: config.outbox_dir,
|
|
@@ -1839,15 +1823,19 @@ async function runHostInvocationAuthenticationCommand(descriptor, args, options)
|
|
|
1839
1823
|
sink = resolved.options.output_sink;
|
|
1840
1824
|
writeResult(await authenticateHostInvocation(descriptor, resolved.input, resolved.options), sink);
|
|
1841
1825
|
return 0;
|
|
1842
|
-
} catch {
|
|
1843
|
-
writeResult({ ok: false, code: "invocation_authentication_unavailable" }, sink);
|
|
1826
|
+
} catch (error) {
|
|
1827
|
+
writeResult({ ok: false, code: "invocation_authentication_unavailable", reason: authenticationRefusalReason(error) }, sink);
|
|
1844
1828
|
return 2;
|
|
1845
1829
|
}
|
|
1846
1830
|
}
|
|
1831
|
+
function authenticationRefusalReason(error) {
|
|
1832
|
+
const message = error instanceof Error ? error.message : "";
|
|
1833
|
+
return REFUSAL_REASON_PATTERN.test(message) ? message : "unclassified";
|
|
1834
|
+
}
|
|
1847
1835
|
async function authenticateHostInvocation(descriptor, input, options) {
|
|
1848
1836
|
if (input.length !== HOST_INVOCATION_AUTHENTICATION_COMMAND_PREFIX.length + 1 || input[0] !== HOST_INVOCATION_AUTHENTICATION_COMMAND_PREFIX[0] || input[1] !== HOST_INVOCATION_AUTHENTICATION_COMMAND_PREFIX[1]) throw new TypeError("invalid arguments");
|
|
1849
1837
|
const request2 = decodeCealHostInvocationAuthenticationRequest({ schema_version: CEAL_HOST_INVOCATION_AUTHENTICATION_REQUEST_SCHEMA, client_nonce: input[2] });
|
|
1850
|
-
const config = validateOptions(options
|
|
1838
|
+
const config = validateOptions(options);
|
|
1851
1839
|
const now = (config.now ?? (() => /* @__PURE__ */ new Date()))();
|
|
1852
1840
|
const { store, current } = await currentInvocation(descriptor, config, now);
|
|
1853
1841
|
if (config.mint_invocation_context === void 0) throw new TypeError("mint unavailable");
|
|
@@ -1885,9 +1873,9 @@ async function resolveOptions(descriptor, args, options) {
|
|
|
1885
1873
|
options: installedHostInvocationAuthenticationCommandOptions(await descriptor.read_producer_config(configPath))
|
|
1886
1874
|
};
|
|
1887
1875
|
}
|
|
1888
|
-
function validateOptions(options
|
|
1876
|
+
function validateOptions(options) {
|
|
1889
1877
|
if (typeof options.outbox_dir !== "string" || options.outbox_dir.length === 0 || typeof options.host_source_ref !== "string" || !SAFE_REF.test(options.host_source_ref) || typeof options.producer_installation_ref !== "string" || !SAFE_REF.test(options.producer_installation_ref) || !validOptionalSession(options.session_id)) {
|
|
1890
|
-
throw new TypeError(
|
|
1878
|
+
throw new TypeError("options invalid");
|
|
1891
1879
|
}
|
|
1892
1880
|
return options;
|
|
1893
1881
|
}
|
|
@@ -2072,6 +2060,7 @@ function boundedMilliseconds(value) {
|
|
|
2072
2060
|
import { createHash as createHash2 } from "node:crypto";
|
|
2073
2061
|
|
|
2074
2062
|
// host/claude/src/claude-types.ts
|
|
2063
|
+
var CLAUDE_SESSION_ID_ENVIRONMENT = "CLAUDE_CODE_SESSION_ID";
|
|
2075
2064
|
var CLAUDE_HOST_ERROR_CODES = ["invalid_input", "storage", "configuration"];
|
|
2076
2065
|
function isClaudeHostErrorCode(value) {
|
|
2077
2066
|
return typeof value === "string" && CLAUDE_HOST_ERROR_CODES.some((code3) => code3 === value);
|
|
@@ -2462,10 +2451,9 @@ var CLAUDE_PRODUCER_DESCRIPTOR = {
|
|
|
2462
2451
|
|
|
2463
2452
|
// host/claude/src/claude-invocation-authentication-command.ts
|
|
2464
2453
|
var CLAUDE_INVOCATION_AUTHENTICATION_DESCRIPTOR = {
|
|
2465
|
-
command_name: "ceal-claude-invocation-authentication",
|
|
2466
2454
|
producer_id: "claude",
|
|
2467
2455
|
create_store: (directory) => new ClaudeOutboxStore(directory),
|
|
2468
|
-
session_id_env:
|
|
2456
|
+
session_id_env: CLAUDE_SESSION_ID_ENVIRONMENT,
|
|
2469
2457
|
session_ref: (_hostSourceRef, sessionId) => claudeLocalSessionRef(sessionId),
|
|
2470
2458
|
config_flag: HOST_PRODUCER_CONFIG_FLAG,
|
|
2471
2459
|
parse_config_flag: parseHostProducerConfigFlag,
|
|
@@ -2498,8 +2486,6 @@ async function doctorClient(options = {}, component) {
|
|
|
2498
2486
|
const contextInspection = await inspectCanonicalContext(options, executable, environment, run, component);
|
|
2499
2487
|
if (!contextInspection.ok) return contextInspection.failure;
|
|
2500
2488
|
const selected = contextInspection.value;
|
|
2501
|
-
const readbackFailure = await inspectAuthenticatedReadback(executable, selected, environment, run, component);
|
|
2502
|
-
if (readbackFailure !== null) return readbackFailure;
|
|
2503
2489
|
return {
|
|
2504
2490
|
ok: true,
|
|
2505
2491
|
status: "ready",
|
|
@@ -2510,9 +2496,7 @@ async function doctorClient(options = {}, component) {
|
|
|
2510
2496
|
source_tree: version.source_tree,
|
|
2511
2497
|
context_source: "canonical_user_config",
|
|
2512
2498
|
context_name: selected.name,
|
|
2513
|
-
instance_ref: selected.instance_ref
|
|
2514
|
-
profile_ref: selected.profile_ref,
|
|
2515
|
-
authenticated_readback: "profile.read"
|
|
2499
|
+
instance_ref: selected.instance_ref
|
|
2516
2500
|
};
|
|
2517
2501
|
}
|
|
2518
2502
|
async function inspectExecutable(options, environment, component) {
|
|
@@ -2543,16 +2527,11 @@ function probeCode(code3) {
|
|
|
2543
2527
|
return "ceal_output_unreadable";
|
|
2544
2528
|
}
|
|
2545
2529
|
async function inspectCanonicalContext(options, executable, environment, run, component) {
|
|
2546
|
-
const probe = hostClientProbe(await safeRun(run, executable.path, ["
|
|
2547
|
-
if (probe.kind === "unreachable") return probeFailure(probe, "
|
|
2530
|
+
const probe = hostClientProbe(await safeRun(run, executable.path, ["access-group", "list"], environment), (result) => selectedContext(commandDocument(result)));
|
|
2531
|
+
if (probe.kind === "unreachable") return probeFailure(probe, "access-group list", component, options);
|
|
2548
2532
|
if (probe.kind !== "value" || options.expected_instance_ref !== void 0 && probe.value.instance_ref !== options.expected_instance_ref) return inspectedFailure("canonical_context_unavailable", `The ${component} Host cannot select the intended authenticated context from Ceal's canonical user configuration (${refusalFacts([{ name: "probe_kind", value: probe.kind, expected: "value" }, { name: "instance_ref", value: probe.kind === "value" ? probe.value.instance_ref : "unavailable", expected: options.expected_instance_ref ?? "a selected context" }])}).`, `Run \`ceal session adopt --email <email>\` without CEAL context overrides, then restart ${component}.`);
|
|
2549
2533
|
return { ok: true, value: probe.value };
|
|
2550
2534
|
}
|
|
2551
|
-
async function inspectAuthenticatedReadback(executable, selected, environment, run, component) {
|
|
2552
|
-
const result = await safeRun(run, executable.path, ["profile", "show"], environment);
|
|
2553
|
-
if (result !== null && result.exit_code === 0 && readbackProvesSelectedContext(commandDocument(result), selected)) return null;
|
|
2554
|
-
return failure("gateway_context_unavailable", "The canonical Ceal context could not complete an authenticated Gateway readback.", `Inspect the structured \`ceal profile show\` failure, repair or re-adopt the context, then restart ${component} if its environment changed.`);
|
|
2555
|
-
}
|
|
2556
2535
|
function inspectedFailure(code3, message, nextAction) {
|
|
2557
2536
|
return { ok: false, failure: failure(code3, message, nextAction) };
|
|
2558
2537
|
}
|
|
@@ -2624,25 +2603,21 @@ function commandDocument(result) {
|
|
|
2624
2603
|
}
|
|
2625
2604
|
}
|
|
2626
2605
|
function selectedContext(value) {
|
|
2627
|
-
if (value?.schema_version !== "ceal.
|
|
2606
|
+
if (value?.schema_version !== "ceal.access-group.v1" || value.ok !== true || !Array.isArray(value.contexts)) return null;
|
|
2628
2607
|
const selected = value.contexts.filter((item) => isRecord2(item) && item.selected === true);
|
|
2629
2608
|
if (selected.length !== 1) return null;
|
|
2630
2609
|
return selectedContextRecord(selected[0]);
|
|
2631
2610
|
}
|
|
2632
2611
|
function selectedContextRecord(item) {
|
|
2633
|
-
if (!isRecord2(item) || typeof item.name !== "string" || typeof item.instance_ref !== "string"
|
|
2634
|
-
if (!SAFE_REF6.test(item.instance_ref)
|
|
2635
|
-
return { name: item.name, instance_ref: item.instance_ref
|
|
2612
|
+
if (!isRecord2(item) || typeof item.name !== "string" || typeof item.instance_ref !== "string") return null;
|
|
2613
|
+
if (!SAFE_REF6.test(item.instance_ref)) return null;
|
|
2614
|
+
return { name: item.name, instance_ref: item.instance_ref };
|
|
2636
2615
|
}
|
|
2637
2616
|
function versionIdentity(value) {
|
|
2638
2617
|
if (value?.schema_version !== "ceal.version.v1" || value.ok !== true || typeof value.version !== "string" || typeof value.source_commit !== "string" || typeof value.source_tree !== "string") return null;
|
|
2639
2618
|
if (value.version.length === 0 || !GIT_OID.test(value.source_commit) || !GIT_OID.test(value.source_tree)) return null;
|
|
2640
2619
|
return { version: value.version, source_commit: value.source_commit, source_tree: value.source_tree };
|
|
2641
2620
|
}
|
|
2642
|
-
function readbackProvesSelectedContext(value, selected) {
|
|
2643
|
-
const authority = cealAuthenticatedProfileReadback(value);
|
|
2644
|
-
return authority?.instance_ref === selected.instance_ref && authority.profile_ref === selected.profile_ref;
|
|
2645
|
-
}
|
|
2646
2621
|
function validExpectations(options) {
|
|
2647
2622
|
return (options.expected_sha256 === void 0 || SHA2562.test(options.expected_sha256)) && (options.expected_source_commit === void 0 || GIT_OID.test(options.expected_source_commit)) && (options.expected_instance_ref === void 0 || SAFE_REF6.test(options.expected_instance_ref));
|
|
2648
2623
|
}
|