@corca-org/ceal-host-linux-arm64 1.0.5 → 1.0.7
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 +35 -17
- package/libexec/ceal-host/claude-invocation-authentication.mjs +2680 -0
- package/libexec/ceal-host/claude-producer.mjs +34 -18
- package/libexec/ceal-host/codex-hook.mjs +38 -21
- package/libexec/ceal-host/codex-invocation-authentication.mjs +49 -31
- package/libexec/ceal-host/codex-producer.mjs +38 -21
- package/libexec/ceal-host/control.mjs +97 -68
- package/libexec/ceal-host/relay.mjs +44 -26
- package/package.json +1 -1
- package/share/ceal-host/bundle-manifest.json +19 -11
- package/share/ceal-host/bundle-manifest.sigstore.json +1 -1
|
@@ -2176,6 +2176,7 @@ var CEAL_OPERATION_RECOVERY_KINDS = vocabulary(["none", "reconcile", "compensate
|
|
|
2176
2176
|
var CEAL_OPERATION_RECOVERY_STATUSES = vocabulary(["not_started", "active", "completed"]);
|
|
2177
2177
|
var CEAL_OPERATION_PROVIDER_READBACK_AVAILABILITY = vocabulary(["not_started", "not_applicable", "not_available", "pending", "available"]);
|
|
2178
2178
|
var CEAL_OPERATION_OFFERED_HANDOFF_STATES = vocabulary(["accepted", "rejected", "unknown"]);
|
|
2179
|
+
var CEAL_OPERATION_RECEIPT_AUTHORITY_KEYS = Object.freeze(["instance_ref", "profile_ref", "principal_ref", "execution_subject_ref", "authority_revision_ref"]);
|
|
2179
2180
|
var CEAL_OPERATION_APPROVAL_DISPOSITIONS = vocabulary([
|
|
2180
2181
|
"approval_not_required_by_policy",
|
|
2181
2182
|
"interactive_pending",
|
|
@@ -2432,7 +2433,13 @@ var CEAL_OPERATION_JSON_SCHEMA_BUDGET = Object.freeze({
|
|
|
2432
2433
|
max_string_length: OPERATION_SCHEMA_LITERAL_MAX_BYTES / 4,
|
|
2433
2434
|
max_alternatives: 8,
|
|
2434
2435
|
max_enum_values: 64,
|
|
2435
|
-
max_literal_bytes: OPERATION_SCHEMA_LITERAL_MAX_BYTES
|
|
2436
|
+
max_literal_bytes: OPERATION_SCHEMA_LITERAL_MAX_BYTES,
|
|
2437
|
+
/** @basis our_policy -- bounds explanatory schema prose carried in one catalog. */
|
|
2438
|
+
max_description_characters: 1024,
|
|
2439
|
+
/** @basis our_policy -- bounds regular-expression compilation input from one schema. */
|
|
2440
|
+
max_pattern_characters: 256,
|
|
2441
|
+
/** @basis our_policy -- bounds traversal work inside one already byte-bounded schema literal. */
|
|
2442
|
+
max_literal_nodes: 512
|
|
2436
2443
|
});
|
|
2437
2444
|
|
|
2438
2445
|
// packages/ceal-client-protocol/src/operation-validation-primitives.ts
|
|
@@ -2452,6 +2459,9 @@ function requireIsoTimestamp(value, message) {
|
|
|
2452
2459
|
if (typeof value !== "string" || !ISO_TIMESTAMP.test(value) || !Number.isFinite(Date.parse(value))) throw new TypeError(message);
|
|
2453
2460
|
}
|
|
2454
2461
|
|
|
2462
|
+
// packages/ceal-client-protocol/src/operation-json-schema.ts
|
|
2463
|
+
var JSON_DESCRIPTION_CONTROL_CHARACTER = new RegExp("\\p{Cc}", "u");
|
|
2464
|
+
|
|
2455
2465
|
// packages/ceal-client-protocol/src/operation-contract-validation.ts
|
|
2456
2466
|
var CEAL_OPERATION_AUTHORITY_POLICY_KEYS = Object.freeze(["profile", "instance_binding", "target", "admission_recheck"]);
|
|
2457
2467
|
var MAX_OPERATION_INPUT_RESOLVER_BINDINGS = 96;
|
|
@@ -2552,7 +2562,6 @@ var CEAL_BOUNDED_SERIES_CATALOG = Object.freeze({
|
|
|
2552
2562
|
control_commit: (root) => join(root, "control-auto-commit.jsonl"),
|
|
2553
2563
|
engagement_signal: (root) => join(root, "runtime-state", "slack-feedback.jsonl"),
|
|
2554
2564
|
runtime_error: (root) => join(root, "runtime-state", "runtime-errors.jsonl"),
|
|
2555
|
-
provider_retry: (root) => join(root, "observability", "provider-retry-queue", "queue.jsonl"),
|
|
2556
2565
|
turn_bridge_request: (root) => join(root, ".ceal", "turn-bridge", "requests.jsonl"),
|
|
2557
2566
|
channel_log: (root) => join(root, "log.jsonl"),
|
|
2558
2567
|
thread_run_events: (root) => join(root, "run-events.jsonl"),
|
|
@@ -2561,8 +2570,6 @@ var CEAL_BOUNDED_SERIES_CATALOG = Object.freeze({
|
|
|
2561
2570
|
gateway_capability_audit: (root) => join(root, "capability-audit.jsonl"),
|
|
2562
2571
|
gateway_retrieval_waste_partition: (root) => `${root}.jsonl`,
|
|
2563
2572
|
gateway_access_policy_publication: (root) => join(root, "access-policy-publications.jsonl"),
|
|
2564
|
-
gateway_event_lease_journal: (root) => `${root}.journal.jsonl`,
|
|
2565
|
-
gateway_control_audit: (root) => `${root}.control-audits.jsonl`,
|
|
2566
2573
|
gateway_profile_connector_control_audit: (root) => `${root}.audit.jsonl`,
|
|
2567
2574
|
gateway_profile_connector_scope_audit: (root) => join(root, "profile-connector-scope-audit.jsonl"),
|
|
2568
2575
|
gateway_profile_connector_activity_scope_audit: (root) => join(root, "profile-connector-activity-scope-audit.jsonl"),
|
|
@@ -2577,6 +2584,11 @@ var CEAL_BOUNDED_SERIES_CATALOG = Object.freeze({
|
|
|
2577
2584
|
gateway_admin_access_token: (root) => join(root, "access-tokens.jsonl")
|
|
2578
2585
|
});
|
|
2579
2586
|
|
|
2587
|
+
// packages/ceal-client-protocol/src/gateway-installation-activation.ts
|
|
2588
|
+
var CEAL_GATEWAY_INSTALLATION_ACTIVATION_CODE_DATA_CHARACTERS = 32;
|
|
2589
|
+
var CEAL_GATEWAY_INSTALLATION_ACTIVATION_CODE_CHECK_CHARACTERS = 8;
|
|
2590
|
+
var CEAL_GATEWAY_INSTALLATION_ACTIVATION_CODE_COMPACT_CHARACTERS = CEAL_GATEWAY_INSTALLATION_ACTIVATION_CODE_DATA_CHARACTERS + CEAL_GATEWAY_INSTALLATION_ACTIVATION_CODE_CHECK_CHARACTERS;
|
|
2591
|
+
|
|
2580
2592
|
// packages/ceal-client-protocol/src/host-registration.ts
|
|
2581
2593
|
var CEAL_HOST_REGISTRATION_RESULT_KEYS = Object.freeze(["credential_generation", "host_access_token", "host_installation_ref", "host_source_ref", "ok", "registration_attempt_ref", "schema_version", "status"]);
|
|
2582
2594
|
|
|
@@ -2885,7 +2897,7 @@ var CEAL_REQUEST_RUN_BATCH_JSON_SCHEMA = {
|
|
|
2885
2897
|
};
|
|
2886
2898
|
|
|
2887
2899
|
// packages/ceal-client-protocol/src/host-observation.ts
|
|
2888
|
-
var CEAL_LOCAL_HOST_CAPABILITIES_SCHEMA_VERSION = "ceal.local_host_capabilities.
|
|
2900
|
+
var CEAL_LOCAL_HOST_CAPABILITIES_SCHEMA_VERSION = "ceal.local_host_capabilities.v7";
|
|
2889
2901
|
var CEAL_HOST_OBSERVATION_REF_PREFIX = "host-observation:";
|
|
2890
2902
|
var HOST_OBSERVATION_PRODUCER = /^[a-z][a-z0-9]{0,31}$/u;
|
|
2891
2903
|
var HOST_OBSERVATION_DIGEST = /^[a-f0-9]{8,64}$/u;
|
|
@@ -3152,7 +3164,7 @@ var CEAL_ACTOR_KINDS = vocabulary(["human", "bot", "app", "unknown"]);
|
|
|
3152
3164
|
// packages/ceal-client-protocol/src/leased-consumer-vocabulary.ts
|
|
3153
3165
|
var CEAL_TERMINAL_DISPOSITIONS = vocabulary(["completed", "failed", "cancelled"]);
|
|
3154
3166
|
var CEAL_LEASE_DISPOSITIONS = vocabulary([...CEAL_TERMINAL_DISPOSITIONS, "deferred"]);
|
|
3155
|
-
var CEAL_AUTOMATIC_FEEDBACK_INTENTS = vocabulary(["
|
|
3167
|
+
var CEAL_AUTOMATIC_FEEDBACK_INTENTS = vocabulary(["initial"]);
|
|
3156
3168
|
var CEAL_LEASED_MESSAGE_DELIVERY_CAPABILITY_IDS = vocabulary(["message.create", "message.update", "message.delete"]);
|
|
3157
3169
|
var CEAL_REPOSITORY_VISIBILITIES = vocabulary(["public", "private", "internal"]);
|
|
3158
3170
|
var CEAL_RESULT_DELIVERY_OFFERS = vocabulary(["pending", "offered", "transport_lost"]);
|
|
@@ -3429,6 +3441,7 @@ import { promisify as promisify2 } from "node:util";
|
|
|
3429
3441
|
// host/relay/src/producer-frame.ts
|
|
3430
3442
|
var HOST_PRODUCER_FRAME_SCHEMA = "ceal.host_producer_frame.v1";
|
|
3431
3443
|
var HOST_PRODUCER_MAX_JSON_BYTES = 262144;
|
|
3444
|
+
var HOST_PRODUCER_FRAME_LENGTH_BYTES = Uint32Array.BYTES_PER_ELEMENT;
|
|
3432
3445
|
var SAFE_REF3 = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u;
|
|
3433
3446
|
var DIGEST2 = /^[a-f0-9]{64}$/u;
|
|
3434
3447
|
var PRODUCERS = /* @__PURE__ */ new Set(["codex", "claude"]);
|
|
@@ -3448,18 +3461,18 @@ function encodeHostProducerFrame(frame) {
|
|
|
3448
3461
|
validateFrame(frame);
|
|
3449
3462
|
const json = Buffer.from(JSON.stringify(frame), "utf8");
|
|
3450
3463
|
if (json.byteLength > HOST_PRODUCER_MAX_JSON_BYTES) throw new HostProducerFrameError("frame_too_large", `frame_too_large: ${refusalFact("frame_bytes", json.byteLength, `at most ${HOST_PRODUCER_MAX_JSON_BYTES}`)}`);
|
|
3451
|
-
const result = Buffer.allocUnsafe(json.byteLength +
|
|
3464
|
+
const result = Buffer.allocUnsafe(json.byteLength + HOST_PRODUCER_FRAME_LENGTH_BYTES);
|
|
3452
3465
|
result.writeUInt32BE(json.byteLength, 0);
|
|
3453
|
-
json.copy(result,
|
|
3466
|
+
json.copy(result, HOST_PRODUCER_FRAME_LENGTH_BYTES);
|
|
3454
3467
|
return result;
|
|
3455
3468
|
}
|
|
3456
3469
|
function decodeHostProducerFrame(input) {
|
|
3457
|
-
if (input.byteLength <
|
|
3470
|
+
if (input.byteLength < HOST_PRODUCER_FRAME_LENGTH_BYTES) throw new HostProducerFrameError("frame_truncated", `frame_truncated: ${refusalFact("frame_bytes", input.byteLength, `at least ${HOST_PRODUCER_FRAME_LENGTH_BYTES}`)}`);
|
|
3458
3471
|
const length = input.readUInt32BE(0);
|
|
3459
3472
|
if (length > HOST_PRODUCER_MAX_JSON_BYTES) throw new HostProducerFrameError("frame_too_large", `frame_too_large: ${refusalFact("declared_bytes", length, `at most ${HOST_PRODUCER_MAX_JSON_BYTES}`)}`);
|
|
3460
3473
|
if (length === 0) throw new HostProducerFrameError("invalid_frame_length");
|
|
3461
|
-
if (input.byteLength !== length +
|
|
3462
|
-
const bytes = input.subarray(
|
|
3474
|
+
if (input.byteLength !== length + HOST_PRODUCER_FRAME_LENGTH_BYTES) throw new HostProducerFrameError(input.byteLength < length + HOST_PRODUCER_FRAME_LENGTH_BYTES ? "frame_truncated" : "invalid_frame_length");
|
|
3475
|
+
const bytes = input.subarray(HOST_PRODUCER_FRAME_LENGTH_BYTES);
|
|
3463
3476
|
const text = new TextDecoder("utf-8", { fatal: true });
|
|
3464
3477
|
let value;
|
|
3465
3478
|
try {
|
|
@@ -3680,6 +3693,8 @@ var HOST_RELAY_REQUEST_BINDING_KEYS = Object.freeze([
|
|
|
3680
3693
|
"host_input_ref"
|
|
3681
3694
|
]);
|
|
3682
3695
|
var HOST_RELAY_IPC_RESPONSE_SCHEMA = "ceal.host_relay_admission.v1";
|
|
3696
|
+
var HOST_RELAY_IPC_LENGTH_BYTES = Uint32Array.BYTES_PER_ELEMENT;
|
|
3697
|
+
var HOST_RELAY_ADMISSION_RESPONSE_MAX_BYTES = 4096;
|
|
3683
3698
|
var HostRelayIpcError = class extends Error {
|
|
3684
3699
|
code;
|
|
3685
3700
|
constructor(code3, message = code3) {
|
|
@@ -3733,12 +3748,12 @@ function exchange(endpoint, encoded, timeoutMs, decode) {
|
|
|
3733
3748
|
});
|
|
3734
3749
|
}
|
|
3735
3750
|
function decodeHostRelayIpcResponse(input) {
|
|
3736
|
-
if (input.length <
|
|
3751
|
+
if (input.length < HOST_RELAY_IPC_LENGTH_BYTES) throw new HostRelayIpcError("relay_unavailable", `Host Relay IPC response is truncated: ${refusalFact("response_bytes", input.byteLength, `at least ${HOST_RELAY_IPC_LENGTH_BYTES}`)}.`);
|
|
3737
3752
|
const length = input.readUInt32BE(0);
|
|
3738
|
-
if (length === 0 || length >
|
|
3753
|
+
if (length === 0 || length > HOST_RELAY_ADMISSION_RESPONSE_MAX_BYTES || input.length !== length + HOST_RELAY_IPC_LENGTH_BYTES) throw new HostRelayIpcError("relay_unavailable", `Host Relay IPC response length is invalid: ${refusalFacts([{ name: "declared_bytes", value: length, expected: `between 1 and ${HOST_RELAY_ADMISSION_RESPONSE_MAX_BYTES}` }, { name: "received_bytes", value: input.byteLength, expected: `exactly ${length + HOST_RELAY_IPC_LENGTH_BYTES}` }])}.`);
|
|
3739
3754
|
let value;
|
|
3740
3755
|
try {
|
|
3741
|
-
value = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(input.subarray(
|
|
3756
|
+
value = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(input.subarray(HOST_RELAY_IPC_LENGTH_BYTES)));
|
|
3742
3757
|
} catch {
|
|
3743
3758
|
throw new HostRelayIpcError("relay_unavailable", "Host Relay IPC response is invalid.");
|
|
3744
3759
|
}
|
|
@@ -3761,11 +3776,11 @@ function record2(value) {
|
|
|
3761
3776
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
3762
3777
|
}
|
|
3763
3778
|
function decodeResponseBuffer(buffer) {
|
|
3764
|
-
if (buffer.length <
|
|
3779
|
+
if (buffer.length < HOST_RELAY_IPC_LENGTH_BYTES) return null;
|
|
3765
3780
|
const length = buffer.readUInt32BE(0);
|
|
3766
|
-
if (length === 0 || length >
|
|
3767
|
-
if (buffer.length < length +
|
|
3768
|
-
if (buffer.length !== length +
|
|
3781
|
+
if (length === 0 || length > HOST_RELAY_ADMISSION_RESPONSE_MAX_BYTES) throw new HostRelayIpcError("relay_unavailable", `Host Relay IPC response length is invalid: ${refusalFact("declared_bytes", length, `between 1 and ${HOST_RELAY_ADMISSION_RESPONSE_MAX_BYTES}`)}.`);
|
|
3782
|
+
if (buffer.length < length + HOST_RELAY_IPC_LENGTH_BYTES) return null;
|
|
3783
|
+
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}` }])}.`);
|
|
3769
3784
|
return decodeHostRelayIpcResponse(buffer);
|
|
3770
3785
|
}
|
|
3771
3786
|
|
|
@@ -4166,7 +4181,8 @@ var CODEX_CLI_VERSION = "0.152.0";
|
|
|
4166
4181
|
var CODEX_HOOK_FEATURE = "hooks";
|
|
4167
4182
|
var CODEX_HOOKS_CONFIG_FILE = "hooks.json";
|
|
4168
4183
|
var CODEX_HOOK_OWNER = "ceal-codex-host-observation-v1";
|
|
4169
|
-
var
|
|
4184
|
+
var CODEX_THREAD_ID_ENVIRONMENT = "CODEX_THREAD_ID";
|
|
4185
|
+
var CODEX_SESSION_ID_ENVIRONMENT = "CODEX_SESSION_ID";
|
|
4170
4186
|
var CODEX_OUTBOX_SCHEMA_VERSION = "ceal.codex_observation_outbox.v1";
|
|
4171
4187
|
var CODEX_TURN_BINDING_SCHEMA_VERSION = "ceal.codex_turn_binding.v1";
|
|
4172
4188
|
var CODEX_SESSION_SCHEMA_VERSION = "ceal.codex_session.v1";
|
|
@@ -4251,6 +4267,7 @@ function isRecord2(value) {
|
|
|
4251
4267
|
|
|
4252
4268
|
// host/codex/src/codex-outbox.ts
|
|
4253
4269
|
var SAFE_REF6 = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u;
|
|
4270
|
+
var CODEX_TRANSCRIPT_PATH_MAX_CHARACTERS = 4096;
|
|
4254
4271
|
var CodexOutboxStore = class {
|
|
4255
4272
|
directory;
|
|
4256
4273
|
entriesDirectory;
|
|
@@ -4617,13 +4634,13 @@ function validateRegistration(value) {
|
|
|
4617
4634
|
}
|
|
4618
4635
|
function validateRegistrationFields(value) {
|
|
4619
4636
|
if (![value.host_source_ref, value.host_session_ref, value.codex_session_id].every((candidate) => typeof candidate === "string" && SAFE_REF6.test(candidate))) throw storageError(`Codex transcript registration references are malformed (${refusalFacts([{ name: "host_source_ref", value: value.host_source_ref }, { name: "host_session_ref", value: value.host_session_ref }, { name: "codex_session_id", value: value.codex_session_id }])}).`);
|
|
4620
|
-
if (!validRegistrationCwd(value.cwd)) throw storageError(`Codex transcript registration working directory is malformed (${refusalFact("cwd_characters", typeof value.cwd === "string" ? value.cwd.length : 0,
|
|
4637
|
+
if (!validRegistrationCwd(value.cwd)) throw storageError(`Codex transcript registration working directory is malformed (${refusalFact("cwd_characters", typeof value.cwd === "string" ? value.cwd.length : 0, `an absolute path of at most ${CODEX_TRANSCRIPT_PATH_MAX_CHARACTERS} characters`)}).`);
|
|
4621
4638
|
if (typeof value.transcript_path !== "string") throw storageError(`Codex transcript registration path is malformed (${refusalFact("kind", typeof value.transcript_path, "string")}).`);
|
|
4622
|
-
if (value.transcript_path.length === 0 || value.transcript_path.length >
|
|
4639
|
+
if (value.transcript_path.length === 0 || value.transcript_path.length > CODEX_TRANSCRIPT_PATH_MAX_CHARACTERS) throw storageError(`Codex transcript registration path is malformed (${refusalFact("characters", value.transcript_path.length, `from 1 through ${CODEX_TRANSCRIPT_PATH_MAX_CHARACTERS}`)}).`);
|
|
4623
4640
|
if (!isTimestamp(value.registered_at) || !isTimestamp(value.expires_at)) throw storageError(`Codex transcript registration timestamps are malformed (${refusalFacts([{ name: "registered_at", value: value.registered_at }, { name: "expires_at", value: value.expires_at }])}).`);
|
|
4624
4641
|
}
|
|
4625
4642
|
function validRegistrationCwd(value) {
|
|
4626
|
-
return value === void 0 || typeof value === "string" && isAbsolute(value) && value.length <=
|
|
4643
|
+
return value === void 0 || typeof value === "string" && isAbsolute(value) && value.length <= CODEX_TRANSCRIPT_PATH_MAX_CHARACTERS && !value.includes("\0");
|
|
4627
4644
|
}
|
|
4628
4645
|
function validateCursor(value) {
|
|
4629
4646
|
if (!isRecord3(value)) throw storageError("Codex transcript cursor is malformed.");
|
|
@@ -5978,6 +5995,8 @@ var HOST_REGISTRATION_STATE_KEYS = Object.freeze([
|
|
|
5978
5995
|
|
|
5979
5996
|
// host/relay/src/host-relay-runtime.ts
|
|
5980
5997
|
var HOST_RELAY_CONFIG_SCHEMA = "ceal.host_relay_config.v1";
|
|
5998
|
+
var HOST_RELAY_CONFIG_MIN_BYTES = Buffer.byteLength("{}", "utf8");
|
|
5999
|
+
var HOST_RELAY_CONFIG_MAX_BYTES = 65536;
|
|
5981
6000
|
var HostRelayConfigError = class extends Error {
|
|
5982
6001
|
name = "HostRelayConfigError";
|
|
5983
6002
|
code;
|
|
@@ -5994,7 +6013,7 @@ async function readHostRelayConfig(path) {
|
|
|
5994
6013
|
handle = await open6(path, O_RDONLY4 | O_NOFOLLOW3);
|
|
5995
6014
|
const stats = await handle.stat();
|
|
5996
6015
|
if (!stats.isFile() || !ownerPrivate2(stats)) throw new HostRelayConfigError("config_not_private", "Host Relay config file is not owner-private.");
|
|
5997
|
-
if (stats.size <
|
|
6016
|
+
if (stats.size < HOST_RELAY_CONFIG_MIN_BYTES || stats.size > HOST_RELAY_CONFIG_MAX_BYTES) throw new HostRelayConfigError("invalid_config", `invalid_config: Host Relay config size is invalid: ${refusalFact("config_bytes", stats.size, `between ${HOST_RELAY_CONFIG_MIN_BYTES} and ${HOST_RELAY_CONFIG_MAX_BYTES}`)}.`);
|
|
5998
6017
|
const text = await handle.readFile("utf8");
|
|
5999
6018
|
assertNoDuplicateJsonKeys(text);
|
|
6000
6019
|
let value;
|
|
@@ -6067,7 +6086,7 @@ function exactOptionalKeys(value, required, optional) {
|
|
|
6067
6086
|
// host/lifecycle/src/host-runtime-hooks.ts
|
|
6068
6087
|
import { lstat as lstat8 } from "node:fs/promises";
|
|
6069
6088
|
import { homedir as homedir4 } from "node:os";
|
|
6070
|
-
import { dirname as dirname7, join as join11 } from "node:path";
|
|
6089
|
+
import { basename as basename3, dirname as dirname7, join as join11 } from "node:path";
|
|
6071
6090
|
|
|
6072
6091
|
// host/hook-drift-policy.ts
|
|
6073
6092
|
var REINSTALL_REPAIRS_PREFIX = ["owned_hook_drifted:"];
|
|
@@ -6238,7 +6257,7 @@ function hostLocalCapabilityDescriptor(input) {
|
|
|
6238
6257
|
return {
|
|
6239
6258
|
schema_version: CEAL_LOCAL_HOST_CAPABILITIES_SCHEMA_VERSION,
|
|
6240
6259
|
owner: input.owner,
|
|
6241
|
-
...input.
|
|
6260
|
+
...input.activation === void 0 ? {} : { activation: input.activation },
|
|
6242
6261
|
authentication: { mode: "nonce", execution: { mode: "verbatim", argv: [...argv, "authenticate", "--client-nonce"] } },
|
|
6243
6262
|
capabilities: []
|
|
6244
6263
|
};
|
|
@@ -6246,7 +6265,7 @@ function hostLocalCapabilityDescriptor(input) {
|
|
|
6246
6265
|
|
|
6247
6266
|
// host/claude/src/claude-installer.ts
|
|
6248
6267
|
var OWNER = "ceal-claude-host-observation-v1";
|
|
6249
|
-
var
|
|
6268
|
+
var CLAUDE_LOCAL_CAPABILITY_ACTIVATION = Object.freeze({ environment: "CLAUDE_CODE_ENTRYPOINT", value: "cli" });
|
|
6250
6269
|
function resolveClaudeSettingsPath(claudeHome, environment = process.env) {
|
|
6251
6270
|
return join8(claudeHome ?? environment.CLAUDE_CONFIG_DIR ?? join8(homedir2(), ".claude"), "settings.json");
|
|
6252
6271
|
}
|
|
@@ -6303,7 +6322,7 @@ async function doctorClaudeHooks(options) {
|
|
|
6303
6322
|
return { status, settings_path: settingsPath, configured_events: configured, missing_events: missing, ...executableSha256 === void 0 ? {} : { executable_sha256: executableSha256 }, drift_reasons: reasons };
|
|
6304
6323
|
}
|
|
6305
6324
|
function claudeLocalCapabilityDescriptor(authenticationCommand) {
|
|
6306
|
-
return hostLocalCapabilityDescriptor({ owner: OWNER, authenticationCommand,
|
|
6325
|
+
return hostLocalCapabilityDescriptor({ owner: OWNER, authenticationCommand, activation: CLAUDE_LOCAL_CAPABILITY_ACTIVATION });
|
|
6307
6326
|
}
|
|
6308
6327
|
async function installClaudeLocalCapability(path, authenticationCommand) {
|
|
6309
6328
|
if (!isAbsolute3(path)) throw new ClaudeHostError("configuration", "Claude local capability path must be absolute.");
|
|
@@ -6452,6 +6471,7 @@ import { copyFile as copyFile2, lstat as lstat7, mkdir as mkdir8, open as open8,
|
|
|
6452
6471
|
import { homedir as homedir3 } from "node:os";
|
|
6453
6472
|
import { basename as basename2, dirname as dirname6, isAbsolute as isAbsolute4, join as join9 } from "node:path";
|
|
6454
6473
|
import { fileURLToPath } from "node:url";
|
|
6474
|
+
var CODEX_HOOK_COMMAND_MAX_CHARACTERS = 4096;
|
|
6455
6475
|
function codexHooksInstalled(doctor) {
|
|
6456
6476
|
return doctor.status === "ready" || doctor.status === "installed";
|
|
6457
6477
|
}
|
|
@@ -6588,7 +6608,7 @@ async function validateAuthenticationCommand(command) {
|
|
|
6588
6608
|
}
|
|
6589
6609
|
}
|
|
6590
6610
|
function codexLocalCapabilityDescriptor(authenticationCommand) {
|
|
6591
|
-
return hostLocalCapabilityDescriptor({ owner: CODEX_LOCAL_CAPABILITY_OWNER, authenticationCommand,
|
|
6611
|
+
return hostLocalCapabilityDescriptor({ owner: CODEX_LOCAL_CAPABILITY_OWNER, authenticationCommand, activation: { environment: CODEX_THREAD_ID_ENVIRONMENT, value: { environment: CODEX_SESSION_ID_ENVIRONMENT } } });
|
|
6592
6612
|
}
|
|
6593
6613
|
async function installCodexLocalCapability(path, authenticationCommand) {
|
|
6594
6614
|
const current = await readOptionalText(path);
|
|
@@ -6704,7 +6724,7 @@ function validateHookHandler(entry) {
|
|
|
6704
6724
|
}
|
|
6705
6725
|
function validateCommandHookHandler(entry) {
|
|
6706
6726
|
if (typeof entry.command !== "string") throw configurationError(`Codex hook command is malformed (${refusalFact("kind", typeof entry.command, "string")}).`);
|
|
6707
|
-
if (entry.command.length === 0 || entry.command.length >
|
|
6727
|
+
if (entry.command.length === 0 || entry.command.length > CODEX_HOOK_COMMAND_MAX_CHARACTERS) throw configurationError(`Codex hook command is malformed (${refusalFact("characters", entry.command.length, `from 1 through ${CODEX_HOOK_COMMAND_MAX_CHARACTERS}`)}).`);
|
|
6708
6728
|
validateOptionalString(entry.commandWindows, "Codex hook commandWindows is malformed.");
|
|
6709
6729
|
validateOptionalInteger(entry.timeout, 1, "Codex hook timeout is malformed.");
|
|
6710
6730
|
validateOptionalBoolean(entry.async, "Codex hook async flag is malformed.");
|
|
@@ -6942,6 +6962,9 @@ function isHostBundleComponent(value) {
|
|
|
6942
6962
|
function isHostBundleProducer(value) {
|
|
6943
6963
|
return HOST_BUNDLE_PRODUCERS.some((producer) => producer === value);
|
|
6944
6964
|
}
|
|
6965
|
+
function hostPrivateRuntimeModule(entry) {
|
|
6966
|
+
return `${entry}.mjs`;
|
|
6967
|
+
}
|
|
6945
6968
|
function hostBundleComponentsForProducers(producers) {
|
|
6946
6969
|
const selected = /* @__PURE__ */ new Set(["lifecycle", "relay", ...producers]);
|
|
6947
6970
|
return HOST_BUNDLE_COMPONENTS.filter((component) => selected.has(component));
|
|
@@ -6981,14 +7004,14 @@ function resolveInstalledHostRuntimePaths(prefix, platform = process.platform) {
|
|
|
6981
7004
|
return {
|
|
6982
7005
|
private_root: privateRoot,
|
|
6983
7006
|
node_executable: join10(privateRoot, "node", "bin", platform === "win32" ? "node.exe" : "node"),
|
|
6984
|
-
control_module: join10(privateRoot, "control
|
|
6985
|
-
codex_hook_module: join10(privateRoot, "codex-hook
|
|
6986
|
-
codex_invocation_authentication_module: join10(privateRoot, "codex-invocation-authentication
|
|
6987
|
-
claude_hook_module: join10(privateRoot, "claude-hook
|
|
6988
|
-
claude_invocation_authentication_module: join10(privateRoot, "claude-invocation-authentication
|
|
6989
|
-
relay_module: join10(privateRoot, "relay
|
|
6990
|
-
codex_producer_module: join10(privateRoot, "codex-producer
|
|
6991
|
-
claude_producer_module: join10(privateRoot, "claude-producer
|
|
7007
|
+
control_module: join10(privateRoot, hostPrivateRuntimeModule("control")),
|
|
7008
|
+
codex_hook_module: join10(privateRoot, hostPrivateRuntimeModule("codex-hook")),
|
|
7009
|
+
codex_invocation_authentication_module: join10(privateRoot, hostPrivateRuntimeModule("codex-invocation-authentication")),
|
|
7010
|
+
claude_hook_module: join10(privateRoot, hostPrivateRuntimeModule("claude-hook")),
|
|
7011
|
+
claude_invocation_authentication_module: join10(privateRoot, hostPrivateRuntimeModule("claude-invocation-authentication")),
|
|
7012
|
+
relay_module: join10(privateRoot, hostPrivateRuntimeModule("relay")),
|
|
7013
|
+
codex_producer_module: join10(privateRoot, hostPrivateRuntimeModule("codex-producer")),
|
|
7014
|
+
claude_producer_module: join10(privateRoot, hostPrivateRuntimeModule("claude-producer"))
|
|
6992
7015
|
};
|
|
6993
7016
|
}
|
|
6994
7017
|
function parseHostRuntimeControlRequest(value) {
|
|
@@ -7229,13 +7252,13 @@ var InstalledHostRuntimeHookAdapter = class {
|
|
|
7229
7252
|
const targets = { runtime: paths.private_root, services: servicesRoot };
|
|
7230
7253
|
if (producer === "codex") {
|
|
7231
7254
|
const entryRoot2 = resolveHostEntryRoot(this.homes.codex_home, ".codex");
|
|
7232
|
-
const hook2 = hostEntryCommand({ entryRoot: entryRoot2, module: "codex-hook
|
|
7233
|
-
const authentication2 = hostEntryCommand({ entryRoot: entryRoot2, module: "codex-invocation-authentication
|
|
7255
|
+
const hook2 = hostEntryCommand({ entryRoot: entryRoot2, module: hostPrivateRuntimeModule("codex-hook"), configFlag: HOST_PRODUCER_CONFIG_FLAG, configFile: "codex.json" });
|
|
7256
|
+
const authentication2 = hostEntryCommand({ entryRoot: entryRoot2, module: hostPrivateRuntimeModule("codex-invocation-authentication"), configFlag: HOST_PRODUCER_CONFIG_FLAG, configFile: "codex.json" });
|
|
7234
7257
|
return { entryRoot: entryRoot2, targets, hook: hook2, authentication: authentication2, configPath: this.configPaths.codex };
|
|
7235
7258
|
}
|
|
7236
7259
|
const entryRoot = resolveHostEntryRoot(this.homes.claude_home, ".claude");
|
|
7237
|
-
const hook = hostEntryCommand({ entryRoot, module: "claude-hook
|
|
7238
|
-
const authentication = hostEntryCommand({ entryRoot, module: "claude-invocation-authentication
|
|
7260
|
+
const hook = hostEntryCommand({ entryRoot, module: hostPrivateRuntimeModule("claude-hook"), configFlag: HOST_PRODUCER_CONFIG_FLAG, configFile: "claude.json" });
|
|
7261
|
+
const authentication = hostEntryCommand({ entryRoot, module: hostPrivateRuntimeModule("claude-invocation-authentication"), configFlag: HOST_PRODUCER_CONFIG_FLAG, configFile: "claude.json" });
|
|
7239
7262
|
return { entryRoot, targets, hook, authentication, configPath: this.configPaths.claude };
|
|
7240
7263
|
}
|
|
7241
7264
|
};
|
|
@@ -7306,13 +7329,17 @@ function claudeLocalCapabilityPath(claudeHome) {
|
|
|
7306
7329
|
async function assertRegularRuntimeFile(path, executable) {
|
|
7307
7330
|
let info;
|
|
7308
7331
|
const platform = process.platform;
|
|
7332
|
+
const module2 = basename3(path);
|
|
7309
7333
|
try {
|
|
7310
7334
|
info = await lstat8(path);
|
|
7311
|
-
} catch
|
|
7312
|
-
throw
|
|
7335
|
+
} catch {
|
|
7336
|
+
throw runtimeUnavailable(`missing_module:${module2}`);
|
|
7313
7337
|
}
|
|
7314
|
-
if (!info.isFile() || info.isSymbolicLink()) throw
|
|
7315
|
-
if (executable && platform !== "win32" && (info.mode & 73) === 0) throw
|
|
7338
|
+
if (!info.isFile() || info.isSymbolicLink()) throw runtimeUnavailable(`irregular_module:${module2}`);
|
|
7339
|
+
if (executable && platform !== "win32" && (info.mode & 73) === 0) throw runtimeUnavailable(`non_executable_module:${module2}`);
|
|
7340
|
+
}
|
|
7341
|
+
function runtimeUnavailable(reason) {
|
|
7342
|
+
return new HostRuntimeReasonedError("private_runtime_unavailable", [reason]);
|
|
7316
7343
|
}
|
|
7317
7344
|
function selectedProducers(selection) {
|
|
7318
7345
|
return selection.components.filter(isHostBundleProducer);
|
|
@@ -7323,7 +7350,7 @@ import { execFile } from "node:child_process";
|
|
|
7323
7350
|
import { constants as constants3 } from "node:fs";
|
|
7324
7351
|
import { chmod as chmod2, lstat as lstat9, mkdir as mkdir9, open as open9, rename as rename8, unlink as unlink5 } from "node:fs/promises";
|
|
7325
7352
|
import { homedir as homedir5 } from "node:os";
|
|
7326
|
-
import { basename as
|
|
7353
|
+
import { basename as basename4, dirname as dirname8, join as join12 } from "node:path";
|
|
7327
7354
|
import { promisify } from "node:util";
|
|
7328
7355
|
import { createHash as createHash7 } from "node:crypto";
|
|
7329
7356
|
|
|
@@ -7338,11 +7365,6 @@ function equalStringLists(left, right) {
|
|
|
7338
7365
|
// host/lifecycle/src/host-runtime-services.ts
|
|
7339
7366
|
var HOST_RUNTIME_SERVICE_COMPONENTS = Object.freeze(hostBundleComponentsForProducers(HOST_BUNDLE_PRODUCERS).filter((component) => component !== "lifecycle"));
|
|
7340
7367
|
var HOST_RUNTIME_SERVICE_COMMAND_TIMEOUT_MS = 2e4;
|
|
7341
|
-
var ENTRYPOINTS = Object.freeze({
|
|
7342
|
-
relay: "relay.mjs",
|
|
7343
|
-
codex: "codex-producer.mjs",
|
|
7344
|
-
claude: "claude-producer.mjs"
|
|
7345
|
-
});
|
|
7346
7368
|
var HOST_RUNTIME_SERVICE_STATES = ["absent", "stopped", "running", "unknown"];
|
|
7347
7369
|
var HostRuntimeServiceContractError = class extends Error {
|
|
7348
7370
|
code;
|
|
@@ -7361,7 +7383,7 @@ function createHostRuntimeServiceSet(input) {
|
|
|
7361
7383
|
const node = path.join(prefix, HOST_BUNDLE_PRIVATE_RUNTIME_ROOT, "node", "bin", flavor === "windows" ? "node.exe" : "node");
|
|
7362
7384
|
const services = selected.map((component) => {
|
|
7363
7385
|
const config = absoluteNormalizedPath(input.config_paths[component], `${component} service config`, path);
|
|
7364
|
-
const entrypoint = path.join(prefix, HOST_BUNDLE_PRIVATE_RUNTIME_ROOT,
|
|
7386
|
+
const entrypoint = path.join(prefix, HOST_BUNDLE_PRIVATE_RUNTIME_ROOT, hostPrivateRuntimeModule(component === "relay" ? component : `${component}-producer`));
|
|
7365
7387
|
const command = { executable: node, args: [entrypoint, "serve", "--config", config] };
|
|
7366
7388
|
validateHostCommandVector(command);
|
|
7367
7389
|
return { component, command };
|
|
@@ -7601,7 +7623,7 @@ async function readManagedPlist(path, marker, uid) {
|
|
|
7601
7623
|
async function writeManagedPlist(path, marker, text, uid) {
|
|
7602
7624
|
const current = await readManagedPlist(path, marker, uid);
|
|
7603
7625
|
if (current === text) return;
|
|
7604
|
-
const temporary = join12(dirname8(path), `.${
|
|
7626
|
+
const temporary = join12(dirname8(path), `.${basename4(path)}.${process.pid}.${createHash7("sha256").update(`${Date.now()}:${Math.random()}`).digest("hex").slice(0, 12)}.tmp`);
|
|
7605
7627
|
try {
|
|
7606
7628
|
const handle = await open9(temporary, "wx", 384);
|
|
7607
7629
|
try {
|
|
@@ -7920,7 +7942,7 @@ var WINDOWS_TASK_SCHEDULER_PROGRAM = Buffer.from(TASK_SCHEDULER_SOURCE, "utf16le
|
|
|
7920
7942
|
|
|
7921
7943
|
// host/lifecycle/src/host-runtime-systemd.ts
|
|
7922
7944
|
import { createHash as createHash8, randomUUID } from "node:crypto";
|
|
7923
|
-
import { chmod as chmod3, lstat as lstat10, mkdir as mkdir10, open as open10, readFile as readFile6, rename as rename9, unlink as unlink6 } from "node:fs/promises";
|
|
7945
|
+
import { chmod as chmod3, lstat as lstat10, mkdir as mkdir10, open as open10, readFile as readFile6, readdir as readdir3, rename as rename9, unlink as unlink6 } from "node:fs/promises";
|
|
7924
7946
|
import { join as join13 } from "node:path";
|
|
7925
7947
|
|
|
7926
7948
|
// host/lifecycle/src/systemd-unit-show.ts
|
|
@@ -8000,12 +8022,12 @@ function createLinuxUserSystemdAdapter(options) {
|
|
|
8000
8022
|
const previousByComponent = serviceMap(previous);
|
|
8001
8023
|
const targetByComponent = serviceMap(target);
|
|
8002
8024
|
await ensurePrivateUnitDirectory(unitDirectory);
|
|
8003
|
-
const ownedUnits = await
|
|
8025
|
+
const ownedUnits = await ownedHostUnits(unitDirectory);
|
|
8004
8026
|
for (const service of target.services) await replaceOwnedUnit(unitDirectory, identity, service);
|
|
8005
|
-
for (const
|
|
8006
|
-
if (targetByComponent.has(
|
|
8007
|
-
|
|
8008
|
-
await removeOwnedUnit(unitDirectory, identity,
|
|
8027
|
+
for (const unit of ownedUnits) {
|
|
8028
|
+
if (unit.identity === identity && targetByComponent.has(unit.component)) continue;
|
|
8029
|
+
await invokeSystemctl(run, systemctl, ["--user", "disable", "--now", unitName(unit.identity, unit.component)]);
|
|
8030
|
+
await removeOwnedUnit(unitDirectory, unit.identity, unit.component);
|
|
8009
8031
|
}
|
|
8010
8032
|
await invokeSystemctl(run, systemctl, ["--user", "daemon-reload"]);
|
|
8011
8033
|
for (const service of target.services) {
|
|
@@ -8014,9 +8036,7 @@ function createLinuxUserSystemdAdapter(options) {
|
|
|
8014
8036
|
if (previousByComponent.has(service.component)) await invokeSystemctl(run, systemctl, ["--user", "restart", name]);
|
|
8015
8037
|
await requireExpectedReadback(run, systemctl, unitDirectory, identity, service, "running");
|
|
8016
8038
|
}
|
|
8017
|
-
for (const
|
|
8018
|
-
if (!targetByComponent.has(service.component)) await requireAbsentReadback(run, systemctl, unitDirectory, identity, service.component);
|
|
8019
|
-
}
|
|
8039
|
+
for (const unit of ownedUnits) if (unit.identity !== identity || !targetByComponent.has(unit.component)) await requireAbsentReadback(run, systemctl, unitDirectory, unit.identity, unit.component);
|
|
8020
8040
|
},
|
|
8021
8041
|
async restart({ target, service }) {
|
|
8022
8042
|
const identity = prefixIdentity(target.prefix);
|
|
@@ -8054,12 +8074,20 @@ function unitPath(directory, identity, component) {
|
|
|
8054
8074
|
function serviceMap(set) {
|
|
8055
8075
|
return new Map(set.services.map((service) => [service.component, service]));
|
|
8056
8076
|
}
|
|
8057
|
-
async function
|
|
8058
|
-
const owned =
|
|
8059
|
-
for (const
|
|
8060
|
-
|
|
8077
|
+
async function ownedHostUnits(directory) {
|
|
8078
|
+
const owned = [];
|
|
8079
|
+
for (const name of await readdir3(directory)) {
|
|
8080
|
+
const match = /^ceal-host-([a-f0-9]{64})-(lifecycle|relay|codex|claude)\.service$/u.exec(name);
|
|
8081
|
+
if (match === null) continue;
|
|
8082
|
+
const identity = match[1];
|
|
8083
|
+
const component = match[2];
|
|
8084
|
+
if (identity === void 0 || !UNIT_ID_PATTERN.test(identity) || !isHostRuntimeServiceComponent(component)) continue;
|
|
8085
|
+
if (await ownedUnitPresent(unitPath(directory, identity, component), identity, component)) owned.push({ identity, component });
|
|
8061
8086
|
}
|
|
8062
|
-
return owned;
|
|
8087
|
+
return owned.sort((left, right) => unitName(left.identity, left.component).localeCompare(unitName(right.identity, right.component)));
|
|
8088
|
+
}
|
|
8089
|
+
function isHostRuntimeServiceComponent(value) {
|
|
8090
|
+
return value !== void 0 && HOST_RUNTIME_SERVICE_COMPONENTS.some((component) => component === value);
|
|
8063
8091
|
}
|
|
8064
8092
|
async function ensurePrivateUnitDirectory(directory) {
|
|
8065
8093
|
try {
|
|
@@ -8227,6 +8255,7 @@ function projectionError(detail) {
|
|
|
8227
8255
|
// host/lifecycle/src/host-runtime-composition.ts
|
|
8228
8256
|
var execFileAsync2 = promisify2(execFile2);
|
|
8229
8257
|
var STATE_ROOT_ENVIRONMENT = "CEAL_HOST_STATE_ROOT";
|
|
8258
|
+
var HOST_STATE_ROOT_MAX_CHARACTERS = 4096;
|
|
8230
8259
|
var InstalledHostRuntimeCompositionError = class extends Error {
|
|
8231
8260
|
code;
|
|
8232
8261
|
constructor(code3, message) {
|
|
@@ -8407,7 +8436,7 @@ function processFailure(error) {
|
|
|
8407
8436
|
function resolveStateRoot(environment, platform) {
|
|
8408
8437
|
const value = environment[STATE_ROOT_ENVIRONMENT];
|
|
8409
8438
|
const path = platform === "win32" ? win324 : posix3;
|
|
8410
|
-
if (value === void 0 || value.length === 0 || value.length >
|
|
8439
|
+
if (value === void 0 || value.length === 0 || value.length > HOST_STATE_ROOT_MAX_CHARACTERS || value.includes("\0") || !path.isAbsolute(value) || path.normalize(value) !== value || path.parse(value).root === value) throw new InstalledHostRuntimeCompositionError("state_root_unavailable", `The Go-owned Host state root is unavailable (${refusalFact("state_root", value, `a normalized absolute non-root path of at most ${HOST_STATE_ROOT_MAX_CHARACTERS} characters`)}).`);
|
|
8411
8440
|
return value;
|
|
8412
8441
|
}
|
|
8413
8442
|
function prefixFromPaths(paths, platform) {
|