@open-artifacts/bus 0.154.0 → 0.156.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/oa-bus.ts +1 -1
- package/assets/openclaw/index.js +1 -1
- package/assets/openclaw/package.json +1 -1
- package/dist/index.js +748 -336
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5097,7 +5097,7 @@ var init_az = __esm({
|
|
|
5097
5097
|
});
|
|
5098
5098
|
|
|
5099
5099
|
// ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/locales/be.js
|
|
5100
|
-
function getBelarusianPlural(count,
|
|
5100
|
+
function getBelarusianPlural(count, one3, few, many) {
|
|
5101
5101
|
const absCount = Math.abs(count);
|
|
5102
5102
|
const lastDigit = absCount % 10;
|
|
5103
5103
|
const lastTwoDigits = absCount % 100;
|
|
@@ -5105,7 +5105,7 @@ function getBelarusianPlural(count, one2, few, many) {
|
|
|
5105
5105
|
return many;
|
|
5106
5106
|
}
|
|
5107
5107
|
if (lastDigit === 1) {
|
|
5108
|
-
return
|
|
5108
|
+
return one3;
|
|
5109
5109
|
}
|
|
5110
5110
|
if (lastDigit >= 2 && lastDigit <= 4) {
|
|
5111
5111
|
return few;
|
|
@@ -7871,8 +7871,8 @@ var init_hu = __esm({
|
|
|
7871
7871
|
});
|
|
7872
7872
|
|
|
7873
7873
|
// ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/locales/hy.js
|
|
7874
|
-
function getArmenianPlural(count,
|
|
7875
|
-
return Math.abs(count) === 1 ?
|
|
7874
|
+
function getArmenianPlural(count, one3, many) {
|
|
7875
|
+
return Math.abs(count) === 1 ? one3 : many;
|
|
7876
7876
|
}
|
|
7877
7877
|
function withDefiniteArticle(word) {
|
|
7878
7878
|
if (!word)
|
|
@@ -10747,7 +10747,7 @@ var init_ro = __esm({
|
|
|
10747
10747
|
});
|
|
10748
10748
|
|
|
10749
10749
|
// ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/locales/ru.js
|
|
10750
|
-
function getRussianPlural(count,
|
|
10750
|
+
function getRussianPlural(count, one3, few, many) {
|
|
10751
10751
|
const absCount = Math.abs(count);
|
|
10752
10752
|
const lastDigit = absCount % 10;
|
|
10753
10753
|
const lastTwoDigits = absCount % 100;
|
|
@@ -10755,7 +10755,7 @@ function getRussianPlural(count, one2, few, many) {
|
|
|
10755
10755
|
return many;
|
|
10756
10756
|
}
|
|
10757
10757
|
if (lastDigit === 1) {
|
|
10758
|
-
return
|
|
10758
|
+
return one3;
|
|
10759
10759
|
}
|
|
10760
10760
|
if (lastDigit >= 2 && lastDigit <= 4) {
|
|
10761
10761
|
return few;
|
|
@@ -19926,7 +19926,7 @@ function visit(schema, fnOrHandlers) {
|
|
|
19926
19926
|
return h ? h(node2, rewritten) : node2;
|
|
19927
19927
|
};
|
|
19928
19928
|
const cache = /* @__PURE__ */ new Map();
|
|
19929
|
-
function
|
|
19929
|
+
function run5(s) {
|
|
19930
19930
|
const cached2 = cache.get(s);
|
|
19931
19931
|
if (cached2 === RESOLVING) {
|
|
19932
19932
|
return new $ZodLazy({
|
|
@@ -19952,21 +19952,21 @@ function visit(schema, fnOrHandlers) {
|
|
|
19952
19952
|
let changed = false;
|
|
19953
19953
|
const newShape = {};
|
|
19954
19954
|
for (const k of keys) {
|
|
19955
|
-
const mapped =
|
|
19955
|
+
const mapped = run5(oldShape[k]);
|
|
19956
19956
|
if (mapped !== oldShape[k])
|
|
19957
19957
|
changed = true;
|
|
19958
19958
|
newShape[k] = mapped;
|
|
19959
19959
|
}
|
|
19960
19960
|
let newCatchall = def.catchall;
|
|
19961
19961
|
if (def.catchall) {
|
|
19962
|
-
newCatchall =
|
|
19962
|
+
newCatchall = run5(def.catchall);
|
|
19963
19963
|
if (newCatchall !== def.catchall)
|
|
19964
19964
|
changed = true;
|
|
19965
19965
|
}
|
|
19966
19966
|
return changed ? clone(s, { ...def, shape: newShape, catchall: newCatchall }) : s;
|
|
19967
19967
|
}
|
|
19968
19968
|
case "array": {
|
|
19969
|
-
const mapped =
|
|
19969
|
+
const mapped = run5(def.element);
|
|
19970
19970
|
return mapped === def.element ? s : clone(s, { ...def, element: mapped });
|
|
19971
19971
|
}
|
|
19972
19972
|
case "tuple": {
|
|
@@ -19974,14 +19974,14 @@ function visit(schema, fnOrHandlers) {
|
|
|
19974
19974
|
let changed = false;
|
|
19975
19975
|
const newItems = [];
|
|
19976
19976
|
for (const item of oldItems) {
|
|
19977
|
-
const mapped =
|
|
19977
|
+
const mapped = run5(item);
|
|
19978
19978
|
if (mapped !== item)
|
|
19979
19979
|
changed = true;
|
|
19980
19980
|
newItems.push(mapped);
|
|
19981
19981
|
}
|
|
19982
19982
|
let newRest = def.rest;
|
|
19983
19983
|
if (def.rest) {
|
|
19984
|
-
newRest =
|
|
19984
|
+
newRest = run5(def.rest);
|
|
19985
19985
|
if (newRest !== def.rest)
|
|
19986
19986
|
changed = true;
|
|
19987
19987
|
}
|
|
@@ -19989,12 +19989,12 @@ function visit(schema, fnOrHandlers) {
|
|
|
19989
19989
|
}
|
|
19990
19990
|
case "record":
|
|
19991
19991
|
case "map": {
|
|
19992
|
-
const newKey =
|
|
19993
|
-
const newVal =
|
|
19992
|
+
const newKey = run5(def.keyType);
|
|
19993
|
+
const newVal = run5(def.valueType);
|
|
19994
19994
|
return newKey === def.keyType && newVal === def.valueType ? s : clone(s, { ...def, keyType: newKey, valueType: newVal });
|
|
19995
19995
|
}
|
|
19996
19996
|
case "set": {
|
|
19997
|
-
const newVal =
|
|
19997
|
+
const newVal = run5(def.valueType);
|
|
19998
19998
|
return newVal === def.valueType ? s : clone(s, { ...def, valueType: newVal });
|
|
19999
19999
|
}
|
|
20000
20000
|
case "union": {
|
|
@@ -20002,7 +20002,7 @@ function visit(schema, fnOrHandlers) {
|
|
|
20002
20002
|
let changed = false;
|
|
20003
20003
|
const newOptions = [];
|
|
20004
20004
|
for (const opt of oldOptions) {
|
|
20005
|
-
const mapped =
|
|
20005
|
+
const mapped = run5(opt);
|
|
20006
20006
|
if (mapped !== opt)
|
|
20007
20007
|
changed = true;
|
|
20008
20008
|
newOptions.push(mapped);
|
|
@@ -20010,8 +20010,8 @@ function visit(schema, fnOrHandlers) {
|
|
|
20010
20010
|
return changed ? clone(s, { ...def, options: newOptions }) : s;
|
|
20011
20011
|
}
|
|
20012
20012
|
case "intersection": {
|
|
20013
|
-
const newLeft =
|
|
20014
|
-
const newRight =
|
|
20013
|
+
const newLeft = run5(def.left);
|
|
20014
|
+
const newRight = run5(def.right);
|
|
20015
20015
|
return newLeft === def.left && newRight === def.right ? s : clone(s, { ...def, left: newLeft, right: newRight });
|
|
20016
20016
|
}
|
|
20017
20017
|
case "optional":
|
|
@@ -20023,23 +20023,23 @@ function visit(schema, fnOrHandlers) {
|
|
|
20023
20023
|
case "nonoptional":
|
|
20024
20024
|
case "promise":
|
|
20025
20025
|
case "success": {
|
|
20026
|
-
const newInner =
|
|
20026
|
+
const newInner = run5(def.innerType);
|
|
20027
20027
|
return newInner === def.innerType ? s : clone(s, { ...def, innerType: newInner });
|
|
20028
20028
|
}
|
|
20029
20029
|
case "pipe": {
|
|
20030
|
-
const newIn =
|
|
20031
|
-
const newOut =
|
|
20030
|
+
const newIn = run5(def.in);
|
|
20031
|
+
const newOut = run5(def.out);
|
|
20032
20032
|
return newIn === def.in && newOut === def.out ? s : clone(s, { ...def, in: newIn, out: newOut });
|
|
20033
20033
|
}
|
|
20034
20034
|
case "function": {
|
|
20035
|
-
const newInput =
|
|
20036
|
-
const newOutput =
|
|
20035
|
+
const newInput = run5(def.input);
|
|
20036
|
+
const newOutput = run5(def.output);
|
|
20037
20037
|
return newInput === def.input && newOutput === def.output ? s : clone(s, { ...def, input: newInput, output: newOutput });
|
|
20038
20038
|
}
|
|
20039
20039
|
case "lazy": {
|
|
20040
20040
|
const original = def.getter;
|
|
20041
20041
|
const { _cachedInner, ...rest } = def;
|
|
20042
|
-
return clone(s, { ...rest, getter: () =>
|
|
20042
|
+
return clone(s, { ...rest, getter: () => run5(original()) });
|
|
20043
20043
|
}
|
|
20044
20044
|
// A leaf by choice: `parts` are regex fragments, not data positions.
|
|
20045
20045
|
case "template_literal":
|
|
@@ -20070,7 +20070,7 @@ function visit(schema, fnOrHandlers) {
|
|
|
20070
20070
|
}
|
|
20071
20071
|
}
|
|
20072
20072
|
}
|
|
20073
|
-
return
|
|
20073
|
+
return run5(schema);
|
|
20074
20074
|
}
|
|
20075
20075
|
var RESOLVING;
|
|
20076
20076
|
var init_visit = __esm({
|
|
@@ -21392,8 +21392,8 @@ var init_protocol = __esm({
|
|
|
21392
21392
|
closed: external_exports.array(AgentRefSchema).max(LIMITS.maxRosterAgents)
|
|
21393
21393
|
}).refine((f) => {
|
|
21394
21394
|
if (!distinct(f.open) || !distinct(f.closed)) return false;
|
|
21395
|
-
const
|
|
21396
|
-
return !f.closed.some((r) =>
|
|
21395
|
+
const open3 = new Set(f.open);
|
|
21396
|
+
return !f.closed.some((r) => open3.has(r));
|
|
21397
21397
|
}, "duplicate or overlapping session refs");
|
|
21398
21398
|
Send = external_exports.strictObject({
|
|
21399
21399
|
...base,
|
|
@@ -21764,7 +21764,7 @@ var init_frames = __esm({
|
|
|
21764
21764
|
late = { late: external_exports.array(external_exports.string().min(1)).optional() };
|
|
21765
21765
|
isWellFormed2 = (s) => s.isWellFormed();
|
|
21766
21766
|
WELL_FORMED = { message: "text is not well-formed unicode" };
|
|
21767
|
-
CLIENT_VERSION = true ? "0.
|
|
21767
|
+
CLIENT_VERSION = true ? "0.156.0" : "0.0.0";
|
|
21768
21768
|
clientVersion = {
|
|
21769
21769
|
client_version: external_exports.string().min(1).max(64).optional()
|
|
21770
21770
|
};
|
|
@@ -22513,10 +22513,10 @@ function receiptText(r, sentTo, namespaces, excerpt, movedTo2, linkedNs) {
|
|
|
22513
22513
|
case "delivered":
|
|
22514
22514
|
return fitLine((v) => `\u2713 Delivered to ${v}.`, to);
|
|
22515
22515
|
case "expired": {
|
|
22516
|
-
const
|
|
22516
|
+
const tail2 = (v) => r.reason === "recipient_closed" ? `was not delivered because ${v} closed first.` : `was not confirmed as delivered. Mail waits at most ${RETAIN}.`;
|
|
22517
22517
|
const head = (v) => `\xD7 Expired: your message to ${v}`;
|
|
22518
|
-
if (!quote2) return fitLine((v) => `${head(v)} ${
|
|
22519
|
-
return fitLine((v) => quoted(head(v), quote2,
|
|
22518
|
+
if (!quote2) return fitLine((v) => `${head(v)} ${tail2(v)}`, to);
|
|
22519
|
+
return fitLine((v) => quoted(head(v), quote2, tail2(v)), to);
|
|
22520
22520
|
}
|
|
22521
22521
|
case "refused": {
|
|
22522
22522
|
const copy2 = r.reason ? refusals[r.reason] : void 0;
|
|
@@ -22548,10 +22548,10 @@ function movedName(to, names2) {
|
|
|
22548
22548
|
for (const name of names2) {
|
|
22549
22549
|
const l = name.toLowerCase();
|
|
22550
22550
|
if (!l.startsWith(base3)) continue;
|
|
22551
|
-
const
|
|
22552
|
-
if (!/^[0-9]+$/.test(
|
|
22553
|
-
if (Number(
|
|
22554
|
-
bestN = Number(
|
|
22551
|
+
const tail2 = l.slice(base3.length);
|
|
22552
|
+
if (!/^[0-9]+$/.test(tail2)) continue;
|
|
22553
|
+
if (Number(tail2) < bestN) {
|
|
22554
|
+
bestN = Number(tail2);
|
|
22555
22555
|
best = name;
|
|
22556
22556
|
}
|
|
22557
22557
|
}
|
|
@@ -22568,22 +22568,22 @@ function linkedLiveNamespace(name, roster2) {
|
|
|
22568
22568
|
}
|
|
22569
22569
|
function unconfirmedText(to, excerpt) {
|
|
22570
22570
|
const head = (v) => `! Unconfirmed: your message to ${v}`;
|
|
22571
|
-
const
|
|
22571
|
+
const tail2 = "may not have been delivered.";
|
|
22572
22572
|
const fixed = "\n The connection to the hub dropped while it was being sent.\n Ask the recipient whether it arrived before sending it again.";
|
|
22573
|
-
if (!excerpt) return fitLine((v) => `${head(v)} ${
|
|
22574
|
-
return fitLine((v) => `${quoted(head(v), `"${excerpt}"`,
|
|
22573
|
+
if (!excerpt) return fitLine((v) => `${head(v)} ${tail2}${fixed}`, to);
|
|
22574
|
+
return fitLine((v) => `${quoted(head(v), `"${excerpt}"`, tail2)}${fixed}`, to);
|
|
22575
22575
|
}
|
|
22576
22576
|
function correctedDeliveredText(to, excerpt) {
|
|
22577
22577
|
const head = (v) => `\u2713 Delivered after all: your message to ${v}`;
|
|
22578
|
-
const
|
|
22579
|
-
if (!excerpt) return fitLine((v) => `${head(v)} ${
|
|
22580
|
-
return fitLine((v) => quoted(head(v), `"${excerpt}"`,
|
|
22578
|
+
const tail2 = "reached it. Ignore the earlier Expired notice.";
|
|
22579
|
+
if (!excerpt) return fitLine((v) => `${head(v)} ${tail2}`, to);
|
|
22580
|
+
return fitLine((v) => quoted(head(v), `"${excerpt}"`, tail2), to);
|
|
22581
22581
|
}
|
|
22582
22582
|
function lateDeliveredText(to, excerpt) {
|
|
22583
22583
|
const head = (v) => `\u2713 Delivered: your message to ${v}`;
|
|
22584
|
-
const
|
|
22585
|
-
if (!excerpt) return fitLine((v) => `${head(v)} ${
|
|
22586
|
-
return fitLine((v) => quoted(head(v), `"${excerpt}"`,
|
|
22584
|
+
const tail2 = "was delivered after all.";
|
|
22585
|
+
if (!excerpt) return fitLine((v) => `${head(v)} ${tail2}`, to);
|
|
22586
|
+
return fitLine((v) => quoted(head(v), `"${excerpt}"`, tail2), to);
|
|
22587
22587
|
}
|
|
22588
22588
|
function cutOff(seq2) {
|
|
22589
22589
|
const bel = seq2.endsWith("\x07");
|
|
@@ -22719,15 +22719,15 @@ var init_copy = __esm({
|
|
|
22719
22719
|
"Run the oa_bus list_agents tool and message the agent you mean by name."
|
|
22720
22720
|
]
|
|
22721
22721
|
};
|
|
22722
|
-
quoted = (head, quote2,
|
|
22723
|
-
const
|
|
22724
|
-
if (
|
|
22725
|
-
${
|
|
22726
|
-
const own2 = ` ${quote2}, ${
|
|
22722
|
+
quoted = (head, quote2, tail2) => {
|
|
22723
|
+
const one3 = `${head}, ${quote2},`;
|
|
22724
|
+
if (one3.length <= MAX_COLS) return `${one3}
|
|
22725
|
+
${tail2}`;
|
|
22726
|
+
const own2 = ` ${quote2}, ${tail2}`;
|
|
22727
22727
|
return own2.length <= MAX_COLS ? `${head},
|
|
22728
22728
|
${own2}` : `${head},
|
|
22729
22729
|
${quote2},
|
|
22730
|
-
${
|
|
22730
|
+
${tail2}`;
|
|
22731
22731
|
};
|
|
22732
22732
|
TERMINAL_CONTROLS = new RegExp(
|
|
22733
22733
|
[
|
|
@@ -23029,8 +23029,8 @@ function handle(sock, opts) {
|
|
|
23029
23029
|
sock.destroy();
|
|
23030
23030
|
return;
|
|
23031
23031
|
}
|
|
23032
|
-
const
|
|
23033
|
-
if (
|
|
23032
|
+
const one3 = opts.oneRequest?.(hello) ?? false;
|
|
23033
|
+
if (one3 && served) {
|
|
23034
23034
|
send({
|
|
23035
23035
|
type: "error",
|
|
23036
23036
|
id: frame.id,
|
|
@@ -23041,7 +23041,7 @@ function handle(sock, opts) {
|
|
|
23041
23041
|
return;
|
|
23042
23042
|
}
|
|
23043
23043
|
served = true;
|
|
23044
|
-
const reply =
|
|
23044
|
+
const reply = one3 ? (f) => {
|
|
23045
23045
|
const ok = push(f);
|
|
23046
23046
|
if (f.id === frame.id) sock.end();
|
|
23047
23047
|
return ok;
|
|
@@ -23050,7 +23050,7 @@ function handle(sock, opts) {
|
|
|
23050
23050
|
const replyNow = opts.onFrame(frame, hello, reply);
|
|
23051
23051
|
if (replyNow) {
|
|
23052
23052
|
send({ ...replyNow, id: frame.id });
|
|
23053
|
-
if (
|
|
23053
|
+
if (one3) sock.end();
|
|
23054
23054
|
}
|
|
23055
23055
|
} catch (e) {
|
|
23056
23056
|
fail2(frame.id, e instanceof Error ? e.message : String(e));
|
|
@@ -26532,11 +26532,11 @@ var require_codegen = __commonJS({
|
|
|
26532
26532
|
const rhs = this.rhs === void 0 ? "" : ` = ${this.rhs}`;
|
|
26533
26533
|
return `${varKind} ${this.name}${rhs};` + _n;
|
|
26534
26534
|
}
|
|
26535
|
-
optimizeNames(names2,
|
|
26535
|
+
optimizeNames(names2, constants6) {
|
|
26536
26536
|
if (!names2[this.name.str])
|
|
26537
26537
|
return;
|
|
26538
26538
|
if (this.rhs)
|
|
26539
|
-
this.rhs = optimizeExpr(this.rhs, names2,
|
|
26539
|
+
this.rhs = optimizeExpr(this.rhs, names2, constants6);
|
|
26540
26540
|
return this;
|
|
26541
26541
|
}
|
|
26542
26542
|
get names() {
|
|
@@ -26553,10 +26553,10 @@ var require_codegen = __commonJS({
|
|
|
26553
26553
|
render({ _n }) {
|
|
26554
26554
|
return `${this.lhs} = ${this.rhs};` + _n;
|
|
26555
26555
|
}
|
|
26556
|
-
optimizeNames(names2,
|
|
26556
|
+
optimizeNames(names2, constants6) {
|
|
26557
26557
|
if (this.lhs instanceof code_1.Name && !names2[this.lhs.str] && !this.sideEffects)
|
|
26558
26558
|
return;
|
|
26559
|
-
this.rhs = optimizeExpr(this.rhs, names2,
|
|
26559
|
+
this.rhs = optimizeExpr(this.rhs, names2, constants6);
|
|
26560
26560
|
return this;
|
|
26561
26561
|
}
|
|
26562
26562
|
get names() {
|
|
@@ -26617,8 +26617,8 @@ var require_codegen = __commonJS({
|
|
|
26617
26617
|
optimizeNodes() {
|
|
26618
26618
|
return `${this.code}` ? this : void 0;
|
|
26619
26619
|
}
|
|
26620
|
-
optimizeNames(names2,
|
|
26621
|
-
this.code = optimizeExpr(this.code, names2,
|
|
26620
|
+
optimizeNames(names2, constants6) {
|
|
26621
|
+
this.code = optimizeExpr(this.code, names2, constants6);
|
|
26622
26622
|
return this;
|
|
26623
26623
|
}
|
|
26624
26624
|
get names() {
|
|
@@ -26647,12 +26647,12 @@ var require_codegen = __commonJS({
|
|
|
26647
26647
|
}
|
|
26648
26648
|
return nodes.length > 0 ? this : void 0;
|
|
26649
26649
|
}
|
|
26650
|
-
optimizeNames(names2,
|
|
26650
|
+
optimizeNames(names2, constants6) {
|
|
26651
26651
|
const { nodes } = this;
|
|
26652
26652
|
let i = nodes.length;
|
|
26653
26653
|
while (i--) {
|
|
26654
26654
|
const n = nodes[i];
|
|
26655
|
-
if (n.optimizeNames(names2,
|
|
26655
|
+
if (n.optimizeNames(names2, constants6))
|
|
26656
26656
|
continue;
|
|
26657
26657
|
subtractNames(names2, n.names);
|
|
26658
26658
|
nodes.splice(i, 1);
|
|
@@ -26705,12 +26705,12 @@ var require_codegen = __commonJS({
|
|
|
26705
26705
|
return void 0;
|
|
26706
26706
|
return this;
|
|
26707
26707
|
}
|
|
26708
|
-
optimizeNames(names2,
|
|
26708
|
+
optimizeNames(names2, constants6) {
|
|
26709
26709
|
var _a3;
|
|
26710
|
-
this.else = (_a3 = this.else) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names2,
|
|
26711
|
-
if (!(super.optimizeNames(names2,
|
|
26710
|
+
this.else = (_a3 = this.else) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names2, constants6);
|
|
26711
|
+
if (!(super.optimizeNames(names2, constants6) || this.else))
|
|
26712
26712
|
return;
|
|
26713
|
-
this.condition = optimizeExpr(this.condition, names2,
|
|
26713
|
+
this.condition = optimizeExpr(this.condition, names2, constants6);
|
|
26714
26714
|
return this;
|
|
26715
26715
|
}
|
|
26716
26716
|
get names() {
|
|
@@ -26733,10 +26733,10 @@ var require_codegen = __commonJS({
|
|
|
26733
26733
|
render(opts) {
|
|
26734
26734
|
return `for(${this.iteration})` + super.render(opts);
|
|
26735
26735
|
}
|
|
26736
|
-
optimizeNames(names2,
|
|
26737
|
-
if (!super.optimizeNames(names2,
|
|
26736
|
+
optimizeNames(names2, constants6) {
|
|
26737
|
+
if (!super.optimizeNames(names2, constants6))
|
|
26738
26738
|
return;
|
|
26739
|
-
this.iteration = optimizeExpr(this.iteration, names2,
|
|
26739
|
+
this.iteration = optimizeExpr(this.iteration, names2, constants6);
|
|
26740
26740
|
return this;
|
|
26741
26741
|
}
|
|
26742
26742
|
get names() {
|
|
@@ -26772,10 +26772,10 @@ var require_codegen = __commonJS({
|
|
|
26772
26772
|
render(opts) {
|
|
26773
26773
|
return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts);
|
|
26774
26774
|
}
|
|
26775
|
-
optimizeNames(names2,
|
|
26776
|
-
if (!super.optimizeNames(names2,
|
|
26775
|
+
optimizeNames(names2, constants6) {
|
|
26776
|
+
if (!super.optimizeNames(names2, constants6))
|
|
26777
26777
|
return;
|
|
26778
|
-
this.iterable = optimizeExpr(this.iterable, names2,
|
|
26778
|
+
this.iterable = optimizeExpr(this.iterable, names2, constants6);
|
|
26779
26779
|
return this;
|
|
26780
26780
|
}
|
|
26781
26781
|
get names() {
|
|
@@ -26817,11 +26817,11 @@ var require_codegen = __commonJS({
|
|
|
26817
26817
|
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNodes();
|
|
26818
26818
|
return this;
|
|
26819
26819
|
}
|
|
26820
|
-
optimizeNames(names2,
|
|
26820
|
+
optimizeNames(names2, constants6) {
|
|
26821
26821
|
var _a3, _b;
|
|
26822
|
-
super.optimizeNames(names2,
|
|
26823
|
-
(_a3 = this.catch) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names2,
|
|
26824
|
-
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names2,
|
|
26822
|
+
super.optimizeNames(names2, constants6);
|
|
26823
|
+
(_a3 = this.catch) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names2, constants6);
|
|
26824
|
+
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names2, constants6);
|
|
26825
26825
|
return this;
|
|
26826
26826
|
}
|
|
26827
26827
|
get names() {
|
|
@@ -27122,7 +27122,7 @@ var require_codegen = __commonJS({
|
|
|
27122
27122
|
function addExprNames(names2, from) {
|
|
27123
27123
|
return from instanceof code_1._CodeOrName ? addNames(names2, from.names) : names2;
|
|
27124
27124
|
}
|
|
27125
|
-
function optimizeExpr(expr, names2,
|
|
27125
|
+
function optimizeExpr(expr, names2, constants6) {
|
|
27126
27126
|
if (expr instanceof code_1.Name)
|
|
27127
27127
|
return replaceName(expr);
|
|
27128
27128
|
if (!canOptimize(expr))
|
|
@@ -27137,14 +27137,14 @@ var require_codegen = __commonJS({
|
|
|
27137
27137
|
return items;
|
|
27138
27138
|
}, []));
|
|
27139
27139
|
function replaceName(n) {
|
|
27140
|
-
const c =
|
|
27140
|
+
const c = constants6[n.str];
|
|
27141
27141
|
if (c === void 0 || names2[n.str] !== 1)
|
|
27142
27142
|
return n;
|
|
27143
27143
|
delete names2[n.str];
|
|
27144
27144
|
return c;
|
|
27145
27145
|
}
|
|
27146
27146
|
function canOptimize(e) {
|
|
27147
|
-
return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names2[c.str] === 1 &&
|
|
27147
|
+
return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names2[c.str] === 1 && constants6[c.str] !== void 0);
|
|
27148
27148
|
}
|
|
27149
27149
|
}
|
|
27150
27150
|
function subtractNames(names2, from) {
|
|
@@ -29313,8 +29313,8 @@ var require_utils = __commonJS({
|
|
|
29313
29313
|
}
|
|
29314
29314
|
if (bestLength < 2) return hextets.join(":");
|
|
29315
29315
|
const head = hextets.slice(0, bestStart).join(":");
|
|
29316
|
-
const
|
|
29317
|
-
return head + "::" +
|
|
29316
|
+
const tail2 = hextets.slice(bestStart + bestLength).join(":");
|
|
29317
|
+
return head + "::" + tail2;
|
|
29318
29318
|
}
|
|
29319
29319
|
function normalizeIPv6Address(input2) {
|
|
29320
29320
|
const compression = input2.indexOf("::");
|
|
@@ -34669,7 +34669,7 @@ function parseAnswer(text3, sse) {
|
|
|
34669
34669
|
}
|
|
34670
34670
|
return void 0;
|
|
34671
34671
|
}
|
|
34672
|
-
async function within(ms,
|
|
34672
|
+
async function within(ms, open3) {
|
|
34673
34673
|
const st = {};
|
|
34674
34674
|
let timer;
|
|
34675
34675
|
const cap = new Promise((res) => {
|
|
@@ -34681,7 +34681,7 @@ async function within(ms, open2) {
|
|
|
34681
34681
|
timer.unref?.();
|
|
34682
34682
|
});
|
|
34683
34683
|
try {
|
|
34684
|
-
return await Promise.race([
|
|
34684
|
+
return await Promise.race([open3(st), cap]);
|
|
34685
34685
|
} finally {
|
|
34686
34686
|
clearTimeout(timer);
|
|
34687
34687
|
}
|
|
@@ -35353,9 +35353,9 @@ var require_permessage_deflate = __commonJS({
|
|
|
35353
35353
|
* @private
|
|
35354
35354
|
*/
|
|
35355
35355
|
_decompress(data, fin, callback) {
|
|
35356
|
-
const
|
|
35356
|
+
const endpoint2 = this._isServer ? "client" : "server";
|
|
35357
35357
|
if (!this._inflate) {
|
|
35358
|
-
const key2 = `${
|
|
35358
|
+
const key2 = `${endpoint2}_max_window_bits`;
|
|
35359
35359
|
const windowBits = typeof this.params[key2] !== "number" ? zlib.Z_DEFAULT_WINDOWBITS : this.params[key2];
|
|
35360
35360
|
this._inflate = zlib.createInflateRaw({
|
|
35361
35361
|
...this._options.zlibInflateOptions,
|
|
@@ -35388,7 +35388,7 @@ var require_permessage_deflate = __commonJS({
|
|
|
35388
35388
|
} else {
|
|
35389
35389
|
this._inflate[kTotalLength] = 0;
|
|
35390
35390
|
this._inflate[kBuffers] = [];
|
|
35391
|
-
if (fin && this.params[`${
|
|
35391
|
+
if (fin && this.params[`${endpoint2}_no_context_takeover`]) {
|
|
35392
35392
|
this._inflate.reset();
|
|
35393
35393
|
}
|
|
35394
35394
|
}
|
|
@@ -35404,9 +35404,9 @@ var require_permessage_deflate = __commonJS({
|
|
|
35404
35404
|
* @private
|
|
35405
35405
|
*/
|
|
35406
35406
|
_compress(data, fin, callback) {
|
|
35407
|
-
const
|
|
35407
|
+
const endpoint2 = this._isServer ? "server" : "client";
|
|
35408
35408
|
if (!this._deflate) {
|
|
35409
|
-
const key2 = `${
|
|
35409
|
+
const key2 = `${endpoint2}_max_window_bits`;
|
|
35410
35410
|
const windowBits = typeof this.params[key2] !== "number" ? zlib.Z_DEFAULT_WINDOWBITS : this.params[key2];
|
|
35411
35411
|
this._deflate = zlib.createDeflateRaw({
|
|
35412
35412
|
...this._options.zlibDeflateOptions,
|
|
@@ -35432,7 +35432,7 @@ var require_permessage_deflate = __commonJS({
|
|
|
35432
35432
|
this._deflate[kCallback] = null;
|
|
35433
35433
|
this._deflate[kTotalLength] = 0;
|
|
35434
35434
|
this._deflate[kBuffers] = [];
|
|
35435
|
-
if (fin && this.params[`${
|
|
35435
|
+
if (fin && this.params[`${endpoint2}_no_context_takeover`]) {
|
|
35436
35436
|
this._deflate.reset();
|
|
35437
35437
|
}
|
|
35438
35438
|
callback(null, data2);
|
|
@@ -38134,7 +38134,7 @@ var require_stream = __commonJS({
|
|
|
38134
38134
|
};
|
|
38135
38135
|
duplex._final = function(callback) {
|
|
38136
38136
|
if (ws.readyState === ws.CONNECTING) {
|
|
38137
|
-
ws.once("open", function
|
|
38137
|
+
ws.once("open", function open3() {
|
|
38138
38138
|
duplex._final(callback);
|
|
38139
38139
|
});
|
|
38140
38140
|
return;
|
|
@@ -38155,7 +38155,7 @@ var require_stream = __commonJS({
|
|
|
38155
38155
|
};
|
|
38156
38156
|
duplex._write = function(chunk, encoding, callback) {
|
|
38157
38157
|
if (ws.readyState === ws.CONNECTING) {
|
|
38158
|
-
ws.once("open", function
|
|
38158
|
+
ws.once("open", function open3() {
|
|
38159
38159
|
duplex._write(chunk, encoding, callback);
|
|
38160
38160
|
});
|
|
38161
38161
|
return;
|
|
@@ -38831,16 +38831,16 @@ async function rootSession(sessionId, deps2) {
|
|
|
38831
38831
|
cur = parent;
|
|
38832
38832
|
}
|
|
38833
38833
|
}
|
|
38834
|
-
var
|
|
38834
|
+
var run3, opencodeApi, MAX_DEPTH, ROOTS;
|
|
38835
38835
|
var init_session2 = __esm({
|
|
38836
38836
|
"../bus-adapter-opencode/src/session.ts"() {
|
|
38837
38837
|
"use strict";
|
|
38838
|
-
|
|
38838
|
+
run3 = promisify2(execFile4);
|
|
38839
38839
|
opencodeApi = async (op, params) => {
|
|
38840
38840
|
const args = ["api", op];
|
|
38841
38841
|
for (const [k, v] of Object.entries(params))
|
|
38842
38842
|
args.push("--param", `${k}=${v}`);
|
|
38843
|
-
const { stdout } = await
|
|
38843
|
+
const { stdout } = await run3("opencode", args, { timeout: 15e3 });
|
|
38844
38844
|
const data = JSON.parse(stdout).data;
|
|
38845
38845
|
return data && typeof data === "object" ? data : void 0;
|
|
38846
38846
|
};
|
|
@@ -39215,13 +39215,13 @@ __export(codex_proxy_main_exports, {
|
|
|
39215
39215
|
readTokenFile: () => readTokenFile,
|
|
39216
39216
|
startCodexProxy: () => startCodexProxy
|
|
39217
39217
|
});
|
|
39218
|
-
import { readFileSync as
|
|
39218
|
+
import { readFileSync as readFileSync31 } from "node:fs";
|
|
39219
39219
|
import { homedir as homedir4 } from "node:os";
|
|
39220
39220
|
function readTokenFile(path) {
|
|
39221
39221
|
if (!path) return void 0;
|
|
39222
39222
|
try {
|
|
39223
39223
|
const p = path.startsWith("~/") ? `${homedir4()}${path.slice(1)}` : path;
|
|
39224
|
-
return
|
|
39224
|
+
return readFileSync31(p, "utf8").trim() || void 0;
|
|
39225
39225
|
} catch {
|
|
39226
39226
|
return void 0;
|
|
39227
39227
|
}
|
|
@@ -39271,13 +39271,13 @@ __export(proxy_main_exports, {
|
|
|
39271
39271
|
readTokenFile: () => readTokenFile2,
|
|
39272
39272
|
startProxy: () => startProxy
|
|
39273
39273
|
});
|
|
39274
|
-
import { readFileSync as
|
|
39274
|
+
import { readFileSync as readFileSync32 } from "node:fs";
|
|
39275
39275
|
import { homedir as homedir5 } from "node:os";
|
|
39276
39276
|
function readTokenFile2(path) {
|
|
39277
39277
|
if (!path) return void 0;
|
|
39278
39278
|
try {
|
|
39279
39279
|
const p = path.startsWith("~/") ? `${homedir5()}${path.slice(1)}` : path;
|
|
39280
|
-
return
|
|
39280
|
+
return readFileSync32(p, "utf8").trim() || void 0;
|
|
39281
39281
|
} catch {
|
|
39282
39282
|
return void 0;
|
|
39283
39283
|
}
|
|
@@ -39478,8 +39478,8 @@ function cutMiddle(value, max, more = "\u2026") {
|
|
|
39478
39478
|
const slash = value.lastIndexOf("/");
|
|
39479
39479
|
const dot = value.lastIndexOf(".", value.lastIndexOf(".") - 1);
|
|
39480
39480
|
const end = slash >= 0 ? value.slice(slash) : dot >= 0 ? value.slice(dot) : "";
|
|
39481
|
-
const
|
|
39482
|
-
return chars.slice(0, keep -
|
|
39481
|
+
const tail2 = len(end) > 0 && len(end) <= keep / 2 ? len(end) : Math.ceil(keep / 2);
|
|
39482
|
+
return chars.slice(0, keep - tail2).join("") + more + chars.slice(chars.length - tail2).join("");
|
|
39483
39483
|
}
|
|
39484
39484
|
var graphemes = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
39485
39485
|
var WIDE = /[\u1100-\u115f\u2e80-\u303e\u3041-\u33ff\u3400-\u4dbf\u4e00-\u9fff\ua000-\ua4cf\uac00-\ud7a3\uf900-\ufaff\ufe30-\ufe4f\uff00-\uff60\uffe0-\uffe6\u{20000}-\u{3fffd}]/u;
|
|
@@ -39566,8 +39566,8 @@ function copy(style, bus = BUS_CMD) {
|
|
|
39566
39566
|
*/
|
|
39567
39567
|
connected: (origin) => {
|
|
39568
39568
|
const page = `${origin}${BUS_ROUTES.page}`;
|
|
39569
|
-
const
|
|
39570
|
-
if (len(
|
|
39569
|
+
const one3 = `Connected to ${origin}. Manage machines: ${page}`;
|
|
39570
|
+
if (len(one3) + 3 <= WIDTH) return [done(one3)];
|
|
39571
39571
|
return [
|
|
39572
39572
|
done(`Connected to ${clip(origin, 17)}.`),
|
|
39573
39573
|
next(`Manage machines: ${clip(page, 20)}`)
|
|
@@ -39778,9 +39778,9 @@ function copy(style, bus = BUS_CMD) {
|
|
|
39778
39778
|
)
|
|
39779
39779
|
],
|
|
39780
39780
|
unreachableFinal: (host, attempts, error62) => {
|
|
39781
|
-
const
|
|
39781
|
+
const tail2 = `after ${attempts} attempts.`;
|
|
39782
39782
|
return [
|
|
39783
|
-
`${fail2(`Couldn't reach ${clip(host, 21 + len(
|
|
39783
|
+
`${fail2(`Couldn't reach ${clip(host, 21 + len(tail2) + len(error62))} ${tail2}`)} ${p("muted", error62)}`,
|
|
39784
39784
|
next("Check your network or the --instance URL, then try again.")
|
|
39785
39785
|
];
|
|
39786
39786
|
},
|
|
@@ -40517,7 +40517,7 @@ var AgentTable = class {
|
|
|
40517
40517
|
// ../bus-daemon/src/attest.ts
|
|
40518
40518
|
init_src3();
|
|
40519
40519
|
init_src2();
|
|
40520
|
-
import { execFileSync as
|
|
40520
|
+
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
40521
40521
|
import { basename as basename3, isAbsolute as isAbsolute2 } from "node:path";
|
|
40522
40522
|
|
|
40523
40523
|
// ../bus-daemon/src/codex-attest.ts
|
|
@@ -40733,7 +40733,9 @@ function openSessions(dir, deps2) {
|
|
|
40733
40733
|
const pid = data?.pid;
|
|
40734
40734
|
if (typeof pid !== "number" || !Number.isSafeInteger(pid) || pid <= 1)
|
|
40735
40735
|
continue;
|
|
40736
|
-
if (!Array.isArray(data.sessionIDs)
|
|
40736
|
+
if (!Array.isArray(data.sessionIDs)) continue;
|
|
40737
|
+
if (!deps2.isRunning(pid)) continue;
|
|
40738
|
+
if (deps2.accept && deps2.accept(pid) !== true) continue;
|
|
40737
40739
|
const started = deps2.procStartEpoch(pid, String(mtime));
|
|
40738
40740
|
if (started !== null && started > mtime + START_TOLERANCE_SECONDS) continue;
|
|
40739
40741
|
for (const id of data.sessionIDs) if (typeof id === "string") out.add(id);
|
|
@@ -40745,6 +40747,43 @@ function lstartEpoch(lstart) {
|
|
|
40745
40747
|
const ms = Date.parse(`${lstart} UTC`);
|
|
40746
40748
|
return Number.isNaN(ms) ? null : ms / 1e3;
|
|
40747
40749
|
}
|
|
40750
|
+
function openState(dir, deps2, ref) {
|
|
40751
|
+
let names2;
|
|
40752
|
+
try {
|
|
40753
|
+
names2 = readdirSync(dir);
|
|
40754
|
+
} catch {
|
|
40755
|
+
return null;
|
|
40756
|
+
}
|
|
40757
|
+
let unknown2 = false;
|
|
40758
|
+
for (const fn of names2) {
|
|
40759
|
+
if (!/^\d+\.json$/.test(fn)) continue;
|
|
40760
|
+
let data;
|
|
40761
|
+
let mtime;
|
|
40762
|
+
try {
|
|
40763
|
+
mtime = statSync3(join5(dir, fn)).mtimeMs / 1e3;
|
|
40764
|
+
data = JSON.parse(readFileSync4(join5(dir, fn), "utf8"));
|
|
40765
|
+
} catch (e) {
|
|
40766
|
+
if (e.code !== "ENOENT") unknown2 = true;
|
|
40767
|
+
continue;
|
|
40768
|
+
}
|
|
40769
|
+
const pid = data?.pid;
|
|
40770
|
+
if (typeof pid !== "number" || !Number.isSafeInteger(pid) || pid <= 1)
|
|
40771
|
+
continue;
|
|
40772
|
+
if (!Array.isArray(data.sessionIDs) || !data.sessionIDs.includes(ref))
|
|
40773
|
+
continue;
|
|
40774
|
+
if (!deps2.isRunning(pid)) continue;
|
|
40775
|
+
const ok = deps2.accept ? deps2.accept(pid) : true;
|
|
40776
|
+
if (ok === null) {
|
|
40777
|
+
unknown2 = true;
|
|
40778
|
+
continue;
|
|
40779
|
+
}
|
|
40780
|
+
if (!ok) continue;
|
|
40781
|
+
const started = deps2.procStartEpoch(pid, String(mtime));
|
|
40782
|
+
if (started !== null && started > mtime + START_TOLERANCE_SECONDS) continue;
|
|
40783
|
+
return true;
|
|
40784
|
+
}
|
|
40785
|
+
return unknown2 ? null : false;
|
|
40786
|
+
}
|
|
40748
40787
|
|
|
40749
40788
|
// ../bus-daemon/src/codex-attest.ts
|
|
40750
40789
|
var CODEX_TOOL_NAMESPACE = "mcp__oa_bus";
|
|
@@ -41102,7 +41141,7 @@ var TURN_ENDS = /* @__PURE__ */ new Set([
|
|
|
41102
41141
|
function visitLine(st, text3, namespaces = [CODEX_TOOL_NAMESPACE]) {
|
|
41103
41142
|
if (!/call|task_complete|turn_aborted|task_started|item_completed/.test(text3))
|
|
41104
41143
|
return;
|
|
41105
|
-
const { open:
|
|
41144
|
+
const { open: open3, execs, lookups } = st;
|
|
41106
41145
|
let line;
|
|
41107
41146
|
try {
|
|
41108
41147
|
line = record3(JSON.parse(text3));
|
|
@@ -41117,9 +41156,9 @@ function visitLine(st, text3, namespaces = [CODEX_TOOL_NAMESPACE]) {
|
|
|
41117
41156
|
}
|
|
41118
41157
|
if (line?.type === "event_msg" && TURN_ENDS.has(p.type)) {
|
|
41119
41158
|
const turn = typeof p.turn_id === "string" ? p.turn_id : void 0;
|
|
41120
|
-
for (const [id, c] of
|
|
41159
|
+
for (const [id, c] of open3)
|
|
41121
41160
|
if (turn === void 0 || c.turn === void 0 || c.turn === turn)
|
|
41122
|
-
|
|
41161
|
+
open3.delete(id);
|
|
41123
41162
|
for (const m of [execs, lookups])
|
|
41124
41163
|
for (const [id, c] of m)
|
|
41125
41164
|
if (turn === void 0 || c.turn === void 0 || c.turn === turn)
|
|
@@ -41129,7 +41168,7 @@ function visitLine(st, text3, namespaces = [CODEX_TOOL_NAMESPACE]) {
|
|
|
41129
41168
|
if (p.type === "item_completed") {
|
|
41130
41169
|
const id = record3(p.item)?.id;
|
|
41131
41170
|
if (typeof id === "string") {
|
|
41132
|
-
|
|
41171
|
+
open3.delete(id);
|
|
41133
41172
|
if (EXEC_CALL.test(id)) {
|
|
41134
41173
|
st.done.add(id);
|
|
41135
41174
|
if (st.done.size > USED_CAP)
|
|
@@ -41159,7 +41198,7 @@ function visitLine(st, text3, namespaces = [CODEX_TOOL_NAMESPACE]) {
|
|
|
41159
41198
|
const ours2 = bus || proxied;
|
|
41160
41199
|
const turn = record3(p.internal_chat_message_metadata_passthrough)?.turn_id;
|
|
41161
41200
|
if (ours2)
|
|
41162
|
-
|
|
41201
|
+
open3.set(p.call_id, {
|
|
41163
41202
|
at: Date.parse(String(line.timestamp)),
|
|
41164
41203
|
turn: typeof turn === "string" ? turn : void 0,
|
|
41165
41204
|
...proxied ? { proxied: true } : {}
|
|
@@ -41167,7 +41206,7 @@ function visitLine(st, text3, namespaces = [CODEX_TOOL_NAMESPACE]) {
|
|
|
41167
41206
|
return;
|
|
41168
41207
|
}
|
|
41169
41208
|
if (p.type.endsWith("_output") || p.type.endsWith("_end")) {
|
|
41170
|
-
|
|
41209
|
+
open3.delete(p.call_id);
|
|
41171
41210
|
for (const m of [execs, lookups])
|
|
41172
41211
|
for (const [id, e] of m) if (e.call === p.call_id) m.delete(id);
|
|
41173
41212
|
}
|
|
@@ -41521,6 +41560,187 @@ function isRunning(pid) {
|
|
|
41521
41560
|
}
|
|
41522
41561
|
}
|
|
41523
41562
|
|
|
41563
|
+
// ../bus-daemon/src/presence/attached.ts
|
|
41564
|
+
init_src2();
|
|
41565
|
+
import { execFileSync as execFileSync3, spawnSync } from "node:child_process";
|
|
41566
|
+
import { readdirSync as readdirSync4, readFileSync as readFileSync7, readlinkSync as readlinkSync2 } from "node:fs";
|
|
41567
|
+
var READ_TIMEOUT_MS = 1500;
|
|
41568
|
+
var exePath = (exe) => exe === null ? null : exe.replace(/ \(deleted\)$/, "");
|
|
41569
|
+
function attachedTo(service, deps2) {
|
|
41570
|
+
let svcExe = null;
|
|
41571
|
+
let svcSockets = null;
|
|
41572
|
+
let parent = null;
|
|
41573
|
+
return (tui) => {
|
|
41574
|
+
svcExe ??= exePath(deps2.exeOf(service));
|
|
41575
|
+
const tuiExe = exePath(deps2.exeOf(tui));
|
|
41576
|
+
if (!svcExe || !tuiExe) return null;
|
|
41577
|
+
if (tuiExe !== svcExe) return false;
|
|
41578
|
+
parent ??= deps2.ppidOf(service);
|
|
41579
|
+
if (parent === tui) return true;
|
|
41580
|
+
svcSockets ??= deps2.established(service);
|
|
41581
|
+
const mine = deps2.established(tui);
|
|
41582
|
+
if (!svcSockets || !mine) return null;
|
|
41583
|
+
const found2 = mine.some(
|
|
41584
|
+
(t) => svcSockets?.some((x) => x.remote === t.local && x.local === t.remote)
|
|
41585
|
+
);
|
|
41586
|
+
if (found2) return true;
|
|
41587
|
+
return parent === null ? null : false;
|
|
41588
|
+
};
|
|
41589
|
+
}
|
|
41590
|
+
var ATTACH_TTL_MS = 2e3;
|
|
41591
|
+
function cachedAttach(deps2, now = Date.now, ttlMs = ATTACH_TTL_MS) {
|
|
41592
|
+
const entries = /* @__PURE__ */ new Map();
|
|
41593
|
+
return (service) => (tui) => {
|
|
41594
|
+
const t = now();
|
|
41595
|
+
for (const [k, e2] of entries) if (t - e2.at >= ttlMs) entries.delete(k);
|
|
41596
|
+
let e = entries.get(service);
|
|
41597
|
+
if (!e) {
|
|
41598
|
+
e = { at: t, pred: attachedTo(service, deps2), seen: /* @__PURE__ */ new Map() };
|
|
41599
|
+
entries.set(service, e);
|
|
41600
|
+
}
|
|
41601
|
+
const hit = e.seen.get(tui);
|
|
41602
|
+
if (hit !== void 0) return hit;
|
|
41603
|
+
const r = e.pred(tui);
|
|
41604
|
+
if (r !== null) e.seen.set(tui, r);
|
|
41605
|
+
return r;
|
|
41606
|
+
};
|
|
41607
|
+
}
|
|
41608
|
+
var hexWord = (w) => (w.match(/../g) ?? []).reverse().map((b) => Number.parseInt(b, 16)).join(".");
|
|
41609
|
+
function hexAddr(hex3) {
|
|
41610
|
+
if (/^[0-9A-F]{8}$/i.test(hex3)) return hexWord(hex3);
|
|
41611
|
+
if (!/^[0-9A-F]{32}$/i.test(hex3)) return null;
|
|
41612
|
+
const words = (hex3.match(/.{8}/g) ?? []).map(
|
|
41613
|
+
(w) => (w.match(/../g) ?? []).reverse().join("")
|
|
41614
|
+
);
|
|
41615
|
+
if (words[0] === "00000000" && words[1] === "00000000" && words[2]?.toUpperCase() === "0000FFFF")
|
|
41616
|
+
return hexWord((hex3.slice(24) ?? "").toUpperCase());
|
|
41617
|
+
const groups = words.flatMap((w) => [w.slice(0, 4), w.slice(4)]);
|
|
41618
|
+
return `[${groups.map((g) => g.toLowerCase().replace(/^0+(?=.)/, "")).join(":")}]`;
|
|
41619
|
+
}
|
|
41620
|
+
function endpoint(field) {
|
|
41621
|
+
const [addr, port] = field.split(":");
|
|
41622
|
+
if (!addr || !port) return null;
|
|
41623
|
+
const a = hexAddr(addr);
|
|
41624
|
+
return a === null ? null : `${a}:${Number.parseInt(port, 16)}`;
|
|
41625
|
+
}
|
|
41626
|
+
function parseProcNetTcp(text3) {
|
|
41627
|
+
const rows = [];
|
|
41628
|
+
for (const line of text3.split("\n").slice(1)) {
|
|
41629
|
+
const f = line.trim().split(/\s+/);
|
|
41630
|
+
if (f.length < 10 || !f[1] || !f[2] || !f[3] || !f[9]) continue;
|
|
41631
|
+
const local = endpoint(f[1]);
|
|
41632
|
+
const remote = endpoint(f[2]);
|
|
41633
|
+
if (local === null || remote === null) continue;
|
|
41634
|
+
rows.push({ state: f[3], local, remote, inode: f[9] });
|
|
41635
|
+
}
|
|
41636
|
+
return rows;
|
|
41637
|
+
}
|
|
41638
|
+
function socketInodes(pid) {
|
|
41639
|
+
try {
|
|
41640
|
+
const out = /* @__PURE__ */ new Set();
|
|
41641
|
+
for (const fd of readdirSync4(`/proc/${pid}/fd`)) {
|
|
41642
|
+
try {
|
|
41643
|
+
const m = /^socket:\[(\d+)\]$/.exec(
|
|
41644
|
+
readlinkSync2(`/proc/${pid}/fd/${fd}`)
|
|
41645
|
+
);
|
|
41646
|
+
if (m?.[1]) out.add(m[1]);
|
|
41647
|
+
} catch {
|
|
41648
|
+
}
|
|
41649
|
+
}
|
|
41650
|
+
return out;
|
|
41651
|
+
} catch {
|
|
41652
|
+
return null;
|
|
41653
|
+
}
|
|
41654
|
+
}
|
|
41655
|
+
function tcpRows() {
|
|
41656
|
+
try {
|
|
41657
|
+
return [
|
|
41658
|
+
...parseProcNetTcp(readFileSync7("/proc/net/tcp", "utf8")),
|
|
41659
|
+
...parseProcNetTcp(readFileSync7("/proc/net/tcp6", "utf8"))
|
|
41660
|
+
];
|
|
41661
|
+
} catch {
|
|
41662
|
+
return null;
|
|
41663
|
+
}
|
|
41664
|
+
}
|
|
41665
|
+
function linuxEstablished(pid) {
|
|
41666
|
+
const inodes = socketInodes(pid);
|
|
41667
|
+
const rows = tcpRows();
|
|
41668
|
+
if (!inodes || !rows) return null;
|
|
41669
|
+
return rows.filter((r) => r.state === "01" && inodes.has(r.inode)).map((r) => ({ local: r.local, remote: r.remote }));
|
|
41670
|
+
}
|
|
41671
|
+
function run2(cmd, args) {
|
|
41672
|
+
try {
|
|
41673
|
+
return execFileSync3(systemTool(cmd), args, {
|
|
41674
|
+
encoding: "utf8",
|
|
41675
|
+
timeout: READ_TIMEOUT_MS,
|
|
41676
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
41677
|
+
});
|
|
41678
|
+
} catch {
|
|
41679
|
+
return null;
|
|
41680
|
+
}
|
|
41681
|
+
}
|
|
41682
|
+
function parseLsofNames(text3) {
|
|
41683
|
+
return text3.split("\n").filter((l) => l.startsWith("n")).map((l) => l.slice(1));
|
|
41684
|
+
}
|
|
41685
|
+
function lsofResult(r, alive2) {
|
|
41686
|
+
if (r.failed) return null;
|
|
41687
|
+
if (r.status === 0) return lsofEstablished(r.stdout);
|
|
41688
|
+
if (r.status === 1 && alive2 && !r.stdout.trim() && !r.stderr.trim())
|
|
41689
|
+
return [];
|
|
41690
|
+
return null;
|
|
41691
|
+
}
|
|
41692
|
+
function lsofEndpoint(e) {
|
|
41693
|
+
const m = /^\[::ffff:(\d+\.\d+\.\d+\.\d+)\](:\d+)$/i.exec(e);
|
|
41694
|
+
return m ? `${m[1]}${m[2]}` : e.toLowerCase();
|
|
41695
|
+
}
|
|
41696
|
+
function lsofEstablished(text3) {
|
|
41697
|
+
const out = [];
|
|
41698
|
+
for (const n of parseLsofNames(text3)) {
|
|
41699
|
+
const [local, remote] = n.split("->");
|
|
41700
|
+
if (local && remote)
|
|
41701
|
+
out.push({ local: lsofEndpoint(local), remote: lsofEndpoint(remote) });
|
|
41702
|
+
}
|
|
41703
|
+
return out;
|
|
41704
|
+
}
|
|
41705
|
+
var defaultAttachDeps = {
|
|
41706
|
+
exeOf(pid) {
|
|
41707
|
+
if (process.platform === "linux") {
|
|
41708
|
+
try {
|
|
41709
|
+
return readlinkSync2(`/proc/${pid}/exe`);
|
|
41710
|
+
} catch {
|
|
41711
|
+
return null;
|
|
41712
|
+
}
|
|
41713
|
+
}
|
|
41714
|
+
const out = run2("ps", ["-o", "comm=", "-p", String(pid)])?.trim();
|
|
41715
|
+
return out?.startsWith("/") ? out : null;
|
|
41716
|
+
},
|
|
41717
|
+
ppidOf(pid) {
|
|
41718
|
+
const out = run2("ps", ["-o", "ppid=", "-p", String(pid)])?.trim();
|
|
41719
|
+
return out && /^\d+$/.test(out) ? Number(out) : null;
|
|
41720
|
+
},
|
|
41721
|
+
established(pid) {
|
|
41722
|
+
if (process.platform === "linux") return linuxEstablished(pid);
|
|
41723
|
+
const r = spawnSync(
|
|
41724
|
+
systemTool("lsof"),
|
|
41725
|
+
["-nP", "-a", "-p", String(pid), "-iTCP", "-sTCP:ESTABLISHED", "-Fn"],
|
|
41726
|
+
{
|
|
41727
|
+
encoding: "utf8",
|
|
41728
|
+
timeout: READ_TIMEOUT_MS,
|
|
41729
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
41730
|
+
}
|
|
41731
|
+
);
|
|
41732
|
+
return lsofResult(
|
|
41733
|
+
{
|
|
41734
|
+
status: r.status,
|
|
41735
|
+
stdout: r.stdout ?? "",
|
|
41736
|
+
stderr: r.stderr ?? "",
|
|
41737
|
+
failed: r.error !== void 0 || r.signal !== null
|
|
41738
|
+
},
|
|
41739
|
+
isRunning(pid)
|
|
41740
|
+
);
|
|
41741
|
+
}
|
|
41742
|
+
};
|
|
41743
|
+
|
|
41524
41744
|
// ../bus-daemon/src/attest.ts
|
|
41525
41745
|
var defaultCodex;
|
|
41526
41746
|
function attest(hello, deps2 = {}) {
|
|
@@ -41590,13 +41810,17 @@ function attestOpenCode(hello, deps2) {
|
|
|
41590
41810
|
);
|
|
41591
41811
|
if (service === void 0)
|
|
41592
41812
|
return { ok: false, reason: "not running under an OpenCode service" };
|
|
41593
|
-
|
|
41594
|
-
|
|
41813
|
+
const open3 = deps2.openSessions ?? ((s, ref) => defaultOpenSessions(s, ref, deps2.attach));
|
|
41814
|
+
if (!open3(service, hello.agent_ref).has(hello.agent_ref))
|
|
41815
|
+
return {
|
|
41816
|
+
ok: false,
|
|
41817
|
+
reason: "opencode session is not open in a TUI attached to this service"
|
|
41818
|
+
};
|
|
41595
41819
|
return { ok: true, pid: service };
|
|
41596
41820
|
}
|
|
41597
41821
|
function commOf(pid) {
|
|
41598
41822
|
try {
|
|
41599
|
-
return
|
|
41823
|
+
return execFileSync4(systemTool("ps"), ["-o", "comm=", "-p", String(pid)], {
|
|
41600
41824
|
encoding: "utf8",
|
|
41601
41825
|
// A timeout reads as null, which ocServiceGone treats as unknown, not gone.
|
|
41602
41826
|
timeout: 1500,
|
|
@@ -41606,11 +41830,17 @@ function commOf(pid) {
|
|
|
41606
41830
|
return null;
|
|
41607
41831
|
}
|
|
41608
41832
|
}
|
|
41609
|
-
function defaultOpenSessions() {
|
|
41610
|
-
|
|
41611
|
-
|
|
41612
|
-
|
|
41613
|
-
|
|
41833
|
+
function defaultOpenSessions(service, ref, attach) {
|
|
41834
|
+
const open3 = openState(
|
|
41835
|
+
opencodePresenceDir(),
|
|
41836
|
+
{
|
|
41837
|
+
accept: attachedTo(service, attach ?? defaultAttachDeps),
|
|
41838
|
+
isRunning,
|
|
41839
|
+
procStartEpoch: (pid) => lstartEpoch(procStartOf(pid))
|
|
41840
|
+
},
|
|
41841
|
+
ref
|
|
41842
|
+
);
|
|
41843
|
+
return open3 === true ? /* @__PURE__ */ new Set([ref]) : /* @__PURE__ */ new Set();
|
|
41614
41844
|
}
|
|
41615
41845
|
|
|
41616
41846
|
// ../bus-daemon/src/claude-links.ts
|
|
@@ -41623,10 +41853,10 @@ import {
|
|
|
41623
41853
|
constants as constants2,
|
|
41624
41854
|
fstatSync as fstatSync2,
|
|
41625
41855
|
openSync as openSync2,
|
|
41626
|
-
readFileSync as
|
|
41856
|
+
readFileSync as readFileSync8
|
|
41627
41857
|
} from "node:fs";
|
|
41628
41858
|
import { userInfo } from "node:os";
|
|
41629
|
-
function isPrivateGroup(gid, user, read = () =>
|
|
41859
|
+
function isPrivateGroup(gid, user, read = () => readFileSync8("/etc/group", "utf8"), readPasswd = () => readFileSync8("/etc/passwd", "utf8")) {
|
|
41630
41860
|
let text3;
|
|
41631
41861
|
let passwd;
|
|
41632
41862
|
try {
|
|
@@ -41694,13 +41924,13 @@ function readOwnFile(file2, uid = process.getuid?.(), opts = {}) {
|
|
|
41694
41924
|
}
|
|
41695
41925
|
return {
|
|
41696
41926
|
state: "ok",
|
|
41697
|
-
text:
|
|
41927
|
+
text: readFileSync8(fd, "utf8"),
|
|
41698
41928
|
...note ? { note } : {}
|
|
41699
41929
|
};
|
|
41700
41930
|
}
|
|
41701
41931
|
if (st.mode & 18)
|
|
41702
41932
|
return { state: "unsafe", why: "is writable by others" };
|
|
41703
|
-
return { state: "ok", text:
|
|
41933
|
+
return { state: "ok", text: readFileSync8(fd, "utf8") };
|
|
41704
41934
|
} catch (e) {
|
|
41705
41935
|
return {
|
|
41706
41936
|
state: "unsafe",
|
|
@@ -41736,11 +41966,11 @@ function readClaudeLinks(file2, uid = process.getuid?.(), log = () => {
|
|
|
41736
41966
|
const out = [];
|
|
41737
41967
|
for (const raw of top.data.links) {
|
|
41738
41968
|
if (out.length >= CLAUDE_LINKS_MAX) break;
|
|
41739
|
-
const
|
|
41740
|
-
if (
|
|
41969
|
+
const one3 = EntrySchema.safeParse(raw);
|
|
41970
|
+
if (one3.success)
|
|
41741
41971
|
out.push({
|
|
41742
|
-
...
|
|
41743
|
-
hashes:
|
|
41972
|
+
...one3.data,
|
|
41973
|
+
hashes: one3.data.hashes.slice(-LINK_HASHES_MAX)
|
|
41744
41974
|
});
|
|
41745
41975
|
}
|
|
41746
41976
|
return out;
|
|
@@ -41793,10 +42023,10 @@ function readCodexAgents(file2, uid = process.getuid?.()) {
|
|
|
41793
42023
|
const out = [];
|
|
41794
42024
|
for (const raw of top.data.agents) {
|
|
41795
42025
|
if (out.length >= LIMITS.maxAgentsPerMachine) break;
|
|
41796
|
-
const
|
|
41797
|
-
if (!
|
|
41798
|
-
seen2.add(
|
|
41799
|
-
out.push(
|
|
42026
|
+
const one3 = CodexAgentSchema.safeParse(raw);
|
|
42027
|
+
if (!one3.success || seen2.has(one3.data.ref)) continue;
|
|
42028
|
+
seen2.add(one3.data.ref);
|
|
42029
|
+
out.push(one3.data);
|
|
41800
42030
|
}
|
|
41801
42031
|
return out;
|
|
41802
42032
|
} catch {
|
|
@@ -41839,10 +42069,10 @@ function readCodexAway(file2, now, uid = process.getuid?.()) {
|
|
|
41839
42069
|
const seen2 = /* @__PURE__ */ new Set();
|
|
41840
42070
|
const out = [];
|
|
41841
42071
|
for (const raw of top.data.rows) {
|
|
41842
|
-
const
|
|
41843
|
-
if (!
|
|
41844
|
-
seen2.add(
|
|
41845
|
-
out.push(
|
|
42072
|
+
const one3 = CodexAwaySchema.safeParse(raw);
|
|
42073
|
+
if (!one3.success || seen2.has(one3.data.ref)) continue;
|
|
42074
|
+
seen2.add(one3.data.ref);
|
|
42075
|
+
out.push(one3.data);
|
|
41846
42076
|
}
|
|
41847
42077
|
return trimAway(out, now);
|
|
41848
42078
|
} catch {
|
|
@@ -42028,7 +42258,7 @@ function writeGlobalDirs(dirs, h = home()) {
|
|
|
42028
42258
|
|
|
42029
42259
|
// ../bus-daemon/src/namespace.ts
|
|
42030
42260
|
init_src();
|
|
42031
|
-
import { execFileSync as
|
|
42261
|
+
import { execFileSync as execFileSync5 } from "node:child_process";
|
|
42032
42262
|
import { existsSync as existsSync3, realpathSync as realpathSync4 } from "node:fs";
|
|
42033
42263
|
import {
|
|
42034
42264
|
basename as basename4,
|
|
@@ -42414,7 +42644,7 @@ function nearestConfig(dir, deps2 = {}) {
|
|
|
42414
42644
|
}
|
|
42415
42645
|
var git = (cwd, args) => {
|
|
42416
42646
|
try {
|
|
42417
|
-
return
|
|
42647
|
+
return execFileSync5("git", ["-C", cwd, ...args], {
|
|
42418
42648
|
encoding: "utf8",
|
|
42419
42649
|
stdio: ["ignore", "pipe", "ignore"]
|
|
42420
42650
|
}).trim() || null;
|
|
@@ -43869,7 +44099,7 @@ init_src2();
|
|
|
43869
44099
|
init_src();
|
|
43870
44100
|
import {
|
|
43871
44101
|
chmodSync as chmodSync8,
|
|
43872
|
-
readFileSync as
|
|
44102
|
+
readFileSync as readFileSync9,
|
|
43873
44103
|
renameSync as renameSync8,
|
|
43874
44104
|
rmSync as rmSync4,
|
|
43875
44105
|
writeFileSync as writeFileSync5
|
|
@@ -44100,7 +44330,7 @@ var SentStore = class {
|
|
|
44100
44330
|
if (!this.file) return;
|
|
44101
44331
|
let raw;
|
|
44102
44332
|
try {
|
|
44103
|
-
raw = JSON.parse(
|
|
44333
|
+
raw = JSON.parse(readFileSync9(this.file, "utf8"));
|
|
44104
44334
|
} catch {
|
|
44105
44335
|
return;
|
|
44106
44336
|
}
|
|
@@ -44359,7 +44589,7 @@ import {
|
|
|
44359
44589
|
chmodSync as chmodSync10,
|
|
44360
44590
|
lstatSync as lstatSync6,
|
|
44361
44591
|
mkdirSync as mkdirSync7,
|
|
44362
|
-
readFileSync as
|
|
44592
|
+
readFileSync as readFileSync11,
|
|
44363
44593
|
renameSync as renameSync10,
|
|
44364
44594
|
rmSync as rmSync5,
|
|
44365
44595
|
writeFileSync as writeFileSync7
|
|
@@ -44369,7 +44599,7 @@ import { dirname as dirname7, join as join13 } from "node:path";
|
|
|
44369
44599
|
import { createInterface } from "node:readline";
|
|
44370
44600
|
|
|
44371
44601
|
// ../bus-daemon/src/transports/held.ts
|
|
44372
|
-
import { chmodSync as chmodSync9, readFileSync as
|
|
44602
|
+
import { chmodSync as chmodSync9, readFileSync as readFileSync10, renameSync as renameSync9, writeFileSync as writeFileSync6 } from "node:fs";
|
|
44373
44603
|
var HeldStore = class {
|
|
44374
44604
|
constructor(file2, opts = {}) {
|
|
44375
44605
|
this.file = file2;
|
|
@@ -44398,7 +44628,7 @@ var HeldStore = class {
|
|
|
44398
44628
|
#read() {
|
|
44399
44629
|
let raw;
|
|
44400
44630
|
try {
|
|
44401
|
-
raw = JSON.parse(
|
|
44631
|
+
raw = JSON.parse(readFileSync10(this.file, "utf8"));
|
|
44402
44632
|
} catch {
|
|
44403
44633
|
return {};
|
|
44404
44634
|
}
|
|
@@ -44459,7 +44689,7 @@ function returnKey(agentRef, namespace2, peerName, fromId) {
|
|
|
44459
44689
|
function readReturnIndex(file2) {
|
|
44460
44690
|
let raw;
|
|
44461
44691
|
try {
|
|
44462
|
-
raw = JSON.parse(
|
|
44692
|
+
raw = JSON.parse(readFileSync11(file2, "utf8"));
|
|
44463
44693
|
} catch {
|
|
44464
44694
|
return /* @__PURE__ */ Object.create(null);
|
|
44465
44695
|
}
|
|
@@ -44902,7 +45132,7 @@ async function shut(sink) {
|
|
|
44902
45132
|
// ../bus-daemon/src/transports/codex.ts
|
|
44903
45133
|
init_src2();
|
|
44904
45134
|
import { execFile } from "node:child_process";
|
|
44905
|
-
import { accessSync as accessSync2, constants as constants4, readFileSync as
|
|
45135
|
+
import { accessSync as accessSync2, constants as constants4, readFileSync as readFileSync12, statSync as statSync6 } from "node:fs";
|
|
44906
45136
|
import { readFile } from "node:fs/promises";
|
|
44907
45137
|
import { delimiter as delimiter2, isAbsolute as isAbsolute6, join as join14 } from "node:path";
|
|
44908
45138
|
var CODEX_QUEUE_TIMEOUT_MS = 1e4;
|
|
@@ -44923,7 +45153,7 @@ var executable2 = (p) => {
|
|
|
44923
45153
|
};
|
|
44924
45154
|
function codexAppBin(app) {
|
|
44925
45155
|
try {
|
|
44926
|
-
const plist =
|
|
45156
|
+
const plist = readFileSync12(join14(app, "Contents", "Info.plist"), "utf8");
|
|
44927
45157
|
const id = /<key>CFBundleIdentifier<\/key>\s*<string>([^<]*)<\/string>/.exec(
|
|
44928
45158
|
plist
|
|
44929
45159
|
)?.[1];
|
|
@@ -44935,7 +45165,7 @@ function codexAppBin(app) {
|
|
|
44935
45165
|
function resolveCodexBin(o) {
|
|
44936
45166
|
if (o.configFile)
|
|
44937
45167
|
try {
|
|
44938
|
-
const raw = JSON.parse(
|
|
45168
|
+
const raw = JSON.parse(readFileSync12(o.configFile, "utf8"));
|
|
44939
45169
|
if (typeof raw.bin === "string" && isAbsolute6(raw.bin) && executable2(raw.bin))
|
|
44940
45170
|
return { path: raw.bin, from: "config" };
|
|
44941
45171
|
} catch {
|
|
@@ -45153,6 +45383,10 @@ var CodexTransport = class {
|
|
|
45153
45383
|
});
|
|
45154
45384
|
} catch (e) {
|
|
45155
45385
|
this.#bin = void 0;
|
|
45386
|
+
this.opts.event?.("codex_queue_failed", {
|
|
45387
|
+
thread: ref,
|
|
45388
|
+
reason: "start"
|
|
45389
|
+
});
|
|
45156
45390
|
this.opts.log?.(
|
|
45157
45391
|
`codex queue could not start (${bin.path}): ${e instanceof Error ? e.message : String(e)}`
|
|
45158
45392
|
);
|
|
@@ -45163,10 +45397,19 @@ var CodexTransport = class {
|
|
|
45163
45397
|
}
|
|
45164
45398
|
if (res.code === null) {
|
|
45165
45399
|
this.#keep(`maybe:${id}`);
|
|
45400
|
+
this.opts.event?.("codex_queue_failed", {
|
|
45401
|
+
thread: ref,
|
|
45402
|
+
reason: "timeout"
|
|
45403
|
+
});
|
|
45166
45404
|
this.opts.log?.(`codex queue for ${ref} timed out; not queued again`);
|
|
45167
45405
|
return { ok: false, taken: "maybe" };
|
|
45168
45406
|
}
|
|
45169
45407
|
this.#bin = void 0;
|
|
45408
|
+
this.opts.event?.("codex_queue_failed", {
|
|
45409
|
+
thread: ref,
|
|
45410
|
+
reason: "exit",
|
|
45411
|
+
code: res.code
|
|
45412
|
+
});
|
|
45170
45413
|
this.opts.log?.(
|
|
45171
45414
|
`codex queue for ${ref} exited ${res.code}: ${stripTerminalControls(res.stderr.trim()).slice(0, 300)}`
|
|
45172
45415
|
);
|
|
@@ -45384,9 +45627,114 @@ var PiTransport = class {
|
|
|
45384
45627
|
}
|
|
45385
45628
|
};
|
|
45386
45629
|
|
|
45630
|
+
// ../bus-daemon/src/event-log.ts
|
|
45631
|
+
init_src2();
|
|
45632
|
+
import { constants as constants5 } from "node:fs";
|
|
45633
|
+
import { chmod, lstat, mkdir, open as open2, rename } from "node:fs/promises";
|
|
45634
|
+
import { dirname as dirname8 } from "node:path";
|
|
45635
|
+
var EVENT_LOG_MAX_BYTES = 1e6;
|
|
45636
|
+
var FIELDS = /* @__PURE__ */ new Set([
|
|
45637
|
+
"name",
|
|
45638
|
+
"ref",
|
|
45639
|
+
"thread",
|
|
45640
|
+
"agent",
|
|
45641
|
+
"ns",
|
|
45642
|
+
"kind",
|
|
45643
|
+
"pid",
|
|
45644
|
+
"reason",
|
|
45645
|
+
"code",
|
|
45646
|
+
"version",
|
|
45647
|
+
"state",
|
|
45648
|
+
"id"
|
|
45649
|
+
]);
|
|
45650
|
+
var MAX_VALUE = 120;
|
|
45651
|
+
var EVENT_LOG_MAX_PENDING = 1e3;
|
|
45652
|
+
var one = (v) => {
|
|
45653
|
+
const s = stripTerminalControls(String(v)).replace(/[\p{Cc}\p{Cf}\u2028\u2029]/gu, " ").replace(/ +/g, " ").slice(0, MAX_VALUE);
|
|
45654
|
+
return /^[\w.:/@+-]+$/.test(s) ? s : JSON.stringify(s);
|
|
45655
|
+
};
|
|
45656
|
+
function formatEvent(at, event, fields = {}) {
|
|
45657
|
+
const parts = [at.toISOString(), event.replace(/[^\w.-]/g, "_")];
|
|
45658
|
+
for (const [k, v] of Object.entries(fields))
|
|
45659
|
+
if (v !== void 0 && FIELDS.has(k)) parts.push(`${k}=${one(v)}`);
|
|
45660
|
+
return parts.join(" ");
|
|
45661
|
+
}
|
|
45662
|
+
function createEventLog(file2, opts = {}) {
|
|
45663
|
+
const max = opts.maxBytes ?? EVENT_LOG_MAX_BYTES;
|
|
45664
|
+
const now = opts.now ?? (() => /* @__PURE__ */ new Date());
|
|
45665
|
+
let chain = Promise.resolve();
|
|
45666
|
+
let size;
|
|
45667
|
+
const write = async (line) => {
|
|
45668
|
+
try {
|
|
45669
|
+
if (size === void 0) {
|
|
45670
|
+
const dir = dirname8(file2);
|
|
45671
|
+
await mkdir(dir, { recursive: true, mode: 448 });
|
|
45672
|
+
await chmod(dir, 448);
|
|
45673
|
+
size = 0;
|
|
45674
|
+
for (const f of [file2, `${file2}.1`]) {
|
|
45675
|
+
const st = await lstat(f).catch(() => void 0);
|
|
45676
|
+
if (!st) continue;
|
|
45677
|
+
if (st.isSymbolicLink()) throw new Error("symlink");
|
|
45678
|
+
await chmod(f, 384);
|
|
45679
|
+
if (f === file2) size = st.size;
|
|
45680
|
+
}
|
|
45681
|
+
}
|
|
45682
|
+
if (size > 0 && size + Buffer.byteLength(line) > max) {
|
|
45683
|
+
await rename(file2, `${file2}.1`);
|
|
45684
|
+
size = 0;
|
|
45685
|
+
}
|
|
45686
|
+
const fh = await open2(
|
|
45687
|
+
file2,
|
|
45688
|
+
constants5.O_WRONLY | constants5.O_APPEND | constants5.O_CREAT | constants5.O_NOFOLLOW,
|
|
45689
|
+
384
|
|
45690
|
+
);
|
|
45691
|
+
try {
|
|
45692
|
+
await fh.write(line);
|
|
45693
|
+
} finally {
|
|
45694
|
+
await fh.close();
|
|
45695
|
+
}
|
|
45696
|
+
size += Buffer.byteLength(line);
|
|
45697
|
+
} catch {
|
|
45698
|
+
size = void 0;
|
|
45699
|
+
}
|
|
45700
|
+
};
|
|
45701
|
+
const maxPending = opts.maxPending ?? EVENT_LOG_MAX_PENDING;
|
|
45702
|
+
let pending = 0;
|
|
45703
|
+
let dropped = 0;
|
|
45704
|
+
const enqueue = (line) => {
|
|
45705
|
+
pending++;
|
|
45706
|
+
chain = chain.then(() => write(line)).then(() => {
|
|
45707
|
+
pending--;
|
|
45708
|
+
if (pending === 0 && dropped > 0) {
|
|
45709
|
+
const n = dropped;
|
|
45710
|
+
dropped = 0;
|
|
45711
|
+
enqueue(`${formatEvent(now(), "events_dropped", {})} n=${n}
|
|
45712
|
+
`);
|
|
45713
|
+
}
|
|
45714
|
+
});
|
|
45715
|
+
};
|
|
45716
|
+
const log = ((event, fields) => {
|
|
45717
|
+
try {
|
|
45718
|
+
const line = `${formatEvent(now(), event, fields)}
|
|
45719
|
+
`;
|
|
45720
|
+
if (pending >= maxPending) dropped++;
|
|
45721
|
+
else enqueue(line);
|
|
45722
|
+
} catch {
|
|
45723
|
+
}
|
|
45724
|
+
});
|
|
45725
|
+
log.flush = async () => {
|
|
45726
|
+
let c;
|
|
45727
|
+
do {
|
|
45728
|
+
c = chain;
|
|
45729
|
+
await c;
|
|
45730
|
+
} while (c !== chain);
|
|
45731
|
+
};
|
|
45732
|
+
return log;
|
|
45733
|
+
}
|
|
45734
|
+
|
|
45387
45735
|
// ../bus-daemon/src/leads/templates.ts
|
|
45388
45736
|
init_src();
|
|
45389
|
-
import { lstatSync as lstatSync7, readdirSync as
|
|
45737
|
+
import { lstatSync as lstatSync7, readdirSync as readdirSync5, realpathSync as realpathSync6, statSync as statSync7 } from "node:fs";
|
|
45390
45738
|
import { join as join15 } from "node:path";
|
|
45391
45739
|
var leadsDir = (h = home()) => join15(h, "leads");
|
|
45392
45740
|
var leadTemplateFile = (name, h = home()) => join15(leadsDir(h), `${name}.json`);
|
|
@@ -45506,7 +45854,7 @@ function listLeadTemplateNames(h = home()) {
|
|
|
45506
45854
|
if (state !== void 0) return [];
|
|
45507
45855
|
let entries;
|
|
45508
45856
|
try {
|
|
45509
|
-
entries =
|
|
45857
|
+
entries = readdirSync5(dir);
|
|
45510
45858
|
} catch {
|
|
45511
45859
|
return [];
|
|
45512
45860
|
}
|
|
@@ -45526,10 +45874,25 @@ var PENDING_PROOF_MAX = 64;
|
|
|
45526
45874
|
var LATE_WINDOW_MS = 60 * 6e4;
|
|
45527
45875
|
var piLike = (kind4) => kind4 === "pi" || kind4 === "omp" || kind4 === "hermes" || kind4 === "openclaw";
|
|
45528
45876
|
var REF_BOUND = "agent_ref is bound to another live connection";
|
|
45877
|
+
var refusalKey = (reason2) => Object.entries(CODEX_REFUSALS).find(([, text3]) => text3 === reason2)?.[0] ?? "other";
|
|
45878
|
+
var agentFields = (a, reason2) => ({
|
|
45879
|
+
kind: a.kind,
|
|
45880
|
+
name: a.busName,
|
|
45881
|
+
ref: a.ref,
|
|
45882
|
+
ns: a.namespace,
|
|
45883
|
+
pid: a.pid,
|
|
45884
|
+
...reason2 !== void 0 ? { reason: reason2 } : {}
|
|
45885
|
+
});
|
|
45529
45886
|
async function runDaemon(deps2 = {}) {
|
|
45530
45887
|
const cfg = deps2.config ?? readConfig();
|
|
45531
45888
|
const log = deps2.log ?? ((msg) => console.error(`oa-bus: ${msg}`));
|
|
45532
45889
|
const debug = deps2.debug ?? process.env.OA_BUS_DEBUG === "1";
|
|
45890
|
+
const ev = (event, fields) => {
|
|
45891
|
+
try {
|
|
45892
|
+
deps2.events?.(event, fields);
|
|
45893
|
+
} catch {
|
|
45894
|
+
}
|
|
45895
|
+
};
|
|
45533
45896
|
const agents = new AgentTable();
|
|
45534
45897
|
const pending = new Pending(
|
|
45535
45898
|
deps2.pendingTimeoutMs,
|
|
@@ -45709,7 +46072,6 @@ async function runDaemon(deps2 = {}) {
|
|
|
45709
46072
|
ttlMs: cl.syncMs ?? 2e3,
|
|
45710
46073
|
jitter: 0
|
|
45711
46074
|
});
|
|
45712
|
-
const ocComm = oc.comm ?? commOf;
|
|
45713
46075
|
const cx = deps2.codex ?? {};
|
|
45714
46076
|
const linkOnly = /* @__PURE__ */ new WeakSet();
|
|
45715
46077
|
const codexCheck = codexAttestor({
|
|
@@ -45720,18 +46082,35 @@ async function runDaemon(deps2 = {}) {
|
|
|
45720
46082
|
const relockEvery = cx.relockEvery ?? 15;
|
|
45721
46083
|
let codexTicks = 0;
|
|
45722
46084
|
const ocServiceStart = /* @__PURE__ */ new Map();
|
|
46085
|
+
const ocComm = oc.comm ?? commOf;
|
|
45723
46086
|
const ocServiceGone = (ref, pid) => {
|
|
45724
46087
|
if (!ocRunning(pid)) return true;
|
|
45725
46088
|
const comm = ocComm(pid);
|
|
45726
46089
|
if (comm !== null && basename5(comm) !== "opencode") return true;
|
|
45727
46090
|
const start = ocServiceStart.get(ref);
|
|
45728
|
-
|
|
46091
|
+
if (start == null) return false;
|
|
46092
|
+
const now = ocStart(pid);
|
|
46093
|
+
return now !== null && now !== start;
|
|
45729
46094
|
};
|
|
45730
46095
|
const presenceDir = oc.presenceDir ?? opencodePresenceDir();
|
|
45731
46096
|
const openCodeSessions = oc.openSessions ?? (() => openSessions(presenceDir, {
|
|
45732
46097
|
isRunning: ocRunning,
|
|
45733
46098
|
procStartEpoch: (pid, stamp2) => lstartEpoch(ocStart(pid, stamp2))
|
|
45734
46099
|
}));
|
|
46100
|
+
const ocAttached = cachedAttach(
|
|
46101
|
+
oc.attach ?? defaultAttachDeps,
|
|
46102
|
+
deps2.bindingNow
|
|
46103
|
+
);
|
|
46104
|
+
const openCodeStateFor = (service, ref) => oc.openSessions ? oc.openSessions().has(ref) : openState(
|
|
46105
|
+
presenceDir,
|
|
46106
|
+
{
|
|
46107
|
+
isRunning: ocRunning,
|
|
46108
|
+
procStartEpoch: (pid, stamp2) => lstartEpoch(ocStart(pid, stamp2)),
|
|
46109
|
+
accept: ocAttached(service)
|
|
46110
|
+
},
|
|
46111
|
+
ref
|
|
46112
|
+
);
|
|
46113
|
+
const openCodeSessionsFor = (service, ref) => openCodeStateFor(service, ref) === true ? /* @__PURE__ */ new Set([ref]) : /* @__PURE__ */ new Set();
|
|
45735
46114
|
const ocSpawn = oc.spawn ?? execSpawn(2e4);
|
|
45736
46115
|
let promptIdSupported = false;
|
|
45737
46116
|
const opencode = new OpenCodeTransport({
|
|
@@ -45753,7 +46132,8 @@ async function runDaemon(deps2 = {}) {
|
|
|
45753
46132
|
home: codexIndexHome,
|
|
45754
46133
|
wakes: cx.wakes ?? codexHostWakes,
|
|
45755
46134
|
queued: new HeldStore(cx.queuedFile ?? join16(home(), "codex-queued.json")),
|
|
45756
|
-
log
|
|
46135
|
+
log,
|
|
46136
|
+
event: ev
|
|
45757
46137
|
});
|
|
45758
46138
|
const pi = new PiTransport({
|
|
45759
46139
|
push: (ref, frame) => {
|
|
@@ -46034,29 +46414,26 @@ async function runDaemon(deps2 = {}) {
|
|
|
46034
46414
|
seenAt.set(s.ref, ++seenSeq);
|
|
46035
46415
|
const old = prev ? void 0 : clearedFrom(s.ref, s.pid, s.procStart, liveRefs);
|
|
46036
46416
|
if (old) takenOver.add(old.ref);
|
|
46037
|
-
|
|
46038
|
-
|
|
46039
|
-
|
|
46040
|
-
|
|
46041
|
-
|
|
46042
|
-
|
|
46043
|
-
|
|
46044
|
-
|
|
46045
|
-
|
|
46046
|
-
|
|
46047
|
-
|
|
46048
|
-
|
|
46049
|
-
|
|
46050
|
-
|
|
46051
|
-
|
|
46052
|
-
|
|
46053
|
-
|
|
46054
|
-
|
|
46055
|
-
);
|
|
46056
|
-
|
|
46057
|
-
const rec = agents.byRef(s.ref);
|
|
46058
|
-
if (rec) seedLinks(rec);
|
|
46059
|
-
}
|
|
46417
|
+
const rec = agents.up({
|
|
46418
|
+
...old ? { replaces: handoverOf(old) } : {},
|
|
46419
|
+
ref: s.ref,
|
|
46420
|
+
kind: "claude-code",
|
|
46421
|
+
proposedName: old?.busName ?? s.name,
|
|
46422
|
+
busName: prev?.busName ?? old?.busName ?? s.name,
|
|
46423
|
+
namespace: ns.namespace,
|
|
46424
|
+
namespaceSource: ns.source,
|
|
46425
|
+
global: ns.global,
|
|
46426
|
+
pid: s.pid,
|
|
46427
|
+
procStart: s.procStart,
|
|
46428
|
+
// The same process keeps its proof across /clear; agent_ok rebinds it.
|
|
46429
|
+
...old?.linkHashes !== void 0 ? { linkHashes: old.linkHashes } : {},
|
|
46430
|
+
sessionName: s.name,
|
|
46431
|
+
cwd: s.cwd,
|
|
46432
|
+
live: true
|
|
46433
|
+
});
|
|
46434
|
+
ev("agent_join", { ...agentFields(rec), state: "synced" });
|
|
46435
|
+
announceUp(rec);
|
|
46436
|
+
seedLinks(rec);
|
|
46060
46437
|
void claude.revive(s.ref);
|
|
46061
46438
|
tellOwed(s.ref);
|
|
46062
46439
|
}
|
|
@@ -46066,6 +46443,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
46066
46443
|
if (a.kind !== "claude-code" || !a.live || liveRefs.has(a.ref)) continue;
|
|
46067
46444
|
a.live = false;
|
|
46068
46445
|
closed = true;
|
|
46446
|
+
ev("agent_leave", agentFields(a, "session_gone"));
|
|
46069
46447
|
void claude.drop(a.ref);
|
|
46070
46448
|
}
|
|
46071
46449
|
persistLinks();
|
|
@@ -46073,20 +46451,21 @@ async function runDaemon(deps2 = {}) {
|
|
|
46073
46451
|
};
|
|
46074
46452
|
let openBefore = /* @__PURE__ */ new Set();
|
|
46075
46453
|
const syncOpenCode = () => {
|
|
46076
|
-
const
|
|
46454
|
+
const open3 = openCodeSessions();
|
|
46077
46455
|
let closed = false;
|
|
46078
46456
|
for (const a of agents.all()) {
|
|
46079
46457
|
if (a.kind !== "opencode") continue;
|
|
46080
|
-
if (a.live && !
|
|
46458
|
+
if (a.live && !open3.has(a.ref)) {
|
|
46081
46459
|
a.live = false;
|
|
46082
46460
|
closed = true;
|
|
46083
|
-
|
|
46461
|
+
ev("agent_leave", agentFields(a, "not_listed"));
|
|
46462
|
+
} else if (!a.live && open3.has(a.ref) && !openBefore.has(a.ref)) {
|
|
46084
46463
|
a.live = true;
|
|
46085
46464
|
announceUp(a);
|
|
46086
46465
|
tellOwed(a.ref);
|
|
46087
46466
|
}
|
|
46088
46467
|
}
|
|
46089
|
-
openBefore =
|
|
46468
|
+
openBefore = open3;
|
|
46090
46469
|
if (closed) announceSessions();
|
|
46091
46470
|
};
|
|
46092
46471
|
const delivery = createDeliver({
|
|
@@ -46102,7 +46481,10 @@ async function runDaemon(deps2 = {}) {
|
|
|
46102
46481
|
codex: (agent, mail) => codex.deliver(agent, mail),
|
|
46103
46482
|
...deps2.transports
|
|
46104
46483
|
},
|
|
46105
|
-
onClosed:
|
|
46484
|
+
onClosed: (a) => {
|
|
46485
|
+
ev("agent_leave", agentFields(a, "delivery_closed"));
|
|
46486
|
+
announceSessions();
|
|
46487
|
+
},
|
|
46106
46488
|
log
|
|
46107
46489
|
});
|
|
46108
46490
|
let hubEver = false;
|
|
@@ -46276,10 +46658,12 @@ async function runDaemon(deps2 = {}) {
|
|
|
46276
46658
|
onOpen: () => {
|
|
46277
46659
|
hubEver = true;
|
|
46278
46660
|
hubDroppedAt = void 0;
|
|
46661
|
+
ev("hub_connect");
|
|
46279
46662
|
for (const rec of agents.all()) if (rec.live) announceUp(rec);
|
|
46280
46663
|
},
|
|
46281
46664
|
onClose: () => {
|
|
46282
46665
|
if (hubEver) hubDroppedAt ??= Date.now();
|
|
46666
|
+
ev("hub_disconnect");
|
|
46283
46667
|
upIds.clear();
|
|
46284
46668
|
renameIds.clear();
|
|
46285
46669
|
hubVersion = void 0;
|
|
@@ -46480,13 +46864,20 @@ async function runDaemon(deps2 = {}) {
|
|
|
46480
46864
|
const checked3 = (deps2.attest ?? ((h) => h.kind === "codex" ? codexCheck.attest(h) : attest(h, {
|
|
46481
46865
|
// The dir liveness reads: a session is attested where it is seen.
|
|
46482
46866
|
sessionsDir: claudeSessions.dir,
|
|
46483
|
-
openSessions:
|
|
46867
|
+
openSessions: openCodeSessionsFor,
|
|
46484
46868
|
ancestors: oc.ancestors,
|
|
46485
46869
|
comm: oc.comm,
|
|
46486
46870
|
codex: codexCheck
|
|
46487
46871
|
})))(hello);
|
|
46488
46872
|
const admit = (check2) => {
|
|
46489
|
-
if (!check2.ok)
|
|
46873
|
+
if (!check2.ok) {
|
|
46874
|
+
ev(hello.kind === "codex" ? "codex_refused" : "agent_refused", {
|
|
46875
|
+
kind: hello.kind,
|
|
46876
|
+
ref: hello.agent_ref,
|
|
46877
|
+
reason: refusalKey(check2.reason)
|
|
46878
|
+
});
|
|
46879
|
+
return { error: check2.reason };
|
|
46880
|
+
}
|
|
46490
46881
|
const pid = check2.pid ?? hello.pid;
|
|
46491
46882
|
if (check2.linkOnly) linkOnly.add(hello);
|
|
46492
46883
|
let bindToken;
|
|
@@ -46516,7 +46907,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
46516
46907
|
if (live.some((s) => s.pid === pid) && !live.some((s) => s.pid === prev.pid))
|
|
46517
46908
|
prev.pid = pid;
|
|
46518
46909
|
}
|
|
46519
|
-
if (prev?.live && prev.kind === "opencode" && hello.kind === "opencode" && prev.pid !== pid && ocServiceGone(prev.ref, prev.pid)) {
|
|
46910
|
+
if (prev?.live && prev.kind === "opencode" && hello.kind === "opencode" && prev.pid !== pid && (ocServiceGone(prev.ref, prev.pid) || openCodeStateFor(prev.pid, prev.ref) === false)) {
|
|
46520
46911
|
prev.pid = pid;
|
|
46521
46912
|
ocServiceStart.set(prev.ref, ocStart(pid));
|
|
46522
46913
|
}
|
|
@@ -46587,6 +46978,10 @@ async function runDaemon(deps2 = {}) {
|
|
|
46587
46978
|
cwd,
|
|
46588
46979
|
live: true
|
|
46589
46980
|
});
|
|
46981
|
+
ev(rec.kind === "codex" ? "codex_admitted" : "agent_join", {
|
|
46982
|
+
...agentFields(rec),
|
|
46983
|
+
...prev ? { state: "revived" } : {}
|
|
46984
|
+
});
|
|
46590
46985
|
if (rec.kind === "opencode") ocServiceStart.set(rec.ref, ocStart(pid));
|
|
46591
46986
|
if (rec.kind === "codex") {
|
|
46592
46987
|
persistCodex();
|
|
@@ -46723,6 +47118,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
46723
47118
|
const rec = agents.byRef(hello.agent_ref);
|
|
46724
47119
|
if (!rec) return;
|
|
46725
47120
|
rec.live = false;
|
|
47121
|
+
ev("agent_leave", agentFields(rec, "link_closed"));
|
|
46726
47122
|
announceSessions();
|
|
46727
47123
|
}
|
|
46728
47124
|
}).catch(socketInUse);
|
|
@@ -46955,6 +47351,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
46955
47351
|
CODEX_WAKE_TEXT
|
|
46956
47352
|
);
|
|
46957
47353
|
wakeWaiting.set(key2, row.waiting);
|
|
47354
|
+
ev("codex_wake", { thread: r.ref, state: res });
|
|
46958
47355
|
if (res === "failed" || res === "maybe")
|
|
46959
47356
|
try {
|
|
46960
47357
|
for (let m = n + 1; m <= WAKES_MAX; m++) woken.add(`${key2}#${m}`);
|
|
@@ -46999,6 +47396,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
46999
47396
|
announceUp(a);
|
|
47000
47397
|
tellOwed(a.ref);
|
|
47001
47398
|
} else changed = true;
|
|
47399
|
+
ev("codex_liveness", { thread, state: live ? "not_live" : "live" });
|
|
47002
47400
|
log(`codex thread ${thread} ${live ? "not live" : "live again"}`);
|
|
47003
47401
|
}
|
|
47004
47402
|
if (changed) announceSessions();
|
|
@@ -47036,11 +47434,13 @@ async function runDaemon(deps2 = {}) {
|
|
|
47036
47434
|
`OpenCode ${ocVersion ?? "(version unknown)"} is below ${MIN_PROMPT_ID_VERSION}: a timed-out prompt is never retried`
|
|
47037
47435
|
);
|
|
47038
47436
|
hub.start();
|
|
47437
|
+
ev("daemon_start", { version: deps2.version, pid: process.pid });
|
|
47039
47438
|
return {
|
|
47040
47439
|
hub,
|
|
47041
47440
|
agents,
|
|
47042
47441
|
bindings: { count: () => bindings.size, sweep: sweepBindings },
|
|
47043
47442
|
stop: async () => {
|
|
47443
|
+
ev("daemon_stop", { pid: process.pid });
|
|
47044
47444
|
clearInterval(socketWatch);
|
|
47045
47445
|
clearInterval(watcher);
|
|
47046
47446
|
clearInterval(retry);
|
|
@@ -47053,14 +47453,16 @@ async function runDaemon(deps2 = {}) {
|
|
|
47053
47453
|
pending.failAll("hub_unavailable", "the daemon is stopping");
|
|
47054
47454
|
sent.flush();
|
|
47055
47455
|
await Promise.all([server4.close(), claude.close()]);
|
|
47456
|
+
await deps2.events?.flush?.().catch(() => {
|
|
47457
|
+
});
|
|
47056
47458
|
}
|
|
47057
47459
|
};
|
|
47058
47460
|
}
|
|
47059
47461
|
|
|
47060
47462
|
// src/context.ts
|
|
47061
47463
|
init_src3();
|
|
47062
|
-
import { execFileSync as
|
|
47063
|
-
import { closeSync as closeSync6, openSync as openSync6, readFileSync as
|
|
47464
|
+
import { execFileSync as execFileSync6, spawn as spawn2 } from "node:child_process";
|
|
47465
|
+
import { closeSync as closeSync6, openSync as openSync6, readFileSync as readFileSync15 } from "node:fs";
|
|
47064
47466
|
import { homedir as homedir3, userInfo as userInfo2 } from "node:os";
|
|
47065
47467
|
import { createInterface as createInterface2 } from "node:readline";
|
|
47066
47468
|
init_src2();
|
|
@@ -47136,11 +47538,11 @@ import {
|
|
|
47136
47538
|
rmSync as rmSync6,
|
|
47137
47539
|
writeFileSync as writeFileSync10
|
|
47138
47540
|
} from "node:fs";
|
|
47139
|
-
import { basename as basename6, dirname as
|
|
47541
|
+
import { basename as basename6, dirname as dirname10, isAbsolute as isAbsolute8, join as join18, resolve as resolve5 } from "node:path";
|
|
47140
47542
|
import { fileURLToPath } from "node:url";
|
|
47141
47543
|
|
|
47142
47544
|
// src/steps/codex.ts
|
|
47143
|
-
import { lstatSync as lstatSync9, readFileSync as
|
|
47545
|
+
import { lstatSync as lstatSync9, readFileSync as readFileSync13 } from "node:fs";
|
|
47144
47546
|
import { join as join17, resolve as resolve4 } from "node:path";
|
|
47145
47547
|
|
|
47146
47548
|
// ../../node_modules/.pnpm/smol-toml@1.9.1/node_modules/smol-toml/dist/error.js
|
|
@@ -47922,7 +48324,7 @@ var findCodexBin = (o) => resolveCodexBin({ ...o, app: o.app ?? null })?.path;
|
|
|
47922
48324
|
function readToml(path) {
|
|
47923
48325
|
let text3;
|
|
47924
48326
|
try {
|
|
47925
|
-
text3 =
|
|
48327
|
+
text3 = readFileSync13(path, "utf8");
|
|
47926
48328
|
} catch (e) {
|
|
47927
48329
|
if (e.code === "ENOENT")
|
|
47928
48330
|
return { text: "", doc: {} };
|
|
@@ -47987,24 +48389,24 @@ function renderEntry(e) {
|
|
|
47987
48389
|
];
|
|
47988
48390
|
}
|
|
47989
48391
|
function scan(lines) {
|
|
47990
|
-
let
|
|
48392
|
+
let open3;
|
|
47991
48393
|
return lines.map((line) => {
|
|
47992
|
-
const startsInString =
|
|
48394
|
+
const startsInString = open3 !== void 0;
|
|
47993
48395
|
let i = 0;
|
|
47994
48396
|
let code2 = false;
|
|
47995
48397
|
while (i < line.length) {
|
|
47996
|
-
if (
|
|
47997
|
-
if (
|
|
48398
|
+
if (open3) {
|
|
48399
|
+
if (open3 === '"""' && line[i] === "\\") {
|
|
47998
48400
|
i += 2;
|
|
47999
48401
|
continue;
|
|
48000
48402
|
}
|
|
48001
|
-
if (!line.startsWith(
|
|
48403
|
+
if (!line.startsWith(open3, i)) {
|
|
48002
48404
|
i++;
|
|
48003
48405
|
continue;
|
|
48004
48406
|
}
|
|
48005
48407
|
i += 3;
|
|
48006
|
-
while (line[i] ===
|
|
48007
|
-
|
|
48408
|
+
while (line[i] === open3[0]) i++;
|
|
48409
|
+
open3 = void 0;
|
|
48008
48410
|
continue;
|
|
48009
48411
|
}
|
|
48010
48412
|
const c = line[i];
|
|
@@ -48013,7 +48415,7 @@ function scan(lines) {
|
|
|
48013
48415
|
code2 = true;
|
|
48014
48416
|
const triple = line.startsWith(c.repeat(3), i);
|
|
48015
48417
|
if (triple) {
|
|
48016
|
-
|
|
48418
|
+
open3 = c === '"' ? '"""' : "'''";
|
|
48017
48419
|
i += 3;
|
|
48018
48420
|
continue;
|
|
48019
48421
|
}
|
|
@@ -48190,14 +48592,14 @@ async function readCodexVersion(o) {
|
|
|
48190
48592
|
import {
|
|
48191
48593
|
chmodSync as chmodSync11,
|
|
48192
48594
|
mkdirSync as mkdirSync8,
|
|
48193
|
-
readFileSync as
|
|
48595
|
+
readFileSync as readFileSync14,
|
|
48194
48596
|
renameSync as renameSync11,
|
|
48195
48597
|
writeFileSync as writeFileSync9
|
|
48196
48598
|
} from "node:fs";
|
|
48197
|
-
import { dirname as
|
|
48599
|
+
import { dirname as dirname9 } from "node:path";
|
|
48198
48600
|
function readInstallFile(path) {
|
|
48199
48601
|
try {
|
|
48200
|
-
const v = JSON.parse(
|
|
48602
|
+
const v = JSON.parse(readFileSync14(path, "utf8"));
|
|
48201
48603
|
if (typeof v === "object" && v !== null && !Array.isArray(v))
|
|
48202
48604
|
return v;
|
|
48203
48605
|
} catch {
|
|
@@ -48206,7 +48608,7 @@ function readInstallFile(path) {
|
|
|
48206
48608
|
}
|
|
48207
48609
|
function updateInstallFile(path, patch) {
|
|
48208
48610
|
const next = { ...readInstallFile(path), ...patch };
|
|
48209
|
-
mkdirSync8(
|
|
48611
|
+
mkdirSync8(dirname9(path), { recursive: true, mode: 448 });
|
|
48210
48612
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
48211
48613
|
writeFileSync9(tmp, `${JSON.stringify(next, null, 2)}
|
|
48212
48614
|
`, { mode: 384 });
|
|
@@ -48307,7 +48709,7 @@ function cliSource() {
|
|
|
48307
48709
|
jiti: import.meta.resolve("jiti")
|
|
48308
48710
|
} : { kind: "bundle", file: here };
|
|
48309
48711
|
}
|
|
48310
|
-
var entryName = (src) => src.kind === "bundle" ? join18(basename6(
|
|
48712
|
+
var entryName = (src) => src.kind === "bundle" ? join18(basename6(dirname10(src.file)), basename6(src.file)) : "oa-bus.js";
|
|
48311
48713
|
var shim = (src) => `// Written by oa-bus install: runs the sources it was installed from.
|
|
48312
48714
|
import { createJiti } from ${JSON.stringify(src.jiti)};
|
|
48313
48715
|
|
|
@@ -48371,7 +48773,7 @@ function installCli(home2, src, node2) {
|
|
|
48371
48773
|
rmSync6(tmp, { recursive: true, force: true });
|
|
48372
48774
|
mkdirSync9(tmp);
|
|
48373
48775
|
if (src.kind === "bundle") {
|
|
48374
|
-
const pkg =
|
|
48776
|
+
const pkg = dirname10(dirname10(src.file));
|
|
48375
48777
|
for (const name of ["dist", "assets", "package.json"])
|
|
48376
48778
|
if (existsSync4(join18(pkg, name)))
|
|
48377
48779
|
cpSync(join18(pkg, name), join18(tmp, name), { recursive: true });
|
|
@@ -48396,7 +48798,7 @@ var present = (path) => {
|
|
|
48396
48798
|
}
|
|
48397
48799
|
};
|
|
48398
48800
|
function writeReplacing(path, text3) {
|
|
48399
|
-
mkdirSync9(
|
|
48801
|
+
mkdirSync9(dirname10(path), { recursive: true });
|
|
48400
48802
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
48401
48803
|
try {
|
|
48402
48804
|
writeFileSync10(tmp, text3, { mode: 420 });
|
|
@@ -48411,7 +48813,7 @@ var real = (path) => {
|
|
|
48411
48813
|
try {
|
|
48412
48814
|
return realpathSync8(abs);
|
|
48413
48815
|
} catch {
|
|
48414
|
-
const parent =
|
|
48816
|
+
const parent = dirname10(abs);
|
|
48415
48817
|
return parent === abs ? abs : join18(real(parent), basename6(abs));
|
|
48416
48818
|
}
|
|
48417
48819
|
};
|
|
@@ -48648,23 +49050,23 @@ var noService = {
|
|
|
48648
49050
|
remove: async () => ({}),
|
|
48649
49051
|
cli: () => ["oa-bus"]
|
|
48650
49052
|
};
|
|
48651
|
-
var VERSION = true ? "0.
|
|
48652
|
-
|
|
49053
|
+
var VERSION = true ? "0.156.0" : JSON.parse(
|
|
49054
|
+
readFileSync15(new URL("../package.json", import.meta.url), "utf8")
|
|
48653
49055
|
).version;
|
|
48654
49056
|
var which = (cmd) => {
|
|
48655
49057
|
try {
|
|
48656
|
-
|
|
49058
|
+
execFileSync6("which", [cmd], { stdio: "ignore" });
|
|
48657
49059
|
return true;
|
|
48658
49060
|
} catch {
|
|
48659
49061
|
return false;
|
|
48660
49062
|
}
|
|
48661
49063
|
};
|
|
48662
49064
|
function processArgs2(pid, io = {
|
|
48663
|
-
ps: (pid2) =>
|
|
49065
|
+
ps: (pid2) => execFileSync6(systemTool("ps"), ["-o", "args=", "-p", String(pid2)], {
|
|
48664
49066
|
encoding: "utf8",
|
|
48665
49067
|
stdio: ["ignore", "pipe", "ignore"]
|
|
48666
49068
|
}),
|
|
48667
|
-
proc: (path) =>
|
|
49069
|
+
proc: (path) => readFileSync15(path, "utf8")
|
|
48668
49070
|
}) {
|
|
48669
49071
|
try {
|
|
48670
49072
|
return io.ps(pid).trim() || void 0;
|
|
@@ -48817,7 +49219,7 @@ var configFileLines = (ctx, files2) => files2.flatMap(
|
|
|
48817
49219
|
);
|
|
48818
49220
|
|
|
48819
49221
|
// src/machine.ts
|
|
48820
|
-
import { readFileSync as
|
|
49222
|
+
import { readFileSync as readFileSync16, statSync as statSync8 } from "node:fs";
|
|
48821
49223
|
import { join as join19 } from "node:path";
|
|
48822
49224
|
init_src();
|
|
48823
49225
|
function readMachine(home2) {
|
|
@@ -48826,7 +49228,7 @@ function readMachine(home2) {
|
|
|
48826
49228
|
let mode;
|
|
48827
49229
|
try {
|
|
48828
49230
|
mode = statSync8(file2).mode;
|
|
48829
|
-
text3 =
|
|
49231
|
+
text3 = readFileSync16(file2, "utf8");
|
|
48830
49232
|
} catch (e) {
|
|
48831
49233
|
return e.code === "ENOENT" ? { state: "missing" } : { state: "bad" };
|
|
48832
49234
|
}
|
|
@@ -48850,7 +49252,7 @@ function readMachine(home2) {
|
|
|
48850
49252
|
var lasting = (e) => [...START_ERROR_CODES, "EACCES", "EPERM"].includes(
|
|
48851
49253
|
e?.code
|
|
48852
49254
|
);
|
|
48853
|
-
async function daemon(ctx,
|
|
49255
|
+
async function daemon(ctx, run5 = runDaemon, signals = process) {
|
|
48854
49256
|
const m = readMachine(ctx.home);
|
|
48855
49257
|
if (existsSync5(join20(ctx.home, "revoked")) && (m.state !== "ok" || m.revoked)) {
|
|
48856
49258
|
sayErr(ctx, ctx.copy.revoked());
|
|
@@ -48869,8 +49271,10 @@ async function daemon(ctx, run4 = runDaemon, signals = process) {
|
|
|
48869
49271
|
const onSignal = () => end(0);
|
|
48870
49272
|
signals.once("SIGINT", onSignal);
|
|
48871
49273
|
signals.once("SIGTERM", onSignal);
|
|
48872
|
-
|
|
49274
|
+
run5({
|
|
48873
49275
|
version: ctx.version,
|
|
49276
|
+
// Always on: ~/.oa-bus/logs/events.log (the service owns daemon.log's fd); `oa-bus logs` shows both.
|
|
49277
|
+
events: createEventLog(join20(ctx.home, "logs", "events.log")),
|
|
48874
49278
|
// Only an older token was revoked: a restart picks up the new one.
|
|
48875
49279
|
onRevoked: (replaced) => end(replaced ? 1 : REVOKED_EXIT),
|
|
48876
49280
|
// Exit non-zero: the service restarts the daemon, which binds again.
|
|
@@ -48893,7 +49297,7 @@ async function daemon(ctx, run4 = runDaemon, signals = process) {
|
|
|
48893
49297
|
}
|
|
48894
49298
|
|
|
48895
49299
|
// src/commands/doctor.ts
|
|
48896
|
-
import { readFileSync as
|
|
49300
|
+
import { readFileSync as readFileSync27 } from "node:fs";
|
|
48897
49301
|
import { join as join32 } from "node:path";
|
|
48898
49302
|
|
|
48899
49303
|
// ../bus-adapter-opencode/src/index.ts
|
|
@@ -48912,14 +49316,14 @@ import {
|
|
|
48912
49316
|
existsSync as existsSync12,
|
|
48913
49317
|
lstatSync as lstatSync15,
|
|
48914
49318
|
mkdirSync as mkdirSync12,
|
|
48915
|
-
readFileSync as
|
|
48916
|
-
readlinkSync as
|
|
49319
|
+
readFileSync as readFileSync25,
|
|
49320
|
+
readlinkSync as readlinkSync5,
|
|
48917
49321
|
renameSync as renameSync15,
|
|
48918
49322
|
rmSync as rmSync14,
|
|
48919
49323
|
statSync as statSync10,
|
|
48920
49324
|
writeFileSync as writeFileSync13
|
|
48921
49325
|
} from "node:fs";
|
|
48922
|
-
import { dirname as
|
|
49326
|
+
import { dirname as dirname14, join as join27, resolve as resolve11 } from "node:path";
|
|
48923
49327
|
import { isDeepStrictEqual } from "node:util";
|
|
48924
49328
|
|
|
48925
49329
|
// ../bus-adapter-hermes/src/index.ts
|
|
@@ -50007,10 +50411,10 @@ function removeAt(text3, path) {
|
|
|
50007
50411
|
const solid = (t) => !isSpace(t.kind) && !isComment(t.kind);
|
|
50008
50412
|
const p = toks.filter((t) => t.end <= s && solid(t)).at(-1);
|
|
50009
50413
|
const f = toks.find((t) => t.offset >= e && solid(t));
|
|
50010
|
-
const
|
|
50414
|
+
const open3 = parent.offset + 1;
|
|
50011
50415
|
const close = parent.offset + parent.length - 1;
|
|
50012
|
-
if (p?.offset === parent.offset && f?.offset === close && !comments(
|
|
50013
|
-
return splice(text3,
|
|
50416
|
+
if (p?.offset === parent.offset && f?.offset === close && !comments(open3, close))
|
|
50417
|
+
return splice(text3, open3, close);
|
|
50014
50418
|
const comma = (t) => t?.kind === SyntaxKind2.CommaToken;
|
|
50015
50419
|
if (p && comma(p) && !comments(p.end, s)) return splice(text3, p.offset, e);
|
|
50016
50420
|
let to = e;
|
|
@@ -50153,20 +50557,20 @@ var PI_EXTENSION = fileURLToPath4(
|
|
|
50153
50557
|
);
|
|
50154
50558
|
|
|
50155
50559
|
// src/steps/claude-proof.ts
|
|
50156
|
-
import { readFileSync as
|
|
50560
|
+
import { readFileSync as readFileSync17 } from "node:fs";
|
|
50157
50561
|
import { join as join21 } from "node:path";
|
|
50158
50562
|
var claudeConfigFile = (home2, env2) => join21(env2.CLAUDE_CONFIG_DIR ?? home2, ".claude.json");
|
|
50159
50563
|
var PROOF_COMMAND = "mcp-proof";
|
|
50160
50564
|
var TOKEN_HELPER = /^T=\$\(cat (.+)\) && printf '\{"Authorization":"Bearer %s"\}' "\$T"$/;
|
|
50161
50565
|
var quote = (s) => /^[A-Za-z0-9_./:@%+=,-]+$/.test(s) ? s : `'${s.replaceAll("'", `'\\''`)}'`;
|
|
50162
50566
|
function proofHelper(busBin, opts) {
|
|
50163
|
-
const
|
|
50567
|
+
const run5 = [
|
|
50164
50568
|
...opts.busHome ? [`OA_BUS_HOME=${quote(opts.busHome)}`] : [],
|
|
50165
50569
|
...busBin.map(quote),
|
|
50166
50570
|
PROOF_COMMAND,
|
|
50167
50571
|
...opts.tokenFile ? ["--token-file", opts.tokenFile] : []
|
|
50168
50572
|
].join(" ");
|
|
50169
|
-
return opts.tokenFile ? `T=$(cat ${opts.tokenFile}) && { ${
|
|
50573
|
+
return opts.tokenFile ? `T=$(cat ${opts.tokenFile}) && { ${run5} 2>/dev/null || printf '{"Authorization":"Bearer %s"}' "$T"; }` : run5;
|
|
50170
50574
|
}
|
|
50171
50575
|
var isProofHelper = (helper) => typeof helper === "string" && / mcp-proof( |$)/.test(helper);
|
|
50172
50576
|
var isRecord3 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
@@ -50187,7 +50591,7 @@ function findEntry(doc, origin) {
|
|
|
50187
50591
|
}
|
|
50188
50592
|
var readText = (path) => {
|
|
50189
50593
|
try {
|
|
50190
|
-
return
|
|
50594
|
+
return readFileSync17(path, "utf8");
|
|
50191
50595
|
} catch (e) {
|
|
50192
50596
|
if (e.code === "ENOENT") return "";
|
|
50193
50597
|
throw e;
|
|
@@ -50195,7 +50599,7 @@ var readText = (path) => {
|
|
|
50195
50599
|
};
|
|
50196
50600
|
function readRecord(path) {
|
|
50197
50601
|
try {
|
|
50198
|
-
const v = JSON.parse(
|
|
50602
|
+
const v = JSON.parse(readFileSync17(path, "utf8"));
|
|
50199
50603
|
if (isRecord3(v)) {
|
|
50200
50604
|
const { claudeProof: claudeProof2, ...rest } = v;
|
|
50201
50605
|
const p = claudeProof2;
|
|
@@ -50271,7 +50675,7 @@ function proofState(file2, origin) {
|
|
|
50271
50675
|
// src/steps/codex-proof.ts
|
|
50272
50676
|
init_src3();
|
|
50273
50677
|
init_src();
|
|
50274
|
-
import { existsSync as existsSync6, readFileSync as
|
|
50678
|
+
import { existsSync as existsSync6, readFileSync as readFileSync18, rmSync as rmSync7 } from "node:fs";
|
|
50275
50679
|
import { isAbsolute as isAbsolute10 } from "node:path";
|
|
50276
50680
|
var CODEX_MIN_VERSION = "0.123.0";
|
|
50277
50681
|
var PROXY_CMD = "mcp-proxy";
|
|
@@ -50294,7 +50698,7 @@ var BLOCKING = [
|
|
|
50294
50698
|
var isRecord4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
50295
50699
|
function readMoved(path) {
|
|
50296
50700
|
try {
|
|
50297
|
-
const v = JSON.parse(
|
|
50701
|
+
const v = JSON.parse(readFileSync18(path, "utf8"));
|
|
50298
50702
|
if (isRecord4(v) && typeof v.name === "string" && typeof v.origin === "string" && Array.isArray(v.lines) && v.lines.every((l) => typeof l === "string") && typeof v.original === "string" && typeof v.swapped === "string")
|
|
50299
50703
|
return v;
|
|
50300
50704
|
} catch {
|
|
@@ -50580,7 +50984,7 @@ init_src();
|
|
|
50580
50984
|
import {
|
|
50581
50985
|
existsSync as existsSync9,
|
|
50582
50986
|
lstatSync as lstatSync14,
|
|
50583
|
-
readFileSync as
|
|
50987
|
+
readFileSync as readFileSync22,
|
|
50584
50988
|
realpathSync as realpathSync12,
|
|
50585
50989
|
rmSync as rmSync11
|
|
50586
50990
|
} from "node:fs";
|
|
@@ -50592,9 +50996,9 @@ import {
|
|
|
50592
50996
|
cpSync as cpSync2,
|
|
50593
50997
|
lstatSync as lstatSync11,
|
|
50594
50998
|
mkdirSync as mkdirSync10,
|
|
50595
|
-
readdirSync as
|
|
50596
|
-
readFileSync as
|
|
50597
|
-
readlinkSync as
|
|
50999
|
+
readdirSync as readdirSync6,
|
|
51000
|
+
readFileSync as readFileSync19,
|
|
51001
|
+
readlinkSync as readlinkSync3,
|
|
50598
51002
|
realpathSync as realpathSync9,
|
|
50599
51003
|
renameSync as renameSync13,
|
|
50600
51004
|
rmdirSync,
|
|
@@ -50603,7 +51007,7 @@ import {
|
|
|
50603
51007
|
} from "node:fs";
|
|
50604
51008
|
import {
|
|
50605
51009
|
basename as basename7,
|
|
50606
|
-
dirname as
|
|
51010
|
+
dirname as dirname11,
|
|
50607
51011
|
isAbsolute as isAbsolute11,
|
|
50608
51012
|
join as join22,
|
|
50609
51013
|
relative as relative2,
|
|
@@ -50622,7 +51026,7 @@ var real2 = (p) => {
|
|
|
50622
51026
|
try {
|
|
50623
51027
|
return join22(realpathSync9(cur), ...rest.reverse());
|
|
50624
51028
|
} catch {
|
|
50625
|
-
const up =
|
|
51029
|
+
const up = dirname11(cur);
|
|
50626
51030
|
if (up === cur) return p;
|
|
50627
51031
|
rest.push(basename7(cur));
|
|
50628
51032
|
cur = up;
|
|
@@ -50644,7 +51048,7 @@ function sweepStaging(staging, own2, o = {}) {
|
|
|
50644
51048
|
const alive2 = o.alive ?? pidAlive;
|
|
50645
51049
|
let names2;
|
|
50646
51050
|
try {
|
|
50647
|
-
names2 =
|
|
51051
|
+
names2 = readdirSync6(staging);
|
|
50648
51052
|
} catch {
|
|
50649
51053
|
return;
|
|
50650
51054
|
}
|
|
@@ -50676,13 +51080,13 @@ function hermesHome(home2, env2, platform = process.platform) {
|
|
|
50676
51080
|
const native = nativeHome(home2, env2, platform);
|
|
50677
51081
|
const v = env2.HERMES_HOME?.trim();
|
|
50678
51082
|
const given = v ? tilded(home2, v) : void 0;
|
|
50679
|
-
if (given !== void 0 && basename7(
|
|
51083
|
+
if (given !== void 0 && basename7(dirname11(given)) === "profiles")
|
|
50680
51084
|
return given;
|
|
50681
51085
|
const base3 = given ?? native;
|
|
50682
51086
|
const root = hermesRoot(home2, env2, platform);
|
|
50683
51087
|
if (env2.HERMES_S6_SUPERVISED_CHILD) return base3;
|
|
50684
51088
|
try {
|
|
50685
|
-
const name =
|
|
51089
|
+
const name = readFileSync19(join22(root, "active_profile"), "utf8").trim().toLowerCase();
|
|
50686
51090
|
if (name && name !== "default" && /^[a-z0-9][a-z0-9_-]{0,63}$/.test(name)) {
|
|
50687
51091
|
const dir = join22(root, "profiles", name);
|
|
50688
51092
|
if (lstatSync11(dir).isDirectory()) return dir;
|
|
@@ -50696,7 +51100,7 @@ function hermesRoot(home2, env2, platform = process.platform) {
|
|
|
50696
51100
|
const v = env2.HERMES_HOME?.trim();
|
|
50697
51101
|
const given = v ? tilded(home2, v) : void 0;
|
|
50698
51102
|
if (given === void 0) return native;
|
|
50699
|
-
if (basename7(
|
|
51103
|
+
if (basename7(dirname11(given)) === "profiles") return dirname11(dirname11(given));
|
|
50700
51104
|
const rel = relative2(real2(native), real2(given));
|
|
50701
51105
|
if (rel === "" || !rel.startsWith("..") && !isAbsolute11(rel)) return native;
|
|
50702
51106
|
return given;
|
|
@@ -50713,14 +51117,14 @@ function hermesProfilesScan(home2, env2, platform = process.platform) {
|
|
|
50713
51117
|
return realpathSync9(path);
|
|
50714
51118
|
} catch {
|
|
50715
51119
|
try {
|
|
50716
|
-
return resolve6(
|
|
51120
|
+
return resolve6(dirname11(path), readlinkSync3(path));
|
|
50717
51121
|
} catch {
|
|
50718
51122
|
return "somewhere else";
|
|
50719
51123
|
}
|
|
50720
51124
|
}
|
|
50721
51125
|
};
|
|
50722
51126
|
try {
|
|
50723
|
-
const names2 =
|
|
51127
|
+
const names2 = readdirSync6(path).sort();
|
|
50724
51128
|
return {
|
|
50725
51129
|
names: names2,
|
|
50726
51130
|
incomplete: false,
|
|
@@ -50770,7 +51174,7 @@ var kind = (path) => {
|
|
|
50770
51174
|
};
|
|
50771
51175
|
function files(dir, rel = "") {
|
|
50772
51176
|
const out = [];
|
|
50773
|
-
for (const name of
|
|
51177
|
+
for (const name of readdirSync6(join22(dir, rel)).sort()) {
|
|
50774
51178
|
if (name === "__pycache__" || name.startsWith(".") || name.endsWith(".pyc") || rel === "" && name === HERMES_HABITS_MARKER)
|
|
50775
51179
|
continue;
|
|
50776
51180
|
const r = rel ? `${rel}/${name}` : name;
|
|
@@ -50783,7 +51187,7 @@ function pluginHash(dir) {
|
|
|
50783
51187
|
const h = createHash7("sha256");
|
|
50784
51188
|
for (const f of files(dir)) {
|
|
50785
51189
|
h.update(`${f}\0`);
|
|
50786
|
-
h.update(
|
|
51190
|
+
h.update(readFileSync19(join22(dir, f)));
|
|
50787
51191
|
h.update("\0");
|
|
50788
51192
|
}
|
|
50789
51193
|
return h.digest("hex").slice(0, 16);
|
|
@@ -50794,7 +51198,7 @@ function pluginState(dir, shipped) {
|
|
|
50794
51198
|
if (k !== "dir") return "foreign";
|
|
50795
51199
|
let marker;
|
|
50796
51200
|
try {
|
|
50797
|
-
marker =
|
|
51201
|
+
marker = readFileSync19(join22(dir, HERMES_MARKER), "utf8").trim();
|
|
50798
51202
|
} catch {
|
|
50799
51203
|
return "foreign";
|
|
50800
51204
|
}
|
|
@@ -50917,8 +51321,8 @@ async function hermesEnabled(deps2) {
|
|
|
50917
51321
|
import {
|
|
50918
51322
|
existsSync as existsSync8,
|
|
50919
51323
|
lstatSync as lstatSync13,
|
|
50920
|
-
readdirSync as
|
|
50921
|
-
readFileSync as
|
|
51324
|
+
readdirSync as readdirSync8,
|
|
51325
|
+
readFileSync as readFileSync21,
|
|
50922
51326
|
realpathSync as realpathSync11,
|
|
50923
51327
|
rmSync as rmSync10
|
|
50924
51328
|
} from "node:fs";
|
|
@@ -50931,9 +51335,9 @@ import {
|
|
|
50931
51335
|
existsSync as existsSync7,
|
|
50932
51336
|
lstatSync as lstatSync12,
|
|
50933
51337
|
mkdirSync as mkdirSync11,
|
|
50934
|
-
readdirSync as
|
|
50935
|
-
readFileSync as
|
|
50936
|
-
readlinkSync as
|
|
51338
|
+
readdirSync as readdirSync7,
|
|
51339
|
+
readFileSync as readFileSync20,
|
|
51340
|
+
readlinkSync as readlinkSync4,
|
|
50937
51341
|
realpathSync as realpathSync10,
|
|
50938
51342
|
renameSync as renameSync14,
|
|
50939
51343
|
rmdirSync as rmdirSync2,
|
|
@@ -50941,7 +51345,7 @@ import {
|
|
|
50941
51345
|
statSync as statSync9,
|
|
50942
51346
|
writeFileSync as writeFileSync12
|
|
50943
51347
|
} from "node:fs";
|
|
50944
|
-
import { dirname as
|
|
51348
|
+
import { dirname as dirname12, join as join23, resolve as resolve7 } from "node:path";
|
|
50945
51349
|
var SKILL_MARKER = "<!-- managed by the Open Artifacts bus installer: edits are replaced on reinstall. -->";
|
|
50946
51350
|
var CODEX_BEGIN = "<!-- BEGIN Open Artifacts skill (managed): edits inside are replaced on reinstall. -->";
|
|
50947
51351
|
var CODEX_END = "<!-- END Open Artifacts skill -->";
|
|
@@ -50970,7 +51374,7 @@ var withoutCodexBlock = (text3) => {
|
|
|
50970
51374
|
};
|
|
50971
51375
|
var dropCodexBlock = (agentsPath, notes) => {
|
|
50972
51376
|
if (brokenLink(agentsPath) || !existsSync7(agentsPath)) return false;
|
|
50973
|
-
const text3 =
|
|
51377
|
+
const text3 = readFileSync20(agentsPath, "utf8");
|
|
50974
51378
|
if (codexBroken(text3)) {
|
|
50975
51379
|
notes.push(
|
|
50976
51380
|
`Left ${agentsPath} alone: its Open Artifacts block has no END marker. Fix or remove the block, then rerun the install.`
|
|
@@ -51091,7 +51495,7 @@ var targetOf = (path) => {
|
|
|
51091
51495
|
};
|
|
51092
51496
|
var seq = 0;
|
|
51093
51497
|
var writeAtomic = (path, text3) => {
|
|
51094
|
-
mkdirSync11(
|
|
51498
|
+
mkdirSync11(dirname12(path), { recursive: true });
|
|
51095
51499
|
const tmp = `${path}.oa-${process.pid}-${seq++}.tmp`;
|
|
51096
51500
|
try {
|
|
51097
51501
|
let mode;
|
|
@@ -51152,19 +51556,19 @@ var placesOf = (p) => {
|
|
|
51152
51556
|
const out = [realOrResolved(p)];
|
|
51153
51557
|
try {
|
|
51154
51558
|
if (lstatSync12(p).isSymbolicLink())
|
|
51155
|
-
out.push(realOrResolved(resolve7(
|
|
51559
|
+
out.push(realOrResolved(resolve7(dirname12(p), readlinkSync4(p))));
|
|
51156
51560
|
} catch {
|
|
51157
51561
|
}
|
|
51158
51562
|
return out;
|
|
51159
51563
|
};
|
|
51160
51564
|
var codexSkillsShared = (deps2) => {
|
|
51161
|
-
const mine = placesOf(
|
|
51565
|
+
const mine = placesOf(dirname12(dirname12(codexSkillFile(deps2, "x"))));
|
|
51162
51566
|
const theirs = placesOf(skillDir(deps2, "pi"));
|
|
51163
51567
|
return mine.some((m) => theirs.includes(m));
|
|
51164
51568
|
};
|
|
51165
51569
|
var ourSkillFile = (path, folder) => {
|
|
51166
51570
|
try {
|
|
51167
|
-
return isOurs(
|
|
51571
|
+
return isOurs(readFileSync20(path, "utf8"), folder);
|
|
51168
51572
|
} catch {
|
|
51169
51573
|
return false;
|
|
51170
51574
|
}
|
|
@@ -51174,7 +51578,7 @@ var installCodex = (deps2, folder, text3, written, notes) => {
|
|
|
51174
51578
|
const filePath = codexSkillFile(deps2, folder);
|
|
51175
51579
|
let before;
|
|
51176
51580
|
try {
|
|
51177
|
-
before = existsSync7(targetOf(agentsPath)) ?
|
|
51581
|
+
before = existsSync7(targetOf(agentsPath)) ? readFileSync20(targetOf(agentsPath), "utf8") : "";
|
|
51178
51582
|
} catch (e) {
|
|
51179
51583
|
notes.push(
|
|
51180
51584
|
`Left ${agentsPath} alone: could not read it (${e instanceof Error ? e.message : String(e)}).`
|
|
@@ -51244,7 +51648,7 @@ var installCodex = (deps2, folder, text3, written, notes) => {
|
|
|
51244
51648
|
try {
|
|
51245
51649
|
rmSync9(targetOf(filePath), { force: true });
|
|
51246
51650
|
try {
|
|
51247
|
-
rmdirSync2(
|
|
51651
|
+
rmdirSync2(dirname12(filePath));
|
|
51248
51652
|
} catch {
|
|
51249
51653
|
}
|
|
51250
51654
|
} catch (e) {
|
|
@@ -51326,7 +51730,7 @@ var uninstallSkill = (deps2, harnesses = [
|
|
|
51326
51730
|
let entries;
|
|
51327
51731
|
try {
|
|
51328
51732
|
if (!existsSync7(base3)) return;
|
|
51329
|
-
entries =
|
|
51733
|
+
entries = readdirSync7(base3);
|
|
51330
51734
|
} catch (e) {
|
|
51331
51735
|
fail2(base3, e);
|
|
51332
51736
|
return;
|
|
@@ -51342,7 +51746,7 @@ var uninstallSkill = (deps2, harnesses = [
|
|
|
51342
51746
|
continue;
|
|
51343
51747
|
}
|
|
51344
51748
|
if (!st.isDirectory() || !lstatOk(file2)) continue;
|
|
51345
|
-
if (!isOurs(
|
|
51749
|
+
if (!isOurs(readFileSync20(targetOf(file2), "utf8"), entry)) {
|
|
51346
51750
|
notes.push(
|
|
51347
51751
|
`Left ${file2} alone: it is not an Open Artifacts skill file.`
|
|
51348
51752
|
);
|
|
@@ -51369,7 +51773,7 @@ var uninstallSkill = (deps2, harnesses = [
|
|
|
51369
51773
|
} catch (e) {
|
|
51370
51774
|
fail2(base3, e);
|
|
51371
51775
|
}
|
|
51372
|
-
scan2(join23(
|
|
51776
|
+
scan2(join23(dirname12(base3), "skills"));
|
|
51373
51777
|
continue;
|
|
51374
51778
|
}
|
|
51375
51779
|
scan2(base3);
|
|
@@ -51381,8 +51785,8 @@ var codexSkillState = (deps2) => {
|
|
|
51381
51785
|
shared: codexSkillsShared(deps2)
|
|
51382
51786
|
};
|
|
51383
51787
|
try {
|
|
51384
|
-
const dir = join23(
|
|
51385
|
-
for (const entry of
|
|
51788
|
+
const dir = join23(dirname12(skillDir(deps2, "codex")), "skills");
|
|
51789
|
+
for (const entry of readdirSync7(dir)) {
|
|
51386
51790
|
const file2 = join23(dir, entry, "SKILL.md");
|
|
51387
51791
|
if (ourSkillFile(file2, entry)) {
|
|
51388
51792
|
out.file = file2;
|
|
@@ -51393,7 +51797,7 @@ var codexSkillState = (deps2) => {
|
|
|
51393
51797
|
}
|
|
51394
51798
|
try {
|
|
51395
51799
|
const agents = skillDir(deps2, "codex");
|
|
51396
|
-
if (withoutCodexBlock(
|
|
51800
|
+
if (withoutCodexBlock(readFileSync20(agents, "utf8")) !== void 0)
|
|
51397
51801
|
out.block = agents;
|
|
51398
51802
|
} catch {
|
|
51399
51803
|
}
|
|
@@ -51435,7 +51839,7 @@ function openclawPluginDirs(home2, env2) {
|
|
|
51435
51839
|
const h = openclawHome(home2, env2);
|
|
51436
51840
|
const states = [join24(h, ".openclaw"), join24(h, ".clawdbot")];
|
|
51437
51841
|
try {
|
|
51438
|
-
for (const name of
|
|
51842
|
+
for (const name of readdirSync8(h).sort())
|
|
51439
51843
|
if (name.startsWith(".openclaw-")) states.push(join24(h, name));
|
|
51440
51844
|
} catch {
|
|
51441
51845
|
}
|
|
@@ -51459,7 +51863,7 @@ var kind2 = (path) => {
|
|
|
51459
51863
|
var openclawManifestIsOurs = (dir) => {
|
|
51460
51864
|
try {
|
|
51461
51865
|
const m = JSON.parse(
|
|
51462
|
-
|
|
51866
|
+
readFileSync21(join24(dir, "openclaw.plugin.json"), "utf8")
|
|
51463
51867
|
);
|
|
51464
51868
|
return m?.id === OPENCLAW_PLUGIN_ID;
|
|
51465
51869
|
} catch {
|
|
@@ -51480,7 +51884,7 @@ function openclawPluginState(dir, shipped) {
|
|
|
51480
51884
|
if (k !== "dir") return "foreign";
|
|
51481
51885
|
let marker;
|
|
51482
51886
|
try {
|
|
51483
|
-
marker =
|
|
51887
|
+
marker = readFileSync21(join24(dir, OPENCLAW_MARKER), "utf8").trim();
|
|
51484
51888
|
} catch {
|
|
51485
51889
|
return sameAsShipped(dir, shipped) ? "stale" : "foreign";
|
|
51486
51890
|
}
|
|
@@ -51842,7 +52246,7 @@ function habitsFileState(deps2, h) {
|
|
|
51842
52246
|
try {
|
|
51843
52247
|
if (brokenLink(path)) return { state: "broken", path };
|
|
51844
52248
|
if (!existsSync9(path)) return { state: "absent", path };
|
|
51845
|
-
return { ...blockState(
|
|
52249
|
+
return { ...blockState(readFileSync22(targetOf(path), "utf8")), path };
|
|
51846
52250
|
} catch {
|
|
51847
52251
|
return { state: "broken", path };
|
|
51848
52252
|
}
|
|
@@ -51870,7 +52274,7 @@ function writeHabits(deps2, harnesses, opts = {}) {
|
|
|
51870
52274
|
const real3 = targetOf(path);
|
|
51871
52275
|
try {
|
|
51872
52276
|
const exists2 = existsSync9(real3);
|
|
51873
|
-
const before = exists2 ?
|
|
52277
|
+
const before = exists2 ? readFileSync22(real3, "utf8") : "";
|
|
51874
52278
|
const fresh = blockState(before).state === "absent";
|
|
51875
52279
|
const after = withHabits(before, habitsBlock());
|
|
51876
52280
|
if (after !== before) writeAtomic(real3, after);
|
|
@@ -51901,7 +52305,7 @@ function removeHabits(deps2, harnesses = HABITS_HARNESSES) {
|
|
|
51901
52305
|
try {
|
|
51902
52306
|
if (brokenLink(path) || !existsSync9(path)) continue;
|
|
51903
52307
|
const real3 = targetOf(path);
|
|
51904
|
-
const before =
|
|
52308
|
+
const before = readFileSync22(real3, "utf8");
|
|
51905
52309
|
if (blockState(before).state === "absent") continue;
|
|
51906
52310
|
const rec = kept[path];
|
|
51907
52311
|
const after = withHabits(before, null, rec?.added);
|
|
@@ -51939,7 +52343,7 @@ function habitsOn(deps2) {
|
|
|
51939
52343
|
seen2.add(path);
|
|
51940
52344
|
try {
|
|
51941
52345
|
if (brokenLink(path) || !existsSync9(path)) continue;
|
|
51942
|
-
const s = blockState(
|
|
52346
|
+
const s = blockState(readFileSync22(targetOf(path), "utf8")).state;
|
|
51943
52347
|
if (s === "current" || s === "changed") out.push(path);
|
|
51944
52348
|
} catch {
|
|
51945
52349
|
}
|
|
@@ -52146,8 +52550,8 @@ var habitsQuestionLines = (q) => [
|
|
|
52146
52550
|
];
|
|
52147
52551
|
|
|
52148
52552
|
// src/steps/opencode-proof.ts
|
|
52149
|
-
import { existsSync as existsSync10, readFileSync as
|
|
52150
|
-
import { dirname as
|
|
52553
|
+
import { existsSync as existsSync10, readFileSync as readFileSync23, rmSync as rmSync12 } from "node:fs";
|
|
52554
|
+
import { dirname as dirname13, isAbsolute as isAbsolute12, join as join26, resolve as resolve10 } from "node:path";
|
|
52151
52555
|
init_src();
|
|
52152
52556
|
var OPENCODE_ENTRY_FILE = "opencode-mcp-entry.json";
|
|
52153
52557
|
var isRecord5 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
@@ -52190,7 +52594,7 @@ var REMOTE_ONLY = /* @__PURE__ */ new Set(["type", "url", "headers", "oauth"]);
|
|
|
52190
52594
|
function resolveTokenFile(x, configFile, home2) {
|
|
52191
52595
|
if (x === "~") return home2;
|
|
52192
52596
|
if (x.startsWith("~/")) return join26(home2, x.slice(2));
|
|
52193
|
-
return isAbsolute12(x) ? x : resolve10(
|
|
52597
|
+
return isAbsolute12(x) ? x : resolve10(dirname13(configFile), x);
|
|
52194
52598
|
}
|
|
52195
52599
|
var proxyEntry = (io, origin, tokenFile, entry) => {
|
|
52196
52600
|
const kept = Object.fromEntries(
|
|
@@ -52229,7 +52633,7 @@ function ourEntry2(e, origin) {
|
|
|
52229
52633
|
}
|
|
52230
52634
|
function readMoved2(path) {
|
|
52231
52635
|
try {
|
|
52232
|
-
const v = JSON.parse(
|
|
52636
|
+
const v = JSON.parse(readFileSync23(path, "utf8"));
|
|
52233
52637
|
if (isRecord5(v) && typeof v.file === "string" && Array.isArray(v.path) && typeof v.origin === "string" && isRecord5(v.config))
|
|
52234
52638
|
return v;
|
|
52235
52639
|
} catch {
|
|
@@ -52338,7 +52742,7 @@ function proxyEntries(text3) {
|
|
|
52338
52742
|
}
|
|
52339
52743
|
|
|
52340
52744
|
// src/steps/pi-proof.ts
|
|
52341
|
-
import { existsSync as existsSync11, readFileSync as
|
|
52745
|
+
import { existsSync as existsSync11, readFileSync as readFileSync24, rmSync as rmSync13 } from "node:fs";
|
|
52342
52746
|
var PI_ENTRY_FILE = "pi-mcp-entry.json";
|
|
52343
52747
|
var OMP_ORIGIN_FILE = "omp-mcp-origin.json";
|
|
52344
52748
|
var PI_MIN_VERSION = "1.5.0";
|
|
@@ -52346,7 +52750,7 @@ var isRecord6 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
|
52346
52750
|
var BOM2 = "\uFEFF";
|
|
52347
52751
|
function readConfig2(file2) {
|
|
52348
52752
|
if (!existsSync11(file2)) return null;
|
|
52349
|
-
const raw =
|
|
52753
|
+
const raw = readFileSync24(file2, "utf8");
|
|
52350
52754
|
const bom = raw.startsWith(BOM2);
|
|
52351
52755
|
const text3 = bom ? raw.slice(1) : raw;
|
|
52352
52756
|
const parsed = JSON.parse(text3);
|
|
@@ -52380,7 +52784,7 @@ function findEntry2(servers4, origin) {
|
|
|
52380
52784
|
}
|
|
52381
52785
|
function readMoved3(path) {
|
|
52382
52786
|
try {
|
|
52383
|
-
const v = JSON.parse(
|
|
52787
|
+
const v = JSON.parse(readFileSync24(path, "utf8"));
|
|
52384
52788
|
if (isRecord6(v) && typeof v.name === "string" && typeof v.index === "number" && isRecord6(v.config))
|
|
52385
52789
|
return {
|
|
52386
52790
|
name: v.name,
|
|
@@ -52450,8 +52854,8 @@ var HARNESSES = [
|
|
|
52450
52854
|
"openclaw"
|
|
52451
52855
|
];
|
|
52452
52856
|
var readAssets = () => ({
|
|
52453
|
-
pi:
|
|
52454
|
-
opencodePlugin:
|
|
52857
|
+
pi: readFileSync25(PI_EXTENSION, "utf8"),
|
|
52858
|
+
opencodePlugin: readFileSync25(OPENCODE_TUI_PLUGIN, "utf8"),
|
|
52455
52859
|
// A folder, not text: the plugin is several Python files.
|
|
52456
52860
|
hermes: HERMES_PLUGIN,
|
|
52457
52861
|
// Built from packages/bus-adapter-openclaw (the CLI's bundle step does it).
|
|
@@ -52528,7 +52932,7 @@ var sharedFile = (deps2) => paths(deps2).omp === paths(deps2).pi;
|
|
|
52528
52932
|
function readDoc(path) {
|
|
52529
52933
|
let text3;
|
|
52530
52934
|
try {
|
|
52531
|
-
text3 =
|
|
52935
|
+
text3 = readFileSync25(path, "utf8");
|
|
52532
52936
|
} catch (e) {
|
|
52533
52937
|
if (e.code === "ENOENT") return {};
|
|
52534
52938
|
throw e;
|
|
@@ -52553,19 +52957,19 @@ function target(path) {
|
|
|
52553
52957
|
let p = path;
|
|
52554
52958
|
for (let hops = 0; hops < 40; hops++) {
|
|
52555
52959
|
if (!present2(p) || !lstatSync15(p).isSymbolicLink()) {
|
|
52556
|
-
if (p !== path && !existsSync12(
|
|
52960
|
+
if (p !== path && !existsSync12(dirname14(p)))
|
|
52557
52961
|
throw new Error(
|
|
52558
52962
|
`${path} is a dangling symlink to ${p}; left it untouched`
|
|
52559
52963
|
);
|
|
52560
52964
|
return p;
|
|
52561
52965
|
}
|
|
52562
|
-
p = resolve11(
|
|
52966
|
+
p = resolve11(dirname14(p), readlinkSync5(p));
|
|
52563
52967
|
}
|
|
52564
52968
|
throw new Error(`${path}: too many symlinks; left it untouched`);
|
|
52565
52969
|
}
|
|
52566
52970
|
function writeAtomic2(path, data, mode) {
|
|
52567
52971
|
const dest = target(path);
|
|
52568
|
-
mkdirSync12(
|
|
52972
|
+
mkdirSync12(dirname14(dest), { recursive: true });
|
|
52569
52973
|
let m = mode ?? 420;
|
|
52570
52974
|
if (mode === void 0)
|
|
52571
52975
|
try {
|
|
@@ -52585,7 +52989,7 @@ function writeAtomic2(path, data, mode) {
|
|
|
52585
52989
|
function readJsonc(path) {
|
|
52586
52990
|
let text3;
|
|
52587
52991
|
try {
|
|
52588
|
-
text3 =
|
|
52992
|
+
text3 = readFileSync25(path, "utf8");
|
|
52589
52993
|
} catch (e) {
|
|
52590
52994
|
if (e.code === "ENOENT") return "";
|
|
52591
52995
|
throw e;
|
|
@@ -52602,7 +53006,7 @@ function saveText(path, before, next, ok) {
|
|
|
52602
53006
|
}
|
|
52603
53007
|
function readRecord2(path) {
|
|
52604
53008
|
try {
|
|
52605
|
-
const v = JSON.parse(
|
|
53009
|
+
const v = JSON.parse(readFileSync25(path, "utf8"));
|
|
52606
53010
|
const c = v?.created;
|
|
52607
53011
|
if (typeof c === "object" && c !== null) return c;
|
|
52608
53012
|
} catch {
|
|
@@ -52613,7 +53017,7 @@ function writeRecord2(path, before, created) {
|
|
|
52613
53017
|
if (isDeepStrictEqual(before, created)) return;
|
|
52614
53018
|
let rest = {};
|
|
52615
53019
|
try {
|
|
52616
|
-
const v = JSON.parse(
|
|
53020
|
+
const v = JSON.parse(readFileSync25(path, "utf8"));
|
|
52617
53021
|
if (typeof v === "object" && v !== null && !Array.isArray(v))
|
|
52618
53022
|
rest = v;
|
|
52619
53023
|
} catch {
|
|
@@ -52632,7 +53036,7 @@ function save(path, before, next) {
|
|
|
52632
53036
|
writeAtomic2(path, json2(next));
|
|
52633
53037
|
return true;
|
|
52634
53038
|
}
|
|
52635
|
-
async function
|
|
53039
|
+
async function run4(deps2, cmd, args) {
|
|
52636
53040
|
try {
|
|
52637
53041
|
return await deps2.exec(cmd, args);
|
|
52638
53042
|
} catch (e) {
|
|
@@ -52694,7 +53098,7 @@ async function codexEntryStep(deps2, notes) {
|
|
|
52694
53098
|
return;
|
|
52695
53099
|
}
|
|
52696
53100
|
const bin = findCodexBin({ path: deps2.env?.PATH, app: deps2.codexApp });
|
|
52697
|
-
const r = await
|
|
53101
|
+
const r = await run4(deps2, bin ?? "codex", ["--version"]);
|
|
52698
53102
|
const version2 = /(\d+\.\d+\.\d+\S*)/.exec(
|
|
52699
53103
|
r.code === 0 ? r.stdout : ""
|
|
52700
53104
|
)?.[1];
|
|
@@ -52734,7 +53138,7 @@ async function piEntry(deps2, notes) {
|
|
|
52734
53138
|
);
|
|
52735
53139
|
return;
|
|
52736
53140
|
}
|
|
52737
|
-
const r = await
|
|
53141
|
+
const r = await run4(deps2, "pi", ["--version"]);
|
|
52738
53142
|
const version2 = r.code === 0 ? r.stdout.trim().split(/\s+/)[0] : void 0;
|
|
52739
53143
|
if (version2 === void 0 || (compareVersions(version2, PI_MIN_VERSION) ?? -1) < 0) {
|
|
52740
53144
|
notes.push(
|
|
@@ -52779,16 +53183,16 @@ var codexHere = (deps2) => hasCodex({
|
|
|
52779
53183
|
app: deps2.codexApp
|
|
52780
53184
|
});
|
|
52781
53185
|
async function restartOpencode(deps2, notes) {
|
|
52782
|
-
const r = await
|
|
53186
|
+
const r = await run4(deps2, "opencode", ["service", "restart"]);
|
|
52783
53187
|
if (r.code !== 0) notes.push(`${RESTART_FAILED}: ${firstLine3(r.stderr)}`);
|
|
52784
53188
|
}
|
|
52785
53189
|
var install = {
|
|
52786
53190
|
// Claude rewrites ~/.claude.json while it runs, so its own CLI does the edit.
|
|
52787
53191
|
async claude(deps2, notes) {
|
|
52788
53192
|
if (!deps2.which("claude")) return "absent";
|
|
52789
|
-
await
|
|
53193
|
+
await run4(deps2, "claude", ["mcp", "remove", "--scope", "user", NAME2]);
|
|
52790
53194
|
const moved = movedHome(deps2);
|
|
52791
|
-
const add = await
|
|
53195
|
+
const add = await run4(deps2, "claude", [
|
|
52792
53196
|
"mcp",
|
|
52793
53197
|
"add",
|
|
52794
53198
|
"--scope",
|
|
@@ -52923,7 +53327,7 @@ var install = {
|
|
|
52923
53327
|
const pin = codexBinPin(bin);
|
|
52924
53328
|
let had = "";
|
|
52925
53329
|
try {
|
|
52926
|
-
had =
|
|
53330
|
+
had = readFileSync25(p.codexBin, "utf8");
|
|
52927
53331
|
} catch {
|
|
52928
53332
|
}
|
|
52929
53333
|
if (had !== pin) writeAtomic2(p.codexBin, pin, 384);
|
|
@@ -52953,7 +53357,7 @@ var uninstall = {
|
|
|
52953
53357
|
);
|
|
52954
53358
|
}
|
|
52955
53359
|
if (deps2.which("claude")) {
|
|
52956
|
-
const r = await
|
|
53360
|
+
const r = await run4(deps2, "claude", [
|
|
52957
53361
|
"mcp",
|
|
52958
53362
|
"remove",
|
|
52959
53363
|
"--scope",
|
|
@@ -53121,7 +53525,7 @@ function opencodeProxyProblem(deps2) {
|
|
|
53121
53525
|
const p = paths(deps2);
|
|
53122
53526
|
for (const f of p.opencodeConfigs.filter(present2))
|
|
53123
53527
|
try {
|
|
53124
|
-
for (const { name, entry } of proxyEntries(
|
|
53528
|
+
for (const { name, entry } of proxyEntries(readFileSync25(f, "utf8"))) {
|
|
53125
53529
|
const missing2 = proxyProgramMissing2(entry, void 0, deps2.which);
|
|
53126
53530
|
if (missing2 !== void 0) return { name, missing: missing2 };
|
|
53127
53531
|
}
|
|
@@ -53141,7 +53545,7 @@ function checkAdapters(deps2) {
|
|
|
53141
53545
|
const homeOf = (env2) => typeof env2 === "object" && env2 !== null ? env2.OA_BUS_HOME : void 0;
|
|
53142
53546
|
const homed = (file2) => {
|
|
53143
53547
|
if (!existsSync12(file2)) return false;
|
|
53144
|
-
const first =
|
|
53548
|
+
const first = readFileSync25(file2, "utf8").split("\n", 1)[0] ?? "";
|
|
53145
53549
|
const ob = movedHome(deps2);
|
|
53146
53550
|
return ob === void 0 ? !first.startsWith("process.env.OA_BUS_HOME ||=") : first === homeLine(ob);
|
|
53147
53551
|
};
|
|
@@ -53157,11 +53561,11 @@ function checkAdapters(deps2) {
|
|
|
53157
53561
|
opencode: state(
|
|
53158
53562
|
"opencode",
|
|
53159
53563
|
() => p.opencodeConfigs.filter(present2).some((f) => {
|
|
53160
|
-
const d = parseJsonc(
|
|
53564
|
+
const d = parseJsonc(readFileSync25(f, "utf8"), f);
|
|
53161
53565
|
const e = servers3(d)?.[NAME2] ?? d.mcp?.[NAME2];
|
|
53162
53566
|
return e !== void 0 && homeOf(e.environment) === movedHome(deps2);
|
|
53163
53567
|
}) && listed(
|
|
53164
|
-
parseJsonc(
|
|
53568
|
+
parseJsonc(readFileSync25(p.opencodeCli, "utf8"), p.opencodeCli),
|
|
53165
53569
|
p.opencodePlugin
|
|
53166
53570
|
) && homed(join27(p.opencodePlugin, "tui.js"))
|
|
53167
53571
|
),
|
|
@@ -53212,12 +53616,12 @@ function codexProxyProblem(deps2) {
|
|
|
53212
53616
|
import {
|
|
53213
53617
|
existsSync as existsSync13,
|
|
53214
53618
|
lstatSync as lstatSync16,
|
|
53215
|
-
readdirSync as
|
|
53216
|
-
readFileSync as
|
|
53619
|
+
readdirSync as readdirSync9,
|
|
53620
|
+
readFileSync as readFileSync26,
|
|
53217
53621
|
rmdirSync as rmdirSync3,
|
|
53218
53622
|
rmSync as rmSync15
|
|
53219
53623
|
} from "node:fs";
|
|
53220
|
-
import { dirname as
|
|
53624
|
+
import { dirname as dirname15, join as join28 } from "node:path";
|
|
53221
53625
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
53222
53626
|
var OUTPUT_STYLE_FILE = "artifacts-teammate.md";
|
|
53223
53627
|
var OUTPUT_STYLE_MARKER = "<!-- managed by the Open Artifacts bus installer: edits are replaced on reinstall. -->";
|
|
@@ -53237,7 +53641,7 @@ var outputStyleSource = () => {
|
|
|
53237
53641
|
"../../output-style/artifacts-teammate.md"
|
|
53238
53642
|
]) {
|
|
53239
53643
|
const path = fileURLToPath6(new URL(rel, import.meta.url));
|
|
53240
|
-
if (existsSync13(path)) return
|
|
53644
|
+
if (existsSync13(path)) return readFileSync26(path, "utf8");
|
|
53241
53645
|
}
|
|
53242
53646
|
throw new Error("the Artifacts Teammate output style is missing");
|
|
53243
53647
|
};
|
|
@@ -53271,7 +53675,7 @@ var readSettings = (path) => {
|
|
|
53271
53675
|
if (isLink2(path)) return { ok: false, why: "it is a symlink" };
|
|
53272
53676
|
if (!exists(path)) return { ok: true, text: void 0, style: void 0 };
|
|
53273
53677
|
try {
|
|
53274
|
-
const text3 =
|
|
53678
|
+
const text3 = readFileSync26(path, "utf8");
|
|
53275
53679
|
parseJsonc(text3, path);
|
|
53276
53680
|
return { ok: true, text: text3, style: jsoncValue(text3, ["outputStyle"]) };
|
|
53277
53681
|
} catch {
|
|
@@ -53333,7 +53737,7 @@ function installOutputStyle(deps2, harnesses) {
|
|
|
53333
53737
|
}
|
|
53334
53738
|
try {
|
|
53335
53739
|
const there = exists(path);
|
|
53336
|
-
if (there && !isOurs2(
|
|
53740
|
+
if (there && !isOurs2(readFileSync26(path, "utf8"))) {
|
|
53337
53741
|
out.notes.push(
|
|
53338
53742
|
`Left ${path} alone: it has no Open Artifacts marker, so it is not ours to replace.`
|
|
53339
53743
|
);
|
|
@@ -53385,7 +53789,7 @@ function uninstallOutputStyle(deps2) {
|
|
|
53385
53789
|
);
|
|
53386
53790
|
} else if (!exists(path)) {
|
|
53387
53791
|
gone = true;
|
|
53388
|
-
} else if (!isOurs2(
|
|
53792
|
+
} else if (!isOurs2(readFileSync26(path, "utf8"))) {
|
|
53389
53793
|
out.notes.push(
|
|
53390
53794
|
`Left ${path} alone: it has no Open Artifacts marker, so it is not ours to replace.`
|
|
53391
53795
|
);
|
|
@@ -53393,7 +53797,7 @@ function uninstallOutputStyle(deps2) {
|
|
|
53393
53797
|
rmSync15(path);
|
|
53394
53798
|
out.written.push(path);
|
|
53395
53799
|
gone = true;
|
|
53396
|
-
if (
|
|
53800
|
+
if (readdirSync9(dir).length === 0) rmdirSync3(dir);
|
|
53397
53801
|
}
|
|
53398
53802
|
} catch (e) {
|
|
53399
53803
|
out.notes.push(
|
|
@@ -53406,8 +53810,8 @@ function uninstallOutputStyle(deps2) {
|
|
|
53406
53810
|
var outputStyleState = (deps2) => {
|
|
53407
53811
|
const path = outputStyleFile(deps2);
|
|
53408
53812
|
try {
|
|
53409
|
-
if (isLink2(
|
|
53410
|
-
if (!isOurs2(
|
|
53813
|
+
if (isLink2(dirname15(path)) || isLink2(path)) return void 0;
|
|
53814
|
+
if (!isOurs2(readFileSync26(path, "utf8"))) return void 0;
|
|
53411
53815
|
const s = readSettings(claudeSettingsFile(deps2));
|
|
53412
53816
|
return { path, on: s.ok && s.style === OUTPUT_STYLE_NAME };
|
|
53413
53817
|
} catch {
|
|
@@ -53440,11 +53844,11 @@ function wired(ctx) {
|
|
|
53440
53844
|
};
|
|
53441
53845
|
}
|
|
53442
53846
|
var stamp = (ctx) => new Date(ctx.now()).toISOString();
|
|
53443
|
-
var
|
|
53847
|
+
var one2 = (ctx, f) => {
|
|
53444
53848
|
const link2 = linkInfo({ home: ctx.userHome }, f);
|
|
53445
53849
|
return link2 ? `${tilde(ctx, f)} (symlink to ${tilde(ctx, link2.target)}${link2.outside ? ", outside your home" : ""})` : tilde(ctx, f);
|
|
53446
53850
|
};
|
|
53447
|
-
var shown2 = (ctx, files2) => files2.map((f) =>
|
|
53851
|
+
var shown2 = (ctx, files2) => files2.map((f) => one2(ctx, f)).join(", ");
|
|
53448
53852
|
var pluginStateText = (ctx, p) => `${p.label} plugin: ${pluginHabitsState(deps(ctx), p)}`;
|
|
53449
53853
|
var show = (ctx) => {
|
|
53450
53854
|
say(
|
|
@@ -53501,7 +53905,7 @@ var pluginStates = (ctx) => Object.fromEntries(
|
|
|
53501
53905
|
PLUGIN_HARNESSES.map((p) => [p.name, pluginHabitsState(deps(ctx), p)])
|
|
53502
53906
|
);
|
|
53503
53907
|
function disclosure(ctx, pending) {
|
|
53504
|
-
const files2 = pending.map((p) => p.label ??
|
|
53908
|
+
const files2 = pending.map((p) => p.label ?? one2(ctx, p.path));
|
|
53505
53909
|
const changed = pending.filter((p) => p.s.state === "changed");
|
|
53506
53910
|
if (changed.length === 0)
|
|
53507
53911
|
return [
|
|
@@ -53550,7 +53954,7 @@ async function habitsAfterInstall(ctx, json3) {
|
|
|
53550
53954
|
const state = changed ? "changed" : "undecided";
|
|
53551
53955
|
const asked = pending.map((p) => p.path);
|
|
53552
53956
|
const question = habitsQuestion(
|
|
53553
|
-
pending.map((p) => p.label ??
|
|
53957
|
+
pending.map((p) => p.label ?? one2(ctx, p.path)),
|
|
53554
53958
|
// --json goes to an agent that may hand the commands to its user's own shell.
|
|
53555
53959
|
json3 ? BUS_CMD : ctx.busCmd
|
|
53556
53960
|
);
|
|
@@ -53632,12 +54036,12 @@ function habitsLine(ctx) {
|
|
|
53632
54036
|
(p) => plugins2.includes(p) || pluginHabitsState(deps(ctx), p) === "on"
|
|
53633
54037
|
);
|
|
53634
54038
|
const states = used.map((p) => pluginStateText(ctx, p));
|
|
53635
|
-
const
|
|
53636
|
-
if (on.length > 0) return `Habits: on in ${shown2(ctx, on)}${
|
|
54039
|
+
const tail2 = states.length > 0 ? `; ${states.join("; ")}` : "";
|
|
54040
|
+
if (on.length > 0) return `Habits: on in ${shown2(ctx, on)}${tail2}`;
|
|
53637
54041
|
if (used.some((p) => pluginHabitsState(deps(ctx), p) === "on"))
|
|
53638
54042
|
return `Habits: ${states.join("; ")}`;
|
|
53639
54043
|
if (targets.length > 0 || plugins2.length > 0)
|
|
53640
|
-
return `Habits: not decided (${ctx.busCmd} install --habits to add them)${
|
|
54044
|
+
return `Habits: not decided (${ctx.busCmd} install --habits to add them)${tail2}`;
|
|
53641
54045
|
return void 0;
|
|
53642
54046
|
}
|
|
53643
54047
|
|
|
@@ -53865,7 +54269,7 @@ init_src();
|
|
|
53865
54269
|
|
|
53866
54270
|
// src/commands/install.ts
|
|
53867
54271
|
init_src3();
|
|
53868
|
-
import { dirname as
|
|
54272
|
+
import { dirname as dirname16, join as join31 } from "node:path";
|
|
53869
54273
|
init_src2();
|
|
53870
54274
|
|
|
53871
54275
|
// src/live.ts
|
|
@@ -54268,7 +54672,7 @@ function reportShim(ctx) {
|
|
|
54268
54672
|
if (r.kind === "installed") {
|
|
54269
54673
|
say(ctx, ctx.copy.shimInstalled(tilde(ctx, r.path)));
|
|
54270
54674
|
if (!r.onPath && r.hint)
|
|
54271
|
-
say(ctx, ctx.copy.shimNotOnPath(tilde(ctx,
|
|
54675
|
+
say(ctx, ctx.copy.shimNotOnPath(tilde(ctx, dirname16(r.path)), r.hint));
|
|
54272
54676
|
} else if (r.kind === "other-home")
|
|
54273
54677
|
say(ctx, ctx.copy.shimOtherHome(tilde(ctx, r.path), tilde(ctx, r.home)));
|
|
54274
54678
|
else if (r.kind === "foreign")
|
|
@@ -54485,7 +54889,7 @@ async function healthz(ctx, hub) {
|
|
|
54485
54889
|
function claudeIsolates(path) {
|
|
54486
54890
|
let text3;
|
|
54487
54891
|
try {
|
|
54488
|
-
text3 =
|
|
54892
|
+
text3 = readFileSync27(path, "utf8");
|
|
54489
54893
|
} catch {
|
|
54490
54894
|
return void 0;
|
|
54491
54895
|
}
|
|
@@ -54783,12 +55187,12 @@ async function global(opts, ctx) {
|
|
|
54783
55187
|
}
|
|
54784
55188
|
|
|
54785
55189
|
// src/commands/leads.ts
|
|
54786
|
-
import { readFileSync as
|
|
55190
|
+
import { readFileSync as readFileSync28 } from "node:fs";
|
|
54787
55191
|
import { join as join33 } from "node:path";
|
|
54788
55192
|
function hubOrigin(ctx) {
|
|
54789
55193
|
try {
|
|
54790
55194
|
const raw = JSON.parse(
|
|
54791
|
-
|
|
55195
|
+
readFileSync28(join33(ctx.home, "machine.json"), "utf8")
|
|
54792
55196
|
);
|
|
54793
55197
|
return typeof raw?.hub === "string" ? new URL(raw.hub).origin : void 0;
|
|
54794
55198
|
} catch {
|
|
@@ -54941,20 +55345,28 @@ async function link(opts, ctx) {
|
|
|
54941
55345
|
}
|
|
54942
55346
|
|
|
54943
55347
|
// src/commands/logs.ts
|
|
54944
|
-
import { readFileSync as
|
|
55348
|
+
import { readFileSync as readFileSync29 } from "node:fs";
|
|
54945
55349
|
import { join as join34 } from "node:path";
|
|
54946
55350
|
var TAIL = 50;
|
|
54947
|
-
|
|
54948
|
-
const path = join34(ctx.home, "logs", "daemon.log");
|
|
54949
|
-
let text3;
|
|
55351
|
+
var tail = (path) => {
|
|
54950
55352
|
try {
|
|
54951
|
-
|
|
55353
|
+
return readFileSync29(path, "utf8").replace(/\n$/, "").split("\n").slice(-TAIL);
|
|
54952
55354
|
} catch {
|
|
55355
|
+
return void 0;
|
|
55356
|
+
}
|
|
55357
|
+
};
|
|
55358
|
+
async function logs(ctx) {
|
|
55359
|
+
const path = join34(ctx.home, "logs", "daemon.log");
|
|
55360
|
+
const daemon2 = tail(path);
|
|
55361
|
+
const events = tail(join34(ctx.home, "logs", "events.log"));
|
|
55362
|
+
if (!daemon2 && !events) {
|
|
54953
55363
|
say(ctx, ctx.copy.noLog(tilde(ctx, path)));
|
|
54954
55364
|
return 1;
|
|
54955
55365
|
}
|
|
54956
|
-
|
|
54957
|
-
|
|
55366
|
+
say(
|
|
55367
|
+
ctx,
|
|
55368
|
+
daemon2 && events ? [...daemon2, "--- events.log ---", ...events] : daemon2 ?? events ?? []
|
|
55369
|
+
);
|
|
54958
55370
|
return 0;
|
|
54959
55371
|
}
|
|
54960
55372
|
|
|
@@ -54977,9 +55389,9 @@ async function mcp(harness, ctx, load = (h) => MCP_SERVER[h]()) {
|
|
|
54977
55389
|
init_src3();
|
|
54978
55390
|
init_src2();
|
|
54979
55391
|
init_src();
|
|
54980
|
-
import { execFileSync as
|
|
55392
|
+
import { execFileSync as execFileSync7 } from "node:child_process";
|
|
54981
55393
|
import { createHash as createHash8, randomBytes as randomBytes8 } from "node:crypto";
|
|
54982
|
-
import { readFileSync as
|
|
55394
|
+
import { readFileSync as readFileSync30, readlinkSync as readlinkSync6 } from "node:fs";
|
|
54983
55395
|
import { basename as basename8 } from "node:path";
|
|
54984
55396
|
var isClaude = (name) => name === "claude" || /\/claude\/versions\/[^/]+$/.test(name);
|
|
54985
55397
|
function parsePs(out) {
|
|
@@ -54990,19 +55402,19 @@ function parsePs(out) {
|
|
|
54990
55402
|
}
|
|
54991
55403
|
function readProc(pid) {
|
|
54992
55404
|
try {
|
|
54993
|
-
const stat =
|
|
55405
|
+
const stat = readFileSync30(`/proc/${pid}/stat`, "utf8");
|
|
54994
55406
|
const ppid = Number(stat.slice(stat.lastIndexOf(")") + 1).split(/\s+/)[2]);
|
|
54995
55407
|
let exe = "";
|
|
54996
55408
|
try {
|
|
54997
|
-
exe =
|
|
55409
|
+
exe = readlinkSync6(`/proc/${pid}/exe`);
|
|
54998
55410
|
} catch {
|
|
54999
55411
|
}
|
|
55000
|
-
const comm =
|
|
55412
|
+
const comm = readFileSync30(`/proc/${pid}/comm`, "utf8").trim();
|
|
55001
55413
|
return { ppid, name: isClaude(exe) ? exe : comm };
|
|
55002
55414
|
} catch {
|
|
55003
55415
|
}
|
|
55004
55416
|
try {
|
|
55005
|
-
const out =
|
|
55417
|
+
const out = execFileSync7(
|
|
55006
55418
|
systemTool("ps"),
|
|
55007
55419
|
["-o", "ppid=,comm=", "-p", String(pid)],
|
|
55008
55420
|
{ encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }
|
|
@@ -55025,7 +55437,7 @@ function findClaude(from, proc) {
|
|
|
55025
55437
|
function tokenOf(file2) {
|
|
55026
55438
|
if (!file2) return void 0;
|
|
55027
55439
|
try {
|
|
55028
|
-
return
|
|
55440
|
+
return readFileSync30(file2, "utf8").trim() || void 0;
|
|
55029
55441
|
} catch {
|
|
55030
55442
|
return void 0;
|
|
55031
55443
|
}
|
|
@@ -55186,7 +55598,7 @@ import { join as join37 } from "node:path";
|
|
|
55186
55598
|
|
|
55187
55599
|
// src/steps/purge.ts
|
|
55188
55600
|
init_src3();
|
|
55189
|
-
import { lstatSync as lstatSync17, readdirSync as
|
|
55601
|
+
import { lstatSync as lstatSync17, readdirSync as readdirSync10, rmdirSync as rmdirSync4, rmSync as rmSync17 } from "node:fs";
|
|
55190
55602
|
import { join as join36 } from "node:path";
|
|
55191
55603
|
var FILES = [
|
|
55192
55604
|
"machine.json",
|
|
@@ -55243,7 +55655,7 @@ function purgeShort(dir, removed) {
|
|
|
55243
55655
|
[dir, (n) => /^daemon\.sock(\.keep-\d+)?$/.test(n)]
|
|
55244
55656
|
]) {
|
|
55245
55657
|
if (kind3(d) !== "dir") continue;
|
|
55246
|
-
for (const name of
|
|
55658
|
+
for (const name of readdirSync10(d)) {
|
|
55247
55659
|
const path = join36(d, name);
|
|
55248
55660
|
const k = kind3(path);
|
|
55249
55661
|
if (k === void 0 || k === "dir" || !ours2(name, path)) continue;
|
|
@@ -55257,7 +55669,7 @@ function purgeShort(dir, removed) {
|
|
|
55257
55669
|
function purge(home2, opts) {
|
|
55258
55670
|
let entries;
|
|
55259
55671
|
try {
|
|
55260
|
-
entries =
|
|
55672
|
+
entries = readdirSync10(home2);
|
|
55261
55673
|
} catch {
|
|
55262
55674
|
return { removed: [], leftDir: false };
|
|
55263
55675
|
}
|
|
@@ -55278,7 +55690,7 @@ function purge(home2, opts) {
|
|
|
55278
55690
|
for (const folder of FOLDERS) {
|
|
55279
55691
|
const dir = join36(home2, folder.path);
|
|
55280
55692
|
if (kind3(dir) !== "dir") continue;
|
|
55281
|
-
for (const name of
|
|
55693
|
+
for (const name of readdirSync10(dir)) {
|
|
55282
55694
|
const path = join36(dir, name);
|
|
55283
55695
|
const k = kind3(path);
|
|
55284
55696
|
if (k === void 0 || !folder.ours(name, path)) continue;
|