@open-artifacts/bus 0.146.0 → 0.148.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/assets/output-styles/artifacts-teammate.md +47 -0
- package/dist/index.js +1060 -295
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1533,8 +1533,8 @@ var init_regexes = __esm({
|
|
|
1533
1533
|
_emoji = `^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
|
|
1534
1534
|
ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
|
|
1535
1535
|
ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
|
|
1536
|
-
mac = (
|
|
1537
|
-
const escapedDelim = escapeRegex(
|
|
1536
|
+
mac = (delimiter3) => {
|
|
1537
|
+
const escapedDelim = escapeRegex(delimiter3 ?? ":");
|
|
1538
1538
|
return new RegExp(`^(?:[0-9A-F]{2}${escapedDelim}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${escapedDelim}){5}[0-9a-f]{2}$`);
|
|
1539
1539
|
};
|
|
1540
1540
|
cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
|
|
@@ -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, resolve16) {
|
|
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, resolve16);
|
|
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, resolve16) : 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 ?? (resolve16 ? 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((resolve16) => setTimeout(resolve16, 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((resolve16, 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
|
+
resolve16(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((resolve16, 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(resolve16, interval);
|
|
23404
23404
|
signal.addEventListener("abort", () => {
|
|
23405
23405
|
clearTimeout(timeoutId);
|
|
23406
23406
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -23853,11 +23853,11 @@ var require_codegen = __commonJS({
|
|
|
23853
23853
|
const rhs = this.rhs === void 0 ? "" : ` = ${this.rhs}`;
|
|
23854
23854
|
return `${varKind} ${this.name}${rhs};` + _n;
|
|
23855
23855
|
}
|
|
23856
|
-
optimizeNames(names2,
|
|
23856
|
+
optimizeNames(names2, constants5) {
|
|
23857
23857
|
if (!names2[this.name.str])
|
|
23858
23858
|
return;
|
|
23859
23859
|
if (this.rhs)
|
|
23860
|
-
this.rhs = optimizeExpr(this.rhs, names2,
|
|
23860
|
+
this.rhs = optimizeExpr(this.rhs, names2, constants5);
|
|
23861
23861
|
return this;
|
|
23862
23862
|
}
|
|
23863
23863
|
get names() {
|
|
@@ -23874,10 +23874,10 @@ var require_codegen = __commonJS({
|
|
|
23874
23874
|
render({ _n }) {
|
|
23875
23875
|
return `${this.lhs} = ${this.rhs};` + _n;
|
|
23876
23876
|
}
|
|
23877
|
-
optimizeNames(names2,
|
|
23877
|
+
optimizeNames(names2, constants5) {
|
|
23878
23878
|
if (this.lhs instanceof code_1.Name && !names2[this.lhs.str] && !this.sideEffects)
|
|
23879
23879
|
return;
|
|
23880
|
-
this.rhs = optimizeExpr(this.rhs, names2,
|
|
23880
|
+
this.rhs = optimizeExpr(this.rhs, names2, constants5);
|
|
23881
23881
|
return this;
|
|
23882
23882
|
}
|
|
23883
23883
|
get names() {
|
|
@@ -23938,8 +23938,8 @@ var require_codegen = __commonJS({
|
|
|
23938
23938
|
optimizeNodes() {
|
|
23939
23939
|
return `${this.code}` ? this : void 0;
|
|
23940
23940
|
}
|
|
23941
|
-
optimizeNames(names2,
|
|
23942
|
-
this.code = optimizeExpr(this.code, names2,
|
|
23941
|
+
optimizeNames(names2, constants5) {
|
|
23942
|
+
this.code = optimizeExpr(this.code, names2, constants5);
|
|
23943
23943
|
return this;
|
|
23944
23944
|
}
|
|
23945
23945
|
get names() {
|
|
@@ -23968,12 +23968,12 @@ var require_codegen = __commonJS({
|
|
|
23968
23968
|
}
|
|
23969
23969
|
return nodes.length > 0 ? this : void 0;
|
|
23970
23970
|
}
|
|
23971
|
-
optimizeNames(names2,
|
|
23971
|
+
optimizeNames(names2, constants5) {
|
|
23972
23972
|
const { nodes } = this;
|
|
23973
23973
|
let i = nodes.length;
|
|
23974
23974
|
while (i--) {
|
|
23975
23975
|
const n = nodes[i];
|
|
23976
|
-
if (n.optimizeNames(names2,
|
|
23976
|
+
if (n.optimizeNames(names2, constants5))
|
|
23977
23977
|
continue;
|
|
23978
23978
|
subtractNames(names2, n.names);
|
|
23979
23979
|
nodes.splice(i, 1);
|
|
@@ -24026,12 +24026,12 @@ var require_codegen = __commonJS({
|
|
|
24026
24026
|
return void 0;
|
|
24027
24027
|
return this;
|
|
24028
24028
|
}
|
|
24029
|
-
optimizeNames(names2,
|
|
24029
|
+
optimizeNames(names2, constants5) {
|
|
24030
24030
|
var _a3;
|
|
24031
|
-
this.else = (_a3 = this.else) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names2,
|
|
24032
|
-
if (!(super.optimizeNames(names2,
|
|
24031
|
+
this.else = (_a3 = this.else) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names2, constants5);
|
|
24032
|
+
if (!(super.optimizeNames(names2, constants5) || this.else))
|
|
24033
24033
|
return;
|
|
24034
|
-
this.condition = optimizeExpr(this.condition, names2,
|
|
24034
|
+
this.condition = optimizeExpr(this.condition, names2, constants5);
|
|
24035
24035
|
return this;
|
|
24036
24036
|
}
|
|
24037
24037
|
get names() {
|
|
@@ -24054,10 +24054,10 @@ var require_codegen = __commonJS({
|
|
|
24054
24054
|
render(opts) {
|
|
24055
24055
|
return `for(${this.iteration})` + super.render(opts);
|
|
24056
24056
|
}
|
|
24057
|
-
optimizeNames(names2,
|
|
24058
|
-
if (!super.optimizeNames(names2,
|
|
24057
|
+
optimizeNames(names2, constants5) {
|
|
24058
|
+
if (!super.optimizeNames(names2, constants5))
|
|
24059
24059
|
return;
|
|
24060
|
-
this.iteration = optimizeExpr(this.iteration, names2,
|
|
24060
|
+
this.iteration = optimizeExpr(this.iteration, names2, constants5);
|
|
24061
24061
|
return this;
|
|
24062
24062
|
}
|
|
24063
24063
|
get names() {
|
|
@@ -24093,10 +24093,10 @@ var require_codegen = __commonJS({
|
|
|
24093
24093
|
render(opts) {
|
|
24094
24094
|
return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts);
|
|
24095
24095
|
}
|
|
24096
|
-
optimizeNames(names2,
|
|
24097
|
-
if (!super.optimizeNames(names2,
|
|
24096
|
+
optimizeNames(names2, constants5) {
|
|
24097
|
+
if (!super.optimizeNames(names2, constants5))
|
|
24098
24098
|
return;
|
|
24099
|
-
this.iterable = optimizeExpr(this.iterable, names2,
|
|
24099
|
+
this.iterable = optimizeExpr(this.iterable, names2, constants5);
|
|
24100
24100
|
return this;
|
|
24101
24101
|
}
|
|
24102
24102
|
get names() {
|
|
@@ -24138,11 +24138,11 @@ var require_codegen = __commonJS({
|
|
|
24138
24138
|
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNodes();
|
|
24139
24139
|
return this;
|
|
24140
24140
|
}
|
|
24141
|
-
optimizeNames(names2,
|
|
24141
|
+
optimizeNames(names2, constants5) {
|
|
24142
24142
|
var _a3, _b;
|
|
24143
|
-
super.optimizeNames(names2,
|
|
24144
|
-
(_a3 = this.catch) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names2,
|
|
24145
|
-
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names2,
|
|
24143
|
+
super.optimizeNames(names2, constants5);
|
|
24144
|
+
(_a3 = this.catch) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names2, constants5);
|
|
24145
|
+
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names2, constants5);
|
|
24146
24146
|
return this;
|
|
24147
24147
|
}
|
|
24148
24148
|
get names() {
|
|
@@ -24443,7 +24443,7 @@ var require_codegen = __commonJS({
|
|
|
24443
24443
|
function addExprNames(names2, from) {
|
|
24444
24444
|
return from instanceof code_1._CodeOrName ? addNames(names2, from.names) : names2;
|
|
24445
24445
|
}
|
|
24446
|
-
function optimizeExpr(expr, names2,
|
|
24446
|
+
function optimizeExpr(expr, names2, constants5) {
|
|
24447
24447
|
if (expr instanceof code_1.Name)
|
|
24448
24448
|
return replaceName(expr);
|
|
24449
24449
|
if (!canOptimize(expr))
|
|
@@ -24458,14 +24458,14 @@ var require_codegen = __commonJS({
|
|
|
24458
24458
|
return items;
|
|
24459
24459
|
}, []));
|
|
24460
24460
|
function replaceName(n) {
|
|
24461
|
-
const c =
|
|
24461
|
+
const c = constants5[n.str];
|
|
24462
24462
|
if (c === void 0 || names2[n.str] !== 1)
|
|
24463
24463
|
return n;
|
|
24464
24464
|
delete names2[n.str];
|
|
24465
24465
|
return c;
|
|
24466
24466
|
}
|
|
24467
24467
|
function canOptimize(e) {
|
|
24468
|
-
return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names2[c.str] === 1 &&
|
|
24468
|
+
return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names2[c.str] === 1 && constants5[c.str] !== void 0);
|
|
24469
24469
|
}
|
|
24470
24470
|
}
|
|
24471
24471
|
function subtractNames(names2, from) {
|
|
@@ -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 = resolve16.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 resolve16(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 resolve16(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: resolve16,
|
|
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.148.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((resolve16, reject) => {
|
|
33121
|
+
sock.once("connect", resolve16);
|
|
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((resolve16, reject) => {
|
|
33189
|
+
waiters.push({ resolve: resolve16, 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((resolve16, 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(resolve16), 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((resolve16, 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(() => resolve16(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((resolve16, 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(() => resolve16(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((resolve16) => {
|
|
33720
33720
|
const probe2 = connect2(path);
|
|
33721
33721
|
probe2.once("connect", () => {
|
|
33722
33722
|
probe2.destroy();
|
|
33723
|
-
|
|
33723
|
+
resolve16(true);
|
|
33724
33724
|
});
|
|
33725
|
-
probe2.once("error", () =>
|
|
33725
|
+
probe2.once("error", () => resolve16(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((resolve16, reject) => {
|
|
33746
33746
|
server4.once("error", reject);
|
|
33747
|
-
server4.listen(opts.path, () =>
|
|
33747
|
+
server4.listen(opts.path, () => resolve16());
|
|
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((resolve16) => {
|
|
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
|
+
resolve16();
|
|
33773
33773
|
});
|
|
33774
33774
|
})
|
|
33775
33775
|
};
|
|
@@ -33981,10 +33981,10 @@ var init_server3 = __esm({
|
|
|
33981
33981
|
|
|
33982
33982
|
// ../bus-ipc/src/sysbin.ts
|
|
33983
33983
|
import { existsSync } from "node:fs";
|
|
33984
|
-
function systemTool(name,
|
|
33984
|
+
function systemTool(name, exists2 = existsSync) {
|
|
33985
33985
|
const hit = found.get(name);
|
|
33986
33986
|
if (hit) return hit;
|
|
33987
|
-
const path = SYSTEM_DIRS.map((d) => `${d}/${name}`).find(
|
|
33987
|
+
const path = SYSTEM_DIRS.map((d) => `${d}/${name}`).find(exists2);
|
|
33988
33988
|
if (path) found.set(name, path);
|
|
33989
33989
|
return path ?? name;
|
|
33990
33990
|
}
|
|
@@ -34766,7 +34766,7 @@ ${neutralize(a.text)}
|
|
|
34766
34766
|
};
|
|
34767
34767
|
}
|
|
34768
34768
|
function inject(a) {
|
|
34769
|
-
return new Promise((
|
|
34769
|
+
return new Promise((resolve16, 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
|
+
resolve16();
|
|
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((resolve16) => {
|
|
38934
38934
|
const json3 = serializeMessage(message);
|
|
38935
38935
|
if (this._stdout.write(json3)) {
|
|
38936
|
-
|
|
38936
|
+
resolve16();
|
|
38937
38937
|
} else {
|
|
38938
|
-
this._stdout.once("drain",
|
|
38938
|
+
this._stdout.once("drain", resolve16);
|
|
38939
38939
|
}
|
|
38940
38940
|
});
|
|
38941
38941
|
}
|
|
@@ -38945,7 +38945,7 @@ var init_stdio2 = __esm({
|
|
|
38945
38945
|
|
|
38946
38946
|
// ../bus-adapter-claude-code/src/main.ts
|
|
38947
38947
|
var main_exports = {};
|
|
38948
|
-
import { existsSync as
|
|
38948
|
+
import { existsSync as existsSync14 } from "node:fs";
|
|
38949
38949
|
var SESSIONS, HOME, SOCKET, connect4, server, underClaude;
|
|
38950
38950
|
var init_main = __esm({
|
|
38951
38951
|
async "../bus-adapter-claude-code/src/main.ts"() {
|
|
@@ -38969,7 +38969,7 @@ var init_main = __esm({
|
|
|
38969
38969
|
}),
|
|
38970
38970
|
// A short socket folder another user could reach is never dialed.
|
|
38971
38971
|
socketDirProblem: () => socketDirProblem(HOME),
|
|
38972
|
-
socketExists: () =>
|
|
38972
|
+
socketExists: () => existsSync14(SOCKET),
|
|
38973
38973
|
connect: (session) => connectDaemon({
|
|
38974
38974
|
path: SOCKET,
|
|
38975
38975
|
hello: sessionHello(session, process.pid, process.cwd())
|
|
@@ -39192,13 +39192,13 @@ __export(codex_proxy_main_exports, {
|
|
|
39192
39192
|
readTokenFile: () => readTokenFile,
|
|
39193
39193
|
startCodexProxy: () => startCodexProxy
|
|
39194
39194
|
});
|
|
39195
|
-
import { readFileSync as
|
|
39195
|
+
import { readFileSync as readFileSync30 } from "node:fs";
|
|
39196
39196
|
import { homedir as homedir4 } from "node:os";
|
|
39197
39197
|
function readTokenFile(path) {
|
|
39198
39198
|
if (!path) return void 0;
|
|
39199
39199
|
try {
|
|
39200
39200
|
const p = path.startsWith("~/") ? `${homedir4()}${path.slice(1)}` : path;
|
|
39201
|
-
return
|
|
39201
|
+
return readFileSync30(p, "utf8").trim() || void 0;
|
|
39202
39202
|
} catch {
|
|
39203
39203
|
return void 0;
|
|
39204
39204
|
}
|
|
@@ -39248,13 +39248,13 @@ __export(proxy_main_exports, {
|
|
|
39248
39248
|
readTokenFile: () => readTokenFile2,
|
|
39249
39249
|
startProxy: () => startProxy
|
|
39250
39250
|
});
|
|
39251
|
-
import { readFileSync as
|
|
39251
|
+
import { readFileSync as readFileSync31 } from "node:fs";
|
|
39252
39252
|
import { homedir as homedir5 } from "node:os";
|
|
39253
39253
|
function readTokenFile2(path) {
|
|
39254
39254
|
if (!path) return void 0;
|
|
39255
39255
|
try {
|
|
39256
39256
|
const p = path.startsWith("~/") ? `${homedir5()}${path.slice(1)}` : path;
|
|
39257
|
-
return
|
|
39257
|
+
return readFileSync31(p, "utf8").trim() || void 0;
|
|
39258
39258
|
} catch {
|
|
39259
39259
|
return void 0;
|
|
39260
39260
|
}
|
|
@@ -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 resolve15 } from "node:path";
|
|
39343
39346
|
|
|
39344
39347
|
// src/commands/daemon.ts
|
|
39345
39348
|
import { existsSync as existsSync5 } from "node:fs";
|
|
@@ -39390,6 +39393,8 @@ init_src2();
|
|
|
39390
39393
|
init_src();
|
|
39391
39394
|
|
|
39392
39395
|
// ../bus-daemon/src/agents.ts
|
|
39396
|
+
var LINK_HASHES_MAX = 4;
|
|
39397
|
+
var withLinkHash = (list, hash2) => [...(list ?? []).filter((h) => h !== hash2), hash2].slice(-LINK_HASHES_MAX);
|
|
39393
39398
|
var AgentTable = class {
|
|
39394
39399
|
#byRef = /* @__PURE__ */ new Map();
|
|
39395
39400
|
up(rec) {
|
|
@@ -42598,6 +42603,7 @@ var metaOf = ({
|
|
|
42598
42603
|
shown: _____,
|
|
42599
42604
|
native: ______,
|
|
42600
42605
|
expired: _______,
|
|
42606
|
+
correction: ________,
|
|
42601
42607
|
...meta3
|
|
42602
42608
|
}) => meta3;
|
|
42603
42609
|
var validOutcome = (o) => {
|
|
@@ -42609,7 +42615,7 @@ var validOutcome = (o) => {
|
|
|
42609
42615
|
var valid = (id, e) => {
|
|
42610
42616
|
if (!e || typeof e !== "object") return false;
|
|
42611
42617
|
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);
|
|
42618
|
+
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
42619
|
};
|
|
42614
42620
|
var validExcerpt = (x) => typeof x === "string" && x.length > 0 && Array.from(x).length <= 41 && !/["\r\n]/.test(x);
|
|
42615
42621
|
var SentStore = class {
|
|
@@ -42709,10 +42715,17 @@ var SentStore = class {
|
|
|
42709
42715
|
* lost body the recipient did take (#1760), so its entry stays, no longer
|
|
42710
42716
|
* owed, for a later delivered; a delivered record stays; anything else goes.
|
|
42711
42717
|
*/
|
|
42712
|
-
told(msgId) {
|
|
42718
|
+
told(msgId, corrected = false) {
|
|
42713
42719
|
const e = this.#all.get(msgId);
|
|
42714
42720
|
if (!e) return;
|
|
42715
|
-
if (e.delivered)
|
|
42721
|
+
if (e.delivered) {
|
|
42722
|
+
if (corrected && e.correction) {
|
|
42723
|
+
const { correction: _, ...rest } = e;
|
|
42724
|
+
this.#all.set(msgId, rest);
|
|
42725
|
+
this.#save();
|
|
42726
|
+
}
|
|
42727
|
+
return;
|
|
42728
|
+
}
|
|
42716
42729
|
if (e.outcome?.state === "expired" && e.outcome.reason === void 0) {
|
|
42717
42730
|
const { outcome: _, ...rest } = e;
|
|
42718
42731
|
this.#all.set(msgId, { ...rest, expired: true });
|
|
@@ -42728,25 +42741,43 @@ var SentStore = class {
|
|
|
42728
42741
|
}
|
|
42729
42742
|
/**
|
|
42730
42743
|
* The recipient took a message reported expired: it ends delivered. True
|
|
42731
|
-
* when the sender
|
|
42732
|
-
*
|
|
42744
|
+
* when the sender was told the expiry, or its notice is `inFlight` (it is
|
|
42745
|
+
* owed a correction, stored until `told(msgId, true)`); an expiry never
|
|
42746
|
+
* told is just dropped.
|
|
42733
42747
|
*/
|
|
42734
|
-
correct(msgId) {
|
|
42748
|
+
correct(msgId, inFlight = false) {
|
|
42735
42749
|
const e = this.#all.get(msgId);
|
|
42736
42750
|
if (!e || !this.correctable(msgId)) return false;
|
|
42737
|
-
const
|
|
42751
|
+
const owed = e.expired === true || inFlight;
|
|
42738
42752
|
const { outcome: _, expired: __, ...rest } = e;
|
|
42739
42753
|
this.#all.delete(msgId);
|
|
42740
|
-
this.#all.set(msgId, {
|
|
42754
|
+
this.#all.set(msgId, {
|
|
42755
|
+
...rest,
|
|
42756
|
+
at: this.#now(),
|
|
42757
|
+
delivered: true,
|
|
42758
|
+
...owed ? { correction: true } : {}
|
|
42759
|
+
});
|
|
42741
42760
|
this.#save();
|
|
42742
|
-
return
|
|
42761
|
+
return owed;
|
|
42743
42762
|
}
|
|
42744
|
-
/**
|
|
42763
|
+
/** The Expired notice never reached the agent, so the correction (which says to ignore it) is dropped. */
|
|
42764
|
+
dropCorrection(msgId) {
|
|
42765
|
+
const e = this.#all.get(msgId);
|
|
42766
|
+
if (!e?.correction) return;
|
|
42767
|
+
const { correction: _, ...rest } = e;
|
|
42768
|
+
this.#all.set(msgId, rest);
|
|
42769
|
+
this.#save();
|
|
42770
|
+
}
|
|
42771
|
+
/** Whether `msgId` is owed a correction. */
|
|
42772
|
+
correctionOwed(msgId) {
|
|
42773
|
+
return this.#all.get(msgId)?.correction === true;
|
|
42774
|
+
}
|
|
42775
|
+
/** Settled entries and owed corrections whose sender is `ref`, oldest first. */
|
|
42745
42776
|
untold(ref) {
|
|
42746
42777
|
this.#prune();
|
|
42747
42778
|
const out = [];
|
|
42748
42779
|
for (const [msgId, e] of this.#all) {
|
|
42749
|
-
if (e.from_ref !== ref || !e.outcome) continue;
|
|
42780
|
+
if (e.from_ref !== ref || !(e.outcome || e.correction)) continue;
|
|
42750
42781
|
out.push({ msgId, meta: metaOf(e), outcome: e.outcome });
|
|
42751
42782
|
}
|
|
42752
42783
|
return out;
|
|
@@ -42767,7 +42798,7 @@ var SentStore = class {
|
|
|
42767
42798
|
if (over <= 0) return;
|
|
42768
42799
|
for (const [id, e] of this.#all) {
|
|
42769
42800
|
if (over <= 0) return;
|
|
42770
|
-
if (e.delivered || e.expired) {
|
|
42801
|
+
if (e.delivered && !e.correction || e.expired) {
|
|
42771
42802
|
this.#all.delete(id);
|
|
42772
42803
|
over--;
|
|
42773
42804
|
}
|
|
@@ -42808,6 +42839,7 @@ var SentStore = class {
|
|
|
42808
42839
|
outcome,
|
|
42809
42840
|
delivered,
|
|
42810
42841
|
expired,
|
|
42842
|
+
correction,
|
|
42811
42843
|
late: late2,
|
|
42812
42844
|
shown: shown5,
|
|
42813
42845
|
native
|
|
@@ -42827,6 +42859,7 @@ var SentStore = class {
|
|
|
42827
42859
|
} : {},
|
|
42828
42860
|
...delivered ? { delivered } : {},
|
|
42829
42861
|
...expired && !delivered && !outcome ? { expired } : {},
|
|
42862
|
+
...delivered && correction ? { correction } : {},
|
|
42830
42863
|
...delivered && late2 ? { late: late2 } : {},
|
|
42831
42864
|
...delivered && late2 && shown5 ? { shown: shown5 } : {},
|
|
42832
42865
|
...native ? { native } : {}
|
|
@@ -42941,7 +42974,7 @@ var Receipts = class {
|
|
|
42941
42974
|
this.store.add(f.msg_id, s.meta, outcome);
|
|
42942
42975
|
return { msgId: f.msg_id, meta: s.meta, ...outcome };
|
|
42943
42976
|
}
|
|
42944
|
-
update(f) {
|
|
42977
|
+
update(f, inFlight = false) {
|
|
42945
42978
|
if (f.state === "pending") return void 0;
|
|
42946
42979
|
const corrects = f.state === "delivered" && this.store.correctable(f.msg_id);
|
|
42947
42980
|
if (this.#finals.has(f.msg_id) && !corrects) return void 0;
|
|
@@ -42952,7 +42985,7 @@ var Receipts = class {
|
|
|
42952
42985
|
}
|
|
42953
42986
|
this.#final(f.msg_id);
|
|
42954
42987
|
if (corrects) {
|
|
42955
|
-
return this.store.correct(f.msg_id) ? { msgId: f.msg_id, meta: meta3, state: "corrected" } : void 0;
|
|
42988
|
+
return this.store.correct(f.msg_id, inFlight) ? { msgId: f.msg_id, meta: meta3, state: "corrected" } : void 0;
|
|
42956
42989
|
}
|
|
42957
42990
|
if (this.store.isDelivered(f.msg_id)) return void 0;
|
|
42958
42991
|
if (f.state === "delivered") {
|
|
@@ -42975,12 +43008,12 @@ var Receipts = class {
|
|
|
42975
43008
|
this.#waiting.delete(msgId);
|
|
42976
43009
|
return Promise.resolve(w.final);
|
|
42977
43010
|
}
|
|
42978
|
-
return new Promise((
|
|
43011
|
+
return new Promise((resolve16) => {
|
|
42979
43012
|
const cancel = this.#after(ms, () => w.done?.(void 0));
|
|
42980
43013
|
w.done = (f) => {
|
|
42981
43014
|
cancel();
|
|
42982
43015
|
this.#waiting.delete(msgId);
|
|
42983
|
-
|
|
43016
|
+
resolve16(f);
|
|
42984
43017
|
};
|
|
42985
43018
|
});
|
|
42986
43019
|
}
|
|
@@ -43005,16 +43038,24 @@ var Receipts = class {
|
|
|
43005
43038
|
/** The owed notice for `msgId`, if one is owed. */
|
|
43006
43039
|
notice(msgId) {
|
|
43007
43040
|
const meta3 = this.store.get(msgId);
|
|
43041
|
+
if (meta3 && this.store.correctionOwed(msgId))
|
|
43042
|
+
return { msgId, meta: meta3, state: "corrected" };
|
|
43008
43043
|
const outcome = this.store.outcome(msgId);
|
|
43009
43044
|
return meta3 && outcome ? { msgId, meta: meta3, ...outcome } : void 0;
|
|
43010
43045
|
}
|
|
43046
|
+
/** Its notice failed to reach the sender: a correction to it is moot. */
|
|
43047
|
+
notTold(msgId) {
|
|
43048
|
+
this.store.dropCorrection(msgId);
|
|
43049
|
+
}
|
|
43011
43050
|
/** The sender has been told: forget the message. */
|
|
43012
|
-
told(msgId) {
|
|
43013
|
-
this.store.told(msgId);
|
|
43051
|
+
told(msgId, corrected = false) {
|
|
43052
|
+
this.store.told(msgId, corrected);
|
|
43014
43053
|
}
|
|
43015
43054
|
/** Notices still owed to `ref`, e.g. after a restart or while it was away. */
|
|
43016
43055
|
owed(ref) {
|
|
43017
|
-
return this.store.untold(ref).map(
|
|
43056
|
+
return this.store.untold(ref).map(
|
|
43057
|
+
({ msgId, meta: meta3, outcome }) => outcome ? { msgId, meta: meta3, ...outcome } : { msgId, meta: meta3, state: "corrected" }
|
|
43058
|
+
);
|
|
43018
43059
|
}
|
|
43019
43060
|
#final(msgId) {
|
|
43020
43061
|
this.#finals.add(msgId);
|
|
@@ -43289,22 +43330,22 @@ var ClaudeTransport = class {
|
|
|
43289
43330
|
return { ok: false, reason: "closed", cause: st };
|
|
43290
43331
|
}
|
|
43291
43332
|
#waitFor(msgId, ms) {
|
|
43292
|
-
return new Promise((
|
|
43333
|
+
return new Promise((resolve16) => {
|
|
43293
43334
|
const buffered = this.#buffered.get(msgId);
|
|
43294
43335
|
if (buffered !== void 0) {
|
|
43295
43336
|
this.#buffered.delete(msgId);
|
|
43296
|
-
|
|
43337
|
+
resolve16(buffered);
|
|
43297
43338
|
return;
|
|
43298
43339
|
}
|
|
43299
43340
|
const timer = setTimeout(() => {
|
|
43300
43341
|
this.#waiting.delete(msgId);
|
|
43301
|
-
|
|
43342
|
+
resolve16(void 0);
|
|
43302
43343
|
}, ms);
|
|
43303
43344
|
timer.unref();
|
|
43304
43345
|
this.#waiting.set(msgId, (s) => {
|
|
43305
43346
|
clearTimeout(timer);
|
|
43306
43347
|
this.#waiting.delete(msgId);
|
|
43307
|
-
|
|
43348
|
+
resolve16(s);
|
|
43308
43349
|
});
|
|
43309
43350
|
});
|
|
43310
43351
|
}
|
|
@@ -43454,9 +43495,9 @@ var ClaudeTransport = class {
|
|
|
43454
43495
|
);
|
|
43455
43496
|
})
|
|
43456
43497
|
};
|
|
43457
|
-
await new Promise((
|
|
43498
|
+
await new Promise((resolve16, reject) => {
|
|
43458
43499
|
sink.server.once("error", reject);
|
|
43459
|
-
sink.server.listen(path, () =>
|
|
43500
|
+
sink.server.listen(path, () => resolve16());
|
|
43460
43501
|
});
|
|
43461
43502
|
chmodSync8(path, 384);
|
|
43462
43503
|
return sink;
|
|
@@ -43675,7 +43716,7 @@ function splitArgv0(args) {
|
|
|
43675
43716
|
});
|
|
43676
43717
|
return words(args.slice(real3 ?? ends[0]));
|
|
43677
43718
|
}
|
|
43678
|
-
var execText = (cmd, args) => new Promise((
|
|
43719
|
+
var execText = (cmd, args) => new Promise((resolve16) => {
|
|
43679
43720
|
execFile(
|
|
43680
43721
|
cmd,
|
|
43681
43722
|
args,
|
|
@@ -43684,7 +43725,7 @@ var execText = (cmd, args) => new Promise((resolve14) => {
|
|
|
43684
43725
|
timeout: 2e3,
|
|
43685
43726
|
env: { ...process.env, LC_ALL: "C" }
|
|
43686
43727
|
},
|
|
43687
|
-
(err, stdout) =>
|
|
43728
|
+
(err, stdout) => resolve16(err ? void 0 : stdout)
|
|
43688
43729
|
);
|
|
43689
43730
|
});
|
|
43690
43731
|
async function processArgs(pid) {
|
|
@@ -43707,17 +43748,17 @@ async function processArgs(pid) {
|
|
|
43707
43748
|
return args ? splitArgv0(args) : void 0;
|
|
43708
43749
|
}
|
|
43709
43750
|
var START_ERRORS = /* @__PURE__ */ new Set(["ENOENT", "EACCES", "ENOEXEC"]);
|
|
43710
|
-
var execCodex = (timeoutMs = CODEX_QUEUE_TIMEOUT_MS) => (bin, args, env2) => new Promise((
|
|
43751
|
+
var execCodex = (timeoutMs = CODEX_QUEUE_TIMEOUT_MS) => (bin, args, env2) => new Promise((resolve16, reject) => {
|
|
43711
43752
|
execFile(
|
|
43712
43753
|
bin,
|
|
43713
43754
|
args,
|
|
43714
43755
|
{ timeout: timeoutMs, maxBuffer: 64 * 1024, env: env2 },
|
|
43715
43756
|
(err, _stdout, stderr) => {
|
|
43716
|
-
if (!err) return
|
|
43757
|
+
if (!err) return resolve16({ code: 0, stderr });
|
|
43717
43758
|
const e = err;
|
|
43718
43759
|
if (typeof e.code === "string" && START_ERRORS.has(e.code))
|
|
43719
43760
|
return reject(err);
|
|
43720
|
-
|
|
43761
|
+
resolve16({
|
|
43721
43762
|
// A maxBuffer kill is SIGTERM too, but carries its own string code.
|
|
43722
43763
|
code: e.killed && e.signal === "SIGTERM" && typeof e.code !== "string" ? null : typeof e.code === "number" ? e.code : -1,
|
|
43723
43764
|
stderr: String(stderr ?? "")
|
|
@@ -43842,17 +43883,17 @@ var codexHostWakes = async (pid) => {
|
|
|
43842
43883
|
init_src2();
|
|
43843
43884
|
import { execFile as execFile2 } from "node:child_process";
|
|
43844
43885
|
var START_ERRORS2 = /* @__PURE__ */ new Set(["ENOENT", "EACCES"]);
|
|
43845
|
-
var execSpawn = (timeoutMs, maxBuffer = 1024 * 1024) => (cmd, args) => new Promise((
|
|
43886
|
+
var execSpawn = (timeoutMs, maxBuffer = 1024 * 1024) => (cmd, args) => new Promise((resolve16, reject) => {
|
|
43846
43887
|
execFile2(
|
|
43847
43888
|
cmd,
|
|
43848
43889
|
args,
|
|
43849
43890
|
{ timeout: timeoutMs, maxBuffer },
|
|
43850
43891
|
(err, stdout, stderr) => {
|
|
43851
|
-
if (!err) return
|
|
43892
|
+
if (!err) return resolve16({ code: 0, stdout, stderr });
|
|
43852
43893
|
const e = err;
|
|
43853
43894
|
if (typeof e.code === "string" && START_ERRORS2.has(e.code))
|
|
43854
43895
|
return reject(err);
|
|
43855
|
-
|
|
43896
|
+
resolve16({
|
|
43856
43897
|
code: e.killed || typeof e.code !== "number" ? null : e.code,
|
|
43857
43898
|
stdout,
|
|
43858
43899
|
stderr
|
|
@@ -43969,18 +44010,18 @@ var PiTransport = class {
|
|
|
43969
44010
|
});
|
|
43970
44011
|
if (!pushed) return { ok: false, reason: "closed" };
|
|
43971
44012
|
this.#forget(mail.msg_id);
|
|
43972
|
-
return new Promise((
|
|
44013
|
+
return new Promise((resolve16) => {
|
|
43973
44014
|
const timer = setTimeout(() => {
|
|
43974
44015
|
this.#waiting.delete(mail.msg_id);
|
|
43975
44016
|
this.#remember(mail.msg_id, agent.ref);
|
|
43976
|
-
|
|
44017
|
+
resolve16({ ok: false, reason: "timeout" });
|
|
43977
44018
|
}, this.opts.ackTimeoutMs ?? 1e4);
|
|
43978
44019
|
timer.unref();
|
|
43979
44020
|
this.#waiting.set(mail.msg_id, {
|
|
43980
44021
|
ref: agent.ref,
|
|
43981
44022
|
done: (o) => {
|
|
43982
44023
|
clearTimeout(timer);
|
|
43983
|
-
|
|
44024
|
+
resolve16(o);
|
|
43984
44025
|
}
|
|
43985
44026
|
});
|
|
43986
44027
|
});
|
|
@@ -44174,6 +44215,8 @@ function listLeadTemplateNames(h = home()) {
|
|
|
44174
44215
|
|
|
44175
44216
|
// ../bus-daemon/src/index.ts
|
|
44176
44217
|
var NOTICE_RETRY_MS = 3e4;
|
|
44218
|
+
var BINDING_IDLE_MS = 24 * 60 * 6e4;
|
|
44219
|
+
var BINDING_SWEEP_MS = 6e4;
|
|
44177
44220
|
var RENAME_HOLD_MS = 60 * 6e4;
|
|
44178
44221
|
var RENAME_WINDOW_MS = 6e4;
|
|
44179
44222
|
var RENAME_WINDOW_MAX = 3;
|
|
@@ -44203,6 +44246,24 @@ async function runDaemon(deps2 = {}) {
|
|
|
44203
44246
|
const conns = /* @__PURE__ */ new Map();
|
|
44204
44247
|
const piLinks = /* @__PURE__ */ new Map();
|
|
44205
44248
|
const bindings = /* @__PURE__ */ new Map();
|
|
44249
|
+
const bindingNow = deps2.bindingNow ?? Date.now;
|
|
44250
|
+
const bindingLapsed = (ref, claim2, startOf) => {
|
|
44251
|
+
if (conns.has(ref)) return false;
|
|
44252
|
+
if (claim2.closedAt !== void 0 && bindingNow() - claim2.closedAt >= BINDING_IDLE_MS)
|
|
44253
|
+
return true;
|
|
44254
|
+
if (!running(claim2.pid)) return true;
|
|
44255
|
+
const now = claim2.start === void 0 ? null : startOf(claim2.pid);
|
|
44256
|
+
return now !== null && claim2.start !== void 0 && now !== claim2.start;
|
|
44257
|
+
};
|
|
44258
|
+
let bindingSweptAt = 0;
|
|
44259
|
+
const sweepBindings = () => {
|
|
44260
|
+
const t = bindingNow();
|
|
44261
|
+
if (t - bindingSweptAt < BINDING_SWEEP_MS) return;
|
|
44262
|
+
bindingSweptAt = t;
|
|
44263
|
+
for (const [ref, claim2] of bindings)
|
|
44264
|
+
if (bindingLapsed(ref, claim2, (p) => claudeSessions.procStart(p)))
|
|
44265
|
+
bindings.delete(ref);
|
|
44266
|
+
};
|
|
44206
44267
|
const held = (ref) => {
|
|
44207
44268
|
const rec = agents.byRef(ref);
|
|
44208
44269
|
return rec?.replaces !== void 0 && !hubHelloed;
|
|
@@ -44242,15 +44303,16 @@ async function runDaemon(deps2 = {}) {
|
|
|
44242
44303
|
if (sent2) rec.sentName = rec.proposedName;
|
|
44243
44304
|
return sent2;
|
|
44244
44305
|
};
|
|
44245
|
-
const sendLink = (rec) => {
|
|
44246
|
-
if (!hubLink || !rec.live
|
|
44247
|
-
|
|
44248
|
-
|
|
44249
|
-
|
|
44250
|
-
|
|
44251
|
-
|
|
44252
|
-
|
|
44253
|
-
|
|
44306
|
+
const sendLink = (rec, only) => {
|
|
44307
|
+
if (!hubLink || !rec.live) return;
|
|
44308
|
+
for (const hash2 of only === void 0 ? rec.linkHashes ?? [] : [only])
|
|
44309
|
+
hub.send({
|
|
44310
|
+
v: 1,
|
|
44311
|
+
id: frameId(),
|
|
44312
|
+
type: "link_bind",
|
|
44313
|
+
agent_ref: rec.ref,
|
|
44314
|
+
hash: hash2
|
|
44315
|
+
});
|
|
44254
44316
|
};
|
|
44255
44317
|
const markLimited = (ref, message) => {
|
|
44256
44318
|
if (!limited.has(ref))
|
|
@@ -44449,11 +44511,23 @@ async function runDaemon(deps2 = {}) {
|
|
|
44449
44511
|
n.msgId
|
|
44450
44512
|
).then(
|
|
44451
44513
|
(ok) => {
|
|
44452
|
-
if (ok) receipts.told(n.msgId);
|
|
44453
|
-
else
|
|
44514
|
+
if (ok) receipts.told(n.msgId, n.state === "corrected");
|
|
44515
|
+
else {
|
|
44516
|
+
if (n.state !== "corrected") receipts.notTold(n.msgId);
|
|
44517
|
+
log(`could not tell ${agent.busName} about ${n.meta.to_name}`);
|
|
44518
|
+
}
|
|
44454
44519
|
},
|
|
44455
|
-
(e) =>
|
|
44456
|
-
|
|
44520
|
+
(e) => {
|
|
44521
|
+
if (n.state !== "corrected") receipts.notTold(n.msgId);
|
|
44522
|
+
log(`notice failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
44523
|
+
}
|
|
44524
|
+
).finally(() => {
|
|
44525
|
+
telling.delete(n.msgId);
|
|
44526
|
+
if (n.state !== "corrected") {
|
|
44527
|
+
const next = receipts.notice(n.msgId);
|
|
44528
|
+
if (next?.state === "corrected") tell(next);
|
|
44529
|
+
}
|
|
44530
|
+
});
|
|
44457
44531
|
};
|
|
44458
44532
|
const tellOwed = (ref) => {
|
|
44459
44533
|
for (const n of receipts.owed(ref)) tell(n);
|
|
@@ -44581,8 +44655,8 @@ async function runDaemon(deps2 = {}) {
|
|
|
44581
44655
|
const p = pendingProofs.get(rec.pid);
|
|
44582
44656
|
if (!p || p.procStart !== rec.procStart) continue;
|
|
44583
44657
|
pendingProofs.delete(rec.pid);
|
|
44584
|
-
rec.
|
|
44585
|
-
sendLink(rec);
|
|
44658
|
+
rec.linkHashes = withLinkHash(rec.linkHashes, p.hash);
|
|
44659
|
+
sendLink(rec, p.hash);
|
|
44586
44660
|
}
|
|
44587
44661
|
};
|
|
44588
44662
|
const renameCodexThreads = () => {
|
|
@@ -44639,7 +44713,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
44639
44713
|
pid: s.pid,
|
|
44640
44714
|
procStart: s.procStart,
|
|
44641
44715
|
// The same process keeps its proof across /clear; agent_ok rebinds it.
|
|
44642
|
-
...old?.
|
|
44716
|
+
...old?.linkHashes !== void 0 ? { linkHashes: old.linkHashes } : {},
|
|
44643
44717
|
sessionName: s.name,
|
|
44644
44718
|
cwd: s.cwd,
|
|
44645
44719
|
live: true
|
|
@@ -44760,7 +44834,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
44760
44834
|
return;
|
|
44761
44835
|
}
|
|
44762
44836
|
case "receipt_update":
|
|
44763
|
-
tell(receipts.update(frame));
|
|
44837
|
+
tell(receipts.update(frame, telling.has(frame.msg_id)));
|
|
44764
44838
|
return;
|
|
44765
44839
|
case "error": {
|
|
44766
44840
|
if (statusRelay.answer(frame)) return;
|
|
@@ -44899,21 +44973,21 @@ async function runDaemon(deps2 = {}) {
|
|
|
44899
44973
|
statusEveryMs: deps2.status?.statusEveryMs
|
|
44900
44974
|
});
|
|
44901
44975
|
const hubRoster = (ref) => new Promise(
|
|
44902
|
-
(
|
|
44976
|
+
(resolve16) => {
|
|
44903
44977
|
const id = pending.open(
|
|
44904
44978
|
"status",
|
|
44905
|
-
(f) =>
|
|
44979
|
+
(f) => resolve16(f.type === "roster" ? f.agents : void 0)
|
|
44906
44980
|
);
|
|
44907
44981
|
const timer = setTimeout(() => {
|
|
44908
44982
|
pending.cancel(id);
|
|
44909
44983
|
hub.cancel(id);
|
|
44910
|
-
|
|
44984
|
+
resolve16(void 0);
|
|
44911
44985
|
}, deps2.statusRosterMs ?? 1500);
|
|
44912
44986
|
timer.unref();
|
|
44913
44987
|
if (!hub.send({ v: 1, id, type: "list", from_ref: ref })) {
|
|
44914
44988
|
clearTimeout(timer);
|
|
44915
44989
|
pending.cancel(id);
|
|
44916
|
-
|
|
44990
|
+
resolve16(void 0);
|
|
44917
44991
|
}
|
|
44918
44992
|
}
|
|
44919
44993
|
);
|
|
@@ -44949,8 +45023,8 @@ async function runDaemon(deps2 = {}) {
|
|
|
44949
45023
|
}
|
|
44950
45024
|
if (rec && rec.procStart !== void 0) {
|
|
44951
45025
|
if (rec.procStart !== start) return { bound: false };
|
|
44952
|
-
rec.
|
|
44953
|
-
sendLink(rec);
|
|
45026
|
+
rec.linkHashes = withLinkHash(rec.linkHashes, req.hash);
|
|
45027
|
+
sendLink(rec, req.hash);
|
|
44954
45028
|
return { bound: true };
|
|
44955
45029
|
}
|
|
44956
45030
|
pendingProofs.delete(req.pid);
|
|
@@ -45075,11 +45149,8 @@ async function runDaemon(deps2 = {}) {
|
|
|
45075
45149
|
if (check2.linkOnly) linkOnly.add(hello);
|
|
45076
45150
|
let bindToken;
|
|
45077
45151
|
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
|
-
}
|
|
45152
|
+
if (claim2 && bindingLapsed(hello.agent_ref, claim2, startOfPid))
|
|
45153
|
+
bindings.delete(hello.agent_ref);
|
|
45083
45154
|
const held2 = bindings.get(hello.agent_ref);
|
|
45084
45155
|
if (held2 && (held2.kind !== hello.kind || !piLike(hello.kind) || held2.token !== hello.bind_token))
|
|
45085
45156
|
return { error: REF_BOUND };
|
|
@@ -45169,7 +45240,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
45169
45240
|
...mine ? { procStart: mine.procStart } : {},
|
|
45170
45241
|
...mine ? { sessionName: mine.name } : {},
|
|
45171
45242
|
// Claude's MCP server reconnects per tool call: the proof stays.
|
|
45172
|
-
...(prev?.
|
|
45243
|
+
...(prev?.linkHashes ?? old?.linkHashes) !== void 0 ? { linkHashes: prev?.linkHashes ?? old?.linkHashes } : {},
|
|
45173
45244
|
...codexName !== void 0 ? { sessionName: codexName } : {},
|
|
45174
45245
|
cwd,
|
|
45175
45246
|
live: true
|
|
@@ -45233,8 +45304,8 @@ async function runDaemon(deps2 = {}) {
|
|
|
45233
45304
|
if (!hubLink || !hubLinkArg) return false;
|
|
45234
45305
|
const rec = agents.byRef(ref);
|
|
45235
45306
|
if (!rec?.live) return false;
|
|
45236
|
-
rec.
|
|
45237
|
-
sendLink(rec);
|
|
45307
|
+
rec.linkHashes = withLinkHash(rec.linkHashes, hash2);
|
|
45308
|
+
sendLink(rec, hash2);
|
|
45238
45309
|
return true;
|
|
45239
45310
|
},
|
|
45240
45311
|
renamed: (ref, name) => {
|
|
@@ -45298,6 +45369,8 @@ async function runDaemon(deps2 = {}) {
|
|
|
45298
45369
|
}
|
|
45299
45370
|
conns.delete(hello.agent_ref);
|
|
45300
45371
|
if (!piLike(hello.kind)) return;
|
|
45372
|
+
const bound2 = bindings.get(hello.agent_ref);
|
|
45373
|
+
if (bound2) bound2.closedAt = bindingNow();
|
|
45301
45374
|
const rec = agents.byRef(hello.agent_ref);
|
|
45302
45375
|
if (!rec) return;
|
|
45303
45376
|
rec.live = false;
|
|
@@ -45422,6 +45495,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
45422
45495
|
}
|
|
45423
45496
|
}
|
|
45424
45497
|
for (const rec of agents.all()) if (rec.live) flushRename(rec);
|
|
45498
|
+
sweepBindings();
|
|
45425
45499
|
};
|
|
45426
45500
|
restoreCodex();
|
|
45427
45501
|
sync();
|
|
@@ -45441,6 +45515,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
45441
45515
|
return {
|
|
45442
45516
|
hub,
|
|
45443
45517
|
agents,
|
|
45518
|
+
bindings: { count: () => bindings.size, sweep: sweepBindings },
|
|
45444
45519
|
stop: async () => {
|
|
45445
45520
|
clearInterval(socketWatch);
|
|
45446
45521
|
clearInterval(watcher);
|
|
@@ -46055,6 +46130,71 @@ function copy(style) {
|
|
|
46055
46130
|
],
|
|
46056
46131
|
// Codex's checks, after its wiring line (C26e).
|
|
46057
46132
|
codexWakes: (bin) => done(`Codex wakes with ${clip(bin, 20)}`),
|
|
46133
|
+
// The Claude Code output style (#1970): turned on, or added beside the person's own choice.
|
|
46134
|
+
// Product's sentence, wrapped to the 80 columns every transcript line keeps.
|
|
46135
|
+
outputStyleOn: (where) => [
|
|
46136
|
+
done("Turned on the Artifacts Teammate output style"),
|
|
46137
|
+
next(`(${clip(where, 5)}).`),
|
|
46138
|
+
next("Restart Claude Code sessions to use it.")
|
|
46139
|
+
],
|
|
46140
|
+
// `style` is undefined when the choice is not a style name (null, a number, "default").
|
|
46141
|
+
outputStyleKept: (style2) => done(
|
|
46142
|
+
`Added the Artifacts Teammate output style. You're on ${style2 ?? "the default style"}; switch with /output-style.`
|
|
46143
|
+
),
|
|
46144
|
+
outputStyleDoctor: (where, on) => done(
|
|
46145
|
+
`Artifacts Teammate output style installed in ${where} (${on ? "on" : "installed, not selected"})`
|
|
46146
|
+
),
|
|
46147
|
+
// #1626: the `oa-bus` shim on PATH.
|
|
46148
|
+
shimInstalled: (where) => done(`Installed the oa-bus command: ${clip(where, 30)}`),
|
|
46149
|
+
shimNotOnPath: (dir, hint) => [
|
|
46150
|
+
warn(
|
|
46151
|
+
`${clip(dir, 30)} is not on your PATH, so \`oa-bus\` won't run yet.`
|
|
46152
|
+
),
|
|
46153
|
+
next(`To fix it, add this line to your shell profile: ${hint}`)
|
|
46154
|
+
],
|
|
46155
|
+
shimForeign: (where) => [
|
|
46156
|
+
warn(`Left ${clip(where, 30)} alone: it isn't from Open Artifacts.`),
|
|
46157
|
+
next(
|
|
46158
|
+
`Typing \`oa-bus\` runs that file, not this install. Remove it, or use \`${BUS_CMD}\`.`
|
|
46159
|
+
)
|
|
46160
|
+
],
|
|
46161
|
+
shimOtherHome: (where, home2) => [
|
|
46162
|
+
warn(
|
|
46163
|
+
`Left ${clip(where, 30)} alone: it belongs to the install in ${clip(home2, 30)}.`
|
|
46164
|
+
),
|
|
46165
|
+
next(
|
|
46166
|
+
`Typing \`oa-bus\` runs that install, not this one. Use \`${BUS_CMD}\` for this one.`
|
|
46167
|
+
)
|
|
46168
|
+
],
|
|
46169
|
+
shimRemoved: (where) => done(`Removed the oa-bus command: ${clip(where, 30)}`),
|
|
46170
|
+
shimDoctorOk: (where) => done(`oa-bus on your PATH runs this install (${clip(where, 30)})`),
|
|
46171
|
+
shimDoctorOffPath: (where, hint) => [
|
|
46172
|
+
warn(`oa-bus is not on your PATH (the command is in ${clip(where, 30)})`),
|
|
46173
|
+
next(`To fix it, add this line to your shell profile: ${hint}`)
|
|
46174
|
+
],
|
|
46175
|
+
shimDoctorOther: (where) => [
|
|
46176
|
+
warn(`oa-bus on your PATH is not this install's (${clip(where, 30)})`),
|
|
46177
|
+
next(
|
|
46178
|
+
`Remove it, or put this install's first. Re-run ${BUS_CMD} install to refresh ours.`
|
|
46179
|
+
)
|
|
46180
|
+
],
|
|
46181
|
+
shimDoctorMissing: () => [
|
|
46182
|
+
warn("oa-bus is not on your PATH"),
|
|
46183
|
+
next(`Run ${BUS_CMD} install to add it.`)
|
|
46184
|
+
],
|
|
46185
|
+
codexSkill: (where) => done(`Codex skill installed in ${clip(where, 20)}`),
|
|
46186
|
+
codexSkillTwice: (file2, block) => [
|
|
46187
|
+
warn("The Codex skill is installed twice, so it loads twice"),
|
|
46188
|
+
next(
|
|
46189
|
+
`It's in both ${clip(file2, 30)} and ${clip(block, 20)}. Run ${BUS_CMD} install again to keep just one.`
|
|
46190
|
+
)
|
|
46191
|
+
],
|
|
46192
|
+
codexSkillSharedTwice: () => [
|
|
46193
|
+
warn("The Codex skill is installed twice, so it loads twice"),
|
|
46194
|
+
next(
|
|
46195
|
+
"Codex shares its skills folder with pi and omp, so it also sees their copy."
|
|
46196
|
+
)
|
|
46197
|
+
],
|
|
46058
46198
|
codexNoWakeCheck: () => [
|
|
46059
46199
|
warn("No codex binary found, so idle Codex threads are not woken"),
|
|
46060
46200
|
next(`Install the Codex CLI, then run ${BUS_CMD} install again.`)
|
|
@@ -46319,19 +46459,19 @@ init_src2();
|
|
|
46319
46459
|
import { execFile as execFile3, spawn } from "node:child_process";
|
|
46320
46460
|
import { promisify } from "node:util";
|
|
46321
46461
|
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((
|
|
46462
|
+
var openBrowser = (url2, launcher = browserCommand(process.platform, url2)) => new Promise((resolve16) => {
|
|
46323
46463
|
try {
|
|
46324
46464
|
const child = spawn(launcher.cmd, launcher.args, {
|
|
46325
46465
|
stdio: "ignore",
|
|
46326
46466
|
detached: true
|
|
46327
46467
|
});
|
|
46328
|
-
child.once("error", () =>
|
|
46468
|
+
child.once("error", () => resolve16(false));
|
|
46329
46469
|
child.once("spawn", () => {
|
|
46330
46470
|
child.unref();
|
|
46331
|
-
|
|
46471
|
+
resolve16(true);
|
|
46332
46472
|
});
|
|
46333
46473
|
} catch {
|
|
46334
|
-
|
|
46474
|
+
resolve16(false);
|
|
46335
46475
|
}
|
|
46336
46476
|
});
|
|
46337
46477
|
var EXEC_TIMEOUT_MS = 1e4;
|
|
@@ -47401,8 +47541,8 @@ function upsert(path, text3, doc, entry) {
|
|
|
47401
47541
|
);
|
|
47402
47542
|
const eol2 = eolOf(lines);
|
|
47403
47543
|
const ended = lines.at(-1)?.text === "" && lines.length > 1;
|
|
47404
|
-
const
|
|
47405
|
-
next = `${text3}${
|
|
47544
|
+
const sep4 = text3 === "" ? "" : ended ? blank(lines.at(-2)) ? "" : eol2 : eol2 + eol2;
|
|
47545
|
+
next = `${text3}${sep4}${block.join(eol2)}${eol2}`;
|
|
47406
47546
|
}
|
|
47407
47547
|
return checked(path, doc, next, entry);
|
|
47408
47548
|
}
|
|
@@ -47420,6 +47560,19 @@ function remove(path, text3, doc) {
|
|
|
47420
47560
|
for (const at of all.reverse()) lines = cut(lines, at);
|
|
47421
47561
|
return checked(path, doc, joinLines(lines), void 0);
|
|
47422
47562
|
}
|
|
47563
|
+
async function readCodexVersion(o) {
|
|
47564
|
+
try {
|
|
47565
|
+
const bin = findCodexBin({
|
|
47566
|
+
configFile: o.configFile,
|
|
47567
|
+
path: o.path,
|
|
47568
|
+
app: o.app
|
|
47569
|
+
});
|
|
47570
|
+
const r = await o.exec(bin ?? "codex", ["--version"]);
|
|
47571
|
+
return /(\d+\.\d+\.\d+\S*)/.exec(r.code === 0 ? r.stdout : "")?.[1];
|
|
47572
|
+
} catch {
|
|
47573
|
+
return void 0;
|
|
47574
|
+
}
|
|
47575
|
+
}
|
|
47423
47576
|
|
|
47424
47577
|
// src/steps/step.ts
|
|
47425
47578
|
import {
|
|
@@ -47883,7 +48036,7 @@ var noService = {
|
|
|
47883
48036
|
remove: async () => ({}),
|
|
47884
48037
|
cli: () => ["oa-bus"]
|
|
47885
48038
|
};
|
|
47886
|
-
var VERSION = true ? "0.
|
|
48039
|
+
var VERSION = true ? "0.148.0" : JSON.parse(
|
|
47887
48040
|
readFileSync13(new URL("../package.json", import.meta.url), "utf8")
|
|
47888
48041
|
).version;
|
|
47889
48042
|
var which = (cmd) => {
|
|
@@ -47965,7 +48118,7 @@ function realCtx(noColor) {
|
|
|
47965
48118
|
});
|
|
47966
48119
|
try {
|
|
47967
48120
|
return await new Promise(
|
|
47968
|
-
(
|
|
48121
|
+
(resolve16) => rl.question(question, resolve16)
|
|
47969
48122
|
);
|
|
47970
48123
|
} finally {
|
|
47971
48124
|
rl.close();
|
|
@@ -48090,7 +48243,7 @@ async function daemon(ctx, run4 = runDaemon, signals = process) {
|
|
|
48090
48243
|
sayErr(ctx, ctx.copy.revoked());
|
|
48091
48244
|
return 0;
|
|
48092
48245
|
}
|
|
48093
|
-
return new Promise((
|
|
48246
|
+
return new Promise((resolve16) => {
|
|
48094
48247
|
let running;
|
|
48095
48248
|
let ended = false;
|
|
48096
48249
|
const end = (code2) => {
|
|
@@ -48098,7 +48251,7 @@ async function daemon(ctx, run4 = runDaemon, signals = process) {
|
|
|
48098
48251
|
ended = true;
|
|
48099
48252
|
signals.off("SIGINT", onSignal);
|
|
48100
48253
|
signals.off("SIGTERM", onSignal);
|
|
48101
|
-
void (running?.stop() ?? Promise.resolve()).finally(() =>
|
|
48254
|
+
void (running?.stop() ?? Promise.resolve()).finally(() => resolve16(code2));
|
|
48102
48255
|
};
|
|
48103
48256
|
const onSignal = () => end(0);
|
|
48104
48257
|
signals.once("SIGINT", onSignal);
|
|
@@ -48127,8 +48280,8 @@ async function daemon(ctx, run4 = runDaemon, signals = process) {
|
|
|
48127
48280
|
}
|
|
48128
48281
|
|
|
48129
48282
|
// src/commands/doctor.ts
|
|
48130
|
-
import { readFileSync as
|
|
48131
|
-
import { join as
|
|
48283
|
+
import { readFileSync as readFileSync26 } from "node:fs";
|
|
48284
|
+
import { join as join32 } from "node:path";
|
|
48132
48285
|
|
|
48133
48286
|
// ../bus-adapter-opencode/src/index.ts
|
|
48134
48287
|
init_proxy();
|
|
@@ -48147,13 +48300,13 @@ import {
|
|
|
48147
48300
|
lstatSync as lstatSync14,
|
|
48148
48301
|
mkdirSync as mkdirSync11,
|
|
48149
48302
|
readFileSync as readFileSync23,
|
|
48150
|
-
readlinkSync as
|
|
48303
|
+
readlinkSync as readlinkSync3,
|
|
48151
48304
|
renameSync as renameSync12,
|
|
48152
48305
|
rmSync as rmSync12,
|
|
48153
48306
|
statSync as statSync10,
|
|
48154
48307
|
writeFileSync as writeFileSync10
|
|
48155
48308
|
} from "node:fs";
|
|
48156
|
-
import { dirname as dirname12, join as join26, resolve as
|
|
48309
|
+
import { dirname as dirname12, join as join26, resolve as resolve10 } from "node:path";
|
|
48157
48310
|
import { isDeepStrictEqual } from "node:util";
|
|
48158
48311
|
|
|
48159
48312
|
// ../bus-adapter-hermes/src/index.ts
|
|
@@ -48701,11 +48854,11 @@ function parseTree(text3, errors = [], options = ParseOptions.DEFAULT) {
|
|
|
48701
48854
|
onValue({ type: getNodeType(value), offset, length, parent: currentParent, value });
|
|
48702
48855
|
ensurePropertyComplete(offset + length);
|
|
48703
48856
|
},
|
|
48704
|
-
onSeparator: (
|
|
48857
|
+
onSeparator: (sep4, offset, length) => {
|
|
48705
48858
|
if (currentParent.type === "property") {
|
|
48706
|
-
if (
|
|
48859
|
+
if (sep4 === ":") {
|
|
48707
48860
|
currentParent.colonOffset = offset;
|
|
48708
|
-
} else if (
|
|
48861
|
+
} else if (sep4 === ",") {
|
|
48709
48862
|
ensurePropertyComplete(offset);
|
|
48710
48863
|
}
|
|
48711
48864
|
}
|
|
@@ -49818,7 +49971,7 @@ import {
|
|
|
49818
49971
|
realpathSync as realpathSync12,
|
|
49819
49972
|
rmSync as rmSync9
|
|
49820
49973
|
} from "node:fs";
|
|
49821
|
-
import { join as join24, resolve as
|
|
49974
|
+
import { join as join24, resolve as resolve8, sep as sep2 } from "node:path";
|
|
49822
49975
|
|
|
49823
49976
|
// src/steps/hermes.ts
|
|
49824
49977
|
import { createHash as createHash7, randomBytes as randomBytes5 } from "node:crypto";
|
|
@@ -49937,9 +50090,9 @@ function hermesRoot(home2, env2, platform = process.platform) {
|
|
|
49937
50090
|
}
|
|
49938
50091
|
function hermesProfilesScan(home2, env2, platform = process.platform) {
|
|
49939
50092
|
const path = join21(hermesRoot(home2, env2, platform), "profiles");
|
|
49940
|
-
let
|
|
50093
|
+
let isLink3 = false;
|
|
49941
50094
|
try {
|
|
49942
|
-
|
|
50095
|
+
isLink3 = lstatSync10(path).isSymbolicLink();
|
|
49943
50096
|
} catch {
|
|
49944
50097
|
}
|
|
49945
50098
|
const target2 = () => {
|
|
@@ -49958,7 +50111,7 @@ function hermesProfilesScan(home2, env2, platform = process.platform) {
|
|
|
49958
50111
|
return {
|
|
49959
50112
|
names: names2,
|
|
49960
50113
|
incomplete: false,
|
|
49961
|
-
note:
|
|
50114
|
+
note: isLink3 ? `The Hermes profiles folder ${path} is a symlink to ${target2()}. Its profiles were checked too.` : void 0
|
|
49962
50115
|
};
|
|
49963
50116
|
} catch (e) {
|
|
49964
50117
|
const code2 = e.code ?? "error";
|
|
@@ -49966,7 +50119,7 @@ function hermesProfilesScan(home2, env2, platform = process.platform) {
|
|
|
49966
50119
|
return {
|
|
49967
50120
|
names: [],
|
|
49968
50121
|
incomplete: false,
|
|
49969
|
-
note:
|
|
50122
|
+
note: isLink3 ? `The Hermes profiles folder ${path} is a symlink to ${target2()}, which doesn't exist, so there were no profiles to check.` : void 0
|
|
49970
50123
|
};
|
|
49971
50124
|
if (code2 === "ENOTDIR")
|
|
49972
50125
|
return {
|
|
@@ -50156,7 +50309,7 @@ import {
|
|
|
50156
50309
|
realpathSync as realpathSync11,
|
|
50157
50310
|
rmSync as rmSync8
|
|
50158
50311
|
} from "node:fs";
|
|
50159
|
-
import { join as join23, resolve as
|
|
50312
|
+
import { join as join23, resolve as resolve7 } from "node:path";
|
|
50160
50313
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
50161
50314
|
|
|
50162
50315
|
// src/steps/skill.ts
|
|
@@ -50167,6 +50320,7 @@ import {
|
|
|
50167
50320
|
mkdirSync as mkdirSync10,
|
|
50168
50321
|
readdirSync as readdirSync6,
|
|
50169
50322
|
readFileSync as readFileSync18,
|
|
50323
|
+
readlinkSync as readlinkSync2,
|
|
50170
50324
|
realpathSync as realpathSync10,
|
|
50171
50325
|
renameSync as renameSync11,
|
|
50172
50326
|
rmdirSync as rmdirSync2,
|
|
@@ -50174,11 +50328,47 @@ import {
|
|
|
50174
50328
|
statSync as statSync9,
|
|
50175
50329
|
writeFileSync as writeFileSync9
|
|
50176
50330
|
} from "node:fs";
|
|
50177
|
-
import { dirname as dirname10, join as join22 } from "node:path";
|
|
50331
|
+
import { dirname as dirname10, join as join22, resolve as resolve6 } from "node:path";
|
|
50178
50332
|
var SKILL_MARKER = "<!-- managed by the Open Artifacts bus installer: edits are replaced on reinstall. -->";
|
|
50179
50333
|
var CODEX_BEGIN = "<!-- BEGIN Open Artifacts skill (managed): edits inside are replaced on reinstall. -->";
|
|
50180
50334
|
var CODEX_END = "<!-- END Open Artifacts skill -->";
|
|
50335
|
+
var CODEX_SKILLS_MIN_VERSION = "0.76.0";
|
|
50181
50336
|
var MAX_SKILL_BYTES = 256 * 1024;
|
|
50337
|
+
var codexSkillFile = (deps2, folder) => join22(codexHome2(deps2.home, env(deps2)), "skills", folder, "SKILL.md");
|
|
50338
|
+
var codexHasSkills = (version2) => version2 !== void 0 && (compareVersions(version2, CODEX_SKILLS_MIN_VERSION) ?? -1) >= 0;
|
|
50339
|
+
var blankLine = (l) => l?.replace(/\r$/, "") === "";
|
|
50340
|
+
var withoutCodexBlock = (text3) => {
|
|
50341
|
+
let lines = text3.split("\n");
|
|
50342
|
+
let removed = false;
|
|
50343
|
+
for (; ; ) {
|
|
50344
|
+
const start = lineIndex(lines, CODEX_BEGIN);
|
|
50345
|
+
if (start === -1) break;
|
|
50346
|
+
const end = lineIndex(lines, CODEX_END, start + 1);
|
|
50347
|
+
if (end === -1) break;
|
|
50348
|
+
const before = lines.slice(0, start);
|
|
50349
|
+
let after = lines.slice(end + 1);
|
|
50350
|
+
if (before.length > 0 && blankLine(before[before.length - 1]) && (after.length === 0 || blankLine(after[0])))
|
|
50351
|
+
before.pop();
|
|
50352
|
+
if (after.length === 0 && before.length > 0) after = [""];
|
|
50353
|
+
lines = [...before, ...after];
|
|
50354
|
+
removed = true;
|
|
50355
|
+
}
|
|
50356
|
+
return removed ? lines.join("\n") : void 0;
|
|
50357
|
+
};
|
|
50358
|
+
var dropCodexBlock = (agentsPath, notes) => {
|
|
50359
|
+
if (brokenLink(agentsPath) || !existsSync7(agentsPath)) return false;
|
|
50360
|
+
const text3 = readFileSync18(agentsPath, "utf8");
|
|
50361
|
+
if (codexBroken(text3)) {
|
|
50362
|
+
notes.push(
|
|
50363
|
+
`Left ${agentsPath} alone: its Open Artifacts block has no END marker. Fix or remove the block, then rerun the install.`
|
|
50364
|
+
);
|
|
50365
|
+
return false;
|
|
50366
|
+
}
|
|
50367
|
+
const next = withoutCodexBlock(text3);
|
|
50368
|
+
if (next === void 0) return false;
|
|
50369
|
+
writeAtomic(targetOf(agentsPath), next);
|
|
50370
|
+
return true;
|
|
50371
|
+
};
|
|
50182
50372
|
var env = (deps2) => deps2.env ?? {};
|
|
50183
50373
|
var skillDir = (deps2, h) => {
|
|
50184
50374
|
const e = env(deps2);
|
|
@@ -50324,8 +50514,132 @@ var withCodexBlock = (existing, text3) => {
|
|
|
50324
50514
|
};
|
|
50325
50515
|
var codexBroken = (text3) => {
|
|
50326
50516
|
const lines = text3.split("\n");
|
|
50327
|
-
|
|
50328
|
-
|
|
50517
|
+
for (let i = 0; i < lines.length; i++) {
|
|
50518
|
+
const t = lines[i]?.replace(/\r$/, "") ?? "";
|
|
50519
|
+
const bare = t.trim();
|
|
50520
|
+
if (t !== CODEX_BEGIN && bare.startsWith("<!-- BEGIN Open Artifacts skill"))
|
|
50521
|
+
return true;
|
|
50522
|
+
if (t !== CODEX_END && bare === CODEX_END) return true;
|
|
50523
|
+
if (t === CODEX_BEGIN) {
|
|
50524
|
+
const end = lineIndex(lines, CODEX_END, i + 1);
|
|
50525
|
+
if (end === -1) return true;
|
|
50526
|
+
i = end;
|
|
50527
|
+
}
|
|
50528
|
+
}
|
|
50529
|
+
return false;
|
|
50530
|
+
};
|
|
50531
|
+
var realOrResolved = (p) => {
|
|
50532
|
+
try {
|
|
50533
|
+
return realpathSync10(p);
|
|
50534
|
+
} catch {
|
|
50535
|
+
return resolve6(p);
|
|
50536
|
+
}
|
|
50537
|
+
};
|
|
50538
|
+
var placesOf = (p) => {
|
|
50539
|
+
const out = [realOrResolved(p)];
|
|
50540
|
+
try {
|
|
50541
|
+
if (lstatSync11(p).isSymbolicLink())
|
|
50542
|
+
out.push(realOrResolved(resolve6(dirname10(p), readlinkSync2(p))));
|
|
50543
|
+
} catch {
|
|
50544
|
+
}
|
|
50545
|
+
return out;
|
|
50546
|
+
};
|
|
50547
|
+
var codexSkillsShared = (deps2) => {
|
|
50548
|
+
const mine = placesOf(dirname10(dirname10(codexSkillFile(deps2, "x"))));
|
|
50549
|
+
const theirs = placesOf(skillDir(deps2, "pi"));
|
|
50550
|
+
return mine.some((m) => theirs.includes(m));
|
|
50551
|
+
};
|
|
50552
|
+
var ourSkillFile = (path, folder) => {
|
|
50553
|
+
try {
|
|
50554
|
+
return isOurs(readFileSync18(path, "utf8"), folder);
|
|
50555
|
+
} catch {
|
|
50556
|
+
return false;
|
|
50557
|
+
}
|
|
50558
|
+
};
|
|
50559
|
+
var installCodex = (deps2, folder, text3, written, notes) => {
|
|
50560
|
+
const agentsPath = skillDir(deps2, "codex");
|
|
50561
|
+
const filePath = codexSkillFile(deps2, folder);
|
|
50562
|
+
let before;
|
|
50563
|
+
try {
|
|
50564
|
+
before = existsSync7(targetOf(agentsPath)) ? readFileSync18(targetOf(agentsPath), "utf8") : "";
|
|
50565
|
+
} catch (e) {
|
|
50566
|
+
notes.push(
|
|
50567
|
+
`Left ${agentsPath} alone: could not read it (${e instanceof Error ? e.message : String(e)}).`
|
|
50568
|
+
);
|
|
50569
|
+
return;
|
|
50570
|
+
}
|
|
50571
|
+
const ourFile = ourSkillFile(filePath, folder);
|
|
50572
|
+
let asFile = codexHasSkills(deps2.codexVersion) || deps2.codexVersion === void 0 && ourFile;
|
|
50573
|
+
const shared = codexSkillsShared(deps2);
|
|
50574
|
+
if (asFile && shared) {
|
|
50575
|
+
asFile = false;
|
|
50576
|
+
notes.push(
|
|
50577
|
+
`Kept the Codex skill in ${agentsPath}: Codex shares its skills folder with pi and omp, and writing there would overwrite their skill.`
|
|
50578
|
+
);
|
|
50579
|
+
}
|
|
50580
|
+
if (codexBroken(before)) {
|
|
50581
|
+
notes.push(
|
|
50582
|
+
`Left ${agentsPath} alone: its Open Artifacts block has no END marker. Fix or remove the block, then rerun the install.`
|
|
50583
|
+
);
|
|
50584
|
+
return;
|
|
50585
|
+
}
|
|
50586
|
+
if (asFile) {
|
|
50587
|
+
if (brokenLink(filePath)) {
|
|
50588
|
+
notes.push(`Left ${filePath} alone: it is a broken symlink.`);
|
|
50589
|
+
return;
|
|
50590
|
+
}
|
|
50591
|
+
const writing2 = targetOf(filePath);
|
|
50592
|
+
try {
|
|
50593
|
+
if (existsSync7(writing2) && !ourSkillFile(writing2, folder)) {
|
|
50594
|
+
notes.push(
|
|
50595
|
+
`Left ${writing2} alone: it has no Open Artifacts marker, so it is not ours to replace.`
|
|
50596
|
+
);
|
|
50597
|
+
return;
|
|
50598
|
+
}
|
|
50599
|
+
writeAtomic(writing2, withMarker(text3));
|
|
50600
|
+
} catch (e) {
|
|
50601
|
+
notes.push(
|
|
50602
|
+
`Could not write ${writing2}: ${e instanceof Error ? e.message : String(e)}`
|
|
50603
|
+
);
|
|
50604
|
+
return;
|
|
50605
|
+
}
|
|
50606
|
+
written.push(filePath);
|
|
50607
|
+
try {
|
|
50608
|
+
dropCodexBlock(agentsPath, notes);
|
|
50609
|
+
} catch (e) {
|
|
50610
|
+
notes.push(
|
|
50611
|
+
`Could not update ${agentsPath}: ${e instanceof Error ? e.message : String(e)}`
|
|
50612
|
+
);
|
|
50613
|
+
}
|
|
50614
|
+
return;
|
|
50615
|
+
}
|
|
50616
|
+
if (brokenLink(agentsPath)) {
|
|
50617
|
+
notes.push(`Left ${agentsPath} alone: it is a broken symlink.`);
|
|
50618
|
+
return;
|
|
50619
|
+
}
|
|
50620
|
+
const writing = targetOf(agentsPath);
|
|
50621
|
+
try {
|
|
50622
|
+
writeAtomic(writing, withCodexBlock(before, text3));
|
|
50623
|
+
} catch (e) {
|
|
50624
|
+
notes.push(
|
|
50625
|
+
`Could not write ${writing}: ${e instanceof Error ? e.message : String(e)}`
|
|
50626
|
+
);
|
|
50627
|
+
return;
|
|
50628
|
+
}
|
|
50629
|
+
written.push(agentsPath);
|
|
50630
|
+
if (ourFile && !shared) {
|
|
50631
|
+
try {
|
|
50632
|
+
rmSync7(targetOf(filePath), { force: true });
|
|
50633
|
+
try {
|
|
50634
|
+
rmdirSync2(dirname10(filePath));
|
|
50635
|
+
} catch {
|
|
50636
|
+
}
|
|
50637
|
+
} catch (e) {
|
|
50638
|
+
notes.push(
|
|
50639
|
+
`Could not remove ${filePath}: ${e instanceof Error ? e.message : String(e)}`
|
|
50640
|
+
);
|
|
50641
|
+
}
|
|
50642
|
+
}
|
|
50329
50643
|
};
|
|
50330
50644
|
async function installSkill(deps2, origin, harnesses) {
|
|
50331
50645
|
const written = [];
|
|
@@ -50352,32 +50666,25 @@ async function installSkill(deps2, origin, harnesses) {
|
|
|
50352
50666
|
notes,
|
|
50353
50667
|
failedUrl: url2
|
|
50354
50668
|
};
|
|
50669
|
+
if (h === "codex") {
|
|
50670
|
+
installCodex(deps2, folder, text3, written, notes);
|
|
50671
|
+
continue;
|
|
50672
|
+
}
|
|
50355
50673
|
const base3 = skillDir(deps2, h);
|
|
50356
|
-
const path =
|
|
50674
|
+
const path = join22(base3, folder, "SKILL.md");
|
|
50357
50675
|
if (brokenLink(path)) {
|
|
50358
50676
|
notes.push(`Left ${path} alone: it is a broken symlink.`);
|
|
50359
50677
|
continue;
|
|
50360
50678
|
}
|
|
50361
50679
|
const writing = targetOf(path);
|
|
50362
50680
|
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));
|
|
50681
|
+
if (existsSync7(writing) && !ourSkillFile(writing, folder)) {
|
|
50682
|
+
notes.push(
|
|
50683
|
+
`Left ${writing} alone: it has no Open Artifacts marker, so it is not ours to replace.`
|
|
50684
|
+
);
|
|
50685
|
+
continue;
|
|
50380
50686
|
}
|
|
50687
|
+
writeAtomic(writing, withMarker(text3));
|
|
50381
50688
|
written.push(path);
|
|
50382
50689
|
} catch (e) {
|
|
50383
50690
|
notes.push(
|
|
@@ -50402,41 +50709,14 @@ var uninstallSkill = (deps2, harnesses = [
|
|
|
50402
50709
|
const fail2 = (path, e) => notes.push(
|
|
50403
50710
|
`Left ${path} alone: ${e instanceof Error ? e.message : String(e)}`
|
|
50404
50711
|
);
|
|
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
|
-
}
|
|
50712
|
+
const scan2 = (base3) => {
|
|
50433
50713
|
let entries;
|
|
50434
50714
|
try {
|
|
50435
|
-
if (!existsSync7(base3))
|
|
50715
|
+
if (!existsSync7(base3)) return;
|
|
50436
50716
|
entries = readdirSync6(base3);
|
|
50437
50717
|
} catch (e) {
|
|
50438
50718
|
fail2(base3, e);
|
|
50439
|
-
|
|
50719
|
+
return;
|
|
50440
50720
|
}
|
|
50441
50721
|
for (const entry of entries) {
|
|
50442
50722
|
const dir = join22(base3, entry);
|
|
@@ -50465,9 +50745,47 @@ var uninstallSkill = (deps2, harnesses = [
|
|
|
50465
50745
|
fail2(file2, e);
|
|
50466
50746
|
}
|
|
50467
50747
|
}
|
|
50748
|
+
};
|
|
50749
|
+
for (const h of harnesses) {
|
|
50750
|
+
const base3 = skillDir(deps2, h);
|
|
50751
|
+
if (seen2.has(base3)) continue;
|
|
50752
|
+
seen2.add(base3);
|
|
50753
|
+
if (harnessSkills[h].agentsMd) {
|
|
50754
|
+
try {
|
|
50755
|
+
if (dropCodexBlock(base3, notes)) written.push(base3);
|
|
50756
|
+
} catch (e) {
|
|
50757
|
+
fail2(base3, e);
|
|
50758
|
+
}
|
|
50759
|
+
scan2(join22(dirname10(base3), "skills"));
|
|
50760
|
+
continue;
|
|
50761
|
+
}
|
|
50762
|
+
scan2(base3);
|
|
50468
50763
|
}
|
|
50469
50764
|
return { written, notes };
|
|
50470
50765
|
};
|
|
50766
|
+
var codexSkillState = (deps2) => {
|
|
50767
|
+
const out = {
|
|
50768
|
+
shared: codexSkillsShared(deps2)
|
|
50769
|
+
};
|
|
50770
|
+
try {
|
|
50771
|
+
const dir = join22(dirname10(skillDir(deps2, "codex")), "skills");
|
|
50772
|
+
for (const entry of readdirSync6(dir)) {
|
|
50773
|
+
const file2 = join22(dir, entry, "SKILL.md");
|
|
50774
|
+
if (ourSkillFile(file2, entry)) {
|
|
50775
|
+
out.file = file2;
|
|
50776
|
+
break;
|
|
50777
|
+
}
|
|
50778
|
+
}
|
|
50779
|
+
} catch {
|
|
50780
|
+
}
|
|
50781
|
+
try {
|
|
50782
|
+
const agents = skillDir(deps2, "codex");
|
|
50783
|
+
if (withoutCodexBlock(readFileSync18(agents, "utf8")) !== void 0)
|
|
50784
|
+
out.block = agents;
|
|
50785
|
+
} catch {
|
|
50786
|
+
}
|
|
50787
|
+
return out;
|
|
50788
|
+
};
|
|
50471
50789
|
|
|
50472
50790
|
// src/steps/openclaw.ts
|
|
50473
50791
|
var OPENCLAW_PLUGIN_ID = "oa-bus";
|
|
@@ -50484,13 +50802,13 @@ var placeholder = (v) => {
|
|
|
50484
50802
|
};
|
|
50485
50803
|
function openclawHome(home2, env2) {
|
|
50486
50804
|
const explicit = placeholder(env2.OPENCLAW_HOME);
|
|
50487
|
-
return
|
|
50805
|
+
return resolve7(explicit ? explicit.replace(/^~(?=$|[\\/])/, home2) : home2);
|
|
50488
50806
|
}
|
|
50489
50807
|
function openclawStateDir(home2, env2) {
|
|
50490
50808
|
const h = openclawHome(home2, env2);
|
|
50491
50809
|
const override = env2.OPENCLAW_STATE_DIR?.trim();
|
|
50492
50810
|
if (override)
|
|
50493
|
-
return
|
|
50811
|
+
return resolve7(
|
|
50494
50812
|
override.startsWith("~") ? override.replace(/^~(?=$|[\\/])/, h) : override
|
|
50495
50813
|
);
|
|
50496
50814
|
const next = join23(h, ".openclaw");
|
|
@@ -50581,7 +50899,7 @@ var realOrSelf = (p) => {
|
|
|
50581
50899
|
try {
|
|
50582
50900
|
return realpathSync11(p);
|
|
50583
50901
|
} catch {
|
|
50584
|
-
return
|
|
50902
|
+
return resolve7(p);
|
|
50585
50903
|
}
|
|
50586
50904
|
};
|
|
50587
50905
|
var NEED_TOOLS = ["oabus_self", "oabus_send_message", "oabus_fetch"];
|
|
@@ -50749,7 +51067,7 @@ var piAgentDir = (home2, env2) => {
|
|
|
50749
51067
|
const d = env2.PI_CODING_AGENT_DIR;
|
|
50750
51068
|
if (!d) return join24(home2, ".pi", "agent");
|
|
50751
51069
|
if (d === "~") return home2;
|
|
50752
|
-
return
|
|
51070
|
+
return resolve8(d.startsWith("~/") ? join24(home2, d.slice(2)) : d);
|
|
50753
51071
|
};
|
|
50754
51072
|
function habitsFiles(deps2, h) {
|
|
50755
51073
|
const env2 = deps2.env ?? {};
|
|
@@ -50796,10 +51114,10 @@ function blockState(existing) {
|
|
|
50796
51114
|
var separatorFor = (existing) => {
|
|
50797
51115
|
if (existing === "") return "";
|
|
50798
51116
|
const eol2 = existing.includes("\r\n") ? "\r\n" : "\n";
|
|
50799
|
-
let
|
|
50800
|
-
if (!existing.endsWith("\n"))
|
|
50801
|
-
if (!/\n\r?\n$/.test(existing +
|
|
50802
|
-
return
|
|
51117
|
+
let sep4 = "";
|
|
51118
|
+
if (!existing.endsWith("\n")) sep4 += eol2;
|
|
51119
|
+
if (!/\n\r?\n$/.test(existing + sep4)) sep4 += eol2;
|
|
51120
|
+
return sep4;
|
|
50803
51121
|
};
|
|
50804
51122
|
function withHabits(existing, block, added) {
|
|
50805
51123
|
const lines = existing.split("\n");
|
|
@@ -50907,15 +51225,15 @@ function writeHabits(deps2, harnesses, opts = {}) {
|
|
|
50907
51225
|
}
|
|
50908
51226
|
const real3 = targetOf(path);
|
|
50909
51227
|
try {
|
|
50910
|
-
const
|
|
50911
|
-
const before =
|
|
51228
|
+
const exists2 = existsSync9(real3);
|
|
51229
|
+
const before = exists2 ? readFileSync20(real3, "utf8") : "";
|
|
50912
51230
|
const fresh = blockState(before).state === "absent";
|
|
50913
51231
|
const after = withHabits(before, habitsBlock());
|
|
50914
51232
|
if (after !== before) writeAtomic(real3, after);
|
|
50915
51233
|
if (fresh)
|
|
50916
51234
|
files_[path] = {
|
|
50917
51235
|
added: separatorFor(before),
|
|
50918
|
-
created: !
|
|
51236
|
+
created: !exists2 && !link2
|
|
50919
51237
|
};
|
|
50920
51238
|
files2.push(path);
|
|
50921
51239
|
} catch (e) {
|
|
@@ -51185,7 +51503,7 @@ var habitsQuestionLines = (q) => [
|
|
|
51185
51503
|
|
|
51186
51504
|
// src/steps/opencode-proof.ts
|
|
51187
51505
|
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
|
|
51506
|
+
import { dirname as dirname11, isAbsolute as isAbsolute12, join as join25, resolve as resolve9 } from "node:path";
|
|
51189
51507
|
init_src();
|
|
51190
51508
|
var OPENCODE_ENTRY_FILE = "opencode-mcp-entry.json";
|
|
51191
51509
|
var isRecord5 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
@@ -51228,7 +51546,7 @@ var REMOTE_ONLY = /* @__PURE__ */ new Set(["type", "url", "headers", "oauth"]);
|
|
|
51228
51546
|
function resolveTokenFile(x, configFile, home2) {
|
|
51229
51547
|
if (x === "~") return home2;
|
|
51230
51548
|
if (x.startsWith("~/")) return join25(home2, x.slice(2));
|
|
51231
|
-
return isAbsolute12(x) ? x :
|
|
51549
|
+
return isAbsolute12(x) ? x : resolve9(dirname11(configFile), x);
|
|
51232
51550
|
}
|
|
51233
51551
|
var proxyEntry = (io, origin, tokenFile, entry) => {
|
|
51234
51552
|
const kept = Object.fromEntries(
|
|
@@ -51497,7 +51815,7 @@ var readAssets = () => ({
|
|
|
51497
51815
|
});
|
|
51498
51816
|
var movedHome = (deps2) => {
|
|
51499
51817
|
if (deps2.busHome === void 0) return void 0;
|
|
51500
|
-
const ob =
|
|
51818
|
+
const ob = resolve10(deps2.busHome);
|
|
51501
51819
|
return ob === join26(deps2.home, ".oa-bus") ? void 0 : ob;
|
|
51502
51820
|
};
|
|
51503
51821
|
var homeLine = (ob) => `process.env.OA_BUS_HOME ||= ${JSON.stringify(ob)};`;
|
|
@@ -51543,7 +51861,7 @@ function agentDirEnv(home2, env2) {
|
|
|
51543
51861
|
const dir = env2.PI_CODING_AGENT_DIR;
|
|
51544
51862
|
if (!dir) return void 0;
|
|
51545
51863
|
if (dir === "~") return home2;
|
|
51546
|
-
return
|
|
51864
|
+
return resolve10(dir.startsWith("~/") ? join26(home2, dir.slice(2)) : dir);
|
|
51547
51865
|
}
|
|
51548
51866
|
var ompRoot = (home2, env2) => join26(home2, env2.PI_CONFIG_DIR || ".omp");
|
|
51549
51867
|
function ompProfile(env2) {
|
|
@@ -51597,7 +51915,7 @@ function target(path) {
|
|
|
51597
51915
|
);
|
|
51598
51916
|
return p;
|
|
51599
51917
|
}
|
|
51600
|
-
p =
|
|
51918
|
+
p = resolve10(dirname12(p), readlinkSync3(p));
|
|
51601
51919
|
}
|
|
51602
51920
|
throw new Error(`${path}: too many symlinks; left it untouched`);
|
|
51603
51921
|
}
|
|
@@ -52246,9 +52564,355 @@ function codexProxyProblem(deps2) {
|
|
|
52246
52564
|
}
|
|
52247
52565
|
}
|
|
52248
52566
|
|
|
52567
|
+
// src/steps/output-style.ts
|
|
52568
|
+
import {
|
|
52569
|
+
existsSync as existsSync13,
|
|
52570
|
+
lstatSync as lstatSync15,
|
|
52571
|
+
readdirSync as readdirSync8,
|
|
52572
|
+
readFileSync as readFileSync24,
|
|
52573
|
+
rmdirSync as rmdirSync3,
|
|
52574
|
+
rmSync as rmSync13
|
|
52575
|
+
} from "node:fs";
|
|
52576
|
+
import { dirname as dirname13, join as join27 } from "node:path";
|
|
52577
|
+
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
52578
|
+
var OUTPUT_STYLE_FILE = "artifacts-teammate.md";
|
|
52579
|
+
var OUTPUT_STYLE_MARKER = "<!-- managed by the Open Artifacts bus installer: edits are replaced on reinstall. -->";
|
|
52580
|
+
var OUTPUT_STYLE_NAME = "Artifacts Teammate";
|
|
52581
|
+
var claudeSettingsFile = (w) => join27(w.env?.CLAUDE_CONFIG_DIR ?? join27(w.home, ".claude"), "settings.json");
|
|
52582
|
+
var readRecord3 = (busHome2) => {
|
|
52583
|
+
if (!busHome2) return void 0;
|
|
52584
|
+
const r = readInstallFile(join27(busHome2, "install.json")).outputStyle;
|
|
52585
|
+
return typeof r === "object" && r !== null ? r : void 0;
|
|
52586
|
+
};
|
|
52587
|
+
var writeRecord3 = (busHome2, r) => updateInstallFile(join27(busHome2, "install.json"), { outputStyle: r });
|
|
52588
|
+
var styleDir = (w) => join27(w.env?.CLAUDE_CONFIG_DIR ?? join27(w.home, ".claude"), "output-styles");
|
|
52589
|
+
var outputStyleFile = (w) => join27(styleDir(w), OUTPUT_STYLE_FILE);
|
|
52590
|
+
var outputStyleSource = () => {
|
|
52591
|
+
for (const rel of [
|
|
52592
|
+
"../assets/output-styles/artifacts-teammate.md",
|
|
52593
|
+
"../../output-style/artifacts-teammate.md"
|
|
52594
|
+
]) {
|
|
52595
|
+
const path = fileURLToPath6(new URL(rel, import.meta.url));
|
|
52596
|
+
if (existsSync13(path)) return readFileSync24(path, "utf8");
|
|
52597
|
+
}
|
|
52598
|
+
throw new Error("the Artifacts Teammate output style is missing");
|
|
52599
|
+
};
|
|
52600
|
+
var withMarker2 = (text3) => {
|
|
52601
|
+
const end = text3.startsWith("---\n") ? text3.indexOf("\n---\n", 3) : -1;
|
|
52602
|
+
if (end === -1) throw new Error("the output style has no frontmatter");
|
|
52603
|
+
const at = end + "\n---\n".length;
|
|
52604
|
+
return `${text3.slice(0, at)}${OUTPUT_STYLE_MARKER}
|
|
52605
|
+
${text3.slice(at)}`;
|
|
52606
|
+
};
|
|
52607
|
+
var isOurs2 = (text3) => {
|
|
52608
|
+
const m = /^---\n[\s\S]*?\n---\n/.exec(text3.replace(/\r\n/g, "\n"));
|
|
52609
|
+
return m !== null && text3.replace(/\r\n/g, "\n").slice(m[0].length).split("\n", 1)[0] === OUTPUT_STYLE_MARKER;
|
|
52610
|
+
};
|
|
52611
|
+
var isLink2 = (path) => {
|
|
52612
|
+
try {
|
|
52613
|
+
return lstatSync15(path).isSymbolicLink();
|
|
52614
|
+
} catch {
|
|
52615
|
+
return false;
|
|
52616
|
+
}
|
|
52617
|
+
};
|
|
52618
|
+
var exists = (path) => {
|
|
52619
|
+
try {
|
|
52620
|
+
lstatSync15(path);
|
|
52621
|
+
return true;
|
|
52622
|
+
} catch {
|
|
52623
|
+
return false;
|
|
52624
|
+
}
|
|
52625
|
+
};
|
|
52626
|
+
var readSettings = (path) => {
|
|
52627
|
+
if (isLink2(path)) return { ok: false, why: "it is a symlink" };
|
|
52628
|
+
if (!exists(path)) return { ok: true, text: void 0, style: void 0 };
|
|
52629
|
+
try {
|
|
52630
|
+
const text3 = readFileSync24(path, "utf8");
|
|
52631
|
+
parseJsonc(text3, path);
|
|
52632
|
+
return { ok: true, text: text3, style: jsoncValue(text3, ["outputStyle"]) };
|
|
52633
|
+
} catch {
|
|
52634
|
+
return { ok: false, why: "it is not valid JSON" };
|
|
52635
|
+
}
|
|
52636
|
+
};
|
|
52637
|
+
function turnOn(deps2, out) {
|
|
52638
|
+
const path = claudeSettingsFile(deps2);
|
|
52639
|
+
const busHome2 = deps2.busHome;
|
|
52640
|
+
if (!busHome2) return;
|
|
52641
|
+
const cur = readSettings(path);
|
|
52642
|
+
if (!cur.ok) {
|
|
52643
|
+
out.notes.push(
|
|
52644
|
+
`Left ${path} alone: ${cur.why}, so the output style was not turned on. Pick it with /output-style.`
|
|
52645
|
+
);
|
|
52646
|
+
return;
|
|
52647
|
+
}
|
|
52648
|
+
const unset = cur.style === void 0 || cur.style === null || typeof cur.style === "string" && cur.style.trim() === "";
|
|
52649
|
+
if (!unset) {
|
|
52650
|
+
if (cur.style !== OUTPUT_STYLE_NAME) {
|
|
52651
|
+
out.settings = "kept";
|
|
52652
|
+
if (typeof cur.style === "string" && cur.style.toLowerCase() !== "default")
|
|
52653
|
+
out.kept = cur.style;
|
|
52654
|
+
}
|
|
52655
|
+
return;
|
|
52656
|
+
}
|
|
52657
|
+
if (readRecord3(busHome2)?.set) return;
|
|
52658
|
+
try {
|
|
52659
|
+
writeRecord3(busHome2, {
|
|
52660
|
+
set: true,
|
|
52661
|
+
value: OUTPUT_STYLE_NAME,
|
|
52662
|
+
before: cur.style === void 0 ? { state: "absent" } : cur.style === null ? { state: "null" } : { state: "empty", value: String(cur.style) },
|
|
52663
|
+
createdFile: cur.text === void 0,
|
|
52664
|
+
file: path
|
|
52665
|
+
});
|
|
52666
|
+
const next = cur.text === void 0 || cur.text.trim() === "" ? createdText() : setJsoncValue(cur.text, ["outputStyle"], OUTPUT_STYLE_NAME);
|
|
52667
|
+
writeAtomic(path, next);
|
|
52668
|
+
out.settings = "set";
|
|
52669
|
+
} catch (e) {
|
|
52670
|
+
try {
|
|
52671
|
+
writeRecord3(busHome2, void 0);
|
|
52672
|
+
} catch {
|
|
52673
|
+
}
|
|
52674
|
+
out.notes.push(
|
|
52675
|
+
`Left ${path} alone: could not edit it (${e instanceof Error ? e.message : String(e)}). Pick the style with /output-style.`
|
|
52676
|
+
);
|
|
52677
|
+
}
|
|
52678
|
+
}
|
|
52679
|
+
function installOutputStyle(deps2, harnesses) {
|
|
52680
|
+
const out = { written: [], notes: [], first: false };
|
|
52681
|
+
if (!harnesses.includes("claude")) return out;
|
|
52682
|
+
const dir = styleDir(deps2);
|
|
52683
|
+
const path = outputStyleFile(deps2);
|
|
52684
|
+
if (isLink2(dir) || isLink2(path)) {
|
|
52685
|
+
out.notes.push(
|
|
52686
|
+
`Left ${isLink2(dir) ? dir : path} alone: it is a symlink, so the output style was not written there.`
|
|
52687
|
+
);
|
|
52688
|
+
return out;
|
|
52689
|
+
}
|
|
52690
|
+
try {
|
|
52691
|
+
const there = exists(path);
|
|
52692
|
+
if (there && !isOurs2(readFileSync24(path, "utf8"))) {
|
|
52693
|
+
out.notes.push(
|
|
52694
|
+
`Left ${path} alone: it has no Open Artifacts marker, so it is not ours to replace.`
|
|
52695
|
+
);
|
|
52696
|
+
return out;
|
|
52697
|
+
}
|
|
52698
|
+
writeAtomic(path, withMarker2(deps2.text));
|
|
52699
|
+
out.written.push(path);
|
|
52700
|
+
out.first = !there;
|
|
52701
|
+
} catch (e) {
|
|
52702
|
+
out.notes.push(
|
|
52703
|
+
`Could not write ${path}: ${e instanceof Error ? e.message : String(e)}`
|
|
52704
|
+
);
|
|
52705
|
+
return out;
|
|
52706
|
+
}
|
|
52707
|
+
turnOn(deps2, out);
|
|
52708
|
+
return out;
|
|
52709
|
+
}
|
|
52710
|
+
var createdText = () => `${JSON.stringify({ outputStyle: OUTPUT_STYLE_NAME }, null, 2)}
|
|
52711
|
+
`;
|
|
52712
|
+
function turnOff(deps2, out) {
|
|
52713
|
+
const busHome2 = deps2.busHome;
|
|
52714
|
+
const rec = readRecord3(busHome2);
|
|
52715
|
+
const path = claudeSettingsFile(deps2);
|
|
52716
|
+
try {
|
|
52717
|
+
const cur = readSettings(path);
|
|
52718
|
+
if (cur.ok && cur.text !== void 0 && cur.style === OUTPUT_STYLE_NAME) {
|
|
52719
|
+
const was = rec?.set ? rec.before : void 0;
|
|
52720
|
+
const next = was?.state === "null" ? setJsoncValue(cur.text, ["outputStyle"], null) : was?.state === "empty" ? setJsoncValue(cur.text, ["outputStyle"], was.value) : removeJsoncValue(cur.text, ["outputStyle"]);
|
|
52721
|
+
if (rec?.set && rec.createdFile && cur.text === createdText())
|
|
52722
|
+
rmSync13(path);
|
|
52723
|
+
else writeAtomic(path, next);
|
|
52724
|
+
}
|
|
52725
|
+
if (busHome2 && rec) writeRecord3(busHome2, void 0);
|
|
52726
|
+
} catch (e) {
|
|
52727
|
+
out.notes.push(
|
|
52728
|
+
`Left ${path} alone: ${e instanceof Error ? e.message : String(e)}`
|
|
52729
|
+
);
|
|
52730
|
+
}
|
|
52731
|
+
}
|
|
52732
|
+
function uninstallOutputStyle(deps2) {
|
|
52733
|
+
const out = { written: [], notes: [] };
|
|
52734
|
+
const dir = styleDir(deps2);
|
|
52735
|
+
const path = outputStyleFile(deps2);
|
|
52736
|
+
let gone = false;
|
|
52737
|
+
try {
|
|
52738
|
+
if (isLink2(dir) || isLink2(path)) {
|
|
52739
|
+
out.notes.push(
|
|
52740
|
+
`Left ${isLink2(dir) ? dir : path} alone: it is a symlink, so the output style was not removed there.`
|
|
52741
|
+
);
|
|
52742
|
+
} else if (!exists(path)) {
|
|
52743
|
+
gone = true;
|
|
52744
|
+
} else if (!isOurs2(readFileSync24(path, "utf8"))) {
|
|
52745
|
+
out.notes.push(
|
|
52746
|
+
`Left ${path} alone: it has no Open Artifacts marker, so it is not ours to replace.`
|
|
52747
|
+
);
|
|
52748
|
+
} else {
|
|
52749
|
+
rmSync13(path);
|
|
52750
|
+
out.written.push(path);
|
|
52751
|
+
gone = true;
|
|
52752
|
+
if (readdirSync8(dir).length === 0) rmdirSync3(dir);
|
|
52753
|
+
}
|
|
52754
|
+
} catch (e) {
|
|
52755
|
+
out.notes.push(
|
|
52756
|
+
`Left ${path} alone: ${e instanceof Error ? e.message : String(e)}`
|
|
52757
|
+
);
|
|
52758
|
+
}
|
|
52759
|
+
if (gone) turnOff(deps2, out);
|
|
52760
|
+
return out;
|
|
52761
|
+
}
|
|
52762
|
+
var outputStyleState = (deps2) => {
|
|
52763
|
+
const path = outputStyleFile(deps2);
|
|
52764
|
+
try {
|
|
52765
|
+
if (isLink2(dirname13(path)) || isLink2(path)) return void 0;
|
|
52766
|
+
if (!isOurs2(readFileSync24(path, "utf8"))) return void 0;
|
|
52767
|
+
const s = readSettings(claudeSettingsFile(deps2));
|
|
52768
|
+
return { path, on: s.ok && s.style === OUTPUT_STYLE_NAME };
|
|
52769
|
+
} catch {
|
|
52770
|
+
return void 0;
|
|
52771
|
+
}
|
|
52772
|
+
};
|
|
52773
|
+
|
|
52774
|
+
// src/steps/path-shim.ts
|
|
52775
|
+
import {
|
|
52776
|
+
accessSync as accessSync2,
|
|
52777
|
+
chmodSync as chmodSync13,
|
|
52778
|
+
constants as constants4,
|
|
52779
|
+
lstatSync as lstatSync16,
|
|
52780
|
+
mkdirSync as mkdirSync12,
|
|
52781
|
+
readFileSync as readFileSync25,
|
|
52782
|
+
readlinkSync as readlinkSync4,
|
|
52783
|
+
renameSync as renameSync13,
|
|
52784
|
+
rmSync as rmSync14,
|
|
52785
|
+
writeFileSync as writeFileSync11
|
|
52786
|
+
} from "node:fs";
|
|
52787
|
+
import { delimiter as delimiter2, dirname as dirname14, join as join28, resolve as resolve11, sep as sep3 } from "node:path";
|
|
52788
|
+
var SHIM_MARKER = "# oa-bus shim: written by oa-bus install";
|
|
52789
|
+
var HOME_PREFIX = "# oa-bus home: ";
|
|
52790
|
+
var NAME2 = "oa-bus";
|
|
52791
|
+
var LOCAL_HINT = 'export PATH="$HOME/.local/bin:$PATH"';
|
|
52792
|
+
var isWindows = (platform) => platform.startsWith("win32");
|
|
52793
|
+
var pathDirs = (p) => (p ?? "").split(delimiter2).filter((d) => d !== "").map((d) => resolve11(d));
|
|
52794
|
+
var candidates2 = (o) => o.platform.startsWith("darwin") ? [join28(o.userHome, ".local", "bin"), join28(o.userHome, "bin")] : [join28(o.userHome, ".local", "bin")];
|
|
52795
|
+
var shQuote2 = (v) => `'${v.replaceAll("'", `'\\''`)}'`;
|
|
52796
|
+
function shimText(o) {
|
|
52797
|
+
const moved = resolve11(o.busHome) !== resolve11(o.userHome, ".oa-bus");
|
|
52798
|
+
return [
|
|
52799
|
+
"#!/bin/sh",
|
|
52800
|
+
SHIM_MARKER,
|
|
52801
|
+
`${HOME_PREFIX}${resolve11(o.busHome)}`,
|
|
52802
|
+
...moved ? [`OA_BUS_HOME=${shQuote2(resolve11(o.busHome))}`, "export OA_BUS_HOME"] : [],
|
|
52803
|
+
`exec ${o.argv.map(shQuote2).join(" ")} "$@"`,
|
|
52804
|
+
""
|
|
52805
|
+
].join("\n");
|
|
52806
|
+
}
|
|
52807
|
+
function ownerOf(file2, busHome2) {
|
|
52808
|
+
let st;
|
|
52809
|
+
try {
|
|
52810
|
+
st = lstatSync16(file2);
|
|
52811
|
+
} catch {
|
|
52812
|
+
return void 0;
|
|
52813
|
+
}
|
|
52814
|
+
if (st.isSymbolicLink()) {
|
|
52815
|
+
try {
|
|
52816
|
+
const to = resolve11(dirname14(file2), readlinkSync4(file2));
|
|
52817
|
+
const home2 = resolve11(busHome2);
|
|
52818
|
+
return to === home2 || to.startsWith(`${home2}/`) ? { ours: true, home: home2 } : { ours: false };
|
|
52819
|
+
} catch {
|
|
52820
|
+
return { ours: false };
|
|
52821
|
+
}
|
|
52822
|
+
}
|
|
52823
|
+
if (!st.isFile() || st.size > 4096) return { ours: false };
|
|
52824
|
+
try {
|
|
52825
|
+
const lines = readFileSync25(file2, "utf8").split("\n");
|
|
52826
|
+
if (lines[1] !== SHIM_MARKER) return { ours: false };
|
|
52827
|
+
const h = lines[2]?.startsWith(HOME_PREFIX) ? lines[2].slice(HOME_PREFIX.length) : void 0;
|
|
52828
|
+
return { ours: true, home: h };
|
|
52829
|
+
} catch {
|
|
52830
|
+
return { ours: false };
|
|
52831
|
+
}
|
|
52832
|
+
}
|
|
52833
|
+
var sameHome = (owner, busHome2) => owner?.ours === true && (owner.home === void 0 || owner.home === resolve11(busHome2));
|
|
52834
|
+
function writeShim(path, text3) {
|
|
52835
|
+
const tmp = `${path}.${process.pid}.tmp`;
|
|
52836
|
+
rmSync14(tmp, { force: true });
|
|
52837
|
+
try {
|
|
52838
|
+
writeFileSync11(tmp, text3, { mode: 493, flag: "wx" });
|
|
52839
|
+
chmodSync13(tmp, 493);
|
|
52840
|
+
renameSync13(tmp, path);
|
|
52841
|
+
} catch (e) {
|
|
52842
|
+
rmSync14(tmp, { force: true });
|
|
52843
|
+
throw e;
|
|
52844
|
+
}
|
|
52845
|
+
}
|
|
52846
|
+
function installShim(o) {
|
|
52847
|
+
if (isWindows(o.platform)) return { kind: "skipped" };
|
|
52848
|
+
const onPath = new Set(pathDirs(o.env.PATH));
|
|
52849
|
+
const list = candidates2(o);
|
|
52850
|
+
const dir = list.find((d) => onPath.has(d)) ?? list[0];
|
|
52851
|
+
const path = join28(dir, NAME2);
|
|
52852
|
+
const owner = ownerOf(path, o.busHome);
|
|
52853
|
+
if (owner && !owner.ours) return { kind: "foreign", path };
|
|
52854
|
+
if (owner?.ours && !sameHome(owner, o.busHome))
|
|
52855
|
+
return { kind: "other-home", path, home: owner.home };
|
|
52856
|
+
mkdirSync12(dir, { recursive: true });
|
|
52857
|
+
const text3 = shimText(o);
|
|
52858
|
+
writeShim(path, text3);
|
|
52859
|
+
for (const d of list) {
|
|
52860
|
+
const other = join28(d, NAME2);
|
|
52861
|
+
if (d !== dir && sameHome(ownerOf(other, o.busHome), o.busHome))
|
|
52862
|
+
writeShim(other, text3);
|
|
52863
|
+
}
|
|
52864
|
+
const on = onPath.has(dir);
|
|
52865
|
+
return {
|
|
52866
|
+
kind: "installed",
|
|
52867
|
+
path,
|
|
52868
|
+
onPath: on,
|
|
52869
|
+
...on ? {} : { hint: LOCAL_HINT }
|
|
52870
|
+
};
|
|
52871
|
+
}
|
|
52872
|
+
function removeShim(o) {
|
|
52873
|
+
if (isWindows(o.platform)) return void 0;
|
|
52874
|
+
let removed;
|
|
52875
|
+
for (const dir of candidates2({ ...o, env: {} })) {
|
|
52876
|
+
const file2 = join28(dir, NAME2);
|
|
52877
|
+
const owner = ownerOf(file2, o.busHome);
|
|
52878
|
+
if (!owner?.ours) continue;
|
|
52879
|
+
if (owner.home !== void 0 && owner.home !== resolve11(o.busHome)) continue;
|
|
52880
|
+
rmSync14(file2, { force: true });
|
|
52881
|
+
removed = file2;
|
|
52882
|
+
}
|
|
52883
|
+
return removed;
|
|
52884
|
+
}
|
|
52885
|
+
var executable2 = (f) => {
|
|
52886
|
+
try {
|
|
52887
|
+
accessSync2(f, constants4.X_OK);
|
|
52888
|
+
return lstatSync16(f).isFile() || lstatSync16(f).isSymbolicLink();
|
|
52889
|
+
} catch {
|
|
52890
|
+
return false;
|
|
52891
|
+
}
|
|
52892
|
+
};
|
|
52893
|
+
function shimState(o) {
|
|
52894
|
+
if (isWindows(o.platform)) return void 0;
|
|
52895
|
+
const dirs = pathDirs(o.env.PATH).filter(
|
|
52896
|
+
(d) => !(d.endsWith(`${sep3}node_modules${sep3}.bin`) && d.split(sep3).includes("_npx"))
|
|
52897
|
+
);
|
|
52898
|
+
for (const dir of dirs) {
|
|
52899
|
+
const file2 = join28(dir, NAME2);
|
|
52900
|
+
if (!executable2(file2)) continue;
|
|
52901
|
+
const owner = ownerOf(file2, o.busHome);
|
|
52902
|
+
return owner?.ours && (owner.home === void 0 || owner.home === resolve11(o.busHome)) ? { kind: "ours", path: file2 } : { kind: "other", path: file2 };
|
|
52903
|
+
}
|
|
52904
|
+
for (const dir of candidates2(o)) {
|
|
52905
|
+
const file2 = join28(dir, NAME2);
|
|
52906
|
+
const owner = ownerOf(file2, o.busHome);
|
|
52907
|
+
if (owner?.ours && (owner.home === void 0 || owner.home === resolve11(o.busHome)))
|
|
52908
|
+
return { kind: "off-path", path: file2, hint: LOCAL_HINT };
|
|
52909
|
+
}
|
|
52910
|
+
return { kind: "missing" };
|
|
52911
|
+
}
|
|
52912
|
+
|
|
52249
52913
|
// src/commands/habits.ts
|
|
52250
52914
|
init_src();
|
|
52251
|
-
import { join as
|
|
52915
|
+
import { join as join29 } from "node:path";
|
|
52252
52916
|
var pluginOn = (p) => `Habits on in the ${p.label} plugin.`;
|
|
52253
52917
|
var pluginOff = (p) => `Habits off in the ${p.label} plugin.`;
|
|
52254
52918
|
var deps = (ctx) => ({
|
|
@@ -52286,7 +52950,7 @@ var show = (ctx) => {
|
|
|
52286
52950
|
);
|
|
52287
52951
|
return 0;
|
|
52288
52952
|
};
|
|
52289
|
-
function
|
|
52953
|
+
function turnOn2(ctx) {
|
|
52290
52954
|
const { targets, plugins: plugins2 } = wired(ctx);
|
|
52291
52955
|
if (targets.length === 0 && plugins2.length === 0) {
|
|
52292
52956
|
sayErr(ctx, [
|
|
@@ -52303,7 +52967,7 @@ function turnOn(ctx) {
|
|
|
52303
52967
|
for (const n of notes) say(ctx, n);
|
|
52304
52968
|
return notes.length > 0 && r.files.length + pl.changed.length === 0 ? 1 : 0;
|
|
52305
52969
|
}
|
|
52306
|
-
function
|
|
52970
|
+
function turnOff2(ctx) {
|
|
52307
52971
|
const r = removeHabits(deps(ctx));
|
|
52308
52972
|
setHabitsOptOut(ctx.home, true, stamp(ctx));
|
|
52309
52973
|
const pluginFiles = r.pluginFiles ?? [];
|
|
@@ -52366,7 +53030,7 @@ async function habitsAfterInstall(ctx, json3) {
|
|
|
52366
53030
|
})),
|
|
52367
53031
|
// A plugin has no block to compare: its marker is there ("current") or not.
|
|
52368
53032
|
...plugins2.map((p) => ({
|
|
52369
|
-
path:
|
|
53033
|
+
path: join29(p.dir(ctx.userHome, ctx.env), p.marker),
|
|
52370
53034
|
label: `the ${p.label} plugin`,
|
|
52371
53035
|
s: {
|
|
52372
53036
|
state: pluginHabitsState(deps(ctx), p) === "on" ? "current" : "absent"
|
|
@@ -52409,7 +53073,7 @@ async function habitsAfterInstall(ctx, json3) {
|
|
|
52409
53073
|
const pl = setPluginHabits(
|
|
52410
53074
|
deps(ctx),
|
|
52411
53075
|
plugins2.filter(
|
|
52412
|
-
(p) => asked.includes(
|
|
53076
|
+
(p) => asked.includes(join29(p.dir(ctx.userHome, ctx.env), p.marker))
|
|
52413
53077
|
),
|
|
52414
53078
|
true
|
|
52415
53079
|
);
|
|
@@ -52451,7 +53115,7 @@ async function habitsAfterInstall(ctx, json3) {
|
|
|
52451
53115
|
}
|
|
52452
53116
|
function habitsCommand(mode, ctx) {
|
|
52453
53117
|
say(ctx, ctx.copy.header(ctx.version), "");
|
|
52454
|
-
return mode === "show" ? show(ctx) : mode === "yes" ?
|
|
53118
|
+
return mode === "show" ? show(ctx) : mode === "yes" ? turnOn2(ctx) : turnOff2(ctx);
|
|
52455
53119
|
}
|
|
52456
53120
|
function habitsLine(ctx) {
|
|
52457
53121
|
const { targets, plugins: plugins2 } = wired(ctx);
|
|
@@ -52474,16 +53138,16 @@ function habitsLine(ctx) {
|
|
|
52474
53138
|
init_src();
|
|
52475
53139
|
import { randomBytes as randomBytes7 } from "node:crypto";
|
|
52476
53140
|
import {
|
|
52477
|
-
chmodSync as
|
|
53141
|
+
chmodSync as chmodSync14,
|
|
52478
53142
|
closeSync as closeSync7,
|
|
52479
|
-
mkdirSync as
|
|
53143
|
+
mkdirSync as mkdirSync13,
|
|
52480
53144
|
openSync as openSync7,
|
|
52481
|
-
renameSync as
|
|
52482
|
-
rmSync as
|
|
53145
|
+
renameSync as renameSync14,
|
|
53146
|
+
rmSync as rmSync15,
|
|
52483
53147
|
unlinkSync as unlinkSync3,
|
|
52484
53148
|
writeSync as writeSync3
|
|
52485
53149
|
} from "node:fs";
|
|
52486
|
-
import { join as
|
|
53150
|
+
import { join as join30 } from "node:path";
|
|
52487
53151
|
|
|
52488
53152
|
// src/machine-label.ts
|
|
52489
53153
|
import { hostname as osHostname } from "node:os";
|
|
@@ -52529,9 +53193,9 @@ function checkVerificationUri(uri, hub) {
|
|
|
52529
53193
|
return uri;
|
|
52530
53194
|
}
|
|
52531
53195
|
function writeMachineFile(home2, body) {
|
|
52532
|
-
|
|
52533
|
-
|
|
52534
|
-
const tmp =
|
|
53196
|
+
mkdirSync13(home2, { recursive: true, mode: 448 });
|
|
53197
|
+
chmodSync14(home2, 448);
|
|
53198
|
+
const tmp = join30(home2, `.machine.json.${randomBytes7(8).toString("hex")}.tmp`);
|
|
52535
53199
|
const fd = openSync7(tmp, "wx", 384);
|
|
52536
53200
|
try {
|
|
52537
53201
|
writeSync3(fd, body);
|
|
@@ -52542,8 +53206,8 @@ function writeMachineFile(home2, body) {
|
|
|
52542
53206
|
}
|
|
52543
53207
|
closeSync7(fd);
|
|
52544
53208
|
try {
|
|
52545
|
-
|
|
52546
|
-
|
|
53209
|
+
chmodSync14(tmp, 384);
|
|
53210
|
+
renameSync14(tmp, join30(home2, "machine.json"));
|
|
52547
53211
|
} catch (e) {
|
|
52548
53212
|
unlinkSync3(tmp);
|
|
52549
53213
|
throw e;
|
|
@@ -52670,7 +53334,7 @@ async function login(args) {
|
|
|
52670
53334
|
`${JSON.stringify({ hub, label, machine_token: poll.machine_token }, null, 2)}
|
|
52671
53335
|
`
|
|
52672
53336
|
);
|
|
52673
|
-
|
|
53337
|
+
rmSync15(join30(args.home, "revoked"), { force: true });
|
|
52674
53338
|
if (!events?.code) print(`Approved this machine as ${label}.`);
|
|
52675
53339
|
return {
|
|
52676
53340
|
machineToken: poll.machine_token,
|
|
@@ -52694,7 +53358,7 @@ init_src();
|
|
|
52694
53358
|
|
|
52695
53359
|
// src/commands/install.ts
|
|
52696
53360
|
init_src3();
|
|
52697
|
-
import { join as
|
|
53361
|
+
import { dirname as dirname15, join as join31 } from "node:path";
|
|
52698
53362
|
init_src2();
|
|
52699
53363
|
|
|
52700
53364
|
// src/live.ts
|
|
@@ -52823,7 +53487,7 @@ async function loginStep(ctx, opts) {
|
|
|
52823
53487
|
ctx,
|
|
52824
53488
|
c.approved(result.label),
|
|
52825
53489
|
c.tokenSaved(
|
|
52826
|
-
tilde(ctx,
|
|
53490
|
+
tilde(ctx, join31(ctx.home, "machine.json")),
|
|
52827
53491
|
result.machineToken
|
|
52828
53492
|
),
|
|
52829
53493
|
c.connected(originOf2(result.hub)),
|
|
@@ -52878,10 +53542,17 @@ async function harnessesStep(ctx, hub) {
|
|
|
52878
53542
|
say(ctx, await skippedLines(ctx, s.harness, s.reason));
|
|
52879
53543
|
if (out.installed.includes("opencode"))
|
|
52880
53544
|
say(ctx, out.opencodeRestarted ? c.restarted() : c.opencodeNotRunning());
|
|
53545
|
+
const codexVersion = out.installed.includes("codex") ? await readCodexVersion({
|
|
53546
|
+
configFile: codexBinFile(ctx.home),
|
|
53547
|
+
exec: ctx.exec,
|
|
53548
|
+
path: ctx.env.PATH,
|
|
53549
|
+
app: ctx.codexApp
|
|
53550
|
+
}) : void 0;
|
|
52881
53551
|
const skill = await installSkill(
|
|
52882
53552
|
{
|
|
52883
53553
|
home: ctx.userHome,
|
|
52884
53554
|
env: ctx.env,
|
|
53555
|
+
codexVersion,
|
|
52885
53556
|
fetchSkill: (url2) => fetchSkillText(ctx.fetch, url2)
|
|
52886
53557
|
},
|
|
52887
53558
|
hub ? originOf2(hub) : machineOrigin(ctx),
|
|
@@ -52889,6 +53560,26 @@ async function harnessesStep(ctx, hub) {
|
|
|
52889
53560
|
);
|
|
52890
53561
|
for (const n of skill.notes) say(ctx, [n]);
|
|
52891
53562
|
if (skill.failedUrl) skillFailure.set(ctx, skill.failedUrl);
|
|
53563
|
+
try {
|
|
53564
|
+
const style = installOutputStyle(
|
|
53565
|
+
{
|
|
53566
|
+
home: ctx.userHome,
|
|
53567
|
+
busHome: ctx.home,
|
|
53568
|
+
env: ctx.env,
|
|
53569
|
+
text: outputStyleSource()
|
|
53570
|
+
},
|
|
53571
|
+
out.installed
|
|
53572
|
+
);
|
|
53573
|
+
for (const n of style.notes) say(ctx, [n]);
|
|
53574
|
+
if (style.settings === "set" && style.written[0])
|
|
53575
|
+
say(ctx, c.outputStyleOn(tilde(ctx, style.written[0])));
|
|
53576
|
+
else if (style.settings === "kept" && style.first)
|
|
53577
|
+
say(ctx, c.outputStyleKept(style.kept));
|
|
53578
|
+
} catch (e) {
|
|
53579
|
+
say(ctx, [
|
|
53580
|
+
`Could not write the output style: ${e instanceof Error ? e.message : String(e)}`
|
|
53581
|
+
]);
|
|
53582
|
+
}
|
|
52892
53583
|
return true;
|
|
52893
53584
|
}
|
|
52894
53585
|
var skillFailure = /* @__PURE__ */ new WeakMap();
|
|
@@ -52918,7 +53609,7 @@ function shownSocket(ctx) {
|
|
|
52918
53609
|
const real3 = `${canonicalHome(ctx.home)}/`;
|
|
52919
53610
|
return tilde(
|
|
52920
53611
|
ctx,
|
|
52921
|
-
path.startsWith(real3) ?
|
|
53612
|
+
path.startsWith(real3) ? join31(ctx.home, path.slice(real3.length)) : path
|
|
52922
53613
|
);
|
|
52923
53614
|
}
|
|
52924
53615
|
async function waitForDaemon(ctx) {
|
|
@@ -53056,6 +53747,31 @@ var installSteps = (opts) => [
|
|
|
53056
53747
|
apply: (ctx) => daemonStep(ctx, opts.noService)
|
|
53057
53748
|
}
|
|
53058
53749
|
];
|
|
53750
|
+
function reportShim(ctx) {
|
|
53751
|
+
const argv = ctx.service.argv?.();
|
|
53752
|
+
if (!argv || argv.length !== 2) return;
|
|
53753
|
+
try {
|
|
53754
|
+
const r = installShim({
|
|
53755
|
+
userHome: ctx.userHome,
|
|
53756
|
+
busHome: ctx.home,
|
|
53757
|
+
platform: ctx.platform,
|
|
53758
|
+
env: ctx.env,
|
|
53759
|
+
argv
|
|
53760
|
+
});
|
|
53761
|
+
if (r.kind === "installed") {
|
|
53762
|
+
say(ctx, ctx.copy.shimInstalled(tilde(ctx, r.path)));
|
|
53763
|
+
if (!r.onPath && r.hint)
|
|
53764
|
+
say(ctx, ctx.copy.shimNotOnPath(tilde(ctx, dirname15(r.path)), r.hint));
|
|
53765
|
+
} else if (r.kind === "other-home")
|
|
53766
|
+
say(ctx, ctx.copy.shimOtherHome(tilde(ctx, r.path), tilde(ctx, r.home)));
|
|
53767
|
+
else if (r.kind === "foreign")
|
|
53768
|
+
say(ctx, ctx.copy.shimForeign(tilde(ctx, r.path)));
|
|
53769
|
+
} catch (e) {
|
|
53770
|
+
say(ctx, [
|
|
53771
|
+
`Could not add the oa-bus command: ${e instanceof Error ? e.message : String(e)}`
|
|
53772
|
+
]);
|
|
53773
|
+
}
|
|
53774
|
+
}
|
|
53059
53775
|
async function install2(opts, realCtx2) {
|
|
53060
53776
|
if (opts.habits) return habitsCommand(opts.habits, realCtx2);
|
|
53061
53777
|
const json3 = Boolean(opts.json && !opts.check);
|
|
@@ -53072,9 +53788,10 @@ async function install2(opts, realCtx2) {
|
|
|
53072
53788
|
return results.every((r) => r.state === "done") ? 0 : 1;
|
|
53073
53789
|
}
|
|
53074
53790
|
const ok = await runSteps(steps, ctx, {
|
|
53075
|
-
path:
|
|
53791
|
+
path: join31(ctx.home, "install.json"),
|
|
53076
53792
|
now: ctx.now
|
|
53077
53793
|
});
|
|
53794
|
+
if (ok) reportShim(ctx);
|
|
53078
53795
|
const skillFailed = reportSkillFailure(ctx);
|
|
53079
53796
|
const habits = ok ? await habitsAfterInstall(ctx, json3) : void 0;
|
|
53080
53797
|
const code2 = ok && !skillFailed ? 0 : 1;
|
|
@@ -53258,7 +53975,7 @@ async function healthz(ctx, hub) {
|
|
|
53258
53975
|
function claudeIsolates(path) {
|
|
53259
53976
|
let text3;
|
|
53260
53977
|
try {
|
|
53261
|
-
text3 =
|
|
53978
|
+
text3 = readFileSync26(path, "utf8");
|
|
53262
53979
|
} catch {
|
|
53263
53980
|
return void 0;
|
|
53264
53981
|
}
|
|
@@ -53287,6 +54004,15 @@ function codexChecks(ctx, out) {
|
|
|
53287
54004
|
if (shell !== service)
|
|
53288
54005
|
out.warn(c.codexHomeMismatch(tilde(ctx, shell), tilde(ctx, service)));
|
|
53289
54006
|
}
|
|
54007
|
+
const skill = codexSkillState({ home: ctx.userHome, env: ctx.env });
|
|
54008
|
+
if (skill.file && skill.block && skill.shared)
|
|
54009
|
+
out.warn(c.codexSkillSharedTwice());
|
|
54010
|
+
else if (skill.file && skill.block)
|
|
54011
|
+
out.warn(
|
|
54012
|
+
c.codexSkillTwice(tilde(ctx, skill.file), tilde(ctx, skill.block))
|
|
54013
|
+
);
|
|
54014
|
+
else if (skill.file ?? skill.block)
|
|
54015
|
+
out.pass(c.codexSkill(tilde(ctx, skill.file ?? skill.block)));
|
|
53290
54016
|
const config2 = codexConfig(ctx.userHome, ctx.env);
|
|
53291
54017
|
let risk;
|
|
53292
54018
|
try {
|
|
@@ -53325,7 +54051,7 @@ async function doctor(ctx) {
|
|
|
53325
54051
|
const node2 = ctx.nodeVersion.replace(/^v/, "");
|
|
53326
54052
|
if (Number(node2.split(".")[0]) >= MIN_NODE) pass(c.nodeOk(node2));
|
|
53327
54053
|
else fail2(c.nodeOld(node2));
|
|
53328
|
-
const machineFile = tilde(ctx,
|
|
54054
|
+
const machineFile = tilde(ctx, join32(ctx.home, "machine.json"));
|
|
53329
54055
|
const m = readMachine(ctx.home);
|
|
53330
54056
|
if (m.state !== "ok") fail2(c.noCredentials(machineFile));
|
|
53331
54057
|
else if (m.revoked) fail2(c.revokedCheck());
|
|
@@ -53412,13 +54138,15 @@ async function doctor(ctx) {
|
|
|
53412
54138
|
pass(c.wired(h, version2));
|
|
53413
54139
|
else fail2(c.notWired(h));
|
|
53414
54140
|
if (h === "claude") {
|
|
53415
|
-
const settings =
|
|
53416
|
-
ctx.env.CLAUDE_CONFIG_DIR ??
|
|
54141
|
+
const settings = join32(
|
|
54142
|
+
ctx.env.CLAUDE_CONFIG_DIR ?? join32(ctx.userHome, ".claude"),
|
|
53417
54143
|
"settings.json"
|
|
53418
54144
|
);
|
|
53419
54145
|
const isolates = claudeIsolates(settings);
|
|
53420
54146
|
if (isolates === false) pass(c.claudeAccepts());
|
|
53421
54147
|
if (isolates === true) warn(c.claudeIsolates(tilde(ctx, settings)));
|
|
54148
|
+
const style = outputStyleState({ home: ctx.userHome, env: ctx.env });
|
|
54149
|
+
if (style) pass(c.outputStyleDoctor(tilde(ctx, style.path), style.on));
|
|
53422
54150
|
}
|
|
53423
54151
|
if (h === "opencode") {
|
|
53424
54152
|
const gone = opencodeProxyProblem({
|
|
@@ -53441,6 +54169,19 @@ async function doctor(ctx) {
|
|
|
53441
54169
|
}
|
|
53442
54170
|
if (h === "openclaw") say(ctx, c.openclawDmNote());
|
|
53443
54171
|
}
|
|
54172
|
+
if (ctx.service.argv?.().length === 2) {
|
|
54173
|
+
const sh = shimState({
|
|
54174
|
+
userHome: ctx.userHome,
|
|
54175
|
+
busHome: ctx.home,
|
|
54176
|
+
platform: ctx.platform,
|
|
54177
|
+
env: ctx.env
|
|
54178
|
+
});
|
|
54179
|
+
if (sh?.kind === "ours") pass(c.shimDoctorOk(tilde(ctx, sh.path)));
|
|
54180
|
+
else if (sh?.kind === "off-path")
|
|
54181
|
+
warn(c.shimDoctorOffPath(tilde(ctx, sh.path), sh.hint));
|
|
54182
|
+
else if (sh?.kind === "other") warn(c.shimDoctorOther(tilde(ctx, sh.path)));
|
|
54183
|
+
else if (sh?.kind === "missing") warn(c.shimDoctorMissing());
|
|
54184
|
+
}
|
|
53444
54185
|
const habits = habitsLine(ctx);
|
|
53445
54186
|
if (habits) say(ctx, habits);
|
|
53446
54187
|
const allow = globalFile(ctx.home);
|
|
@@ -53474,7 +54215,7 @@ async function doctor(ctx) {
|
|
|
53474
54215
|
|
|
53475
54216
|
// src/commands/global.ts
|
|
53476
54217
|
import { realpathSync as realpathSync13, statSync as statSync11 } from "node:fs";
|
|
53477
|
-
import { resolve as
|
|
54218
|
+
import { resolve as resolve12 } from "node:path";
|
|
53478
54219
|
function shown3(ctx, path) {
|
|
53479
54220
|
const t = tilde(ctx, path);
|
|
53480
54221
|
if (t !== path) return t;
|
|
@@ -53500,7 +54241,7 @@ async function global(opts, ctx) {
|
|
|
53500
54241
|
);
|
|
53501
54242
|
return 0;
|
|
53502
54243
|
}
|
|
53503
|
-
const given =
|
|
54244
|
+
const given = resolve12(ctx.cwd, opts.dir);
|
|
53504
54245
|
let real3;
|
|
53505
54246
|
try {
|
|
53506
54247
|
real3 = canonicalPath(given);
|
|
@@ -53532,12 +54273,12 @@ async function global(opts, ctx) {
|
|
|
53532
54273
|
}
|
|
53533
54274
|
|
|
53534
54275
|
// src/commands/leads.ts
|
|
53535
|
-
import { readFileSync as
|
|
53536
|
-
import { join as
|
|
54276
|
+
import { readFileSync as readFileSync27 } from "node:fs";
|
|
54277
|
+
import { join as join33 } from "node:path";
|
|
53537
54278
|
function hubOrigin(ctx) {
|
|
53538
54279
|
try {
|
|
53539
54280
|
const raw = JSON.parse(
|
|
53540
|
-
|
|
54281
|
+
readFileSync27(join33(ctx.home, "machine.json"), "utf8")
|
|
53541
54282
|
);
|
|
53542
54283
|
return typeof raw?.hub === "string" ? new URL(raw.hub).origin : void 0;
|
|
53543
54284
|
} catch {
|
|
@@ -53596,10 +54337,10 @@ async function leads(opts, ctx) {
|
|
|
53596
54337
|
|
|
53597
54338
|
// src/commands/link.ts
|
|
53598
54339
|
import { statSync as statSync12 } from "node:fs";
|
|
53599
|
-
import { resolve as
|
|
54340
|
+
import { resolve as resolve13 } from "node:path";
|
|
53600
54341
|
init_src();
|
|
53601
54342
|
function side(ctx, dir) {
|
|
53602
|
-
const given =
|
|
54343
|
+
const given = resolve13(ctx.cwd, dir);
|
|
53603
54344
|
try {
|
|
53604
54345
|
const real3 = canonicalPath(given);
|
|
53605
54346
|
if (!statSync12(real3).isDirectory()) return void 0;
|
|
@@ -53630,7 +54371,7 @@ async function link(opts, ctx) {
|
|
|
53630
54371
|
for (const d of opts.dirs) {
|
|
53631
54372
|
const s = side(ctx, d);
|
|
53632
54373
|
if (!s) {
|
|
53633
|
-
sayErr(ctx, c.linkNotDir(shq(
|
|
54374
|
+
sayErr(ctx, c.linkNotDir(shq(resolve13(ctx.cwd, d))));
|
|
53634
54375
|
return 1;
|
|
53635
54376
|
}
|
|
53636
54377
|
sides.push(s);
|
|
@@ -53690,14 +54431,14 @@ async function link(opts, ctx) {
|
|
|
53690
54431
|
}
|
|
53691
54432
|
|
|
53692
54433
|
// src/commands/logs.ts
|
|
53693
|
-
import { readFileSync as
|
|
53694
|
-
import { join as
|
|
54434
|
+
import { readFileSync as readFileSync28 } from "node:fs";
|
|
54435
|
+
import { join as join34 } from "node:path";
|
|
53695
54436
|
var TAIL = 50;
|
|
53696
54437
|
async function logs(ctx) {
|
|
53697
|
-
const path =
|
|
54438
|
+
const path = join34(ctx.home, "logs", "daemon.log");
|
|
53698
54439
|
let text3;
|
|
53699
54440
|
try {
|
|
53700
|
-
text3 =
|
|
54441
|
+
text3 = readFileSync28(path, "utf8");
|
|
53701
54442
|
} catch {
|
|
53702
54443
|
say(ctx, ctx.copy.noLog(tilde(ctx, path)));
|
|
53703
54444
|
return 1;
|
|
@@ -53728,7 +54469,7 @@ init_src2();
|
|
|
53728
54469
|
init_src();
|
|
53729
54470
|
import { execFileSync as execFileSync6 } from "node:child_process";
|
|
53730
54471
|
import { createHash as createHash8, randomBytes as randomBytes8 } from "node:crypto";
|
|
53731
|
-
import { readFileSync as
|
|
54472
|
+
import { readFileSync as readFileSync29, readlinkSync as readlinkSync5 } from "node:fs";
|
|
53732
54473
|
import { basename as basename8 } from "node:path";
|
|
53733
54474
|
var isClaude = (name) => name === "claude" || /\/claude\/versions\/[^/]+$/.test(name);
|
|
53734
54475
|
function parsePs(out) {
|
|
@@ -53739,14 +54480,14 @@ function parsePs(out) {
|
|
|
53739
54480
|
}
|
|
53740
54481
|
function readProc(pid) {
|
|
53741
54482
|
try {
|
|
53742
|
-
const stat =
|
|
54483
|
+
const stat = readFileSync29(`/proc/${pid}/stat`, "utf8");
|
|
53743
54484
|
const ppid = Number(stat.slice(stat.lastIndexOf(")") + 1).split(/\s+/)[2]);
|
|
53744
54485
|
let exe = "";
|
|
53745
54486
|
try {
|
|
53746
|
-
exe =
|
|
54487
|
+
exe = readlinkSync5(`/proc/${pid}/exe`);
|
|
53747
54488
|
} catch {
|
|
53748
54489
|
}
|
|
53749
|
-
const comm =
|
|
54490
|
+
const comm = readFileSync29(`/proc/${pid}/comm`, "utf8").trim();
|
|
53750
54491
|
return { ppid, name: isClaude(exe) ? exe : comm };
|
|
53751
54492
|
} catch {
|
|
53752
54493
|
}
|
|
@@ -53774,7 +54515,7 @@ function findClaude(from, proc) {
|
|
|
53774
54515
|
function tokenOf(file2) {
|
|
53775
54516
|
if (!file2) return void 0;
|
|
53776
54517
|
try {
|
|
53777
|
-
return
|
|
54518
|
+
return readFileSync29(file2, "utf8").trim() || void 0;
|
|
53778
54519
|
} catch {
|
|
53779
54520
|
return void 0;
|
|
53780
54521
|
}
|
|
@@ -53803,7 +54544,7 @@ async function mcpProof(opts, ctx, deps2 = {
|
|
|
53803
54544
|
|
|
53804
54545
|
// src/commands/namespace.ts
|
|
53805
54546
|
import { realpathSync as realpathSync14, statSync as statSync13 } from "node:fs";
|
|
53806
|
-
import { join as
|
|
54547
|
+
import { join as join35, resolve as resolve14 } from "node:path";
|
|
53807
54548
|
init_src();
|
|
53808
54549
|
function shown4(ctx, path) {
|
|
53809
54550
|
const t = tilde(ctx, path);
|
|
@@ -53830,7 +54571,7 @@ async function namespace(opts, ctx) {
|
|
|
53830
54571
|
);
|
|
53831
54572
|
return 0;
|
|
53832
54573
|
}
|
|
53833
|
-
const given =
|
|
54574
|
+
const given = resolve14(ctx.cwd, opts.dir);
|
|
53834
54575
|
let real3;
|
|
53835
54576
|
try {
|
|
53836
54577
|
real3 = canonicalPath(given);
|
|
@@ -53857,7 +54598,7 @@ async function namespace(opts, ctx) {
|
|
|
53857
54598
|
sayErr(ctx, c.nsNotDir(shown4(ctx, real3 ?? given)));
|
|
53858
54599
|
return 1;
|
|
53859
54600
|
}
|
|
53860
|
-
const cfgFile =
|
|
54601
|
+
const cfgFile = join35(real3, CONFIG_FILE);
|
|
53861
54602
|
const own2 = readOwnFile(cfgFile, process.getuid?.(), {
|
|
53862
54603
|
allowGroupWrite: true
|
|
53863
54604
|
});
|
|
@@ -53931,12 +54672,12 @@ async function namespace(opts, ctx) {
|
|
|
53931
54672
|
}
|
|
53932
54673
|
|
|
53933
54674
|
// src/commands/uninstall.ts
|
|
53934
|
-
import { join as
|
|
54675
|
+
import { join as join37 } from "node:path";
|
|
53935
54676
|
|
|
53936
54677
|
// src/steps/purge.ts
|
|
53937
54678
|
init_src3();
|
|
53938
|
-
import { lstatSync as
|
|
53939
|
-
import { join as
|
|
54679
|
+
import { lstatSync as lstatSync17, readdirSync as readdirSync9, rmdirSync as rmdirSync4, rmSync as rmSync16 } from "node:fs";
|
|
54680
|
+
import { join as join36 } from "node:path";
|
|
53940
54681
|
var FILES = [
|
|
53941
54682
|
"machine.json",
|
|
53942
54683
|
"install.json",
|
|
@@ -53969,16 +54710,16 @@ var FOLDERS = [
|
|
|
53969
54710
|
];
|
|
53970
54711
|
function kind3(path) {
|
|
53971
54712
|
try {
|
|
53972
|
-
const st =
|
|
54713
|
+
const st = lstatSync17(path);
|
|
53973
54714
|
return st.isDirectory() ? "dir" : st.isSocket() ? "socket" : "other";
|
|
53974
54715
|
} catch {
|
|
53975
54716
|
return void 0;
|
|
53976
54717
|
}
|
|
53977
54718
|
}
|
|
53978
|
-
var remove2 = (path, k) =>
|
|
54719
|
+
var remove2 = (path, k) => rmSync16(path, { recursive: k === "dir", force: true });
|
|
53979
54720
|
var rmdirIfEmpty = (path) => {
|
|
53980
54721
|
try {
|
|
53981
|
-
|
|
54722
|
+
rmdirSync4(path);
|
|
53982
54723
|
return true;
|
|
53983
54724
|
} catch {
|
|
53984
54725
|
return false;
|
|
@@ -53986,14 +54727,14 @@ var rmdirIfEmpty = (path) => {
|
|
|
53986
54727
|
};
|
|
53987
54728
|
function purgeShort(dir, removed) {
|
|
53988
54729
|
if (kind3(dir) !== "dir" || unsafeSocketDir(dir)) return;
|
|
53989
|
-
const ret =
|
|
54730
|
+
const ret = join36(dir, "claude-return");
|
|
53990
54731
|
for (const [d, ours2] of [
|
|
53991
54732
|
[ret, (_n, p) => kind3(p) === "socket"],
|
|
53992
54733
|
[dir, (n) => /^daemon\.sock(\.keep-\d+)?$/.test(n)]
|
|
53993
54734
|
]) {
|
|
53994
54735
|
if (kind3(d) !== "dir") continue;
|
|
53995
|
-
for (const name of
|
|
53996
|
-
const path =
|
|
54736
|
+
for (const name of readdirSync9(d)) {
|
|
54737
|
+
const path = join36(d, name);
|
|
53997
54738
|
const k = kind3(path);
|
|
53998
54739
|
if (k === void 0 || k === "dir" || !ours2(name, path)) continue;
|
|
53999
54740
|
remove2(path, k);
|
|
@@ -54006,7 +54747,7 @@ function purgeShort(dir, removed) {
|
|
|
54006
54747
|
function purge(home2, opts) {
|
|
54007
54748
|
let entries;
|
|
54008
54749
|
try {
|
|
54009
|
-
entries =
|
|
54750
|
+
entries = readdirSync9(home2);
|
|
54010
54751
|
} catch {
|
|
54011
54752
|
return { removed: [], leftDir: false };
|
|
54012
54753
|
}
|
|
@@ -54018,21 +54759,21 @@ function purge(home2, opts) {
|
|
|
54018
54759
|
...FILES,
|
|
54019
54760
|
...entries.filter((n) => TEMP.some((re) => re.test(n)))
|
|
54020
54761
|
]) {
|
|
54021
|
-
const path =
|
|
54762
|
+
const path = join36(home2, name);
|
|
54022
54763
|
const k = kind3(path);
|
|
54023
54764
|
if (k === void 0 || k === "dir") continue;
|
|
54024
54765
|
remove2(path, k);
|
|
54025
54766
|
removed.push(name);
|
|
54026
54767
|
}
|
|
54027
54768
|
for (const folder of FOLDERS) {
|
|
54028
|
-
const dir =
|
|
54769
|
+
const dir = join36(home2, folder.path);
|
|
54029
54770
|
if (kind3(dir) !== "dir") continue;
|
|
54030
|
-
for (const name of
|
|
54031
|
-
const path =
|
|
54771
|
+
for (const name of readdirSync9(dir)) {
|
|
54772
|
+
const path = join36(dir, name);
|
|
54032
54773
|
const k = kind3(path);
|
|
54033
54774
|
if (k === void 0 || !folder.ours(name, path)) continue;
|
|
54034
54775
|
remove2(path, k);
|
|
54035
|
-
removed.push(
|
|
54776
|
+
removed.push(join36(folder.path, name));
|
|
54036
54777
|
}
|
|
54037
54778
|
if (rmdirIfEmpty(dir)) removed.push(folder.path);
|
|
54038
54779
|
}
|
|
@@ -54071,6 +54812,18 @@ async function uninstall2(opts, ctx) {
|
|
|
54071
54812
|
`Could not remove the skill files: ${e instanceof Error ? e.message : String(e)}`
|
|
54072
54813
|
]);
|
|
54073
54814
|
}
|
|
54815
|
+
try {
|
|
54816
|
+
const style = uninstallOutputStyle({
|
|
54817
|
+
home: ctx.userHome,
|
|
54818
|
+
busHome: ctx.home,
|
|
54819
|
+
env: ctx.env
|
|
54820
|
+
});
|
|
54821
|
+
for (const n of style.notes) say(ctx, [n]);
|
|
54822
|
+
} catch (e) {
|
|
54823
|
+
say(ctx, [
|
|
54824
|
+
`Could not remove the output style: ${e instanceof Error ? e.message : String(e)}`
|
|
54825
|
+
]);
|
|
54826
|
+
}
|
|
54074
54827
|
try {
|
|
54075
54828
|
const habits = removeHabits({
|
|
54076
54829
|
home: ctx.userHome,
|
|
@@ -54083,11 +54836,23 @@ async function uninstall2(opts, ctx) {
|
|
|
54083
54836
|
`Could not remove the habits block: ${e instanceof Error ? e.message : String(e)}`
|
|
54084
54837
|
]);
|
|
54085
54838
|
}
|
|
54839
|
+
try {
|
|
54840
|
+
const gone = removeShim({
|
|
54841
|
+
userHome: ctx.userHome,
|
|
54842
|
+
busHome: ctx.home,
|
|
54843
|
+
platform: ctx.platform
|
|
54844
|
+
});
|
|
54845
|
+
if (gone) say(ctx, c.shimRemoved(tilde(ctx, gone)));
|
|
54846
|
+
} catch (e) {
|
|
54847
|
+
say(ctx, [
|
|
54848
|
+
`Could not remove the oa-bus command: ${e instanceof Error ? e.message : String(e)}`
|
|
54849
|
+
]);
|
|
54850
|
+
}
|
|
54086
54851
|
if (r.hermesNoCli)
|
|
54087
54852
|
say(
|
|
54088
54853
|
ctx,
|
|
54089
54854
|
c.hermesNoCli(
|
|
54090
|
-
tilde(ctx,
|
|
54855
|
+
tilde(ctx, join37(hermesHome(ctx.userHome, ctx.env), "config.yaml"))
|
|
54091
54856
|
)
|
|
54092
54857
|
);
|
|
54093
54858
|
if (r.openclawNoCli) say(ctx, c.openclawNoCli());
|
|
@@ -54106,7 +54871,7 @@ async function uninstall2(opts, ctx) {
|
|
|
54106
54871
|
r.opencodeRestarted ? c.restartedUnload() : c.opencodeNotRunningUnload()
|
|
54107
54872
|
);
|
|
54108
54873
|
if (!opts.purge) {
|
|
54109
|
-
say(ctx, "", c.kept(tilde(ctx,
|
|
54874
|
+
say(ctx, "", c.kept(tilde(ctx, join37(ctx.home, "machine.json"))));
|
|
54110
54875
|
return 0;
|
|
54111
54876
|
}
|
|
54112
54877
|
const home2 = tilde(ctx, ctx.home);
|
|
@@ -54117,7 +54882,7 @@ async function uninstall2(opts, ctx) {
|
|
|
54117
54882
|
} catch {
|
|
54118
54883
|
}
|
|
54119
54884
|
const out = purge(ctx.home, {
|
|
54120
|
-
isDefault: ctx.home ===
|
|
54885
|
+
isDefault: ctx.home === join37(ctx.userHome, ".oa-bus")
|
|
54121
54886
|
});
|
|
54122
54887
|
if ("refused" in out) {
|
|
54123
54888
|
sayErr(ctx, c.purgeRefused(home2));
|
|
@@ -54348,7 +55113,7 @@ async function main(argv, makeCtx = realCtx) {
|
|
|
54348
55113
|
return 2;
|
|
54349
55114
|
}
|
|
54350
55115
|
const ctx = makeCtx(cmd.noColor);
|
|
54351
|
-
if (cmd.home) ctx.home =
|
|
55116
|
+
if (cmd.home) ctx.home = resolve15(cmd.home);
|
|
54352
55117
|
try {
|
|
54353
55118
|
return await dispatch(cmd, ctx);
|
|
54354
55119
|
} catch (e) {
|