@open-artifacts/bus 0.146.0 → 0.147.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 +450 -171
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4586,7 +4586,7 @@ function isRef(value) {
|
|
|
4586
4586
|
function cloneIssues(issues) {
|
|
4587
4587
|
return issues.map((iss) => iss.path ? { ...iss, path: iss.path.slice() } : { ...iss });
|
|
4588
4588
|
}
|
|
4589
|
-
function isRecursive(inst, stack,
|
|
4589
|
+
function isRecursive(inst, stack, resolve15) {
|
|
4590
4590
|
const cached2 = recursive.get(inst);
|
|
4591
4591
|
if (cached2 !== void 0)
|
|
4592
4592
|
return cached2 ? PROVEN : NONE;
|
|
@@ -4596,7 +4596,7 @@ function isRecursive(inst, stack, resolve14) {
|
|
|
4596
4596
|
let result = NONE;
|
|
4597
4597
|
const check2 = (child) => {
|
|
4598
4598
|
if (result !== PROVEN && child?._zod) {
|
|
4599
|
-
const answer = isRecursive(child, stack,
|
|
4599
|
+
const answer = isRecursive(child, stack, resolve15);
|
|
4600
4600
|
if (answer > result)
|
|
4601
4601
|
result = answer;
|
|
4602
4602
|
}
|
|
@@ -4607,7 +4607,7 @@ function isRecursive(inst, stack, resolve14) {
|
|
|
4607
4607
|
const desc = Object.getOwnPropertyDescriptor(sh, key2);
|
|
4608
4608
|
if (spread && !desc.enumerable)
|
|
4609
4609
|
continue;
|
|
4610
|
-
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack,
|
|
4610
|
+
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve15) : NONE;
|
|
4611
4611
|
if (child > answer)
|
|
4612
4612
|
answer = child;
|
|
4613
4613
|
}
|
|
@@ -4671,7 +4671,7 @@ function isRecursive(inst, stack, resolve14) {
|
|
|
4671
4671
|
break;
|
|
4672
4672
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
4673
4673
|
case "lazy": {
|
|
4674
|
-
const inner = def._cachedInner ?? (
|
|
4674
|
+
const inner = def._cachedInner ?? (resolve15 ? inst._zod.innerType : void 0);
|
|
4675
4675
|
merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
4676
4676
|
break;
|
|
4677
4677
|
}
|
|
@@ -23038,7 +23038,7 @@ var init_protocol = __esm({
|
|
|
23038
23038
|
return;
|
|
23039
23039
|
}
|
|
23040
23040
|
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
|
|
23041
|
-
await new Promise((
|
|
23041
|
+
await new Promise((resolve15) => setTimeout(resolve15, pollInterval));
|
|
23042
23042
|
options?.signal?.throwIfAborted();
|
|
23043
23043
|
}
|
|
23044
23044
|
} catch (error62) {
|
|
@@ -23055,7 +23055,7 @@ var init_protocol = __esm({
|
|
|
23055
23055
|
*/
|
|
23056
23056
|
request(request, resultSchema, options) {
|
|
23057
23057
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
23058
|
-
return new Promise((
|
|
23058
|
+
return new Promise((resolve15, reject) => {
|
|
23059
23059
|
const earlyReject = (error62) => {
|
|
23060
23060
|
reject(error62);
|
|
23061
23061
|
};
|
|
@@ -23133,7 +23133,7 @@ var init_protocol = __esm({
|
|
|
23133
23133
|
if (!parseResult.success) {
|
|
23134
23134
|
reject(parseResult.error);
|
|
23135
23135
|
} else {
|
|
23136
|
-
|
|
23136
|
+
resolve15(parseResult.data);
|
|
23137
23137
|
}
|
|
23138
23138
|
} catch (error62) {
|
|
23139
23139
|
reject(error62);
|
|
@@ -23395,12 +23395,12 @@ var init_protocol = __esm({
|
|
|
23395
23395
|
}
|
|
23396
23396
|
} catch {
|
|
23397
23397
|
}
|
|
23398
|
-
return new Promise((
|
|
23398
|
+
return new Promise((resolve15, reject) => {
|
|
23399
23399
|
if (signal.aborted) {
|
|
23400
23400
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
23401
23401
|
return;
|
|
23402
23402
|
}
|
|
23403
|
-
const timeoutId = setTimeout(
|
|
23403
|
+
const timeoutId = setTimeout(resolve15, interval);
|
|
23404
23404
|
signal.addEventListener("abort", () => {
|
|
23405
23405
|
clearTimeout(timeoutId);
|
|
23406
23406
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -26427,7 +26427,7 @@ var require_compile = __commonJS({
|
|
|
26427
26427
|
const schOrFunc = root.refs[ref];
|
|
26428
26428
|
if (schOrFunc)
|
|
26429
26429
|
return schOrFunc;
|
|
26430
|
-
let _sch =
|
|
26430
|
+
let _sch = resolve15.call(this, root, ref);
|
|
26431
26431
|
if (_sch === void 0) {
|
|
26432
26432
|
const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
|
|
26433
26433
|
const { schemaId } = this.opts;
|
|
@@ -26454,7 +26454,7 @@ var require_compile = __commonJS({
|
|
|
26454
26454
|
function sameSchemaEnv(s1, s2) {
|
|
26455
26455
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
26456
26456
|
}
|
|
26457
|
-
function
|
|
26457
|
+
function resolve15(root, ref) {
|
|
26458
26458
|
let sch;
|
|
26459
26459
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
26460
26460
|
ref = sch;
|
|
@@ -27284,7 +27284,7 @@ var require_fast_uri = __commonJS({
|
|
|
27284
27284
|
}
|
|
27285
27285
|
return uri;
|
|
27286
27286
|
}
|
|
27287
|
-
function
|
|
27287
|
+
function resolve15(baseURI, relativeURI, options) {
|
|
27288
27288
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
27289
27289
|
const {
|
|
27290
27290
|
parsed: baseParsed,
|
|
@@ -27653,7 +27653,7 @@ var require_fast_uri = __commonJS({
|
|
|
27653
27653
|
var fastUri = {
|
|
27654
27654
|
SCHEMES,
|
|
27655
27655
|
normalize,
|
|
27656
|
-
resolve:
|
|
27656
|
+
resolve: resolve15,
|
|
27657
27657
|
resolveComponent,
|
|
27658
27658
|
equal,
|
|
27659
27659
|
serialize,
|
|
@@ -32649,7 +32649,7 @@ var init_frames = __esm({
|
|
|
32649
32649
|
late = { late: external_exports.array(external_exports.string().min(1)).optional() };
|
|
32650
32650
|
isWellFormed2 = (s) => s.isWellFormed();
|
|
32651
32651
|
WELL_FORMED = { message: "text is not well-formed unicode" };
|
|
32652
|
-
CLIENT_VERSION = true ? "0.
|
|
32652
|
+
CLIENT_VERSION = true ? "0.147.0" : "0.0.0";
|
|
32653
32653
|
clientVersion = {
|
|
32654
32654
|
client_version: external_exports.string().min(1).max(64).optional()
|
|
32655
32655
|
};
|
|
@@ -33117,8 +33117,8 @@ import { connect } from "node:net";
|
|
|
33117
33117
|
async function connectDaemon(opts) {
|
|
33118
33118
|
const sock = connect(opts.path);
|
|
33119
33119
|
if (opts.unref) sock.unref();
|
|
33120
|
-
await new Promise((
|
|
33121
|
-
sock.once("connect",
|
|
33120
|
+
await new Promise((resolve15, reject) => {
|
|
33121
|
+
sock.once("connect", resolve15);
|
|
33122
33122
|
sock.once("error", reject);
|
|
33123
33123
|
});
|
|
33124
33124
|
const decoder = new LineDecoder();
|
|
@@ -33185,8 +33185,8 @@ async function connectDaemon(opts) {
|
|
|
33185
33185
|
sock.on("error", (e) => failAll(e));
|
|
33186
33186
|
sock.on("close", () => failAll(new Error("daemon connection closed")));
|
|
33187
33187
|
let timer;
|
|
33188
|
-
const welcomeRaw = await new Promise((
|
|
33189
|
-
waiters.push({ resolve:
|
|
33188
|
+
const welcomeRaw = await new Promise((resolve15, reject) => {
|
|
33189
|
+
waiters.push({ resolve: resolve15, reject });
|
|
33190
33190
|
timer = setTimeout(() => {
|
|
33191
33191
|
reject(new Error("daemon did not answer hello"));
|
|
33192
33192
|
sock.destroy();
|
|
@@ -33208,7 +33208,7 @@ async function connectDaemon(opts) {
|
|
|
33208
33208
|
if (state === "closed")
|
|
33209
33209
|
return Promise.reject(new Error("daemon connection closed"));
|
|
33210
33210
|
const id = partial2.id ?? String(++seq2);
|
|
33211
|
-
return new Promise((
|
|
33211
|
+
return new Promise((resolve15, reject) => {
|
|
33212
33212
|
const ms = opts.requestTimeoutMs ?? 2e4;
|
|
33213
33213
|
const timer2 = setTimeout(() => {
|
|
33214
33214
|
if (pending.delete(id)) {
|
|
@@ -33225,7 +33225,7 @@ async function connectDaemon(opts) {
|
|
|
33225
33225
|
clearTimeout(timer2);
|
|
33226
33226
|
f(...a);
|
|
33227
33227
|
};
|
|
33228
|
-
pending.set(id, { resolve: done(
|
|
33228
|
+
pending.set(id, { resolve: done(resolve15), reject: done(reject) });
|
|
33229
33229
|
holdWhilePending();
|
|
33230
33230
|
sock.write(`${JSON.stringify({ v: 1, ...partial2, id })}
|
|
33231
33231
|
`);
|
|
@@ -33250,7 +33250,7 @@ async function connectDaemon(opts) {
|
|
|
33250
33250
|
};
|
|
33251
33251
|
}
|
|
33252
33252
|
function daemonStatus(opts) {
|
|
33253
|
-
return new Promise((
|
|
33253
|
+
return new Promise((resolve15, reject) => {
|
|
33254
33254
|
const sock = connect(opts.path);
|
|
33255
33255
|
const decoder = new LineDecoder();
|
|
33256
33256
|
const done = (f) => {
|
|
@@ -33287,7 +33287,7 @@ function daemonStatus(opts) {
|
|
|
33287
33287
|
try {
|
|
33288
33288
|
for (const raw of decoder.push(chunk)) {
|
|
33289
33289
|
const f = DaemonFrame.parse(raw);
|
|
33290
|
-
if (f.type === "status") return done(() =>
|
|
33290
|
+
if (f.type === "status") return done(() => resolve15(f));
|
|
33291
33291
|
if (f.type === "error")
|
|
33292
33292
|
return done(
|
|
33293
33293
|
() => reject(
|
|
@@ -33306,7 +33306,7 @@ function daemonStatus(opts) {
|
|
|
33306
33306
|
});
|
|
33307
33307
|
}
|
|
33308
33308
|
function daemonLinkProof(opts) {
|
|
33309
|
-
return new Promise((
|
|
33309
|
+
return new Promise((resolve15, reject) => {
|
|
33310
33310
|
const sock = connect(opts.path);
|
|
33311
33311
|
const decoder = new LineDecoder();
|
|
33312
33312
|
const done = (f) => {
|
|
@@ -33334,7 +33334,7 @@ function daemonLinkProof(opts) {
|
|
|
33334
33334
|
try {
|
|
33335
33335
|
for (const raw of decoder.push(chunk)) {
|
|
33336
33336
|
const f = DaemonFrame.parse(raw);
|
|
33337
|
-
if (f.type === "link_proofed") return done(() =>
|
|
33337
|
+
if (f.type === "link_proofed") return done(() => resolve15(f.bound));
|
|
33338
33338
|
if (f.type === "error")
|
|
33339
33339
|
return done(() => reject(new Error(f.message)));
|
|
33340
33340
|
}
|
|
@@ -33716,13 +33716,13 @@ async function clearStale(path) {
|
|
|
33716
33716
|
code: "ENOTSOCK"
|
|
33717
33717
|
});
|
|
33718
33718
|
}
|
|
33719
|
-
const live = await new Promise((
|
|
33719
|
+
const live = await new Promise((resolve15) => {
|
|
33720
33720
|
const probe2 = connect2(path);
|
|
33721
33721
|
probe2.once("connect", () => {
|
|
33722
33722
|
probe2.destroy();
|
|
33723
|
-
|
|
33723
|
+
resolve15(true);
|
|
33724
33724
|
});
|
|
33725
|
-
probe2.once("error", () =>
|
|
33725
|
+
probe2.once("error", () => resolve15(false));
|
|
33726
33726
|
});
|
|
33727
33727
|
if (live) {
|
|
33728
33728
|
throw Object.assign(new Error(`daemon already listening on ${path}`), {
|
|
@@ -33742,16 +33742,16 @@ async function serveDaemon(opts) {
|
|
|
33742
33742
|
sock.once("close", () => sockets.delete(sock));
|
|
33743
33743
|
handle(sock, opts);
|
|
33744
33744
|
});
|
|
33745
|
-
await new Promise((
|
|
33745
|
+
await new Promise((resolve15, reject) => {
|
|
33746
33746
|
server4.once("error", reject);
|
|
33747
|
-
server4.listen(opts.path, () =>
|
|
33747
|
+
server4.listen(opts.path, () => resolve15());
|
|
33748
33748
|
});
|
|
33749
33749
|
chmodSync(opts.path, 384);
|
|
33750
33750
|
const st = statSync(opts.path);
|
|
33751
33751
|
const mode = st.mode & 511;
|
|
33752
33752
|
return {
|
|
33753
33753
|
mode,
|
|
33754
|
-
close: () => new Promise((
|
|
33754
|
+
close: () => new Promise((resolve15) => {
|
|
33755
33755
|
for (const s of sockets) s.destroy();
|
|
33756
33756
|
let parked;
|
|
33757
33757
|
try {
|
|
@@ -33769,7 +33769,7 @@ async function serveDaemon(opts) {
|
|
|
33769
33769
|
} catch {
|
|
33770
33770
|
}
|
|
33771
33771
|
}
|
|
33772
|
-
|
|
33772
|
+
resolve15();
|
|
33773
33773
|
});
|
|
33774
33774
|
})
|
|
33775
33775
|
};
|
|
@@ -34766,7 +34766,7 @@ ${neutralize(a.text)}
|
|
|
34766
34766
|
};
|
|
34767
34767
|
}
|
|
34768
34768
|
function inject(a) {
|
|
34769
|
-
return new Promise((
|
|
34769
|
+
return new Promise((resolve15, reject) => {
|
|
34770
34770
|
const sock = connect3(a.socketPath);
|
|
34771
34771
|
let connected = false;
|
|
34772
34772
|
const fail2 = (e) => {
|
|
@@ -34790,7 +34790,7 @@ function inject(a) {
|
|
|
34790
34790
|
sock.once("finish", () => {
|
|
34791
34791
|
clearTimeout(timer);
|
|
34792
34792
|
sock.destroy();
|
|
34793
|
-
|
|
34793
|
+
resolve15();
|
|
34794
34794
|
});
|
|
34795
34795
|
sock.end(`${JSON.stringify(frameOf(a))}
|
|
34796
34796
|
`);
|
|
@@ -38930,12 +38930,12 @@ var init_stdio2 = __esm({
|
|
|
38930
38930
|
this.onclose?.();
|
|
38931
38931
|
}
|
|
38932
38932
|
send(message) {
|
|
38933
|
-
return new Promise((
|
|
38933
|
+
return new Promise((resolve15) => {
|
|
38934
38934
|
const json3 = serializeMessage(message);
|
|
38935
38935
|
if (this._stdout.write(json3)) {
|
|
38936
|
-
|
|
38936
|
+
resolve15();
|
|
38937
38937
|
} else {
|
|
38938
|
-
this._stdout.once("drain",
|
|
38938
|
+
this._stdout.once("drain", resolve15);
|
|
38939
38939
|
}
|
|
38940
38940
|
});
|
|
38941
38941
|
}
|
|
@@ -39315,11 +39315,14 @@ var harnessSkills = {
|
|
|
39315
39315
|
skillPath: "~/.config/opencode/skills/open-artifacts/SKILL.md",
|
|
39316
39316
|
busToolName: (tool) => `oa_bus_${tool}`
|
|
39317
39317
|
},
|
|
39318
|
+
// The extension's tools carry an `oabus_` prefix (packages/bus-adapter-pi/assets/oa-bus.ts, #1448).
|
|
39318
39319
|
pi: {
|
|
39319
|
-
skillPath: "~/.agents/skills/open-artifacts/SKILL.md"
|
|
39320
|
+
skillPath: "~/.agents/skills/open-artifacts/SKILL.md",
|
|
39321
|
+
busToolName: (tool) => `oabus_${tool}`
|
|
39320
39322
|
},
|
|
39321
39323
|
omp: {
|
|
39322
|
-
skillPath: "~/.agents/skills/open-artifacts/SKILL.md"
|
|
39324
|
+
skillPath: "~/.agents/skills/open-artifacts/SKILL.md",
|
|
39325
|
+
busToolName: (tool) => `oabus_${tool}`
|
|
39323
39326
|
},
|
|
39324
39327
|
// The plugin's tools carry an `oabus_` prefix (packages/bus-adapter-hermes/assets/oa_bus/tools.py).
|
|
39325
39328
|
// The path is under HERMES_HOME when that is set; the installer resolves it.
|
|
@@ -39339,7 +39342,7 @@ var harnessSkills = {
|
|
|
39339
39342
|
var harnessNames = Object.keys(harnessSkills);
|
|
39340
39343
|
|
|
39341
39344
|
// src/main.ts
|
|
39342
|
-
import { resolve as
|
|
39345
|
+
import { resolve as resolve14 } from "node:path";
|
|
39343
39346
|
|
|
39344
39347
|
// src/commands/daemon.ts
|
|
39345
39348
|
import { existsSync as existsSync5 } from "node:fs";
|
|
@@ -42598,6 +42601,7 @@ var metaOf = ({
|
|
|
42598
42601
|
shown: _____,
|
|
42599
42602
|
native: ______,
|
|
42600
42603
|
expired: _______,
|
|
42604
|
+
correction: ________,
|
|
42601
42605
|
...meta3
|
|
42602
42606
|
}) => meta3;
|
|
42603
42607
|
var validOutcome = (o) => {
|
|
@@ -42609,7 +42613,7 @@ var validOutcome = (o) => {
|
|
|
42609
42613
|
var valid = (id, e) => {
|
|
42610
42614
|
if (!e || typeof e !== "object") return false;
|
|
42611
42615
|
const r = e;
|
|
42612
|
-
return MsgIdSchema.safeParse(id).success && AgentRefSchema.safeParse(r.from_ref).success && BusNameSchema.safeParse(r.to_name).success && (r.namespace === void 0 || WireNamespaceSchema.safeParse(r.namespace).success) && typeof r.at === "number" && validOutcome(r.outcome) && (r.delivered === void 0 || r.delivered === true) && (r.expired === void 0 || r.expired === true) && (r.late === void 0 || r.late === true) && (r.shown === void 0 || r.shown === true) && (r.native === void 0 || r.native === true);
|
|
42616
|
+
return MsgIdSchema.safeParse(id).success && AgentRefSchema.safeParse(r.from_ref).success && BusNameSchema.safeParse(r.to_name).success && (r.namespace === void 0 || WireNamespaceSchema.safeParse(r.namespace).success) && typeof r.at === "number" && validOutcome(r.outcome) && (r.delivered === void 0 || r.delivered === true) && (r.expired === void 0 || r.expired === true) && (r.correction === void 0 || r.correction === true) && (r.late === void 0 || r.late === true) && (r.shown === void 0 || r.shown === true) && (r.native === void 0 || r.native === true);
|
|
42613
42617
|
};
|
|
42614
42618
|
var validExcerpt = (x) => typeof x === "string" && x.length > 0 && Array.from(x).length <= 41 && !/["\r\n]/.test(x);
|
|
42615
42619
|
var SentStore = class {
|
|
@@ -42709,10 +42713,17 @@ var SentStore = class {
|
|
|
42709
42713
|
* lost body the recipient did take (#1760), so its entry stays, no longer
|
|
42710
42714
|
* owed, for a later delivered; a delivered record stays; anything else goes.
|
|
42711
42715
|
*/
|
|
42712
|
-
told(msgId) {
|
|
42716
|
+
told(msgId, corrected = false) {
|
|
42713
42717
|
const e = this.#all.get(msgId);
|
|
42714
42718
|
if (!e) return;
|
|
42715
|
-
if (e.delivered)
|
|
42719
|
+
if (e.delivered) {
|
|
42720
|
+
if (corrected && e.correction) {
|
|
42721
|
+
const { correction: _, ...rest } = e;
|
|
42722
|
+
this.#all.set(msgId, rest);
|
|
42723
|
+
this.#save();
|
|
42724
|
+
}
|
|
42725
|
+
return;
|
|
42726
|
+
}
|
|
42716
42727
|
if (e.outcome?.state === "expired" && e.outcome.reason === void 0) {
|
|
42717
42728
|
const { outcome: _, ...rest } = e;
|
|
42718
42729
|
this.#all.set(msgId, { ...rest, expired: true });
|
|
@@ -42728,25 +42739,43 @@ var SentStore = class {
|
|
|
42728
42739
|
}
|
|
42729
42740
|
/**
|
|
42730
42741
|
* The recipient took a message reported expired: it ends delivered. True
|
|
42731
|
-
* when the sender
|
|
42732
|
-
*
|
|
42742
|
+
* when the sender was told the expiry, or its notice is `inFlight` (it is
|
|
42743
|
+
* owed a correction, stored until `told(msgId, true)`); an expiry never
|
|
42744
|
+
* told is just dropped.
|
|
42733
42745
|
*/
|
|
42734
|
-
correct(msgId) {
|
|
42746
|
+
correct(msgId, inFlight = false) {
|
|
42735
42747
|
const e = this.#all.get(msgId);
|
|
42736
42748
|
if (!e || !this.correctable(msgId)) return false;
|
|
42737
|
-
const
|
|
42749
|
+
const owed = e.expired === true || inFlight;
|
|
42738
42750
|
const { outcome: _, expired: __, ...rest } = e;
|
|
42739
42751
|
this.#all.delete(msgId);
|
|
42740
|
-
this.#all.set(msgId, {
|
|
42752
|
+
this.#all.set(msgId, {
|
|
42753
|
+
...rest,
|
|
42754
|
+
at: this.#now(),
|
|
42755
|
+
delivered: true,
|
|
42756
|
+
...owed ? { correction: true } : {}
|
|
42757
|
+
});
|
|
42741
42758
|
this.#save();
|
|
42742
|
-
return
|
|
42759
|
+
return owed;
|
|
42743
42760
|
}
|
|
42744
|
-
/**
|
|
42761
|
+
/** The Expired notice never reached the agent, so the correction (which says to ignore it) is dropped. */
|
|
42762
|
+
dropCorrection(msgId) {
|
|
42763
|
+
const e = this.#all.get(msgId);
|
|
42764
|
+
if (!e?.correction) return;
|
|
42765
|
+
const { correction: _, ...rest } = e;
|
|
42766
|
+
this.#all.set(msgId, rest);
|
|
42767
|
+
this.#save();
|
|
42768
|
+
}
|
|
42769
|
+
/** Whether `msgId` is owed a correction. */
|
|
42770
|
+
correctionOwed(msgId) {
|
|
42771
|
+
return this.#all.get(msgId)?.correction === true;
|
|
42772
|
+
}
|
|
42773
|
+
/** Settled entries and owed corrections whose sender is `ref`, oldest first. */
|
|
42745
42774
|
untold(ref) {
|
|
42746
42775
|
this.#prune();
|
|
42747
42776
|
const out = [];
|
|
42748
42777
|
for (const [msgId, e] of this.#all) {
|
|
42749
|
-
if (e.from_ref !== ref || !e.outcome) continue;
|
|
42778
|
+
if (e.from_ref !== ref || !(e.outcome || e.correction)) continue;
|
|
42750
42779
|
out.push({ msgId, meta: metaOf(e), outcome: e.outcome });
|
|
42751
42780
|
}
|
|
42752
42781
|
return out;
|
|
@@ -42767,7 +42796,7 @@ var SentStore = class {
|
|
|
42767
42796
|
if (over <= 0) return;
|
|
42768
42797
|
for (const [id, e] of this.#all) {
|
|
42769
42798
|
if (over <= 0) return;
|
|
42770
|
-
if (e.delivered || e.expired) {
|
|
42799
|
+
if (e.delivered && !e.correction || e.expired) {
|
|
42771
42800
|
this.#all.delete(id);
|
|
42772
42801
|
over--;
|
|
42773
42802
|
}
|
|
@@ -42808,6 +42837,7 @@ var SentStore = class {
|
|
|
42808
42837
|
outcome,
|
|
42809
42838
|
delivered,
|
|
42810
42839
|
expired,
|
|
42840
|
+
correction,
|
|
42811
42841
|
late: late2,
|
|
42812
42842
|
shown: shown5,
|
|
42813
42843
|
native
|
|
@@ -42827,6 +42857,7 @@ var SentStore = class {
|
|
|
42827
42857
|
} : {},
|
|
42828
42858
|
...delivered ? { delivered } : {},
|
|
42829
42859
|
...expired && !delivered && !outcome ? { expired } : {},
|
|
42860
|
+
...delivered && correction ? { correction } : {},
|
|
42830
42861
|
...delivered && late2 ? { late: late2 } : {},
|
|
42831
42862
|
...delivered && late2 && shown5 ? { shown: shown5 } : {},
|
|
42832
42863
|
...native ? { native } : {}
|
|
@@ -42941,7 +42972,7 @@ var Receipts = class {
|
|
|
42941
42972
|
this.store.add(f.msg_id, s.meta, outcome);
|
|
42942
42973
|
return { msgId: f.msg_id, meta: s.meta, ...outcome };
|
|
42943
42974
|
}
|
|
42944
|
-
update(f) {
|
|
42975
|
+
update(f, inFlight = false) {
|
|
42945
42976
|
if (f.state === "pending") return void 0;
|
|
42946
42977
|
const corrects = f.state === "delivered" && this.store.correctable(f.msg_id);
|
|
42947
42978
|
if (this.#finals.has(f.msg_id) && !corrects) return void 0;
|
|
@@ -42952,7 +42983,7 @@ var Receipts = class {
|
|
|
42952
42983
|
}
|
|
42953
42984
|
this.#final(f.msg_id);
|
|
42954
42985
|
if (corrects) {
|
|
42955
|
-
return this.store.correct(f.msg_id) ? { msgId: f.msg_id, meta: meta3, state: "corrected" } : void 0;
|
|
42986
|
+
return this.store.correct(f.msg_id, inFlight) ? { msgId: f.msg_id, meta: meta3, state: "corrected" } : void 0;
|
|
42956
42987
|
}
|
|
42957
42988
|
if (this.store.isDelivered(f.msg_id)) return void 0;
|
|
42958
42989
|
if (f.state === "delivered") {
|
|
@@ -42975,12 +43006,12 @@ var Receipts = class {
|
|
|
42975
43006
|
this.#waiting.delete(msgId);
|
|
42976
43007
|
return Promise.resolve(w.final);
|
|
42977
43008
|
}
|
|
42978
|
-
return new Promise((
|
|
43009
|
+
return new Promise((resolve15) => {
|
|
42979
43010
|
const cancel = this.#after(ms, () => w.done?.(void 0));
|
|
42980
43011
|
w.done = (f) => {
|
|
42981
43012
|
cancel();
|
|
42982
43013
|
this.#waiting.delete(msgId);
|
|
42983
|
-
|
|
43014
|
+
resolve15(f);
|
|
42984
43015
|
};
|
|
42985
43016
|
});
|
|
42986
43017
|
}
|
|
@@ -43005,16 +43036,24 @@ var Receipts = class {
|
|
|
43005
43036
|
/** The owed notice for `msgId`, if one is owed. */
|
|
43006
43037
|
notice(msgId) {
|
|
43007
43038
|
const meta3 = this.store.get(msgId);
|
|
43039
|
+
if (meta3 && this.store.correctionOwed(msgId))
|
|
43040
|
+
return { msgId, meta: meta3, state: "corrected" };
|
|
43008
43041
|
const outcome = this.store.outcome(msgId);
|
|
43009
43042
|
return meta3 && outcome ? { msgId, meta: meta3, ...outcome } : void 0;
|
|
43010
43043
|
}
|
|
43044
|
+
/** Its notice failed to reach the sender: a correction to it is moot. */
|
|
43045
|
+
notTold(msgId) {
|
|
43046
|
+
this.store.dropCorrection(msgId);
|
|
43047
|
+
}
|
|
43011
43048
|
/** The sender has been told: forget the message. */
|
|
43012
|
-
told(msgId) {
|
|
43013
|
-
this.store.told(msgId);
|
|
43049
|
+
told(msgId, corrected = false) {
|
|
43050
|
+
this.store.told(msgId, corrected);
|
|
43014
43051
|
}
|
|
43015
43052
|
/** Notices still owed to `ref`, e.g. after a restart or while it was away. */
|
|
43016
43053
|
owed(ref) {
|
|
43017
|
-
return this.store.untold(ref).map(
|
|
43054
|
+
return this.store.untold(ref).map(
|
|
43055
|
+
({ msgId, meta: meta3, outcome }) => outcome ? { msgId, meta: meta3, ...outcome } : { msgId, meta: meta3, state: "corrected" }
|
|
43056
|
+
);
|
|
43018
43057
|
}
|
|
43019
43058
|
#final(msgId) {
|
|
43020
43059
|
this.#finals.add(msgId);
|
|
@@ -43289,22 +43328,22 @@ var ClaudeTransport = class {
|
|
|
43289
43328
|
return { ok: false, reason: "closed", cause: st };
|
|
43290
43329
|
}
|
|
43291
43330
|
#waitFor(msgId, ms) {
|
|
43292
|
-
return new Promise((
|
|
43331
|
+
return new Promise((resolve15) => {
|
|
43293
43332
|
const buffered = this.#buffered.get(msgId);
|
|
43294
43333
|
if (buffered !== void 0) {
|
|
43295
43334
|
this.#buffered.delete(msgId);
|
|
43296
|
-
|
|
43335
|
+
resolve15(buffered);
|
|
43297
43336
|
return;
|
|
43298
43337
|
}
|
|
43299
43338
|
const timer = setTimeout(() => {
|
|
43300
43339
|
this.#waiting.delete(msgId);
|
|
43301
|
-
|
|
43340
|
+
resolve15(void 0);
|
|
43302
43341
|
}, ms);
|
|
43303
43342
|
timer.unref();
|
|
43304
43343
|
this.#waiting.set(msgId, (s) => {
|
|
43305
43344
|
clearTimeout(timer);
|
|
43306
43345
|
this.#waiting.delete(msgId);
|
|
43307
|
-
|
|
43346
|
+
resolve15(s);
|
|
43308
43347
|
});
|
|
43309
43348
|
});
|
|
43310
43349
|
}
|
|
@@ -43454,9 +43493,9 @@ var ClaudeTransport = class {
|
|
|
43454
43493
|
);
|
|
43455
43494
|
})
|
|
43456
43495
|
};
|
|
43457
|
-
await new Promise((
|
|
43496
|
+
await new Promise((resolve15, reject) => {
|
|
43458
43497
|
sink.server.once("error", reject);
|
|
43459
|
-
sink.server.listen(path, () =>
|
|
43498
|
+
sink.server.listen(path, () => resolve15());
|
|
43460
43499
|
});
|
|
43461
43500
|
chmodSync8(path, 384);
|
|
43462
43501
|
return sink;
|
|
@@ -43675,7 +43714,7 @@ function splitArgv0(args) {
|
|
|
43675
43714
|
});
|
|
43676
43715
|
return words(args.slice(real3 ?? ends[0]));
|
|
43677
43716
|
}
|
|
43678
|
-
var execText = (cmd, args) => new Promise((
|
|
43717
|
+
var execText = (cmd, args) => new Promise((resolve15) => {
|
|
43679
43718
|
execFile(
|
|
43680
43719
|
cmd,
|
|
43681
43720
|
args,
|
|
@@ -43684,7 +43723,7 @@ var execText = (cmd, args) => new Promise((resolve14) => {
|
|
|
43684
43723
|
timeout: 2e3,
|
|
43685
43724
|
env: { ...process.env, LC_ALL: "C" }
|
|
43686
43725
|
},
|
|
43687
|
-
(err, stdout) =>
|
|
43726
|
+
(err, stdout) => resolve15(err ? void 0 : stdout)
|
|
43688
43727
|
);
|
|
43689
43728
|
});
|
|
43690
43729
|
async function processArgs(pid) {
|
|
@@ -43707,17 +43746,17 @@ async function processArgs(pid) {
|
|
|
43707
43746
|
return args ? splitArgv0(args) : void 0;
|
|
43708
43747
|
}
|
|
43709
43748
|
var START_ERRORS = /* @__PURE__ */ new Set(["ENOENT", "EACCES", "ENOEXEC"]);
|
|
43710
|
-
var execCodex = (timeoutMs = CODEX_QUEUE_TIMEOUT_MS) => (bin, args, env2) => new Promise((
|
|
43749
|
+
var execCodex = (timeoutMs = CODEX_QUEUE_TIMEOUT_MS) => (bin, args, env2) => new Promise((resolve15, reject) => {
|
|
43711
43750
|
execFile(
|
|
43712
43751
|
bin,
|
|
43713
43752
|
args,
|
|
43714
43753
|
{ timeout: timeoutMs, maxBuffer: 64 * 1024, env: env2 },
|
|
43715
43754
|
(err, _stdout, stderr) => {
|
|
43716
|
-
if (!err) return
|
|
43755
|
+
if (!err) return resolve15({ code: 0, stderr });
|
|
43717
43756
|
const e = err;
|
|
43718
43757
|
if (typeof e.code === "string" && START_ERRORS.has(e.code))
|
|
43719
43758
|
return reject(err);
|
|
43720
|
-
|
|
43759
|
+
resolve15({
|
|
43721
43760
|
// A maxBuffer kill is SIGTERM too, but carries its own string code.
|
|
43722
43761
|
code: e.killed && e.signal === "SIGTERM" && typeof e.code !== "string" ? null : typeof e.code === "number" ? e.code : -1,
|
|
43723
43762
|
stderr: String(stderr ?? "")
|
|
@@ -43842,17 +43881,17 @@ var codexHostWakes = async (pid) => {
|
|
|
43842
43881
|
init_src2();
|
|
43843
43882
|
import { execFile as execFile2 } from "node:child_process";
|
|
43844
43883
|
var START_ERRORS2 = /* @__PURE__ */ new Set(["ENOENT", "EACCES"]);
|
|
43845
|
-
var execSpawn = (timeoutMs, maxBuffer = 1024 * 1024) => (cmd, args) => new Promise((
|
|
43884
|
+
var execSpawn = (timeoutMs, maxBuffer = 1024 * 1024) => (cmd, args) => new Promise((resolve15, reject) => {
|
|
43846
43885
|
execFile2(
|
|
43847
43886
|
cmd,
|
|
43848
43887
|
args,
|
|
43849
43888
|
{ timeout: timeoutMs, maxBuffer },
|
|
43850
43889
|
(err, stdout, stderr) => {
|
|
43851
|
-
if (!err) return
|
|
43890
|
+
if (!err) return resolve15({ code: 0, stdout, stderr });
|
|
43852
43891
|
const e = err;
|
|
43853
43892
|
if (typeof e.code === "string" && START_ERRORS2.has(e.code))
|
|
43854
43893
|
return reject(err);
|
|
43855
|
-
|
|
43894
|
+
resolve15({
|
|
43856
43895
|
code: e.killed || typeof e.code !== "number" ? null : e.code,
|
|
43857
43896
|
stdout,
|
|
43858
43897
|
stderr
|
|
@@ -43969,18 +44008,18 @@ var PiTransport = class {
|
|
|
43969
44008
|
});
|
|
43970
44009
|
if (!pushed) return { ok: false, reason: "closed" };
|
|
43971
44010
|
this.#forget(mail.msg_id);
|
|
43972
|
-
return new Promise((
|
|
44011
|
+
return new Promise((resolve15) => {
|
|
43973
44012
|
const timer = setTimeout(() => {
|
|
43974
44013
|
this.#waiting.delete(mail.msg_id);
|
|
43975
44014
|
this.#remember(mail.msg_id, agent.ref);
|
|
43976
|
-
|
|
44015
|
+
resolve15({ ok: false, reason: "timeout" });
|
|
43977
44016
|
}, this.opts.ackTimeoutMs ?? 1e4);
|
|
43978
44017
|
timer.unref();
|
|
43979
44018
|
this.#waiting.set(mail.msg_id, {
|
|
43980
44019
|
ref: agent.ref,
|
|
43981
44020
|
done: (o) => {
|
|
43982
44021
|
clearTimeout(timer);
|
|
43983
|
-
|
|
44022
|
+
resolve15(o);
|
|
43984
44023
|
}
|
|
43985
44024
|
});
|
|
43986
44025
|
});
|
|
@@ -44174,6 +44213,8 @@ function listLeadTemplateNames(h = home()) {
|
|
|
44174
44213
|
|
|
44175
44214
|
// ../bus-daemon/src/index.ts
|
|
44176
44215
|
var NOTICE_RETRY_MS = 3e4;
|
|
44216
|
+
var BINDING_IDLE_MS = 24 * 60 * 6e4;
|
|
44217
|
+
var BINDING_SWEEP_MS = 6e4;
|
|
44177
44218
|
var RENAME_HOLD_MS = 60 * 6e4;
|
|
44178
44219
|
var RENAME_WINDOW_MS = 6e4;
|
|
44179
44220
|
var RENAME_WINDOW_MAX = 3;
|
|
@@ -44203,6 +44244,24 @@ async function runDaemon(deps2 = {}) {
|
|
|
44203
44244
|
const conns = /* @__PURE__ */ new Map();
|
|
44204
44245
|
const piLinks = /* @__PURE__ */ new Map();
|
|
44205
44246
|
const bindings = /* @__PURE__ */ new Map();
|
|
44247
|
+
const bindingNow = deps2.bindingNow ?? Date.now;
|
|
44248
|
+
const bindingLapsed = (ref, claim2, startOf) => {
|
|
44249
|
+
if (conns.has(ref)) return false;
|
|
44250
|
+
if (claim2.closedAt !== void 0 && bindingNow() - claim2.closedAt >= BINDING_IDLE_MS)
|
|
44251
|
+
return true;
|
|
44252
|
+
if (!running(claim2.pid)) return true;
|
|
44253
|
+
const now = claim2.start === void 0 ? null : startOf(claim2.pid);
|
|
44254
|
+
return now !== null && claim2.start !== void 0 && now !== claim2.start;
|
|
44255
|
+
};
|
|
44256
|
+
let bindingSweptAt = 0;
|
|
44257
|
+
const sweepBindings = () => {
|
|
44258
|
+
const t = bindingNow();
|
|
44259
|
+
if (t - bindingSweptAt < BINDING_SWEEP_MS) return;
|
|
44260
|
+
bindingSweptAt = t;
|
|
44261
|
+
for (const [ref, claim2] of bindings)
|
|
44262
|
+
if (bindingLapsed(ref, claim2, (p) => claudeSessions.procStart(p)))
|
|
44263
|
+
bindings.delete(ref);
|
|
44264
|
+
};
|
|
44206
44265
|
const held = (ref) => {
|
|
44207
44266
|
const rec = agents.byRef(ref);
|
|
44208
44267
|
return rec?.replaces !== void 0 && !hubHelloed;
|
|
@@ -44449,11 +44508,23 @@ async function runDaemon(deps2 = {}) {
|
|
|
44449
44508
|
n.msgId
|
|
44450
44509
|
).then(
|
|
44451
44510
|
(ok) => {
|
|
44452
|
-
if (ok) receipts.told(n.msgId);
|
|
44453
|
-
else
|
|
44511
|
+
if (ok) receipts.told(n.msgId, n.state === "corrected");
|
|
44512
|
+
else {
|
|
44513
|
+
if (n.state !== "corrected") receipts.notTold(n.msgId);
|
|
44514
|
+
log(`could not tell ${agent.busName} about ${n.meta.to_name}`);
|
|
44515
|
+
}
|
|
44454
44516
|
},
|
|
44455
|
-
(e) =>
|
|
44456
|
-
|
|
44517
|
+
(e) => {
|
|
44518
|
+
if (n.state !== "corrected") receipts.notTold(n.msgId);
|
|
44519
|
+
log(`notice failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
44520
|
+
}
|
|
44521
|
+
).finally(() => {
|
|
44522
|
+
telling.delete(n.msgId);
|
|
44523
|
+
if (n.state !== "corrected") {
|
|
44524
|
+
const next = receipts.notice(n.msgId);
|
|
44525
|
+
if (next?.state === "corrected") tell(next);
|
|
44526
|
+
}
|
|
44527
|
+
});
|
|
44457
44528
|
};
|
|
44458
44529
|
const tellOwed = (ref) => {
|
|
44459
44530
|
for (const n of receipts.owed(ref)) tell(n);
|
|
@@ -44760,7 +44831,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
44760
44831
|
return;
|
|
44761
44832
|
}
|
|
44762
44833
|
case "receipt_update":
|
|
44763
|
-
tell(receipts.update(frame));
|
|
44834
|
+
tell(receipts.update(frame, telling.has(frame.msg_id)));
|
|
44764
44835
|
return;
|
|
44765
44836
|
case "error": {
|
|
44766
44837
|
if (statusRelay.answer(frame)) return;
|
|
@@ -44899,21 +44970,21 @@ async function runDaemon(deps2 = {}) {
|
|
|
44899
44970
|
statusEveryMs: deps2.status?.statusEveryMs
|
|
44900
44971
|
});
|
|
44901
44972
|
const hubRoster = (ref) => new Promise(
|
|
44902
|
-
(
|
|
44973
|
+
(resolve15) => {
|
|
44903
44974
|
const id = pending.open(
|
|
44904
44975
|
"status",
|
|
44905
|
-
(f) =>
|
|
44976
|
+
(f) => resolve15(f.type === "roster" ? f.agents : void 0)
|
|
44906
44977
|
);
|
|
44907
44978
|
const timer = setTimeout(() => {
|
|
44908
44979
|
pending.cancel(id);
|
|
44909
44980
|
hub.cancel(id);
|
|
44910
|
-
|
|
44981
|
+
resolve15(void 0);
|
|
44911
44982
|
}, deps2.statusRosterMs ?? 1500);
|
|
44912
44983
|
timer.unref();
|
|
44913
44984
|
if (!hub.send({ v: 1, id, type: "list", from_ref: ref })) {
|
|
44914
44985
|
clearTimeout(timer);
|
|
44915
44986
|
pending.cancel(id);
|
|
44916
|
-
|
|
44987
|
+
resolve15(void 0);
|
|
44917
44988
|
}
|
|
44918
44989
|
}
|
|
44919
44990
|
);
|
|
@@ -45075,11 +45146,8 @@ async function runDaemon(deps2 = {}) {
|
|
|
45075
45146
|
if (check2.linkOnly) linkOnly.add(hello);
|
|
45076
45147
|
let bindToken;
|
|
45077
45148
|
const claim2 = bindings.get(hello.agent_ref);
|
|
45078
|
-
if (claim2)
|
|
45079
|
-
|
|
45080
|
-
if (!running(claim2.pid) || now !== null && claim2.start !== void 0 && now !== claim2.start)
|
|
45081
|
-
bindings.delete(hello.agent_ref);
|
|
45082
|
-
}
|
|
45149
|
+
if (claim2 && bindingLapsed(hello.agent_ref, claim2, startOfPid))
|
|
45150
|
+
bindings.delete(hello.agent_ref);
|
|
45083
45151
|
const held2 = bindings.get(hello.agent_ref);
|
|
45084
45152
|
if (held2 && (held2.kind !== hello.kind || !piLike(hello.kind) || held2.token !== hello.bind_token))
|
|
45085
45153
|
return { error: REF_BOUND };
|
|
@@ -45298,6 +45366,8 @@ async function runDaemon(deps2 = {}) {
|
|
|
45298
45366
|
}
|
|
45299
45367
|
conns.delete(hello.agent_ref);
|
|
45300
45368
|
if (!piLike(hello.kind)) return;
|
|
45369
|
+
const bound2 = bindings.get(hello.agent_ref);
|
|
45370
|
+
if (bound2) bound2.closedAt = bindingNow();
|
|
45301
45371
|
const rec = agents.byRef(hello.agent_ref);
|
|
45302
45372
|
if (!rec) return;
|
|
45303
45373
|
rec.live = false;
|
|
@@ -45422,6 +45492,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
45422
45492
|
}
|
|
45423
45493
|
}
|
|
45424
45494
|
for (const rec of agents.all()) if (rec.live) flushRename(rec);
|
|
45495
|
+
sweepBindings();
|
|
45425
45496
|
};
|
|
45426
45497
|
restoreCodex();
|
|
45427
45498
|
sync();
|
|
@@ -45441,6 +45512,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
45441
45512
|
return {
|
|
45442
45513
|
hub,
|
|
45443
45514
|
agents,
|
|
45515
|
+
bindings: { count: () => bindings.size, sweep: sweepBindings },
|
|
45444
45516
|
stop: async () => {
|
|
45445
45517
|
clearInterval(socketWatch);
|
|
45446
45518
|
clearInterval(watcher);
|
|
@@ -46055,6 +46127,19 @@ function copy(style) {
|
|
|
46055
46127
|
],
|
|
46056
46128
|
// Codex's checks, after its wiring line (C26e).
|
|
46057
46129
|
codexWakes: (bin) => done(`Codex wakes with ${clip(bin, 20)}`),
|
|
46130
|
+
codexSkill: (where) => done(`Codex skill installed in ${clip(where, 20)}`),
|
|
46131
|
+
codexSkillTwice: (file2, block) => [
|
|
46132
|
+
warn("The Codex skill is installed twice, so it loads twice"),
|
|
46133
|
+
next(
|
|
46134
|
+
`It's in both ${clip(file2, 30)} and ${clip(block, 20)}. Run ${BUS_CMD} install again to keep just one.`
|
|
46135
|
+
)
|
|
46136
|
+
],
|
|
46137
|
+
codexSkillSharedTwice: () => [
|
|
46138
|
+
warn("The Codex skill is installed twice, so it loads twice"),
|
|
46139
|
+
next(
|
|
46140
|
+
"Codex shares its skills folder with pi and omp, so it also sees their copy."
|
|
46141
|
+
)
|
|
46142
|
+
],
|
|
46058
46143
|
codexNoWakeCheck: () => [
|
|
46059
46144
|
warn("No codex binary found, so idle Codex threads are not woken"),
|
|
46060
46145
|
next(`Install the Codex CLI, then run ${BUS_CMD} install again.`)
|
|
@@ -46319,19 +46404,19 @@ init_src2();
|
|
|
46319
46404
|
import { execFile as execFile3, spawn } from "node:child_process";
|
|
46320
46405
|
import { promisify } from "node:util";
|
|
46321
46406
|
var browserCommand = (platform, url2) => platform === "darwin" ? { cmd: "open", args: [url2] } : platform === "win32" ? { cmd: "rundll32", args: ["url.dll,FileProtocolHandler", url2] } : { cmd: "xdg-open", args: [url2] };
|
|
46322
|
-
var openBrowser = (url2, launcher = browserCommand(process.platform, url2)) => new Promise((
|
|
46407
|
+
var openBrowser = (url2, launcher = browserCommand(process.platform, url2)) => new Promise((resolve15) => {
|
|
46323
46408
|
try {
|
|
46324
46409
|
const child = spawn(launcher.cmd, launcher.args, {
|
|
46325
46410
|
stdio: "ignore",
|
|
46326
46411
|
detached: true
|
|
46327
46412
|
});
|
|
46328
|
-
child.once("error", () =>
|
|
46413
|
+
child.once("error", () => resolve15(false));
|
|
46329
46414
|
child.once("spawn", () => {
|
|
46330
46415
|
child.unref();
|
|
46331
|
-
|
|
46416
|
+
resolve15(true);
|
|
46332
46417
|
});
|
|
46333
46418
|
} catch {
|
|
46334
|
-
|
|
46419
|
+
resolve15(false);
|
|
46335
46420
|
}
|
|
46336
46421
|
});
|
|
46337
46422
|
var EXEC_TIMEOUT_MS = 1e4;
|
|
@@ -47420,6 +47505,19 @@ function remove(path, text3, doc) {
|
|
|
47420
47505
|
for (const at of all.reverse()) lines = cut(lines, at);
|
|
47421
47506
|
return checked(path, doc, joinLines(lines), void 0);
|
|
47422
47507
|
}
|
|
47508
|
+
async function readCodexVersion(o) {
|
|
47509
|
+
try {
|
|
47510
|
+
const bin = findCodexBin({
|
|
47511
|
+
configFile: o.configFile,
|
|
47512
|
+
path: o.path,
|
|
47513
|
+
app: o.app
|
|
47514
|
+
});
|
|
47515
|
+
const r = await o.exec(bin ?? "codex", ["--version"]);
|
|
47516
|
+
return /(\d+\.\d+\.\d+\S*)/.exec(r.code === 0 ? r.stdout : "")?.[1];
|
|
47517
|
+
} catch {
|
|
47518
|
+
return void 0;
|
|
47519
|
+
}
|
|
47520
|
+
}
|
|
47423
47521
|
|
|
47424
47522
|
// src/steps/step.ts
|
|
47425
47523
|
import {
|
|
@@ -47883,7 +47981,7 @@ var noService = {
|
|
|
47883
47981
|
remove: async () => ({}),
|
|
47884
47982
|
cli: () => ["oa-bus"]
|
|
47885
47983
|
};
|
|
47886
|
-
var VERSION = true ? "0.
|
|
47984
|
+
var VERSION = true ? "0.147.0" : JSON.parse(
|
|
47887
47985
|
readFileSync13(new URL("../package.json", import.meta.url), "utf8")
|
|
47888
47986
|
).version;
|
|
47889
47987
|
var which = (cmd) => {
|
|
@@ -47965,7 +48063,7 @@ function realCtx(noColor) {
|
|
|
47965
48063
|
});
|
|
47966
48064
|
try {
|
|
47967
48065
|
return await new Promise(
|
|
47968
|
-
(
|
|
48066
|
+
(resolve15) => rl.question(question, resolve15)
|
|
47969
48067
|
);
|
|
47970
48068
|
} finally {
|
|
47971
48069
|
rl.close();
|
|
@@ -48090,7 +48188,7 @@ async function daemon(ctx, run4 = runDaemon, signals = process) {
|
|
|
48090
48188
|
sayErr(ctx, ctx.copy.revoked());
|
|
48091
48189
|
return 0;
|
|
48092
48190
|
}
|
|
48093
|
-
return new Promise((
|
|
48191
|
+
return new Promise((resolve15) => {
|
|
48094
48192
|
let running;
|
|
48095
48193
|
let ended = false;
|
|
48096
48194
|
const end = (code2) => {
|
|
@@ -48098,7 +48196,7 @@ async function daemon(ctx, run4 = runDaemon, signals = process) {
|
|
|
48098
48196
|
ended = true;
|
|
48099
48197
|
signals.off("SIGINT", onSignal);
|
|
48100
48198
|
signals.off("SIGTERM", onSignal);
|
|
48101
|
-
void (running?.stop() ?? Promise.resolve()).finally(() =>
|
|
48199
|
+
void (running?.stop() ?? Promise.resolve()).finally(() => resolve15(code2));
|
|
48102
48200
|
};
|
|
48103
48201
|
const onSignal = () => end(0);
|
|
48104
48202
|
signals.once("SIGINT", onSignal);
|
|
@@ -48147,13 +48245,13 @@ import {
|
|
|
48147
48245
|
lstatSync as lstatSync14,
|
|
48148
48246
|
mkdirSync as mkdirSync11,
|
|
48149
48247
|
readFileSync as readFileSync23,
|
|
48150
|
-
readlinkSync as
|
|
48248
|
+
readlinkSync as readlinkSync3,
|
|
48151
48249
|
renameSync as renameSync12,
|
|
48152
48250
|
rmSync as rmSync12,
|
|
48153
48251
|
statSync as statSync10,
|
|
48154
48252
|
writeFileSync as writeFileSync10
|
|
48155
48253
|
} from "node:fs";
|
|
48156
|
-
import { dirname as dirname12, join as join26, resolve as
|
|
48254
|
+
import { dirname as dirname12, join as join26, resolve as resolve10 } from "node:path";
|
|
48157
48255
|
import { isDeepStrictEqual } from "node:util";
|
|
48158
48256
|
|
|
48159
48257
|
// ../bus-adapter-hermes/src/index.ts
|
|
@@ -49818,7 +49916,7 @@ import {
|
|
|
49818
49916
|
realpathSync as realpathSync12,
|
|
49819
49917
|
rmSync as rmSync9
|
|
49820
49918
|
} from "node:fs";
|
|
49821
|
-
import { join as join24, resolve as
|
|
49919
|
+
import { join as join24, resolve as resolve8, sep as sep2 } from "node:path";
|
|
49822
49920
|
|
|
49823
49921
|
// src/steps/hermes.ts
|
|
49824
49922
|
import { createHash as createHash7, randomBytes as randomBytes5 } from "node:crypto";
|
|
@@ -50156,7 +50254,7 @@ import {
|
|
|
50156
50254
|
realpathSync as realpathSync11,
|
|
50157
50255
|
rmSync as rmSync8
|
|
50158
50256
|
} from "node:fs";
|
|
50159
|
-
import { join as join23, resolve as
|
|
50257
|
+
import { join as join23, resolve as resolve7 } from "node:path";
|
|
50160
50258
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
50161
50259
|
|
|
50162
50260
|
// src/steps/skill.ts
|
|
@@ -50167,6 +50265,7 @@ import {
|
|
|
50167
50265
|
mkdirSync as mkdirSync10,
|
|
50168
50266
|
readdirSync as readdirSync6,
|
|
50169
50267
|
readFileSync as readFileSync18,
|
|
50268
|
+
readlinkSync as readlinkSync2,
|
|
50170
50269
|
realpathSync as realpathSync10,
|
|
50171
50270
|
renameSync as renameSync11,
|
|
50172
50271
|
rmdirSync as rmdirSync2,
|
|
@@ -50174,11 +50273,47 @@ import {
|
|
|
50174
50273
|
statSync as statSync9,
|
|
50175
50274
|
writeFileSync as writeFileSync9
|
|
50176
50275
|
} from "node:fs";
|
|
50177
|
-
import { dirname as dirname10, join as join22 } from "node:path";
|
|
50276
|
+
import { dirname as dirname10, join as join22, resolve as resolve6 } from "node:path";
|
|
50178
50277
|
var SKILL_MARKER = "<!-- managed by the Open Artifacts bus installer: edits are replaced on reinstall. -->";
|
|
50179
50278
|
var CODEX_BEGIN = "<!-- BEGIN Open Artifacts skill (managed): edits inside are replaced on reinstall. -->";
|
|
50180
50279
|
var CODEX_END = "<!-- END Open Artifacts skill -->";
|
|
50280
|
+
var CODEX_SKILLS_MIN_VERSION = "0.76.0";
|
|
50181
50281
|
var MAX_SKILL_BYTES = 256 * 1024;
|
|
50282
|
+
var codexSkillFile = (deps2, folder) => join22(codexHome2(deps2.home, env(deps2)), "skills", folder, "SKILL.md");
|
|
50283
|
+
var codexHasSkills = (version2) => version2 !== void 0 && (compareVersions(version2, CODEX_SKILLS_MIN_VERSION) ?? -1) >= 0;
|
|
50284
|
+
var blankLine = (l) => l?.replace(/\r$/, "") === "";
|
|
50285
|
+
var withoutCodexBlock = (text3) => {
|
|
50286
|
+
let lines = text3.split("\n");
|
|
50287
|
+
let removed = false;
|
|
50288
|
+
for (; ; ) {
|
|
50289
|
+
const start = lineIndex(lines, CODEX_BEGIN);
|
|
50290
|
+
if (start === -1) break;
|
|
50291
|
+
const end = lineIndex(lines, CODEX_END, start + 1);
|
|
50292
|
+
if (end === -1) break;
|
|
50293
|
+
const before = lines.slice(0, start);
|
|
50294
|
+
let after = lines.slice(end + 1);
|
|
50295
|
+
if (before.length > 0 && blankLine(before[before.length - 1]) && (after.length === 0 || blankLine(after[0])))
|
|
50296
|
+
before.pop();
|
|
50297
|
+
if (after.length === 0 && before.length > 0) after = [""];
|
|
50298
|
+
lines = [...before, ...after];
|
|
50299
|
+
removed = true;
|
|
50300
|
+
}
|
|
50301
|
+
return removed ? lines.join("\n") : void 0;
|
|
50302
|
+
};
|
|
50303
|
+
var dropCodexBlock = (agentsPath, notes) => {
|
|
50304
|
+
if (brokenLink(agentsPath) || !existsSync7(agentsPath)) return false;
|
|
50305
|
+
const text3 = readFileSync18(agentsPath, "utf8");
|
|
50306
|
+
if (codexBroken(text3)) {
|
|
50307
|
+
notes.push(
|
|
50308
|
+
`Left ${agentsPath} alone: its Open Artifacts block has no END marker. Fix or remove the block, then rerun the install.`
|
|
50309
|
+
);
|
|
50310
|
+
return false;
|
|
50311
|
+
}
|
|
50312
|
+
const next = withoutCodexBlock(text3);
|
|
50313
|
+
if (next === void 0) return false;
|
|
50314
|
+
writeAtomic(targetOf(agentsPath), next);
|
|
50315
|
+
return true;
|
|
50316
|
+
};
|
|
50182
50317
|
var env = (deps2) => deps2.env ?? {};
|
|
50183
50318
|
var skillDir = (deps2, h) => {
|
|
50184
50319
|
const e = env(deps2);
|
|
@@ -50324,8 +50459,132 @@ var withCodexBlock = (existing, text3) => {
|
|
|
50324
50459
|
};
|
|
50325
50460
|
var codexBroken = (text3) => {
|
|
50326
50461
|
const lines = text3.split("\n");
|
|
50327
|
-
|
|
50328
|
-
|
|
50462
|
+
for (let i = 0; i < lines.length; i++) {
|
|
50463
|
+
const t = lines[i]?.replace(/\r$/, "") ?? "";
|
|
50464
|
+
const bare = t.trim();
|
|
50465
|
+
if (t !== CODEX_BEGIN && bare.startsWith("<!-- BEGIN Open Artifacts skill"))
|
|
50466
|
+
return true;
|
|
50467
|
+
if (t !== CODEX_END && bare === CODEX_END) return true;
|
|
50468
|
+
if (t === CODEX_BEGIN) {
|
|
50469
|
+
const end = lineIndex(lines, CODEX_END, i + 1);
|
|
50470
|
+
if (end === -1) return true;
|
|
50471
|
+
i = end;
|
|
50472
|
+
}
|
|
50473
|
+
}
|
|
50474
|
+
return false;
|
|
50475
|
+
};
|
|
50476
|
+
var realOrResolved = (p) => {
|
|
50477
|
+
try {
|
|
50478
|
+
return realpathSync10(p);
|
|
50479
|
+
} catch {
|
|
50480
|
+
return resolve6(p);
|
|
50481
|
+
}
|
|
50482
|
+
};
|
|
50483
|
+
var placesOf = (p) => {
|
|
50484
|
+
const out = [realOrResolved(p)];
|
|
50485
|
+
try {
|
|
50486
|
+
if (lstatSync11(p).isSymbolicLink())
|
|
50487
|
+
out.push(realOrResolved(resolve6(dirname10(p), readlinkSync2(p))));
|
|
50488
|
+
} catch {
|
|
50489
|
+
}
|
|
50490
|
+
return out;
|
|
50491
|
+
};
|
|
50492
|
+
var codexSkillsShared = (deps2) => {
|
|
50493
|
+
const mine = placesOf(dirname10(dirname10(codexSkillFile(deps2, "x"))));
|
|
50494
|
+
const theirs = placesOf(skillDir(deps2, "pi"));
|
|
50495
|
+
return mine.some((m) => theirs.includes(m));
|
|
50496
|
+
};
|
|
50497
|
+
var ourSkillFile = (path, folder) => {
|
|
50498
|
+
try {
|
|
50499
|
+
return isOurs(readFileSync18(path, "utf8"), folder);
|
|
50500
|
+
} catch {
|
|
50501
|
+
return false;
|
|
50502
|
+
}
|
|
50503
|
+
};
|
|
50504
|
+
var installCodex = (deps2, folder, text3, written, notes) => {
|
|
50505
|
+
const agentsPath = skillDir(deps2, "codex");
|
|
50506
|
+
const filePath = codexSkillFile(deps2, folder);
|
|
50507
|
+
let before;
|
|
50508
|
+
try {
|
|
50509
|
+
before = existsSync7(targetOf(agentsPath)) ? readFileSync18(targetOf(agentsPath), "utf8") : "";
|
|
50510
|
+
} catch (e) {
|
|
50511
|
+
notes.push(
|
|
50512
|
+
`Left ${agentsPath} alone: could not read it (${e instanceof Error ? e.message : String(e)}).`
|
|
50513
|
+
);
|
|
50514
|
+
return;
|
|
50515
|
+
}
|
|
50516
|
+
const ourFile = ourSkillFile(filePath, folder);
|
|
50517
|
+
let asFile = codexHasSkills(deps2.codexVersion) || deps2.codexVersion === void 0 && ourFile;
|
|
50518
|
+
const shared = codexSkillsShared(deps2);
|
|
50519
|
+
if (asFile && shared) {
|
|
50520
|
+
asFile = false;
|
|
50521
|
+
notes.push(
|
|
50522
|
+
`Kept the Codex skill in ${agentsPath}: Codex shares its skills folder with pi and omp, and writing there would overwrite their skill.`
|
|
50523
|
+
);
|
|
50524
|
+
}
|
|
50525
|
+
if (codexBroken(before)) {
|
|
50526
|
+
notes.push(
|
|
50527
|
+
`Left ${agentsPath} alone: its Open Artifacts block has no END marker. Fix or remove the block, then rerun the install.`
|
|
50528
|
+
);
|
|
50529
|
+
return;
|
|
50530
|
+
}
|
|
50531
|
+
if (asFile) {
|
|
50532
|
+
if (brokenLink(filePath)) {
|
|
50533
|
+
notes.push(`Left ${filePath} alone: it is a broken symlink.`);
|
|
50534
|
+
return;
|
|
50535
|
+
}
|
|
50536
|
+
const writing2 = targetOf(filePath);
|
|
50537
|
+
try {
|
|
50538
|
+
if (existsSync7(writing2) && !ourSkillFile(writing2, folder)) {
|
|
50539
|
+
notes.push(
|
|
50540
|
+
`Left ${writing2} alone: it has no Open Artifacts marker, so it is not ours to replace.`
|
|
50541
|
+
);
|
|
50542
|
+
return;
|
|
50543
|
+
}
|
|
50544
|
+
writeAtomic(writing2, withMarker(text3));
|
|
50545
|
+
} catch (e) {
|
|
50546
|
+
notes.push(
|
|
50547
|
+
`Could not write ${writing2}: ${e instanceof Error ? e.message : String(e)}`
|
|
50548
|
+
);
|
|
50549
|
+
return;
|
|
50550
|
+
}
|
|
50551
|
+
written.push(filePath);
|
|
50552
|
+
try {
|
|
50553
|
+
dropCodexBlock(agentsPath, notes);
|
|
50554
|
+
} catch (e) {
|
|
50555
|
+
notes.push(
|
|
50556
|
+
`Could not update ${agentsPath}: ${e instanceof Error ? e.message : String(e)}`
|
|
50557
|
+
);
|
|
50558
|
+
}
|
|
50559
|
+
return;
|
|
50560
|
+
}
|
|
50561
|
+
if (brokenLink(agentsPath)) {
|
|
50562
|
+
notes.push(`Left ${agentsPath} alone: it is a broken symlink.`);
|
|
50563
|
+
return;
|
|
50564
|
+
}
|
|
50565
|
+
const writing = targetOf(agentsPath);
|
|
50566
|
+
try {
|
|
50567
|
+
writeAtomic(writing, withCodexBlock(before, text3));
|
|
50568
|
+
} catch (e) {
|
|
50569
|
+
notes.push(
|
|
50570
|
+
`Could not write ${writing}: ${e instanceof Error ? e.message : String(e)}`
|
|
50571
|
+
);
|
|
50572
|
+
return;
|
|
50573
|
+
}
|
|
50574
|
+
written.push(agentsPath);
|
|
50575
|
+
if (ourFile && !shared) {
|
|
50576
|
+
try {
|
|
50577
|
+
rmSync7(targetOf(filePath), { force: true });
|
|
50578
|
+
try {
|
|
50579
|
+
rmdirSync2(dirname10(filePath));
|
|
50580
|
+
} catch {
|
|
50581
|
+
}
|
|
50582
|
+
} catch (e) {
|
|
50583
|
+
notes.push(
|
|
50584
|
+
`Could not remove ${filePath}: ${e instanceof Error ? e.message : String(e)}`
|
|
50585
|
+
);
|
|
50586
|
+
}
|
|
50587
|
+
}
|
|
50329
50588
|
};
|
|
50330
50589
|
async function installSkill(deps2, origin, harnesses) {
|
|
50331
50590
|
const written = [];
|
|
@@ -50352,32 +50611,25 @@ async function installSkill(deps2, origin, harnesses) {
|
|
|
50352
50611
|
notes,
|
|
50353
50612
|
failedUrl: url2
|
|
50354
50613
|
};
|
|
50614
|
+
if (h === "codex") {
|
|
50615
|
+
installCodex(deps2, folder, text3, written, notes);
|
|
50616
|
+
continue;
|
|
50617
|
+
}
|
|
50355
50618
|
const base3 = skillDir(deps2, h);
|
|
50356
|
-
const path =
|
|
50619
|
+
const path = join22(base3, folder, "SKILL.md");
|
|
50357
50620
|
if (brokenLink(path)) {
|
|
50358
50621
|
notes.push(`Left ${path} alone: it is a broken symlink.`);
|
|
50359
50622
|
continue;
|
|
50360
50623
|
}
|
|
50361
50624
|
const writing = targetOf(path);
|
|
50362
50625
|
try {
|
|
50363
|
-
if (
|
|
50364
|
-
|
|
50365
|
-
|
|
50366
|
-
|
|
50367
|
-
|
|
50368
|
-
);
|
|
50369
|
-
continue;
|
|
50370
|
-
}
|
|
50371
|
-
writeAtomic(writing, withCodexBlock(before, text3));
|
|
50372
|
-
} else {
|
|
50373
|
-
if (existsSync7(writing) && !isOurs(readFileSync18(writing, "utf8"), folder)) {
|
|
50374
|
-
notes.push(
|
|
50375
|
-
`Left ${writing} alone: it has no Open Artifacts marker, so it is not ours to replace.`
|
|
50376
|
-
);
|
|
50377
|
-
continue;
|
|
50378
|
-
}
|
|
50379
|
-
writeAtomic(writing, withMarker(text3));
|
|
50626
|
+
if (existsSync7(writing) && !ourSkillFile(writing, folder)) {
|
|
50627
|
+
notes.push(
|
|
50628
|
+
`Left ${writing} alone: it has no Open Artifacts marker, so it is not ours to replace.`
|
|
50629
|
+
);
|
|
50630
|
+
continue;
|
|
50380
50631
|
}
|
|
50632
|
+
writeAtomic(writing, withMarker(text3));
|
|
50381
50633
|
written.push(path);
|
|
50382
50634
|
} catch (e) {
|
|
50383
50635
|
notes.push(
|
|
@@ -50402,41 +50654,14 @@ var uninstallSkill = (deps2, harnesses = [
|
|
|
50402
50654
|
const fail2 = (path, e) => notes.push(
|
|
50403
50655
|
`Left ${path} alone: ${e instanceof Error ? e.message : String(e)}`
|
|
50404
50656
|
);
|
|
50405
|
-
|
|
50406
|
-
const base3 = skillDir(deps2, h);
|
|
50407
|
-
if (seen2.has(base3)) continue;
|
|
50408
|
-
seen2.add(base3);
|
|
50409
|
-
if (harnessSkills[h].agentsMd) {
|
|
50410
|
-
try {
|
|
50411
|
-
if (brokenLink(base3) || !existsSync7(base3)) continue;
|
|
50412
|
-
const text3 = readFileSync18(base3, "utf8");
|
|
50413
|
-
if (codexBroken(text3)) {
|
|
50414
|
-
notes.push(
|
|
50415
|
-
`Left ${base3} alone: its Open Artifacts block has no END marker. Fix or remove the block, then rerun the install.`
|
|
50416
|
-
);
|
|
50417
|
-
continue;
|
|
50418
|
-
}
|
|
50419
|
-
const next = withCodexBlock(text3, "");
|
|
50420
|
-
const clean = next.split("\n").filter((l) => {
|
|
50421
|
-
const t = l.replace(/\r$/, "");
|
|
50422
|
-
return t !== CODEX_BEGIN && t !== CODEX_END;
|
|
50423
|
-
}).join("\n").trimEnd();
|
|
50424
|
-
if (clean) writeAtomic(targetOf(base3), `${clean}
|
|
50425
|
-
`);
|
|
50426
|
-
else rmSync7(targetOf(base3), { force: true });
|
|
50427
|
-
written.push(base3);
|
|
50428
|
-
} catch (e) {
|
|
50429
|
-
fail2(base3, e);
|
|
50430
|
-
}
|
|
50431
|
-
continue;
|
|
50432
|
-
}
|
|
50657
|
+
const scan2 = (base3) => {
|
|
50433
50658
|
let entries;
|
|
50434
50659
|
try {
|
|
50435
|
-
if (!existsSync7(base3))
|
|
50660
|
+
if (!existsSync7(base3)) return;
|
|
50436
50661
|
entries = readdirSync6(base3);
|
|
50437
50662
|
} catch (e) {
|
|
50438
50663
|
fail2(base3, e);
|
|
50439
|
-
|
|
50664
|
+
return;
|
|
50440
50665
|
}
|
|
50441
50666
|
for (const entry of entries) {
|
|
50442
50667
|
const dir = join22(base3, entry);
|
|
@@ -50465,9 +50690,47 @@ var uninstallSkill = (deps2, harnesses = [
|
|
|
50465
50690
|
fail2(file2, e);
|
|
50466
50691
|
}
|
|
50467
50692
|
}
|
|
50693
|
+
};
|
|
50694
|
+
for (const h of harnesses) {
|
|
50695
|
+
const base3 = skillDir(deps2, h);
|
|
50696
|
+
if (seen2.has(base3)) continue;
|
|
50697
|
+
seen2.add(base3);
|
|
50698
|
+
if (harnessSkills[h].agentsMd) {
|
|
50699
|
+
try {
|
|
50700
|
+
if (dropCodexBlock(base3, notes)) written.push(base3);
|
|
50701
|
+
} catch (e) {
|
|
50702
|
+
fail2(base3, e);
|
|
50703
|
+
}
|
|
50704
|
+
scan2(join22(dirname10(base3), "skills"));
|
|
50705
|
+
continue;
|
|
50706
|
+
}
|
|
50707
|
+
scan2(base3);
|
|
50468
50708
|
}
|
|
50469
50709
|
return { written, notes };
|
|
50470
50710
|
};
|
|
50711
|
+
var codexSkillState = (deps2) => {
|
|
50712
|
+
const out = {
|
|
50713
|
+
shared: codexSkillsShared(deps2)
|
|
50714
|
+
};
|
|
50715
|
+
try {
|
|
50716
|
+
const dir = join22(dirname10(skillDir(deps2, "codex")), "skills");
|
|
50717
|
+
for (const entry of readdirSync6(dir)) {
|
|
50718
|
+
const file2 = join22(dir, entry, "SKILL.md");
|
|
50719
|
+
if (ourSkillFile(file2, entry)) {
|
|
50720
|
+
out.file = file2;
|
|
50721
|
+
break;
|
|
50722
|
+
}
|
|
50723
|
+
}
|
|
50724
|
+
} catch {
|
|
50725
|
+
}
|
|
50726
|
+
try {
|
|
50727
|
+
const agents = skillDir(deps2, "codex");
|
|
50728
|
+
if (withoutCodexBlock(readFileSync18(agents, "utf8")) !== void 0)
|
|
50729
|
+
out.block = agents;
|
|
50730
|
+
} catch {
|
|
50731
|
+
}
|
|
50732
|
+
return out;
|
|
50733
|
+
};
|
|
50471
50734
|
|
|
50472
50735
|
// src/steps/openclaw.ts
|
|
50473
50736
|
var OPENCLAW_PLUGIN_ID = "oa-bus";
|
|
@@ -50484,13 +50747,13 @@ var placeholder = (v) => {
|
|
|
50484
50747
|
};
|
|
50485
50748
|
function openclawHome(home2, env2) {
|
|
50486
50749
|
const explicit = placeholder(env2.OPENCLAW_HOME);
|
|
50487
|
-
return
|
|
50750
|
+
return resolve7(explicit ? explicit.replace(/^~(?=$|[\\/])/, home2) : home2);
|
|
50488
50751
|
}
|
|
50489
50752
|
function openclawStateDir(home2, env2) {
|
|
50490
50753
|
const h = openclawHome(home2, env2);
|
|
50491
50754
|
const override = env2.OPENCLAW_STATE_DIR?.trim();
|
|
50492
50755
|
if (override)
|
|
50493
|
-
return
|
|
50756
|
+
return resolve7(
|
|
50494
50757
|
override.startsWith("~") ? override.replace(/^~(?=$|[\\/])/, h) : override
|
|
50495
50758
|
);
|
|
50496
50759
|
const next = join23(h, ".openclaw");
|
|
@@ -50581,7 +50844,7 @@ var realOrSelf = (p) => {
|
|
|
50581
50844
|
try {
|
|
50582
50845
|
return realpathSync11(p);
|
|
50583
50846
|
} catch {
|
|
50584
|
-
return
|
|
50847
|
+
return resolve7(p);
|
|
50585
50848
|
}
|
|
50586
50849
|
};
|
|
50587
50850
|
var NEED_TOOLS = ["oabus_self", "oabus_send_message", "oabus_fetch"];
|
|
@@ -50749,7 +51012,7 @@ var piAgentDir = (home2, env2) => {
|
|
|
50749
51012
|
const d = env2.PI_CODING_AGENT_DIR;
|
|
50750
51013
|
if (!d) return join24(home2, ".pi", "agent");
|
|
50751
51014
|
if (d === "~") return home2;
|
|
50752
|
-
return
|
|
51015
|
+
return resolve8(d.startsWith("~/") ? join24(home2, d.slice(2)) : d);
|
|
50753
51016
|
};
|
|
50754
51017
|
function habitsFiles(deps2, h) {
|
|
50755
51018
|
const env2 = deps2.env ?? {};
|
|
@@ -51185,7 +51448,7 @@ var habitsQuestionLines = (q) => [
|
|
|
51185
51448
|
|
|
51186
51449
|
// src/steps/opencode-proof.ts
|
|
51187
51450
|
import { existsSync as existsSync10, readFileSync as readFileSync21, rmSync as rmSync10 } from "node:fs";
|
|
51188
|
-
import { dirname as dirname11, isAbsolute as isAbsolute12, join as join25, resolve as
|
|
51451
|
+
import { dirname as dirname11, isAbsolute as isAbsolute12, join as join25, resolve as resolve9 } from "node:path";
|
|
51189
51452
|
init_src();
|
|
51190
51453
|
var OPENCODE_ENTRY_FILE = "opencode-mcp-entry.json";
|
|
51191
51454
|
var isRecord5 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
@@ -51228,7 +51491,7 @@ var REMOTE_ONLY = /* @__PURE__ */ new Set(["type", "url", "headers", "oauth"]);
|
|
|
51228
51491
|
function resolveTokenFile(x, configFile, home2) {
|
|
51229
51492
|
if (x === "~") return home2;
|
|
51230
51493
|
if (x.startsWith("~/")) return join25(home2, x.slice(2));
|
|
51231
|
-
return isAbsolute12(x) ? x :
|
|
51494
|
+
return isAbsolute12(x) ? x : resolve9(dirname11(configFile), x);
|
|
51232
51495
|
}
|
|
51233
51496
|
var proxyEntry = (io, origin, tokenFile, entry) => {
|
|
51234
51497
|
const kept = Object.fromEntries(
|
|
@@ -51497,7 +51760,7 @@ var readAssets = () => ({
|
|
|
51497
51760
|
});
|
|
51498
51761
|
var movedHome = (deps2) => {
|
|
51499
51762
|
if (deps2.busHome === void 0) return void 0;
|
|
51500
|
-
const ob =
|
|
51763
|
+
const ob = resolve10(deps2.busHome);
|
|
51501
51764
|
return ob === join26(deps2.home, ".oa-bus") ? void 0 : ob;
|
|
51502
51765
|
};
|
|
51503
51766
|
var homeLine = (ob) => `process.env.OA_BUS_HOME ||= ${JSON.stringify(ob)};`;
|
|
@@ -51543,7 +51806,7 @@ function agentDirEnv(home2, env2) {
|
|
|
51543
51806
|
const dir = env2.PI_CODING_AGENT_DIR;
|
|
51544
51807
|
if (!dir) return void 0;
|
|
51545
51808
|
if (dir === "~") return home2;
|
|
51546
|
-
return
|
|
51809
|
+
return resolve10(dir.startsWith("~/") ? join26(home2, dir.slice(2)) : dir);
|
|
51547
51810
|
}
|
|
51548
51811
|
var ompRoot = (home2, env2) => join26(home2, env2.PI_CONFIG_DIR || ".omp");
|
|
51549
51812
|
function ompProfile(env2) {
|
|
@@ -51597,7 +51860,7 @@ function target(path) {
|
|
|
51597
51860
|
);
|
|
51598
51861
|
return p;
|
|
51599
51862
|
}
|
|
51600
|
-
p =
|
|
51863
|
+
p = resolve10(dirname12(p), readlinkSync3(p));
|
|
51601
51864
|
}
|
|
51602
51865
|
throw new Error(`${path}: too many symlinks; left it untouched`);
|
|
51603
51866
|
}
|
|
@@ -52878,10 +53141,17 @@ async function harnessesStep(ctx, hub) {
|
|
|
52878
53141
|
say(ctx, await skippedLines(ctx, s.harness, s.reason));
|
|
52879
53142
|
if (out.installed.includes("opencode"))
|
|
52880
53143
|
say(ctx, out.opencodeRestarted ? c.restarted() : c.opencodeNotRunning());
|
|
53144
|
+
const codexVersion = out.installed.includes("codex") ? await readCodexVersion({
|
|
53145
|
+
configFile: codexBinFile(ctx.home),
|
|
53146
|
+
exec: ctx.exec,
|
|
53147
|
+
path: ctx.env.PATH,
|
|
53148
|
+
app: ctx.codexApp
|
|
53149
|
+
}) : void 0;
|
|
52881
53150
|
const skill = await installSkill(
|
|
52882
53151
|
{
|
|
52883
53152
|
home: ctx.userHome,
|
|
52884
53153
|
env: ctx.env,
|
|
53154
|
+
codexVersion,
|
|
52885
53155
|
fetchSkill: (url2) => fetchSkillText(ctx.fetch, url2)
|
|
52886
53156
|
},
|
|
52887
53157
|
hub ? originOf2(hub) : machineOrigin(ctx),
|
|
@@ -53287,6 +53557,15 @@ function codexChecks(ctx, out) {
|
|
|
53287
53557
|
if (shell !== service)
|
|
53288
53558
|
out.warn(c.codexHomeMismatch(tilde(ctx, shell), tilde(ctx, service)));
|
|
53289
53559
|
}
|
|
53560
|
+
const skill = codexSkillState({ home: ctx.userHome, env: ctx.env });
|
|
53561
|
+
if (skill.file && skill.block && skill.shared)
|
|
53562
|
+
out.warn(c.codexSkillSharedTwice());
|
|
53563
|
+
else if (skill.file && skill.block)
|
|
53564
|
+
out.warn(
|
|
53565
|
+
c.codexSkillTwice(tilde(ctx, skill.file), tilde(ctx, skill.block))
|
|
53566
|
+
);
|
|
53567
|
+
else if (skill.file ?? skill.block)
|
|
53568
|
+
out.pass(c.codexSkill(tilde(ctx, skill.file ?? skill.block)));
|
|
53290
53569
|
const config2 = codexConfig(ctx.userHome, ctx.env);
|
|
53291
53570
|
let risk;
|
|
53292
53571
|
try {
|
|
@@ -53474,7 +53753,7 @@ async function doctor(ctx) {
|
|
|
53474
53753
|
|
|
53475
53754
|
// src/commands/global.ts
|
|
53476
53755
|
import { realpathSync as realpathSync13, statSync as statSync11 } from "node:fs";
|
|
53477
|
-
import { resolve as
|
|
53756
|
+
import { resolve as resolve11 } from "node:path";
|
|
53478
53757
|
function shown3(ctx, path) {
|
|
53479
53758
|
const t = tilde(ctx, path);
|
|
53480
53759
|
if (t !== path) return t;
|
|
@@ -53500,7 +53779,7 @@ async function global(opts, ctx) {
|
|
|
53500
53779
|
);
|
|
53501
53780
|
return 0;
|
|
53502
53781
|
}
|
|
53503
|
-
const given =
|
|
53782
|
+
const given = resolve11(ctx.cwd, opts.dir);
|
|
53504
53783
|
let real3;
|
|
53505
53784
|
try {
|
|
53506
53785
|
real3 = canonicalPath(given);
|
|
@@ -53596,10 +53875,10 @@ async function leads(opts, ctx) {
|
|
|
53596
53875
|
|
|
53597
53876
|
// src/commands/link.ts
|
|
53598
53877
|
import { statSync as statSync12 } from "node:fs";
|
|
53599
|
-
import { resolve as
|
|
53878
|
+
import { resolve as resolve12 } from "node:path";
|
|
53600
53879
|
init_src();
|
|
53601
53880
|
function side(ctx, dir) {
|
|
53602
|
-
const given =
|
|
53881
|
+
const given = resolve12(ctx.cwd, dir);
|
|
53603
53882
|
try {
|
|
53604
53883
|
const real3 = canonicalPath(given);
|
|
53605
53884
|
if (!statSync12(real3).isDirectory()) return void 0;
|
|
@@ -53630,7 +53909,7 @@ async function link(opts, ctx) {
|
|
|
53630
53909
|
for (const d of opts.dirs) {
|
|
53631
53910
|
const s = side(ctx, d);
|
|
53632
53911
|
if (!s) {
|
|
53633
|
-
sayErr(ctx, c.linkNotDir(shq(
|
|
53912
|
+
sayErr(ctx, c.linkNotDir(shq(resolve12(ctx.cwd, d))));
|
|
53634
53913
|
return 1;
|
|
53635
53914
|
}
|
|
53636
53915
|
sides.push(s);
|
|
@@ -53728,7 +54007,7 @@ init_src2();
|
|
|
53728
54007
|
init_src();
|
|
53729
54008
|
import { execFileSync as execFileSync6 } from "node:child_process";
|
|
53730
54009
|
import { createHash as createHash8, randomBytes as randomBytes8 } from "node:crypto";
|
|
53731
|
-
import { readFileSync as readFileSync27, readlinkSync as
|
|
54010
|
+
import { readFileSync as readFileSync27, readlinkSync as readlinkSync4 } from "node:fs";
|
|
53732
54011
|
import { basename as basename8 } from "node:path";
|
|
53733
54012
|
var isClaude = (name) => name === "claude" || /\/claude\/versions\/[^/]+$/.test(name);
|
|
53734
54013
|
function parsePs(out) {
|
|
@@ -53743,7 +54022,7 @@ function readProc(pid) {
|
|
|
53743
54022
|
const ppid = Number(stat.slice(stat.lastIndexOf(")") + 1).split(/\s+/)[2]);
|
|
53744
54023
|
let exe = "";
|
|
53745
54024
|
try {
|
|
53746
|
-
exe =
|
|
54025
|
+
exe = readlinkSync4(`/proc/${pid}/exe`);
|
|
53747
54026
|
} catch {
|
|
53748
54027
|
}
|
|
53749
54028
|
const comm = readFileSync27(`/proc/${pid}/comm`, "utf8").trim();
|
|
@@ -53803,7 +54082,7 @@ async function mcpProof(opts, ctx, deps2 = {
|
|
|
53803
54082
|
|
|
53804
54083
|
// src/commands/namespace.ts
|
|
53805
54084
|
import { realpathSync as realpathSync14, statSync as statSync13 } from "node:fs";
|
|
53806
|
-
import { join as join33, resolve as
|
|
54085
|
+
import { join as join33, resolve as resolve13 } from "node:path";
|
|
53807
54086
|
init_src();
|
|
53808
54087
|
function shown4(ctx, path) {
|
|
53809
54088
|
const t = tilde(ctx, path);
|
|
@@ -53830,7 +54109,7 @@ async function namespace(opts, ctx) {
|
|
|
53830
54109
|
);
|
|
53831
54110
|
return 0;
|
|
53832
54111
|
}
|
|
53833
|
-
const given =
|
|
54112
|
+
const given = resolve13(ctx.cwd, opts.dir);
|
|
53834
54113
|
let real3;
|
|
53835
54114
|
try {
|
|
53836
54115
|
real3 = canonicalPath(given);
|
|
@@ -54348,7 +54627,7 @@ async function main(argv, makeCtx = realCtx) {
|
|
|
54348
54627
|
return 2;
|
|
54349
54628
|
}
|
|
54350
54629
|
const ctx = makeCtx(cmd.noColor);
|
|
54351
|
-
if (cmd.home) ctx.home =
|
|
54630
|
+
if (cmd.home) ctx.home = resolve14(cmd.home);
|
|
54352
54631
|
try {
|
|
54353
54632
|
return await dispatch(cmd, ctx);
|
|
54354
54633
|
} catch (e) {
|