@corca-org/ceal-host-linux-arm64 1.0.18 → 1.0.19
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 +1924 -522
- package/libexec/ceal-host/claude-invocation-authentication.mjs +1806 -330
- package/libexec/ceal-host/claude-producer.mjs +1773 -412
- package/libexec/ceal-host/codex-hook.mjs +1427 -1013
- package/libexec/ceal-host/codex-invocation-authentication.mjs +3071 -515
- package/libexec/ceal-host/codex-producer.mjs +815 -439
- package/libexec/ceal-host/control.mjs +2266 -1095
- package/libexec/ceal-host/relay.mjs +468 -103
- package/package.json +1 -1
- package/share/ceal-host/bundle-manifest.json +12 -12
- package/share/ceal-host/bundle-manifest.sigstore.json +1 -1
|
@@ -109,6 +109,9 @@ var client_wire_contract_default = {
|
|
|
109
109
|
"document"
|
|
110
110
|
],
|
|
111
111
|
optional_fields: [
|
|
112
|
+
"operation_id",
|
|
113
|
+
"visible_output_max_bytes",
|
|
114
|
+
"local_delivery",
|
|
112
115
|
"verified_artifact"
|
|
113
116
|
],
|
|
114
117
|
bare_document_fields: [
|
|
@@ -195,6 +198,7 @@ var CEAL_COMMAND_RESPONSE_FOCUSED_PROMPT_CONTINUATION_DOCUMENT_FIELDS = Object.f
|
|
|
195
198
|
var CEAL_COMMAND_RESPONSE_DISCOVERY_COMMAND = response.discovery_command;
|
|
196
199
|
var CEAL_COMMAND_RESPONSE_DISCOVERY_MANIFEST_SCHEMA_VERSION = response.discovery_manifest_schema_version;
|
|
197
200
|
var CEAL_COMMAND_RESPONSE_DISCOVERY_MANIFEST_DOCUMENT_FIELDS = Object.freeze([...response.discovery_manifest_document_fields]);
|
|
201
|
+
var CEAL_COMMAND_RESPONSE_MAX_BYTES = CEAL_ENCODED_JSON_DOCUMENT_MAX_BYTES;
|
|
198
202
|
|
|
199
203
|
// packages/ceal-client-protocol/src/vocabulary.ts
|
|
200
204
|
function vocabulary(words) {
|
|
@@ -225,6 +229,7 @@ var CEAL_WRITE_RECEIPT_PROVIDER_STATES = vocabulary(["outcome_unknown", "verifie
|
|
|
225
229
|
var CEAL_WRITE_RECEIPT_PROVIDER_READBACKS = vocabulary(["outcome_unknown", "verified", "not_applied"]);
|
|
226
230
|
var CEAL_PROTOCOL_VERSION = "1.4.0";
|
|
227
231
|
var CEAL_OPERATION_ACCESS_SCHEMA_VERSION = "ceal.operation_access.v1";
|
|
232
|
+
var CEAL_GATEWAY_CONTINUATION_CURSOR_PHASES = vocabulary(["scan", "delivery", "terminal"]);
|
|
228
233
|
var CEAL_GATEWAY_ACTIVE_CALL_PHASES = vocabulary([
|
|
229
234
|
"audited_call_pending",
|
|
230
235
|
"continuation_read_pending",
|
|
@@ -248,6 +253,7 @@ var CEAL_GATEWAY_ORGANIZATION_ROUTE_FACT_CALL_KEYS = Object.freeze([
|
|
|
248
253
|
// packages/ceal-client-protocol/src/operation-next-actions.ts
|
|
249
254
|
var CEAL_REPEAT_REQUEST_NEXT_ACTION = "repeat_request";
|
|
250
255
|
var CEAL_INSPECT_RECEIPT_NEXT_ACTION = "inspect_receipt";
|
|
256
|
+
var CEAL_ANSWER_WITH_GAP_NEXT_ACTION = "answer_with_gap";
|
|
251
257
|
var CALLER_RECOVERABLE_NEXT_ACTION_VALUES = [
|
|
252
258
|
"select_did_you_mean",
|
|
253
259
|
"choose_new_output_path",
|
|
@@ -301,10 +307,20 @@ var CALLER_RECOVERABLE_NEXT_ACTION_VALUES = [
|
|
|
301
307
|
"retry_after",
|
|
302
308
|
// The ref names a container of rows (a Notion database or data source), which
|
|
303
309
|
// has no body of its own; the caller searches its rows instead of reading it.
|
|
304
|
-
"search_container_rows"
|
|
310
|
+
"search_container_rows",
|
|
311
|
+
// A settled unknown write names the exact receipt Operation that can inspect
|
|
312
|
+
// its outcome without issuing another provider mutation.
|
|
313
|
+
"write_receipt.get",
|
|
314
|
+
// Command resolution carries the exact required Operation sequence beside
|
|
315
|
+
// this action, so the caller can execute each declared input in order.
|
|
316
|
+
"follow_required_action_sequence",
|
|
317
|
+
// The command needs caller-owned local materialization (for example an
|
|
318
|
+
// @path file) before the Gateway can receive the argument.
|
|
319
|
+
"materialize_local_argument"
|
|
305
320
|
];
|
|
306
321
|
var CEAL_CALLER_RECOVERABLE_NEXT_ACTIONS = Object.freeze(CALLER_RECOVERABLE_NEXT_ACTION_VALUES);
|
|
307
322
|
var NON_REMEDY_NEXT_ACTION_VALUES = [
|
|
323
|
+
CEAL_ANSWER_WITH_GAP_NEXT_ACTION,
|
|
308
324
|
// Only an administrator can take the named step -- approving a place for an
|
|
309
325
|
// Operation, granting a withheld capability -- so a non-administrator asks
|
|
310
326
|
// one. The refusal names the administrator step; this word is the ask.
|
|
@@ -352,7 +368,58 @@ var NON_REMEDY_NEXT_ACTION_VALUES = [
|
|
|
352
368
|
"select_exact_approval"
|
|
353
369
|
];
|
|
354
370
|
var CEAL_NON_REMEDY_NEXT_ACTIONS = Object.freeze(NON_REMEDY_NEXT_ACTION_VALUES);
|
|
355
|
-
var
|
|
371
|
+
var CEAL_DECLARED_NEXT_ACTIONS = Object.freeze([...CEAL_CALLER_RECOVERABLE_NEXT_ACTIONS, ...CEAL_NON_REMEDY_NEXT_ACTIONS]);
|
|
372
|
+
var DECLARED = new Set(CEAL_DECLARED_NEXT_ACTIONS);
|
|
373
|
+
function defineCealNonModelNextActions(actions) {
|
|
374
|
+
return actions;
|
|
375
|
+
}
|
|
376
|
+
var NON_MODEL_NEXT_ACTION_VALUES = defineCealNonModelNextActions([
|
|
377
|
+
CEAL_INSPECT_RECEIPT_NEXT_ACTION,
|
|
378
|
+
"await_pending_approval",
|
|
379
|
+
"inspect_gateway",
|
|
380
|
+
"operator_action",
|
|
381
|
+
"none",
|
|
382
|
+
"check_gateway",
|
|
383
|
+
"inspect_context_store",
|
|
384
|
+
"inspect_local_cache",
|
|
385
|
+
"inspect_local_client",
|
|
386
|
+
"inspect_local_command",
|
|
387
|
+
"inspect_local_output",
|
|
388
|
+
"inspect_local_route",
|
|
389
|
+
"inspect_request",
|
|
390
|
+
"reconcile",
|
|
391
|
+
"reconcile_occurrence",
|
|
392
|
+
"retry_after_owner_recovery",
|
|
393
|
+
"select_exact_approval"
|
|
394
|
+
]);
|
|
395
|
+
var NON_MODEL_NEXT_ACTIONS = new Set(NON_MODEL_NEXT_ACTION_VALUES);
|
|
396
|
+
function isCealModelActionableNonRemedyNextAction(action) {
|
|
397
|
+
return !NON_MODEL_NEXT_ACTIONS.has(action);
|
|
398
|
+
}
|
|
399
|
+
var CEAL_MODEL_ACTIONABLE_NEXT_ACTIONS = Object.freeze([
|
|
400
|
+
...CEAL_CALLER_RECOVERABLE_NEXT_ACTIONS,
|
|
401
|
+
...CEAL_NON_REMEDY_NEXT_ACTIONS.filter(isCealModelActionableNonRemedyNextAction)
|
|
402
|
+
]);
|
|
403
|
+
var MODEL_ACTIONABLE = new Set(CEAL_MODEL_ACTIONABLE_NEXT_ACTIONS);
|
|
404
|
+
var NON_MODEL_ACTION_TO_MODEL_ACTION = Object.freeze({
|
|
405
|
+
[CEAL_INSPECT_RECEIPT_NEXT_ACTION]: CEAL_ANSWER_WITH_GAP_NEXT_ACTION,
|
|
406
|
+
await_pending_approval: "ask_admin",
|
|
407
|
+
inspect_gateway: CEAL_ANSWER_WITH_GAP_NEXT_ACTION,
|
|
408
|
+
operator_action: "ask_admin",
|
|
409
|
+
none: CEAL_ANSWER_WITH_GAP_NEXT_ACTION,
|
|
410
|
+
check_gateway: "ask_admin",
|
|
411
|
+
inspect_context_store: CEAL_ANSWER_WITH_GAP_NEXT_ACTION,
|
|
412
|
+
inspect_local_cache: CEAL_ANSWER_WITH_GAP_NEXT_ACTION,
|
|
413
|
+
inspect_local_client: CEAL_ANSWER_WITH_GAP_NEXT_ACTION,
|
|
414
|
+
inspect_local_command: CEAL_ANSWER_WITH_GAP_NEXT_ACTION,
|
|
415
|
+
inspect_local_output: CEAL_ANSWER_WITH_GAP_NEXT_ACTION,
|
|
416
|
+
inspect_local_route: CEAL_ANSWER_WITH_GAP_NEXT_ACTION,
|
|
417
|
+
inspect_request: CEAL_ANSWER_WITH_GAP_NEXT_ACTION,
|
|
418
|
+
reconcile: CEAL_ANSWER_WITH_GAP_NEXT_ACTION,
|
|
419
|
+
reconcile_occurrence: "ask_admin",
|
|
420
|
+
retry_after_owner_recovery: "ask_admin",
|
|
421
|
+
select_exact_approval: "ask_admin"
|
|
422
|
+
});
|
|
356
423
|
var RETRY_PROMISE_NEXT_ACTIONS = ["retry", "retry_after"];
|
|
357
424
|
var RETRY_PROMISE = new Set(RETRY_PROMISE_NEXT_ACTIONS);
|
|
358
425
|
var RECOVERABLE = new Set(CEAL_CALLER_RECOVERABLE_NEXT_ACTIONS);
|
|
@@ -622,21 +689,15 @@ var CEAL_OPERATION_ACCESS_CLASSES = vocabulary(["read", "write"]);
|
|
|
622
689
|
// packages/ceal-client-protocol/src/domain-vocabulary.ts
|
|
623
690
|
var CEAL_CONNECTOR_STATUSES = vocabulary(["active", "disabled", "disconnected"]);
|
|
624
691
|
var CEAL_CONNECTOR_CUSTODIES = vocabulary(["organization", "personal"]);
|
|
625
|
-
var CEAL_PROVIDER_BOUNDARY_KINDS = vocabulary([
|
|
626
|
-
"github_account",
|
|
627
|
-
"github_organization",
|
|
628
|
-
"google_workspace_domain",
|
|
629
|
-
"notion_workspace",
|
|
630
|
-
"slack_workspace"
|
|
631
|
-
]);
|
|
632
|
-
var CEAL_PROVIDER_BOUNDARY_EVIDENCE = vocabulary(["provider_readback", "operator_stated"]);
|
|
633
692
|
var CEAL_ACCESS_LEVELS = vocabulary(["none", "read", "read_write"]);
|
|
634
693
|
var CEAL_PERSONAL_ACCESS_CEILINGS = vocabulary(["disabled", "read", "read_write"]);
|
|
635
694
|
var CEAL_TARGET_REF_PATTERN = "^[^\\p{Cc}]+$";
|
|
636
695
|
var TARGET_REF = new RegExp(CEAL_TARGET_REF_PATTERN, "u");
|
|
637
696
|
var CEAL_TARGET_VISIBILITIES = vocabulary(["public", "private"]);
|
|
638
|
-
var CEAL_PRINCIPAL_KINDS = vocabulary(["human", "
|
|
697
|
+
var CEAL_PRINCIPAL_KINDS = vocabulary(["human", "runtime"]);
|
|
698
|
+
var CEAL_PERSISTED_PRINCIPAL_KINDS = vocabulary(["human", "service", "runtime"]);
|
|
639
699
|
var CEAL_ORGANIZATION_ROLES = vocabulary(["member", "admin"]);
|
|
700
|
+
var CEAL_CALENDAR_PERIODS = vocabulary(["day", "week", "month"]);
|
|
640
701
|
var LABEL_EXPECTATION = `public-safe display text of at most ${CEAL_PUBLIC_DISPLAY_NAME_MAX_BYTES} bytes`;
|
|
641
702
|
|
|
642
703
|
// packages/ceal-client-protocol/src/safe-json-budget.ts
|
|
@@ -812,7 +873,7 @@ var CEAL_SCHEMA_LITERALS = [
|
|
|
812
873
|
"ceal.operation_receipt.v1",
|
|
813
874
|
"ceal.operation_result.v1",
|
|
814
875
|
"ceal.operation_result.compact.v1",
|
|
815
|
-
"ceal.
|
|
876
|
+
"ceal.local_result_file.v1",
|
|
816
877
|
"ceal.local_result_root.v1",
|
|
817
878
|
"ceal.owner_bootstrap_exchange_request.v1",
|
|
818
879
|
"ceal.owner_bootstrap_exchange_result.v1",
|
|
@@ -842,6 +903,9 @@ var CEAL_BOUNDED_SERIES_CATALOG = Object.freeze({
|
|
|
842
903
|
gateway_personal_client_access_audit: (root) => join(root, "access-audit.jsonl")
|
|
843
904
|
});
|
|
844
905
|
|
|
906
|
+
// packages/ceal-client-protocol/src/canonical-http-boundary.ts
|
|
907
|
+
var CEAL_CANONICAL_HTTP_MAX_RESPONSE_BYTES = CEAL_COMMAND_RESPONSE_MAX_BYTES;
|
|
908
|
+
|
|
845
909
|
// packages/ceal-client-protocol/src/gateway-installation-activation.ts
|
|
846
910
|
var CEAL_GATEWAY_INSTALLATION_ACTIVATION_CODE_DATA_CHARACTERS = 32;
|
|
847
911
|
var CEAL_GATEWAY_INSTALLATION_ACTIVATION_CODE_CHECK_CHARACTERS = 8;
|
|
@@ -907,41 +971,6 @@ var CEAL_VERIFIED_ARTIFACT_DESCRIPTOR_JSON_SCHEMA = Object.freeze({
|
|
|
907
971
|
}
|
|
908
972
|
});
|
|
909
973
|
|
|
910
|
-
// packages/ceal-client-protocol/src/provider-operation-vocabulary.ts
|
|
911
|
-
var CEAL_FILE_TYPE_FAMILIES = vocabulary(["all", "image", "pdf"]);
|
|
912
|
-
var CEAL_GITHUB_ISSUE_STATES = vocabulary(["open", "closed", "all"]);
|
|
913
|
-
var CEAL_NOTION_UPDATABLE_BLOCK_TYPES = vocabulary([
|
|
914
|
-
"paragraph",
|
|
915
|
-
"heading_1",
|
|
916
|
-
"heading_2",
|
|
917
|
-
"heading_3",
|
|
918
|
-
"bulleted_list_item",
|
|
919
|
-
"numbered_list_item",
|
|
920
|
-
"to_do",
|
|
921
|
-
"code"
|
|
922
|
-
]);
|
|
923
|
-
var CEAL_NOTION_NEUTRAL_TYPES = vocabulary([
|
|
924
|
-
"text",
|
|
925
|
-
"number",
|
|
926
|
-
"boolean",
|
|
927
|
-
"date",
|
|
928
|
-
"select",
|
|
929
|
-
"multi_select",
|
|
930
|
-
"people",
|
|
931
|
-
"url",
|
|
932
|
-
"email",
|
|
933
|
-
"phone",
|
|
934
|
-
"unsupported"
|
|
935
|
-
]);
|
|
936
|
-
var CEAL_NOTION_IDENTITY_GAP_REASONS = vocabulary([
|
|
937
|
-
"identity_unavailable",
|
|
938
|
-
"identity_stale",
|
|
939
|
-
"identity_ambiguous",
|
|
940
|
-
"identity_revoked",
|
|
941
|
-
"identity_unlinked"
|
|
942
|
-
]);
|
|
943
|
-
var CEAL_NOTION_STRING_VALUE_TYPES = vocabulary(["text", "select", "url", "email", "phone"]);
|
|
944
|
-
|
|
945
974
|
// packages/ceal-client-protocol/src/opaque-reference.ts
|
|
946
975
|
var CEAL_OPAQUE_HANDLE_KINDS = vocabulary(["target", "message", "thread", "artifact", "document", "block", "object"]);
|
|
947
976
|
var CEAL_OPAQUE_REF_KINDS = vocabulary([...CEAL_OPAQUE_HANDLE_KINDS, "result", "operation-receipt", "reply-receipt", "field", "notion-data-source"]);
|
|
@@ -974,6 +1003,7 @@ var CEAL_ACTIVITY_TIMESTAMP_BASES = vocabulary([
|
|
|
974
1003
|
"resource_modified"
|
|
975
1004
|
]);
|
|
976
1005
|
var CEAL_ACTIVITY_CONNECTOR_KINDS = vocabulary(["slack", "github", "google-calendar", "google-drive", "notion"]);
|
|
1006
|
+
var CEAL_ACTIVITY_UNSUPPORTED_EVENT_KIND_CODE = "unsupported_event_kind";
|
|
977
1007
|
var CEAL_ACTIVITY_GAP_CODES = vocabulary([
|
|
978
1008
|
"provider_page_budget",
|
|
979
1009
|
"call_deadline",
|
|
@@ -981,7 +1011,7 @@ var CEAL_ACTIVITY_GAP_CODES = vocabulary([
|
|
|
981
1011
|
"provider_cursor_unavailable",
|
|
982
1012
|
"malformed_provider_page",
|
|
983
1013
|
"visibility_incomplete",
|
|
984
|
-
|
|
1014
|
+
CEAL_ACTIVITY_UNSUPPORTED_EVENT_KIND_CODE,
|
|
985
1015
|
"direct_messages_excluded"
|
|
986
1016
|
]);
|
|
987
1017
|
var CEAL_ACTIVITY_EVENT_KINDS = vocabulary([
|
|
@@ -1046,6 +1076,8 @@ var RESOURCE_ROW_KEY_RULES = Object.freeze({
|
|
|
1046
1076
|
modified_at: { required: false, timestamp: true },
|
|
1047
1077
|
modified_at_local: { required: false, timestamp: true },
|
|
1048
1078
|
viewed_by_me_at: { required: false, timestamp: true },
|
|
1079
|
+
own_ceal_write: { required: false, timestamp: false },
|
|
1080
|
+
owned_by_me: { required: false, timestamp: false },
|
|
1049
1081
|
visibility: { required: false, timestamp: false },
|
|
1050
1082
|
start: { required: false, timestamp: false },
|
|
1051
1083
|
end: { required: false, timestamp: false },
|
|
@@ -1079,6 +1111,15 @@ function cealExcludedTargetCoverageJsonSchema() {
|
|
|
1079
1111
|
};
|
|
1080
1112
|
}
|
|
1081
1113
|
|
|
1114
|
+
// packages/ceal-client-protocol/src/gateway-write-identity.ts
|
|
1115
|
+
var CEAL_GATEWAY_WRITE_IDENTITY_ROLES = Object.freeze(["replay_identity", "lookup_handle", "collision_evidence"]);
|
|
1116
|
+
var CEAL_GATEWAY_WRITE_REQUEST_REF_PATTERN = /^gateway-write-request:[a-f0-9]{8}-(?:[a-f0-9]{4}-){3}[a-f0-9]{12}$/u;
|
|
1117
|
+
var CEAL_GATEWAY_WRITE_IDENTITY_FIELDS = Object.freeze({
|
|
1118
|
+
replay_identity: "idempotency_claim_sha256",
|
|
1119
|
+
lookup_handle: "write_request_sha256",
|
|
1120
|
+
collision_evidence: "normalized_mutation_sha256"
|
|
1121
|
+
});
|
|
1122
|
+
|
|
1082
1123
|
// packages/ceal-client-protocol/src/write-safety-finding.ts
|
|
1083
1124
|
var CEAL_WRITE_SAFETY_FINDING_STATUSES = vocabulary(["warning", "unchecked"]);
|
|
1084
1125
|
var CEAL_WRITE_SAFETY_AUDIENCES = vocabulary(["workspace", "person", "members", "unknown"]);
|
|
@@ -1106,7 +1147,11 @@ var CEAL_REFRESH_FAILURE_CODES = vocabulary([
|
|
|
1106
1147
|
"refresh_revoked",
|
|
1107
1148
|
"authority_replaced",
|
|
1108
1149
|
"refresh_recovery_unavailable",
|
|
1109
|
-
"refresh_recovery_expired"
|
|
1150
|
+
"refresh_recovery_expired",
|
|
1151
|
+
// The serving gate answers this while the Gateway is still starting and the
|
|
1152
|
+
// refresh was never attempted; the same attempt stays retryable. It is never
|
|
1153
|
+
// stored by the session owner, only answered at the serving edge.
|
|
1154
|
+
"gateway_starting"
|
|
1110
1155
|
]);
|
|
1111
1156
|
|
|
1112
1157
|
// packages/ceal-client-protocol/src/request-validation-primitives.ts
|
|
@@ -1139,7 +1184,7 @@ var CANCELLATION_STATES = vocabulary(["requested", "cancelled"]);
|
|
|
1139
1184
|
var CEAL_REQUEST_KEYS = Object.freeze(["schema_version", "ceal_request_ref", "created_at", "authority", "prompt_ref", "host_session_ref", "host_turn_ref", "host_source_ref"]);
|
|
1140
1185
|
var CEAL_REQUEST_JSON_SCHEMA = {
|
|
1141
1186
|
type: "object",
|
|
1142
|
-
maxProperties:
|
|
1187
|
+
maxProperties: 11,
|
|
1143
1188
|
additionalProperties: false,
|
|
1144
1189
|
properties: {
|
|
1145
1190
|
schema_version: { type: "string", const: CEAL_REQUEST_SCHEMA_VERSION, maxLength: 32 },
|
|
@@ -1163,7 +1208,8 @@ var CEAL_REQUEST_JSON_SCHEMA = {
|
|
|
1163
1208
|
host_turn_ref: { type: "string", minLength: 1, maxLength: 128, pattern: SAFE_REF.source },
|
|
1164
1209
|
host_input_ref: { type: "string", minLength: 1, maxLength: 128, pattern: SAFE_REF.source },
|
|
1165
1210
|
host_source_ref: { type: "string", minLength: 1, maxLength: 128, pattern: SAFE_REF.source },
|
|
1166
|
-
requester_timezone: { type: "string", minLength: 1, maxLength: 128, description: "IANA timezone observed for the requester on this Request." }
|
|
1211
|
+
requester_timezone: { type: "string", minLength: 1, maxLength: 128, description: "IANA timezone observed for the requester on this Request." },
|
|
1212
|
+
device_ref: { type: "string", minLength: 1, maxLength: 128, pattern: SAFE_REF.source, description: "Device that submitted this Request through its client session; absent for Host turns and older records." }
|
|
1167
1213
|
},
|
|
1168
1214
|
required: CEAL_REQUEST_KEYS
|
|
1169
1215
|
};
|
|
@@ -1222,6 +1268,7 @@ var REQUEST_EXECUTION_PREPARE_REFUSAL_PROPERTIES = {
|
|
|
1222
1268
|
retryable: { type: "boolean" },
|
|
1223
1269
|
source: { type: "string", enum: ["provider", "gateway"] },
|
|
1224
1270
|
retry_after_ms: { type: "integer", minimum: 0, maximum: CEAL_RETRY_AFTER_MAX_MS },
|
|
1271
|
+
write_request_ref: { type: "string", pattern: CEAL_GATEWAY_WRITE_REQUEST_REF_PATTERN.source, maxLength: 128 },
|
|
1225
1272
|
excluded_targets: cealExcludedTargetCoverageJsonSchema(),
|
|
1226
1273
|
repaired_input: {},
|
|
1227
1274
|
unrepaired_pointers: { type: "array", maxItems: 128, items: { type: "string", minLength: 1, maxLength: 256 } },
|
|
@@ -1280,6 +1327,7 @@ function isCealHostInputKind(value) {
|
|
|
1280
1327
|
return typeof value === "string" && CEAL_HOST_INPUT_KINDS.some((kind) => kind === value);
|
|
1281
1328
|
}
|
|
1282
1329
|
var CEAL_HOST_OBSERVATION_REF_PREFIX = "host-observation:";
|
|
1330
|
+
var HOST_TOKEN_OBSERVATION_BREAKDOWN_KEYS = vocabulary(["cached_input", "cache_write_input", "reasoning_output"]);
|
|
1283
1331
|
function validateCealHostObservationDraft(value) {
|
|
1284
1332
|
const record6 = operationRecord(value, "Ceal Host observation draft is invalid.");
|
|
1285
1333
|
requirePrefixedRef(record6.observation_ref, CEAL_HOST_OBSERVATION_REF_PREFIX, "Ceal Host observation reference is invalid.");
|
|
@@ -1433,6 +1481,94 @@ var CEAL_HOST_MINT_REQUEST_CONTEXT_REFUSAL_REASONS = vocabulary([
|
|
|
1433
1481
|
"host_input_mismatch",
|
|
1434
1482
|
"host_prompt_mismatch"
|
|
1435
1483
|
]);
|
|
1484
|
+
var CEAL_HOST_AUTHENTICATION_CAUSES = vocabulary([
|
|
1485
|
+
"invalid_arguments",
|
|
1486
|
+
"options_invalid",
|
|
1487
|
+
"session_unavailable",
|
|
1488
|
+
"context_unavailable",
|
|
1489
|
+
"context_replaced",
|
|
1490
|
+
"no_binding",
|
|
1491
|
+
"context_stale",
|
|
1492
|
+
"context_expired",
|
|
1493
|
+
"host_source_refused",
|
|
1494
|
+
"host_credential_refused",
|
|
1495
|
+
"gateway_unavailable",
|
|
1496
|
+
"gateway_rate_limited",
|
|
1497
|
+
"gateway_refused",
|
|
1498
|
+
"gateway_response_invalid",
|
|
1499
|
+
"producer_frame_invalid",
|
|
1500
|
+
"relay_permission_denied",
|
|
1501
|
+
"relay_unavailable",
|
|
1502
|
+
"transient_retryable",
|
|
1503
|
+
"mint_failed",
|
|
1504
|
+
"relay_failed",
|
|
1505
|
+
"host_refusal_invalid"
|
|
1506
|
+
]);
|
|
1507
|
+
var CEAL_HOST_AUTHENTICATION_POLICY = Object.freeze({
|
|
1508
|
+
invalid_arguments: Object.freeze({ classification: "host_arguments_invalid", next_action: "answer_with_gap" }),
|
|
1509
|
+
options_invalid: Object.freeze({ classification: "host_configuration_invalid", next_action: "answer_with_gap" }),
|
|
1510
|
+
session_unavailable: Object.freeze({ classification: "host_session_unavailable", next_action: "answer_with_gap" }),
|
|
1511
|
+
context_unavailable: Object.freeze({ classification: "host_context_unavailable", next_action: "refresh_host_invocation_context", remedy: "the Host has no invocation context from the current transcript turn; run `ceal-host install` to repair the Host hook registration, then retry this command on a fresh Host turn" }),
|
|
1512
|
+
context_replaced: Object.freeze({ classification: "host_invocation_context_stale", next_action: "refresh_host_invocation_context" }),
|
|
1513
|
+
no_binding: Object.freeze({ classification: "host_binding_unavailable", next_action: "refresh_host_invocation_context" }),
|
|
1514
|
+
context_stale: Object.freeze({ classification: "host_invocation_context_stale", next_action: "refresh_host_invocation_context" }),
|
|
1515
|
+
context_expired: Object.freeze({ classification: "host_invocation_context_expired", next_action: "refresh_host_invocation_context" }),
|
|
1516
|
+
host_source_refused: Object.freeze({ classification: "host_source_refused", next_action: "answer_with_gap" }),
|
|
1517
|
+
host_credential_refused: Object.freeze({ classification: "host_registration_credential_refused", next_action: "ask_admin" }),
|
|
1518
|
+
gateway_unavailable: Object.freeze({ classification: "host_mint_gateway_unavailable", next_action: "ask_admin" }),
|
|
1519
|
+
gateway_rate_limited: Object.freeze({ classification: "host_mint_gateway_rate_limited", next_action: "answer_with_gap" }),
|
|
1520
|
+
gateway_refused: Object.freeze({ classification: "host_mint_gateway_refused", next_action: "answer_with_gap" }),
|
|
1521
|
+
gateway_response_invalid: Object.freeze({ classification: "host_mint_gateway_response_invalid", next_action: "answer_with_gap" }),
|
|
1522
|
+
producer_frame_invalid: Object.freeze({ classification: "host_producer_frame_invalid", next_action: "ask_admin", remedy: "ask an administrator to inspect and repair the producer frame, then start a fresh Host turn" }),
|
|
1523
|
+
relay_permission_denied: Object.freeze({ classification: "host_relay_permission_denied", next_action: "rerun_outside_agent_sandbox", remedy: "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" }),
|
|
1524
|
+
relay_unavailable: Object.freeze({ classification: "host_relay_unavailable", next_action: "answer_with_gap" }),
|
|
1525
|
+
transient_retryable: Object.freeze({ classification: "host_mint_transient_retryable", next_action: "retry" }),
|
|
1526
|
+
mint_failed: Object.freeze({ classification: "host_mint_failed", next_action: "answer_with_gap" }),
|
|
1527
|
+
relay_failed: Object.freeze({ classification: "host_relay_failed", next_action: "answer_with_gap" }),
|
|
1528
|
+
host_refusal_invalid: Object.freeze({ classification: "host_refusal_invalid", next_action: "answer_with_gap" })
|
|
1529
|
+
});
|
|
1530
|
+
function projectCealHostAuthenticationCause(diagnostic) {
|
|
1531
|
+
return projectRelayCodeCause(diagnostic) ?? projectGatewayCodeCause(diagnostic) ?? projectGatewayStatusCause(diagnostic) ?? "mint_failed";
|
|
1532
|
+
}
|
|
1533
|
+
function projectRelayCodeCause(diagnostic) {
|
|
1534
|
+
switch (diagnostic.relayCode) {
|
|
1535
|
+
case "credential":
|
|
1536
|
+
return "host_credential_refused";
|
|
1537
|
+
case "configuration":
|
|
1538
|
+
return "options_invalid";
|
|
1539
|
+
case "payload_rejected":
|
|
1540
|
+
return "producer_frame_invalid";
|
|
1541
|
+
case "invalid_response":
|
|
1542
|
+
return "gateway_response_invalid";
|
|
1543
|
+
case "gateway_refused":
|
|
1544
|
+
return projectGatewayRefusedCause(diagnostic);
|
|
1545
|
+
case "gateway_unavailable":
|
|
1546
|
+
return diagnostic.exhausted === true ? void 0 : "gateway_unavailable";
|
|
1547
|
+
case void 0:
|
|
1548
|
+
case "":
|
|
1549
|
+
return void 0;
|
|
1550
|
+
default:
|
|
1551
|
+
return "mint_failed";
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
function projectGatewayRefusedCause(diagnostic) {
|
|
1555
|
+
if (diagnostic.gatewayStatus === 401 || diagnostic.gatewayStatus === 403) return "host_credential_refused";
|
|
1556
|
+
const stale = projectGatewayCodeCause(diagnostic);
|
|
1557
|
+
if (stale !== void 0) return stale;
|
|
1558
|
+
if (diagnostic.exhausted === true && (diagnostic.gatewayStatus === 408 || diagnostic.gatewayStatus === 429)) return "gateway_rate_limited";
|
|
1559
|
+
return "gateway_refused";
|
|
1560
|
+
}
|
|
1561
|
+
function projectGatewayCodeCause(diagnostic) {
|
|
1562
|
+
if (diagnostic.gatewayCode === "request_context_refused" && diagnostic.gatewayReason !== void 0 && isVocabularyWord(CEAL_HOST_MINT_REQUEST_CONTEXT_REFUSAL_REASONS, diagnostic.gatewayReason)) return "context_stale";
|
|
1563
|
+
if (diagnostic.gatewayCode === "context_expired") return "context_expired";
|
|
1564
|
+
if (diagnostic.gatewayCode === "host_source_refused") return "host_source_refused";
|
|
1565
|
+
return void 0;
|
|
1566
|
+
}
|
|
1567
|
+
function projectGatewayStatusCause(diagnostic) {
|
|
1568
|
+
if (diagnostic.gatewayStatus === 401 || diagnostic.gatewayStatus === 403) return "host_credential_refused";
|
|
1569
|
+
if (diagnostic.exhausted === true && (diagnostic.gatewayStatus === 408 || diagnostic.gatewayStatus === 429)) return "gateway_rate_limited";
|
|
1570
|
+
return void 0;
|
|
1571
|
+
}
|
|
1436
1572
|
function decodeCealHostInvocationAuthenticationResult(value, now = /* @__PURE__ */ new Date()) {
|
|
1437
1573
|
if (!isCealJsonRecord(value) || !exactKeys(value, ["schema_version", "context_token", "expires_at"]) || value.schema_version !== CEAL_HOST_INVOCATION_AUTHENTICATION_RESULT_SCHEMA || typeof value.context_token !== "string" || !CEAL_HOST_CONTEXT_TOKEN_PATTERN.test(value.context_token) || typeof value.expires_at !== "string" || !validFutureTimestamp(value.expires_at, now)) {
|
|
1438
1574
|
throw new TypeError("The Host invocation authentication result is invalid.");
|
|
@@ -1448,11 +1584,36 @@ function exactKeys(value, expected) {
|
|
|
1448
1584
|
return keys.length === expected.length && expected.every((key) => Object.hasOwn(value, key));
|
|
1449
1585
|
}
|
|
1450
1586
|
|
|
1587
|
+
// packages/ceal-client-protocol/src/host-service-diagnostic.ts
|
|
1588
|
+
var CEAL_HOST_SERVICE_DIAGNOSTIC_PRODUCERS = vocabulary(["claude", "codex"]);
|
|
1589
|
+
var CEAL_HOST_SERVICE_DIAGNOSTIC_EVENTS = vocabulary([
|
|
1590
|
+
"hook_invoked",
|
|
1591
|
+
"registration_written",
|
|
1592
|
+
"hook_failed",
|
|
1593
|
+
"watcher_turn_observed",
|
|
1594
|
+
"current_prompt_registered",
|
|
1595
|
+
"current_prompt_registration_failed",
|
|
1596
|
+
"activation_recorded",
|
|
1597
|
+
"activation_failed",
|
|
1598
|
+
"watcher_scan_failed",
|
|
1599
|
+
"activation_wait_skipped",
|
|
1600
|
+
"activation_wait_engaged",
|
|
1601
|
+
"activation_wait_completed",
|
|
1602
|
+
"activation_wait_exhausted"
|
|
1603
|
+
]);
|
|
1604
|
+
var CEAL_HOST_SERVICE_DIAGNOSTIC_FAILURE_KINDS = vocabulary([
|
|
1605
|
+
"malformed_line",
|
|
1606
|
+
"other",
|
|
1607
|
+
"payload_rejected",
|
|
1608
|
+
"read_error",
|
|
1609
|
+
"size_budget",
|
|
1610
|
+
"symlink"
|
|
1611
|
+
]);
|
|
1612
|
+
|
|
1451
1613
|
// packages/ceal-client-protocol/src/client-result-materialization.ts
|
|
1452
1614
|
var CEAL_UNREAD_REASONS = vocabulary(["blocked", "unavailable", "too_large", "unsupported", "download_failed", "permission_denied"]);
|
|
1453
|
-
var
|
|
1454
|
-
var
|
|
1455
|
-
var FIELDS = /* @__PURE__ */ new Set([...REQUIRED_FIELDS2, "local_result_root", "continue_argv", "model_disclosure"]);
|
|
1615
|
+
var REQUIRED_FIELDS2 = Object.freeze(["schema_version", "operation_id", "path", "sha256"]);
|
|
1616
|
+
var FIELDS = /* @__PURE__ */ new Set([...REQUIRED_FIELDS2, "items_path", "row_count", "result_complete", "coverage", "local_result_root", "model_disclosure", "continue_argv", "how_to_read"]);
|
|
1456
1617
|
|
|
1457
1618
|
// packages/ceal-client-protocol/src/gateway-cache-origin-validation.ts
|
|
1458
1619
|
var CEAL_MAX_CACHE_ORIGIN_AGE_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
@@ -1482,14 +1643,6 @@ var CEAL_GATEWAY_ANNOUNCEMENT_POLICY_NON_CLAIMS = vocabulary([
|
|
|
1482
1643
|
"target_specific_scope_not_declared"
|
|
1483
1644
|
]);
|
|
1484
1645
|
|
|
1485
|
-
// packages/ceal-client-protocol/src/gateway-write-identity.ts
|
|
1486
|
-
var CEAL_GATEWAY_WRITE_IDENTITY_ROLES = Object.freeze(["replay_identity", "lookup_handle", "collision_evidence"]);
|
|
1487
|
-
var CEAL_GATEWAY_WRITE_IDENTITY_FIELDS = Object.freeze({
|
|
1488
|
-
replay_identity: "idempotency_claim_sha256",
|
|
1489
|
-
lookup_handle: "write_request_sha256",
|
|
1490
|
-
collision_evidence: "normalized_mutation_sha256"
|
|
1491
|
-
});
|
|
1492
|
-
|
|
1493
1646
|
// packages/ceal-client-protocol/src/gateway-scoped-identity-projection-validation.ts
|
|
1494
1647
|
var PROJECTION_REVISION_KEYS = Object.freeze(["graph_revision", "subject_key_revision", "projection_revision"]);
|
|
1495
1648
|
|
|
@@ -1502,6 +1655,18 @@ var CEAL_SUPPORTED_GATEWAY_PROTOCOL_RANGE = Object.freeze({
|
|
|
1502
1655
|
// packages/ceal-client-protocol/src/admin-projection-vocabulary.ts
|
|
1503
1656
|
var ADMIN_PROJECTION_STATES = vocabulary(["ready", "empty", "partial", "unknown"]);
|
|
1504
1657
|
var ADMIN_VIEW_KINDS = vocabulary(["request_detail", "resource_access_timeline", "weekly_usage"]);
|
|
1658
|
+
var ADMIN_RECORD_PROJECTION_KINDS = vocabulary([
|
|
1659
|
+
"request_list",
|
|
1660
|
+
"usage_series",
|
|
1661
|
+
"connector_health",
|
|
1662
|
+
"person_connections",
|
|
1663
|
+
"client_sessions",
|
|
1664
|
+
"knowledge_base",
|
|
1665
|
+
"change_history",
|
|
1666
|
+
"approval_queue",
|
|
1667
|
+
"access_group_list",
|
|
1668
|
+
"capability_catalogue"
|
|
1669
|
+
]);
|
|
1505
1670
|
var ADMIN_GAP_KINDS = vocabulary(["unknown", "unavailable", "partial"]);
|
|
1506
1671
|
var ADMIN_UNAVAILABLE_REASONS = vocabulary([
|
|
1507
1672
|
"not_recorded",
|
|
@@ -1525,7 +1690,11 @@ var ADMIN_SOURCE_OWNERS = vocabulary([
|
|
|
1525
1690
|
"person",
|
|
1526
1691
|
"resource",
|
|
1527
1692
|
"prompt",
|
|
1528
|
-
"usage"
|
|
1693
|
+
"usage",
|
|
1694
|
+
"connector",
|
|
1695
|
+
"session",
|
|
1696
|
+
"knowledge",
|
|
1697
|
+
"policy"
|
|
1529
1698
|
]);
|
|
1530
1699
|
var ADMIN_COMPLETENESS_STATES = vocabulary(["complete", "partial", "unknown"]);
|
|
1531
1700
|
var ADMIN_OPERATION_OUTCOMES = vocabulary(["completed", "failed", "denied", "cancelled", "unknown"]);
|
|
@@ -1760,6 +1929,15 @@ var FRAME_KINDS = new Set(HOST_PRODUCER_FRAME_KINDS);
|
|
|
1760
1929
|
function isHostProducerFrameKind(value) {
|
|
1761
1930
|
return typeof value === "string" && FRAME_KINDS.has(value);
|
|
1762
1931
|
}
|
|
1932
|
+
var HOST_PRODUCER_FRAME_ERROR_CODES = [
|
|
1933
|
+
"invalid_frame_encoding",
|
|
1934
|
+
"invalid_frame_length",
|
|
1935
|
+
"frame_truncated",
|
|
1936
|
+
"unsupported_frame_schema",
|
|
1937
|
+
"invalid_frame_shape",
|
|
1938
|
+
"invalid_producer_identity",
|
|
1939
|
+
"frame_too_large"
|
|
1940
|
+
];
|
|
1763
1941
|
var HostProducerFrameError = class extends Error {
|
|
1764
1942
|
code;
|
|
1765
1943
|
constructor(code, message = code) {
|
|
@@ -1800,6 +1978,30 @@ function decodeHostProducerFrame(input) {
|
|
|
1800
1978
|
function hostProducerFrameHash(frame) {
|
|
1801
1979
|
return createHash3("sha256").update(JSON.stringify(frame), "utf8").digest("hex");
|
|
1802
1980
|
}
|
|
1981
|
+
function extractHostBindingSelector(frame) {
|
|
1982
|
+
if (frame.frame_kind !== "user_input") return null;
|
|
1983
|
+
if (!PRODUCERS.has(frame.producer_id) || !safeRef(frame.producer_installation_ref)) return null;
|
|
1984
|
+
const payload = frame.payload;
|
|
1985
|
+
if (!safeRef(payload.local_session_ref) || !safeRef(payload.local_turn_ref)) return null;
|
|
1986
|
+
const aliases = payload.local_turn_aliases;
|
|
1987
|
+
if (aliases === void 0) {
|
|
1988
|
+
return Object.freeze({
|
|
1989
|
+
producer_id: frame.producer_id,
|
|
1990
|
+
producer_installation_ref: frame.producer_installation_ref,
|
|
1991
|
+
local_session_ref: payload.local_session_ref,
|
|
1992
|
+
local_turn_ref: payload.local_turn_ref,
|
|
1993
|
+
local_turn_aliases: Object.freeze([])
|
|
1994
|
+
});
|
|
1995
|
+
}
|
|
1996
|
+
if (!Array.isArray(aliases) || aliases.length > 16 || !aliases.every(safeRef) || new Set(aliases).size !== aliases.length) return null;
|
|
1997
|
+
return Object.freeze({
|
|
1998
|
+
producer_id: frame.producer_id,
|
|
1999
|
+
producer_installation_ref: frame.producer_installation_ref,
|
|
2000
|
+
local_session_ref: payload.local_session_ref,
|
|
2001
|
+
local_turn_ref: payload.local_turn_ref,
|
|
2002
|
+
local_turn_aliases: Object.freeze([...aliases])
|
|
2003
|
+
});
|
|
2004
|
+
}
|
|
1803
2005
|
function hostProducerIdentityRefs(hostSourceRef, frame, localSessionRef, localTurnRef, localInputRef) {
|
|
1804
2006
|
if (!opaqueHostSourceRef(hostSourceRef)) throw new TypeError("Gateway host source reference is invalid.");
|
|
1805
2007
|
const host_session_ref = localSessionRef === void 0 ? void 0 : `ceal-host-session:${cealRequestSha256({ host_source_ref: hostSourceRef, producer_id: frame.producer_id, producer_installation_ref: frame.producer_installation_ref, local_session_ref: localSessionRef })}`;
|
|
@@ -1823,6 +2025,31 @@ function hostProducerSubmissionRef(hostSourceRef, frame) {
|
|
|
1823
2025
|
function opaqueHostSourceRef(value) {
|
|
1824
2026
|
return typeof value === "string" && SAFE_REF2.test(value) && !value.startsWith("ceal-host-source:");
|
|
1825
2027
|
}
|
|
2028
|
+
function isHostSafeRef(value) {
|
|
2029
|
+
return safeRef(value);
|
|
2030
|
+
}
|
|
2031
|
+
var BOUNDED_REFUSAL_WORD = /^[a-z][a-z0-9_]{0,63}$/u;
|
|
2032
|
+
function isBoundedRefusalWord(value) {
|
|
2033
|
+
return typeof value === "string" && BOUNDED_REFUSAL_WORD.test(value);
|
|
2034
|
+
}
|
|
2035
|
+
function hasExactKeys2(value, required, optional = []) {
|
|
2036
|
+
return required.every((key) => Object.hasOwn(value, key)) && Object.keys(value).every((key) => required.includes(key) || optional.includes(key));
|
|
2037
|
+
}
|
|
2038
|
+
function isUndefinedOr(value, guard) {
|
|
2039
|
+
return value === void 0 || guard(value);
|
|
2040
|
+
}
|
|
2041
|
+
var HOST_RELAY_GATEWAY_ERROR_CODES = [
|
|
2042
|
+
"configuration",
|
|
2043
|
+
"credential",
|
|
2044
|
+
"gateway_unavailable",
|
|
2045
|
+
"gateway_refused",
|
|
2046
|
+
"invalid_response",
|
|
2047
|
+
"payload_rejected"
|
|
2048
|
+
];
|
|
2049
|
+
function isRelayGatewayErrorCode(value) {
|
|
2050
|
+
return isVocabularyWord(HOST_RELAY_GATEWAY_ERROR_CODES, value);
|
|
2051
|
+
}
|
|
2052
|
+
var RELAY_DELIVERY_DIAGNOSTIC_KEYS = ["relayCode", "gatewayStatus", "gatewayCode", "gatewayReason", "exhausted"];
|
|
1826
2053
|
function requiredIdentity(value) {
|
|
1827
2054
|
if (value === void 0) throw new TypeError("Canonical Host identity is incomplete.");
|
|
1828
2055
|
return value;
|
|
@@ -2251,6 +2478,8 @@ var RELAY_QUARANTINE_MAX_RECORDS = 512;
|
|
|
2251
2478
|
var RELAY_QUARANTINE_MAX_BYTES = 16 * 1024 * 1024;
|
|
2252
2479
|
var MAX_CAPTURE_BYTES = 262148;
|
|
2253
2480
|
var PRODUCERS2 = ["codex", "claude", "unknown"];
|
|
2481
|
+
var RELAY_QUARANTINE_FRAME_REASONS = ["frame_identity_conflict", "sequence_gap", "gateway_refused"];
|
|
2482
|
+
var RELAY_QUARANTINE_REASONS = [...RELAY_QUARANTINE_FRAME_REASONS, ...HOST_PRODUCER_FRAME_ERROR_CODES];
|
|
2254
2483
|
var RelayQuarantineStore = class {
|
|
2255
2484
|
root;
|
|
2256
2485
|
maxRecords;
|
|
@@ -2263,8 +2492,8 @@ var RelayQuarantineStore = class {
|
|
|
2263
2492
|
if (!Number.isSafeInteger(this.maxRecords) || this.maxRecords < 1 || this.maxRecords > RELAY_QUARANTINE_MAX_RECORDS) throw new TypeError(`Relay quarantine record cap is invalid: ${refusalFact("max_records", this.maxRecords, `between 1 and ${RELAY_QUARANTINE_MAX_RECORDS}`)}.`);
|
|
2264
2493
|
if (!Number.isSafeInteger(this.maxBytes) || this.maxBytes < 1 || this.maxBytes > RELAY_QUARANTINE_MAX_BYTES) throw new TypeError(`Relay quarantine byte cap is invalid: ${refusalFact("max_bytes", this.maxBytes, `between 1 and ${RELAY_QUARANTINE_MAX_BYTES}`)}.`);
|
|
2265
2494
|
}
|
|
2266
|
-
async retainFrame(frame, reason, capturedAt = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
2267
|
-
await this.retain(encodeHostProducerFrame(frame), frame.producer_id, reason, capturedAt);
|
|
2495
|
+
async retainFrame(frame, reason, attribution, capturedAt = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
2496
|
+
await this.retain(encodeHostProducerFrame(frame), frame.producer_id, reason, capturedAt, attribution);
|
|
2268
2497
|
}
|
|
2269
2498
|
async retainMalformed(rawFrame, reason, capturedAt = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
2270
2499
|
await this.retain(rawFrame, inferProducer(rawFrame), reason, capturedAt);
|
|
@@ -2276,11 +2505,26 @@ var RelayQuarantineStore = class {
|
|
|
2276
2505
|
const records = state.producers[producerId].slice(-Math.min(limit, this.maxRecords)).map((record6) => structuredClone(record6));
|
|
2277
2506
|
return { producer_id: producerId, records, total_bytes: records.reduce((total, record6) => total + record6.charged_bytes, 0) };
|
|
2278
2507
|
}
|
|
2508
|
+
/**
|
|
2509
|
+
* The newest quarantined record whose exact-turn attribution matches the
|
|
2510
|
+
* query, or null when evicted, unattributed, or for another turn. The
|
|
2511
|
+
* file-backed state survives drain, restart, and overwrite.
|
|
2512
|
+
*/
|
|
2513
|
+
async findNewestAttributedMatch(query) {
|
|
2514
|
+
await this.tail;
|
|
2515
|
+
const state = await this.readState();
|
|
2516
|
+
const bucket = query.producer_id === "codex" || query.producer_id === "claude" ? state.producers[query.producer_id] : [];
|
|
2517
|
+
for (let index = bucket.length - 1; index >= 0; index -= 1) {
|
|
2518
|
+
const record6 = bucket[index];
|
|
2519
|
+
if (record6 !== void 0 && attributedRecordMatchesQuery(record6, query)) return structuredClone(record6);
|
|
2520
|
+
}
|
|
2521
|
+
return null;
|
|
2522
|
+
}
|
|
2279
2523
|
async snapshot() {
|
|
2280
2524
|
await this.tail;
|
|
2281
2525
|
return this.readState();
|
|
2282
2526
|
}
|
|
2283
|
-
async retain(rawFrame, producerId, reason, capturedAt) {
|
|
2527
|
+
async retain(rawFrame, producerId, reason, capturedAt, attribution) {
|
|
2284
2528
|
const run = this.tail.then(async () => {
|
|
2285
2529
|
if (!PRODUCERS2.includes(producerId) || !Number.isFinite(Date.parse(capturedAt))) throw new TypeError("Relay quarantine record identity is invalid.");
|
|
2286
2530
|
const raw = Buffer.from(rawFrame).subarray(0, MAX_CAPTURE_BYTES);
|
|
@@ -2292,7 +2536,8 @@ var RelayQuarantineStore = class {
|
|
|
2292
2536
|
captured_at: capturedAt,
|
|
2293
2537
|
frame_sha256: createHash4("sha256").update(raw).digest("hex"),
|
|
2294
2538
|
charged_bytes: raw.byteLength,
|
|
2295
|
-
raw_frame_base64: raw.toString("base64")
|
|
2539
|
+
raw_frame_base64: raw.toString("base64"),
|
|
2540
|
+
...attribution === void 0 ? {} : { attribution: structuredClone(attribution) }
|
|
2296
2541
|
};
|
|
2297
2542
|
const records = state.producers[producerId];
|
|
2298
2543
|
records.push(record6);
|
|
@@ -2329,8 +2574,47 @@ function decodeState2(value) {
|
|
|
2329
2574
|
return state;
|
|
2330
2575
|
}
|
|
2331
2576
|
function validRecord(value) {
|
|
2332
|
-
if (!record3(value) ||
|
|
2333
|
-
return
|
|
2577
|
+
if (!record3(value) || !validRecordIdentity(value)) return false;
|
|
2578
|
+
return value.attribution === void 0 || validAttribution(value.attribution);
|
|
2579
|
+
}
|
|
2580
|
+
function validRecordIdentity(value) {
|
|
2581
|
+
return typeof value.quarantine_ref === "string" && quarantineProducer(value.producer_id) && validReason(value.reason) && Number.isFinite(Date.parse(String(value.captured_at))) && typeof value.frame_sha256 === "string" && typeof value.raw_frame_base64 === "string" && validChargedBytes(value.charged_bytes);
|
|
2582
|
+
}
|
|
2583
|
+
function validReason(value) {
|
|
2584
|
+
return typeof value === "string" && RELAY_QUARANTINE_REASONS.includes(value);
|
|
2585
|
+
}
|
|
2586
|
+
function validChargedBytes(value) {
|
|
2587
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
2588
|
+
}
|
|
2589
|
+
var ATTRIBUTION_REQUIRED_KEYS = ["producer_id", "producer_installation_ref", "local_session_ref", "local_turn_ref", "local_turn_aliases", "sequence", "frame_sha256"];
|
|
2590
|
+
var ATTRIBUTION_OPTIONAL_KEYS = ["diagnostic"];
|
|
2591
|
+
function validAttribution(value) {
|
|
2592
|
+
if (!record3(value) || !hasExactKeys2(value, ATTRIBUTION_REQUIRED_KEYS, ATTRIBUTION_OPTIONAL_KEYS)) return false;
|
|
2593
|
+
return validAttributionIdentity(value) && validAttributionAliases(value.local_turn_aliases) && validAttributionEnvelope(value) && (value.diagnostic === void 0 || validAttributionDiagnostic(value.diagnostic));
|
|
2594
|
+
}
|
|
2595
|
+
function validAttributionIdentity(value) {
|
|
2596
|
+
return (value.producer_id === "codex" || value.producer_id === "claude") && isHostSafeRef(value.producer_installation_ref) && isHostSafeRef(value.local_session_ref) && isHostSafeRef(value.local_turn_ref);
|
|
2597
|
+
}
|
|
2598
|
+
function validAttributionAliases(value) {
|
|
2599
|
+
return Array.isArray(value) && value.length <= 16 && value.every(isHostSafeRef);
|
|
2600
|
+
}
|
|
2601
|
+
function validAttributionEnvelope(value) {
|
|
2602
|
+
return typeof value.sequence === "number" && Number.isSafeInteger(value.sequence) && value.sequence > 0 && typeof value.frame_sha256 === "string";
|
|
2603
|
+
}
|
|
2604
|
+
function validAttributionDiagnostic(value) {
|
|
2605
|
+
if (!record3(value) || !hasExactKeys2(value, [], RELAY_DELIVERY_DIAGNOSTIC_KEYS)) return false;
|
|
2606
|
+
return isUndefinedOr(value.relayCode, isRelayGatewayErrorCode) && isUndefinedOr(value.gatewayStatus, isSafeInteger) && isUndefinedOr(value.gatewayCode, isBoundedRefusalWord) && isUndefinedOr(value.gatewayReason, isBoundedRefusalWord) && isUndefinedOr(value.exhausted, isBoolean);
|
|
2607
|
+
}
|
|
2608
|
+
function isSafeInteger(value) {
|
|
2609
|
+
return Number.isSafeInteger(value);
|
|
2610
|
+
}
|
|
2611
|
+
function isBoolean(value) {
|
|
2612
|
+
return typeof value === "boolean";
|
|
2613
|
+
}
|
|
2614
|
+
function attributedRecordMatchesQuery(recordValue, query) {
|
|
2615
|
+
const attribution = recordValue.attribution;
|
|
2616
|
+
if (attribution === void 0) return false;
|
|
2617
|
+
return attribution.producer_id === query.producer_id && attribution.producer_installation_ref === query.producer_installation_ref && attribution.local_session_ref === query.local_session_ref && (attribution.local_turn_ref === query.local_turn_ref || attribution.local_turn_aliases.includes(query.local_turn_ref));
|
|
2334
2618
|
}
|
|
2335
2619
|
function quarantineProducer(value) {
|
|
2336
2620
|
return value === "codex" || value === "claude" || value === "unknown";
|
|
@@ -2418,11 +2702,11 @@ var RelayAdmissionStore = class {
|
|
|
2418
2702
|
const hash = hostProducerFrameHash(frame);
|
|
2419
2703
|
const replay = replayCode(existing, hash, frame.sequence, installation2);
|
|
2420
2704
|
if (replay !== null) {
|
|
2421
|
-
if (replay === "frame_identity_conflict") await this.quarantine.retainFrame(frame, replay);
|
|
2705
|
+
if (replay === "frame_identity_conflict") await this.quarantine.retainFrame(frame, replay, attributionForFrame(frame, hash, frame.sequence));
|
|
2422
2706
|
return result(replay, installation2);
|
|
2423
2707
|
}
|
|
2424
2708
|
if (frame.sequence !== installation2.admitted_through_sequence + 1) {
|
|
2425
|
-
await this.quarantine.retainFrame(frame, "sequence_gap");
|
|
2709
|
+
await this.quarantine.retainFrame(frame, "sequence_gap", attributionForFrame(frame, hash, frame.sequence));
|
|
2426
2710
|
return result("sequence_gap", installation2);
|
|
2427
2711
|
}
|
|
2428
2712
|
const chargedBytes = 4 + Buffer.byteLength(JSON.stringify(frame), "utf8");
|
|
@@ -2468,8 +2752,9 @@ var RelayAdmissionStore = class {
|
|
|
2468
2752
|
const installation2 = state.installations[installationKey(head.frame)];
|
|
2469
2753
|
if (!installation2) throw new TypeError("Host Relay delivery installation is unavailable.");
|
|
2470
2754
|
if (outcome.status === "refused" || exhausted) {
|
|
2471
|
-
|
|
2472
|
-
|
|
2755
|
+
const diagnostic = exhaustedDiagnostic(outcome, exhausted);
|
|
2756
|
+
await this.quarantine.retainFrame(head.frame, "gateway_refused", attributionForFrame(head.frame, head.hash, head.sequence, diagnostic));
|
|
2757
|
+
installation2.last_refusal = { sequence: head.sequence, submission_ref: input.submission_ref, ...refusalCause(outcome, head), ...diagnostic === void 0 ? {} : { diagnostic }, refused_at_ms: options.now_ms };
|
|
2473
2758
|
refused.push(input.submission_ref);
|
|
2474
2759
|
} else {
|
|
2475
2760
|
await options.after_gateway_accept_before_delivery_fsync?.({ fault_point: "after_gateway_accept_before_delivery_fsync", delivery: structuredClone(input) });
|
|
@@ -2513,17 +2798,22 @@ function installationKey(frame) {
|
|
|
2513
2798
|
return `${frame.producer_id}\0${frame.producer_installation_ref}`;
|
|
2514
2799
|
}
|
|
2515
2800
|
function pendingFrameMatchesBindingQuery(entry2, query) {
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2801
|
+
const selector = extractHostBindingSelector(entry2.frame);
|
|
2802
|
+
if (selector === null) return false;
|
|
2803
|
+
return relayRequestBindingMatchesQuery(query, selector);
|
|
2804
|
+
}
|
|
2805
|
+
function attributionForFrame(frame, hash, sequence, diagnostic) {
|
|
2806
|
+
const selector = extractHostBindingSelector(frame);
|
|
2807
|
+
if (selector === null) return void 0;
|
|
2808
|
+
if (frame.producer_id !== selector.producer_id || frame.producer_installation_ref !== selector.producer_installation_ref || frame.sequence !== sequence) return void 0;
|
|
2809
|
+
if (hostProducerFrameHash(frame) !== hash) return void 0;
|
|
2810
|
+
return { ...selector, sequence, frame_sha256: hash, ...diagnostic === void 0 ? {} : { diagnostic } };
|
|
2811
|
+
}
|
|
2812
|
+
function exhaustedDiagnostic(outcome, exhausted) {
|
|
2813
|
+
if (outcome.status !== "retryable" && outcome.status !== "refused") return void 0;
|
|
2814
|
+
if (outcome.diagnostic !== void 0) return exhausted ? { ...outcome.diagnostic, exhausted: true } : outcome.diagnostic;
|
|
2815
|
+
if (exhausted) return { exhausted: true };
|
|
2816
|
+
return void 0;
|
|
2527
2817
|
}
|
|
2528
2818
|
function replayCode(existing, hash, sequence, installation2) {
|
|
2529
2819
|
if (existing !== void 0) return existing.hash === hash ? "already_admitted" : "frame_identity_conflict";
|
|
@@ -2575,7 +2865,17 @@ function installation(value) {
|
|
|
2575
2865
|
return typeof value === "object" && value !== null && !Array.isArray(value) && "epoch" in value && "admitted_through_sequence" in value && "delivered_through_sequence" in value && [value.epoch, value.admitted_through_sequence, value.delivered_through_sequence].every(Number.isSafeInteger) && (!("last_refusal" in value) || refusalRecord(value.last_refusal));
|
|
2576
2866
|
}
|
|
2577
2867
|
function refusalRecord(value) {
|
|
2578
|
-
return object(value) && Number.isSafeInteger(value.sequence) && typeof value.submission_ref === "string" && typeof value.code === "string" && typeof value.message === "string" && Number.isSafeInteger(value.refused_at_ms);
|
|
2868
|
+
return object(value) && Number.isSafeInteger(value.sequence) && typeof value.submission_ref === "string" && typeof value.code === "string" && typeof value.message === "string" && Number.isSafeInteger(value.refused_at_ms) && (value.diagnostic === void 0 || validDiagnostic(value.diagnostic));
|
|
2869
|
+
}
|
|
2870
|
+
function validDiagnostic(value) {
|
|
2871
|
+
if (!object(value) || !hasExactKeys2(value, [], RELAY_DELIVERY_DIAGNOSTIC_KEYS)) return false;
|
|
2872
|
+
return isUndefinedOr(value.relayCode, isRelayGatewayErrorCode) && isUndefinedOr(value.gatewayStatus, isSafeInteger2) && isUndefinedOr(value.gatewayCode, isBoundedRefusalWord) && isUndefinedOr(value.gatewayReason, isBoundedRefusalWord) && isUndefinedOr(value.exhausted, isBoolean2);
|
|
2873
|
+
}
|
|
2874
|
+
function isSafeInteger2(value) {
|
|
2875
|
+
return Number.isSafeInteger(value);
|
|
2876
|
+
}
|
|
2877
|
+
function isBoolean2(value) {
|
|
2878
|
+
return typeof value === "boolean";
|
|
2579
2879
|
}
|
|
2580
2880
|
function entry(value) {
|
|
2581
2881
|
return object(value) && producer2(value.producer_id) && typeof value.producer_installation_ref === "string" && Number.isSafeInteger(value.sequence) && typeof value.hash === "string" && Number.isSafeInteger(value.charged_bytes) && object(value.frame) && Number.isSafeInteger(value.retry_attempts) && Number.isSafeInteger(value.retry_at_ms);
|
|
@@ -2783,10 +3083,22 @@ function submissionRefusal(error) {
|
|
|
2783
3083
|
const status = isRecord(error) && typeof error.status === "number" ? error.status : void 0;
|
|
2784
3084
|
const code = errorCode7(error) ?? "gateway_unavailable";
|
|
2785
3085
|
const definitive = code === "payload_rejected" || status !== void 0 && status >= 400 && status < 500 && !RETRYABLE_HTTP_STATUSES.has(status);
|
|
2786
|
-
return { code, message: errorMessage(error), definitive };
|
|
3086
|
+
return { code, message: errorMessage(error), definitive, diagnostic: typedDiagnostic(error, status) };
|
|
3087
|
+
}
|
|
3088
|
+
function typedDiagnostic(error, status) {
|
|
3089
|
+
if (!isRecord(error)) return status === void 0 ? {} : { gatewayStatus: status };
|
|
3090
|
+
const gatewayCode = isBoundedRefusalWord(error.error_code) ? error.error_code : void 0;
|
|
3091
|
+
const gatewayReason = isBoundedRefusalWord(error.refusal_reason) ? error.refusal_reason : void 0;
|
|
3092
|
+
return {
|
|
3093
|
+
...typeof error.code === "string" ? { relayCode: error.code } : {},
|
|
3094
|
+
...status === void 0 ? {} : { gatewayStatus: status },
|
|
3095
|
+
...gatewayCode === void 0 ? {} : { gatewayCode },
|
|
3096
|
+
...gatewayReason === void 0 ? {} : { gatewayReason }
|
|
3097
|
+
};
|
|
2787
3098
|
}
|
|
2788
3099
|
function deliveryRefusal(refusal) {
|
|
2789
|
-
|
|
3100
|
+
const diagnostic = refusal.diagnostic === void 0 ? {} : { diagnostic: refusal.diagnostic };
|
|
3101
|
+
return refusal.definitive ? { status: "refused", code: refusal.code, message: refusal.message, ...diagnostic } : { status: "retryable", reason: `${refusal.code}: ${refusal.message}`, ...diagnostic };
|
|
2790
3102
|
}
|
|
2791
3103
|
function errorMessage(error) {
|
|
2792
3104
|
return error instanceof Error ? error.message : String(error);
|
|
@@ -3009,6 +3321,10 @@ async function gatewayRefusal(response2) {
|
|
|
3009
3321
|
return {};
|
|
3010
3322
|
}
|
|
3011
3323
|
}
|
|
3324
|
+
function submitRefusalCode(body) {
|
|
3325
|
+
if (!isCealJsonRecord(body) || typeof body.error_code !== "string" || !GATEWAY_REFUSAL_CODE_PATTERN.test(body.error_code)) return void 0;
|
|
3326
|
+
return body.error_code;
|
|
3327
|
+
}
|
|
3012
3328
|
function refusalMessage(status, body) {
|
|
3013
3329
|
const record6 = isCealJsonRecord(body) ? body : {};
|
|
3014
3330
|
const code = typeof record6.error_code === "string" ? record6.error_code : "unknown";
|
|
@@ -3036,7 +3352,7 @@ function createHostRelayGatewayHttpPort(options) {
|
|
|
3036
3352
|
invalidEventTime: () => new HostRelayGatewayError("payload_rejected", "Host Relay submission has no event time."),
|
|
3037
3353
|
unavailable: () => new HostRelayGatewayError("gateway_unavailable", "Gateway Host ingress is unavailable."),
|
|
3038
3354
|
invalidResponse: () => new HostRelayGatewayError("invalid_response", "Gateway Host ingress response is not JSON."),
|
|
3039
|
-
refused: (status, body) => new HostRelayGatewayError("gateway_refused", refusalMessage(status, body), status),
|
|
3355
|
+
refused: (status, body) => new HostRelayGatewayError("gateway_refused", refusalMessage(status, body), status, submitRefusalCode(body)),
|
|
3040
3356
|
acknowledgement
|
|
3041
3357
|
});
|
|
3042
3358
|
},
|
|
@@ -3258,6 +3574,8 @@ var HOST_RELAY_INVOCATION_MINT_REFUSAL_REASONS = vocabulary([
|
|
|
3258
3574
|
"gateway_unavailable",
|
|
3259
3575
|
"gateway_refused",
|
|
3260
3576
|
"gateway_response_invalid",
|
|
3577
|
+
"gateway_rate_limited",
|
|
3578
|
+
"producer_frame_invalid",
|
|
3261
3579
|
"deadline",
|
|
3262
3580
|
"cancelled",
|
|
3263
3581
|
"mint_failed",
|
|
@@ -3271,6 +3589,17 @@ var HOST_RELAY_INVOCATION_MINT_REFUSAL_REASONS = vocabulary([
|
|
|
3271
3589
|
"host_input_mismatch",
|
|
3272
3590
|
"host_prompt_mismatch"
|
|
3273
3591
|
]);
|
|
3592
|
+
var HOST_RELAY_DIRECT_WIRE_MINT_REASONS = vocabulary([
|
|
3593
|
+
"context_stale",
|
|
3594
|
+
"context_expired",
|
|
3595
|
+
"host_source_refused",
|
|
3596
|
+
"host_credential_refused",
|
|
3597
|
+
"gateway_unavailable",
|
|
3598
|
+
"gateway_rate_limited",
|
|
3599
|
+
"gateway_refused",
|
|
3600
|
+
"gateway_response_invalid",
|
|
3601
|
+
"producer_frame_invalid"
|
|
3602
|
+
]);
|
|
3274
3603
|
var HostRelayInvocationMintRefusal = class extends Error {
|
|
3275
3604
|
reason;
|
|
3276
3605
|
constructor(reason) {
|
|
@@ -3500,30 +3829,62 @@ async function resolveInvocationContext(request2, admission, bindings, currentPr
|
|
|
3500
3829
|
const query = bindingQueryFromRequest(request2);
|
|
3501
3830
|
const expectedSequences = pendingAdmissionSequences(await admission.snapshot(), query);
|
|
3502
3831
|
const binding = await waitForRequestBinding(query, admission, bindings, signal);
|
|
3503
|
-
if (binding.status !== "ready") return unboundInvocationContextRefusal(await admission.snapshot(), query, expectedSequences) ?? { schema_version: HOST_RELAY_INVOCATION_CONTEXT_RESULT_SCHEMA, status: "no_binding" };
|
|
3832
|
+
if (binding.status !== "ready") return await unboundInvocationContextRefusal(admission, await admission.snapshot(), query, expectedSequences) ?? { schema_version: HOST_RELAY_INVOCATION_CONTEXT_RESULT_SCHEMA, status: "no_binding" };
|
|
3504
3833
|
const currentPrompt = currentPrompts.take({ producer_id: request2.producer_id, producer_installation_ref: request2.producer_installation_ref, local_session_ref: request2.local_session_ref, local_turn_ref: request2.local_turn_ref, prompt_ref: binding.binding.prompt_ref });
|
|
3505
3834
|
let result2;
|
|
3506
3835
|
try {
|
|
3507
|
-
result2 = await mint({ client_nonce: request2.client_nonce, context_expires_at: binding.binding.context_expires_at ?? binding.binding.bound_at, request_work_context: relayRequestWorkContextFromBinding(binding.binding), ...currentPrompt === void 0 ? {} : { current_prompt: currentPrompt } }, signal);
|
|
3836
|
+
result2 = await mint({ client_nonce: request2.client_nonce, context_expires_at: binding.binding.context_expires_at ?? binding.binding.bound_at, request_work_context: relayRequestWorkContextFromBinding(binding.binding), ...currentPrompt === void 0 ? {} : { current_prompt: currentPrompt }, ...request2.visible_output_max_bytes === void 0 ? {} : { visible_output_max_bytes: request2.visible_output_max_bytes } }, signal);
|
|
3508
3837
|
} catch (error) {
|
|
3509
3838
|
return { schema_version: HOST_RELAY_INVOCATION_CONTEXT_RESULT_SCHEMA, status: "refused", reason: error instanceof HostRelayInvocationMintRefusal ? error.reason : "mint_failed" };
|
|
3510
3839
|
}
|
|
3511
3840
|
return { schema_version: HOST_RELAY_INVOCATION_CONTEXT_RESULT_SCHEMA, status: "ready", result: result2 };
|
|
3512
3841
|
}
|
|
3513
|
-
function unboundInvocationContextRefusal(snapshot, query, expectedSequences) {
|
|
3514
|
-
if (expectedSequences.length
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3842
|
+
async function unboundInvocationContextRefusal(admission, snapshot, query, expectedSequences) {
|
|
3843
|
+
if (expectedSequences.length > 0) {
|
|
3844
|
+
const refusal = snapshot.installations[`${query.producer_id}\0${query.producer_installation_ref}`]?.last_refusal;
|
|
3845
|
+
if (refusal !== void 0 && expectedSequences.includes(refusal.sequence)) {
|
|
3846
|
+
const reason2 = mintReasonForDeliveryRefusal(refusal.code, refusal.diagnostic);
|
|
3847
|
+
if (reason2 !== void 0) return { schema_version: HOST_RELAY_INVOCATION_CONTEXT_RESULT_SCHEMA, status: "refused", reason: reason2 };
|
|
3848
|
+
}
|
|
3849
|
+
}
|
|
3850
|
+
const selector = Object.freeze({
|
|
3851
|
+
producer_id: query.producer_id,
|
|
3852
|
+
producer_installation_ref: query.producer_installation_ref,
|
|
3853
|
+
local_session_ref: query.local_session_ref,
|
|
3854
|
+
local_turn_ref: query.local_turn_ref,
|
|
3855
|
+
local_turn_aliases: Object.freeze([])
|
|
3856
|
+
});
|
|
3857
|
+
const match = await admission.quarantine.findNewestAttributedMatch(selector);
|
|
3858
|
+
if (match === null) return null;
|
|
3859
|
+
const reason = mintReasonForQuarantinedMatch(match);
|
|
3860
|
+
if (reason === void 0) return null;
|
|
3861
|
+
return { schema_version: HOST_RELAY_INVOCATION_CONTEXT_RESULT_SCHEMA, status: "refused", reason };
|
|
3862
|
+
}
|
|
3863
|
+
function mintReasonForDeliveryRefusal(code, diagnostic) {
|
|
3864
|
+
if (code !== "gateway_refused") return void 0;
|
|
3865
|
+
if (diagnostic === void 0) return "gateway_refused";
|
|
3866
|
+
return mintReasonForWireCause(projectCealHostAuthenticationCause(diagnostic));
|
|
3867
|
+
}
|
|
3868
|
+
function mintReasonForQuarantinedMatch(match) {
|
|
3869
|
+
if (match === null) return void 0;
|
|
3870
|
+
if (match.reason !== "gateway_refused") return "producer_frame_invalid";
|
|
3871
|
+
const diagnostic = match.attribution?.diagnostic;
|
|
3872
|
+
if (diagnostic === void 0) return void 0;
|
|
3873
|
+
return mintReasonForWireCause(projectCealHostAuthenticationCause(diagnostic));
|
|
3874
|
+
}
|
|
3875
|
+
function mintReasonForWireCause(cause) {
|
|
3876
|
+
if (isDirectWireCause(cause)) return cause;
|
|
3877
|
+
if (cause === "relay_failed" || cause === "relay_unavailable" || cause === "options_invalid") return "relay_failed";
|
|
3878
|
+
return "mint_failed";
|
|
3879
|
+
}
|
|
3880
|
+
function isDirectWireCause(cause) {
|
|
3881
|
+
return isVocabularyWord(HOST_RELAY_DIRECT_WIRE_MINT_REASONS, cause);
|
|
3518
3882
|
}
|
|
3519
3883
|
function pendingAdmissionSequences(snapshot, query) {
|
|
3520
3884
|
const sequences = [];
|
|
3521
3885
|
for (const entry2 of snapshot.entries) {
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
if (typeof payload.local_session_ref !== "string" || typeof payload.local_turn_ref !== "string") continue;
|
|
3525
|
-
const aliases = Array.isArray(payload.local_turn_aliases) ? payload.local_turn_aliases.filter((value) => typeof value === "string") : [];
|
|
3526
|
-
if (!relayRequestBindingMatchesQuery(query, { producer_id: entry2.frame.producer_id, producer_installation_ref: entry2.frame.producer_installation_ref, local_session_ref: payload.local_session_ref, local_turn_ref: payload.local_turn_ref, local_turn_aliases: aliases })) continue;
|
|
3886
|
+
const selector = extractHostBindingSelector(entry2.frame);
|
|
3887
|
+
if (selector === null || !relayRequestBindingMatchesQuery(query, selector)) continue;
|
|
3527
3888
|
sequences.push(entry2.sequence);
|
|
3528
3889
|
}
|
|
3529
3890
|
return sequences;
|
|
@@ -3645,11 +4006,14 @@ function bindingQueryFromRequest(value) {
|
|
|
3645
4006
|
return { producer_id: value.producer_id, producer_installation_ref: value.producer_installation_ref, local_session_ref: value.local_session_ref, local_turn_ref: value.local_turn_ref };
|
|
3646
4007
|
}
|
|
3647
4008
|
function validInvocationContextQueryRequest(value) {
|
|
3648
|
-
return validQueryIdentity(value, HOST_RELAY_INVOCATION_CONTEXT_QUERY_SCHEMA) && exactKeys4(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);
|
|
4009
|
+
return validQueryIdentity(value, HOST_RELAY_INVOCATION_CONTEXT_QUERY_SCHEMA) && exactKeys4(value, ["schema_version", "producer_id", "producer_installation_ref", "local_session_ref", "local_turn_ref", "client_nonce"], ["visible_output_max_bytes"]) && typeof value.client_nonce === "string" && CEAL_HOST_CLIENT_NONCE_PATTERN.test(value.client_nonce) && (value.visible_output_max_bytes === void 0 || validVisibleOutputBudget(value.visible_output_max_bytes));
|
|
3649
4010
|
}
|
|
3650
4011
|
function validQueryIdentity(value, schema) {
|
|
3651
4012
|
return record4(value) && value.schema_version === schema && (value.producer_id === "codex" || value.producer_id === "claude") && safeRef3(value.producer_installation_ref) && safeRef3(value.local_session_ref) && safeRef3(value.local_turn_ref);
|
|
3652
4013
|
}
|
|
4014
|
+
function validVisibleOutputBudget(value) {
|
|
4015
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value > 0 && value <= CEAL_CANONICAL_HTTP_MAX_RESPONSE_BYTES;
|
|
4016
|
+
}
|
|
3653
4017
|
function decodeLengthPrefixedJson(input, maximum) {
|
|
3654
4018
|
if (input.length < HOST_RELAY_IPC_LENGTH_BYTES) return null;
|
|
3655
4019
|
const length = input.readUInt32BE(0);
|
|
@@ -3672,8 +4036,9 @@ function encodeLengthPrefixed(value) {
|
|
|
3672
4036
|
function currentPromptWire(value) {
|
|
3673
4037
|
return value.subarray(HOST_RELAY_IPC_LENGTH_BYTES, Math.min(value.length, HOST_RELAY_IPC_LENGTH_BYTES + 128)).includes(Buffer.from(`"schema_version":"${HOST_RELAY_CURRENT_PROMPT_REGISTER_SCHEMA}"`, "utf8"));
|
|
3674
4038
|
}
|
|
3675
|
-
function exactKeys4(value,
|
|
3676
|
-
|
|
4039
|
+
function exactKeys4(value, required, optional = []) {
|
|
4040
|
+
const keys = Object.keys(value);
|
|
4041
|
+
return required.every((key) => Object.hasOwn(value, key)) && keys.every((key) => required.includes(key) || optional.includes(key));
|
|
3677
4042
|
}
|
|
3678
4043
|
function safeRef3(value) {
|
|
3679
4044
|
return typeof value === "string" && /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u.test(value);
|