@open-artifacts/bus 0.258.0 → 0.259.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 +105 -21
- package/assets/openclaw/index.js +6 -2
- package/assets/openclaw/package.json +1 -1
- package/dist/index.js +140 -29
- package/package.json +2 -2
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.259.0";
|
|
15
15
|
|
|
16
16
|
type Frame = Json & { type: string; id: string };
|
|
17
17
|
type Ctx = {
|
|
@@ -20,6 +20,10 @@ type Ctx = {
|
|
|
20
20
|
getSessionId(): string;
|
|
21
21
|
getSessionName?(): string | undefined;
|
|
22
22
|
};
|
|
23
|
+
ui?: {
|
|
24
|
+
getEditorText?(): string;
|
|
25
|
+
onTerminalInput?(handler: (data: string) => void): () => void;
|
|
26
|
+
};
|
|
23
27
|
/**
|
|
24
28
|
* omp only (Pi has none): the agent this session runs, set on every omp
|
|
25
29
|
* session (types.ts ExtensionAgentIdentity); `sub` for a subagent (task
|
|
@@ -1017,14 +1021,24 @@ function nameOf(title: string | undefined, kind: string): string {
|
|
|
1017
1021
|
return cut || kind;
|
|
1018
1022
|
}
|
|
1019
1023
|
|
|
1020
|
-
|
|
1024
|
+
// Pi's session manager flattens multiline names before storing them.
|
|
1025
|
+
const piTitle = (name: string | undefined) =>
|
|
1026
|
+
name?.replace(/[\r\n]+/g, " ").trim();
|
|
1027
|
+
|
|
1028
|
+
type Identity = {
|
|
1029
|
+
ref: string;
|
|
1030
|
+
cwd: string;
|
|
1031
|
+
name: string;
|
|
1032
|
+
kind: "pi" | "omp";
|
|
1033
|
+
nameChosen: boolean;
|
|
1034
|
+
};
|
|
1021
1035
|
type Link = {
|
|
1022
1036
|
ref: string;
|
|
1023
1037
|
welcome: Frame;
|
|
1024
1038
|
request: (frame: Json, timeoutMs?: number) => Promise<Frame>;
|
|
1025
1039
|
ack: (msgId: string) => void;
|
|
1026
1040
|
/** #1635: tell the daemon the session's new name; false when this daemon does not take it. */
|
|
1027
|
-
rename: (name: string) => boolean;
|
|
1041
|
+
rename: (name: string, chosen: boolean) => boolean;
|
|
1028
1042
|
/** #1856: this link's proof hash, to a daemon whose welcome listed `link`; true only when it bound it. */
|
|
1029
1043
|
prove: (hash: string) => Promise<boolean>;
|
|
1030
1044
|
closed: () => boolean;
|
|
@@ -1098,11 +1112,16 @@ function open(
|
|
|
1098
1112
|
// Fire-and-forget: the daemon answers an ack with nothing.
|
|
1099
1113
|
ack: (msgId) => write({ type: "ack", id: `ack-${++seq}`, msg_id: msgId }),
|
|
1100
1114
|
// Only to a daemon whose welcome listed `rename`: an older one has no such frame.
|
|
1101
|
-
rename: (name) => {
|
|
1115
|
+
rename: (name, chosen) => {
|
|
1102
1116
|
const caps = link.welcome.caps;
|
|
1103
1117
|
if (ended || !Array.isArray(caps) || !caps.includes("rename"))
|
|
1104
1118
|
return false;
|
|
1105
|
-
write({
|
|
1119
|
+
write({
|
|
1120
|
+
type: "rename",
|
|
1121
|
+
id: `rename-${++seq}`,
|
|
1122
|
+
name,
|
|
1123
|
+
...(chosen ? { name_chosen: true } : {}),
|
|
1124
|
+
});
|
|
1106
1125
|
return true;
|
|
1107
1126
|
},
|
|
1108
1127
|
prove: async (hash) => {
|
|
@@ -1195,6 +1214,7 @@ function open(
|
|
|
1195
1214
|
pid: process.pid,
|
|
1196
1215
|
cwd: id.cwd,
|
|
1197
1216
|
proposed_name: id.name,
|
|
1217
|
+
...(id.nameChosen ? { name_chosen: true } : {}),
|
|
1198
1218
|
// #1295: this asset decodes away rows and the new refusals.
|
|
1199
1219
|
// #1525: and a config file that is pending approval.
|
|
1200
1220
|
// #1635: and may send a rename.
|
|
@@ -1580,10 +1600,11 @@ export default function oaBus(pi: Pi): void {
|
|
|
1580
1600
|
// Renamed while this hello was in flight (#1635).
|
|
1581
1601
|
if (
|
|
1582
1602
|
identity.kind !== "omp" &&
|
|
1583
|
-
identity.name !== id.name
|
|
1584
|
-
|
|
1603
|
+
(identity.name !== id.name ||
|
|
1604
|
+
identity.nameChosen !== id.nameChosen) &&
|
|
1605
|
+
(identity.name !== identity.kind || identity.nameChosen)
|
|
1585
1606
|
)
|
|
1586
|
-
l.rename(identity.name);
|
|
1607
|
+
l.rename(identity.name, identity.nameChosen);
|
|
1587
1608
|
return l;
|
|
1588
1609
|
},
|
|
1589
1610
|
(e: unknown) => {
|
|
@@ -1597,11 +1618,19 @@ export default function oaBus(pi: Pi): void {
|
|
|
1597
1618
|
|
|
1598
1619
|
const identityOf = (ctx: Ctx): Identity => {
|
|
1599
1620
|
const kind = ctx.agent !== undefined ? "omp" : "pi";
|
|
1621
|
+
const ref = ctx.sessionManager.getSessionId();
|
|
1622
|
+
const name = nameOf(ctx.sessionManager.getSessionName?.(), "");
|
|
1600
1623
|
return {
|
|
1601
|
-
ref
|
|
1624
|
+
ref,
|
|
1602
1625
|
cwd: ctx.cwd,
|
|
1603
|
-
name:
|
|
1626
|
+
name: name || kind,
|
|
1604
1627
|
kind,
|
|
1628
|
+
nameChosen:
|
|
1629
|
+
name !== "" &&
|
|
1630
|
+
kind === "pi" &&
|
|
1631
|
+
identity?.ref === ref &&
|
|
1632
|
+
identity.name === name &&
|
|
1633
|
+
identity.nameChosen,
|
|
1605
1634
|
};
|
|
1606
1635
|
};
|
|
1607
1636
|
|
|
@@ -1612,11 +1641,8 @@ export default function oaBus(pi: Pi): void {
|
|
|
1612
1641
|
*/
|
|
1613
1642
|
const subagent = (ctx: Ctx | undefined) => ctx?.agent?.kind === "sub";
|
|
1614
1643
|
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
* per change; nothing for the fallback name. The identity carries the name,
|
|
1618
|
-
* so a reconnect's hello proposes the new one.
|
|
1619
|
-
*/
|
|
1644
|
+
let stopWatchingName: (() => void) | undefined;
|
|
1645
|
+
let submittedName: { ref: string; name: string } | undefined;
|
|
1620
1646
|
const renamed = (ctx: Ctx) => {
|
|
1621
1647
|
if (stopped || !identity) return;
|
|
1622
1648
|
// omp titles a session itself ("auto") after its first message, and its
|
|
@@ -1624,13 +1650,53 @@ export default function oaBus(pi: Pi): void {
|
|
|
1624
1650
|
// so omp never renames on the hub. (pi has no auto titles.)
|
|
1625
1651
|
if (identity.kind === "omp") return;
|
|
1626
1652
|
const id = identityOf(ctx);
|
|
1627
|
-
if (id.ref !== identity.ref
|
|
1628
|
-
|
|
1629
|
-
|
|
1653
|
+
if (id.ref !== identity.ref) return;
|
|
1654
|
+
if (
|
|
1655
|
+
submittedName?.ref === id.ref &&
|
|
1656
|
+
submittedName.name === ctx.sessionManager.getSessionName?.()
|
|
1657
|
+
)
|
|
1658
|
+
id.nameChosen = true;
|
|
1659
|
+
if (id.name === identity.name && id.nameChosen === identity.nameChosen)
|
|
1660
|
+
return;
|
|
1661
|
+
identity = id;
|
|
1662
|
+
if (id.name === id.kind && !id.nameChosen) return;
|
|
1630
1663
|
// An open link tells the daemon now; a daemon without the cap, or no
|
|
1631
1664
|
// link, learns it from the next hello.
|
|
1632
1665
|
if (current && !current.closed() && current.ref === id.ref)
|
|
1633
|
-
current.rename(id.name);
|
|
1666
|
+
current.rename(id.name, id.nameChosen);
|
|
1667
|
+
};
|
|
1668
|
+
|
|
1669
|
+
// Pi handles the built-in /name in the editor before emitting extension
|
|
1670
|
+
// input events. Its metadata event is also emitted by setSessionName.
|
|
1671
|
+
const watchNameCommand = (ctx: Ctx) => {
|
|
1672
|
+
const ui = ctx.ui;
|
|
1673
|
+
return ui?.onTerminalInput?.((data) => {
|
|
1674
|
+
// Enter and keypad Enter in Pi's legacy and Kitty keyboard modes.
|
|
1675
|
+
if (
|
|
1676
|
+
data !== "\r" &&
|
|
1677
|
+
data !== "\n" &&
|
|
1678
|
+
data !== "\x1bOM" &&
|
|
1679
|
+
!(
|
|
1680
|
+
data.startsWith("\x1b") &&
|
|
1681
|
+
/^\[(?:13|57414)(?:;1(?::[12])?)?u$/.test(data.slice(1))
|
|
1682
|
+
)
|
|
1683
|
+
)
|
|
1684
|
+
return;
|
|
1685
|
+
const text = ui.getEditorText?.()?.trim();
|
|
1686
|
+
if (!text?.startsWith("/name ")) return;
|
|
1687
|
+
const name = piTitle(text.slice(6));
|
|
1688
|
+
if (!name || !nameOf(name, "")) return;
|
|
1689
|
+
const before = ctx.sessionManager.getSessionName?.();
|
|
1690
|
+
const submission = { ref: ctx.sessionManager.getSessionId(), name };
|
|
1691
|
+
submittedName = submission;
|
|
1692
|
+
queueMicrotask(() => {
|
|
1693
|
+
if (submittedName !== submission) return;
|
|
1694
|
+
// The editor applies /name synchronously. Other extensions can delay
|
|
1695
|
+
// delivery of session_info_changed.
|
|
1696
|
+
if (ctx.sessionManager.getSessionName?.() !== before) renamed(ctx);
|
|
1697
|
+
submittedName = undefined;
|
|
1698
|
+
});
|
|
1699
|
+
});
|
|
1634
1700
|
};
|
|
1635
1701
|
pi.on("session_info_changed", (_event, ctx) => {
|
|
1636
1702
|
if (!subagent(ctx)) renamed(ctx);
|
|
@@ -1648,15 +1714,30 @@ export default function oaBus(pi: Pi): void {
|
|
|
1648
1714
|
retryProof();
|
|
1649
1715
|
});
|
|
1650
1716
|
|
|
1651
|
-
pi.on("session_start", async (
|
|
1717
|
+
pi.on("session_start", async (event, ctx) => {
|
|
1652
1718
|
if (subagent(ctx)) return;
|
|
1653
1719
|
stopped = false;
|
|
1654
1720
|
// The entry works unlinked: no header until this session's link is bound.
|
|
1655
1721
|
identity = identityOf(ctx);
|
|
1722
|
+
stopWatchingName?.();
|
|
1723
|
+
stopWatchingName = undefined;
|
|
1724
|
+
if (identity.kind === "pi") {
|
|
1725
|
+
if ((event as { reason?: string }).reason === "startup") {
|
|
1726
|
+
let startName: string | undefined;
|
|
1727
|
+
const argv = process.argv.slice(2);
|
|
1728
|
+
for (let i = 0; i < argv.length && argv[i] !== "--"; i++) {
|
|
1729
|
+
if (argv[i] === "--name" || argv[i] === "-n") startName = argv[++i];
|
|
1730
|
+
}
|
|
1731
|
+
const name = piTitle(startName);
|
|
1732
|
+
if (nameOf(name, "") && name === ctx.sessionManager.getSessionName?.())
|
|
1733
|
+
identity.nameChosen = true;
|
|
1734
|
+
}
|
|
1735
|
+
stopWatchingName = watchNameCommand(ctx);
|
|
1736
|
+
}
|
|
1656
1737
|
register();
|
|
1657
1738
|
if (identity.kind === "omp" && ctx.mode === "tui") ompWrapOn();
|
|
1658
1739
|
// Pi is reachable while this link is open; a daemon that is down is retried.
|
|
1659
|
-
await ensure(
|
|
1740
|
+
await ensure(identity).catch(reconnect);
|
|
1660
1741
|
});
|
|
1661
1742
|
// omp's /new, /resume and fork keep the process and emit only these two, no
|
|
1662
1743
|
// shutdown or start: a new session id gets a fresh link and a fresh proof.
|
|
@@ -1681,6 +1762,9 @@ export default function oaBus(pi: Pi): void {
|
|
|
1681
1762
|
pi.on("session_shutdown", (_event, ctx) => {
|
|
1682
1763
|
if (subagent(ctx)) return;
|
|
1683
1764
|
stopped = true;
|
|
1765
|
+
stopWatchingName?.();
|
|
1766
|
+
stopWatchingName = undefined;
|
|
1767
|
+
submittedName = undefined;
|
|
1684
1768
|
identity = identity ?? identityOf(ctx);
|
|
1685
1769
|
dropHeader();
|
|
1686
1770
|
ompWrap?.restore();
|
package/assets/openclaw/index.js
CHANGED
|
@@ -27929,7 +27929,7 @@ var base2 = { v: external_exports.literal(V), id: external_exports.string().min(
|
|
|
27929
27929
|
var late = { late: external_exports.array(external_exports.string().min(1)).optional() };
|
|
27930
27930
|
var isWellFormed2 = (s) => s.isWellFormed();
|
|
27931
27931
|
var WELL_FORMED = { message: "text is not well-formed unicode" };
|
|
27932
|
-
var CLIENT_VERSION = true ? "0.
|
|
27932
|
+
var CLIENT_VERSION = true ? "0.259.0" : "0.0.0";
|
|
27933
27933
|
var clientVersion = {
|
|
27934
27934
|
client_version: external_exports.string().min(1).max(64).optional()
|
|
27935
27935
|
};
|
|
@@ -27995,6 +27995,8 @@ var Hello2 = external_exports.object({
|
|
|
27995
27995
|
*/
|
|
27996
27996
|
cwd: external_exports.string().min(1).max(4096).optional(),
|
|
27997
27997
|
proposed_name: external_exports.string().min(1).max(64).refine(isWellFormed2, WELL_FORMED).optional(),
|
|
27998
|
+
/** Pi observed a person choose the proposed name. */
|
|
27999
|
+
name_chosen: external_exports.literal(true).optional(),
|
|
27998
28000
|
/** What this adapter can decode (ADAPTER_CAPS); absent means none. */
|
|
27999
28001
|
caps: external_exports.array(external_exports.string().max(32)).max(16).optional(),
|
|
28000
28002
|
/**
|
|
@@ -28087,7 +28089,9 @@ var Rename2 = external_exports.object({
|
|
|
28087
28089
|
...base2,
|
|
28088
28090
|
...optIn,
|
|
28089
28091
|
type: external_exports.literal("rename"),
|
|
28090
|
-
name: external_exports.string().min(1).max(64).refine(isWellFormed2, WELL_FORMED)
|
|
28092
|
+
name: external_exports.string().min(1).max(64).refine(isWellFormed2, WELL_FORMED),
|
|
28093
|
+
/** Pi observed a person choose this name. */
|
|
28094
|
+
name_chosen: external_exports.literal(true).optional()
|
|
28091
28095
|
});
|
|
28092
28096
|
var Follow2 = external_exports.object({
|
|
28093
28097
|
...base2,
|
package/dist/index.js
CHANGED
|
@@ -23690,7 +23690,7 @@ var init_frames = __esm({
|
|
|
23690
23690
|
late = { late: external_exports.array(external_exports.string().min(1)).optional() };
|
|
23691
23691
|
isWellFormed2 = (s) => s.isWellFormed();
|
|
23692
23692
|
WELL_FORMED = { message: "text is not well-formed unicode" };
|
|
23693
|
-
CLIENT_VERSION = true ? "0.
|
|
23693
|
+
CLIENT_VERSION = true ? "0.259.0" : "0.0.0";
|
|
23694
23694
|
clientVersion = {
|
|
23695
23695
|
client_version: external_exports.string().min(1).max(64).optional()
|
|
23696
23696
|
};
|
|
@@ -23758,6 +23758,8 @@ var init_frames = __esm({
|
|
|
23758
23758
|
*/
|
|
23759
23759
|
cwd: external_exports.string().min(1).max(4096).optional(),
|
|
23760
23760
|
proposed_name: external_exports.string().min(1).max(64).refine(isWellFormed2, WELL_FORMED).optional(),
|
|
23761
|
+
/** Pi observed a person choose the proposed name. */
|
|
23762
|
+
name_chosen: external_exports.literal(true).optional(),
|
|
23761
23763
|
/** What this adapter can decode (ADAPTER_CAPS); absent means none. */
|
|
23762
23764
|
caps: external_exports.array(external_exports.string().max(32)).max(16).optional(),
|
|
23763
23765
|
/**
|
|
@@ -23851,7 +23853,9 @@ var init_frames = __esm({
|
|
|
23851
23853
|
...base2,
|
|
23852
23854
|
...optIn,
|
|
23853
23855
|
type: external_exports.literal("rename"),
|
|
23854
|
-
name: external_exports.string().min(1).max(64).refine(isWellFormed2, WELL_FORMED)
|
|
23856
|
+
name: external_exports.string().min(1).max(64).refine(isWellFormed2, WELL_FORMED),
|
|
23857
|
+
/** Pi observed a person choose this name. */
|
|
23858
|
+
name_chosen: external_exports.literal(true).optional()
|
|
23855
23859
|
});
|
|
23856
23860
|
Follow2 = external_exports.object({
|
|
23857
23861
|
...base2,
|
|
@@ -48111,6 +48115,7 @@ var codexThreadNames = (home2, opts = {}) => {
|
|
|
48111
48115
|
} catch {
|
|
48112
48116
|
}
|
|
48113
48117
|
}
|
|
48118
|
+
const firstNames = /* @__PURE__ */ new Map();
|
|
48114
48119
|
for (const line of text3.split("\n")) {
|
|
48115
48120
|
if (!line.trim()) continue;
|
|
48116
48121
|
let o;
|
|
@@ -48122,9 +48127,14 @@ var codexThreadNames = (home2, opts = {}) => {
|
|
|
48122
48127
|
if (typeof o !== "object" || o === null) continue;
|
|
48123
48128
|
const { id, thread_name } = o;
|
|
48124
48129
|
if (typeof id !== "string" || id === "") continue;
|
|
48125
|
-
|
|
48126
|
-
|
|
48127
|
-
|
|
48130
|
+
const name = typeof thread_name === "string" ? thread_name.trim() : "";
|
|
48131
|
+
if (name === "") {
|
|
48132
|
+
names2.delete(id);
|
|
48133
|
+
continue;
|
|
48134
|
+
}
|
|
48135
|
+
const first = firstNames.get(id) ?? name;
|
|
48136
|
+
firstNames.set(id, first);
|
|
48137
|
+
names2.set(id, { name, chosen: name !== first });
|
|
48128
48138
|
}
|
|
48129
48139
|
return names2;
|
|
48130
48140
|
};
|
|
@@ -51107,7 +51117,11 @@ function routeLocal(frame, hello, reply, ctx) {
|
|
|
51107
51117
|
code: "bad_frame",
|
|
51108
51118
|
message: "rename is not supported on this connection"
|
|
51109
51119
|
};
|
|
51110
|
-
ctx.renamed(
|
|
51120
|
+
ctx.renamed(
|
|
51121
|
+
ref,
|
|
51122
|
+
frame.name,
|
|
51123
|
+
hello.kind === "pi" && frame.name_chosen === true
|
|
51124
|
+
);
|
|
51111
51125
|
return void 0;
|
|
51112
51126
|
case "link_proof":
|
|
51113
51127
|
if (!hello.caps?.includes(ADAPTER_CAPS.link) || !ctx.linked)
|
|
@@ -56481,10 +56495,20 @@ async function runDaemon(deps2 = {}) {
|
|
|
56481
56495
|
rec.proposedName = name;
|
|
56482
56496
|
flushRename(rec);
|
|
56483
56497
|
};
|
|
56484
|
-
const renameFromAdapter = (rec, name) => {
|
|
56498
|
+
const renameFromAdapter = (rec, name, chosen) => {
|
|
56485
56499
|
const was = rec.sessionName ?? rec.proposedName;
|
|
56500
|
+
if (name === "" || rec.kind !== "codex" && name === rec.kind && !chosen)
|
|
56501
|
+
return;
|
|
56486
56502
|
rec.sessionName = name;
|
|
56487
|
-
if (name === was
|
|
56503
|
+
if (name === was) {
|
|
56504
|
+
if (chosen && !rec.nameChosen) {
|
|
56505
|
+
rec.nameChosen = true;
|
|
56506
|
+
if (rec.sentName === rec.proposedName && laneOfRef(rec.ref)?.nameChosen && rec.replaces === void 0 && !limited.has(rec.ref))
|
|
56507
|
+
announceUp(rec);
|
|
56508
|
+
}
|
|
56509
|
+
return;
|
|
56510
|
+
}
|
|
56511
|
+
rec.nameChosen = chosen;
|
|
56488
56512
|
rec.proposedName = name;
|
|
56489
56513
|
flushRename(rec);
|
|
56490
56514
|
};
|
|
@@ -56508,8 +56532,8 @@ async function runDaemon(deps2 = {}) {
|
|
|
56508
56532
|
agent_ref: rec.ref,
|
|
56509
56533
|
proposed_name: fitName(rec.proposedName, 64),
|
|
56510
56534
|
name_kind: "chosen",
|
|
56511
|
-
// #2311:
|
|
56512
|
-
...lane.nameChosen
|
|
56535
|
+
// #2311: the hub treats an omitted flag as chosen on a rename.
|
|
56536
|
+
...lane.nameChosen ? { name_chosen: rec.nameChosen === true } : {}
|
|
56513
56537
|
})) {
|
|
56514
56538
|
rec.sentName = rec.proposedName;
|
|
56515
56539
|
recent.push(now);
|
|
@@ -56915,13 +56939,15 @@ async function runDaemon(deps2 = {}) {
|
|
|
56915
56939
|
for (const g of guestSet.values())
|
|
56916
56940
|
if (g.instance === lane.name) g.sent = void 0;
|
|
56917
56941
|
};
|
|
56942
|
+
const codexNameChosen = (rec, title) => rec?.nameChosen === true || title?.chosen === true || rec?.sessionName !== void 0 && title !== void 0 && rec.sessionName !== title.name;
|
|
56918
56943
|
const renameCodexThreads = () => {
|
|
56919
56944
|
const live = agents.all().filter((a) => a.kind === "codex" && a.live);
|
|
56920
56945
|
if (!live.length) return;
|
|
56921
56946
|
const names2 = codexThreadNames(codexIndexHome);
|
|
56922
56947
|
for (const rec of live) {
|
|
56923
|
-
const
|
|
56924
|
-
if (
|
|
56948
|
+
const title = names2.get(rec.ref);
|
|
56949
|
+
if (title === void 0) continue;
|
|
56950
|
+
renameFromAdapter(rec, title.name, codexNameChosen(rec, title));
|
|
56925
56951
|
}
|
|
56926
56952
|
};
|
|
56927
56953
|
const syncClaude = (adoptPid) => {
|
|
@@ -57874,7 +57900,11 @@ async function runDaemon(deps2 = {}) {
|
|
|
57874
57900
|
conns.set(prev.ref, (conns.get(prev.ref) ?? 0) + 1);
|
|
57875
57901
|
if (!piLike(hello.kind)) tellOwed(prev.ref);
|
|
57876
57902
|
if (hello.proposed_name !== void 0 && prev.kind === "pi")
|
|
57877
|
-
renameFromAdapter(
|
|
57903
|
+
renameFromAdapter(
|
|
57904
|
+
prev,
|
|
57905
|
+
hello.proposed_name,
|
|
57906
|
+
hello.name_chosen === true
|
|
57907
|
+
);
|
|
57878
57908
|
return {
|
|
57879
57909
|
bus_name: prev.busName,
|
|
57880
57910
|
namespace: prev.namespace,
|
|
@@ -57898,8 +57928,10 @@ async function runDaemon(deps2 = {}) {
|
|
|
57898
57928
|
};
|
|
57899
57929
|
attested(pid);
|
|
57900
57930
|
noteFolder(cwd);
|
|
57901
|
-
const
|
|
57931
|
+
const codexTitle = hello.kind === "codex" ? codexThreadNames(codexIndexHome).get(hello.agent_ref) : void 0;
|
|
57932
|
+
const codexName = hello.kind === "codex" ? codexTitle?.name ?? prev?.sessionName : void 0;
|
|
57902
57933
|
const proposedName = codexName ?? hello.proposed_name ?? hello.agent_ref;
|
|
57934
|
+
const adapterChoseName = hello.kind === "codex" ? codexNameChosen(prev, codexTitle) : hello.kind === "pi" && (hello.name_chosen === true || prev?.nameChosen === true && prev.proposedName === proposedName);
|
|
57903
57935
|
const files2 = hello.kind === "claude-code" ? liveClaudeSessions(
|
|
57904
57936
|
claudeSessions,
|
|
57905
57937
|
(r) => r === hello.agent_ref ? pid : agents.byRef(r)?.pid
|
|
@@ -57930,7 +57962,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
57930
57962
|
// #2861: a lookup that misses keeps the start time the record had.
|
|
57931
57963
|
...mine ? { procStart: mine.procStart } : agyStart !== void 0 ? { procStart: agyStart } : prev?.pid === pid && prev.procStart !== void 0 ? { procStart: prev.procStart } : {},
|
|
57932
57964
|
...mine ? { sessionName: mine.name } : {},
|
|
57933
|
-
...mine?.nameChosen ? { nameChosen: true } : {},
|
|
57965
|
+
...mine?.nameChosen || adapterChoseName ? { nameChosen: true } : {},
|
|
57934
57966
|
// Claude's MCP server reconnects per tool call: the proof stays.
|
|
57935
57967
|
...carryLinks(instance, prev, old) !== void 0 ? { linkHashes: carryLinks(instance, prev, old) } : {},
|
|
57936
57968
|
...codexName !== void 0 ? { sessionName: codexName } : {},
|
|
@@ -58055,9 +58087,9 @@ async function runDaemon(deps2 = {}) {
|
|
|
58055
58087
|
sendLink(rec, hash2);
|
|
58056
58088
|
return true;
|
|
58057
58089
|
},
|
|
58058
|
-
renamed: (ref, name) => {
|
|
58090
|
+
renamed: (ref, name, chosen) => {
|
|
58059
58091
|
const rec = agents.byRef(ref);
|
|
58060
|
-
if (rec) renameFromAdapter(rec, name);
|
|
58092
|
+
if (rec) renameFromAdapter(rec, name, chosen);
|
|
58061
58093
|
},
|
|
58062
58094
|
ownerAwayUntil: awayUntil,
|
|
58063
58095
|
codexPendingLocal: (ref) => codexTaken.size(ref),
|
|
@@ -59704,6 +59736,14 @@ function copy(style, bus = BUS_CMD, approve) {
|
|
|
59704
59736
|
],
|
|
59705
59737
|
// agy S3, doctor: the one rule that lets a session start its watcher without asking.
|
|
59706
59738
|
agyRulePresent: () => done("Antigravity may start the bus watcher without asking"),
|
|
59739
|
+
agyToolsMissing: (rules2) => [
|
|
59740
|
+
warn(
|
|
59741
|
+
`Antigravity bus tool grants missing or restricted: ${rules2.join(", ")}`
|
|
59742
|
+
),
|
|
59743
|
+
next(
|
|
59744
|
+
`Run ${bus} to restore missing grants. Review any explicit ask or deny entries in Antigravity settings.`
|
|
59745
|
+
)
|
|
59746
|
+
],
|
|
59707
59747
|
agyRuleMissing: () => [
|
|
59708
59748
|
warn("Antigravity will ask before it starts the bus watcher"),
|
|
59709
59749
|
next(
|
|
@@ -61440,7 +61480,17 @@ function setJsoncValue(text3, path, value) {
|
|
|
61440
61480
|
return verified(insert(text3, path, value), path, value);
|
|
61441
61481
|
}
|
|
61442
61482
|
function removeJsoncValue(text3, path) {
|
|
61443
|
-
|
|
61483
|
+
const index = path.at(-1);
|
|
61484
|
+
const parent = path.slice(0, -1);
|
|
61485
|
+
const before = typeof index === "number" ? jsoncValue(text3, parent) : void 0;
|
|
61486
|
+
const out = removeAt(text3, path);
|
|
61487
|
+
if (Array.isArray(before))
|
|
61488
|
+
return verified(
|
|
61489
|
+
out,
|
|
61490
|
+
parent,
|
|
61491
|
+
before.filter((_, i) => i !== index)
|
|
61492
|
+
);
|
|
61493
|
+
return verified(out, path, void 0);
|
|
61444
61494
|
}
|
|
61445
61495
|
function jsoncValue(text3, path) {
|
|
61446
61496
|
let v = parseJsonc(text3, "config");
|
|
@@ -62012,6 +62062,7 @@ function agyPagesState(io, targets, which2) {
|
|
|
62012
62062
|
}
|
|
62013
62063
|
|
|
62014
62064
|
// src/steps/agy-rule.ts
|
|
62065
|
+
init_src3();
|
|
62015
62066
|
import { randomBytes as randomBytes9 } from "node:crypto";
|
|
62016
62067
|
import {
|
|
62017
62068
|
lstatSync as lstatSync11,
|
|
@@ -62027,6 +62078,19 @@ var agySettingsFile = (home2) => join32(home2, ".gemini", "antigravity-cli", "se
|
|
|
62027
62078
|
var agyRuleRecord = (busDir) => join32(busDir, "agy-rule.json");
|
|
62028
62079
|
var reEscape = (s) => s.replace(/[\\^$.*+?()[\]{}|]/g, "\\$&");
|
|
62029
62080
|
var agyWatchRule = (line) => `command(regex:^${reEscape(line)}$)`;
|
|
62081
|
+
var approvedTools = /* @__PURE__ */ new Set([
|
|
62082
|
+
"fetch",
|
|
62083
|
+
"follow",
|
|
62084
|
+
"following",
|
|
62085
|
+
"list_agents",
|
|
62086
|
+
"self",
|
|
62087
|
+
"send_message",
|
|
62088
|
+
"set_status",
|
|
62089
|
+
"unfollow"
|
|
62090
|
+
]);
|
|
62091
|
+
var toolRules = TOOLS.filter(({ name }) => approvedTools.has(name)).map(
|
|
62092
|
+
({ name }) => `mcp(oa_bus/${name})`
|
|
62093
|
+
);
|
|
62030
62094
|
var strings = (v) => Array.isArray(v) ? v.filter((x) => typeof x === "string") : [];
|
|
62031
62095
|
function readText(file2) {
|
|
62032
62096
|
try {
|
|
@@ -62061,6 +62125,8 @@ function readRecorded(busDir) {
|
|
|
62061
62125
|
return {
|
|
62062
62126
|
file: v.file,
|
|
62063
62127
|
rule: v.rule,
|
|
62128
|
+
previousRules: v.previousRules && strings(v.previousRules),
|
|
62129
|
+
toolRules: strings(v.toolRules).filter((r) => toolRules.includes(r)),
|
|
62064
62130
|
made: Array.isArray(v.made) ? v.made : []
|
|
62065
62131
|
};
|
|
62066
62132
|
} catch {
|
|
@@ -62104,8 +62170,16 @@ function installAgyRule(home2, busDir, line) {
|
|
|
62104
62170
|
const text3 = readText(file2) ?? "";
|
|
62105
62171
|
const old = readRecorded(busDir);
|
|
62106
62172
|
let out = text3;
|
|
62107
|
-
|
|
62108
|
-
|
|
62173
|
+
const previousRules = /* @__PURE__ */ new Set();
|
|
62174
|
+
if (old?.file === file2) {
|
|
62175
|
+
const allowed = lists(text3, file2).allow;
|
|
62176
|
+
for (const previous of [old.rule, ...old.previousRules ?? []]) {
|
|
62177
|
+
if (previous !== rule && allowed.includes(previous)) {
|
|
62178
|
+
previousRules.add(previous);
|
|
62179
|
+
out = without(out, previous, file2);
|
|
62180
|
+
}
|
|
62181
|
+
}
|
|
62182
|
+
}
|
|
62109
62183
|
const made = old?.file === file2 ? old.made : [["permissions"], ["permissions", "allow"]].filter(
|
|
62110
62184
|
(p) => jsoncValue(text3, p) === void 0
|
|
62111
62185
|
);
|
|
@@ -62114,11 +62188,24 @@ function installAgyRule(home2, busDir, line) {
|
|
|
62114
62188
|
const n = Array.isArray(raw) ? raw.length : 0;
|
|
62115
62189
|
out = setJsoncValue(out, ["permissions", "allow", n], rule);
|
|
62116
62190
|
}
|
|
62117
|
-
|
|
62191
|
+
const owned = new Set(old?.file === file2 ? old.toolRules : []);
|
|
62192
|
+
const allow = jsoncValue(out, ["permissions", "allow"]);
|
|
62193
|
+
let next = allow.length;
|
|
62194
|
+
for (const grant of toolRules) {
|
|
62195
|
+
if (allow.includes(grant)) continue;
|
|
62196
|
+
out = setJsoncValue(out, ["permissions", "allow", next++], grant);
|
|
62197
|
+
owned.add(grant);
|
|
62198
|
+
}
|
|
62118
62199
|
mkdirSync12(busDir, { recursive: true });
|
|
62119
|
-
const rec = { file: file2, rule, made };
|
|
62120
|
-
|
|
62121
|
-
|
|
62200
|
+
const rec = { file: file2, rule, toolRules: [...owned], made };
|
|
62201
|
+
const pending = previousRules.size ? { ...rec, previousRules: [...previousRules] } : rec;
|
|
62202
|
+
const recordFile = agyRuleRecord(busDir);
|
|
62203
|
+
if (JSON.stringify(old) !== JSON.stringify(pending))
|
|
62204
|
+
writeAtomic(recordFile, `${JSON.stringify(pending)}
|
|
62205
|
+
`, 384);
|
|
62206
|
+
if (out !== text3) writeAtomic(file2, out, 384);
|
|
62207
|
+
if (previousRules.size)
|
|
62208
|
+
writeAtomic(recordFile, `${JSON.stringify(rec)}
|
|
62122
62209
|
`, 384);
|
|
62123
62210
|
return out !== text3;
|
|
62124
62211
|
}
|
|
@@ -62126,11 +62213,22 @@ function uninstallAgyRule(home2, busDir, line) {
|
|
|
62126
62213
|
const file2 = agySettingsFile(home2);
|
|
62127
62214
|
const rec = readRecorded(busDir);
|
|
62128
62215
|
const rules2 = /* @__PURE__ */ new Set();
|
|
62129
|
-
if (rec?.file === file2)
|
|
62216
|
+
if (rec?.file === file2) {
|
|
62217
|
+
rules2.add(rec.rule);
|
|
62218
|
+
for (const previous of rec.previousRules ?? []) rules2.add(previous);
|
|
62219
|
+
}
|
|
62130
62220
|
if (line !== void 0) rules2.add(agyWatchRule(line));
|
|
62131
62221
|
const text3 = readText(file2);
|
|
62132
62222
|
let out = text3;
|
|
62133
62223
|
if (text3 !== void 0) {
|
|
62224
|
+
if (rec?.file === file2) {
|
|
62225
|
+
for (const grant of [...rec.toolRules].reverse()) {
|
|
62226
|
+
const allow = jsoncValue(out, ["permissions", "allow"]);
|
|
62227
|
+
const i = Array.isArray(allow) ? allow.indexOf(grant) : -1;
|
|
62228
|
+
if (i >= 0)
|
|
62229
|
+
out = removeJsoncValue(out, ["permissions", "allow", i]);
|
|
62230
|
+
}
|
|
62231
|
+
}
|
|
62134
62232
|
for (const r of rules2) out = without(out, r, file2);
|
|
62135
62233
|
if (out !== text3)
|
|
62136
62234
|
for (const p of [...rec?.made ?? []].sort(
|
|
@@ -62148,8 +62246,11 @@ function agyRuleState(home2, busDir, line) {
|
|
|
62148
62246
|
try {
|
|
62149
62247
|
l = lists(readText(file2) ?? "", file2);
|
|
62150
62248
|
} catch {
|
|
62151
|
-
return { state: "altered", file: file2 };
|
|
62249
|
+
return { state: "altered", file: file2, missingTools: [...toolRules] };
|
|
62152
62250
|
}
|
|
62251
|
+
const missingTools = toolRules.filter(
|
|
62252
|
+
(r) => !l.allow.includes(r) || l.ask.includes(r) || l.deny.includes(r)
|
|
62253
|
+
);
|
|
62153
62254
|
const rec = readRecorded(busDir);
|
|
62154
62255
|
const want = line === void 0 ? rec?.rule : agyWatchRule(line);
|
|
62155
62256
|
const watcherRule = (r) => /agy-watch/.test(r);
|
|
@@ -62157,9 +62258,17 @@ function agyRuleState(home2, busDir, line) {
|
|
|
62157
62258
|
if (want !== void 0 && l.allow.includes(want)) {
|
|
62158
62259
|
const elsewhere = l.ask.includes(want) || l.deny.includes(want);
|
|
62159
62260
|
const others2 = all.filter((r) => watcherRule(r) && r !== want);
|
|
62160
|
-
return {
|
|
62261
|
+
return {
|
|
62262
|
+
state: elsewhere || others2.length ? "altered" : "present",
|
|
62263
|
+
file: file2,
|
|
62264
|
+
missingTools
|
|
62265
|
+
};
|
|
62161
62266
|
}
|
|
62162
|
-
return {
|
|
62267
|
+
return {
|
|
62268
|
+
state: all.some(watcherRule) ? "altered" : "missing",
|
|
62269
|
+
file: file2,
|
|
62270
|
+
missingTools
|
|
62271
|
+
};
|
|
62163
62272
|
}
|
|
62164
62273
|
|
|
62165
62274
|
// src/steps/antigravity.ts
|
|
@@ -67332,7 +67441,7 @@ var noService = {
|
|
|
67332
67441
|
remove: async () => ({}),
|
|
67333
67442
|
cli: () => ["oa-bus"]
|
|
67334
67443
|
};
|
|
67335
|
-
var VERSION = true ? "0.
|
|
67444
|
+
var VERSION = true ? "0.259.0" : JSON.parse(
|
|
67336
67445
|
readFileSync37(new URL("../package.json", import.meta.url), "utf8")
|
|
67337
67446
|
).version;
|
|
67338
67447
|
var which = (cmd) => {
|
|
@@ -71422,6 +71531,8 @@ async function doctor(ctx) {
|
|
|
71422
71531
|
ctx.home,
|
|
71423
71532
|
bin === void 0 ? void 0 : agyWatchCommand(bin, resolve16(ctx.home))
|
|
71424
71533
|
);
|
|
71534
|
+
if (rule.missingTools.length)
|
|
71535
|
+
warn(c.agyToolsMissing(rule.missingTools));
|
|
71425
71536
|
if (rule.state === "present") pass(c.agyRulePresent());
|
|
71426
71537
|
else if (rule.state === "missing") warn(c.agyRuleMissing());
|
|
71427
71538
|
else warn(c.agyRuleAltered(tilde(ctx, rule.file)));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-artifacts/bus",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.259.0",
|
|
5
5
|
"description": "The Open Artifacts bus: your AI agents reach each other across machines.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -29,6 +29,6 @@
|
|
|
29
29
|
"typecheck": "tsc --noEmit"
|
|
30
30
|
},
|
|
31
31
|
"oaBus": {
|
|
32
|
-
"commit": "
|
|
32
|
+
"commit": "9da9953542e5603a6b3991b3b238ed27445ef9c7"
|
|
33
33
|
}
|
|
34
34
|
}
|