@sjawhar/claude-envoy 5.27.1 → 5.28.0
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/.claude-plugin/plugin.json +1 -1
- package/.omp-plugin/plugin.json +1 -1
- package/dist/codex-hook.js +107 -31
- package/dist/dispatch.js +120 -31
- package/dist/envoy-channel.js +227 -128
- package/dist/session-hook.js +113 -37
- package/dist/session-title-hook.js +8 -6
- package/package.json +2 -2
- package/src/envoy-channel-server.ts +25 -10
package/.omp-plugin/plugin.json
CHANGED
package/dist/codex-hook.js
CHANGED
|
@@ -13650,6 +13650,7 @@ var GHOSTWISPR_TOPIC_PREFIX = "notifications.ghostwispr.";
|
|
|
13650
13650
|
function uncapturedTopicRefusal(topic, sessionID) {
|
|
13651
13651
|
return `${topic} was not registered: no stream subject captures it, so nothing would be delivered to ${sessionID} on it; follow a notifications.team.<name> topic instead`;
|
|
13652
13652
|
}
|
|
13653
|
+
var MESSAGE_NOT_SENT_PREFIX = "envoy: the message was not sent, and may be sent again later";
|
|
13653
13654
|
|
|
13654
13655
|
// ../contracts/src/legion-roles.ts
|
|
13655
13656
|
var LEGION_ROLES = [
|
|
@@ -14484,6 +14485,25 @@ var projectKeyValidation = {
|
|
|
14484
14485
|
message: `project is not a project key: ${PROJECT_KEY_RULE}`
|
|
14485
14486
|
};
|
|
14486
14487
|
var ARCHITECTURE_SOURCE_REPO_PATTERN = /^[A-Za-z0-9_-]+\/(?!\.\.?$)[A-Za-z0-9._-]+$/;
|
|
14488
|
+
var API_ROUTE_PATTERN = /^\/api\/v1(?=[/?]|$)/;
|
|
14489
|
+
var API_PATH_RULE = "path is a route under /api/v1: it begins /api/v1 and names no scheme or host, every character is printable ASCII other than a space, a backslash and #, and no segment before the query is . or ..";
|
|
14490
|
+
function apiPathProblem(value) {
|
|
14491
|
+
const { path } = value;
|
|
14492
|
+
if (typeof path !== "string")
|
|
14493
|
+
return;
|
|
14494
|
+
const named = JSON.stringify(path);
|
|
14495
|
+
if (!API_ROUTE_PATTERN.test(path)) {
|
|
14496
|
+
return `path ${named} is no route under /api/v1: give the route alone, beginning /api/v1, with no scheme or host (dispatch api --path /api/v1 lists every route).`;
|
|
14497
|
+
}
|
|
14498
|
+
if (!/^[!-~]*$/.test(path) || /[\\#]/.test(path)) {
|
|
14499
|
+
return `path ${named} holds a space, a backslash, a # or a character outside printable ASCII: percent-encode it.`;
|
|
14500
|
+
}
|
|
14501
|
+
const route = path.split("?", 1)[0] ?? "";
|
|
14502
|
+
if (route.split("/").some((segment) => /^(?:\.|%2e){1,2}$/i.test(segment))) {
|
|
14503
|
+
return `path ${named} holds a . or .. segment: name the route itself.`;
|
|
14504
|
+
}
|
|
14505
|
+
return;
|
|
14506
|
+
}
|
|
14487
14507
|
var ISSUE_STATUSES = [
|
|
14488
14508
|
"triage",
|
|
14489
14509
|
"icebox",
|
|
@@ -15089,6 +15109,20 @@ var dispatchToolSpecs = [
|
|
|
15089
15109
|
arguments: () => ({}),
|
|
15090
15110
|
strict: true
|
|
15091
15111
|
},
|
|
15112
|
+
{
|
|
15113
|
+
name: "dispatch_api",
|
|
15114
|
+
example: { path: "/api/v1/issues/DSP-1/events?limit=200" },
|
|
15115
|
+
description: "Read one route of Dispatch's HTTP API that no other command reads, with this session's own credential, and print Dispatch's JSON answer, for jq to read. It sends one GET of path: a route beginning /api/v1, with its query after ?; dispatch api --path /api/v1 lists every route. It only reads: it takes no method and no body, and every write goes through the command named for it (dispatch --help lists them). When Dispatch refuses the read, the command prints Dispatch's error with its code and, where Dispatch gives one, its hint, and exits 1. Under Claude Code, an answer longer than the output limit is written to a file the output names.",
|
|
15116
|
+
arguments: (z) => ({
|
|
15117
|
+
path: z.string({ min: 1 }).describe("The route to read, beginning /api/v1, with its query after ?, such as /api/v1/issues/ACME-12/events?limit=200. No scheme or host, and no . or .. segment.")
|
|
15118
|
+
}),
|
|
15119
|
+
validation: {
|
|
15120
|
+
check: (value) => apiPathProblem(value) === undefined,
|
|
15121
|
+
message: API_PATH_RULE,
|
|
15122
|
+
refusal: (value) => apiPathProblem(value) ?? API_PATH_RULE
|
|
15123
|
+
},
|
|
15124
|
+
strict: true
|
|
15125
|
+
},
|
|
15092
15126
|
{
|
|
15093
15127
|
name: "dispatch_handoff_write",
|
|
15094
15128
|
example: {
|
|
@@ -17508,17 +17542,19 @@ function errorClass(error) {
|
|
|
17508
17542
|
}
|
|
17509
17543
|
|
|
17510
17544
|
// ../envoy-client/src/errors.ts
|
|
17511
|
-
function
|
|
17512
|
-
if (!("fromDispatch" in error)
|
|
17545
|
+
function dispatchField(error, field) {
|
|
17546
|
+
if (!("fromDispatch" in error))
|
|
17513
17547
|
return;
|
|
17514
|
-
const
|
|
17515
|
-
return typeof
|
|
17548
|
+
const value = Reflect.get(error, field);
|
|
17549
|
+
return typeof value === "string" && value !== "" ? value : undefined;
|
|
17516
17550
|
}
|
|
17517
17551
|
function messageFor(error) {
|
|
17518
17552
|
if (!(error instanceof Error))
|
|
17519
17553
|
return scrub(String(error));
|
|
17520
|
-
const code =
|
|
17521
|
-
|
|
17554
|
+
const code = dispatchField(error, "code");
|
|
17555
|
+
const message = code === undefined || error.message.startsWith(code) ? error.message : `${code}: ${error.message}`;
|
|
17556
|
+
const hint = dispatchField(error, "hint");
|
|
17557
|
+
return scrub(hint === undefined ? message : `${message}; ${hint}`);
|
|
17522
17558
|
}
|
|
17523
17559
|
function hasErrnoCode(error, code) {
|
|
17524
17560
|
return error instanceof Error && "code" in error && error.code === code;
|
|
@@ -21341,6 +21377,7 @@ class DispatchServiceError extends Error {
|
|
|
21341
21377
|
mismatches;
|
|
21342
21378
|
issues;
|
|
21343
21379
|
changed;
|
|
21380
|
+
hint;
|
|
21344
21381
|
constructor(code, status, message, details = {}) {
|
|
21345
21382
|
super(message);
|
|
21346
21383
|
this.code = code;
|
|
@@ -21350,6 +21387,7 @@ class DispatchServiceError extends Error {
|
|
|
21350
21387
|
this.mismatches = details.mismatches;
|
|
21351
21388
|
this.issues = details.issues;
|
|
21352
21389
|
this.changed = details.changed;
|
|
21390
|
+
this.hint = details.hint;
|
|
21353
21391
|
}
|
|
21354
21392
|
}
|
|
21355
21393
|
|
|
@@ -21839,6 +21877,10 @@ class DispatchClient {
|
|
|
21839
21877
|
async limits() {
|
|
21840
21878
|
return this.#json("GET", ["api", "v1", "limits"]);
|
|
21841
21879
|
}
|
|
21880
|
+
async readRoute(path) {
|
|
21881
|
+
const url = new URL(path.slice(1), `${this.#baseUrl}/`).toString();
|
|
21882
|
+
return this.#response("GET", url, await this.#send("GET", url));
|
|
21883
|
+
}
|
|
21842
21884
|
async inbox(assignee) {
|
|
21843
21885
|
return this.#json("GET", ["api", "v1", "inbox"], undefined, { assignee });
|
|
21844
21886
|
}
|
|
@@ -22527,7 +22569,7 @@ class DispatchClient {
|
|
|
22527
22569
|
if (response.status === 409 && error.code === IDEMPOTENCY_KEY_COMMITTED) {
|
|
22528
22570
|
throw new DispatchWriteLandedError(IDEMPOTENCY_KEY_COMMITTED, response.status, method, requestForText(this.#baseUrl, url, DISPATCH_URL_SETTING));
|
|
22529
22571
|
}
|
|
22530
|
-
throw new DispatchServiceError(error.code ?? `HTTP_${response.status}`, response.status, error.error, error);
|
|
22572
|
+
throw new DispatchServiceError(error.code ?? `HTTP_${response.status}`, response.status, error.error, { ...error, hint: typeof error.hint === "string" ? error.hint : undefined });
|
|
22531
22573
|
}
|
|
22532
22574
|
throw this.#gatewayError(method, url, response, text, "Dispatch's error JSON");
|
|
22533
22575
|
}
|
|
@@ -24301,6 +24343,7 @@ var issueFreeTools = {
|
|
|
24301
24343
|
dispatch_answers: true,
|
|
24302
24344
|
dispatch_whoami: true,
|
|
24303
24345
|
dispatch_limits: true,
|
|
24346
|
+
dispatch_api: true,
|
|
24304
24347
|
dispatch_inbox: true,
|
|
24305
24348
|
dispatch_send_to_agent: true,
|
|
24306
24349
|
dispatch_architecture_sync: true
|
|
@@ -26707,6 +26750,16 @@ async function resultsCommand(context) {
|
|
|
26707
26750
|
};
|
|
26708
26751
|
}
|
|
26709
26752
|
|
|
26753
|
+
// ../envoy-client/src/dispatch-commands/api.ts
|
|
26754
|
+
async function apiCommand(context) {
|
|
26755
|
+
const path = stringArg(context.args, "path");
|
|
26756
|
+
const answer = await context.newClient().readRoute(path);
|
|
26757
|
+
return {
|
|
26758
|
+
text: typeof answer === "string" ? answer : JSON.stringify(answer, null, 2),
|
|
26759
|
+
details: { path }
|
|
26760
|
+
};
|
|
26761
|
+
}
|
|
26762
|
+
|
|
26710
26763
|
// ../envoy-client/src/dispatch-commands/render-item.ts
|
|
26711
26764
|
function askSummary({ ask, replies, answers }, askRef, pictures, incoming, outgoing) {
|
|
26712
26765
|
const answer = ask.answer;
|
|
@@ -29596,6 +29649,7 @@ var dispatchCommands = {
|
|
|
29596
29649
|
dispatch_answers: onSession(answersCommand),
|
|
29597
29650
|
dispatch_whoami: onSession(whoamiCommand),
|
|
29598
29651
|
dispatch_limits: onSession(limitsCommand),
|
|
29652
|
+
dispatch_api: onSession(apiCommand),
|
|
29599
29653
|
dispatch_inbox: onSession(inboxCommand)
|
|
29600
29654
|
};
|
|
29601
29655
|
// ../envoy-client/src/dispatch-execute.ts
|
|
@@ -29616,6 +29670,10 @@ async function executeDispatchTool(input) {
|
|
|
29616
29670
|
return command.origin === "none" ? command.run(session) : command.run(await commandContext(session));
|
|
29617
29671
|
}
|
|
29618
29672
|
|
|
29673
|
+
// ../cipher-client/src/environment.ts
|
|
29674
|
+
import { readFile as readFile6 } from "fs/promises";
|
|
29675
|
+
import { join as join7 } from "path";
|
|
29676
|
+
|
|
29619
29677
|
// ../cipher-client/src/device-login.ts
|
|
29620
29678
|
import { generateKeyPairSync as generateKeyPairSync2, randomUUID as randomUUID5 } from "crypto";
|
|
29621
29679
|
|
|
@@ -33412,6 +33470,8 @@ var BROKER_URL_VAR = "AGENT_SECRETS_URL";
|
|
|
33412
33470
|
var IDENTITY_VAR = "AGENT_SECRETS_MACHINE_IDENTITY";
|
|
33413
33471
|
var MACHINE_TOKEN_FILE_VAR = "AGENT_SECRETS_MACHINE_TOKEN_FILE";
|
|
33414
33472
|
var MACHINE_AUDIENCE_VAR = "AGENT_SECRETS_MACHINE_AUDIENCE";
|
|
33473
|
+
var KEY_DIR_VAR = "AGENT_SECRETS_KEY_DIR";
|
|
33474
|
+
var ROLE_KEY_FILE = "key.pem";
|
|
33415
33475
|
var SESSION_VAR = "AGENT_SECRETS_SESSION";
|
|
33416
33476
|
var PROJECTS_VAR = "AGENT_SECRETS_PROJECTS";
|
|
33417
33477
|
var MAX_PROJECTS = 16;
|
|
@@ -33425,6 +33485,7 @@ var BROKER_VARIABLES = [
|
|
|
33425
33485
|
BROKER_URL_VAR,
|
|
33426
33486
|
IDENTITY_VAR,
|
|
33427
33487
|
MACHINE_TOKEN_FILE_VAR,
|
|
33488
|
+
KEY_DIR_VAR,
|
|
33428
33489
|
MACHINE_AUDIENCE_VAR,
|
|
33429
33490
|
SESSION_VAR,
|
|
33430
33491
|
PROJECTS_VAR,
|
|
@@ -33500,6 +33561,21 @@ function tradeProjects(env) {
|
|
|
33500
33561
|
}
|
|
33501
33562
|
return sorted;
|
|
33502
33563
|
}
|
|
33564
|
+
async function machineKey(env) {
|
|
33565
|
+
const dir = value(env, KEY_DIR_VAR);
|
|
33566
|
+
if (value(env, IDENTITY_VAR) !== IDENTITY_KUBERNETES || dir === "")
|
|
33567
|
+
return await newDpopKey();
|
|
33568
|
+
const path = join7(dir, ROLE_KEY_FILE);
|
|
33569
|
+
let pem;
|
|
33570
|
+
try {
|
|
33571
|
+
pem = await readFile6(path, "utf8");
|
|
33572
|
+
} catch (error) {
|
|
33573
|
+
throw new Error(`read this role's agent-secrets key ${path}: ${messageOf(error)}`, {
|
|
33574
|
+
cause: error
|
|
33575
|
+
});
|
|
33576
|
+
}
|
|
33577
|
+
return await importDpopKey(pem, `this role's agent-secrets key ${path}`);
|
|
33578
|
+
}
|
|
33503
33579
|
async function brokerTokenClient(env, own = "", read) {
|
|
33504
33580
|
const brokerUrl = value(env, BROKER_URL_VAR);
|
|
33505
33581
|
const machine = machineIdentity(env);
|
|
@@ -33527,7 +33603,7 @@ async function brokerTokenClient(env, own = "", read) {
|
|
|
33527
33603
|
if (record === undefined) {
|
|
33528
33604
|
const client = new BrokerTokenClient({
|
|
33529
33605
|
brokerUrl,
|
|
33530
|
-
key: await
|
|
33606
|
+
key: await machineKey(env),
|
|
33531
33607
|
subject: machine,
|
|
33532
33608
|
session: tradeSession(env, own),
|
|
33533
33609
|
launcherCredential: false,
|
|
@@ -34722,18 +34798,18 @@ function claudeProjectDirectory(environment, fallback) {
|
|
|
34722
34798
|
// src/codex/codex-session-record.ts
|
|
34723
34799
|
import { spawnSync } from "child_process";
|
|
34724
34800
|
import { readFileSync as readFileSync4, readlinkSync, unwatchFile, watchFile } from "fs";
|
|
34725
|
-
import { mkdir as mkdir3, readFile as
|
|
34801
|
+
import { mkdir as mkdir3, readFile as readFile8, rename as rename4, utimes as utimes3, writeFile as writeFile2 } from "fs/promises";
|
|
34726
34802
|
import { homedir as homedir3 } from "os";
|
|
34727
|
-
import { basename as basename4, dirname as dirname5, join as
|
|
34803
|
+
import { basename as basename4, dirname as dirname5, join as join10 } from "path";
|
|
34728
34804
|
|
|
34729
34805
|
// src/session-identity.ts
|
|
34730
|
-
import { readFile as
|
|
34731
|
-
import { basename as basename3, join as
|
|
34806
|
+
import { readFile as readFile7 } from "fs/promises";
|
|
34807
|
+
import { basename as basename3, join as join9 } from "path";
|
|
34732
34808
|
|
|
34733
34809
|
// src/session-state.ts
|
|
34734
34810
|
import { readFileSync as readFileSync3 } from "fs";
|
|
34735
34811
|
import { mkdir as mkdir2, readdir as readdir3, rename as rename3, rm as rm4, stat as stat4, utimes as utimes2, writeFile } from "fs/promises";
|
|
34736
|
-
import { dirname as dirname4, join as
|
|
34812
|
+
import { dirname as dirname4, join as join8 } from "path";
|
|
34737
34813
|
async function writeAtomicStateFile(file, contents) {
|
|
34738
34814
|
await mkdir2(dirname4(file), { recursive: true, mode: 448 });
|
|
34739
34815
|
const temporary = `${file}.${process.pid}.${crypto.randomUUID()}.tmp`;
|
|
@@ -34751,7 +34827,7 @@ async function pruneStateDirectory(directory, isStale) {
|
|
|
34751
34827
|
throw error;
|
|
34752
34828
|
});
|
|
34753
34829
|
for (const entry of entries) {
|
|
34754
|
-
const file =
|
|
34830
|
+
const file = join8(directory, entry);
|
|
34755
34831
|
if (!await isStale(file))
|
|
34756
34832
|
continue;
|
|
34757
34833
|
await rm4(file, { recursive: true, force: true });
|
|
@@ -34766,7 +34842,7 @@ async function writtenLongAgo(file) {
|
|
|
34766
34842
|
}
|
|
34767
34843
|
var TITLES_DIRECTORY = "titles";
|
|
34768
34844
|
function sessionTitleFile(stateDirectory, sessionId) {
|
|
34769
|
-
return
|
|
34845
|
+
return join8(stateDirectory, TITLES_DIRECTORY, `${encodeURIComponent(sessionId)}.txt`);
|
|
34770
34846
|
}
|
|
34771
34847
|
async function writeChosenTitle(file, title) {
|
|
34772
34848
|
await writeAtomicStateFile(file, `${title}
|
|
@@ -34794,7 +34870,7 @@ async function recordChosenTitle(sessionId, title) {
|
|
|
34794
34870
|
await writeChosenTitle(file, chosen);
|
|
34795
34871
|
}
|
|
34796
34872
|
async function pruneStaleSessionTitles(stateDirectory) {
|
|
34797
|
-
await pruneStateDirectory(
|
|
34873
|
+
await pruneStateDirectory(join8(stateDirectory, TITLES_DIRECTORY), writtenLongAgo);
|
|
34798
34874
|
}
|
|
34799
34875
|
|
|
34800
34876
|
// src/session-identity.ts
|
|
@@ -34819,14 +34895,14 @@ class SessionIdentity {
|
|
|
34819
34895
|
}
|
|
34820
34896
|
}
|
|
34821
34897
|
function sessionHandoffDirectory(stateDirectory, claudePid) {
|
|
34822
|
-
return
|
|
34898
|
+
return join9(stateDirectory, "sessions", String(claudePid));
|
|
34823
34899
|
}
|
|
34824
34900
|
function sessionHandoffFile(stateDirectory, claudePid) {
|
|
34825
|
-
return
|
|
34901
|
+
return join9(sessionHandoffDirectory(stateDirectory, claudePid), "session-id");
|
|
34826
34902
|
}
|
|
34827
34903
|
var ROLES_DIRECTORY = "roles";
|
|
34828
34904
|
function roleStateFile(stateDirectory, sessionId) {
|
|
34829
|
-
return
|
|
34905
|
+
return join9(stateDirectory, ROLES_DIRECTORY, `${encodeURIComponent(sessionId)}.json`);
|
|
34830
34906
|
}
|
|
34831
34907
|
|
|
34832
34908
|
class UnparseableRoleRecordError extends Error {
|
|
@@ -34838,7 +34914,7 @@ class UnparseableRoleRecordError extends Error {
|
|
|
34838
34914
|
async function readPersistedRole(roleFile) {
|
|
34839
34915
|
let bytes;
|
|
34840
34916
|
try {
|
|
34841
|
-
bytes = await
|
|
34917
|
+
bytes = await readFile7(roleFile, "utf8");
|
|
34842
34918
|
} catch (error) {
|
|
34843
34919
|
if (hasErrnoCode(error, "ENOENT"))
|
|
34844
34920
|
return;
|
|
@@ -34860,7 +34936,7 @@ async function writeSessionHandoff(file, sessionId) {
|
|
|
34860
34936
|
}
|
|
34861
34937
|
async function readSessionHandoff(file) {
|
|
34862
34938
|
try {
|
|
34863
|
-
const id = (await
|
|
34939
|
+
const id = (await readFile7(file, "utf8")).trim();
|
|
34864
34940
|
return id.length === 0 ? undefined : id;
|
|
34865
34941
|
} catch (error) {
|
|
34866
34942
|
if (hasErrnoCode(error, "ENOENT"))
|
|
@@ -34877,14 +34953,14 @@ function processExists(pid) {
|
|
|
34877
34953
|
}
|
|
34878
34954
|
}
|
|
34879
34955
|
async function pruneStaleSessionHandoffs(stateDirectory) {
|
|
34880
|
-
await pruneStateDirectory(
|
|
34956
|
+
await pruneStateDirectory(join9(stateDirectory, "sessions"), (file) => {
|
|
34881
34957
|
const pid = basename3(file);
|
|
34882
34958
|
return /^\d+$/.test(pid) && !processExists(Number(pid));
|
|
34883
34959
|
});
|
|
34884
34960
|
}
|
|
34885
34961
|
async function pruneStaleSessionRoles(stateDirectory, currentSessionId) {
|
|
34886
34962
|
const own = roleStateFile(stateDirectory, currentSessionId);
|
|
34887
|
-
await pruneStateDirectory(
|
|
34963
|
+
await pruneStateDirectory(join9(stateDirectory, ROLES_DIRECTORY), async (file) => file !== own && await writtenLongAgo(file));
|
|
34888
34964
|
}
|
|
34889
34965
|
|
|
34890
34966
|
// src/codex/codex-session-record.ts
|
|
@@ -34898,10 +34974,10 @@ var CodexSessionRecord = object({
|
|
|
34898
34974
|
codex_started: string2().nullable().default(null)
|
|
34899
34975
|
});
|
|
34900
34976
|
function codexSessionRecordFile(stateDirectory, pid) {
|
|
34901
|
-
return
|
|
34977
|
+
return join10(stateDirectory, "codex-sessions", `${pid}.json`);
|
|
34902
34978
|
}
|
|
34903
34979
|
function codexEndedFile(stateDirectory, pid, sessionId) {
|
|
34904
|
-
return
|
|
34980
|
+
return join10(stateDirectory, "codex-sessions", `${pid}.${encodeURIComponent(sessionId)}.ended`);
|
|
34905
34981
|
}
|
|
34906
34982
|
async function markSessionEnded(stateDirectory, pid, sessionId) {
|
|
34907
34983
|
const marker = codexEndedFile(stateDirectory, pid, sessionId);
|
|
@@ -34924,7 +35000,7 @@ function watchRecord(file, pid, ended, changed, intervalMs) {
|
|
|
34924
35000
|
}
|
|
34925
35001
|
async function sessionEnded(file) {
|
|
34926
35002
|
try {
|
|
34927
|
-
await
|
|
35003
|
+
await readFile8(file);
|
|
34928
35004
|
return true;
|
|
34929
35005
|
} catch {
|
|
34930
35006
|
return false;
|
|
@@ -34938,7 +35014,7 @@ async function writeCodexSessionRecord(file, value) {
|
|
|
34938
35014
|
}
|
|
34939
35015
|
async function readCodexSessionRecord(file) {
|
|
34940
35016
|
try {
|
|
34941
|
-
const parsed = CodexSessionRecord.safeParse(JSON.parse(await
|
|
35017
|
+
const parsed = CodexSessionRecord.safeParse(JSON.parse(await readFile8(file, "utf8")));
|
|
34942
35018
|
return parsed.success ? parsed.data : undefined;
|
|
34943
35019
|
} catch {
|
|
34944
35020
|
return;
|
|
@@ -34946,7 +35022,7 @@ async function readCodexSessionRecord(file) {
|
|
|
34946
35022
|
}
|
|
34947
35023
|
function codexHome(env) {
|
|
34948
35024
|
const set = env["CODEX_HOME"];
|
|
34949
|
-
return set !== undefined && set !== "" ? set :
|
|
35025
|
+
return set !== undefined && set !== "" ? set : join10(env["HOME"] || homedir3(), ".codex");
|
|
34950
35026
|
}
|
|
34951
35027
|
function codexPluginDataDirectory(pluginRoot) {
|
|
34952
35028
|
const version = pluginRoot;
|
|
@@ -34956,7 +35032,7 @@ function codexPluginDataDirectory(pluginRoot) {
|
|
|
34956
35032
|
const plugins = dirname5(cache);
|
|
34957
35033
|
if (basename4(cache) !== "cache" || basename4(plugins) !== "plugins")
|
|
34958
35034
|
return;
|
|
34959
|
-
return
|
|
35035
|
+
return join10(plugins, "data", `${basename4(plugin)}-${basename4(marketplace)}`);
|
|
34960
35036
|
}
|
|
34961
35037
|
var MAX_ANCESTORS = 16;
|
|
34962
35038
|
function codexProcessId(readComm = procComm, readParent = procParent) {
|
|
@@ -35058,11 +35134,11 @@ function codexSubcommand(args) {
|
|
|
35058
35134
|
}
|
|
35059
35135
|
var SHARED_APP_SERVER_NOTE = "Codex runs this session in its shared app server (`codex app-server`), which runs several sessions in one process, so the Envoy plugin does not register it with Envoy: it receives no Envoy messages and does not show on Dispatch's Agents page. Its `dispatch` tool works, acting as this session.";
|
|
35060
35136
|
async function pruneCodexSessionRecords(stateDirectory) {
|
|
35061
|
-
await pruneStateDirectory(
|
|
35137
|
+
await pruneStateDirectory(join10(stateDirectory, "codex-sessions"), (file) => {
|
|
35062
35138
|
const match = /^(\d+)\.(?:json|.+\.ended)$/.exec(basename4(file));
|
|
35063
35139
|
return match !== null && !processExists(Number(match[1]));
|
|
35064
35140
|
});
|
|
35065
|
-
await pruneStateDirectory(
|
|
35141
|
+
await pruneStateDirectory(join10(stateDirectory, "codex-servers"), (file) => {
|
|
35066
35142
|
const name = basename4(file);
|
|
35067
35143
|
return /^\d+$/.test(name) && !processExists(Number(name));
|
|
35068
35144
|
});
|