@sjawhar/pi-envoy 15.5.1 → 15.6.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/README.md +24 -5
- package/dist/dispatch.js +69 -16
- package/dist/envoy.js +82 -22
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -397,16 +397,34 @@ gated write only when it consumes one, so a write sent any other way is refused
|
|
|
397
397
|
|
|
398
398
|
- **The record.** While the gate is bound, pi-envoy keeps one owner-only file for its process in
|
|
399
399
|
the `askgate/` directory of the CLI's state directory of each session id it binds
|
|
400
|
-
(`<state>/sessions/<id>/askgate/<pid>-<start>.json`, where `<state>` is
|
|
401
|
-
else `$XDG_STATE_HOME/dispatch`, else `~/.local/state/dispatch`). It names
|
|
402
|
-
its Linux start time,
|
|
403
|
-
|
|
400
|
+
(`<state>/sessions/<id>/askgate/<pid>-<start>-<ns>.json`, where `<state>` is
|
|
401
|
+
`DISPATCH_STATE_DIR`, else `$XDG_STATE_HOME/dispatch`, else `~/.local/state/dispatch`). It names
|
|
402
|
+
the Oh My Pi process, its Linux start time, its pid namespace (the inode `/proc/self/ns/pid`
|
|
403
|
+
names), and the process's owner-only marker store. Each process writes and removes only its own
|
|
404
|
+
file, so two processes that bind one session never drop each other. pi-envoy sets
|
|
404
405
|
`DISPATCH_STATE_DIR` in the session's environment when it is not set, so a command that changes
|
|
405
406
|
`HOME` or `XDG_STATE_HOME` still finds the record. A record of a session the process switched
|
|
406
407
|
away from stays until the process exits, since a shell or an eval kernel started before the
|
|
407
408
|
switch still acts as that session. A record whose process is gone, or whose pid another process
|
|
408
409
|
now holds, is inert, and the CLI's session pruning keeps a directory whose record is live. A
|
|
409
410
|
record pi-envoy cannot write is a notice in the session, at start or at a switch.
|
|
411
|
+
- **Other pid namespaces.** One state directory can serve processes of several pid namespaces: the
|
|
412
|
+
host's and those of the containers that mount the host's state directory, each with a pid
|
|
413
|
+
namespace of its own. A pid and a start time name a process only in the namespace they were read
|
|
414
|
+
in, so the CLI looks up by pid only an owner of its own namespace. An owner of another one counts
|
|
415
|
+
live while its marker store changed within the last two hours; the process touches its store
|
|
416
|
+
every ten minutes while it keeps a record, so a live one never looks gone from another namespace.
|
|
417
|
+
The process also makes its store again, empty, before each write of its own file, so a store that
|
|
418
|
+
another process removed is back by the gate's next call. A record written by an older pi-envoy
|
|
419
|
+
names no namespace and is still looked up by pid in the reader's own. The pruning keeps a store
|
|
420
|
+
such a pi-envoy named for 14 days rather than two hours, since its process may be a live one of
|
|
421
|
+
another namespace, which touches its store only when it mints a marker, and it keeps a session
|
|
422
|
+
directory whose record names a store that is still there. A process of another namespace that
|
|
423
|
+
reads the record (the host's CLI, for a box's session) is never that session's own agent, whose
|
|
424
|
+
calls run in its process's namespace, so it reads such an owner live only by its store. Every
|
|
425
|
+
`dispatch` command that shares the state directory must be this release or later (pi-envoy's,
|
|
426
|
+
and the copy Claude Code sessions run): an earlier one reads a namespaced owner by pid, and its
|
|
427
|
+
pruning can still remove a box session's idle directory.
|
|
410
428
|
- **The marker.** The gate mints one file in the store for each literal call it lets run, created
|
|
411
429
|
owner-only and exclusively. It binds the exact argument vector the CLI receives and, behind a
|
|
412
430
|
review or a deliberate pass (a rebuttal, a breaker trip), the digest of the arguments the dry
|
|
@@ -417,7 +435,8 @@ gated write only when it consumes one, so a write sent any other way is refused
|
|
|
417
435
|
its marker until
|
|
418
436
|
shutdown, and a marker older than two hours, longer than any tool's time limit, is refused and
|
|
419
437
|
removed. The process removes its store when it exits; the CLI's daily session pruning removes
|
|
420
|
-
the store of a process that is gone and that nothing changed for two hours
|
|
438
|
+
the store of a process that is gone and that nothing changed for two hours, which for a process
|
|
439
|
+
of another pid namespace is how it is known to be gone.
|
|
421
440
|
- **The check.** After `--help`, `--dry-run` and the session and Dispatch settings, and before a
|
|
422
441
|
gated write posts, the CLI reads the session's record. With a live one it reads each file the
|
|
423
442
|
argv names once and consumes one matching marker by unlinking it: exactly one process wins, so a
|
package/dist/dispatch.js
CHANGED
|
@@ -961,10 +961,12 @@ import {
|
|
|
961
961
|
openSync,
|
|
962
962
|
readdirSync,
|
|
963
963
|
readFileSync,
|
|
964
|
+
readlinkSync,
|
|
964
965
|
renameSync,
|
|
965
966
|
rmSync,
|
|
966
967
|
statSync,
|
|
967
968
|
unlinkSync,
|
|
969
|
+
utimesSync,
|
|
968
970
|
writeFileSync
|
|
969
971
|
} from "fs";
|
|
970
972
|
import { isAbsolute, join, resolve } from "path";
|
|
@@ -980,6 +982,7 @@ function hasErrnoCode(error, code) {
|
|
|
980
982
|
// ../envoy-client/src/askgate-marker.ts
|
|
981
983
|
var ASKGATE_RECORD = "askgate";
|
|
982
984
|
var MARKER_MAX_AGE_MS = 2 * 60 * 60000;
|
|
985
|
+
var STORE_BEAT_MS = 10 * 60000;
|
|
983
986
|
var MARKERS = "markers";
|
|
984
987
|
var ALWAYS_GATED = {
|
|
985
988
|
dispatch_ask: true,
|
|
@@ -1044,7 +1047,25 @@ function processStart(pid) {
|
|
|
1044
1047
|
return null;
|
|
1045
1048
|
}
|
|
1046
1049
|
}
|
|
1047
|
-
|
|
1050
|
+
var ownNamespace;
|
|
1051
|
+
function pidNamespace() {
|
|
1052
|
+
if (ownNamespace === undefined) {
|
|
1053
|
+
try {
|
|
1054
|
+
ownNamespace = /^pid:\[([0-9]+)\]$/.exec(readlinkSync("/proc/self/ns/pid"))?.[1] ?? null;
|
|
1055
|
+
} catch {
|
|
1056
|
+
ownNamespace = null;
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
return ownNamespace;
|
|
1060
|
+
}
|
|
1061
|
+
function ownerLive(owner, now) {
|
|
1062
|
+
if (owner.ns !== null && owner.ns !== pidNamespace()) {
|
|
1063
|
+
try {
|
|
1064
|
+
return now - storeTouched(owner.store) <= MARKER_MAX_AGE_MS;
|
|
1065
|
+
} catch {
|
|
1066
|
+
return false;
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1048
1069
|
if (owner.start !== null)
|
|
1049
1070
|
return processStart(owner.pid) === owner.start;
|
|
1050
1071
|
try {
|
|
@@ -1054,11 +1075,11 @@ function ownerLive(owner) {
|
|
|
1054
1075
|
return !hasErrnoCode(error, "ESRCH");
|
|
1055
1076
|
}
|
|
1056
1077
|
}
|
|
1057
|
-
function
|
|
1078
|
+
function isOwnerText(value) {
|
|
1058
1079
|
if (typeof value !== "object" || value === null)
|
|
1059
1080
|
return false;
|
|
1060
|
-
const { pid, start, store } = value;
|
|
1061
|
-
return typeof pid === "number" && Number.isSafeInteger(pid) && pid > 0 && (start === null || typeof start === "string") && typeof store === "string" && store.startsWith("/");
|
|
1081
|
+
const { pid, start, ns, store } = value;
|
|
1082
|
+
return typeof pid === "number" && Number.isSafeInteger(pid) && pid > 0 && (start === null || typeof start === "string") && (ns === undefined || ns === null || typeof ns === "string" && /^[0-9]+$/.test(ns)) && typeof store === "string" && store.startsWith("/");
|
|
1062
1083
|
}
|
|
1063
1084
|
function parseOwner(text) {
|
|
1064
1085
|
let data;
|
|
@@ -1067,16 +1088,16 @@ function parseOwner(text) {
|
|
|
1067
1088
|
} catch {
|
|
1068
1089
|
return;
|
|
1069
1090
|
}
|
|
1070
|
-
if (!
|
|
1091
|
+
if (!isOwnerText(data) || data.v !== 2)
|
|
1071
1092
|
return;
|
|
1072
|
-
const { pid, start, store, mode } = data;
|
|
1093
|
+
const { pid, start, ns, store, mode } = data;
|
|
1073
1094
|
return {
|
|
1074
|
-
owner: { pid, start, store },
|
|
1095
|
+
owner: { pid, start, ns: ns ?? null, store },
|
|
1075
1096
|
mode: mode === "block" ? "block" : "warn"
|
|
1076
1097
|
};
|
|
1077
1098
|
}
|
|
1078
1099
|
var OWNER_FILE = ".json";
|
|
1079
|
-
var STORE_NAME = /^([1-9][0-9]*)(?:-([0-9]+))?$/;
|
|
1100
|
+
var STORE_NAME = /^([1-9][0-9]*)(?:-([0-9]+)(?:-([0-9]+))?)?$/;
|
|
1080
1101
|
function storeTouched(store) {
|
|
1081
1102
|
const own = statSync(store).mtimeMs;
|
|
1082
1103
|
try {
|
|
@@ -1087,6 +1108,7 @@ function storeTouched(store) {
|
|
|
1087
1108
|
throw error;
|
|
1088
1109
|
}
|
|
1089
1110
|
}
|
|
1111
|
+
var UNNAMESPACED_STORE_MAX_AGE_MS = 14 * 86400000;
|
|
1090
1112
|
function sweepStores(root, now) {
|
|
1091
1113
|
const parent = join(root, "askgate");
|
|
1092
1114
|
let names;
|
|
@@ -1101,15 +1123,42 @@ function sweepStores(root, now) {
|
|
|
1101
1123
|
continue;
|
|
1102
1124
|
const store = join(parent, name);
|
|
1103
1125
|
try {
|
|
1104
|
-
|
|
1126
|
+
const owner = { pid: Number(match[1]), start: match[2] ?? null, ns: match[3] ?? null, store };
|
|
1127
|
+
if (ownerLive(owner, now))
|
|
1105
1128
|
continue;
|
|
1106
|
-
|
|
1129
|
+
const unnamespaced = owner.start !== null && owner.ns === null;
|
|
1130
|
+
const keep = unnamespaced ? UNNAMESPACED_STORE_MAX_AGE_MS : MARKER_MAX_AGE_MS;
|
|
1131
|
+
if (now - storeTouched(store) <= keep)
|
|
1107
1132
|
continue;
|
|
1108
1133
|
rmSync(store, { recursive: true, force: true });
|
|
1109
1134
|
} catch {}
|
|
1110
1135
|
}
|
|
1111
1136
|
}
|
|
1112
|
-
function
|
|
1137
|
+
function recordNamesStore(dir) {
|
|
1138
|
+
const record = join(dir, ASKGATE_RECORD);
|
|
1139
|
+
let names;
|
|
1140
|
+
try {
|
|
1141
|
+
names = readdirSync(record);
|
|
1142
|
+
} catch (error) {
|
|
1143
|
+
return !hasErrnoCode(error, "ENOENT");
|
|
1144
|
+
}
|
|
1145
|
+
for (const name of names) {
|
|
1146
|
+
if (!name.endsWith(OWNER_FILE))
|
|
1147
|
+
continue;
|
|
1148
|
+
try {
|
|
1149
|
+
const parsed = parseOwner(readFileSync(join(record, name), "utf-8"));
|
|
1150
|
+
if (parsed === undefined)
|
|
1151
|
+
return true;
|
|
1152
|
+
statSync(parsed.owner.store);
|
|
1153
|
+
return true;
|
|
1154
|
+
} catch (error) {
|
|
1155
|
+
if (!hasErrnoCode(error, "ENOENT"))
|
|
1156
|
+
return true;
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
return false;
|
|
1160
|
+
}
|
|
1161
|
+
function askgateState(dir, now = Date.now()) {
|
|
1113
1162
|
const record = join(dir, ASKGATE_RECORD);
|
|
1114
1163
|
let names;
|
|
1115
1164
|
try {
|
|
@@ -1135,8 +1184,9 @@ function askgateState(dir) {
|
|
|
1135
1184
|
const parsed = parseOwner(text);
|
|
1136
1185
|
if (parsed === undefined)
|
|
1137
1186
|
return { kind: "broken", problem: `${file}, is not an AskGate record` };
|
|
1138
|
-
if (ownerLive(parsed.owner))
|
|
1187
|
+
if (ownerLive(parsed.owner, now)) {
|
|
1139
1188
|
live.push({ file, store: parsed.owner.store, mode: parsed.mode });
|
|
1189
|
+
}
|
|
1140
1190
|
}
|
|
1141
1191
|
if (live.length === 0)
|
|
1142
1192
|
return { kind: "off" };
|
|
@@ -18972,7 +19022,7 @@ function dispatchRefFromUrl(value, serverUrl) {
|
|
|
18972
19022
|
const id = url.hash.startsWith("#b-") ? decodeBlockId(url.hash.slice(3)) : undefined;
|
|
18973
19023
|
return id === undefined || versionName !== undefined && url.searchParams.get(versionName) ? "" : `#b-${encodeBlockId(id)}`;
|
|
18974
19024
|
};
|
|
18975
|
-
const issuePage = url.pathname.match(/^\/issues\/([A-Z][A-Z0-9]{1,9}-[1-9][0-9]*)(?:\/(spec|log|conversation|activity|children)|\/artifacts\/([^/]+)|\/asks\/([^/]+)|\/comments\/([^/]+)|\/messages\/([^/]+))?\/?$/);
|
|
19025
|
+
const issuePage = url.pathname.match(/^\/issues\/([A-Z][A-Z0-9]{1,9}-[1-9][0-9]*)(?:\/(spec|log|conversation|activity|children|decisions)|\/artifacts\/([^/]+)|\/asks\/([^/]+)|\/comments\/([^/]+)|\/messages\/([^/]+))?\/?$/);
|
|
18976
19026
|
if (issuePage) {
|
|
18977
19027
|
const [, key = "", page, artifact, ask, comment, message] = issuePage;
|
|
18978
19028
|
const version = versionOf("v");
|
|
@@ -18987,6 +19037,8 @@ function dispatchRefFromUrl(value, serverUrl) {
|
|
|
18987
19037
|
return `dispatch://${key}/artifact/spec${version}`;
|
|
18988
19038
|
if (page === "spec")
|
|
18989
19039
|
return `dispatch://${key}/spec${blockOf("v")}`;
|
|
19040
|
+
if (page === "decisions")
|
|
19041
|
+
return `dispatch://${key}/artifact/decisions-md`;
|
|
18990
19042
|
if (page !== undefined)
|
|
18991
19043
|
return `dispatch://${key}/${page === "conversation" ? "log" : page}`;
|
|
18992
19044
|
if (artifact !== undefined) {
|
|
@@ -21491,7 +21543,8 @@ function pruneSessions(root, now) {
|
|
|
21491
21543
|
continue;
|
|
21492
21544
|
const dir = join3(sessions, entry.name);
|
|
21493
21545
|
try {
|
|
21494
|
-
|
|
21546
|
+
const idle = now - statSync2(dir).mtimeMs > IDLE_SESSION_MS;
|
|
21547
|
+
if (idle && askgateState(dir, now).kind === "off" && !recordNamesStore(dir)) {
|
|
21495
21548
|
rmSync3(dir, { recursive: true, force: true });
|
|
21496
21549
|
}
|
|
21497
21550
|
} catch (error) {
|
|
@@ -21513,7 +21566,7 @@ import {
|
|
|
21513
21566
|
mkdtempSync,
|
|
21514
21567
|
openSync as openSync3,
|
|
21515
21568
|
readFileSync as readFileSync4,
|
|
21516
|
-
readlinkSync,
|
|
21569
|
+
readlinkSync as readlinkSync2,
|
|
21517
21570
|
rmSync as rmSync4,
|
|
21518
21571
|
statSync as statSync3
|
|
21519
21572
|
} from "fs";
|
|
@@ -21740,7 +21793,7 @@ function describeSchemaIssue(filePath, error) {
|
|
|
21740
21793
|
}
|
|
21741
21794
|
function danglingLink(filePath) {
|
|
21742
21795
|
try {
|
|
21743
|
-
return lstatSync(filePath).isSymbolicLink() ?
|
|
21796
|
+
return lstatSync(filePath).isSymbolicLink() ? readlinkSync2(filePath) : null;
|
|
21744
21797
|
} catch {
|
|
21745
21798
|
return null;
|
|
21746
21799
|
}
|
package/dist/envoy.js
CHANGED
|
@@ -30997,10 +30997,12 @@ import {
|
|
|
30997
30997
|
openSync,
|
|
30998
30998
|
readdirSync,
|
|
30999
30999
|
readFileSync,
|
|
31000
|
+
readlinkSync,
|
|
31000
31001
|
renameSync,
|
|
31001
31002
|
rmSync,
|
|
31002
31003
|
statSync,
|
|
31003
31004
|
unlinkSync,
|
|
31005
|
+
utimesSync,
|
|
31004
31006
|
writeFileSync
|
|
31005
31007
|
} from "fs";
|
|
31006
31008
|
import { isAbsolute, join, resolve } from "path";
|
|
@@ -31016,6 +31018,7 @@ function hasErrnoCode(error, code) {
|
|
|
31016
31018
|
// ../envoy-client/src/askgate-marker.ts
|
|
31017
31019
|
var ASKGATE_RECORD = "askgate";
|
|
31018
31020
|
var MARKER_MAX_AGE_MS = 2 * 60 * 60000;
|
|
31021
|
+
var STORE_BEAT_MS = 10 * 60000;
|
|
31019
31022
|
var PRIVATE_DIR = 448;
|
|
31020
31023
|
var PRIVATE_FILE = 384;
|
|
31021
31024
|
var MARKERS = "markers";
|
|
@@ -31082,17 +31085,38 @@ function processStart(pid) {
|
|
|
31082
31085
|
return null;
|
|
31083
31086
|
}
|
|
31084
31087
|
}
|
|
31085
|
-
|
|
31086
|
-
|
|
31088
|
+
var ownNamespace;
|
|
31089
|
+
function pidNamespace() {
|
|
31090
|
+
if (ownNamespace === undefined) {
|
|
31091
|
+
try {
|
|
31092
|
+
ownNamespace = /^pid:\[([0-9]+)\]$/.exec(readlinkSync("/proc/self/ns/pid"))?.[1] ?? null;
|
|
31093
|
+
} catch {
|
|
31094
|
+
ownNamespace = null;
|
|
31095
|
+
}
|
|
31096
|
+
}
|
|
31097
|
+
return ownNamespace;
|
|
31098
|
+
}
|
|
31099
|
+
function ownerName({ pid, start, ns }) {
|
|
31100
|
+
if (start === null)
|
|
31101
|
+
return String(pid);
|
|
31102
|
+
return ns === null ? `${pid}-${start}` : `${pid}-${start}-${ns}`;
|
|
31087
31103
|
}
|
|
31088
|
-
function askgateStore(root, pid, start) {
|
|
31089
|
-
return join(root, "askgate", ownerName(pid, start));
|
|
31104
|
+
function askgateStore(root, pid, start, ns = null) {
|
|
31105
|
+
return join(root, "askgate", ownerName({ pid, start, ns }));
|
|
31090
31106
|
}
|
|
31091
31107
|
function selfOwner(root) {
|
|
31092
31108
|
const start = processStart(process.pid);
|
|
31093
|
-
|
|
31109
|
+
const ns = pidNamespace();
|
|
31110
|
+
return { pid: process.pid, start, ns, store: askgateStore(root, process.pid, start, ns) };
|
|
31094
31111
|
}
|
|
31095
|
-
function ownerLive(owner) {
|
|
31112
|
+
function ownerLive(owner, now) {
|
|
31113
|
+
if (owner.ns !== null && owner.ns !== pidNamespace()) {
|
|
31114
|
+
try {
|
|
31115
|
+
return now - storeTouched(owner.store) <= MARKER_MAX_AGE_MS;
|
|
31116
|
+
} catch {
|
|
31117
|
+
return false;
|
|
31118
|
+
}
|
|
31119
|
+
}
|
|
31096
31120
|
if (owner.start !== null)
|
|
31097
31121
|
return processStart(owner.pid) === owner.start;
|
|
31098
31122
|
try {
|
|
@@ -31102,11 +31126,11 @@ function ownerLive(owner) {
|
|
|
31102
31126
|
return !hasErrnoCode(error, "ESRCH");
|
|
31103
31127
|
}
|
|
31104
31128
|
}
|
|
31105
|
-
function
|
|
31129
|
+
function isOwnerText(value) {
|
|
31106
31130
|
if (typeof value !== "object" || value === null)
|
|
31107
31131
|
return false;
|
|
31108
|
-
const { pid, start, store } = value;
|
|
31109
|
-
return typeof pid === "number" && Number.isSafeInteger(pid) && pid > 0 && (start === null || typeof start === "string") && typeof store === "string" && store.startsWith("/");
|
|
31132
|
+
const { pid, start, ns, store } = value;
|
|
31133
|
+
return typeof pid === "number" && Number.isSafeInteger(pid) && pid > 0 && (start === null || typeof start === "string") && (ns === undefined || ns === null || typeof ns === "string" && /^[0-9]+$/.test(ns)) && typeof store === "string" && store.startsWith("/");
|
|
31110
31134
|
}
|
|
31111
31135
|
function parseOwner(text) {
|
|
31112
31136
|
let data;
|
|
@@ -31115,11 +31139,11 @@ function parseOwner(text) {
|
|
|
31115
31139
|
} catch {
|
|
31116
31140
|
return;
|
|
31117
31141
|
}
|
|
31118
|
-
if (!
|
|
31142
|
+
if (!isOwnerText(data) || data.v !== 2)
|
|
31119
31143
|
return;
|
|
31120
|
-
const { pid, start, store, mode } = data;
|
|
31144
|
+
const { pid, start, ns, store, mode } = data;
|
|
31121
31145
|
return {
|
|
31122
|
-
owner: { pid, start, store },
|
|
31146
|
+
owner: { pid, start, ns: ns ?? null, store },
|
|
31123
31147
|
mode: mode === "block" ? "block" : "warn"
|
|
31124
31148
|
};
|
|
31125
31149
|
}
|
|
@@ -31130,9 +31154,10 @@ function writeAtomically(file, text) {
|
|
|
31130
31154
|
}
|
|
31131
31155
|
var OWNER_FILE = ".json";
|
|
31132
31156
|
function ownerFile(dir, owner) {
|
|
31133
|
-
return join(dir, ASKGATE_RECORD, `${ownerName(owner
|
|
31157
|
+
return join(dir, ASKGATE_RECORD, `${ownerName(owner)}${OWNER_FILE}`);
|
|
31134
31158
|
}
|
|
31135
|
-
function writeAskgateRecord(dir, owner, mode) {
|
|
31159
|
+
function writeAskgateRecord(dir, owner, mode, now = Date.now()) {
|
|
31160
|
+
keepStore(owner.store, now);
|
|
31136
31161
|
const record = join(dir, ASKGATE_RECORD);
|
|
31137
31162
|
mkdirSync(record, { recursive: true, mode: PRIVATE_DIR });
|
|
31138
31163
|
const own = ownerFile(dir, owner);
|
|
@@ -31147,12 +31172,15 @@ function writeAskgateRecord(dir, owner, mode) {
|
|
|
31147
31172
|
} catch {
|
|
31148
31173
|
continue;
|
|
31149
31174
|
}
|
|
31150
|
-
|
|
31175
|
+
const gone = other !== undefined && other.owner.start !== null && other.owner.ns !== null && other.owner.ns === pidNamespace() && !ownerLive(other.owner, now);
|
|
31176
|
+
if (gone) {
|
|
31151
31177
|
rmSync(file, { force: true });
|
|
31152
31178
|
}
|
|
31153
31179
|
}
|
|
31154
31180
|
}
|
|
31155
|
-
function setRecordMode(dir, owner, mode) {
|
|
31181
|
+
function setRecordMode(dir, owner, mode, now = Date.now()) {
|
|
31182
|
+
keepStore(owner.store, now);
|
|
31183
|
+
mkdirSync(join(dir, ASKGATE_RECORD), { recursive: true, mode: PRIVATE_DIR });
|
|
31156
31184
|
writeAtomically(ownerFile(dir, owner), ownerText(owner, mode));
|
|
31157
31185
|
}
|
|
31158
31186
|
function recordedOwnerMode(dir, owner) {
|
|
@@ -31163,7 +31191,8 @@ function recordedOwnerMode(dir, owner) {
|
|
|
31163
31191
|
}
|
|
31164
31192
|
}
|
|
31165
31193
|
function ownerText(owner, mode) {
|
|
31166
|
-
|
|
31194
|
+
const { pid, start, ns, store } = owner;
|
|
31195
|
+
return JSON.stringify({ v: 2, pid, start, ns, store, mode });
|
|
31167
31196
|
}
|
|
31168
31197
|
function dropAskgateRecord(dir, owner) {
|
|
31169
31198
|
rmSync(ownerFile(dir, owner), { force: true });
|
|
@@ -31171,9 +31200,25 @@ function dropAskgateRecord(dir, owner) {
|
|
|
31171
31200
|
function openStore(store) {
|
|
31172
31201
|
mkdirSync(join(store, MARKERS), { recursive: true, mode: PRIVATE_DIR });
|
|
31173
31202
|
}
|
|
31203
|
+
function keepStore(store, now) {
|
|
31204
|
+
openStore(store);
|
|
31205
|
+
const at = new Date(now);
|
|
31206
|
+
utimesSync(store, at, at);
|
|
31207
|
+
}
|
|
31174
31208
|
function closeStore(store) {
|
|
31175
31209
|
rmSync(store, { recursive: true, force: true });
|
|
31176
31210
|
}
|
|
31211
|
+
function storeTouched(store) {
|
|
31212
|
+
const own = statSync(store).mtimeMs;
|
|
31213
|
+
try {
|
|
31214
|
+
return Math.max(own, statSync(join(store, MARKERS)).mtimeMs);
|
|
31215
|
+
} catch (error) {
|
|
31216
|
+
if (hasErrnoCode(error, "ENOENT"))
|
|
31217
|
+
return own;
|
|
31218
|
+
throw error;
|
|
31219
|
+
}
|
|
31220
|
+
}
|
|
31221
|
+
var UNNAMESPACED_STORE_MAX_AGE_MS = 14 * 86400000;
|
|
31177
31222
|
function sweepMarkers(dir, now) {
|
|
31178
31223
|
for (const name of readdirSync(dir)) {
|
|
31179
31224
|
const file = join(dir, name);
|
|
@@ -33881,7 +33926,7 @@ import {
|
|
|
33881
33926
|
mkdtempSync,
|
|
33882
33927
|
openSync as openSync2,
|
|
33883
33928
|
readFileSync as readFileSync3,
|
|
33884
|
-
readlinkSync,
|
|
33929
|
+
readlinkSync as readlinkSync2,
|
|
33885
33930
|
rmSync as rmSync2,
|
|
33886
33931
|
statSync as statSync2
|
|
33887
33932
|
} from "fs";
|
|
@@ -34108,7 +34153,7 @@ function describeSchemaIssue(filePath, error) {
|
|
|
34108
34153
|
}
|
|
34109
34154
|
function danglingLink(filePath) {
|
|
34110
34155
|
try {
|
|
34111
|
-
return lstatSync(filePath).isSymbolicLink() ?
|
|
34156
|
+
return lstatSync(filePath).isSymbolicLink() ? readlinkSync2(filePath) : null;
|
|
34112
34157
|
} catch {
|
|
34113
34158
|
return null;
|
|
34114
34159
|
}
|
|
@@ -36927,7 +36972,7 @@ function dispatchRefFromUrl(value, serverUrl) {
|
|
|
36927
36972
|
const id = url.hash.startsWith("#b-") ? decodeBlockId(url.hash.slice(3)) : undefined;
|
|
36928
36973
|
return id === undefined || versionName !== undefined && url.searchParams.get(versionName) ? "" : `#b-${encodeBlockId(id)}`;
|
|
36929
36974
|
};
|
|
36930
|
-
const issuePage = url.pathname.match(/^\/issues\/([A-Z][A-Z0-9]{1,9}-[1-9][0-9]*)(?:\/(spec|log|conversation|activity|children)|\/artifacts\/([^/]+)|\/asks\/([^/]+)|\/comments\/([^/]+)|\/messages\/([^/]+))?\/?$/);
|
|
36975
|
+
const issuePage = url.pathname.match(/^\/issues\/([A-Z][A-Z0-9]{1,9}-[1-9][0-9]*)(?:\/(spec|log|conversation|activity|children|decisions)|\/artifacts\/([^/]+)|\/asks\/([^/]+)|\/comments\/([^/]+)|\/messages\/([^/]+))?\/?$/);
|
|
36931
36976
|
if (issuePage) {
|
|
36932
36977
|
const [, key = "", page, artifact, ask, comment, message] = issuePage;
|
|
36933
36978
|
const version = versionOf("v");
|
|
@@ -36942,6 +36987,8 @@ function dispatchRefFromUrl(value, serverUrl) {
|
|
|
36942
36987
|
return `dispatch://${key}/artifact/spec${version}`;
|
|
36943
36988
|
if (page === "spec")
|
|
36944
36989
|
return `dispatch://${key}/spec${blockOf("v")}`;
|
|
36990
|
+
if (page === "decisions")
|
|
36991
|
+
return `dispatch://${key}/artifact/decisions-md`;
|
|
36945
36992
|
if (page !== undefined)
|
|
36946
36993
|
return `dispatch://${key}/${page === "conversation" ? "log" : page}`;
|
|
36947
36994
|
if (artifact !== undefined) {
|
|
@@ -38280,7 +38327,7 @@ var import_nats2 = __toESM(require_mod4(), 1);
|
|
|
38280
38327
|
|
|
38281
38328
|
// package.json
|
|
38282
38329
|
var name = "@sjawhar/pi-envoy";
|
|
38283
|
-
var version2 = "15.
|
|
38330
|
+
var version2 = "15.6.1";
|
|
38284
38331
|
var package_default = {
|
|
38285
38332
|
name,
|
|
38286
38333
|
version: version2,
|
|
@@ -44138,6 +44185,7 @@ function envoyExtension(pi) {
|
|
|
44138
44185
|
}
|
|
44139
44186
|
const askgateOwner = askgateFile === null ? undefined : selfOwner(sessionStateRoot(process.env));
|
|
44140
44187
|
const askgateRecords = new Set;
|
|
44188
|
+
let askgateBeat;
|
|
44141
44189
|
const serverClock = new ServerClock(() => Date.now());
|
|
44142
44190
|
const active = envoy.enabled ? {
|
|
44143
44191
|
settings: envoy,
|
|
@@ -44287,10 +44335,20 @@ function envoyExtension(pi) {
|
|
|
44287
44335
|
if (askgateOwner !== undefined) {
|
|
44288
44336
|
const dir = sessionDirectory(process.env, id);
|
|
44289
44337
|
try {
|
|
44290
|
-
openStore(askgateOwner.store);
|
|
44291
44338
|
const recorded = recordedOwnerMode(dir, askgateOwner);
|
|
44292
44339
|
writeAskgateRecord(dir, askgateOwner, process.env.OMP_ASKGATE?.trim() === "block" || recorded === "block" ? "block" : "warn");
|
|
44293
44340
|
askgateRecords.add(dir);
|
|
44341
|
+
if (askgateBeat === undefined) {
|
|
44342
|
+
const { store } = askgateOwner;
|
|
44343
|
+
askgateBeat = setInterval(() => {
|
|
44344
|
+
try {
|
|
44345
|
+
keepStore(store, Date.now());
|
|
44346
|
+
} catch (error) {
|
|
44347
|
+
logger3.warn(`AskGate could not touch its marker store ${store}: ${messageFor(error)}`);
|
|
44348
|
+
}
|
|
44349
|
+
}, STORE_BEAT_MS);
|
|
44350
|
+
askgateBeat.unref();
|
|
44351
|
+
}
|
|
44294
44352
|
} catch (error) {
|
|
44295
44353
|
const notice = `AskGate could not write its record for session ${id} (${messageFor(error)}), so the dispatch CLI does not ask for AskGate's marker there: a Dispatch write AskGate cannot read posts unreviewed.`;
|
|
44296
44354
|
logger3.warn(notice);
|
|
@@ -45660,6 +45718,8 @@ ${REPLAYED_BTW_NOTE}`, frame.envelope, "inert");
|
|
|
45660
45718
|
} catch {}
|
|
45661
45719
|
}
|
|
45662
45720
|
askgateRecords.clear();
|
|
45721
|
+
clearInterval(askgateBeat);
|
|
45722
|
+
askgateBeat = undefined;
|
|
45663
45723
|
closeStore(askgateOwner.store);
|
|
45664
45724
|
}
|
|
45665
45725
|
const deadline = Promise.withResolvers();
|