@open-artifacts/bus 0.126.0 → 0.127.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/dist/index.js +439 -114
- package/package.json +1 -1
package/assets/oa-bus.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { StringDecoder } from "node:string_decoder";
|
|
|
11
11
|
type Json = Record<string, unknown>;
|
|
12
12
|
|
|
13
13
|
/** The IPC marker (CONTRACT.md): the package version, stamped by the CLI's bundler. */
|
|
14
|
-
const CLIENT_VERSION = "0.
|
|
14
|
+
const CLIENT_VERSION = "0.127.0";
|
|
15
15
|
|
|
16
16
|
type Frame = Json & { type: string; id: string };
|
|
17
17
|
type Ctx = {
|
package/dist/index.js
CHANGED
|
@@ -26316,20 +26316,20 @@ var require_compile = __commonJS({
|
|
|
26316
26316
|
var util_1 = require_util();
|
|
26317
26317
|
var validate_1 = require_validate();
|
|
26318
26318
|
var SchemaEnv = class {
|
|
26319
|
-
constructor(
|
|
26319
|
+
constructor(env2) {
|
|
26320
26320
|
var _a3;
|
|
26321
26321
|
this.refs = {};
|
|
26322
26322
|
this.dynamicAnchors = {};
|
|
26323
26323
|
let schema;
|
|
26324
|
-
if (typeof
|
|
26325
|
-
schema =
|
|
26326
|
-
this.schema =
|
|
26327
|
-
this.schemaId =
|
|
26328
|
-
this.root =
|
|
26329
|
-
this.baseId = (_a3 =
|
|
26330
|
-
this.schemaPath =
|
|
26331
|
-
this.localRefs =
|
|
26332
|
-
this.meta =
|
|
26324
|
+
if (typeof env2.schema == "object")
|
|
26325
|
+
schema = env2.schema;
|
|
26326
|
+
this.schema = env2.schema;
|
|
26327
|
+
this.schemaId = env2.schemaId;
|
|
26328
|
+
this.root = env2.root || this;
|
|
26329
|
+
this.baseId = (_a3 = env2.baseId) !== null && _a3 !== void 0 ? _a3 : (0, resolve_1.normalizeId)(schema === null || schema === void 0 ? void 0 : schema[env2.schemaId || "$id"]);
|
|
26330
|
+
this.schemaPath = env2.schemaPath;
|
|
26331
|
+
this.localRefs = env2.localRefs;
|
|
26332
|
+
this.meta = env2.meta;
|
|
26333
26333
|
this.$async = schema === null || schema === void 0 ? void 0 : schema.$async;
|
|
26334
26334
|
this.refs = {};
|
|
26335
26335
|
}
|
|
@@ -26513,15 +26513,15 @@ var require_compile = __commonJS({
|
|
|
26513
26513
|
baseId = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schId);
|
|
26514
26514
|
}
|
|
26515
26515
|
}
|
|
26516
|
-
let
|
|
26516
|
+
let env2;
|
|
26517
26517
|
if (typeof schema != "boolean" && schema.$ref && !(0, util_1.schemaHasRulesButRef)(schema, this.RULES)) {
|
|
26518
26518
|
const $ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schema.$ref);
|
|
26519
|
-
|
|
26519
|
+
env2 = resolveSchema.call(this, root, $ref);
|
|
26520
26520
|
}
|
|
26521
26521
|
const { schemaId } = this.opts;
|
|
26522
|
-
|
|
26523
|
-
if (
|
|
26524
|
-
return
|
|
26522
|
+
env2 = env2 || new SchemaEnv({ schema, schemaId, root, baseId });
|
|
26523
|
+
if (env2.schema !== env2.root.schema)
|
|
26524
|
+
return env2;
|
|
26525
26525
|
return void 0;
|
|
26526
26526
|
}
|
|
26527
26527
|
}
|
|
@@ -28319,8 +28319,8 @@ var require_ref = __commonJS({
|
|
|
28319
28319
|
schemaType: "string",
|
|
28320
28320
|
code(cxt) {
|
|
28321
28321
|
const { gen, schema: $ref, it } = cxt;
|
|
28322
|
-
const { baseId, schemaEnv:
|
|
28323
|
-
const { root } =
|
|
28322
|
+
const { baseId, schemaEnv: env2, validateName, opts, self } = it;
|
|
28323
|
+
const { root } = env2;
|
|
28324
28324
|
if (($ref === "#" || $ref === "#/") && baseId === root.baseId)
|
|
28325
28325
|
return callRootRef();
|
|
28326
28326
|
const schOrEnv = compile_1.resolveRef.call(self, root, baseId, $ref);
|
|
@@ -28330,8 +28330,8 @@ var require_ref = __commonJS({
|
|
|
28330
28330
|
return callValidate(schOrEnv);
|
|
28331
28331
|
return inlineRefSchema(schOrEnv);
|
|
28332
28332
|
function callRootRef() {
|
|
28333
|
-
if (
|
|
28334
|
-
return callRef(cxt, validateName,
|
|
28333
|
+
if (env2 === root)
|
|
28334
|
+
return callRef(cxt, validateName, env2, env2.$async);
|
|
28335
28335
|
const rootName = gen.scopeValue("root", { ref: root });
|
|
28336
28336
|
return callRef(cxt, (0, codegen_1._)`${rootName}.validate`, root, root.$async);
|
|
28337
28337
|
}
|
|
@@ -28361,14 +28361,14 @@ var require_ref = __commonJS({
|
|
|
28361
28361
|
exports.getValidate = getValidate;
|
|
28362
28362
|
function callRef(cxt, v, sch, $async) {
|
|
28363
28363
|
const { gen, it } = cxt;
|
|
28364
|
-
const { allErrors, schemaEnv:
|
|
28364
|
+
const { allErrors, schemaEnv: env2, opts } = it;
|
|
28365
28365
|
const passCxt = opts.passContext ? names_1.default.this : codegen_1.nil;
|
|
28366
28366
|
if ($async)
|
|
28367
28367
|
callAsyncRef();
|
|
28368
28368
|
else
|
|
28369
28369
|
callSyncRef();
|
|
28370
28370
|
function callAsyncRef() {
|
|
28371
|
-
if (!
|
|
28371
|
+
if (!env2.$async)
|
|
28372
28372
|
throw new Error("async schema referenced by sync schema");
|
|
28373
28373
|
const valid2 = gen.let("valid");
|
|
28374
28374
|
gen.try(() => {
|
|
@@ -32409,7 +32409,7 @@ var init_frames = __esm({
|
|
|
32409
32409
|
late = { late: external_exports.array(external_exports.string().min(1)).optional() };
|
|
32410
32410
|
isWellFormed2 = (s) => s.isWellFormed();
|
|
32411
32411
|
WELL_FORMED = { message: "text is not well-formed unicode" };
|
|
32412
|
-
CLIENT_VERSION = true ? "0.
|
|
32412
|
+
CLIENT_VERSION = true ? "0.127.0" : "0.0.0";
|
|
32413
32413
|
clientVersion = {
|
|
32414
32414
|
client_version: external_exports.string().min(1).max(64).optional()
|
|
32415
32415
|
};
|
|
@@ -32737,7 +32737,7 @@ async function connectDaemon(opts) {
|
|
|
32737
32737
|
});
|
|
32738
32738
|
const decoder = new LineDecoder();
|
|
32739
32739
|
let state = "open";
|
|
32740
|
-
let
|
|
32740
|
+
let seq2 = 0;
|
|
32741
32741
|
const pending = /* @__PURE__ */ new Map();
|
|
32742
32742
|
const waiters = [];
|
|
32743
32743
|
let deliver;
|
|
@@ -32814,7 +32814,7 @@ async function connectDaemon(opts) {
|
|
|
32814
32814
|
request: (partial2) => {
|
|
32815
32815
|
if (state === "closed")
|
|
32816
32816
|
return Promise.reject(new Error("daemon connection closed"));
|
|
32817
|
-
const id = partial2.id ?? String(++
|
|
32817
|
+
const id = partial2.id ?? String(++seq2);
|
|
32818
32818
|
return new Promise((resolve8, reject) => {
|
|
32819
32819
|
const ms = opts.requestTimeoutMs ?? 2e4;
|
|
32820
32820
|
const timer2 = setTimeout(() => {
|
|
@@ -32838,7 +32838,7 @@ async function connectDaemon(opts) {
|
|
|
32838
32838
|
ack: (msg_id) => {
|
|
32839
32839
|
if (state === "closed") return;
|
|
32840
32840
|
sock.write(
|
|
32841
|
-
`${JSON.stringify({ v: 1, type: "ack", id: `ack-${++
|
|
32841
|
+
`${JSON.stringify({ v: 1, type: "ack", id: `ack-${++seq2}`, msg_id })}
|
|
32842
32842
|
`
|
|
32843
32843
|
);
|
|
32844
32844
|
},
|
|
@@ -33014,11 +33014,11 @@ function lateDeliveredText(to, excerpt) {
|
|
|
33014
33014
|
if (!excerpt) return fitLine((v) => `${head(v)} ${tail}`, to);
|
|
33015
33015
|
return fitLine((v) => quoted(head(v), `"${excerpt}"`, tail), to);
|
|
33016
33016
|
}
|
|
33017
|
-
function cutOff(
|
|
33018
|
-
const bel =
|
|
33019
|
-
if (
|
|
33020
|
-
return !bel && !
|
|
33021
|
-
return
|
|
33017
|
+
function cutOff(seq2) {
|
|
33018
|
+
const bel = seq2.endsWith("\x07");
|
|
33019
|
+
if (seq2[0] === "\x1B" && seq2.length > 1 && "P]X^_".includes(seq2[1]))
|
|
33020
|
+
return !bel && !seq2.endsWith("\x1B\\");
|
|
33021
|
+
return seq2[0] === "\x9D" && !bel && !seq2.endsWith("\x9C");
|
|
33022
33022
|
}
|
|
33023
33023
|
function messageHeader(m) {
|
|
33024
33024
|
const reply = m.global ? `Reply with the oa_bus send_message tool (to_namespace ${m.namespace}) if needed.` : "Reply with the oa_bus send_message tool if needed.";
|
|
@@ -33140,7 +33140,7 @@ ${own2}` : `${head},
|
|
|
33140
33140
|
"g"
|
|
33141
33141
|
);
|
|
33142
33142
|
CUT_OFF = " [control sequence removed]";
|
|
33143
|
-
stripTerminalControls = (text3) => text3.replace(TERMINAL_CONTROLS, (
|
|
33143
|
+
stripTerminalControls = (text3) => text3.replace(TERMINAL_CONTROLS, (seq2) => cutOff(seq2) ? CUT_OFF : "");
|
|
33144
33144
|
KIND_CHARS = 32;
|
|
33145
33145
|
displayKind = (kind2) => [
|
|
33146
33146
|
...stripTerminalControls(kind2).replace(INVISIBLES, "").replace(/\s+/g, " ").trim()
|
|
@@ -34013,8 +34013,8 @@ var init_session = __esm({
|
|
|
34013
34013
|
"../bus-adapter-claude-code/src/session.ts"() {
|
|
34014
34014
|
"use strict";
|
|
34015
34015
|
init_src2();
|
|
34016
|
-
claudeSessionsDir = (
|
|
34017
|
-
busHome = (
|
|
34016
|
+
claudeSessionsDir = (env2 = process.env) => env2.OA_BUS_CLAUDE_SESSIONS_DIR || join(env2.CLAUDE_CONFIG_DIR || join(homedir(), ".claude"), "sessions");
|
|
34017
|
+
busHome = (env2 = process.env) => resolve(env2.OA_BUS_HOME || join(homedir(), ".oa-bus"));
|
|
34018
34018
|
notASession = (rec) => rec.parkedJobId !== void 0 || Boolean(rec.agentBus);
|
|
34019
34019
|
sha256 = (s) => createHash("sha256").update(s).digest("hex");
|
|
34020
34020
|
NOT_UNDER_CLAUDE = "This MCP server is for Claude Code; use this harness's own bus tools.";
|
|
@@ -41751,11 +41751,11 @@ async function processArgs(pid) {
|
|
|
41751
41751
|
return args ? splitArgv0(args) : void 0;
|
|
41752
41752
|
}
|
|
41753
41753
|
var START_ERRORS = /* @__PURE__ */ new Set(["ENOENT", "EACCES", "ENOEXEC"]);
|
|
41754
|
-
var execCodex = (timeoutMs = CODEX_QUEUE_TIMEOUT_MS) => (bin, args,
|
|
41754
|
+
var execCodex = (timeoutMs = CODEX_QUEUE_TIMEOUT_MS) => (bin, args, env2) => new Promise((resolve8, reject) => {
|
|
41755
41755
|
execFile(
|
|
41756
41756
|
bin,
|
|
41757
41757
|
args,
|
|
41758
|
-
{ timeout: timeoutMs, maxBuffer: 64 * 1024, env },
|
|
41758
|
+
{ timeout: timeoutMs, maxBuffer: 64 * 1024, env: env2 },
|
|
41759
41759
|
(err, _stdout, stderr) => {
|
|
41760
41760
|
if (!err) return resolve8({ code: 0, stderr });
|
|
41761
41761
|
const e = err;
|
|
@@ -43001,19 +43001,19 @@ var terminalAnsi = {
|
|
|
43001
43001
|
};
|
|
43002
43002
|
|
|
43003
43003
|
// src/term.ts
|
|
43004
|
-
function detectStyle(
|
|
43005
|
-
const fgbg =
|
|
43004
|
+
function detectStyle(env2, stream, noColor = false) {
|
|
43005
|
+
const fgbg = env2.COLORFGBG?.split(";").at(-1);
|
|
43006
43006
|
const dark = !(fgbg === "7" || fgbg === "15");
|
|
43007
|
-
const locale = `${
|
|
43008
|
-
const utf8 = /utf-?8/i.test(locale) || Boolean(
|
|
43007
|
+
const locale = `${env2.LC_ALL ?? ""} ${env2.LC_CTYPE ?? ""} ${env2.LANG ?? ""}`;
|
|
43008
|
+
const utf8 = /utf-?8/i.test(locale) || Boolean(env2.WT_SESSION);
|
|
43009
43009
|
const style = (color) => ({ color, dark, utf8 });
|
|
43010
|
-
if (noColor ||
|
|
43011
|
-
const force =
|
|
43010
|
+
if (noColor || env2.NO_COLOR) return style("none");
|
|
43011
|
+
const force = env2.FORCE_COLOR;
|
|
43012
43012
|
if (force !== void 0)
|
|
43013
43013
|
return style(force === "0" ? "none" : force === "3" ? "truecolor" : "ansi");
|
|
43014
|
-
if (
|
|
43014
|
+
if (env2.TERM === "dumb" || !stream.isTTY || !stream.hasColors?.())
|
|
43015
43015
|
return style("none");
|
|
43016
|
-
const deep = stream.hasColors(2 ** 24) || /^(truecolor|24bit)$/i.test(
|
|
43016
|
+
const deep = stream.hasColors(2 ** 24) || /^(truecolor|24bit)$/i.test(env2.COLORTERM ?? "");
|
|
43017
43017
|
return style(deep ? "truecolor" : "ansi");
|
|
43018
43018
|
}
|
|
43019
43019
|
var rgb = (hex3) => [1, 3, 5].map((i) => Number.parseInt(hex3.slice(i, i + 2), 16)).join(";");
|
|
@@ -43656,8 +43656,8 @@ var openBrowser = (url2, launcher = browserCommand(process.platform, url2)) => n
|
|
|
43656
43656
|
}
|
|
43657
43657
|
});
|
|
43658
43658
|
var EXEC_TIMEOUT_MS = 1e4;
|
|
43659
|
-
function guardServiceManager(cmd, args = [],
|
|
43660
|
-
if (!
|
|
43659
|
+
function guardServiceManager(cmd, args = [], env2 = process.env) {
|
|
43660
|
+
if (!env2.VITEST) return;
|
|
43661
43661
|
if ([cmd, ...args].some((a) => /\b(launchctl|systemctl)\b/.test(a)))
|
|
43662
43662
|
throw new Error(`refusing to run ${cmd} under vitest: inject exec`);
|
|
43663
43663
|
}
|
|
@@ -44470,12 +44470,12 @@ var HAS_WELLFORMED = !!"".isWellFormed;
|
|
|
44470
44470
|
|
|
44471
44471
|
// src/steps/codex.ts
|
|
44472
44472
|
var CODEX_ENTRY = "oa_bus";
|
|
44473
|
-
var codexHome2 = (home2,
|
|
44474
|
-
function codexHomeEnv(home2,
|
|
44475
|
-
const dir = codexHome2(home2,
|
|
44473
|
+
var codexHome2 = (home2, env2) => env2.CODEX_HOME ? resolve3(env2.CODEX_HOME) : join12(home2, ".codex");
|
|
44474
|
+
function codexHomeEnv(home2, env2) {
|
|
44475
|
+
const dir = codexHome2(home2, env2);
|
|
44476
44476
|
return dir === join12(home2, ".codex") ? {} : { CODEX_HOME: dir };
|
|
44477
44477
|
}
|
|
44478
|
-
var codexConfig = (home2,
|
|
44478
|
+
var codexConfig = (home2, env2) => join12(codexHome2(home2, env2), "config.toml");
|
|
44479
44479
|
function hasCodex(o) {
|
|
44480
44480
|
if (o.which("codex")) return true;
|
|
44481
44481
|
try {
|
|
@@ -44544,12 +44544,12 @@ function sandboxRisk(doc, home2, codexDir) {
|
|
|
44544
44544
|
var str2 = (s) => JSON.stringify(s);
|
|
44545
44545
|
var key = (k) => /^[A-Za-z0-9_-]+$/.test(k) ? k : str2(k);
|
|
44546
44546
|
function renderEntry(e) {
|
|
44547
|
-
const
|
|
44547
|
+
const env2 = Object.entries(e.env ?? {});
|
|
44548
44548
|
return [
|
|
44549
44549
|
`[mcp_servers.${CODEX_ENTRY}]`,
|
|
44550
44550
|
`command = ${str2(e.command)}`,
|
|
44551
44551
|
`args = [${e.args.map(str2).join(", ")}]`,
|
|
44552
|
-
...
|
|
44552
|
+
...env2.length ? [`env = { ${env2.map(([k, v]) => `${key(k)} = ${str2(v)}`).join(", ")} }`] : [],
|
|
44553
44553
|
`default_tools_approval_mode = ${str2(e.default_tools_approval_mode)}`
|
|
44554
44554
|
];
|
|
44555
44555
|
}
|
|
@@ -44811,7 +44811,7 @@ var oneLine = (v) => {
|
|
|
44811
44811
|
var xml = (v) => oneLine(v).replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
44812
44812
|
function renderPlist(u, label = LAUNCHD_LABEL) {
|
|
44813
44813
|
const str3 = (v) => `<string>${xml(v)}</string>`;
|
|
44814
|
-
const
|
|
44814
|
+
const env2 = Object.entries(u.env).map(([k, v]) => `<key>${xml(k)}</key>${str3(v)}`).join("");
|
|
44815
44815
|
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
44816
44816
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
44817
44817
|
<plist version="1.0">
|
|
@@ -44825,7 +44825,7 @@ function renderPlist(u, label = LAUNCHD_LABEL) {
|
|
|
44825
44825
|
<key>StandardOutPath</key>${str3(u.out)}
|
|
44826
44826
|
<key>StandardErrorPath</key>${str3(u.err)}
|
|
44827
44827
|
<key>EnvironmentVariables</key>
|
|
44828
|
-
<dict>${
|
|
44828
|
+
<dict>${env2}</dict>
|
|
44829
44829
|
</dict>
|
|
44830
44830
|
</plist>
|
|
44831
44831
|
`;
|
|
@@ -44834,7 +44834,7 @@ var specifiers = (v) => oneLine(v).replaceAll("%", "%%");
|
|
|
44834
44834
|
var quoted2 = (v) => `"${specifiers(v).replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
|
|
44835
44835
|
var execWord = (v) => quoted2(v.replaceAll("$", "$$$$"));
|
|
44836
44836
|
function renderSystemd(u) {
|
|
44837
|
-
const
|
|
44837
|
+
const env2 = Object.entries(u.env).map(([k, v]) => `Environment=${quoted2(`${k}=${v}`)}
|
|
44838
44838
|
`).join("");
|
|
44839
44839
|
return `[Unit]
|
|
44840
44840
|
Description=Open Artifacts bus daemon
|
|
@@ -44846,7 +44846,7 @@ ExecStart=${execWord(u.node)} ${execWord(u.entry)} daemon
|
|
|
44846
44846
|
Restart=on-failure
|
|
44847
44847
|
RestartSec=10
|
|
44848
44848
|
RestartPreventExitStatus=${REVOKED_EXIT}
|
|
44849
|
-
${
|
|
44849
|
+
${env2}StandardOutput=append:${specifiers(u.out)}
|
|
44850
44850
|
StandardError=append:${specifiers(u.err)}
|
|
44851
44851
|
|
|
44852
44852
|
[Install]
|
|
@@ -45145,7 +45145,7 @@ var noService = {
|
|
|
45145
45145
|
remove: async () => ({}),
|
|
45146
45146
|
cli: () => ["oa-bus"]
|
|
45147
45147
|
};
|
|
45148
|
-
var VERSION = true ? "0.
|
|
45148
|
+
var VERSION = true ? "0.127.0" : JSON.parse(
|
|
45149
45149
|
readFileSync13(new URL("../package.json", import.meta.url), "utf8")
|
|
45150
45150
|
).version;
|
|
45151
45151
|
var which = (cmd) => {
|
|
@@ -45197,19 +45197,19 @@ var userName = () => {
|
|
|
45197
45197
|
}
|
|
45198
45198
|
};
|
|
45199
45199
|
function realCtx(noColor) {
|
|
45200
|
-
const
|
|
45201
|
-
const style = detectStyle(
|
|
45200
|
+
const env2 = process.env;
|
|
45201
|
+
const style = detectStyle(env2, process.stdout, noColor);
|
|
45202
45202
|
const ctx = {
|
|
45203
45203
|
...realDeps,
|
|
45204
45204
|
print: (line) => process.stdout.write(`${line}
|
|
45205
45205
|
`),
|
|
45206
45206
|
stdout: process.stdout,
|
|
45207
45207
|
stderr: process.stderr,
|
|
45208
|
-
env,
|
|
45208
|
+
env: env2,
|
|
45209
45209
|
cwd: process.cwd(),
|
|
45210
45210
|
userHome: homedir3(),
|
|
45211
45211
|
// Absolute: the plist and unit must never carry a relative path.
|
|
45212
|
-
home: busHome(
|
|
45212
|
+
home: busHome(env2),
|
|
45213
45213
|
which,
|
|
45214
45214
|
service: noService,
|
|
45215
45215
|
status: daemonStatus,
|
|
@@ -45224,7 +45224,7 @@ function realCtx(noColor) {
|
|
|
45224
45224
|
platform: process.platform,
|
|
45225
45225
|
userHome: ctx.userHome,
|
|
45226
45226
|
home: () => ctx.home,
|
|
45227
|
-
env,
|
|
45227
|
+
env: env2,
|
|
45228
45228
|
exec: ctx.exec,
|
|
45229
45229
|
sleep: ctx.sleep,
|
|
45230
45230
|
execPath: process.execPath,
|
|
@@ -45375,8 +45375,8 @@ async function daemon(ctx, run4 = runDaemon, signals = process) {
|
|
|
45375
45375
|
}
|
|
45376
45376
|
|
|
45377
45377
|
// src/commands/doctor.ts
|
|
45378
|
-
import { readFileSync as
|
|
45379
|
-
import { join as
|
|
45378
|
+
import { readFileSync as readFileSync17 } from "node:fs";
|
|
45379
|
+
import { join as join20 } from "node:path";
|
|
45380
45380
|
|
|
45381
45381
|
// ../bus-adapter-opencode/src/index.ts
|
|
45382
45382
|
init_session2();
|
|
@@ -46638,11 +46638,11 @@ var homeLine = (ob) => `process.env.OA_BUS_HOME ||= ${JSON.stringify(ob)};`;
|
|
|
46638
46638
|
var withHome = (text3, ob) => ob === void 0 ? text3 : `${homeLine(ob)}
|
|
46639
46639
|
${text3}`;
|
|
46640
46640
|
var paths = (deps) => {
|
|
46641
|
-
const
|
|
46642
|
-
const opencode =
|
|
46641
|
+
const env2 = deps.env ?? {};
|
|
46642
|
+
const opencode = env2.OPENCODE_CONFIG_DIR ?? join16(env2.XDG_CONFIG_HOME ?? join16(deps.home, ".config"), "opencode");
|
|
46643
46643
|
const busDir = deps.busHome ?? join16(deps.home, ".oa-bus");
|
|
46644
46644
|
return {
|
|
46645
|
-
claude: join16(
|
|
46645
|
+
claude: join16(env2.CLAUDE_CONFIG_DIR ?? deps.home, ".claude.json"),
|
|
46646
46646
|
// OpenCode reads both; edit the one the user has, else create .json.
|
|
46647
46647
|
opencodeConfigs: [
|
|
46648
46648
|
join16(opencode, "opencode.json"),
|
|
@@ -46653,33 +46653,33 @@ var paths = (deps) => {
|
|
|
46653
46653
|
// OpenCode registers the folder that holds tui.js.
|
|
46654
46654
|
opencodePlugin: join16(busDir, "integrations/opencode", NAME),
|
|
46655
46655
|
pi: join16(
|
|
46656
|
-
agentDirEnv(deps.home,
|
|
46656
|
+
agentDirEnv(deps.home, env2) ?? join16(deps.home, ".pi/agent"),
|
|
46657
46657
|
"extensions/oa-bus.ts"
|
|
46658
46658
|
),
|
|
46659
|
-
omp: join16(ompAgentDir(deps.home,
|
|
46660
|
-
codex: codexConfig(deps.home,
|
|
46659
|
+
omp: join16(ompAgentDir(deps.home, env2), "extensions/oa-bus.ts"),
|
|
46660
|
+
codex: codexConfig(deps.home, env2),
|
|
46661
46661
|
codexBin: codexBinFile(busDir),
|
|
46662
46662
|
busDir
|
|
46663
46663
|
};
|
|
46664
46664
|
};
|
|
46665
|
-
function agentDirEnv(home2,
|
|
46666
|
-
const dir =
|
|
46665
|
+
function agentDirEnv(home2, env2) {
|
|
46666
|
+
const dir = env2.PI_CODING_AGENT_DIR;
|
|
46667
46667
|
if (!dir) return void 0;
|
|
46668
46668
|
if (dir === "~") return home2;
|
|
46669
46669
|
return resolve5(dir.startsWith("~/") ? join16(home2, dir.slice(2)) : dir);
|
|
46670
46670
|
}
|
|
46671
|
-
var ompRoot = (home2,
|
|
46672
|
-
function ompProfile(
|
|
46673
|
-
const name = (
|
|
46671
|
+
var ompRoot = (home2, env2) => join16(home2, env2.PI_CONFIG_DIR || ".omp");
|
|
46672
|
+
function ompProfile(env2) {
|
|
46673
|
+
const name = (env2.OMP_PROFILE !== void 0 ? env2.OMP_PROFILE : env2.PI_PROFILE)?.trim();
|
|
46674
46674
|
if (!name || name === "default" || name.endsWith(".")) return void 0;
|
|
46675
46675
|
return /^[a-z0-9][a-z0-9._-]{0,63}$/.test(name) ? name : void 0;
|
|
46676
46676
|
}
|
|
46677
|
-
function ompAgentDir(home2,
|
|
46678
|
-
const root = ompRoot(home2,
|
|
46679
|
-
const profile = ompProfile(
|
|
46677
|
+
function ompAgentDir(home2, env2) {
|
|
46678
|
+
const root = ompRoot(home2, env2);
|
|
46679
|
+
const profile = ompProfile(env2);
|
|
46680
46680
|
if (profile) return join16(root, "profiles", profile, "agent");
|
|
46681
|
-
const piProfile = ompProfile({ PI_PROFILE:
|
|
46682
|
-
const dir = agentDirEnv(home2,
|
|
46681
|
+
const piProfile = ompProfile({ PI_PROFILE: env2.PI_PROFILE });
|
|
46682
|
+
const dir = agentDirEnv(home2, env2);
|
|
46683
46683
|
if (dir && !(piProfile && dir === join16(root, "profiles", piProfile, "agent")))
|
|
46684
46684
|
return dir;
|
|
46685
46685
|
return join16(root, "agent");
|
|
@@ -47086,7 +47086,7 @@ function checkAdapters(deps) {
|
|
|
47086
47086
|
return false;
|
|
47087
47087
|
}
|
|
47088
47088
|
};
|
|
47089
|
-
const homeOf = (
|
|
47089
|
+
const homeOf = (env2) => typeof env2 === "object" && env2 !== null ? env2.OA_BUS_HOME : void 0;
|
|
47090
47090
|
const homed = (file2) => {
|
|
47091
47091
|
if (!existsSync5(file2)) return false;
|
|
47092
47092
|
const first = readFileSync15(file2, "utf8").split("\n", 1)[0] ?? "";
|
|
@@ -47352,7 +47352,7 @@ init_src();
|
|
|
47352
47352
|
|
|
47353
47353
|
// src/commands/install.ts
|
|
47354
47354
|
init_src3();
|
|
47355
|
-
import { join as
|
|
47355
|
+
import { join as join19 } from "node:path";
|
|
47356
47356
|
init_src2();
|
|
47357
47357
|
|
|
47358
47358
|
// src/live.ts
|
|
@@ -47401,6 +47401,297 @@ function spinner(ctx) {
|
|
|
47401
47401
|
};
|
|
47402
47402
|
}
|
|
47403
47403
|
|
|
47404
|
+
// src/steps/skill.ts
|
|
47405
|
+
import {
|
|
47406
|
+
existsSync as existsSync6,
|
|
47407
|
+
lstatSync as lstatSync10,
|
|
47408
|
+
mkdirSync as mkdirSync10,
|
|
47409
|
+
readdirSync as readdirSync4,
|
|
47410
|
+
readFileSync as readFileSync16,
|
|
47411
|
+
realpathSync as realpathSync8,
|
|
47412
|
+
renameSync as renameSync10,
|
|
47413
|
+
rmdirSync,
|
|
47414
|
+
rmSync as rmSync7,
|
|
47415
|
+
writeFileSync as writeFileSync8
|
|
47416
|
+
} from "node:fs";
|
|
47417
|
+
import { dirname as dirname9, join as join18 } from "node:path";
|
|
47418
|
+
var SKILL_MARKER = "<!-- managed by the Open Artifacts bus installer: edits are replaced on reinstall. -->";
|
|
47419
|
+
var CODEX_BEGIN = "<!-- BEGIN Open Artifacts skill (managed): edits inside are replaced on reinstall. -->";
|
|
47420
|
+
var CODEX_END = "<!-- END Open Artifacts skill -->";
|
|
47421
|
+
var MAX_SKILL_BYTES = 256 * 1024;
|
|
47422
|
+
var env = (deps) => deps.env ?? {};
|
|
47423
|
+
var skillDir = (deps, h) => {
|
|
47424
|
+
const e = env(deps);
|
|
47425
|
+
const opencode = e.OPENCODE_CONFIG_DIR ?? join18(e.XDG_CONFIG_HOME ?? join18(deps.home, ".config"), "opencode");
|
|
47426
|
+
const agents = join18(deps.home, ".agents", "skills");
|
|
47427
|
+
return {
|
|
47428
|
+
claude: join18(e.CLAUDE_CONFIG_DIR ?? join18(deps.home, ".claude"), "skills"),
|
|
47429
|
+
opencode: join18(opencode, "skills"),
|
|
47430
|
+
pi: agents,
|
|
47431
|
+
omp: agents,
|
|
47432
|
+
codex: join18(codexHome2(deps.home, e), "AGENTS.md")
|
|
47433
|
+
}[h];
|
|
47434
|
+
};
|
|
47435
|
+
var skillFolder = (text3) => {
|
|
47436
|
+
const m = /^---\n([\s\S]*?)\n---\n/.exec(text3);
|
|
47437
|
+
const name = m?.[1] ? /^name:\s*"?([^"\n]+)"?\s*$/m.exec(m[1])?.[1] : void 0;
|
|
47438
|
+
return name && /^[a-z0-9][a-z0-9-]{0,62}$/.test(name) ? name : void 0;
|
|
47439
|
+
};
|
|
47440
|
+
var withMarker = (text3) => {
|
|
47441
|
+
const end = text3.startsWith("---\n") ? text3.indexOf("\n---\n", 3) : -1;
|
|
47442
|
+
if (end === -1) return `${text3.trimEnd()}
|
|
47443
|
+
|
|
47444
|
+
${SKILL_MARKER}
|
|
47445
|
+
`;
|
|
47446
|
+
const at = end + "\n---\n".length;
|
|
47447
|
+
return `${text3.slice(0, at)}${SKILL_MARKER}
|
|
47448
|
+
${text3.slice(at)}`;
|
|
47449
|
+
};
|
|
47450
|
+
var isOurs = (text3, folder) => {
|
|
47451
|
+
const t = text3.replace(/\r\n/g, "\n");
|
|
47452
|
+
const m = /^---\n[\s\S]*?\n---\n/.exec(t);
|
|
47453
|
+
if (!m) return false;
|
|
47454
|
+
const name = skillFolder(t);
|
|
47455
|
+
return name === folder && name.startsWith("open-artifacts") && t.slice(m[0].length).split("\n", 1)[0] === SKILL_MARKER;
|
|
47456
|
+
};
|
|
47457
|
+
var lineIndex = (lines, marker, from = 0) => {
|
|
47458
|
+
for (let i = from; i < lines.length; i++)
|
|
47459
|
+
if (lines[i]?.replace(/\r$/, "") === marker) return i;
|
|
47460
|
+
return -1;
|
|
47461
|
+
};
|
|
47462
|
+
var quotesMarker = (text3) => {
|
|
47463
|
+
const lines = text3.split("\n");
|
|
47464
|
+
return [SKILL_MARKER, CODEX_BEGIN, CODEX_END].some(
|
|
47465
|
+
(m) => lineIndex(lines, m) !== -1
|
|
47466
|
+
);
|
|
47467
|
+
};
|
|
47468
|
+
var lstatOk = (path) => {
|
|
47469
|
+
try {
|
|
47470
|
+
lstatSync10(path);
|
|
47471
|
+
return true;
|
|
47472
|
+
} catch {
|
|
47473
|
+
return false;
|
|
47474
|
+
}
|
|
47475
|
+
};
|
|
47476
|
+
var brokenLink = (path) => {
|
|
47477
|
+
try {
|
|
47478
|
+
return lstatSync10(path).isSymbolicLink() && !existsSync6(path);
|
|
47479
|
+
} catch {
|
|
47480
|
+
return false;
|
|
47481
|
+
}
|
|
47482
|
+
};
|
|
47483
|
+
async function fetchSkillText(doFetch, url2) {
|
|
47484
|
+
const r = await doFetch(url2, {
|
|
47485
|
+
headers: { accept: "text/markdown" },
|
|
47486
|
+
redirect: "error"
|
|
47487
|
+
});
|
|
47488
|
+
if (!r.ok) throw new Error(`${r.status} ${r.statusText}`);
|
|
47489
|
+
const type = r.headers.get("content-type") ?? "";
|
|
47490
|
+
if (!type.toLowerCase().startsWith("text/markdown"))
|
|
47491
|
+
throw new Error(`unexpected content-type: ${type || "none"}`);
|
|
47492
|
+
const declared = Number(r.headers.get("content-length"));
|
|
47493
|
+
if (Number.isFinite(declared) && declared > MAX_SKILL_BYTES) {
|
|
47494
|
+
await r.body?.cancel().catch(() => {
|
|
47495
|
+
});
|
|
47496
|
+
throw new Error("skill too large");
|
|
47497
|
+
}
|
|
47498
|
+
const chunks = [];
|
|
47499
|
+
let total = 0;
|
|
47500
|
+
const reader = r.body?.getReader();
|
|
47501
|
+
if (reader) {
|
|
47502
|
+
for (; ; ) {
|
|
47503
|
+
const { done, value } = await reader.read();
|
|
47504
|
+
if (done) break;
|
|
47505
|
+
total += value.byteLength;
|
|
47506
|
+
if (total > MAX_SKILL_BYTES) {
|
|
47507
|
+
await reader.cancel().catch(() => {
|
|
47508
|
+
});
|
|
47509
|
+
throw new Error("skill too large");
|
|
47510
|
+
}
|
|
47511
|
+
chunks.push(value);
|
|
47512
|
+
}
|
|
47513
|
+
}
|
|
47514
|
+
const text3 = new TextDecoder().decode(Buffer.concat(chunks));
|
|
47515
|
+
if (!text3.startsWith("---\nname: "))
|
|
47516
|
+
throw new Error("not a skill: no frontmatter");
|
|
47517
|
+
return text3;
|
|
47518
|
+
}
|
|
47519
|
+
var targetOf = (path) => {
|
|
47520
|
+
try {
|
|
47521
|
+
return lstatSync10(path).isSymbolicLink() ? realpathSync8(path) : path;
|
|
47522
|
+
} catch {
|
|
47523
|
+
return path;
|
|
47524
|
+
}
|
|
47525
|
+
};
|
|
47526
|
+
var seq = 0;
|
|
47527
|
+
var writeAtomic2 = (path, text3) => {
|
|
47528
|
+
mkdirSync10(dirname9(path), { recursive: true });
|
|
47529
|
+
const tmp = `${path}.oa-${process.pid}-${seq++}.tmp`;
|
|
47530
|
+
try {
|
|
47531
|
+
writeFileSync8(tmp, text3);
|
|
47532
|
+
renameSync10(tmp, path);
|
|
47533
|
+
} catch (e) {
|
|
47534
|
+
try {
|
|
47535
|
+
rmSync7(tmp, { force: true });
|
|
47536
|
+
} catch {
|
|
47537
|
+
}
|
|
47538
|
+
throw e;
|
|
47539
|
+
}
|
|
47540
|
+
};
|
|
47541
|
+
var withCodexBlock = (existing, text3) => {
|
|
47542
|
+
const lines = existing.split("\n");
|
|
47543
|
+
const start = lineIndex(lines, CODEX_BEGIN);
|
|
47544
|
+
const end = lineIndex(lines, CODEX_END, start + 1);
|
|
47545
|
+
const block = [CODEX_BEGIN, ...text3.trimEnd().split("\n"), CODEX_END];
|
|
47546
|
+
if (start === -1) {
|
|
47547
|
+
const head = existing.trimEnd();
|
|
47548
|
+
return `${head}${head ? "\n\n" : ""}${block.join("\n")}
|
|
47549
|
+
`;
|
|
47550
|
+
}
|
|
47551
|
+
if (end === -1) throw new Error("unterminated");
|
|
47552
|
+
return [...lines.slice(0, start), ...block, ...lines.slice(end + 1)].join(
|
|
47553
|
+
"\n"
|
|
47554
|
+
);
|
|
47555
|
+
};
|
|
47556
|
+
var codexBroken = (text3) => {
|
|
47557
|
+
const lines = text3.split("\n");
|
|
47558
|
+
const start = lineIndex(lines, CODEX_BEGIN);
|
|
47559
|
+
return start !== -1 && lineIndex(lines, CODEX_END, start + 1) === -1;
|
|
47560
|
+
};
|
|
47561
|
+
async function installSkill(deps, origin, harnesses) {
|
|
47562
|
+
const written = [];
|
|
47563
|
+
const notes = [];
|
|
47564
|
+
if (harnesses.length === 0) return { written, notes };
|
|
47565
|
+
if (!origin) {
|
|
47566
|
+
notes.push(
|
|
47567
|
+
"Skipped the skill file: this machine isn't approved on an instance yet. Rerun the install once it is."
|
|
47568
|
+
);
|
|
47569
|
+
return { written, notes };
|
|
47570
|
+
}
|
|
47571
|
+
for (const h of harnesses) {
|
|
47572
|
+
const url2 = `${origin}/skill.md?harness=${h}`;
|
|
47573
|
+
let text3;
|
|
47574
|
+
try {
|
|
47575
|
+
text3 = await deps.fetchSkill(url2);
|
|
47576
|
+
} catch {
|
|
47577
|
+
return { written, notes, failedUrl: url2 };
|
|
47578
|
+
}
|
|
47579
|
+
const folder = skillFolder(text3);
|
|
47580
|
+
if (!folder?.startsWith("open-artifacts") || quotesMarker(text3))
|
|
47581
|
+
return {
|
|
47582
|
+
written,
|
|
47583
|
+
notes,
|
|
47584
|
+
failedUrl: url2
|
|
47585
|
+
};
|
|
47586
|
+
const base3 = skillDir(deps, h);
|
|
47587
|
+
const path = harnessSkills[h].agentsMd ? base3 : join18(base3, folder, "SKILL.md");
|
|
47588
|
+
if (brokenLink(path)) {
|
|
47589
|
+
notes.push(`Left ${path} alone: it is a broken symlink.`);
|
|
47590
|
+
continue;
|
|
47591
|
+
}
|
|
47592
|
+
const writing = targetOf(path);
|
|
47593
|
+
try {
|
|
47594
|
+
if (harnessSkills[h].agentsMd) {
|
|
47595
|
+
const before = existsSync6(writing) ? readFileSync16(writing, "utf8") : "";
|
|
47596
|
+
if (codexBroken(before)) {
|
|
47597
|
+
notes.push(
|
|
47598
|
+
`Left ${writing} alone: its Open Artifacts block has no END marker. Fix or remove the block, then rerun the install.`
|
|
47599
|
+
);
|
|
47600
|
+
continue;
|
|
47601
|
+
}
|
|
47602
|
+
writeAtomic2(writing, withCodexBlock(before, text3));
|
|
47603
|
+
} else {
|
|
47604
|
+
if (existsSync6(writing) && !isOurs(readFileSync16(writing, "utf8"), folder)) {
|
|
47605
|
+
notes.push(
|
|
47606
|
+
`Left ${writing} alone: it has no Open Artifacts marker, so it is not ours to replace.`
|
|
47607
|
+
);
|
|
47608
|
+
continue;
|
|
47609
|
+
}
|
|
47610
|
+
writeAtomic2(writing, withMarker(text3));
|
|
47611
|
+
}
|
|
47612
|
+
written.push(path);
|
|
47613
|
+
} catch (e) {
|
|
47614
|
+
notes.push(
|
|
47615
|
+
`Could not write ${writing}: ${e instanceof Error ? e.message : String(e)}`
|
|
47616
|
+
);
|
|
47617
|
+
}
|
|
47618
|
+
}
|
|
47619
|
+
return { written, notes };
|
|
47620
|
+
}
|
|
47621
|
+
var uninstallSkill = (deps, harnesses = ["claude", "opencode", "pi", "omp", "codex"]) => {
|
|
47622
|
+
const written = [];
|
|
47623
|
+
const notes = [];
|
|
47624
|
+
const seen2 = /* @__PURE__ */ new Set();
|
|
47625
|
+
const fail = (path, e) => notes.push(
|
|
47626
|
+
`Left ${path} alone: ${e instanceof Error ? e.message : String(e)}`
|
|
47627
|
+
);
|
|
47628
|
+
for (const h of harnesses) {
|
|
47629
|
+
const base3 = skillDir(deps, h);
|
|
47630
|
+
if (seen2.has(base3)) continue;
|
|
47631
|
+
seen2.add(base3);
|
|
47632
|
+
if (harnessSkills[h].agentsMd) {
|
|
47633
|
+
try {
|
|
47634
|
+
if (brokenLink(base3) || !existsSync6(base3)) continue;
|
|
47635
|
+
const text3 = readFileSync16(base3, "utf8");
|
|
47636
|
+
if (codexBroken(text3)) {
|
|
47637
|
+
notes.push(
|
|
47638
|
+
`Left ${base3} alone: its Open Artifacts block has no END marker. Fix or remove the block, then rerun the install.`
|
|
47639
|
+
);
|
|
47640
|
+
continue;
|
|
47641
|
+
}
|
|
47642
|
+
const next = withCodexBlock(text3, "");
|
|
47643
|
+
const clean = next.split("\n").filter((l) => {
|
|
47644
|
+
const t = l.replace(/\r$/, "");
|
|
47645
|
+
return t !== CODEX_BEGIN && t !== CODEX_END;
|
|
47646
|
+
}).join("\n").trimEnd();
|
|
47647
|
+
if (clean) writeAtomic2(targetOf(base3), `${clean}
|
|
47648
|
+
`);
|
|
47649
|
+
else rmSync7(targetOf(base3), { force: true });
|
|
47650
|
+
written.push(base3);
|
|
47651
|
+
} catch (e) {
|
|
47652
|
+
fail(base3, e);
|
|
47653
|
+
}
|
|
47654
|
+
continue;
|
|
47655
|
+
}
|
|
47656
|
+
let entries;
|
|
47657
|
+
try {
|
|
47658
|
+
if (!existsSync6(base3)) continue;
|
|
47659
|
+
entries = readdirSync4(base3);
|
|
47660
|
+
} catch (e) {
|
|
47661
|
+
fail(base3, e);
|
|
47662
|
+
continue;
|
|
47663
|
+
}
|
|
47664
|
+
for (const entry of entries) {
|
|
47665
|
+
const dir = join18(base3, entry);
|
|
47666
|
+
const file2 = join18(dir, "SKILL.md");
|
|
47667
|
+
try {
|
|
47668
|
+
const st = lstatSync10(dir);
|
|
47669
|
+
if (st.isSymbolicLink()) {
|
|
47670
|
+
if (existsSync6(file2))
|
|
47671
|
+
notes.push(`Left ${dir} alone: it is a symlinked folder.`);
|
|
47672
|
+
continue;
|
|
47673
|
+
}
|
|
47674
|
+
if (!st.isDirectory() || !lstatOk(file2)) continue;
|
|
47675
|
+
if (!isOurs(readFileSync16(targetOf(file2), "utf8"), entry)) {
|
|
47676
|
+
notes.push(
|
|
47677
|
+
`Left ${file2} alone: it is not an Open Artifacts skill file.`
|
|
47678
|
+
);
|
|
47679
|
+
continue;
|
|
47680
|
+
}
|
|
47681
|
+
rmSync7(targetOf(file2), { force: true });
|
|
47682
|
+
try {
|
|
47683
|
+
rmdirSync(dir);
|
|
47684
|
+
} catch {
|
|
47685
|
+
}
|
|
47686
|
+
written.push(file2);
|
|
47687
|
+
} catch (e) {
|
|
47688
|
+
fail(file2, e);
|
|
47689
|
+
}
|
|
47690
|
+
}
|
|
47691
|
+
}
|
|
47692
|
+
return { written, notes };
|
|
47693
|
+
};
|
|
47694
|
+
|
|
47404
47695
|
// src/commands/install.ts
|
|
47405
47696
|
var CODE_RETRY_MS = [2e3, 4e3, 8e3];
|
|
47406
47697
|
var DAEMON_WAIT_MS = 1e4;
|
|
@@ -47481,7 +47772,7 @@ async function loginStep(ctx, opts) {
|
|
|
47481
47772
|
ctx,
|
|
47482
47773
|
c.approved(result.label),
|
|
47483
47774
|
c.tokenSaved(
|
|
47484
|
-
tilde(ctx,
|
|
47775
|
+
tilde(ctx, join19(ctx.home, "machine.json")),
|
|
47485
47776
|
result.machineToken
|
|
47486
47777
|
),
|
|
47487
47778
|
c.connected(originOf2(result.hub)),
|
|
@@ -47509,7 +47800,7 @@ async function loginStep(ctx, opts) {
|
|
|
47509
47800
|
live.clear();
|
|
47510
47801
|
}
|
|
47511
47802
|
}
|
|
47512
|
-
async function harnessesStep(ctx) {
|
|
47803
|
+
async function harnessesStep(ctx, hub) {
|
|
47513
47804
|
const c = ctx.copy;
|
|
47514
47805
|
const out = await installAdapters({
|
|
47515
47806
|
home: ctx.userHome,
|
|
@@ -47530,8 +47821,33 @@ async function harnessesStep(ctx) {
|
|
|
47530
47821
|
say(ctx, await skippedLines(ctx, s.harness, s.reason));
|
|
47531
47822
|
if (out.installed.includes("opencode"))
|
|
47532
47823
|
say(ctx, out.opencodeRestarted ? c.restarted() : c.opencodeNotRunning());
|
|
47824
|
+
const skill = await installSkill(
|
|
47825
|
+
{
|
|
47826
|
+
home: ctx.userHome,
|
|
47827
|
+
env: ctx.env,
|
|
47828
|
+
fetchSkill: (url2) => fetchSkillText(ctx.fetch, url2)
|
|
47829
|
+
},
|
|
47830
|
+
hub ? originOf2(hub) : machineOrigin(ctx),
|
|
47831
|
+
out.installed
|
|
47832
|
+
);
|
|
47833
|
+
for (const n of skill.notes) say(ctx, [n]);
|
|
47834
|
+
if (skill.failedUrl) skillFailure.set(ctx, skill.failedUrl);
|
|
47835
|
+
return true;
|
|
47836
|
+
}
|
|
47837
|
+
var skillFailure = /* @__PURE__ */ new WeakMap();
|
|
47838
|
+
function reportSkillFailure(ctx) {
|
|
47839
|
+
const url2 = skillFailure.get(ctx);
|
|
47840
|
+
if (!url2) return false;
|
|
47841
|
+
sayErr(ctx, [
|
|
47842
|
+
`Could not fetch the skill from ${url2}.`,
|
|
47843
|
+
`The bus tools are set up. Rerun ${BUS_CMD} install to write the skill.`
|
|
47844
|
+
]);
|
|
47533
47845
|
return true;
|
|
47534
47846
|
}
|
|
47847
|
+
function machineOrigin(ctx) {
|
|
47848
|
+
const m = readMachine(ctx.home);
|
|
47849
|
+
return m.state === "ok" ? originOf2(m.hub) : void 0;
|
|
47850
|
+
}
|
|
47535
47851
|
async function skippedLines(ctx, h, reason) {
|
|
47536
47852
|
if (h !== "opencode") return ctx.copy.skipped(h, tildeReason(ctx, h, reason));
|
|
47537
47853
|
const v = await opencodeVersion(ctx.exec);
|
|
@@ -47545,7 +47861,7 @@ function shownSocket(ctx) {
|
|
|
47545
47861
|
const real2 = `${canonicalHome(ctx.home)}/`;
|
|
47546
47862
|
return tilde(
|
|
47547
47863
|
ctx,
|
|
47548
|
-
path.startsWith(real2) ?
|
|
47864
|
+
path.startsWith(real2) ? join19(ctx.home, path.slice(real2.length)) : path
|
|
47549
47865
|
);
|
|
47550
47866
|
}
|
|
47551
47867
|
async function waitForDaemon(ctx) {
|
|
@@ -47650,7 +47966,7 @@ var installSteps = (opts) => [
|
|
|
47650
47966
|
busBin: ctx.service.argv?.()
|
|
47651
47967
|
})
|
|
47652
47968
|
).includes("missing") ? "todo" : "done",
|
|
47653
|
-
apply: harnessesStep
|
|
47969
|
+
apply: (ctx) => harnessesStep(ctx, opts.hub)
|
|
47654
47970
|
},
|
|
47655
47971
|
{
|
|
47656
47972
|
name: "daemon",
|
|
@@ -47681,10 +47997,11 @@ async function install2(opts, ctx) {
|
|
|
47681
47997
|
return results.every((r) => r.state === "done") ? 0 : 1;
|
|
47682
47998
|
}
|
|
47683
47999
|
const ok = await runSteps(steps, ctx, {
|
|
47684
|
-
path:
|
|
48000
|
+
path: join19(ctx.home, "install.json"),
|
|
47685
48001
|
now: ctx.now
|
|
47686
48002
|
});
|
|
47687
|
-
|
|
48003
|
+
const skillFailed = reportSkillFailure(ctx);
|
|
48004
|
+
return ok && !skillFailed ? 0 : 1;
|
|
47688
48005
|
}
|
|
47689
48006
|
|
|
47690
48007
|
// src/commands/status.ts
|
|
@@ -47829,7 +48146,7 @@ async function healthz(ctx, hub) {
|
|
|
47829
48146
|
function claudeIsolates(path) {
|
|
47830
48147
|
let text3;
|
|
47831
48148
|
try {
|
|
47832
|
-
text3 =
|
|
48149
|
+
text3 = readFileSync17(path, "utf8");
|
|
47833
48150
|
} catch {
|
|
47834
48151
|
return void 0;
|
|
47835
48152
|
}
|
|
@@ -47896,7 +48213,7 @@ async function doctor(ctx) {
|
|
|
47896
48213
|
const node2 = ctx.nodeVersion.replace(/^v/, "");
|
|
47897
48214
|
if (Number(node2.split(".")[0]) >= MIN_NODE) pass(c.nodeOk(node2));
|
|
47898
48215
|
else fail(c.nodeOld(node2));
|
|
47899
|
-
const machineFile = tilde(ctx,
|
|
48216
|
+
const machineFile = tilde(ctx, join20(ctx.home, "machine.json"));
|
|
47900
48217
|
const m = readMachine(ctx.home);
|
|
47901
48218
|
if (m.state !== "ok") fail(c.noCredentials(machineFile));
|
|
47902
48219
|
else if (m.revoked) fail(c.revokedCheck());
|
|
@@ -47966,8 +48283,8 @@ async function doctor(ctx) {
|
|
|
47966
48283
|
if (wiring[h] === "configured") pass(c.wired(h, version2));
|
|
47967
48284
|
else fail(c.notWired(h));
|
|
47968
48285
|
if (h === "claude") {
|
|
47969
|
-
const settings =
|
|
47970
|
-
ctx.env.CLAUDE_CONFIG_DIR ??
|
|
48286
|
+
const settings = join20(
|
|
48287
|
+
ctx.env.CLAUDE_CONFIG_DIR ?? join20(ctx.userHome, ".claude"),
|
|
47971
48288
|
"settings.json"
|
|
47972
48289
|
);
|
|
47973
48290
|
const isolates = claudeIsolates(settings);
|
|
@@ -47992,13 +48309,13 @@ async function doctor(ctx) {
|
|
|
47992
48309
|
}
|
|
47993
48310
|
|
|
47994
48311
|
// src/commands/global.ts
|
|
47995
|
-
import { realpathSync as
|
|
48312
|
+
import { realpathSync as realpathSync9, statSync as statSync10 } from "node:fs";
|
|
47996
48313
|
import { resolve as resolve6 } from "node:path";
|
|
47997
48314
|
function shown(ctx, path) {
|
|
47998
48315
|
const t = tilde(ctx, path);
|
|
47999
48316
|
if (t !== path) return t;
|
|
48000
48317
|
try {
|
|
48001
|
-
return tilde({ userHome:
|
|
48318
|
+
return tilde({ userHome: realpathSync9(ctx.userHome) }, path);
|
|
48002
48319
|
} catch {
|
|
48003
48320
|
return path;
|
|
48004
48321
|
}
|
|
@@ -48051,14 +48368,14 @@ async function global(opts, ctx) {
|
|
|
48051
48368
|
}
|
|
48052
48369
|
|
|
48053
48370
|
// src/commands/logs.ts
|
|
48054
|
-
import { readFileSync as
|
|
48055
|
-
import { join as
|
|
48371
|
+
import { readFileSync as readFileSync18 } from "node:fs";
|
|
48372
|
+
import { join as join21 } from "node:path";
|
|
48056
48373
|
var TAIL = 50;
|
|
48057
48374
|
async function logs(ctx) {
|
|
48058
|
-
const path =
|
|
48375
|
+
const path = join21(ctx.home, "logs", "daemon.log");
|
|
48059
48376
|
let text3;
|
|
48060
48377
|
try {
|
|
48061
|
-
text3 =
|
|
48378
|
+
text3 = readFileSync18(path, "utf8");
|
|
48062
48379
|
} catch {
|
|
48063
48380
|
say(ctx, ctx.copy.noLog(tilde(ctx, path)));
|
|
48064
48381
|
return 1;
|
|
@@ -48084,12 +48401,12 @@ async function mcp(harness, ctx, load = (h) => MCP_SERVER[h]()) {
|
|
|
48084
48401
|
}
|
|
48085
48402
|
|
|
48086
48403
|
// src/commands/uninstall.ts
|
|
48087
|
-
import { join as
|
|
48404
|
+
import { join as join23 } from "node:path";
|
|
48088
48405
|
|
|
48089
48406
|
// src/steps/purge.ts
|
|
48090
48407
|
init_src3();
|
|
48091
|
-
import { lstatSync as
|
|
48092
|
-
import { join as
|
|
48408
|
+
import { lstatSync as lstatSync11, readdirSync as readdirSync5, rmdirSync as rmdirSync2, rmSync as rmSync8 } from "node:fs";
|
|
48409
|
+
import { join as join22 } from "node:path";
|
|
48093
48410
|
var FILES = [
|
|
48094
48411
|
"machine.json",
|
|
48095
48412
|
"install.json",
|
|
@@ -48121,16 +48438,16 @@ var FOLDERS = [
|
|
|
48121
48438
|
];
|
|
48122
48439
|
function kind(path) {
|
|
48123
48440
|
try {
|
|
48124
|
-
const st =
|
|
48441
|
+
const st = lstatSync11(path);
|
|
48125
48442
|
return st.isDirectory() ? "dir" : st.isSocket() ? "socket" : "other";
|
|
48126
48443
|
} catch {
|
|
48127
48444
|
return void 0;
|
|
48128
48445
|
}
|
|
48129
48446
|
}
|
|
48130
|
-
var remove2 = (path, k) =>
|
|
48447
|
+
var remove2 = (path, k) => rmSync8(path, { recursive: k === "dir", force: true });
|
|
48131
48448
|
var rmdirIfEmpty = (path) => {
|
|
48132
48449
|
try {
|
|
48133
|
-
|
|
48450
|
+
rmdirSync2(path);
|
|
48134
48451
|
return true;
|
|
48135
48452
|
} catch {
|
|
48136
48453
|
return false;
|
|
@@ -48138,14 +48455,14 @@ var rmdirIfEmpty = (path) => {
|
|
|
48138
48455
|
};
|
|
48139
48456
|
function purgeShort(dir, removed) {
|
|
48140
48457
|
if (kind(dir) !== "dir" || unsafeSocketDir(dir)) return;
|
|
48141
|
-
const ret =
|
|
48458
|
+
const ret = join22(dir, "claude-return");
|
|
48142
48459
|
for (const [d, ours2] of [
|
|
48143
48460
|
[ret, (_n, p) => kind(p) === "socket"],
|
|
48144
48461
|
[dir, (n) => /^daemon\.sock(\.keep-\d+)?$/.test(n)]
|
|
48145
48462
|
]) {
|
|
48146
48463
|
if (kind(d) !== "dir") continue;
|
|
48147
|
-
for (const name of
|
|
48148
|
-
const path =
|
|
48464
|
+
for (const name of readdirSync5(d)) {
|
|
48465
|
+
const path = join22(d, name);
|
|
48149
48466
|
const k = kind(path);
|
|
48150
48467
|
if (k === void 0 || k === "dir" || !ours2(name, path)) continue;
|
|
48151
48468
|
remove2(path, k);
|
|
@@ -48158,7 +48475,7 @@ function purgeShort(dir, removed) {
|
|
|
48158
48475
|
function purge(home2, opts) {
|
|
48159
48476
|
let entries;
|
|
48160
48477
|
try {
|
|
48161
|
-
entries =
|
|
48478
|
+
entries = readdirSync5(home2);
|
|
48162
48479
|
} catch {
|
|
48163
48480
|
return { removed: [], leftDir: false };
|
|
48164
48481
|
}
|
|
@@ -48170,21 +48487,21 @@ function purge(home2, opts) {
|
|
|
48170
48487
|
...FILES,
|
|
48171
48488
|
...entries.filter((n) => TEMP.some((re) => re.test(n)))
|
|
48172
48489
|
]) {
|
|
48173
|
-
const path =
|
|
48490
|
+
const path = join22(home2, name);
|
|
48174
48491
|
const k = kind(path);
|
|
48175
48492
|
if (k === void 0 || k === "dir") continue;
|
|
48176
48493
|
remove2(path, k);
|
|
48177
48494
|
removed.push(name);
|
|
48178
48495
|
}
|
|
48179
48496
|
for (const folder of FOLDERS) {
|
|
48180
|
-
const dir =
|
|
48497
|
+
const dir = join22(home2, folder.path);
|
|
48181
48498
|
if (kind(dir) !== "dir") continue;
|
|
48182
|
-
for (const name of
|
|
48183
|
-
const path =
|
|
48499
|
+
for (const name of readdirSync5(dir)) {
|
|
48500
|
+
const path = join22(dir, name);
|
|
48184
48501
|
const k = kind(path);
|
|
48185
48502
|
if (k === void 0 || !folder.ours(name, path)) continue;
|
|
48186
48503
|
remove2(path, k);
|
|
48187
|
-
removed.push(
|
|
48504
|
+
removed.push(join22(folder.path, name));
|
|
48188
48505
|
}
|
|
48189
48506
|
if (rmdirIfEmpty(dir)) removed.push(folder.path);
|
|
48190
48507
|
}
|
|
@@ -48215,6 +48532,14 @@ async function uninstall2(opts, ctx) {
|
|
|
48215
48532
|
codexApp: ctx.codexApp
|
|
48216
48533
|
});
|
|
48217
48534
|
if (r.removed.length > 0) say(ctx, c.removedFrom(r.removed));
|
|
48535
|
+
try {
|
|
48536
|
+
const skills = uninstallSkill({ home: ctx.userHome, env: ctx.env });
|
|
48537
|
+
for (const n of skills.notes) say(ctx, [n]);
|
|
48538
|
+
} catch (e) {
|
|
48539
|
+
say(ctx, [
|
|
48540
|
+
`Could not remove the skill files: ${e instanceof Error ? e.message : String(e)}`
|
|
48541
|
+
]);
|
|
48542
|
+
}
|
|
48218
48543
|
if (r.folderOnly.includes("opencode")) say(ctx, c.removedPluginFolder());
|
|
48219
48544
|
if (r.removed.length + r.folderOnly.length === 0) say(ctx, c.noneWired());
|
|
48220
48545
|
for (const s of r.skipped)
|
|
@@ -48228,7 +48553,7 @@ async function uninstall2(opts, ctx) {
|
|
|
48228
48553
|
r.opencodeRestarted ? c.restartedUnload() : c.opencodeNotRunningUnload()
|
|
48229
48554
|
);
|
|
48230
48555
|
if (!opts.purge) {
|
|
48231
|
-
say(ctx, "", c.kept(tilde(ctx,
|
|
48556
|
+
say(ctx, "", c.kept(tilde(ctx, join23(ctx.home, "machine.json"))));
|
|
48232
48557
|
return 0;
|
|
48233
48558
|
}
|
|
48234
48559
|
const home2 = tilde(ctx, ctx.home);
|
|
@@ -48239,7 +48564,7 @@ async function uninstall2(opts, ctx) {
|
|
|
48239
48564
|
} catch {
|
|
48240
48565
|
}
|
|
48241
48566
|
const out = purge(ctx.home, {
|
|
48242
|
-
isDefault: ctx.home ===
|
|
48567
|
+
isDefault: ctx.home === join23(ctx.userHome, ".oa-bus")
|
|
48243
48568
|
});
|
|
48244
48569
|
if ("refused" in out) {
|
|
48245
48570
|
sayErr(ctx, c.purgeRefused(home2));
|