@sjawhar/claude-envoy 5.10.3 → 5.11.1
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 +98 -76
- package/dist/session-hook.js +1 -1
- package/package.json +1 -1
- package/src/codex/codex-server.ts +6 -2
- package/src/envoy-channel-server.ts +6 -2
- package/src/installed-build.ts +22 -1
package/.omp-plugin/plugin.json
CHANGED
package/dist/codex-hook.js
CHANGED
|
@@ -14726,7 +14726,7 @@ var dispatchToolSpecs = [
|
|
|
14726
14726
|
{
|
|
14727
14727
|
name: "dispatch_results",
|
|
14728
14728
|
example: { issue: "DSP-1" },
|
|
14729
|
-
description: "Print each check of an issue's Verification document with every result recorded against " + "it, newest first. " + "Each check prints what Dispatch compared its results with. A before_merge check is " + "compared with the head of each pull request Dispatch holds for the check's issue, open " + "or merged. An after_merge check is compared with the branch that issue's pull request " + "merged into and with the repository's default branch, and with the default branch alone " + "where Dispatch holds no merge of the issue. A default_branch check is compared with the " + "repository's default branch alone, whatever branch the pull request merged into. Where " + "a check compared with nothing, it says which of three things happened: the issue has no " + "pull request and no branch to compare with, Dispatch cannot read the repository, or a " + "read Dispatch made did not answer. " + "Each check then prints one line that answers the gate: whether a pass of it stands, and " + "from which roles. A pass stands when its commit is one of the commits the check " + "compared with, the check's words did not move after the result was recorded, and no " + "retraction stands against it. " + "The check's own words print once, under the check. Each result then prints its verdict, " + "its role, its whole 40-character commit, where that commit stands, whether the check's " + "words moved after it was recorded, the time, its id, and the reading the role recorded. " + "A result nobody gave a reading says so. A retracted result prints as retracted, with " + "the reason and the caller that retracted it. A check with no result says so. " + `${CHECK_PROVED_BY_CI}: ` + "no role records its result, and Dispatch reads it from GitHub at the head of the " + "issue's open pull request of the highest number, else at the head of its merged one of " + "the highest number. Its one result prints as `- <id> (before_merge): <verdict> at " + "<commit> by ci (CI run <name>, <conclusion>), <where that commit stands>. <the check's " + "words>`, then the `A pass stands:` line a recorded check prints, then `Pull request line:` " + "and the line to write into the pull-request body unchanged, then the reading: the " + "conclusion, the run's output title and summary, and its URL. A run that proves nothing " + "prints `- <id> (before_merge): no result:`, the sentence that names why, and the check's " + "words, then the `A pass stands:` line, then `Pull request line:` and `- Check <id> " + "(before_merge): CI run <name> has no result (<case>)`. That is a run that has not " + "concluded, one that concluded neutral, skipped or cancelled, one absent at the head, an " + "issue with no pull request head, or GitHub not read, with what GitHub answered. " + "A push that moves a pull request's head leaves a result at the commit before it, with " + "no write of anyone's: record the check again at the new head. A check CI proves is read " + "again at the new head by itself. " + ISSUE_REFERENCE,
|
|
14729
|
+
description: "Print each check of an issue's Verification document with every result recorded against " + "it, newest first. " + "Each check prints what Dispatch compared its results with. A before_merge check is " + "compared with the head of each pull request Dispatch holds for the check's issue, open " + "or merged. An after_merge check is compared with the branch that issue's pull request " + "merged into and with the repository's default branch, and with the default branch alone " + "where Dispatch holds no merge of the issue. A default_branch check is compared with the " + "repository's default branch alone, whatever branch the pull request merged into. Where " + "a check compared with nothing, it says which of three things happened: the issue has no " + "pull request and no branch to compare with, Dispatch cannot read the repository, or a " + "read Dispatch made did not answer. " + "Each check then prints one line that answers the gate: whether a pass of it stands, and " + "from which roles. A pass stands when its commit is one of the commits the check " + "compared with, the check's words did not move after the result was recorded, and no " + "retraction stands against it. " + "The check's own words print once, under the check. Each result then prints its verdict, " + "its role, its whole 40-character commit, where that commit stands, whether the check's " + "words moved after it was recorded, the time, its id, and the reading the role recorded. " + "A result nobody gave a reading says so. A retracted result prints as retracted, with " + "the reason and the caller that retracted it. A check with no result says so. " + `${CHECK_PROVED_BY_CI}: ` + "no role records its result, and Dispatch reads it from GitHub at the head of the " + "issue's open pull request of the highest number, else at the head of its merged one of " + "the highest number. Its one result prints as `- <id> (before_merge): <verdict> at " + "<commit> by ci (CI run <name>, <conclusion>), <where that commit stands>. <the check's " + "words>`, then the `A pass stands:` line a recorded check prints, then `Pull request line:` " + "and the line to write into the pull-request body unchanged, then the reading: the " + "conclusion, the run's output title and summary, and its URL. A run that proves nothing " + "prints `- <id> (before_merge): no result:`, the sentence that names why, and the check's " + "words, then the `A pass stands:` line, then `Pull request line:` and `- Check <id> " + "(before_merge): CI run <name> has no result (<case>)`. That is a run that has not " + "concluded, one that concluded neutral, skipped or cancelled, one absent at the head, an " + "issue with no pull request head, or GitHub not read, with what GitHub answered. " + "A pull-request line writes `CI run <name>` only when it keeps every word of the name, " + "and `the CI run the check names` in its place where it drops one: a word the line drops, " + "such as an issue key or a word holding `_`. " + "A push that moves a pull request's head leaves a result at the commit before it, with " + "no write of anyone's: record the check again at the new head. A check CI proves is read " + "again at the new head by itself. " + ISSUE_REFERENCE,
|
|
14730
14730
|
arguments: (z) => ({
|
|
14731
14731
|
issue: z.string().describe(ISSUE_REFERENCE),
|
|
14732
14732
|
at: z.string().describe("One commit of 40 lowercase hex characters. It becomes the only thing every check is compared with. Dispatch reads GitHub for none of it, except the check runs of a check CI proves, which it reads at the issue's newest pull request head as on every read, so that check's result stands at this commit only where it is that head.").optional(),
|
package/dist/dispatch.js
CHANGED
|
@@ -15326,7 +15326,7 @@ var dispatchToolSpecs = [
|
|
|
15326
15326
|
{
|
|
15327
15327
|
name: "dispatch_results",
|
|
15328
15328
|
example: { issue: "DSP-1" },
|
|
15329
|
-
description: "Print each check of an issue's Verification document with every result recorded against " + "it, newest first. " + "Each check prints what Dispatch compared its results with. A before_merge check is " + "compared with the head of each pull request Dispatch holds for the check's issue, open " + "or merged. An after_merge check is compared with the branch that issue's pull request " + "merged into and with the repository's default branch, and with the default branch alone " + "where Dispatch holds no merge of the issue. A default_branch check is compared with the " + "repository's default branch alone, whatever branch the pull request merged into. Where " + "a check compared with nothing, it says which of three things happened: the issue has no " + "pull request and no branch to compare with, Dispatch cannot read the repository, or a " + "read Dispatch made did not answer. " + "Each check then prints one line that answers the gate: whether a pass of it stands, and " + "from which roles. A pass stands when its commit is one of the commits the check " + "compared with, the check's words did not move after the result was recorded, and no " + "retraction stands against it. " + "The check's own words print once, under the check. Each result then prints its verdict, " + "its role, its whole 40-character commit, where that commit stands, whether the check's " + "words moved after it was recorded, the time, its id, and the reading the role recorded. " + "A result nobody gave a reading says so. A retracted result prints as retracted, with " + "the reason and the caller that retracted it. A check with no result says so. " + `${CHECK_PROVED_BY_CI}: ` + "no role records its result, and Dispatch reads it from GitHub at the head of the " + "issue's open pull request of the highest number, else at the head of its merged one of " + "the highest number. Its one result prints as `- <id> (before_merge): <verdict> at " + "<commit> by ci (CI run <name>, <conclusion>), <where that commit stands>. <the check's " + "words>`, then the `A pass stands:` line a recorded check prints, then `Pull request line:` " + "and the line to write into the pull-request body unchanged, then the reading: the " + "conclusion, the run's output title and summary, and its URL. A run that proves nothing " + "prints `- <id> (before_merge): no result:`, the sentence that names why, and the check's " + "words, then the `A pass stands:` line, then `Pull request line:` and `- Check <id> " + "(before_merge): CI run <name> has no result (<case>)`. That is a run that has not " + "concluded, one that concluded neutral, skipped or cancelled, one absent at the head, an " + "issue with no pull request head, or GitHub not read, with what GitHub answered. " + "A push that moves a pull request's head leaves a result at the commit before it, with " + "no write of anyone's: record the check again at the new head. A check CI proves is read " + "again at the new head by itself. " + ISSUE_REFERENCE,
|
|
15329
|
+
description: "Print each check of an issue's Verification document with every result recorded against " + "it, newest first. " + "Each check prints what Dispatch compared its results with. A before_merge check is " + "compared with the head of each pull request Dispatch holds for the check's issue, open " + "or merged. An after_merge check is compared with the branch that issue's pull request " + "merged into and with the repository's default branch, and with the default branch alone " + "where Dispatch holds no merge of the issue. A default_branch check is compared with the " + "repository's default branch alone, whatever branch the pull request merged into. Where " + "a check compared with nothing, it says which of three things happened: the issue has no " + "pull request and no branch to compare with, Dispatch cannot read the repository, or a " + "read Dispatch made did not answer. " + "Each check then prints one line that answers the gate: whether a pass of it stands, and " + "from which roles. A pass stands when its commit is one of the commits the check " + "compared with, the check's words did not move after the result was recorded, and no " + "retraction stands against it. " + "The check's own words print once, under the check. Each result then prints its verdict, " + "its role, its whole 40-character commit, where that commit stands, whether the check's " + "words moved after it was recorded, the time, its id, and the reading the role recorded. " + "A result nobody gave a reading says so. A retracted result prints as retracted, with " + "the reason and the caller that retracted it. A check with no result says so. " + `${CHECK_PROVED_BY_CI}: ` + "no role records its result, and Dispatch reads it from GitHub at the head of the " + "issue's open pull request of the highest number, else at the head of its merged one of " + "the highest number. Its one result prints as `- <id> (before_merge): <verdict> at " + "<commit> by ci (CI run <name>, <conclusion>), <where that commit stands>. <the check's " + "words>`, then the `A pass stands:` line a recorded check prints, then `Pull request line:` " + "and the line to write into the pull-request body unchanged, then the reading: the " + "conclusion, the run's output title and summary, and its URL. A run that proves nothing " + "prints `- <id> (before_merge): no result:`, the sentence that names why, and the check's " + "words, then the `A pass stands:` line, then `Pull request line:` and `- Check <id> " + "(before_merge): CI run <name> has no result (<case>)`. That is a run that has not " + "concluded, one that concluded neutral, skipped or cancelled, one absent at the head, an " + "issue with no pull request head, or GitHub not read, with what GitHub answered. " + "A pull-request line writes `CI run <name>` only when it keeps every word of the name, " + "and `the CI run the check names` in its place where it drops one: a word the line drops, " + "such as an issue key or a word holding `_`. " + "A push that moves a pull request's head leaves a result at the commit before it, with " + "no write of anyone's: record the check again at the new head. A check CI proves is read " + "again at the new head by itself. " + ISSUE_REFERENCE,
|
|
15330
15330
|
arguments: (z) => ({
|
|
15331
15331
|
issue: z.string().describe(ISSUE_REFERENCE),
|
|
15332
15332
|
at: z.string().describe("One commit of 40 lowercase hex characters. It becomes the only thing every check is compared with. Dispatch reads GitHub for none of it, except the check runs of a check CI proves, which it reads at the issue's newest pull request head as on every read, so that check's result stands at this commit only where it is that head.").optional(),
|
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"
|
|
@@ -37526,7 +37526,7 @@ var dispatchToolSpecs = [
|
|
|
37526
37526
|
{
|
|
37527
37527
|
name: "dispatch_results",
|
|
37528
37528
|
example: { issue: "DSP-1" },
|
|
37529
|
-
description: "Print each check of an issue's Verification document with every result recorded against " + "it, newest first. " + "Each check prints what Dispatch compared its results with. A before_merge check is " + "compared with the head of each pull request Dispatch holds for the check's issue, open " + "or merged. An after_merge check is compared with the branch that issue's pull request " + "merged into and with the repository's default branch, and with the default branch alone " + "where Dispatch holds no merge of the issue. A default_branch check is compared with the " + "repository's default branch alone, whatever branch the pull request merged into. Where " + "a check compared with nothing, it says which of three things happened: the issue has no " + "pull request and no branch to compare with, Dispatch cannot read the repository, or a " + "read Dispatch made did not answer. " + "Each check then prints one line that answers the gate: whether a pass of it stands, and " + "from which roles. A pass stands when its commit is one of the commits the check " + "compared with, the check's words did not move after the result was recorded, and no " + "retraction stands against it. " + "The check's own words print once, under the check. Each result then prints its verdict, " + "its role, its whole 40-character commit, where that commit stands, whether the check's " + "words moved after it was recorded, the time, its id, and the reading the role recorded. " + "A result nobody gave a reading says so. A retracted result prints as retracted, with " + "the reason and the caller that retracted it. A check with no result says so. " + `${CHECK_PROVED_BY_CI}: ` + "no role records its result, and Dispatch reads it from GitHub at the head of the " + "issue's open pull request of the highest number, else at the head of its merged one of " + "the highest number. Its one result prints as `- <id> (before_merge): <verdict> at " + "<commit> by ci (CI run <name>, <conclusion>), <where that commit stands>. <the check's " + "words>`, then the `A pass stands:` line a recorded check prints, then `Pull request line:` " + "and the line to write into the pull-request body unchanged, then the reading: the " + "conclusion, the run's output title and summary, and its URL. A run that proves nothing " + "prints `- <id> (before_merge): no result:`, the sentence that names why, and the check's " + "words, then the `A pass stands:` line, then `Pull request line:` and `- Check <id> " + "(before_merge): CI run <name> has no result (<case>)`. That is a run that has not " + "concluded, one that concluded neutral, skipped or cancelled, one absent at the head, an " + "issue with no pull request head, or GitHub not read, with what GitHub answered. " + "A push that moves a pull request's head leaves a result at the commit before it, with " + "no write of anyone's: record the check again at the new head. A check CI proves is read " + "again at the new head by itself. " + ISSUE_REFERENCE,
|
|
37529
|
+
description: "Print each check of an issue's Verification document with every result recorded against " + "it, newest first. " + "Each check prints what Dispatch compared its results with. A before_merge check is " + "compared with the head of each pull request Dispatch holds for the check's issue, open " + "or merged. An after_merge check is compared with the branch that issue's pull request " + "merged into and with the repository's default branch, and with the default branch alone " + "where Dispatch holds no merge of the issue. A default_branch check is compared with the " + "repository's default branch alone, whatever branch the pull request merged into. Where " + "a check compared with nothing, it says which of three things happened: the issue has no " + "pull request and no branch to compare with, Dispatch cannot read the repository, or a " + "read Dispatch made did not answer. " + "Each check then prints one line that answers the gate: whether a pass of it stands, and " + "from which roles. A pass stands when its commit is one of the commits the check " + "compared with, the check's words did not move after the result was recorded, and no " + "retraction stands against it. " + "The check's own words print once, under the check. Each result then prints its verdict, " + "its role, its whole 40-character commit, where that commit stands, whether the check's " + "words moved after it was recorded, the time, its id, and the reading the role recorded. " + "A result nobody gave a reading says so. A retracted result prints as retracted, with " + "the reason and the caller that retracted it. A check with no result says so. " + `${CHECK_PROVED_BY_CI}: ` + "no role records its result, and Dispatch reads it from GitHub at the head of the " + "issue's open pull request of the highest number, else at the head of its merged one of " + "the highest number. Its one result prints as `- <id> (before_merge): <verdict> at " + "<commit> by ci (CI run <name>, <conclusion>), <where that commit stands>. <the check's " + "words>`, then the `A pass stands:` line a recorded check prints, then `Pull request line:` " + "and the line to write into the pull-request body unchanged, then the reading: the " + "conclusion, the run's output title and summary, and its URL. A run that proves nothing " + "prints `- <id> (before_merge): no result:`, the sentence that names why, and the check's " + "words, then the `A pass stands:` line, then `Pull request line:` and `- Check <id> " + "(before_merge): CI run <name> has no result (<case>)`. That is a run that has not " + "concluded, one that concluded neutral, skipped or cancelled, one absent at the head, an " + "issue with no pull request head, or GitHub not read, with what GitHub answered. " + "A pull-request line writes `CI run <name>` only when it keeps every word of the name, " + "and `the CI run the check names` in its place where it drops one: a word the line drops, " + "such as an issue key or a word holding `_`. " + "A push that moves a pull request's head leaves a result at the commit before it, with " + "no write of anyone's: record the check again at the new head. A check CI proves is read " + "again at the new head by itself. " + ISSUE_REFERENCE,
|
|
37530
37530
|
arguments: (z) => ({
|
|
37531
37531
|
issue: z.string().describe(ISSUE_REFERENCE),
|
|
37532
37532
|
at: z.string().describe("One commit of 40 lowercase hex characters. It becomes the only thing every check is compared with. Dispatch reads GitHub for none of it, except the check runs of a check CI proves, which it reads at the issue's newest pull request head as on every read, so that check's result stands at this commit only where it is that head.").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.1";
|
|
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
|
|
@@ -64940,8 +64962,8 @@ function listenerAskedToClaimAgain(error) {
|
|
|
64940
64962
|
|
|
64941
64963
|
// src/legion-phase-hook.ts
|
|
64942
64964
|
import { randomUUID as randomUUID7 } from "crypto";
|
|
64943
|
-
import { readFileSync as
|
|
64944
|
-
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";
|
|
64945
64967
|
|
|
64946
64968
|
// ../pi-shared/src/phase-reminder.ts
|
|
64947
64969
|
import { randomUUID as randomUUID6 } from "crypto";
|
|
@@ -65397,7 +65419,7 @@ function phaseHookToolDefinition() {
|
|
|
65397
65419
|
};
|
|
65398
65420
|
}
|
|
65399
65421
|
function phaseStallFile(configDir, sessionID) {
|
|
65400
|
-
return
|
|
65422
|
+
return join12(configDir, `legion-phase-stall-${sessionID}.json`);
|
|
65401
65423
|
}
|
|
65402
65424
|
function paneReminderLog(write) {
|
|
65403
65425
|
const line = (level, message, context) => {
|
|
@@ -65412,7 +65434,7 @@ var NO_RECORD = { entry: undefined, recreatedNoticeSent: false };
|
|
|
65412
65434
|
function readPhaseStallRecord(file, log) {
|
|
65413
65435
|
let raw;
|
|
65414
65436
|
try {
|
|
65415
|
-
raw =
|
|
65437
|
+
raw = readFileSync8(file, "utf8");
|
|
65416
65438
|
} catch (error) {
|
|
65417
65439
|
const missing = typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
65418
65440
|
if (!missing) {
|
|
@@ -65450,7 +65472,7 @@ function readPhaseStallRecord(file, log) {
|
|
|
65450
65472
|
};
|
|
65451
65473
|
}
|
|
65452
65474
|
function writePhaseStallRecord(file, entry, recreatedNoticeSent, log) {
|
|
65453
|
-
const temporary =
|
|
65475
|
+
const temporary = join12(dirname6(file), `.legion-phase-stall-${randomUUID7()}`);
|
|
65454
65476
|
try {
|
|
65455
65477
|
writeFileSync4(temporary, JSON.stringify({ ...entry, ...recreatedNoticeSent ? { recreatedNoticeSent } : {} }), { mode: 384 });
|
|
65456
65478
|
renameSync3(temporary, file);
|
|
@@ -65658,12 +65680,12 @@ function stopPane(why) {
|
|
|
65658
65680
|
endPane();
|
|
65659
65681
|
}
|
|
65660
65682
|
async function waitForTranscript(configDir, sessionID, signal, pollMs = 100) {
|
|
65661
|
-
const projects =
|
|
65683
|
+
const projects = join13(configDir, "projects");
|
|
65662
65684
|
const name = `${sessionID}.jsonl`;
|
|
65663
65685
|
for (;; ) {
|
|
65664
65686
|
signal.throwIfAborted();
|
|
65665
65687
|
for (const directory of await readdir4(projects).catch(() => [])) {
|
|
65666
|
-
const file =
|
|
65688
|
+
const file = join13(projects, directory, name);
|
|
65667
65689
|
if (await isFile(file))
|
|
65668
65690
|
return file;
|
|
65669
65691
|
}
|
|
@@ -66240,7 +66262,7 @@ import {
|
|
|
66240
66262
|
createServer,
|
|
66241
66263
|
request as httpRequest
|
|
66242
66264
|
} from "http";
|
|
66243
|
-
import { dirname as
|
|
66265
|
+
import { dirname as dirname7 } from "path";
|
|
66244
66266
|
|
|
66245
66267
|
// hooks/mod-protocol.ts
|
|
66246
66268
|
var MOD_HEALTH_MARKER = "claude-envoy-mod";
|
|
@@ -66462,7 +66484,7 @@ async function privateDirectory(path) {
|
|
|
66462
66484
|
}
|
|
66463
66485
|
}
|
|
66464
66486
|
async function bind(server, socketPath) {
|
|
66465
|
-
await privateDirectory(
|
|
66487
|
+
await privateDirectory(dirname7(socketPath));
|
|
66466
66488
|
if (await exists(socketPath)) {
|
|
66467
66489
|
if (await probeHealth(socketPath, MOD_PROBE_TIMEOUT_MS)) {
|
|
66468
66490
|
throw new Error(`another claude-envoy server already serves this session at ${socketPath}`);
|
|
@@ -66853,7 +66875,7 @@ function modSession(options) {
|
|
|
66853
66875
|
}
|
|
66854
66876
|
|
|
66855
66877
|
// src/replay-state.ts
|
|
66856
|
-
import { join as
|
|
66878
|
+
import { join as join14 } from "path";
|
|
66857
66879
|
|
|
66858
66880
|
// src/state-file.ts
|
|
66859
66881
|
import { readFile as readFile5 } from "fs/promises";
|
|
@@ -66883,7 +66905,7 @@ var ReplayStateFileSchema = LedgerSnapshotSchema.extend({
|
|
|
66883
66905
|
consumer: ConsumerDeliverySnapshotSchema.optional()
|
|
66884
66906
|
});
|
|
66885
66907
|
function replayStateFile(stateDirectory, sessionId) {
|
|
66886
|
-
return
|
|
66908
|
+
return join14(stateDirectory, `replay-${encodeURIComponent(sessionId)}.json`);
|
|
66887
66909
|
}
|
|
66888
66910
|
async function readReplayState(file) {
|
|
66889
66911
|
return await readStateFile(file, ReplayStateFileSchema, { ledger: [] }, "holds no delivery state");
|
|
@@ -66915,12 +66937,12 @@ import { basename as basename4 } from "path";
|
|
|
66915
66937
|
|
|
66916
66938
|
// ../envoy-client/src/process-ancestry.ts
|
|
66917
66939
|
import { execFileSync } from "child_process";
|
|
66918
|
-
import { readFileSync as
|
|
66940
|
+
import { readFileSync as readFileSync9 } from "fs";
|
|
66919
66941
|
var MAX_ANCESTORS = 64;
|
|
66920
66942
|
var PARENT_LOOKUP_MS = 1000;
|
|
66921
66943
|
function procParentPid(pid) {
|
|
66922
66944
|
try {
|
|
66923
|
-
const stat =
|
|
66945
|
+
const stat = readFileSync9(`/proc/${pid}/stat`, "utf8");
|
|
66924
66946
|
const parent = Number(stat.slice(stat.lastIndexOf(")") + 2).split(" ")[1]);
|
|
66925
66947
|
return Number.isInteger(parent) ? parent : undefined;
|
|
66926
66948
|
} catch {
|
|
@@ -66962,7 +66984,7 @@ function isAncestor(candidate, pid = process.pid) {
|
|
|
66962
66984
|
}
|
|
66963
66985
|
function procCommand(pid) {
|
|
66964
66986
|
try {
|
|
66965
|
-
return
|
|
66987
|
+
return readFileSync9(`/proc/${pid}/comm`, "utf8").trim();
|
|
66966
66988
|
} catch {
|
|
66967
66989
|
return;
|
|
66968
66990
|
}
|
|
@@ -67398,7 +67420,7 @@ function createUserTurnRouter(options) {
|
|
|
67398
67420
|
}
|
|
67399
67421
|
|
|
67400
67422
|
// src/user-turn-state.ts
|
|
67401
|
-
import { join as
|
|
67423
|
+
import { join as join15 } from "path";
|
|
67402
67424
|
var TURNS_DIRECTORY = "turns";
|
|
67403
67425
|
var HANDLED_ATTEMPTS_MAX = 1000;
|
|
67404
67426
|
var DELIVERED_ROWS_MAX = 1000;
|
|
@@ -67408,7 +67430,7 @@ var UserTurnStateSchema = object({
|
|
|
67408
67430
|
rows: array(DeliveredRowSchema).default([])
|
|
67409
67431
|
});
|
|
67410
67432
|
function userTurnStateFile(stateDirectory, sessionId) {
|
|
67411
|
-
return
|
|
67433
|
+
return join15(stateDirectory, TURNS_DIRECTORY, `${encodeURIComponent(sessionId)}.json`);
|
|
67412
67434
|
}
|
|
67413
67435
|
async function readUserTurnState(file) {
|
|
67414
67436
|
return await readStateFile(file, UserTurnStateSchema, { handled: [], rows: [] }, "holds no record of this session's turns");
|
|
@@ -67446,7 +67468,7 @@ function userTurnState(file, restored) {
|
|
|
67446
67468
|
};
|
|
67447
67469
|
}
|
|
67448
67470
|
async function pruneStaleSessionTurns(stateDirectory) {
|
|
67449
|
-
await pruneStateDirectory(
|
|
67471
|
+
await pruneStateDirectory(join15(stateDirectory, TURNS_DIRECTORY), writtenLongAgo);
|
|
67450
67472
|
}
|
|
67451
67473
|
|
|
67452
67474
|
// src/envoy-channel-server.ts
|
|
@@ -68875,7 +68897,7 @@ async function runEnvoyChannelServer() {
|
|
|
68875
68897
|
session = inboundOffChannelSession({ identity, stateDirectory, why: inbound.off });
|
|
68876
68898
|
} else {
|
|
68877
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";
|
|
68878
|
-
const natsName = `claude-envoy-channel-${identity.id}
|
|
68900
|
+
const natsName = channelConnectionName(`claude-envoy-channel-${identity.id}`, bundlePath, name2);
|
|
68879
68901
|
const dialled = await dialChannelInbound(inbound, envoy.url, currentSessionId, natsName, (text, dialError) => {
|
|
68880
68902
|
if (dialError !== undefined)
|
|
68881
68903
|
starting = text;
|
|
@@ -69165,10 +69187,10 @@ function startCodexAgentStream(options) {
|
|
|
69165
69187
|
// src/codex/codex-cli.ts
|
|
69166
69188
|
import { spawn } from "child_process";
|
|
69167
69189
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
69168
|
-
import { mkdirSync as mkdirSync4, readFileSync as
|
|
69169
|
-
import { join as
|
|
69190
|
+
import { mkdirSync as mkdirSync4, readFileSync as readFileSync10, writeFileSync as writeFileSync5 } from "fs";
|
|
69191
|
+
import { join as join16 } from "path";
|
|
69170
69192
|
var QUEUE_TIMEOUT_MS = 30000;
|
|
69171
|
-
function codexProcessEnv(pid, fallback, read = (path) =>
|
|
69193
|
+
function codexProcessEnv(pid, fallback, read = (path) => readFileSync10(path, "utf8")) {
|
|
69172
69194
|
let raw;
|
|
69173
69195
|
try {
|
|
69174
69196
|
raw = read(`/proc/${pid}/environ`);
|
|
@@ -69235,7 +69257,7 @@ function fitArgument(text, spillDirectory) {
|
|
|
69235
69257
|
throw new Error(`the message is ${Buffer.byteLength(text)} bytes, over what codex queue takes`);
|
|
69236
69258
|
}
|
|
69237
69259
|
mkdirSync4(spillDirectory, { mode: 448, recursive: true });
|
|
69238
|
-
const file =
|
|
69260
|
+
const file = join16(spillDirectory, `${Date.now()}-${randomBytes2(4).toString("hex")}.txt`);
|
|
69239
69261
|
writeFileSync5(file, text, { mode: 384 });
|
|
69240
69262
|
return `${text.slice(0, QUEUE_HEAD_CHARS)}
|
|
69241
69263
|
|
|
@@ -69361,10 +69383,10 @@ function askSideQuestion(command, threadId, question, timeoutMs = SIDE_QUESTION_
|
|
|
69361
69383
|
// src/codex/codex-inbox.ts
|
|
69362
69384
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
69363
69385
|
import { mkdir as mkdir4, readdir as readdir5, readFile as readFile6, rename as rename4, rm as rm5, writeFile as writeFile2 } from "fs/promises";
|
|
69364
|
-
import { join as
|
|
69386
|
+
import { join as join17 } from "path";
|
|
69365
69387
|
var TAKEN_DIRECTORY = { hook: "taken", server: "queued" };
|
|
69366
69388
|
function codexInboxDirectory(stateDirectory, sessionId) {
|
|
69367
|
-
return
|
|
69389
|
+
return join17(stateDirectory, "codex-inbox", encodeURIComponent(sessionId));
|
|
69368
69390
|
}
|
|
69369
69391
|
var lastOrder = 0;
|
|
69370
69392
|
function inboxItemName() {
|
|
@@ -69373,17 +69395,17 @@ function inboxItemName() {
|
|
|
69373
69395
|
return `${String(order).padStart(15, "0")}-${randomBytes3(4).toString("hex")}.json`;
|
|
69374
69396
|
}
|
|
69375
69397
|
async function putInbox(directory, item, name = inboxItemName()) {
|
|
69376
|
-
const waiting =
|
|
69398
|
+
const waiting = join17(directory, "waiting");
|
|
69377
69399
|
await mkdir4(waiting, { recursive: true, mode: 448 });
|
|
69378
|
-
const temporary =
|
|
69400
|
+
const temporary = join17(directory, `.${name}.tmp`);
|
|
69379
69401
|
await writeFile2(temporary, JSON.stringify(item), { mode: 384 });
|
|
69380
|
-
await rename4(temporary,
|
|
69402
|
+
await rename4(temporary, join17(waiting, name));
|
|
69381
69403
|
return name;
|
|
69382
69404
|
}
|
|
69383
69405
|
async function takenBy(directory, name) {
|
|
69384
69406
|
for (const taker of ["hook", "server"]) {
|
|
69385
69407
|
try {
|
|
69386
|
-
await readFile6(
|
|
69408
|
+
await readFile6(join17(directory, TAKEN_DIRECTORY[taker], name));
|
|
69387
69409
|
return taker;
|
|
69388
69410
|
} catch {}
|
|
69389
69411
|
}
|
|
@@ -69391,14 +69413,14 @@ async function takenBy(directory, name) {
|
|
|
69391
69413
|
}
|
|
69392
69414
|
async function withdrawWaiting(directory, name) {
|
|
69393
69415
|
try {
|
|
69394
|
-
await rm5(
|
|
69416
|
+
await rm5(join17(directory, "waiting", name));
|
|
69395
69417
|
return true;
|
|
69396
69418
|
} catch {
|
|
69397
69419
|
return false;
|
|
69398
69420
|
}
|
|
69399
69421
|
}
|
|
69400
69422
|
async function discardWaiting(directory, keep = () => false) {
|
|
69401
|
-
const waiting =
|
|
69423
|
+
const waiting = join17(directory, "waiting");
|
|
69402
69424
|
let names;
|
|
69403
69425
|
try {
|
|
69404
69426
|
names = await readdir5(waiting);
|
|
@@ -69410,7 +69432,7 @@ async function discardWaiting(directory, keep = () => false) {
|
|
|
69410
69432
|
if (!name.endsWith(".json") || keep(name))
|
|
69411
69433
|
continue;
|
|
69412
69434
|
try {
|
|
69413
|
-
await rm5(
|
|
69435
|
+
await rm5(join17(waiting, name));
|
|
69414
69436
|
removed++;
|
|
69415
69437
|
} catch {}
|
|
69416
69438
|
}
|
|
@@ -69418,7 +69440,7 @@ async function discardWaiting(directory, keep = () => false) {
|
|
|
69418
69440
|
}
|
|
69419
69441
|
var HOOK_CONTEXT_MAX_BYTES = 8000;
|
|
69420
69442
|
async function takeInbox(directory, taker, maxContextBytes) {
|
|
69421
|
-
const waiting =
|
|
69443
|
+
const waiting = join17(directory, "waiting");
|
|
69422
69444
|
let names;
|
|
69423
69445
|
try {
|
|
69424
69446
|
names = (await readdir5(waiting)).filter((name) => name.endsWith(".json")).sort();
|
|
@@ -69427,14 +69449,14 @@ async function takeInbox(directory, taker, maxContextBytes) {
|
|
|
69427
69449
|
}
|
|
69428
69450
|
if (names.length === 0)
|
|
69429
69451
|
return [];
|
|
69430
|
-
const destination =
|
|
69452
|
+
const destination = join17(directory, TAKEN_DIRECTORY[taker]);
|
|
69431
69453
|
await mkdir4(destination, { recursive: true, mode: 448 });
|
|
69432
69454
|
const taken = [];
|
|
69433
69455
|
for (const name of names) {
|
|
69434
69456
|
if (maxContextBytes !== undefined) {
|
|
69435
69457
|
let waitingItem;
|
|
69436
69458
|
try {
|
|
69437
|
-
waitingItem = JSON.parse(await readFile6(
|
|
69459
|
+
waitingItem = JSON.parse(await readFile6(join17(waiting, name), "utf8"));
|
|
69438
69460
|
} catch {
|
|
69439
69461
|
continue;
|
|
69440
69462
|
}
|
|
@@ -69445,12 +69467,12 @@ async function takeInbox(directory, taker, maxContextBytes) {
|
|
|
69445
69467
|
break;
|
|
69446
69468
|
}
|
|
69447
69469
|
try {
|
|
69448
|
-
await rename4(
|
|
69470
|
+
await rename4(join17(waiting, name), join17(destination, name));
|
|
69449
69471
|
} catch {
|
|
69450
69472
|
continue;
|
|
69451
69473
|
}
|
|
69452
69474
|
try {
|
|
69453
|
-
const parsed = JSON.parse(await readFile6(
|
|
69475
|
+
const parsed = JSON.parse(await readFile6(join17(destination, name), "utf8"));
|
|
69454
69476
|
if (typeof parsed === "object" && parsed !== null && typeof parsed.content === "string") {
|
|
69455
69477
|
taken.push({ item: parsed, name });
|
|
69456
69478
|
}
|
|
@@ -69608,14 +69630,14 @@ function createCodexDelivery(options) {
|
|
|
69608
69630
|
|
|
69609
69631
|
// src/codex/codex-owner.ts
|
|
69610
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";
|
|
69611
|
-
import { join as
|
|
69633
|
+
import { join as join19 } from "path";
|
|
69612
69634
|
|
|
69613
69635
|
// src/codex/codex-session-record.ts
|
|
69614
69636
|
import { spawnSync } from "child_process";
|
|
69615
|
-
import { readFileSync as
|
|
69637
|
+
import { readFileSync as readFileSync11, readlinkSync as readlinkSync3, unwatchFile as unwatchFile2, watchFile as watchFile2 } from "fs";
|
|
69616
69638
|
import { mkdir as mkdir5, readFile as readFile7, rename as rename5, utimes as utimes3, writeFile as writeFile3 } from "fs/promises";
|
|
69617
69639
|
import { homedir as homedir3 } from "os";
|
|
69618
|
-
import { basename as basename5, dirname as
|
|
69640
|
+
import { basename as basename5, dirname as dirname8, join as join18 } from "path";
|
|
69619
69641
|
var CodexSessionRecord = object({
|
|
69620
69642
|
session_id: string2().min(1),
|
|
69621
69643
|
transcript_path: string2().nullable(),
|
|
@@ -69626,14 +69648,14 @@ var CodexSessionRecord = object({
|
|
|
69626
69648
|
codex_started: string2().nullable().default(null)
|
|
69627
69649
|
});
|
|
69628
69650
|
function codexSessionRecordFile(stateDirectory, pid) {
|
|
69629
|
-
return
|
|
69651
|
+
return join18(stateDirectory, "codex-sessions", `${pid}.json`);
|
|
69630
69652
|
}
|
|
69631
69653
|
function codexEndedFile(stateDirectory, pid, sessionId) {
|
|
69632
|
-
return
|
|
69654
|
+
return join18(stateDirectory, "codex-sessions", `${pid}.${encodeURIComponent(sessionId)}.ended`);
|
|
69633
69655
|
}
|
|
69634
69656
|
async function markSessionEnded(stateDirectory, pid, sessionId) {
|
|
69635
69657
|
const marker = codexEndedFile(stateDirectory, pid, sessionId);
|
|
69636
|
-
await mkdir5(
|
|
69658
|
+
await mkdir5(dirname8(marker), { mode: 448, recursive: true });
|
|
69637
69659
|
await writeFile3(marker, "", { mode: 384 });
|
|
69638
69660
|
const now = new Date;
|
|
69639
69661
|
await utimes3(codexSessionRecordFile(stateDirectory, pid), now, now);
|
|
@@ -69659,7 +69681,7 @@ async function sessionEnded(file) {
|
|
|
69659
69681
|
}
|
|
69660
69682
|
}
|
|
69661
69683
|
async function writeCodexSessionRecord(file, value) {
|
|
69662
|
-
await mkdir5(
|
|
69684
|
+
await mkdir5(dirname8(file), { recursive: true, mode: 448 });
|
|
69663
69685
|
const temporary = `${file}.${process.pid}.tmp`;
|
|
69664
69686
|
await writeFile3(temporary, JSON.stringify(value), { mode: 384 });
|
|
69665
69687
|
await rename5(temporary, file);
|
|
@@ -69674,17 +69696,17 @@ async function readCodexSessionRecord(file) {
|
|
|
69674
69696
|
}
|
|
69675
69697
|
function codexHome(env) {
|
|
69676
69698
|
const set = env["CODEX_HOME"];
|
|
69677
|
-
return set !== undefined && set !== "" ? set :
|
|
69699
|
+
return set !== undefined && set !== "" ? set : join18(env["HOME"] || homedir3(), ".codex");
|
|
69678
69700
|
}
|
|
69679
69701
|
function codexPluginDataDirectory(pluginRoot) {
|
|
69680
69702
|
const version = pluginRoot;
|
|
69681
|
-
const plugin =
|
|
69682
|
-
const marketplace =
|
|
69683
|
-
const cache =
|
|
69684
|
-
const plugins =
|
|
69703
|
+
const plugin = dirname8(version);
|
|
69704
|
+
const marketplace = dirname8(plugin);
|
|
69705
|
+
const cache = dirname8(marketplace);
|
|
69706
|
+
const plugins = dirname8(cache);
|
|
69685
69707
|
if (basename5(cache) !== "cache" || basename5(plugins) !== "plugins")
|
|
69686
69708
|
return;
|
|
69687
|
-
return
|
|
69709
|
+
return join18(plugins, "data", `${basename5(plugin)}-${basename5(marketplace)}`);
|
|
69688
69710
|
}
|
|
69689
69711
|
var MAX_ANCESTORS2 = 16;
|
|
69690
69712
|
function codexProcessId(readComm = procComm, readParent = procParent) {
|
|
@@ -69698,14 +69720,14 @@ function codexProcessId(readComm = procComm, readParent = procParent) {
|
|
|
69698
69720
|
}
|
|
69699
69721
|
function procComm(pid) {
|
|
69700
69722
|
try {
|
|
69701
|
-
return
|
|
69723
|
+
return readFileSync11(`/proc/${pid}/comm`, "utf8").trim();
|
|
69702
69724
|
} catch {
|
|
69703
69725
|
return;
|
|
69704
69726
|
}
|
|
69705
69727
|
}
|
|
69706
69728
|
function procParent(pid) {
|
|
69707
69729
|
try {
|
|
69708
|
-
const stat =
|
|
69730
|
+
const stat = readFileSync11(`/proc/${pid}/stat`, "utf8");
|
|
69709
69731
|
const parent = Number(stat.slice(stat.lastIndexOf(")") + 2).split(" ")[1]);
|
|
69710
69732
|
return Number.isInteger(parent) ? parent : undefined;
|
|
69711
69733
|
} catch {
|
|
@@ -69719,7 +69741,7 @@ var PS_OPTIONS = {
|
|
|
69719
69741
|
};
|
|
69720
69742
|
function procStarted(pid) {
|
|
69721
69743
|
try {
|
|
69722
|
-
const stat =
|
|
69744
|
+
const stat = readFileSync11(`/proc/${pid}/stat`, "utf8");
|
|
69723
69745
|
return stat.slice(stat.lastIndexOf(")") + 2).split(" ")[19];
|
|
69724
69746
|
} catch {
|
|
69725
69747
|
return;
|
|
@@ -69740,7 +69762,7 @@ function recordOfProcess(record, pid) {
|
|
|
69740
69762
|
function sharedAppServer(pid) {
|
|
69741
69763
|
let argv;
|
|
69742
69764
|
try {
|
|
69743
|
-
argv =
|
|
69765
|
+
argv = readFileSync11(`/proc/${pid}/cmdline`, "utf8").split("\x00");
|
|
69744
69766
|
} catch {
|
|
69745
69767
|
const ps = spawnSync("ps", ["-o", "args=", "-p", String(pid)], PS_OPTIONS);
|
|
69746
69768
|
if (ps.status !== 0)
|
|
@@ -69786,11 +69808,11 @@ function codexSubcommand(args) {
|
|
|
69786
69808
|
}
|
|
69787
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.";
|
|
69788
69810
|
async function pruneCodexSessionRecords(stateDirectory) {
|
|
69789
|
-
await pruneStateDirectory(
|
|
69811
|
+
await pruneStateDirectory(join18(stateDirectory, "codex-sessions"), (file) => {
|
|
69790
69812
|
const match = /^(\d+)\.(?:json|.+\.ended)$/.exec(basename5(file));
|
|
69791
69813
|
return match !== null && !processExists(Number(match[1]));
|
|
69792
69814
|
});
|
|
69793
|
-
await pruneStateDirectory(
|
|
69815
|
+
await pruneStateDirectory(join18(stateDirectory, "codex-servers"), (file) => {
|
|
69794
69816
|
const name = basename5(file);
|
|
69795
69817
|
return /^\d+$/.test(name) && !processExists(Number(name));
|
|
69796
69818
|
});
|
|
@@ -69805,7 +69827,7 @@ function codexExecutable(pid) {
|
|
|
69805
69827
|
|
|
69806
69828
|
// src/codex/codex-owner.ts
|
|
69807
69829
|
function codexServersDirectory(stateDirectory, codexPid) {
|
|
69808
|
-
return
|
|
69830
|
+
return join19(stateDirectory, "codex-servers", String(codexPid));
|
|
69809
69831
|
}
|
|
69810
69832
|
var ENTRY_NAME = /^(\d+)\.json$/;
|
|
69811
69833
|
var TEMPORARY_NAME = /^\.\d+\.\d+\.tmp$/;
|
|
@@ -69814,13 +69836,13 @@ function entryName(entry) {
|
|
|
69814
69836
|
}
|
|
69815
69837
|
async function registerServer(directory, pid, started, list = (path) => readdir6(path)) {
|
|
69816
69838
|
await mkdir6(directory, { mode: 448, recursive: true });
|
|
69817
|
-
const temporary =
|
|
69839
|
+
const temporary = join19(directory, `.${pid}.${process.hrtime.bigint()}.tmp`);
|
|
69818
69840
|
await writeFile4(temporary, JSON.stringify({ pid, started }), { mode: 384 });
|
|
69819
69841
|
try {
|
|
69820
69842
|
let seq = Math.max(0, ...numbered(await list(directory)).map(({ seq: taken }) => taken)) + 1;
|
|
69821
69843
|
for (;; ) {
|
|
69822
69844
|
try {
|
|
69823
|
-
await place(temporary,
|
|
69845
|
+
await place(temporary, join19(directory, entryName({ seq })), pid, started);
|
|
69824
69846
|
return { pid, seq, started };
|
|
69825
69847
|
} catch (error) {
|
|
69826
69848
|
if (error.code !== "EEXIST")
|
|
@@ -69848,7 +69870,7 @@ async function place(temporary, target, pid, started) {
|
|
|
69848
69870
|
await writeFile4(target, JSON.stringify({ pid, started }), { flag: "wx", mode: 384 });
|
|
69849
69871
|
}
|
|
69850
69872
|
async function unregisterServer(directory, self2) {
|
|
69851
|
-
const file =
|
|
69873
|
+
const file = join19(directory, entryName(self2));
|
|
69852
69874
|
const named = await readFile8(file, "utf8").then(serverOf, () => {
|
|
69853
69875
|
return;
|
|
69854
69876
|
});
|
|
@@ -69912,7 +69934,7 @@ async function readEntries(directory, probe, now = Date.now) {
|
|
|
69912
69934
|
for (const name of names.filter((each) => TEMPORARY_NAME.test(each))) {
|
|
69913
69935
|
let text;
|
|
69914
69936
|
try {
|
|
69915
|
-
text = await readFile8(
|
|
69937
|
+
text = await readFile8(join19(directory, name), "utf8");
|
|
69916
69938
|
} catch {
|
|
69917
69939
|
publishing = true;
|
|
69918
69940
|
break;
|
|
@@ -69928,13 +69950,13 @@ async function readEntries(directory, probe, now = Date.now) {
|
|
|
69928
69950
|
for (const { name, seq } of numbered(names)) {
|
|
69929
69951
|
let text;
|
|
69930
69952
|
try {
|
|
69931
|
-
text = await readFile8(
|
|
69953
|
+
text = await readFile8(join19(directory, name), "utf8");
|
|
69932
69954
|
} catch {
|
|
69933
69955
|
continue;
|
|
69934
69956
|
}
|
|
69935
69957
|
const server = serverOf(text);
|
|
69936
69958
|
if (server === undefined) {
|
|
69937
|
-
const written = await stat6(
|
|
69959
|
+
const written = await stat6(join19(directory, name)).then((info) => info.mtimeMs, () => {
|
|
69938
69960
|
return;
|
|
69939
69961
|
});
|
|
69940
69962
|
if (written === undefined)
|
|
@@ -69962,7 +69984,7 @@ async function currentOwner(directory, probe = SYSTEM_PROBE) {
|
|
|
69962
69984
|
const text = seen.held.get(seq);
|
|
69963
69985
|
if (text === undefined)
|
|
69964
69986
|
return;
|
|
69965
|
-
const now = await readFile8(
|
|
69987
|
+
const now = await readFile8(join19(directory, entryName({ seq })), "utf8").catch(() => {
|
|
69966
69988
|
return;
|
|
69967
69989
|
});
|
|
69968
69990
|
if (now !== text)
|
|
@@ -70023,7 +70045,7 @@ async function stillOwner(directory, self2, probe = SYSTEM_PROBE) {
|
|
|
70023
70045
|
// src/codex/codex-transcript.ts
|
|
70024
70046
|
import { watch } from "fs";
|
|
70025
70047
|
import { open as open3 } from "fs/promises";
|
|
70026
|
-
import { join as
|
|
70048
|
+
import { join as join20 } from "path";
|
|
70027
70049
|
function record3(value) {
|
|
70028
70050
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : undefined;
|
|
70029
70051
|
}
|
|
@@ -70293,7 +70315,7 @@ async function findTranscript(home, threadId) {
|
|
|
70293
70315
|
const glob = new Bun.Glob(`**/rollout-*-${threadId}.jsonl`);
|
|
70294
70316
|
const found = [];
|
|
70295
70317
|
try {
|
|
70296
|
-
for await (const file of glob.scan({ absolute: true, cwd:
|
|
70318
|
+
for await (const file of glob.scan({ absolute: true, cwd: join20(home, "sessions") })) {
|
|
70297
70319
|
found.push(file);
|
|
70298
70320
|
}
|
|
70299
70321
|
} catch {
|
|
@@ -70438,7 +70460,7 @@ function runDispatchCommand(script, args, stdin, options) {
|
|
|
70438
70460
|
});
|
|
70439
70461
|
}
|
|
70440
70462
|
function stateDirectoryFor(pluginRoot) {
|
|
70441
|
-
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");
|
|
70442
70464
|
}
|
|
70443
70465
|
function waitForRecord(file, pid, signal, ended) {
|
|
70444
70466
|
return new Promise((done) => {
|
|
@@ -70526,7 +70548,7 @@ async function runCodexEnvoyServer() {
|
|
|
70526
70548
|
env["DISPATCH_HOST"] = "codex";
|
|
70527
70549
|
if (configFile.path !== null)
|
|
70528
70550
|
env["ENVOY_CONFIG_FILE"] = configFile.path;
|
|
70529
|
-
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 });
|
|
70530
70552
|
return `${output}${output.endsWith(`
|
|
70531
70553
|
`) || output === "" ? "" : `
|
|
70532
70554
|
`}[exit ${code}]`;
|
|
@@ -70666,7 +70688,7 @@ async function runCodexEnvoyServer() {
|
|
|
70666
70688
|
const runningSession = () => record?.session_id ?? bound.session_id;
|
|
70667
70689
|
const codexDelivery = createCodexDelivery({
|
|
70668
70690
|
inboxDirectory: (sessionId) => codexInboxDirectory(stateDirectory, sessionId),
|
|
70669
|
-
queue: (text) => queueMessage(command(), runningSession(), text,
|
|
70691
|
+
queue: (text) => queueMessage(command(), runningSession(), text, join21(stateDirectory, "codex-long-messages")),
|
|
70670
70692
|
sessionId: runningSession,
|
|
70671
70693
|
taken: (item) => stream?.delivered(item.content, item.dispatchMessageId),
|
|
70672
70694
|
warn
|
|
@@ -70700,7 +70722,7 @@ async function runCodexEnvoyServer() {
|
|
|
70700
70722
|
if ("off" in inbound) {
|
|
70701
70723
|
session = inboundOffChannelSession({ identity: id, stateDirectory, why: inbound.off });
|
|
70702
70724
|
} else {
|
|
70703
|
-
const natsName = `codex-envoy-channel-${id.id}
|
|
70725
|
+
const natsName = channelConnectionName(`codex-envoy-channel-${id.id}`, bundlePath, name);
|
|
70704
70726
|
const dialled = await dialChannelInbound(inbound, envoy.url, () => id.id, natsName, warn, import_nats6.connect, stopping.signal).catch((error) => {
|
|
70705
70727
|
if (isStopping)
|
|
70706
70728
|
return;
|
package/dist/session-hook.js
CHANGED
|
@@ -14930,7 +14930,7 @@ var dispatchToolSpecs = [
|
|
|
14930
14930
|
{
|
|
14931
14931
|
name: "dispatch_results",
|
|
14932
14932
|
example: { issue: "DSP-1" },
|
|
14933
|
-
description: "Print each check of an issue's Verification document with every result recorded against " + "it, newest first. " + "Each check prints what Dispatch compared its results with. A before_merge check is " + "compared with the head of each pull request Dispatch holds for the check's issue, open " + "or merged. An after_merge check is compared with the branch that issue's pull request " + "merged into and with the repository's default branch, and with the default branch alone " + "where Dispatch holds no merge of the issue. A default_branch check is compared with the " + "repository's default branch alone, whatever branch the pull request merged into. Where " + "a check compared with nothing, it says which of three things happened: the issue has no " + "pull request and no branch to compare with, Dispatch cannot read the repository, or a " + "read Dispatch made did not answer. " + "Each check then prints one line that answers the gate: whether a pass of it stands, and " + "from which roles. A pass stands when its commit is one of the commits the check " + "compared with, the check's words did not move after the result was recorded, and no " + "retraction stands against it. " + "The check's own words print once, under the check. Each result then prints its verdict, " + "its role, its whole 40-character commit, where that commit stands, whether the check's " + "words moved after it was recorded, the time, its id, and the reading the role recorded. " + "A result nobody gave a reading says so. A retracted result prints as retracted, with " + "the reason and the caller that retracted it. A check with no result says so. " + `${CHECK_PROVED_BY_CI}: ` + "no role records its result, and Dispatch reads it from GitHub at the head of the " + "issue's open pull request of the highest number, else at the head of its merged one of " + "the highest number. Its one result prints as `- <id> (before_merge): <verdict> at " + "<commit> by ci (CI run <name>, <conclusion>), <where that commit stands>. <the check's " + "words>`, then the `A pass stands:` line a recorded check prints, then `Pull request line:` " + "and the line to write into the pull-request body unchanged, then the reading: the " + "conclusion, the run's output title and summary, and its URL. A run that proves nothing " + "prints `- <id> (before_merge): no result:`, the sentence that names why, and the check's " + "words, then the `A pass stands:` line, then `Pull request line:` and `- Check <id> " + "(before_merge): CI run <name> has no result (<case>)`. That is a run that has not " + "concluded, one that concluded neutral, skipped or cancelled, one absent at the head, an " + "issue with no pull request head, or GitHub not read, with what GitHub answered. " + "A push that moves a pull request's head leaves a result at the commit before it, with " + "no write of anyone's: record the check again at the new head. A check CI proves is read " + "again at the new head by itself. " + ISSUE_REFERENCE,
|
|
14933
|
+
description: "Print each check of an issue's Verification document with every result recorded against " + "it, newest first. " + "Each check prints what Dispatch compared its results with. A before_merge check is " + "compared with the head of each pull request Dispatch holds for the check's issue, open " + "or merged. An after_merge check is compared with the branch that issue's pull request " + "merged into and with the repository's default branch, and with the default branch alone " + "where Dispatch holds no merge of the issue. A default_branch check is compared with the " + "repository's default branch alone, whatever branch the pull request merged into. Where " + "a check compared with nothing, it says which of three things happened: the issue has no " + "pull request and no branch to compare with, Dispatch cannot read the repository, or a " + "read Dispatch made did not answer. " + "Each check then prints one line that answers the gate: whether a pass of it stands, and " + "from which roles. A pass stands when its commit is one of the commits the check " + "compared with, the check's words did not move after the result was recorded, and no " + "retraction stands against it. " + "The check's own words print once, under the check. Each result then prints its verdict, " + "its role, its whole 40-character commit, where that commit stands, whether the check's " + "words moved after it was recorded, the time, its id, and the reading the role recorded. " + "A result nobody gave a reading says so. A retracted result prints as retracted, with " + "the reason and the caller that retracted it. A check with no result says so. " + `${CHECK_PROVED_BY_CI}: ` + "no role records its result, and Dispatch reads it from GitHub at the head of the " + "issue's open pull request of the highest number, else at the head of its merged one of " + "the highest number. Its one result prints as `- <id> (before_merge): <verdict> at " + "<commit> by ci (CI run <name>, <conclusion>), <where that commit stands>. <the check's " + "words>`, then the `A pass stands:` line a recorded check prints, then `Pull request line:` " + "and the line to write into the pull-request body unchanged, then the reading: the " + "conclusion, the run's output title and summary, and its URL. A run that proves nothing " + "prints `- <id> (before_merge): no result:`, the sentence that names why, and the check's " + "words, then the `A pass stands:` line, then `Pull request line:` and `- Check <id> " + "(before_merge): CI run <name> has no result (<case>)`. That is a run that has not " + "concluded, one that concluded neutral, skipped or cancelled, one absent at the head, an " + "issue with no pull request head, or GitHub not read, with what GitHub answered. " + "A pull-request line writes `CI run <name>` only when it keeps every word of the name, " + "and `the CI run the check names` in its place where it drops one: a word the line drops, " + "such as an issue key or a word holding `_`. " + "A push that moves a pull request's head leaves a result at the commit before it, with " + "no write of anyone's: record the check again at the new head. A check CI proves is read " + "again at the new head by itself. " + ISSUE_REFERENCE,
|
|
14934
14934
|
arguments: (z) => ({
|
|
14935
14935
|
issue: z.string().describe(ISSUE_REFERENCE),
|
|
14936
14936
|
at: z.string().describe("One commit of 40 lowercase hex characters. It becomes the only thing every check is compared with. Dispatch reads GitHub for none of it, except the check runs of a check CI proves, which it reads at the issue's newest pull request head as on every read, so that check's result stands at this commit only where it is that head.").optional(),
|
package/package.json
CHANGED
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
startChannelSession,
|
|
42
42
|
} from "../envoy-channel-server"
|
|
43
43
|
import { inboundOffChannelSession } from "../envoy-off"
|
|
44
|
-
import { installedPluginVersion } from "../installed-build"
|
|
44
|
+
import { channelConnectionName, installedPluginVersion } from "../installed-build"
|
|
45
45
|
import { SessionIdentity } from "../session-identity"
|
|
46
46
|
import { sessionTitle } from "../session-title"
|
|
47
47
|
import { type CodexAgentStream, startCodexAgentStream } from "./codex-agent-stream"
|
|
@@ -542,7 +542,11 @@ export async function runCodexEnvoyServer(): Promise<void> {
|
|
|
542
542
|
// taken; or the listener's relay socket, opened again for the new session at a `/new`. A
|
|
543
543
|
// connection that closes for good is replaced as the Claude Code one is (`channelReopener`):
|
|
544
544
|
// Codex starts no plugin server again for a thread whose server lost its connection.
|
|
545
|
-
const natsName =
|
|
545
|
+
const natsName = channelConnectionName(
|
|
546
|
+
`codex-envoy-channel-${id.id}`,
|
|
547
|
+
bundlePath,
|
|
548
|
+
CODEX_PACKAGE_NAME,
|
|
549
|
+
)
|
|
546
550
|
// A stop asked for while the token or the dial is awaited ends the start, and is no failure:
|
|
547
551
|
// the process ends as an asked-for stop does, as the Claude Code server's does.
|
|
548
552
|
const dialled = await dialChannelInbound(
|
|
@@ -114,7 +114,7 @@ import {
|
|
|
114
114
|
} from "./channel-topics"
|
|
115
115
|
import { claudeProjectDirectory, claudeSessionId, configuredValue } from "./claude-session"
|
|
116
116
|
import { inboundOffChannelSession, serveEnvoyOff } from "./envoy-off"
|
|
117
|
-
import { installedPluginVersion } from "./installed-build"
|
|
117
|
+
import { channelConnectionName, installedPluginVersion } from "./installed-build"
|
|
118
118
|
import {
|
|
119
119
|
endPane,
|
|
120
120
|
type LegionClaim,
|
|
@@ -2809,7 +2809,11 @@ export async function runEnvoyChannelServer(): Promise<void> {
|
|
|
2809
2809
|
: inbound.natsCredential.kind === "broker"
|
|
2810
2810
|
? "it waits for this session's broker token, and its stderr says what each trade came to"
|
|
2811
2811
|
: "it connects to NATS"
|
|
2812
|
-
const natsName =
|
|
2812
|
+
const natsName = channelConnectionName(
|
|
2813
|
+
`claude-envoy-channel-${identity.id}`,
|
|
2814
|
+
bundlePath,
|
|
2815
|
+
packageName,
|
|
2816
|
+
)
|
|
2813
2817
|
const dialled = await dialChannelInbound(
|
|
2814
2818
|
inbound,
|
|
2815
2819
|
envoy.url,
|
package/src/installed-build.ts
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
// the version is the published npm version, since this plugin's marketplace entry is an `npm`
|
|
5
5
|
// source. Every registration names that build to the listener, so the Agents page can tell a
|
|
6
6
|
// session running a release from one running a checkout.
|
|
7
|
-
import { sep } from "node:path"
|
|
7
|
+
import { dirname, join, sep } from "node:path"
|
|
8
|
+
import { clientBuild, clientConnectionName } from "@legion/envoy-client/nats-connection"
|
|
8
9
|
|
|
9
10
|
/** The segments after `…/plugins/cache/` in a plugin install path, or undefined for any other
|
|
10
11
|
* path: a source checkout, `--plugin-dir`, or a bare server config. */
|
|
@@ -24,3 +25,23 @@ function pluginCacheSegments(bundlePath: string): string[] | undefined {
|
|
|
24
25
|
export function installedPluginVersion(bundlePath: string): string | undefined {
|
|
25
26
|
return pluginCacheSegments(bundlePath)?.[2]
|
|
26
27
|
}
|
|
28
|
+
|
|
29
|
+
/** The name the channel server's NATS connection presents: `name`, then its build, which
|
|
30
|
+
* legacy-subjects-gate.sh reads from the hub's census of connections. The build is the build-commit
|
|
31
|
+
* stamp the worker image writes beside the bundle (`/opt/legion/claude-envoy/dist/build-commit`),
|
|
32
|
+
* else `<package>@<version>` for a release Claude Code or Codex installed in its plugin cache,
|
|
33
|
+
* else none (a checkout). */
|
|
34
|
+
export function channelConnectionName(
|
|
35
|
+
name: string,
|
|
36
|
+
bundlePath: string,
|
|
37
|
+
packageName: string,
|
|
38
|
+
): string {
|
|
39
|
+
const version = installedPluginVersion(bundlePath)
|
|
40
|
+
return clientConnectionName(
|
|
41
|
+
name,
|
|
42
|
+
clientBuild(
|
|
43
|
+
join(dirname(bundlePath), "build-commit"),
|
|
44
|
+
version === undefined ? undefined : { name: packageName, version },
|
|
45
|
+
),
|
|
46
|
+
)
|
|
47
|
+
}
|