@sjawhar/claude-envoy 5.10.2 → 5.11.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 +1 -1
- package/dist/dispatch.js +1 -1
- package/dist/envoy-channel.js +104 -77
- package/dist/session-hook.js +1 -1
- package/legion/agents/thermonuclear-code-quality.md +1 -0
- package/legion/agents/thermonuclear-deep-review.md +1 -0
- package/legion/skills/legion-architect/SKILL.md +1 -1
- package/legion/skills/legion-architect/references/acceptance.md +1 -2
- package/legion/skills/legion-architect/references/decomposition.md +4 -4
- package/legion/skills/legion-architect/references/design-gate.md +5 -3
- package/legion/skills/legion-architect/references/wake-routing.md +4 -4
- package/legion/skills/legion-controller/references/admission.md +3 -3
- package/legion/skills/legion-controller/references/consolidation.md +1 -1
- package/legion/skills/legion-controller/references/daily-report.md +1 -1
- package/legion/skills/legion-controller/references/finding-asks.md +2 -2
- package/legion/skills/legion-controller/references/parked-decisions.md +2 -2
- package/legion/skills/legion-controller/references/wakes.md +3 -3
- package/legion/skills/legion-oracle/SKILL.md +1 -3
- package/legion/skills/legion-retro/SKILL.md +3 -3
- package/legion/skills/legion-worker/SKILL.md +6 -8
- package/legion/skills/legion-worker/references/conflicts-and-rewrites.md +2 -2
- package/legion/skills/legion-worker/references/pr-body.md +1 -1
- package/package.json +1 -1
- package/skills/agent-secrets/SKILL.md +4 -4
- package/skills/envoy/references/check-settlement.md +2 -1
- package/skills/envoy/references/legion.md +1 -1
- package/skills/envoy/references/roles.md +1 -1
- package/skills/thermonuclear-code-quality/SKILL.md +0 -2
- package/skills/thermonuclear-deep-review/SKILL.md +0 -2
- package/src/codex/codex-server.ts +6 -2
- package/src/envoy-channel-server.ts +6 -2
- package/src/installed-build.ts +22 -1
- package/legion/skills/legion-worker/references/default-branch-check.md +0 -31
- package/legion/skills/legion-worker/references/foreign-path.md +0 -19
package/dist/envoy-channel.js
CHANGED
|
@@ -23780,7 +23780,7 @@ function scrubProcessStreams() {
|
|
|
23780
23780
|
import { spawn as spawn2 } from "child_process";
|
|
23781
23781
|
import { unwatchFile as unwatchFile3, watchFile as watchFile3 } from "fs";
|
|
23782
23782
|
import { homedir as homedir4 } from "os";
|
|
23783
|
-
import { join as
|
|
23783
|
+
import { join as join21, resolve as resolve3 } from "path";
|
|
23784
23784
|
// ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/core.js
|
|
23785
23785
|
var NEVER = Object.freeze({
|
|
23786
23786
|
status: "aborted"
|
|
@@ -37499,7 +37499,7 @@ var dispatchToolSpecs = [
|
|
|
37499
37499
|
verdict: "pass",
|
|
37500
37500
|
commit: "1111111111111111111111111111111111111111"
|
|
37501
37501
|
},
|
|
37502
|
-
description: "Record one result of one check of an issue's Verification document, or retract a result " + "recorded before. A record prints the pull-request body line it implies. Write that line " + "into the pull-request body unchanged: it is the one grammar every writer uses, and it " + "carries no link to Dispatch, no private host and no issue key: Dispatch keeps only words " + "of letters, digits and plain punctuation, and of those leaves out every word that holds " + "`://`, a private or Dispatch host, or an issue key of one of its projects; the record keeps " + "the whole reading. --dry-run prints the line the record would print, and records nothing. " + "Name the check by its block id. Where two Verification documents in reach hold that id, " + "name it by its canonical reference (dispatch://KEY/artifact/verification-md#b-<id>). " + "409 CHECK_AMBIGUOUS names both documents. An id no Verification document of the issue " + "or of an issue above it holds is 400 UNKNOWN_CHECK. " + `${CHECK_PROVED_BY_CI}. ` + "Dispatch reads its result from that run, so a record for it is 409 " + "CHECK_PROVED_BY_CI from every role, which names the check and the run. " + "A pass that counts a failed, a skipped or an excluded case contradicts itself, and is " + "400 RESULT_CONTRADICTS. " + "Dispatch asks GitHub whether the repository of the check's issue holds the commit. If " + "GitHub does not say that it does, Dispatch reads the external links of the check's issue: " + "a link to a GitHub pull request (https://github.com/<owner>/<repo>/pull/<n>) that is open " + "or merged, in a repository that Dispatch's GitHub App is installed on and can read, adds " + "the repository of that pull request. One record reads at most 10 linked pull requests. A " + "commit that none of these repositories holds is 400 RESULT_COMMIT_UNKNOWN, which names the " + "commit and each owner/repo that Dispatch asked. It also names, with its reason " + "(owner/repo#n (repository_unreadable)), each linked pull request that Dispatch could not " + "read, at most 10 and a count of the rest, and every linked pull request in whose " + "repository it could not read the commit, since each of those spent one of the record's 10 " + "reads, and says to grant Dispatch's GitHub App that repository or to link a readable pull " + "request. It says how many linked pull requests it left unread past that bound. Record the " + "result after the commit is pushed. A linked repository that the App is not installed on " + "or cannot read does " + "not count. Where a read of " + "a linked pull request or of a linked repository does not answer, and no repository is shown " + "to hold the commit, the record is 502 GITHUB_UNREADABLE and nothing is recorded: record the " + "result again, after the wait the refusal names for a rate limit. Where the issue has no " + "repository, the result is recorded as before. Where Dispatch cannot read the repository " + "of the check's issue, the result is recorded as before only when every linked read " + "answers and no linked repository holds the commit: a linked read that does not answer " + "is 502 GITHUB_UNREADABLE and nothing is recorded. " + "The result is recorded against the check's own issue, so a child's run of a parent's " + "check appears under that check. A closed issue takes a result only for a check whose " + "when is after_merge or default_branch, the production check after the merge. It refuses " + "every other record with 409 ISSUE_CLOSED
|
|
37502
|
+
description: "Record one result of one check of an issue's Verification document, or retract a result " + "recorded before. A record prints the pull-request body line it implies. Write that line " + "into the pull-request body unchanged: it is the one grammar every writer uses, and it " + "carries no link to Dispatch, no private host and no issue key: Dispatch keeps only words " + "of letters, digits and plain punctuation, and of those leaves out every word that holds " + "`://`, a private or Dispatch host, or an issue key of one of its projects; the record keeps " + "the whole reading. --dry-run prints the line the record would print, and records nothing. " + "Name the check by its block id. Where two Verification documents in reach hold that id, " + "name it by its canonical reference (dispatch://KEY/artifact/verification-md#b-<id>). " + "409 CHECK_AMBIGUOUS names both documents. An id no Verification document of the issue " + "or of an issue above it holds is 400 UNKNOWN_CHECK. " + `${CHECK_PROVED_BY_CI}. ` + "Dispatch reads its result from that run, so a record for it is 409 " + "CHECK_PROVED_BY_CI from every role, which names the check and the run. " + "A pass that counts a failed, a skipped or an excluded case contradicts itself, and is " + "400 RESULT_CONTRADICTS. " + "Dispatch asks GitHub whether the repository of the check's issue holds the commit. If " + "GitHub does not say that it does, Dispatch reads the external links of the check's issue: " + "a link to a GitHub pull request (https://github.com/<owner>/<repo>/pull/<n>) that is open " + "or merged, in a repository that Dispatch's GitHub App is installed on and can read, adds " + "the repository of that pull request. One record reads at most 10 linked pull requests. A " + "commit that none of these repositories holds is 400 RESULT_COMMIT_UNKNOWN, which names the " + "commit and each owner/repo that Dispatch asked. It also names, with its reason " + "(owner/repo#n (repository_unreadable)), each linked pull request that Dispatch could not " + "read, at most 10 and a count of the rest, and every linked pull request in whose " + "repository it could not read the commit, since each of those spent one of the record's 10 " + "reads, and says to grant Dispatch's GitHub App that repository or to link a readable pull " + "request. It says how many linked pull requests it left unread past that bound. Record the " + "result after the commit is pushed. A linked repository that the App is not installed on " + "or cannot read does " + "not count. Where a read of " + "a linked pull request or of a linked repository does not answer, and no repository is shown " + "to hold the commit, the record is 502 GITHUB_UNREADABLE and nothing is recorded: record the " + "result again, after the wait the refusal names for a rate limit. Where the issue has no " + "repository, the result is recorded as before. Where Dispatch cannot read the repository " + "of the check's issue, the result is recorded as before only when every linked read " + "answers and no linked repository holds the commit: a linked read that does not answer " + "is 502 GITHUB_UNREADABLE and nothing is recorded. " + "The result is recorded against the check's own issue, so a child's run of a parent's " + "check appears under that check. A closed issue takes a result only for a check whose " + "when is after_merge or default_branch, the production check after the merge. It refuses " + "every other record with 409 ISSUE_CLOSED. " + "A check a document version rewords while the result is being written is 409 " + "CHECK_CONTENDED, with nothing recorded: run the same command again. " + RESULT_RETRACT_RULE + " The retraction keeps both records: the result stays readable, and it proves nothing " + "from then on. Record a new result where the check still needs one. A retraction is " + "taken on a closed issue and for a check of any when. Three callers may retract: the " + "session that recorded the result, a session that holds the Dispatch claim of the issue " + "the result was recorded on, and a caller whose credential carries a person. Every other " + "caller is 403 RETRACTION_FORBIDDEN. A result retracted already is 409 RESULT_RETRACTED. " + ISSUE_REFERENCE,
|
|
37503
37503
|
arguments: (z) => ({
|
|
37504
37504
|
issue: z.string().describe(ISSUE_REFERENCE).optional(),
|
|
37505
37505
|
check: z.string().describe("The check block's id, or its canonical reference dispatch://KEY/artifact/verification-md#b-<id> when the id is not unique among the issue's Verification document and those of the issues above it.").optional(),
|
|
@@ -60356,6 +60356,7 @@ function inboundUnavailable(tell, restored) {
|
|
|
60356
60356
|
var import_nats2 = __toESM(require_mod4(), 1);
|
|
60357
60357
|
var import_nats3 = __toESM(require_nats(), 1);
|
|
60358
60358
|
var import_servers = __toESM(require_servers(), 1);
|
|
60359
|
+
import { readFileSync as readFileSync6 } from "fs";
|
|
60359
60360
|
import { setTimeout as delay } from "timers/promises";
|
|
60360
60361
|
|
|
60361
60362
|
// ../envoy-client/src/nats-auth.ts
|
|
@@ -60388,6 +60389,23 @@ function natsAuthOptions(credential) {
|
|
|
60388
60389
|
var NATS_PING_INTERVAL_MS = 1e4;
|
|
60389
60390
|
var NATS_MAX_PINGS_OUT = 2;
|
|
60390
60391
|
var NATS_DIAL_TIMEOUT_MS = 1e4;
|
|
60392
|
+
var FULL_COMMIT = /^[0-9a-f]{40}$/;
|
|
60393
|
+
var RELEASE_VERSION = /^\d+\.\d+\.\d+$/;
|
|
60394
|
+
function clientBuild(stampFile, release) {
|
|
60395
|
+
let stamp = "";
|
|
60396
|
+
try {
|
|
60397
|
+
stamp = readFileSync6(stampFile, "utf8").trim();
|
|
60398
|
+
} catch {}
|
|
60399
|
+
if (FULL_COMMIT.test(stamp))
|
|
60400
|
+
return `legion@${stamp}`;
|
|
60401
|
+
if (release !== undefined && RELEASE_VERSION.test(release.version)) {
|
|
60402
|
+
return `${release.name}@${release.version}`;
|
|
60403
|
+
}
|
|
60404
|
+
return;
|
|
60405
|
+
}
|
|
60406
|
+
function clientConnectionName(name, build) {
|
|
60407
|
+
return build === undefined ? name : `${name} ${build}`;
|
|
60408
|
+
}
|
|
60391
60409
|
function natsConnectionOptions(input) {
|
|
60392
60410
|
return {
|
|
60393
60411
|
servers: [...input.servers],
|
|
@@ -62129,7 +62147,7 @@ var import_nats5 = __toESM(require_mod4(), 1);
|
|
|
62129
62147
|
|
|
62130
62148
|
// package.json
|
|
62131
62149
|
var name2 = "@sjawhar/claude-envoy";
|
|
62132
|
-
var version2 = "5.
|
|
62150
|
+
var version2 = "5.11.0";
|
|
62133
62151
|
var legion = {
|
|
62134
62152
|
daemonApiVersion: 217
|
|
62135
62153
|
};
|
|
@@ -63333,7 +63351,7 @@ import { readFile as readFile4 } from "fs/promises";
|
|
|
63333
63351
|
import { basename as basename3, join as join10 } from "path";
|
|
63334
63352
|
|
|
63335
63353
|
// src/session-state.ts
|
|
63336
|
-
import { readFileSync as
|
|
63354
|
+
import { readFileSync as readFileSync7 } from "fs";
|
|
63337
63355
|
import { mkdir as mkdir2, readdir as readdir3, rename as rename3, rm as rm3, stat as stat3, utimes as utimes2, writeFile } from "fs/promises";
|
|
63338
63356
|
import { dirname as dirname4, join as join9 } from "path";
|
|
63339
63357
|
async function writeAtomicStateFile(file, contents) {
|
|
@@ -63379,7 +63397,7 @@ async function removeChosenTitle(file) {
|
|
|
63379
63397
|
}
|
|
63380
63398
|
function readChosenTitleSync(file) {
|
|
63381
63399
|
try {
|
|
63382
|
-
return
|
|
63400
|
+
return readFileSync7(file, "utf8");
|
|
63383
63401
|
} catch {
|
|
63384
63402
|
return;
|
|
63385
63403
|
}
|
|
@@ -63544,7 +63562,7 @@ async function serveEnvoyOff(serverInfo, refusal) {
|
|
|
63544
63562
|
}
|
|
63545
63563
|
|
|
63546
63564
|
// src/installed-build.ts
|
|
63547
|
-
import { sep } from "path";
|
|
63565
|
+
import { dirname as dirname5, join as join11, sep } from "path";
|
|
63548
63566
|
function pluginCacheSegments(bundlePath) {
|
|
63549
63567
|
const parts = bundlePath.split(sep);
|
|
63550
63568
|
for (let index = 0;index + 1 < parts.length; index++) {
|
|
@@ -63556,10 +63574,14 @@ function pluginCacheSegments(bundlePath) {
|
|
|
63556
63574
|
function installedPluginVersion(bundlePath) {
|
|
63557
63575
|
return pluginCacheSegments(bundlePath)?.[2];
|
|
63558
63576
|
}
|
|
63577
|
+
function channelConnectionName(name, bundlePath, packageName) {
|
|
63578
|
+
const version = installedPluginVersion(bundlePath);
|
|
63579
|
+
return clientConnectionName(name, clientBuild(join11(dirname5(bundlePath), "build-commit"), version === undefined ? undefined : { name: packageName, version }));
|
|
63580
|
+
}
|
|
63559
63581
|
|
|
63560
63582
|
// src/legion-claim.ts
|
|
63561
63583
|
import { readdir as readdir4, stat as stat4 } from "fs/promises";
|
|
63562
|
-
import { join as
|
|
63584
|
+
import { join as join13 } from "path";
|
|
63563
63585
|
import { setTimeout as delay2 } from "timers/promises";
|
|
63564
63586
|
|
|
63565
63587
|
// ../pi-shared/src/stall-limits.ts
|
|
@@ -64470,6 +64492,9 @@ var LEGION_ANSWER_READS = {
|
|
|
64470
64492
|
"admission",
|
|
64471
64493
|
"admission.blocked[].issue",
|
|
64472
64494
|
"admission.blocked[].blockedBy",
|
|
64495
|
+
"admission.held[].issue",
|
|
64496
|
+
"admission.held[].reason",
|
|
64497
|
+
"admission.held[].heldBy",
|
|
64473
64498
|
"capabilities",
|
|
64474
64499
|
"capabilities[].name",
|
|
64475
64500
|
"capabilities[].status",
|
|
@@ -64489,6 +64514,7 @@ var LEGION_ANSWER_READS = {
|
|
|
64489
64514
|
"paused.waitsOn[].issue",
|
|
64490
64515
|
"paused.waitsOn[].role",
|
|
64491
64516
|
"paused.held",
|
|
64517
|
+
"paused.held[].issue",
|
|
64492
64518
|
"lastPause",
|
|
64493
64519
|
"lastPause.id",
|
|
64494
64520
|
"lastPause.since",
|
|
@@ -64533,6 +64559,7 @@ var LEGION_ANSWER_READS = {
|
|
|
64533
64559
|
"holds",
|
|
64534
64560
|
"holds[].reason"
|
|
64535
64561
|
],
|
|
64562
|
+
LegionWaveReleaseResponse: ["held[].issue"],
|
|
64536
64563
|
LegionProjectPauseResponse: [
|
|
64537
64564
|
"pause.by|0.kind",
|
|
64538
64565
|
"pause.by|1.kind",
|
|
@@ -64935,8 +64962,8 @@ function listenerAskedToClaimAgain(error) {
|
|
|
64935
64962
|
|
|
64936
64963
|
// src/legion-phase-hook.ts
|
|
64937
64964
|
import { randomUUID as randomUUID7 } from "crypto";
|
|
64938
|
-
import { readFileSync as
|
|
64939
|
-
import { dirname as
|
|
64965
|
+
import { readFileSync as readFileSync8, renameSync as renameSync3, rmSync as rmSync5, writeFileSync as writeFileSync4 } from "fs";
|
|
64966
|
+
import { dirname as dirname6, join as join12 } from "path";
|
|
64940
64967
|
|
|
64941
64968
|
// ../pi-shared/src/phase-reminder.ts
|
|
64942
64969
|
import { randomUUID as randomUUID6 } from "crypto";
|
|
@@ -65392,7 +65419,7 @@ function phaseHookToolDefinition() {
|
|
|
65392
65419
|
};
|
|
65393
65420
|
}
|
|
65394
65421
|
function phaseStallFile(configDir, sessionID) {
|
|
65395
|
-
return
|
|
65422
|
+
return join12(configDir, `legion-phase-stall-${sessionID}.json`);
|
|
65396
65423
|
}
|
|
65397
65424
|
function paneReminderLog(write) {
|
|
65398
65425
|
const line = (level, message, context) => {
|
|
@@ -65407,7 +65434,7 @@ var NO_RECORD = { entry: undefined, recreatedNoticeSent: false };
|
|
|
65407
65434
|
function readPhaseStallRecord(file, log) {
|
|
65408
65435
|
let raw;
|
|
65409
65436
|
try {
|
|
65410
|
-
raw =
|
|
65437
|
+
raw = readFileSync8(file, "utf8");
|
|
65411
65438
|
} catch (error) {
|
|
65412
65439
|
const missing = typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
65413
65440
|
if (!missing) {
|
|
@@ -65445,7 +65472,7 @@ function readPhaseStallRecord(file, log) {
|
|
|
65445
65472
|
};
|
|
65446
65473
|
}
|
|
65447
65474
|
function writePhaseStallRecord(file, entry, recreatedNoticeSent, log) {
|
|
65448
|
-
const temporary =
|
|
65475
|
+
const temporary = join12(dirname6(file), `.legion-phase-stall-${randomUUID7()}`);
|
|
65449
65476
|
try {
|
|
65450
65477
|
writeFileSync4(temporary, JSON.stringify({ ...entry, ...recreatedNoticeSent ? { recreatedNoticeSent } : {} }), { mode: 384 });
|
|
65451
65478
|
renameSync3(temporary, file);
|
|
@@ -65653,12 +65680,12 @@ function stopPane(why) {
|
|
|
65653
65680
|
endPane();
|
|
65654
65681
|
}
|
|
65655
65682
|
async function waitForTranscript(configDir, sessionID, signal, pollMs = 100) {
|
|
65656
|
-
const projects =
|
|
65683
|
+
const projects = join13(configDir, "projects");
|
|
65657
65684
|
const name = `${sessionID}.jsonl`;
|
|
65658
65685
|
for (;; ) {
|
|
65659
65686
|
signal.throwIfAborted();
|
|
65660
65687
|
for (const directory of await readdir4(projects).catch(() => [])) {
|
|
65661
|
-
const file =
|
|
65688
|
+
const file = join13(projects, directory, name);
|
|
65662
65689
|
if (await isFile(file))
|
|
65663
65690
|
return file;
|
|
65664
65691
|
}
|
|
@@ -65928,7 +65955,7 @@ function phaseOpParameters(zod) {
|
|
|
65928
65955
|
var PHASE_OP_SENTENCES = {
|
|
65929
65956
|
readRecord: "read_record returns the record of `issue` from the daemon's record route for that issue, your own issue when you leave `issue` out. " + "A held issue names in `heldFrom` the phase the hold took it out of. A failed claim carries `failure`: the " + "`cause` word for what failed it, the `detail` sentence beside that word, `at`, when it failed, and " + "`attempts`, the four counts it failed with. A todo written on a held root releases the hold and starts " + "that phase again, as the architect's retry_or_escalate with retry does. ",
|
|
65930
65957
|
readReleaseRecords: "read_release_records returns this deployment's idle-release records from `since` (an RFC 3339 time) on, read with this session's own claim: " + "every release, resume and hold the daemon recorded, and over them the counts of releases, of the releases among them that suspended no " + "role, of resumes by wake kind and of holds by reason, the pod-hours released, the share of releases woken again within ten minutes, and " + "the median, 90th percentile and maximum seconds from a wake to the woken role's first turn. A wake that a project pause held is " + "counted as `heldByPause` and left out of those seconds, since its wait measures the pause. A release that suspended no role is woken by " + "nothing, so the pod-hours released and the woken share count the releases that suspended a role alone. ",
|
|
65931
|
-
requestBackwardMove: "request_backward_move returns an issue to an earlier phase (`to`, `reason`). A phase worker moves its own issue. " + "The architect that owns an issue in accepting moves it, named by `issue`, back to planning, implementing or testing. That move counts
|
|
65958
|
+
requestBackwardMove: "request_backward_move returns an issue to an earlier phase (`to`, `reason`). A phase worker moves its own issue. " + "The architect that owns an issue in accepting moves it, named by `issue`, back to planning, implementing or testing. That move counts no review round. ",
|
|
65932
65959
|
readBuild: "read_build reports the build this process runs: the plugin package and version the process loaded, and the contract that build speaks. " + "It also reports the contract the daemon states on its answer to the health route. " + "That contract is null where the daemon stated none, where the daemon refused the health route and where no answer reached this process at all, and a note of its own says which. " + "The two numbers can differ, and the answer shows both. " + "Report the version this call answers, never the one at the plugin's path on the image. " + "In a pod, an Oh My Pi role relaunched onto the daemon's contract loads the build that relaunch installed under the role's own state home, " + "and a Claude Code role installs no plugin: it loads its pod image's own claude-envoy. " + "read_build reads no project state. "
|
|
65933
65960
|
};
|
|
65934
65961
|
var STALE_ENTRY_INSTRUCTION = "End this turn without completing. The task of the entry the phase is on is owed to this claim, and the daemon sends it by itself. " + "That task is work of its own: do what it asks at the head it names and complete it with a handoff of its own, never this completion's " + "record, commit or verdict";
|
|
@@ -66235,7 +66262,7 @@ import {
|
|
|
66235
66262
|
createServer,
|
|
66236
66263
|
request as httpRequest
|
|
66237
66264
|
} from "http";
|
|
66238
|
-
import { dirname as
|
|
66265
|
+
import { dirname as dirname7 } from "path";
|
|
66239
66266
|
|
|
66240
66267
|
// hooks/mod-protocol.ts
|
|
66241
66268
|
var MOD_HEALTH_MARKER = "claude-envoy-mod";
|
|
@@ -66457,7 +66484,7 @@ async function privateDirectory(path) {
|
|
|
66457
66484
|
}
|
|
66458
66485
|
}
|
|
66459
66486
|
async function bind(server, socketPath) {
|
|
66460
|
-
await privateDirectory(
|
|
66487
|
+
await privateDirectory(dirname7(socketPath));
|
|
66461
66488
|
if (await exists(socketPath)) {
|
|
66462
66489
|
if (await probeHealth(socketPath, MOD_PROBE_TIMEOUT_MS)) {
|
|
66463
66490
|
throw new Error(`another claude-envoy server already serves this session at ${socketPath}`);
|
|
@@ -66848,7 +66875,7 @@ function modSession(options) {
|
|
|
66848
66875
|
}
|
|
66849
66876
|
|
|
66850
66877
|
// src/replay-state.ts
|
|
66851
|
-
import { join as
|
|
66878
|
+
import { join as join14 } from "path";
|
|
66852
66879
|
|
|
66853
66880
|
// src/state-file.ts
|
|
66854
66881
|
import { readFile as readFile5 } from "fs/promises";
|
|
@@ -66878,7 +66905,7 @@ var ReplayStateFileSchema = LedgerSnapshotSchema.extend({
|
|
|
66878
66905
|
consumer: ConsumerDeliverySnapshotSchema.optional()
|
|
66879
66906
|
});
|
|
66880
66907
|
function replayStateFile(stateDirectory, sessionId) {
|
|
66881
|
-
return
|
|
66908
|
+
return join14(stateDirectory, `replay-${encodeURIComponent(sessionId)}.json`);
|
|
66882
66909
|
}
|
|
66883
66910
|
async function readReplayState(file) {
|
|
66884
66911
|
return await readStateFile(file, ReplayStateFileSchema, { ledger: [] }, "holds no delivery state");
|
|
@@ -66910,12 +66937,12 @@ import { basename as basename4 } from "path";
|
|
|
66910
66937
|
|
|
66911
66938
|
// ../envoy-client/src/process-ancestry.ts
|
|
66912
66939
|
import { execFileSync } from "child_process";
|
|
66913
|
-
import { readFileSync as
|
|
66940
|
+
import { readFileSync as readFileSync9 } from "fs";
|
|
66914
66941
|
var MAX_ANCESTORS = 64;
|
|
66915
66942
|
var PARENT_LOOKUP_MS = 1000;
|
|
66916
66943
|
function procParentPid(pid) {
|
|
66917
66944
|
try {
|
|
66918
|
-
const stat =
|
|
66945
|
+
const stat = readFileSync9(`/proc/${pid}/stat`, "utf8");
|
|
66919
66946
|
const parent = Number(stat.slice(stat.lastIndexOf(")") + 2).split(" ")[1]);
|
|
66920
66947
|
return Number.isInteger(parent) ? parent : undefined;
|
|
66921
66948
|
} catch {
|
|
@@ -66957,7 +66984,7 @@ function isAncestor(candidate, pid = process.pid) {
|
|
|
66957
66984
|
}
|
|
66958
66985
|
function procCommand(pid) {
|
|
66959
66986
|
try {
|
|
66960
|
-
return
|
|
66987
|
+
return readFileSync9(`/proc/${pid}/comm`, "utf8").trim();
|
|
66961
66988
|
} catch {
|
|
66962
66989
|
return;
|
|
66963
66990
|
}
|
|
@@ -67393,7 +67420,7 @@ function createUserTurnRouter(options) {
|
|
|
67393
67420
|
}
|
|
67394
67421
|
|
|
67395
67422
|
// src/user-turn-state.ts
|
|
67396
|
-
import { join as
|
|
67423
|
+
import { join as join15 } from "path";
|
|
67397
67424
|
var TURNS_DIRECTORY = "turns";
|
|
67398
67425
|
var HANDLED_ATTEMPTS_MAX = 1000;
|
|
67399
67426
|
var DELIVERED_ROWS_MAX = 1000;
|
|
@@ -67403,7 +67430,7 @@ var UserTurnStateSchema = object({
|
|
|
67403
67430
|
rows: array(DeliveredRowSchema).default([])
|
|
67404
67431
|
});
|
|
67405
67432
|
function userTurnStateFile(stateDirectory, sessionId) {
|
|
67406
|
-
return
|
|
67433
|
+
return join15(stateDirectory, TURNS_DIRECTORY, `${encodeURIComponent(sessionId)}.json`);
|
|
67407
67434
|
}
|
|
67408
67435
|
async function readUserTurnState(file) {
|
|
67409
67436
|
return await readStateFile(file, UserTurnStateSchema, { handled: [], rows: [] }, "holds no record of this session's turns");
|
|
@@ -67441,7 +67468,7 @@ function userTurnState(file, restored) {
|
|
|
67441
67468
|
};
|
|
67442
67469
|
}
|
|
67443
67470
|
async function pruneStaleSessionTurns(stateDirectory) {
|
|
67444
|
-
await pruneStateDirectory(
|
|
67471
|
+
await pruneStateDirectory(join15(stateDirectory, TURNS_DIRECTORY), writtenLongAgo);
|
|
67445
67472
|
}
|
|
67446
67473
|
|
|
67447
67474
|
// src/envoy-channel-server.ts
|
|
@@ -68870,7 +68897,7 @@ async function runEnvoyChannelServer() {
|
|
|
68870
68897
|
session = inboundOffChannelSession({ identity, stateDirectory, why: inbound.off });
|
|
68871
68898
|
} else {
|
|
68872
68899
|
starting = "relaySetting" in inbound ? "it opens the listener's relay socket for this session, and its stderr says why an open failed" : inbound.natsCredential.kind === "broker" ? "it waits for this session's broker token, and its stderr says what each trade came to" : "it connects to NATS";
|
|
68873
|
-
const natsName = `claude-envoy-channel-${identity.id}
|
|
68900
|
+
const natsName = channelConnectionName(`claude-envoy-channel-${identity.id}`, bundlePath, name2);
|
|
68874
68901
|
const dialled = await dialChannelInbound(inbound, envoy.url, currentSessionId, natsName, (text, dialError) => {
|
|
68875
68902
|
if (dialError !== undefined)
|
|
68876
68903
|
starting = text;
|
|
@@ -69160,10 +69187,10 @@ function startCodexAgentStream(options) {
|
|
|
69160
69187
|
// src/codex/codex-cli.ts
|
|
69161
69188
|
import { spawn } from "child_process";
|
|
69162
69189
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
69163
|
-
import { mkdirSync as mkdirSync4, readFileSync as
|
|
69164
|
-
import { join as
|
|
69190
|
+
import { mkdirSync as mkdirSync4, readFileSync as readFileSync10, writeFileSync as writeFileSync5 } from "fs";
|
|
69191
|
+
import { join as join16 } from "path";
|
|
69165
69192
|
var QUEUE_TIMEOUT_MS = 30000;
|
|
69166
|
-
function codexProcessEnv(pid, fallback, read = (path) =>
|
|
69193
|
+
function codexProcessEnv(pid, fallback, read = (path) => readFileSync10(path, "utf8")) {
|
|
69167
69194
|
let raw;
|
|
69168
69195
|
try {
|
|
69169
69196
|
raw = read(`/proc/${pid}/environ`);
|
|
@@ -69230,7 +69257,7 @@ function fitArgument(text, spillDirectory) {
|
|
|
69230
69257
|
throw new Error(`the message is ${Buffer.byteLength(text)} bytes, over what codex queue takes`);
|
|
69231
69258
|
}
|
|
69232
69259
|
mkdirSync4(spillDirectory, { mode: 448, recursive: true });
|
|
69233
|
-
const file =
|
|
69260
|
+
const file = join16(spillDirectory, `${Date.now()}-${randomBytes2(4).toString("hex")}.txt`);
|
|
69234
69261
|
writeFileSync5(file, text, { mode: 384 });
|
|
69235
69262
|
return `${text.slice(0, QUEUE_HEAD_CHARS)}
|
|
69236
69263
|
|
|
@@ -69356,10 +69383,10 @@ function askSideQuestion(command, threadId, question, timeoutMs = SIDE_QUESTION_
|
|
|
69356
69383
|
// src/codex/codex-inbox.ts
|
|
69357
69384
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
69358
69385
|
import { mkdir as mkdir4, readdir as readdir5, readFile as readFile6, rename as rename4, rm as rm5, writeFile as writeFile2 } from "fs/promises";
|
|
69359
|
-
import { join as
|
|
69386
|
+
import { join as join17 } from "path";
|
|
69360
69387
|
var TAKEN_DIRECTORY = { hook: "taken", server: "queued" };
|
|
69361
69388
|
function codexInboxDirectory(stateDirectory, sessionId) {
|
|
69362
|
-
return
|
|
69389
|
+
return join17(stateDirectory, "codex-inbox", encodeURIComponent(sessionId));
|
|
69363
69390
|
}
|
|
69364
69391
|
var lastOrder = 0;
|
|
69365
69392
|
function inboxItemName() {
|
|
@@ -69368,17 +69395,17 @@ function inboxItemName() {
|
|
|
69368
69395
|
return `${String(order).padStart(15, "0")}-${randomBytes3(4).toString("hex")}.json`;
|
|
69369
69396
|
}
|
|
69370
69397
|
async function putInbox(directory, item, name = inboxItemName()) {
|
|
69371
|
-
const waiting =
|
|
69398
|
+
const waiting = join17(directory, "waiting");
|
|
69372
69399
|
await mkdir4(waiting, { recursive: true, mode: 448 });
|
|
69373
|
-
const temporary =
|
|
69400
|
+
const temporary = join17(directory, `.${name}.tmp`);
|
|
69374
69401
|
await writeFile2(temporary, JSON.stringify(item), { mode: 384 });
|
|
69375
|
-
await rename4(temporary,
|
|
69402
|
+
await rename4(temporary, join17(waiting, name));
|
|
69376
69403
|
return name;
|
|
69377
69404
|
}
|
|
69378
69405
|
async function takenBy(directory, name) {
|
|
69379
69406
|
for (const taker of ["hook", "server"]) {
|
|
69380
69407
|
try {
|
|
69381
|
-
await readFile6(
|
|
69408
|
+
await readFile6(join17(directory, TAKEN_DIRECTORY[taker], name));
|
|
69382
69409
|
return taker;
|
|
69383
69410
|
} catch {}
|
|
69384
69411
|
}
|
|
@@ -69386,14 +69413,14 @@ async function takenBy(directory, name) {
|
|
|
69386
69413
|
}
|
|
69387
69414
|
async function withdrawWaiting(directory, name) {
|
|
69388
69415
|
try {
|
|
69389
|
-
await rm5(
|
|
69416
|
+
await rm5(join17(directory, "waiting", name));
|
|
69390
69417
|
return true;
|
|
69391
69418
|
} catch {
|
|
69392
69419
|
return false;
|
|
69393
69420
|
}
|
|
69394
69421
|
}
|
|
69395
69422
|
async function discardWaiting(directory, keep = () => false) {
|
|
69396
|
-
const waiting =
|
|
69423
|
+
const waiting = join17(directory, "waiting");
|
|
69397
69424
|
let names;
|
|
69398
69425
|
try {
|
|
69399
69426
|
names = await readdir5(waiting);
|
|
@@ -69405,7 +69432,7 @@ async function discardWaiting(directory, keep = () => false) {
|
|
|
69405
69432
|
if (!name.endsWith(".json") || keep(name))
|
|
69406
69433
|
continue;
|
|
69407
69434
|
try {
|
|
69408
|
-
await rm5(
|
|
69435
|
+
await rm5(join17(waiting, name));
|
|
69409
69436
|
removed++;
|
|
69410
69437
|
} catch {}
|
|
69411
69438
|
}
|
|
@@ -69413,7 +69440,7 @@ async function discardWaiting(directory, keep = () => false) {
|
|
|
69413
69440
|
}
|
|
69414
69441
|
var HOOK_CONTEXT_MAX_BYTES = 8000;
|
|
69415
69442
|
async function takeInbox(directory, taker, maxContextBytes) {
|
|
69416
|
-
const waiting =
|
|
69443
|
+
const waiting = join17(directory, "waiting");
|
|
69417
69444
|
let names;
|
|
69418
69445
|
try {
|
|
69419
69446
|
names = (await readdir5(waiting)).filter((name) => name.endsWith(".json")).sort();
|
|
@@ -69422,14 +69449,14 @@ async function takeInbox(directory, taker, maxContextBytes) {
|
|
|
69422
69449
|
}
|
|
69423
69450
|
if (names.length === 0)
|
|
69424
69451
|
return [];
|
|
69425
|
-
const destination =
|
|
69452
|
+
const destination = join17(directory, TAKEN_DIRECTORY[taker]);
|
|
69426
69453
|
await mkdir4(destination, { recursive: true, mode: 448 });
|
|
69427
69454
|
const taken = [];
|
|
69428
69455
|
for (const name of names) {
|
|
69429
69456
|
if (maxContextBytes !== undefined) {
|
|
69430
69457
|
let waitingItem;
|
|
69431
69458
|
try {
|
|
69432
|
-
waitingItem = JSON.parse(await readFile6(
|
|
69459
|
+
waitingItem = JSON.parse(await readFile6(join17(waiting, name), "utf8"));
|
|
69433
69460
|
} catch {
|
|
69434
69461
|
continue;
|
|
69435
69462
|
}
|
|
@@ -69440,12 +69467,12 @@ async function takeInbox(directory, taker, maxContextBytes) {
|
|
|
69440
69467
|
break;
|
|
69441
69468
|
}
|
|
69442
69469
|
try {
|
|
69443
|
-
await rename4(
|
|
69470
|
+
await rename4(join17(waiting, name), join17(destination, name));
|
|
69444
69471
|
} catch {
|
|
69445
69472
|
continue;
|
|
69446
69473
|
}
|
|
69447
69474
|
try {
|
|
69448
|
-
const parsed = JSON.parse(await readFile6(
|
|
69475
|
+
const parsed = JSON.parse(await readFile6(join17(destination, name), "utf8"));
|
|
69449
69476
|
if (typeof parsed === "object" && parsed !== null && typeof parsed.content === "string") {
|
|
69450
69477
|
taken.push({ item: parsed, name });
|
|
69451
69478
|
}
|
|
@@ -69603,14 +69630,14 @@ function createCodexDelivery(options) {
|
|
|
69603
69630
|
|
|
69604
69631
|
// src/codex/codex-owner.ts
|
|
69605
69632
|
import { link as link2, mkdir as mkdir6, readdir as readdir6, readFile as readFile8, rm as rm6, stat as stat6, writeFile as writeFile4 } from "fs/promises";
|
|
69606
|
-
import { join as
|
|
69633
|
+
import { join as join19 } from "path";
|
|
69607
69634
|
|
|
69608
69635
|
// src/codex/codex-session-record.ts
|
|
69609
69636
|
import { spawnSync } from "child_process";
|
|
69610
|
-
import { readFileSync as
|
|
69637
|
+
import { readFileSync as readFileSync11, readlinkSync as readlinkSync3, unwatchFile as unwatchFile2, watchFile as watchFile2 } from "fs";
|
|
69611
69638
|
import { mkdir as mkdir5, readFile as readFile7, rename as rename5, utimes as utimes3, writeFile as writeFile3 } from "fs/promises";
|
|
69612
69639
|
import { homedir as homedir3 } from "os";
|
|
69613
|
-
import { basename as basename5, dirname as
|
|
69640
|
+
import { basename as basename5, dirname as dirname8, join as join18 } from "path";
|
|
69614
69641
|
var CodexSessionRecord = object({
|
|
69615
69642
|
session_id: string2().min(1),
|
|
69616
69643
|
transcript_path: string2().nullable(),
|
|
@@ -69621,14 +69648,14 @@ var CodexSessionRecord = object({
|
|
|
69621
69648
|
codex_started: string2().nullable().default(null)
|
|
69622
69649
|
});
|
|
69623
69650
|
function codexSessionRecordFile(stateDirectory, pid) {
|
|
69624
|
-
return
|
|
69651
|
+
return join18(stateDirectory, "codex-sessions", `${pid}.json`);
|
|
69625
69652
|
}
|
|
69626
69653
|
function codexEndedFile(stateDirectory, pid, sessionId) {
|
|
69627
|
-
return
|
|
69654
|
+
return join18(stateDirectory, "codex-sessions", `${pid}.${encodeURIComponent(sessionId)}.ended`);
|
|
69628
69655
|
}
|
|
69629
69656
|
async function markSessionEnded(stateDirectory, pid, sessionId) {
|
|
69630
69657
|
const marker = codexEndedFile(stateDirectory, pid, sessionId);
|
|
69631
|
-
await mkdir5(
|
|
69658
|
+
await mkdir5(dirname8(marker), { mode: 448, recursive: true });
|
|
69632
69659
|
await writeFile3(marker, "", { mode: 384 });
|
|
69633
69660
|
const now = new Date;
|
|
69634
69661
|
await utimes3(codexSessionRecordFile(stateDirectory, pid), now, now);
|
|
@@ -69654,7 +69681,7 @@ async function sessionEnded(file) {
|
|
|
69654
69681
|
}
|
|
69655
69682
|
}
|
|
69656
69683
|
async function writeCodexSessionRecord(file, value) {
|
|
69657
|
-
await mkdir5(
|
|
69684
|
+
await mkdir5(dirname8(file), { recursive: true, mode: 448 });
|
|
69658
69685
|
const temporary = `${file}.${process.pid}.tmp`;
|
|
69659
69686
|
await writeFile3(temporary, JSON.stringify(value), { mode: 384 });
|
|
69660
69687
|
await rename5(temporary, file);
|
|
@@ -69669,17 +69696,17 @@ async function readCodexSessionRecord(file) {
|
|
|
69669
69696
|
}
|
|
69670
69697
|
function codexHome(env) {
|
|
69671
69698
|
const set = env["CODEX_HOME"];
|
|
69672
|
-
return set !== undefined && set !== "" ? set :
|
|
69699
|
+
return set !== undefined && set !== "" ? set : join18(env["HOME"] || homedir3(), ".codex");
|
|
69673
69700
|
}
|
|
69674
69701
|
function codexPluginDataDirectory(pluginRoot) {
|
|
69675
69702
|
const version = pluginRoot;
|
|
69676
|
-
const plugin =
|
|
69677
|
-
const marketplace =
|
|
69678
|
-
const cache =
|
|
69679
|
-
const plugins =
|
|
69703
|
+
const plugin = dirname8(version);
|
|
69704
|
+
const marketplace = dirname8(plugin);
|
|
69705
|
+
const cache = dirname8(marketplace);
|
|
69706
|
+
const plugins = dirname8(cache);
|
|
69680
69707
|
if (basename5(cache) !== "cache" || basename5(plugins) !== "plugins")
|
|
69681
69708
|
return;
|
|
69682
|
-
return
|
|
69709
|
+
return join18(plugins, "data", `${basename5(plugin)}-${basename5(marketplace)}`);
|
|
69683
69710
|
}
|
|
69684
69711
|
var MAX_ANCESTORS2 = 16;
|
|
69685
69712
|
function codexProcessId(readComm = procComm, readParent = procParent) {
|
|
@@ -69693,14 +69720,14 @@ function codexProcessId(readComm = procComm, readParent = procParent) {
|
|
|
69693
69720
|
}
|
|
69694
69721
|
function procComm(pid) {
|
|
69695
69722
|
try {
|
|
69696
|
-
return
|
|
69723
|
+
return readFileSync11(`/proc/${pid}/comm`, "utf8").trim();
|
|
69697
69724
|
} catch {
|
|
69698
69725
|
return;
|
|
69699
69726
|
}
|
|
69700
69727
|
}
|
|
69701
69728
|
function procParent(pid) {
|
|
69702
69729
|
try {
|
|
69703
|
-
const stat =
|
|
69730
|
+
const stat = readFileSync11(`/proc/${pid}/stat`, "utf8");
|
|
69704
69731
|
const parent = Number(stat.slice(stat.lastIndexOf(")") + 2).split(" ")[1]);
|
|
69705
69732
|
return Number.isInteger(parent) ? parent : undefined;
|
|
69706
69733
|
} catch {
|
|
@@ -69714,7 +69741,7 @@ var PS_OPTIONS = {
|
|
|
69714
69741
|
};
|
|
69715
69742
|
function procStarted(pid) {
|
|
69716
69743
|
try {
|
|
69717
|
-
const stat =
|
|
69744
|
+
const stat = readFileSync11(`/proc/${pid}/stat`, "utf8");
|
|
69718
69745
|
return stat.slice(stat.lastIndexOf(")") + 2).split(" ")[19];
|
|
69719
69746
|
} catch {
|
|
69720
69747
|
return;
|
|
@@ -69735,7 +69762,7 @@ function recordOfProcess(record, pid) {
|
|
|
69735
69762
|
function sharedAppServer(pid) {
|
|
69736
69763
|
let argv;
|
|
69737
69764
|
try {
|
|
69738
|
-
argv =
|
|
69765
|
+
argv = readFileSync11(`/proc/${pid}/cmdline`, "utf8").split("\x00");
|
|
69739
69766
|
} catch {
|
|
69740
69767
|
const ps = spawnSync("ps", ["-o", "args=", "-p", String(pid)], PS_OPTIONS);
|
|
69741
69768
|
if (ps.status !== 0)
|
|
@@ -69781,11 +69808,11 @@ function codexSubcommand(args) {
|
|
|
69781
69808
|
}
|
|
69782
69809
|
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.";
|
|
69783
69810
|
async function pruneCodexSessionRecords(stateDirectory) {
|
|
69784
|
-
await pruneStateDirectory(
|
|
69811
|
+
await pruneStateDirectory(join18(stateDirectory, "codex-sessions"), (file) => {
|
|
69785
69812
|
const match = /^(\d+)\.(?:json|.+\.ended)$/.exec(basename5(file));
|
|
69786
69813
|
return match !== null && !processExists(Number(match[1]));
|
|
69787
69814
|
});
|
|
69788
|
-
await pruneStateDirectory(
|
|
69815
|
+
await pruneStateDirectory(join18(stateDirectory, "codex-servers"), (file) => {
|
|
69789
69816
|
const name = basename5(file);
|
|
69790
69817
|
return /^\d+$/.test(name) && !processExists(Number(name));
|
|
69791
69818
|
});
|
|
@@ -69800,7 +69827,7 @@ function codexExecutable(pid) {
|
|
|
69800
69827
|
|
|
69801
69828
|
// src/codex/codex-owner.ts
|
|
69802
69829
|
function codexServersDirectory(stateDirectory, codexPid) {
|
|
69803
|
-
return
|
|
69830
|
+
return join19(stateDirectory, "codex-servers", String(codexPid));
|
|
69804
69831
|
}
|
|
69805
69832
|
var ENTRY_NAME = /^(\d+)\.json$/;
|
|
69806
69833
|
var TEMPORARY_NAME = /^\.\d+\.\d+\.tmp$/;
|
|
@@ -69809,13 +69836,13 @@ function entryName(entry) {
|
|
|
69809
69836
|
}
|
|
69810
69837
|
async function registerServer(directory, pid, started, list = (path) => readdir6(path)) {
|
|
69811
69838
|
await mkdir6(directory, { mode: 448, recursive: true });
|
|
69812
|
-
const temporary =
|
|
69839
|
+
const temporary = join19(directory, `.${pid}.${process.hrtime.bigint()}.tmp`);
|
|
69813
69840
|
await writeFile4(temporary, JSON.stringify({ pid, started }), { mode: 384 });
|
|
69814
69841
|
try {
|
|
69815
69842
|
let seq = Math.max(0, ...numbered(await list(directory)).map(({ seq: taken }) => taken)) + 1;
|
|
69816
69843
|
for (;; ) {
|
|
69817
69844
|
try {
|
|
69818
|
-
await place(temporary,
|
|
69845
|
+
await place(temporary, join19(directory, entryName({ seq })), pid, started);
|
|
69819
69846
|
return { pid, seq, started };
|
|
69820
69847
|
} catch (error) {
|
|
69821
69848
|
if (error.code !== "EEXIST")
|
|
@@ -69843,7 +69870,7 @@ async function place(temporary, target, pid, started) {
|
|
|
69843
69870
|
await writeFile4(target, JSON.stringify({ pid, started }), { flag: "wx", mode: 384 });
|
|
69844
69871
|
}
|
|
69845
69872
|
async function unregisterServer(directory, self2) {
|
|
69846
|
-
const file =
|
|
69873
|
+
const file = join19(directory, entryName(self2));
|
|
69847
69874
|
const named = await readFile8(file, "utf8").then(serverOf, () => {
|
|
69848
69875
|
return;
|
|
69849
69876
|
});
|
|
@@ -69907,7 +69934,7 @@ async function readEntries(directory, probe, now = Date.now) {
|
|
|
69907
69934
|
for (const name of names.filter((each) => TEMPORARY_NAME.test(each))) {
|
|
69908
69935
|
let text;
|
|
69909
69936
|
try {
|
|
69910
|
-
text = await readFile8(
|
|
69937
|
+
text = await readFile8(join19(directory, name), "utf8");
|
|
69911
69938
|
} catch {
|
|
69912
69939
|
publishing = true;
|
|
69913
69940
|
break;
|
|
@@ -69923,13 +69950,13 @@ async function readEntries(directory, probe, now = Date.now) {
|
|
|
69923
69950
|
for (const { name, seq } of numbered(names)) {
|
|
69924
69951
|
let text;
|
|
69925
69952
|
try {
|
|
69926
|
-
text = await readFile8(
|
|
69953
|
+
text = await readFile8(join19(directory, name), "utf8");
|
|
69927
69954
|
} catch {
|
|
69928
69955
|
continue;
|
|
69929
69956
|
}
|
|
69930
69957
|
const server = serverOf(text);
|
|
69931
69958
|
if (server === undefined) {
|
|
69932
|
-
const written = await stat6(
|
|
69959
|
+
const written = await stat6(join19(directory, name)).then((info) => info.mtimeMs, () => {
|
|
69933
69960
|
return;
|
|
69934
69961
|
});
|
|
69935
69962
|
if (written === undefined)
|
|
@@ -69957,7 +69984,7 @@ async function currentOwner(directory, probe = SYSTEM_PROBE) {
|
|
|
69957
69984
|
const text = seen.held.get(seq);
|
|
69958
69985
|
if (text === undefined)
|
|
69959
69986
|
return;
|
|
69960
|
-
const now = await readFile8(
|
|
69987
|
+
const now = await readFile8(join19(directory, entryName({ seq })), "utf8").catch(() => {
|
|
69961
69988
|
return;
|
|
69962
69989
|
});
|
|
69963
69990
|
if (now !== text)
|
|
@@ -70018,7 +70045,7 @@ async function stillOwner(directory, self2, probe = SYSTEM_PROBE) {
|
|
|
70018
70045
|
// src/codex/codex-transcript.ts
|
|
70019
70046
|
import { watch } from "fs";
|
|
70020
70047
|
import { open as open3 } from "fs/promises";
|
|
70021
|
-
import { join as
|
|
70048
|
+
import { join as join20 } from "path";
|
|
70022
70049
|
function record3(value) {
|
|
70023
70050
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : undefined;
|
|
70024
70051
|
}
|
|
@@ -70288,7 +70315,7 @@ async function findTranscript(home, threadId) {
|
|
|
70288
70315
|
const glob = new Bun.Glob(`**/rollout-*-${threadId}.jsonl`);
|
|
70289
70316
|
const found = [];
|
|
70290
70317
|
try {
|
|
70291
|
-
for await (const file of glob.scan({ absolute: true, cwd:
|
|
70318
|
+
for await (const file of glob.scan({ absolute: true, cwd: join20(home, "sessions") })) {
|
|
70292
70319
|
found.push(file);
|
|
70293
70320
|
}
|
|
70294
70321
|
} catch {
|
|
@@ -70433,7 +70460,7 @@ function runDispatchCommand(script, args, stdin, options) {
|
|
|
70433
70460
|
});
|
|
70434
70461
|
}
|
|
70435
70462
|
function stateDirectoryFor(pluginRoot) {
|
|
70436
|
-
return configuredValue(process.env["PLUGIN_DATA"]) ?? codexPluginDataDirectory(pluginRoot) ??
|
|
70463
|
+
return configuredValue(process.env["PLUGIN_DATA"]) ?? codexPluginDataDirectory(pluginRoot) ?? join21(configuredValue(process.env["XDG_STATE_HOME"]) ?? join21(homedir4(), ".local", "state"), "claude-envoy", "codex");
|
|
70437
70464
|
}
|
|
70438
70465
|
function waitForRecord(file, pid, signal, ended) {
|
|
70439
70466
|
return new Promise((done) => {
|
|
@@ -70521,7 +70548,7 @@ async function runCodexEnvoyServer() {
|
|
|
70521
70548
|
env["DISPATCH_HOST"] = "codex";
|
|
70522
70549
|
if (configFile.path !== null)
|
|
70523
70550
|
env["ENVOY_CONFIG_FILE"] = configFile.path;
|
|
70524
|
-
const { code, output } = await runDispatchCommand(
|
|
70551
|
+
const { code, output } = await runDispatchCommand(join21(pluginRoot, "dist", "dispatch.js"), parsed.data.args, parsed.data.stdin ?? "", { cwd: await latestTurnCwd(transcript) ?? own?.cwd ?? current?.cwd ?? homedir4(), env });
|
|
70525
70552
|
return `${output}${output.endsWith(`
|
|
70526
70553
|
`) || output === "" ? "" : `
|
|
70527
70554
|
`}[exit ${code}]`;
|
|
@@ -70661,7 +70688,7 @@ async function runCodexEnvoyServer() {
|
|
|
70661
70688
|
const runningSession = () => record?.session_id ?? bound.session_id;
|
|
70662
70689
|
const codexDelivery = createCodexDelivery({
|
|
70663
70690
|
inboxDirectory: (sessionId) => codexInboxDirectory(stateDirectory, sessionId),
|
|
70664
|
-
queue: (text) => queueMessage(command(), runningSession(), text,
|
|
70691
|
+
queue: (text) => queueMessage(command(), runningSession(), text, join21(stateDirectory, "codex-long-messages")),
|
|
70665
70692
|
sessionId: runningSession,
|
|
70666
70693
|
taken: (item) => stream?.delivered(item.content, item.dispatchMessageId),
|
|
70667
70694
|
warn
|
|
@@ -70695,7 +70722,7 @@ async function runCodexEnvoyServer() {
|
|
|
70695
70722
|
if ("off" in inbound) {
|
|
70696
70723
|
session = inboundOffChannelSession({ identity: id, stateDirectory, why: inbound.off });
|
|
70697
70724
|
} else {
|
|
70698
|
-
const natsName = `codex-envoy-channel-${id.id}
|
|
70725
|
+
const natsName = channelConnectionName(`codex-envoy-channel-${id.id}`, bundlePath, name);
|
|
70699
70726
|
const dialled = await dialChannelInbound(inbound, envoy.url, () => id.id, natsName, warn, import_nats6.connect, stopping.signal).catch((error) => {
|
|
70700
70727
|
if (isStopping)
|
|
70701
70728
|
return;
|