@corca-org/ceal-host-win32-x64 1.0.24 → 1.0.25
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/README.md +2 -2
- package/bin/ceal-host.exe +0 -0
- package/libexec/ceal-host/ceal-host-background.exe +0 -0
- package/libexec/ceal-host/claude-hook.mjs +183 -77
- package/libexec/ceal-host/claude-invocation-authentication.mjs +322 -100
- package/libexec/ceal-host/claude-producer.mjs +175 -69
- package/libexec/ceal-host/codex-hook.mjs +170 -64
- package/libexec/ceal-host/codex-invocation-authentication.mjs +307 -85
- package/libexec/ceal-host/codex-producer.mjs +164 -58
- package/libexec/ceal-host/control.mjs +563 -210
- package/libexec/ceal-host/relay.mjs +115 -29
- package/package.json +1 -1
- package/share/ceal-host/bundle-manifest.json +13 -13
- package/share/ceal-host/bundle-manifest.sigstore.json +1 -1
|
@@ -328,6 +328,12 @@ var CALLER_RECOVERABLE_NEXT_ACTION_VALUES = [
|
|
|
328
328
|
// (never connected, revoked, or expired). The caller runs that exact
|
|
329
329
|
// Operation, completes the consent it hands back, and retries the same call.
|
|
330
330
|
"connect_personal_account",
|
|
331
|
+
// The refusal names the caller's own preferences update step: the read
|
|
332
|
+
// needs a personal connection the caller holds but has not selected in
|
|
333
|
+
// Ceal preferences, or has not confirmed through the initial review. The
|
|
334
|
+
// caller reads personal.preferences.get, runs personal.preferences.update
|
|
335
|
+
// at the current revision to select it, and retries the same call.
|
|
336
|
+
"update_personal_preferences",
|
|
331
337
|
// The provider or Gateway named a bounded wait; the caller waits that long
|
|
332
338
|
// and submits the same read again.
|
|
333
339
|
"retry_after",
|
|
@@ -877,9 +883,11 @@ var LOCAL_COMMAND_INVALID = "The local command or argument is invalid.";
|
|
|
877
883
|
var LOCAL_TRANSPORT_INCOMPLETE = "The local Ceal transport could not complete; report this as a gap.";
|
|
878
884
|
var GATEWAY_TRANSPORT_UNAVAILABLE = "The Gateway transport is unavailable; ask an administrator to restore Gateway availability.";
|
|
879
885
|
var HOST_AUTHENTICATION_UNAVAILABLE = "The Host could not authenticate this invocation; report this as a gap.";
|
|
880
|
-
var
|
|
886
|
+
var CEAL_CLIENT_UPGRADE_COMMAND = "npm install -g @corca-org/ceal";
|
|
887
|
+
var CLIENT_HOST_RELEASE_MISMATCH = `Install or upgrade the Ceal CLI and Host Relay to the same release as the Gateway, then retry. Update with \`${CEAL_CLIENT_UPGRADE_COMMAND}\`.`;
|
|
881
888
|
var HOST_INSTALL_REPAIR = "The local Host or Relay is missing, stale, or unavailable. Run `ceal-host install`, then `ceal-host discovery sync`, and retry from a new producer conversation.";
|
|
882
|
-
var HOST_CONTEXT_UNAVAILABLE = "The Host could not select this turn;
|
|
889
|
+
var HOST_CONTEXT_UNAVAILABLE = "The Host could not select this turn right now; the Host may be restarting. Wait briefly and retry the same command. If you know you are in an ephemeral side conversation, `ceal --standalone ...` uses your configured Ceal session/Gateway permissions without Host session/turn correlation. Otherwise return to the original regular conversation. Host refusal never switches modes. If the retry still fails, report intended Host calls as a gap.";
|
|
890
|
+
var HOST_RELAY_RESTARTING = "The Host Relay is temporarily unavailable while the Host restarts; wait briefly and retry the same command. If the retry still fails, report this as a gap.";
|
|
883
891
|
var SESSION_CONTEXT_UNAVAILABLE = "The local Gateway session context is unavailable.";
|
|
884
892
|
var SESSION_ADOPT_RECOVERY = "The refresh Session is no longer usable. Run `ceal session adopt --gateway <origin> --email <email>` to complete mailbox-confirmed recovery.";
|
|
885
893
|
function guidance(message, next_action, http_status, retryable = false, redaction_class = "model_safe") {
|
|
@@ -909,6 +917,9 @@ var CEAL_FAILURE_GUIDANCE_TABLE = Object.freeze({
|
|
|
909
917
|
person_inactive: guidance("The Person is inactive, so the Gateway refused this refresh without revoking the Session family. Ask an Admin to reactivate the Person, then retry this same session refresh.", "ask_admin", 403),
|
|
910
918
|
principal_inactive: guidance("The Principal is inactive, so the Gateway refused this refresh without revoking the Session family. Ask an Admin to reactivate the Principal, then retry this same session refresh.", "ask_admin", 403),
|
|
911
919
|
authority_replaced: guidance("The Gateway authority has been replaced; this session is no longer valid here. Run `ceal session adopt --gateway <origin> --email <email>` against the current Gateway to complete mailbox-confirmed recovery.", "repair_or_adopt_session", 409),
|
|
920
|
+
// A stored session that predates the authority-epoch commitment carries no
|
|
921
|
+
// epoch to compare, so it can never refresh: adopt a fresh session instead.
|
|
922
|
+
authority_epoch_unknown: guidance(SESSION_ADOPT_RECOVERY, "repair_or_adopt_session", 401),
|
|
912
923
|
refresh_inactive: guidance(SESSION_ADOPT_RECOVERY, "repair_or_adopt_session", 410),
|
|
913
924
|
refresh_recovery_unavailable: guidance("The Gateway's durable refresh-recovery key is unavailable. Retry the same refresh attempt after the key is available.", "retry", 503, true),
|
|
914
925
|
refresh_recovery_outcome_unavailable: guidance("The Gateway could not safely recover the outcome of a prior refresh. Ask an administrator to inspect the Gateway session state before retrying or adopting this session.", "ask_admin", 503),
|
|
@@ -1033,7 +1044,7 @@ var CEAL_FAILURE_GUIDANCE_TABLE = Object.freeze({
|
|
|
1033
1044
|
host_session_unavailable: guidance(HOST_AUTHENTICATION_UNAVAILABLE, "answer_with_gap", 401),
|
|
1034
1045
|
// The bounded Host reason does not prove ephemerality. A Host refusal never
|
|
1035
1046
|
// changes mode; standalone remains the separate Client authority path.
|
|
1036
|
-
host_context_unavailable: guidance(HOST_CONTEXT_UNAVAILABLE, "
|
|
1047
|
+
host_context_unavailable: guidance(HOST_CONTEXT_UNAVAILABLE, "retry", 401, true),
|
|
1037
1048
|
host_context_activation_wait_exhausted: guidance("The Host selected this turn, but its invocation context did not activate before the bounded wait ended. Wait for the supplied retry_after_ms value, then retry the same command.", "retry_after", 401, true),
|
|
1038
1049
|
host_invocation_context_stale: guidance("The Host turn changed while this invocation was authenticating. Its command cannot be rebound safely; report this invocation as a gap.", "answer_with_gap", 401),
|
|
1039
1050
|
host_invocation_context_expired: guidance("The Host invocation context expired before authentication completed. This invocation cannot be retried in the expired turn; report it as a gap.", "answer_with_gap", 401),
|
|
@@ -1050,7 +1061,7 @@ var CEAL_FAILURE_GUIDANCE_TABLE = Object.freeze({
|
|
|
1050
1061
|
// Moved from the retired `CEAL_HOST_AUTHENTICATION_POLICY` remedy: the
|
|
1051
1062
|
// sandboxed Relay socket names the run-alone retry.
|
|
1052
1063
|
host_relay_permission_denied: guidance("An agent sandbox denied the Host Relay socket; run `ceal` as the only command, with no pipe, redirect, or `&&`, so the Host allow rule runs it outside the sandbox.", "rerun_outside_agent_sandbox", 403),
|
|
1053
|
-
host_relay_unavailable: guidance(
|
|
1064
|
+
host_relay_unavailable: guidance(HOST_RELAY_RESTARTING, "retry", 503, true),
|
|
1054
1065
|
host_mint_transient_retryable: guidance(HOST_AUTHENTICATION_UNAVAILABLE, "retry", 503, true),
|
|
1055
1066
|
host_mint_failed: guidance(HOST_AUTHENTICATION_UNAVAILABLE, "answer_with_gap", 500),
|
|
1056
1067
|
host_relay_failed: guidance(HOST_INSTALL_REPAIR, "install_ceal_host", 502),
|
|
@@ -1298,7 +1309,7 @@ var CEAL_OPERATION_JSON_SCHEMA_BUDGET = Object.freeze({
|
|
|
1298
1309
|
max_literal_nodes: 512
|
|
1299
1310
|
});
|
|
1300
1311
|
|
|
1301
|
-
// packages/ceal-client-protocol/src/operation-json-schema.ts
|
|
1312
|
+
// packages/ceal-client-protocol/src/operation-json-schema-leaf-validators.ts
|
|
1302
1313
|
var JSON_DESCRIPTION_CONTROL_CHARACTER = new RegExp("\\p{Cc}", "u");
|
|
1303
1314
|
|
|
1304
1315
|
// packages/ceal-client-protocol/src/operation-contract-validation.ts
|
|
@@ -1445,7 +1456,8 @@ var CEAL_OPERATION_ID_PLACEHOLDER = "<operation-id>";
|
|
|
1445
1456
|
var CEAL_OPERATION_INPUT_PLACEHOLDER = "<json-object>";
|
|
1446
1457
|
var MODEL_INVOCATION_BASE_ARGUMENTS = [CEAL_OPERATION_INVOKE_COMMAND, CEAL_OPERATION_ID_PLACEHOLDER].join(" ");
|
|
1447
1458
|
var CEAL_MODEL_INVOCATION_ARGUMENTS = [MODEL_INVOCATION_BASE_ARGUMENTS, CEAL_OPERATION_INPUT_FLAG, shellSingleQuoted(CEAL_OPERATION_INPUT_PLACEHOLDER)].join(" ");
|
|
1448
|
-
var
|
|
1459
|
+
var CEAL_MODEL_INPUT_SOURCE_BASE_GUIDANCE = `For caller-owned fields, add ${CEAL_OPERATION_INPUT_FLAG} ${shellSingleQuoted(CEAL_OPERATION_INPUT_PLACEHOLDER)}. Use inline JSON for short input; for longer or generated input, put exactly one JSON object in a caller-owned regular non-symlink UTF-8 JSON file and pass --input @path; relative paths resolve from the command working directory.`;
|
|
1460
|
+
var CEAL_MODEL_INPUT_SOURCE_GUIDANCE = `${CEAL_MODEL_INPUT_SOURCE_BASE_GUIDANCE} On Windows, write the JSON file first; use the program's .cmd launcher with --input and only one quoted @path argument.`;
|
|
1449
1461
|
function shellSingleQuoted(value) {
|
|
1450
1462
|
return `'${value.replaceAll("'", "'\\''")}'`;
|
|
1451
1463
|
}
|
|
@@ -2429,9 +2441,11 @@ var CEAL_HOST_AUTHENTICATION_POLICY = Object.freeze({
|
|
|
2429
2441
|
invalid_arguments: Object.freeze({ classification: "host_arguments_invalid", next_action: "answer_with_gap" }),
|
|
2430
2442
|
options_invalid: Object.freeze({ classification: "host_configuration_invalid", next_action: "answer_with_gap" }),
|
|
2431
2443
|
session_unavailable: Object.freeze({ classification: "host_session_unavailable", next_action: "answer_with_gap" }),
|
|
2432
|
-
//
|
|
2433
|
-
//
|
|
2434
|
-
|
|
2444
|
+
// A missing turn right after a Host restart clears by itself once the
|
|
2445
|
+
// watcher reactivates the turn, so the caller waits briefly and retries;
|
|
2446
|
+
// a caller that knows it is in an ephemeral side conversation keeps the
|
|
2447
|
+
// standalone fallback the guidance names second.
|
|
2448
|
+
context_unavailable: Object.freeze({ classification: "host_context_unavailable", next_action: "retry" }),
|
|
2435
2449
|
activation_wait_exhausted: Object.freeze({ classification: "host_context_activation_wait_exhausted", next_action: "retry_after" }),
|
|
2436
2450
|
context_replaced: Object.freeze({ classification: "host_invocation_context_stale", next_action: "answer_with_gap" }),
|
|
2437
2451
|
// `no_binding` now means the producer has no real current Host session. The
|
|
@@ -2448,7 +2462,7 @@ var CEAL_HOST_AUTHENTICATION_POLICY = Object.freeze({
|
|
|
2448
2462
|
gateway_response_invalid: Object.freeze({ classification: "host_mint_gateway_response_invalid", next_action: "answer_with_gap" }),
|
|
2449
2463
|
producer_frame_invalid: Object.freeze({ classification: "host_producer_frame_invalid", next_action: "ask_admin" }),
|
|
2450
2464
|
relay_permission_denied: Object.freeze({ classification: "host_relay_permission_denied", next_action: "rerun_outside_agent_sandbox" }),
|
|
2451
|
-
relay_unavailable: Object.freeze({ classification: "host_relay_unavailable", next_action: "
|
|
2465
|
+
relay_unavailable: Object.freeze({ classification: "host_relay_unavailable", next_action: "retry" }),
|
|
2452
2466
|
transient_retryable: Object.freeze({ classification: "host_mint_transient_retryable", next_action: "retry" }),
|
|
2453
2467
|
mint_failed: Object.freeze({ classification: "host_mint_failed", next_action: "answer_with_gap" }),
|
|
2454
2468
|
relay_failed: Object.freeze({ classification: "host_relay_failed", next_action: "install_ceal_host" }),
|
|
@@ -2829,8 +2843,80 @@ function waitForAbort(signal, milliseconds) {
|
|
|
2829
2843
|
import { execFile } from "node:child_process";
|
|
2830
2844
|
import { constants } from "node:fs";
|
|
2831
2845
|
import { lstat, open } from "node:fs/promises";
|
|
2832
|
-
import { dirname, join as
|
|
2846
|
+
import { dirname, join as join3, win32 as win323 } from "node:path";
|
|
2833
2847
|
import { fileURLToPath } from "node:url";
|
|
2848
|
+
|
|
2849
|
+
// host/spawn-working-directory.ts
|
|
2850
|
+
import { mkdirSync } from "node:fs";
|
|
2851
|
+
import { tmpdir } from "node:os";
|
|
2852
|
+
import { isAbsolute, join as join2, normalize, parse, sep } from "node:path";
|
|
2853
|
+
function resolveCealSpawnWorkingDirectory(stateRoot, keepOutside = []) {
|
|
2854
|
+
const candidates = [];
|
|
2855
|
+
const explicit = candidateDir(stateRoot);
|
|
2856
|
+
if (explicit !== void 0) candidates.push(explicit);
|
|
2857
|
+
const fallback = defaultHostStateRoot();
|
|
2858
|
+
if (fallback !== void 0 && !candidates.some((candidate) => sameDir(candidate, fallback))) candidates.push(fallback);
|
|
2859
|
+
const temporary = candidateDir(join2(tmpdir(), "ceal-spawn-cwd"));
|
|
2860
|
+
if (temporary !== void 0 && !candidates.some((candidate) => sameDir(candidate, temporary))) candidates.push(temporary);
|
|
2861
|
+
for (const dir of candidates) {
|
|
2862
|
+
if (!keptOutside(dir, keepOutside)) continue;
|
|
2863
|
+
try {
|
|
2864
|
+
mkdirSync(dir, { recursive: true, mode: 448 });
|
|
2865
|
+
return dir;
|
|
2866
|
+
} catch {
|
|
2867
|
+
continue;
|
|
2868
|
+
}
|
|
2869
|
+
}
|
|
2870
|
+
return tmpdir();
|
|
2871
|
+
}
|
|
2872
|
+
function candidateDir(dir) {
|
|
2873
|
+
if (dir === void 0 || dir === "") return void 0;
|
|
2874
|
+
if (!isAbsolute(dir) || normalize(dir) !== dir || parse(dir).root === dir) return void 0;
|
|
2875
|
+
return normalize(dir);
|
|
2876
|
+
}
|
|
2877
|
+
function defaultHostStateRoot() {
|
|
2878
|
+
if (process.platform === "win32") {
|
|
2879
|
+
const localAppData = nonEmptyEnv("LOCALAPPDATA");
|
|
2880
|
+
if (localAppData === void 0) return void 0;
|
|
2881
|
+
return candidateDir(join2(localAppData, "Ceal", "Host"));
|
|
2882
|
+
}
|
|
2883
|
+
if (process.platform === "darwin") {
|
|
2884
|
+
const home2 = nonEmptyEnv("HOME");
|
|
2885
|
+
if (home2 === void 0) return void 0;
|
|
2886
|
+
return candidateDir(join2(home2, "Library", "Application Support", "Ceal", "Host"));
|
|
2887
|
+
}
|
|
2888
|
+
const xdg = nonEmptyEnv("XDG_STATE_HOME");
|
|
2889
|
+
if (xdg !== void 0) {
|
|
2890
|
+
const root = candidateDir(join2(xdg, "ceal", "host"));
|
|
2891
|
+
if (root !== void 0) return root;
|
|
2892
|
+
}
|
|
2893
|
+
const home = nonEmptyEnv("HOME");
|
|
2894
|
+
if (home === void 0) return void 0;
|
|
2895
|
+
return candidateDir(join2(home, ".local", "state", "ceal", "host"));
|
|
2896
|
+
}
|
|
2897
|
+
function nonEmptyEnv(name) {
|
|
2898
|
+
const value = process.env[name];
|
|
2899
|
+
return value === void 0 || value === "" ? void 0 : value;
|
|
2900
|
+
}
|
|
2901
|
+
function keptOutside(dir, keepOutside) {
|
|
2902
|
+
for (const tree of keepOutside) {
|
|
2903
|
+
const clean = candidateDir(tree);
|
|
2904
|
+
if (clean === void 0) continue;
|
|
2905
|
+
if (insideDir(dir, clean)) return false;
|
|
2906
|
+
}
|
|
2907
|
+
return true;
|
|
2908
|
+
}
|
|
2909
|
+
function insideDir(dir, tree) {
|
|
2910
|
+
if (sameDir(dir, tree)) return true;
|
|
2911
|
+
if (process.platform === "win32") return dir.toLowerCase().startsWith(tree.toLowerCase() + sep);
|
|
2912
|
+
return dir.startsWith(tree + sep);
|
|
2913
|
+
}
|
|
2914
|
+
function sameDir(left, right) {
|
|
2915
|
+
if (process.platform === "win32") return left.toLowerCase() === right.toLowerCase();
|
|
2916
|
+
return left === right;
|
|
2917
|
+
}
|
|
2918
|
+
|
|
2919
|
+
// host/secure-file.ts
|
|
2834
2920
|
var SecureFileCustodyError = class extends Error {
|
|
2835
2921
|
name = "SecureFileCustodyError";
|
|
2836
2922
|
reason;
|
|
@@ -2929,7 +3015,7 @@ async function runSecurefsCommand(args, maxBytes, custody, stdin) {
|
|
|
2929
3015
|
const executable = custody.securefs_executable ?? resolveInstalledHostExecutable(process.platform);
|
|
2930
3016
|
const processArgs = [...custody.securefs_args_prefix ?? [], ...args];
|
|
2931
3017
|
return await new Promise((resolve, reject) => {
|
|
2932
|
-
const child = execFile(executable, processArgs, { encoding: "buffer", windowsHide: true, timeout: WINDOWS_SECUREFS_TIMEOUT_MS, maxBuffer: maxBytes + WINDOWS_SECUREFS_DIAGNOSTIC_BYTES }, (error, stdout, stderr) => {
|
|
3018
|
+
const child = execFile(executable, processArgs, { encoding: "buffer", windowsHide: true, timeout: WINDOWS_SECUREFS_TIMEOUT_MS, maxBuffer: maxBytes + WINDOWS_SECUREFS_DIAGNOSTIC_BYTES, cwd: resolveCealSpawnWorkingDirectory() }, (error, stdout, stderr) => {
|
|
2933
3019
|
const exitCode = error === null ? 0 : typeof error.code === "number" ? error.code : null;
|
|
2934
3020
|
if (exitCode === null) {
|
|
2935
3021
|
reject(new SecureFileCustodyError("unavailable", "The installed Windows Host securefs command could not run."));
|
|
@@ -2958,7 +3044,7 @@ function securefsRefusal(stderr) {
|
|
|
2958
3044
|
}
|
|
2959
3045
|
function resolveInstalledHostExecutable(platform) {
|
|
2960
3046
|
const privateRuntimeRoot = dirname(fileURLToPath(import.meta.url));
|
|
2961
|
-
return platform === "win32" ? win323.join(privateRuntimeRoot, "..", "..", "bin", "ceal-host.exe") :
|
|
3047
|
+
return platform === "win32" ? win323.join(privateRuntimeRoot, "..", "..", "bin", "ceal-host.exe") : join3(privateRuntimeRoot, "..", "..", "bin", "ceal-host");
|
|
2962
3048
|
}
|
|
2963
3049
|
function isRecord(value) {
|
|
2964
3050
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -3345,7 +3431,7 @@ function record(value) {
|
|
|
3345
3431
|
import { createHash as createHash5 } from "node:crypto";
|
|
3346
3432
|
import { constants as constants4 } from "node:fs";
|
|
3347
3433
|
import { mkdir as mkdir2, open as open3, opendir, unlink as unlink2 } from "node:fs/promises";
|
|
3348
|
-
import { dirname as dirname4, join as
|
|
3434
|
+
import { dirname as dirname4, join as join4 } from "node:path";
|
|
3349
3435
|
|
|
3350
3436
|
// host/relay/src/durable-atomic-replacement.ts
|
|
3351
3437
|
import { lstat as lstat3, mkdir, open as open2, rename, unlink } from "node:fs/promises";
|
|
@@ -3498,9 +3584,9 @@ var HostUsageFactsStore = class {
|
|
|
3498
3584
|
afterBatchPublish;
|
|
3499
3585
|
sessionDirectoryCursor;
|
|
3500
3586
|
constructor(options) {
|
|
3501
|
-
this.root =
|
|
3502
|
-
this.sessions =
|
|
3503
|
-
this.batches =
|
|
3587
|
+
this.root = join4(options.outbox_dir, "usage-facts");
|
|
3588
|
+
this.sessions = join4(this.root, "sessions");
|
|
3589
|
+
this.batches = join4(this.root, "batches");
|
|
3504
3590
|
this.platform = options.platform ?? process.platform;
|
|
3505
3591
|
this.custody = options.secure_file_custody ?? {};
|
|
3506
3592
|
this.afterPendingWrite = options.afterPendingWrite;
|
|
@@ -3517,7 +3603,6 @@ var HostUsageFactsStore = class {
|
|
|
3517
3603
|
await cursor?.close();
|
|
3518
3604
|
}
|
|
3519
3605
|
async readState(producer, hostSourceRef, hostSessionRef) {
|
|
3520
|
-
await this.prepare();
|
|
3521
3606
|
const path = this.sessionPath(producer, hostSourceRef, hostSessionRef);
|
|
3522
3607
|
const value = await readOptionalJson(path, HOST_USAGE_FACTS_STATE_MAX_BYTES, this.platform, this.custody);
|
|
3523
3608
|
if (value === null) return null;
|
|
@@ -3575,11 +3660,15 @@ var HostUsageFactsStore = class {
|
|
|
3575
3660
|
}
|
|
3576
3661
|
/** Remove unreferenced local batch objects in bounded pieces after settling any exact pending transition. */
|
|
3577
3662
|
async sweepOrphanedBatches(state) {
|
|
3578
|
-
await this.prepare();
|
|
3579
3663
|
const directoryPath = this.batchSessionDirectory(state.producer, state.host_source_ref, state.host_session_ref);
|
|
3580
|
-
await preparePrivateDirectory(directoryPath, this.platform, this.custody);
|
|
3581
3664
|
const expected = expectedBatchNames(state);
|
|
3582
|
-
|
|
3665
|
+
let directory;
|
|
3666
|
+
try {
|
|
3667
|
+
directory = await opendir(directoryPath);
|
|
3668
|
+
} catch (error) {
|
|
3669
|
+
if (errorCode2(error) === "ENOENT") return 0;
|
|
3670
|
+
throw error;
|
|
3671
|
+
}
|
|
3583
3672
|
let inspected = 0;
|
|
3584
3673
|
let deleted = 0;
|
|
3585
3674
|
try {
|
|
@@ -3588,7 +3677,7 @@ var HostUsageFactsStore = class {
|
|
|
3588
3677
|
if (entry === null) break;
|
|
3589
3678
|
inspected += 1;
|
|
3590
3679
|
if (!isOrphanBatchEntry(entry, expected)) continue;
|
|
3591
|
-
await unlink2(
|
|
3680
|
+
await unlink2(join4(directoryPath, entry.name));
|
|
3592
3681
|
deleted += 1;
|
|
3593
3682
|
}
|
|
3594
3683
|
} finally {
|
|
@@ -3616,10 +3705,9 @@ var HostUsageFactsStore = class {
|
|
|
3616
3705
|
});
|
|
3617
3706
|
}
|
|
3618
3707
|
async nextUploadCandidate(producer, hostSourceRef) {
|
|
3619
|
-
await this.prepare();
|
|
3620
3708
|
const names = await this.readNextSessionNames();
|
|
3621
3709
|
for (const name of names) {
|
|
3622
|
-
const state = await readOptionalJson(
|
|
3710
|
+
const state = await readOptionalJson(join4(this.sessions, name), HOST_USAGE_FACTS_STATE_MAX_BYTES, this.platform, this.custody);
|
|
3623
3711
|
if (state === null) continue;
|
|
3624
3712
|
validateStateOwner(state, producer, hostSourceRef);
|
|
3625
3713
|
let validated = state;
|
|
@@ -3634,7 +3722,14 @@ var HostUsageFactsStore = class {
|
|
|
3634
3722
|
return null;
|
|
3635
3723
|
}
|
|
3636
3724
|
async readNextSessionNames() {
|
|
3637
|
-
this.sessionDirectoryCursor
|
|
3725
|
+
if (this.sessionDirectoryCursor === void 0) {
|
|
3726
|
+
try {
|
|
3727
|
+
this.sessionDirectoryCursor = await opendir(this.sessions);
|
|
3728
|
+
} catch (error) {
|
|
3729
|
+
if (errorCode2(error) === "ENOENT") return [];
|
|
3730
|
+
throw error;
|
|
3731
|
+
}
|
|
3732
|
+
}
|
|
3638
3733
|
const names = [];
|
|
3639
3734
|
let inspected = 0;
|
|
3640
3735
|
while (inspected < HOST_USAGE_FACTS_UPLOAD_SCAN_SESSIONS) {
|
|
@@ -3800,14 +3895,14 @@ var HostUsageFactsStore = class {
|
|
|
3800
3895
|
}
|
|
3801
3896
|
}
|
|
3802
3897
|
sessionPath(producer, hostSourceRef, hostSessionRef) {
|
|
3803
|
-
return
|
|
3898
|
+
return join4(this.sessions, `${sha2562(JSON.stringify({ producer, host_source_ref: hostSourceRef, host_session_ref: hostSessionRef }))}.json`);
|
|
3804
3899
|
}
|
|
3805
3900
|
batchSessionDirectory(producer, hostSourceRef, hostSessionRef) {
|
|
3806
3901
|
const sessionName = `${sha2562(JSON.stringify({ producer, host_source_ref: hostSourceRef, host_session_ref: hostSessionRef }))}.json`;
|
|
3807
|
-
return
|
|
3902
|
+
return join4(this.batches, sessionName.slice(0, -5));
|
|
3808
3903
|
}
|
|
3809
3904
|
batchPath(state, batchRef) {
|
|
3810
|
-
return
|
|
3905
|
+
return join4(this.batchSessionDirectory(state.producer, state.host_source_ref, state.host_session_ref), batchFileName(batchRef));
|
|
3811
3906
|
}
|
|
3812
3907
|
};
|
|
3813
3908
|
function serializeBatch(batch) {
|
|
@@ -4048,7 +4143,7 @@ function sha2562(value) {
|
|
|
4048
4143
|
|
|
4049
4144
|
// host/service-log.ts
|
|
4050
4145
|
import { copyFile, mkdir as mkdir3, stat, truncate, appendFile } from "node:fs/promises";
|
|
4051
|
-
import { dirname as dirname5, isAbsolute, posix as posix4, win32 as win325 } from "node:path";
|
|
4146
|
+
import { dirname as dirname5, isAbsolute as isAbsolute2, posix as posix4, win32 as win325 } from "node:path";
|
|
4052
4147
|
|
|
4053
4148
|
// host/service-log-delivery.ts
|
|
4054
4149
|
var HOST_SERVICE_LOG_DELIVERY_SCHEMA = "ceal.host_service_log_delivery.v1";
|
|
@@ -4243,7 +4338,7 @@ async function rotateHostServiceLog(path, maxBytes = HOST_SERVICE_LOG_MAX_BYTES)
|
|
|
4243
4338
|
}
|
|
4244
4339
|
function boundHostServiceLog(environment = process.env) {
|
|
4245
4340
|
const path = environment[HOST_SERVICE_LOG_ENVIRONMENT];
|
|
4246
|
-
if (path === void 0 || !
|
|
4341
|
+
if (path === void 0 || !isAbsolute2(path)) return () => void 0;
|
|
4247
4342
|
let reported = false;
|
|
4248
4343
|
const ready = ensureHostServiceLogDirectory(path);
|
|
4249
4344
|
const check = () => {
|
|
@@ -4278,7 +4373,7 @@ async function persistHostServiceLogLine(line, environment = process.env) {
|
|
|
4278
4373
|
await appendHostServiceLogLine(path, line).catch(() => void 0);
|
|
4279
4374
|
}
|
|
4280
4375
|
async function appendHostServiceLogLine(path, line) {
|
|
4281
|
-
if (!
|
|
4376
|
+
if (!isAbsolute2(path)) return;
|
|
4282
4377
|
await ensureHostServiceLogDirectory(path);
|
|
4283
4378
|
await appendFile(path, line);
|
|
4284
4379
|
}
|
|
@@ -4314,6 +4409,10 @@ var HostUsageFactsUploader = class {
|
|
|
4314
4409
|
async close() {
|
|
4315
4410
|
await this.store.close();
|
|
4316
4411
|
}
|
|
4412
|
+
/** The start owner prepares the store once, so idle ticks below never re-prepare. */
|
|
4413
|
+
async prepare() {
|
|
4414
|
+
await this.store.prepare();
|
|
4415
|
+
}
|
|
4317
4416
|
async uploadOne(signal) {
|
|
4318
4417
|
const candidate = await this.store.nextUploadCandidate(this.options.producer, this.options.host_source_ref);
|
|
4319
4418
|
if (candidate === null) return false;
|
|
@@ -4336,6 +4435,11 @@ var HostUsageFactsUploader = class {
|
|
|
4336
4435
|
};
|
|
4337
4436
|
async function runHostUsageFactsUploader(options, signal, wait = waitForAbort) {
|
|
4338
4437
|
const uploader = new HostUsageFactsUploader(options);
|
|
4438
|
+
try {
|
|
4439
|
+
await uploader.prepare();
|
|
4440
|
+
} catch {
|
|
4441
|
+
writeHostServiceDiagnostic(options.producer, "usage_upload_failed", void 0, "upload_failed");
|
|
4442
|
+
}
|
|
4339
4443
|
let delay = 500;
|
|
4340
4444
|
let failures = 0;
|
|
4341
4445
|
try {
|
|
@@ -4365,6 +4469,7 @@ async function runHostUsageFactsUploader(options, signal, wait = waitForAbort) {
|
|
|
4365
4469
|
|
|
4366
4470
|
// host/relay/src/host-producer-core.ts
|
|
4367
4471
|
import { createHash as createHash6 } from "node:crypto";
|
|
4472
|
+
import { readdir } from "node:fs/promises";
|
|
4368
4473
|
var HOST_TRANSCRIPT_CURSOR_REASONS = vocabulary(["transcript_replaced", "transcript_truncated", "transcript_rewritten", "transcript_malformed"]);
|
|
4369
4474
|
function isHostTranscriptCursorReason(value) {
|
|
4370
4475
|
return typeof value === "string" && HOST_TRANSCRIPT_CURSOR_REASONS.some((reason) => reason === value);
|
|
@@ -4570,6 +4675,14 @@ var HostTranscriptWatcher = class {
|
|
|
4570
4675
|
return transcriptCursorBoundsReason(handle, cursor, size);
|
|
4571
4676
|
}
|
|
4572
4677
|
};
|
|
4678
|
+
async function listHostOutboxDirectoryNames(directory) {
|
|
4679
|
+
try {
|
|
4680
|
+
return await readdir(directory);
|
|
4681
|
+
} catch (error) {
|
|
4682
|
+
if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") return [];
|
|
4683
|
+
throw error;
|
|
4684
|
+
}
|
|
4685
|
+
}
|
|
4573
4686
|
var HostProducerDrainCore = class {
|
|
4574
4687
|
host;
|
|
4575
4688
|
now;
|
|
@@ -4597,8 +4710,8 @@ var HostProducerDrainCore = class {
|
|
|
4597
4710
|
};
|
|
4598
4711
|
|
|
4599
4712
|
// host/claude/src/claude-outbox.ts
|
|
4600
|
-
import { mkdir as mkdir4,
|
|
4601
|
-
import { isAbsolute as
|
|
4713
|
+
import { mkdir as mkdir4, readFile, unlink as unlink3 } from "node:fs/promises";
|
|
4714
|
+
import { isAbsolute as isAbsolute4, join as join5 } from "node:path";
|
|
4602
4715
|
|
|
4603
4716
|
// host/invocation-context.ts
|
|
4604
4717
|
var HOST_INVOCATION_TURN_SELECTION_SCHEMA = "ceal.host_invocation_turn_selection.v1";
|
|
@@ -4827,7 +4940,7 @@ var ClaudeHostError = class extends Error {
|
|
|
4827
4940
|
};
|
|
4828
4941
|
|
|
4829
4942
|
// host/claude/src/claude-invocation-context.ts
|
|
4830
|
-
import { isAbsolute as
|
|
4943
|
+
import { isAbsolute as isAbsolute3 } from "node:path";
|
|
4831
4944
|
function claudeInvocationContextFromTurn(identity, promptRef, expiresAt, workingDirectory, turnGenerationRef) {
|
|
4832
4945
|
return invocationContextFromTurn(identity, promptRef, expiresAt, { schema_version: CLAUDE_INVOCATION_CONTEXT_SCHEMA_VERSION, validate: validateClaudeHostInvocationContext, working_directory: workingDirectory, turn_generation_ref: turnGenerationRef });
|
|
4833
4946
|
}
|
|
@@ -4856,7 +4969,7 @@ function optionalSafeRef(value) {
|
|
|
4856
4969
|
return value === void 0 || safeRef2(value);
|
|
4857
4970
|
}
|
|
4858
4971
|
function optionalDirectory(value) {
|
|
4859
|
-
return value === void 0 || typeof value === "string" &&
|
|
4972
|
+
return value === void 0 || typeof value === "string" && isAbsolute3(value) && !value.includes("\0") && value.length <= 4096;
|
|
4860
4973
|
}
|
|
4861
4974
|
function safeRef2(value) {
|
|
4862
4975
|
return typeof value === "string" && /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u.test(value);
|
|
@@ -4881,14 +4994,14 @@ var ClaudeOutboxStore = class {
|
|
|
4881
4994
|
activeContexts;
|
|
4882
4995
|
turnSelections;
|
|
4883
4996
|
constructor(directory) {
|
|
4884
|
-
if (!
|
|
4997
|
+
if (!isAbsolute4(directory)) throw new ClaudeHostError("configuration", "Claude outbox directory must be absolute.");
|
|
4885
4998
|
this.directory = directory;
|
|
4886
|
-
this.envelopes =
|
|
4887
|
-
this.sessions =
|
|
4888
|
-
this.registrations =
|
|
4889
|
-
this.cursors =
|
|
4890
|
-
this.activeContexts =
|
|
4891
|
-
this.turnSelections =
|
|
4999
|
+
this.envelopes = join5(directory, "envelopes");
|
|
5000
|
+
this.sessions = join5(directory, "sessions");
|
|
5001
|
+
this.registrations = join5(directory, "transcript-registrations");
|
|
5002
|
+
this.cursors = join5(directory, "transcript-cursors");
|
|
5003
|
+
this.activeContexts = join5(directory, "active-contexts");
|
|
5004
|
+
this.turnSelections = join5(directory, "turn-selections");
|
|
4892
5005
|
}
|
|
4893
5006
|
async prepare() {
|
|
4894
5007
|
for (const path of [this.envelopes, this.sessions, this.registrations, this.cursors, this.activeContexts, this.turnSelections]) {
|
|
@@ -4916,6 +5029,7 @@ var ClaudeOutboxStore = class {
|
|
|
4916
5029
|
const path = this.activeContextPath(identity);
|
|
4917
5030
|
const active = await readProjectionFile(path);
|
|
4918
5031
|
if (active === null || active.prompt_ref !== promptRef || active.identity.host_turn_ref !== identity.host_turn_ref) return false;
|
|
5032
|
+
await this.prepare();
|
|
4919
5033
|
const updated = { ...active, turn_generation_ref: turnGenerationRef };
|
|
4920
5034
|
validateClaudeHostInvocationContext(updated);
|
|
4921
5035
|
await durableAtomicReplace(path, JSON.stringify(updated));
|
|
@@ -4928,17 +5042,15 @@ var ClaudeOutboxStore = class {
|
|
|
4928
5042
|
*/
|
|
4929
5043
|
async readRawInvocationContext(hostSourceRef, hostSessionRef) {
|
|
4930
5044
|
if (!SAFE_REF3.test(hostSourceRef) || !SAFE_REF3.test(hostSessionRef)) throw new ClaudeHostError("invalid_input", "Claude Host context identity or clock is invalid.");
|
|
4931
|
-
await this.prepare();
|
|
4932
5045
|
const context = await readLatestSessionProjection(this.activeContextPath({ host_source_ref: hostSourceRef, host_session_ref: hostSessionRef }), hostSourceRef, hostSessionRef, readProjectionFile);
|
|
4933
5046
|
return context;
|
|
4934
5047
|
}
|
|
4935
5048
|
async listInvocationContexts(now = /* @__PURE__ */ new Date()) {
|
|
4936
|
-
await this.prepare();
|
|
4937
5049
|
const contexts = [];
|
|
4938
|
-
for (const name of await
|
|
5050
|
+
for (const name of await listHostOutboxDirectoryNames(this.activeContexts)) {
|
|
4939
5051
|
if (!name.endsWith(".json")) continue;
|
|
4940
5052
|
try {
|
|
4941
|
-
const value = JSON.parse(await readFile(
|
|
5053
|
+
const value = JSON.parse(await readFile(join5(this.activeContexts, name), "utf8"));
|
|
4942
5054
|
validateClaudeHostInvocationContext(value);
|
|
4943
5055
|
if (Date.parse(value.expires_at) > now.getTime()) contexts.push(value);
|
|
4944
5056
|
} catch {
|
|
@@ -4952,13 +5064,12 @@ var ClaudeOutboxStore = class {
|
|
|
4952
5064
|
await durableAtomicReplace(this.envelopePath(entry.submission_ref), JSON.stringify(entry));
|
|
4953
5065
|
}
|
|
4954
5066
|
async listEnvelopes() {
|
|
4955
|
-
await this.prepare();
|
|
4956
5067
|
const entries = [];
|
|
4957
5068
|
let malformed = 0;
|
|
4958
|
-
for (const name of await
|
|
5069
|
+
for (const name of await listHostOutboxDirectoryNames(this.envelopes)) {
|
|
4959
5070
|
if (!name.endsWith(".json")) continue;
|
|
4960
5071
|
try {
|
|
4961
|
-
const value = JSON.parse(await readFile(
|
|
5072
|
+
const value = JSON.parse(await readFile(join5(this.envelopes, name), "utf8"));
|
|
4962
5073
|
validateEnvelope(value);
|
|
4963
5074
|
entries.push(value);
|
|
4964
5075
|
} catch {
|
|
@@ -4979,13 +5090,12 @@ var ClaudeOutboxStore = class {
|
|
|
4979
5090
|
async saveSession(snapshot) {
|
|
4980
5091
|
validateSession(snapshot);
|
|
4981
5092
|
await this.prepare();
|
|
4982
|
-
await durableAtomicReplace(
|
|
5093
|
+
await durableAtomicReplace(join5(this.sessions, `${cealRequestSha256({ source: snapshot.host_source_ref, session: snapshot.host_session_ref })}.json`), JSON.stringify(snapshot));
|
|
4983
5094
|
}
|
|
4984
5095
|
async readSession(sourceRef, sessionRef) {
|
|
4985
5096
|
if (!SAFE_REF3.test(sourceRef) || !SAFE_REF3.test(sessionRef)) throw new ClaudeHostError("invalid_input", "Claude session identity is invalid.");
|
|
4986
|
-
await this.prepare();
|
|
4987
5097
|
try {
|
|
4988
|
-
const value = JSON.parse(await readFile(
|
|
5098
|
+
const value = JSON.parse(await readFile(join5(this.sessions, `${cealRequestSha256({ source: sourceRef, session: sessionRef })}.json`), "utf8"));
|
|
4989
5099
|
validateSession(value);
|
|
4990
5100
|
return value;
|
|
4991
5101
|
} catch (error) {
|
|
@@ -5016,18 +5126,16 @@ var ClaudeOutboxStore = class {
|
|
|
5016
5126
|
}
|
|
5017
5127
|
async readTranscriptRegistration(hostSourceRef, hostSessionRef) {
|
|
5018
5128
|
if (!SAFE_REF3.test(hostSourceRef) || !SAFE_REF3.test(hostSessionRef)) throw new ClaudeHostError("invalid_input", "Claude transcript session identity is invalid.");
|
|
5019
|
-
await this.prepare();
|
|
5020
5129
|
const registration = await this.readRegistrationFile(this.registrationPath(hostSourceRef, hostSessionRef));
|
|
5021
5130
|
if (registration !== null && (registration.host_source_ref !== hostSourceRef || registration.host_session_ref !== hostSessionRef)) throw new ClaudeHostError("storage", "Claude transcript registration identity does not match its session.");
|
|
5022
5131
|
return registration;
|
|
5023
5132
|
}
|
|
5024
5133
|
async listTranscriptRegistrations() {
|
|
5025
|
-
await this.prepare();
|
|
5026
5134
|
const registrations = [];
|
|
5027
|
-
for (const name of await
|
|
5135
|
+
for (const name of await listHostOutboxDirectoryNames(this.registrations)) {
|
|
5028
5136
|
if (!name.endsWith(".json")) continue;
|
|
5029
5137
|
try {
|
|
5030
|
-
const value = JSON.parse(await readFile(
|
|
5138
|
+
const value = JSON.parse(await readFile(join5(this.registrations, name), "utf8"));
|
|
5031
5139
|
validateRegistration(value);
|
|
5032
5140
|
registrations.push(value);
|
|
5033
5141
|
} catch {
|
|
@@ -5037,7 +5145,6 @@ var ClaudeOutboxStore = class {
|
|
|
5037
5145
|
}
|
|
5038
5146
|
async readInvocationTurnSelection(hostSourceRef, hostSessionRef) {
|
|
5039
5147
|
if (!SAFE_REF3.test(hostSourceRef) || !SAFE_REF3.test(hostSessionRef)) throw new ClaudeHostError("invalid_input", "Claude Host turn selection identity is invalid.");
|
|
5040
|
-
await this.prepare();
|
|
5041
5148
|
try {
|
|
5042
5149
|
const value = JSON.parse(await readFile(this.turnSelectionPath(hostSourceRef, hostSessionRef), "utf8"));
|
|
5043
5150
|
if (!isHostInvocationTurnSelection(value) || value.host_source_ref !== hostSourceRef || value.host_session_ref !== hostSessionRef) throw new ClaudeHostError("storage", "Claude Host turn selection is malformed.");
|
|
@@ -5049,7 +5156,6 @@ var ClaudeOutboxStore = class {
|
|
|
5049
5156
|
}
|
|
5050
5157
|
async readTranscriptCursor(registration) {
|
|
5051
5158
|
validateRegistration(registration);
|
|
5052
|
-
await this.prepare();
|
|
5053
5159
|
try {
|
|
5054
5160
|
const value = JSON.parse(await readFile(this.cursorPath(registration.host_source_ref, registration.host_session_ref), "utf8"));
|
|
5055
5161
|
validateCursor(value);
|
|
@@ -5065,16 +5171,16 @@ var ClaudeOutboxStore = class {
|
|
|
5065
5171
|
await durableAtomicReplace(this.cursorPath(cursor.host_source_ref, cursor.host_session_ref), JSON.stringify(cursor));
|
|
5066
5172
|
}
|
|
5067
5173
|
envelopePath(ref) {
|
|
5068
|
-
return
|
|
5174
|
+
return join5(this.envelopes, `${cealRequestSha256(ref)}.json`);
|
|
5069
5175
|
}
|
|
5070
5176
|
registrationPath(sourceRef, sessionRef) {
|
|
5071
|
-
return
|
|
5177
|
+
return join5(this.registrations, `${cealRequestSha256({ source: sourceRef, session: sessionRef })}.json`);
|
|
5072
5178
|
}
|
|
5073
5179
|
turnSelectionPath(sourceRef, sessionRef) {
|
|
5074
|
-
return
|
|
5180
|
+
return join5(this.turnSelections, `${cealRequestSha256({ source: sourceRef, session: sessionRef })}.json`);
|
|
5075
5181
|
}
|
|
5076
5182
|
cursorPath(sourceRef, sessionRef) {
|
|
5077
|
-
return
|
|
5183
|
+
return join5(this.cursors, `${cealRequestSha256({ source: sourceRef, session: sessionRef })}.json`);
|
|
5078
5184
|
}
|
|
5079
5185
|
async readRegistrationFile(path) {
|
|
5080
5186
|
try {
|
|
@@ -5094,7 +5200,7 @@ var ClaudeOutboxStore = class {
|
|
|
5094
5200
|
}
|
|
5095
5201
|
}
|
|
5096
5202
|
activeContextPath(identity) {
|
|
5097
|
-
return
|
|
5203
|
+
return join5(this.activeContexts, `${invocationContextKey(identity)}.json`);
|
|
5098
5204
|
}
|
|
5099
5205
|
};
|
|
5100
5206
|
function validateInvocationContextReadArguments(hostSourceRef, hostSessionRef, now) {
|
|
@@ -5170,7 +5276,7 @@ function validateRegistration(value) {
|
|
|
5170
5276
|
if (!timestamp2(value.registered_at) || !timestamp2(value.expires_at)) throw new ClaudeHostError("storage", "Claude transcript registration timestamps are malformed.");
|
|
5171
5277
|
}
|
|
5172
5278
|
function validateRegistrationPaths(cwd, transcriptPath) {
|
|
5173
|
-
if (cwd !== void 0 && (typeof cwd !== "string" || !
|
|
5279
|
+
if (cwd !== void 0 && (typeof cwd !== "string" || !isAbsolute4(cwd) || cwd.length > CLAUDE_TRANSCRIPT_PATH_MAX_CHARACTERS || cwd.includes("\0"))) {
|
|
5174
5280
|
throw new ClaudeHostError("storage", "Claude transcript registration working directory is malformed.");
|
|
5175
5281
|
}
|
|
5176
5282
|
if (typeof transcriptPath !== "string" || transcriptPath.length === 0 || transcriptPath.length > CLAUDE_TRANSCRIPT_PATH_MAX_CHARACTERS) {
|
|
@@ -5291,7 +5397,7 @@ var ClaudeProducer = class {
|
|
|
5291
5397
|
// host/claude/src/claude-transcript-watcher.ts
|
|
5292
5398
|
import { readdir as readdir2 } from "node:fs/promises";
|
|
5293
5399
|
import { isDeepStrictEqual } from "node:util";
|
|
5294
|
-
import { join as
|
|
5400
|
+
import { join as join6 } from "node:path";
|
|
5295
5401
|
|
|
5296
5402
|
// host/claude/src/claude-decoder.ts
|
|
5297
5403
|
import { createHash as createHash7 } from "node:crypto";
|
|
@@ -5667,7 +5773,7 @@ var ClaudeTranscriptWatcher = class extends HostTranscriptWatcher {
|
|
|
5667
5773
|
return consumed;
|
|
5668
5774
|
}
|
|
5669
5775
|
async consumeSubagentFile(draft, directory, name) {
|
|
5670
|
-
const path =
|
|
5776
|
+
const path = join6(directory, name);
|
|
5671
5777
|
let handle;
|
|
5672
5778
|
try {
|
|
5673
5779
|
handle = await openNoFollow(path);
|
|
@@ -5916,7 +6022,7 @@ function isAssistantUsageLine(record5) {
|
|
|
5916
6022
|
}
|
|
5917
6023
|
function subagentsDirectory(transcriptPath) {
|
|
5918
6024
|
const stem = transcriptPath.endsWith(".jsonl") ? transcriptPath.slice(0, -".jsonl".length) : transcriptPath;
|
|
5919
|
-
return
|
|
6025
|
+
return join6(stem, "subagents");
|
|
5920
6026
|
}
|
|
5921
6027
|
function observationRef(hostSourceRef, event, identity, value) {
|
|
5922
6028
|
return cealHostObservationRef("claude", transcriptObjectSha256({ host_source_ref: hostSourceRef, event, identity, value }));
|
|
@@ -5972,7 +6078,7 @@ async function drainClaudeProducerOnce(options) {
|
|
|
5972
6078
|
import { createHash as createHash8 } from "node:crypto";
|
|
5973
6079
|
import { constants as constants6 } from "node:fs";
|
|
5974
6080
|
import { readdir as readdir3 } from "node:fs/promises";
|
|
5975
|
-
import { join as
|
|
6081
|
+
import { join as join7 } from "node:path";
|
|
5976
6082
|
var ClaudeUsageFactsCapturer = class {
|
|
5977
6083
|
sources;
|
|
5978
6084
|
usage;
|
|
@@ -6085,7 +6191,7 @@ var ClaudeUsageFactsCapturer = class {
|
|
|
6085
6191
|
async captureSubagentFile(registration, name, state) {
|
|
6086
6192
|
let handle;
|
|
6087
6193
|
try {
|
|
6088
|
-
const opened = await readHostUsageTranscriptSource(() => openNoFollow(
|
|
6194
|
+
const opened = await readHostUsageTranscriptSource(() => openNoFollow(join7(subagentsDirectory(registration.transcript_path), name), constants6.O_RDONLY));
|
|
6089
6195
|
handle = opened;
|
|
6090
6196
|
const file = await readHostUsageTranscriptSource(() => ownedClaudeTranscriptFile(opened));
|
|
6091
6197
|
const sourceRef = sourceFileRef(registration, file.device, file.inode);
|