@open-artifacts/bus 0.201.0 → 0.203.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 +78 -5
- package/assets/openclaw/package.json +1 -1
- package/dist/index.js +323 -25
- 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.203.0";
|
|
15
15
|
|
|
16
16
|
type Frame = Json & { type: string; id: string };
|
|
17
17
|
type Ctx = {
|
package/assets/openclaw/index.js
CHANGED
|
@@ -27532,6 +27532,66 @@ var Follows = external_exports.strictObject({
|
|
|
27532
27532
|
type: external_exports.literal("follows"),
|
|
27533
27533
|
follows: external_exports.array(FollowEntry).max(MAX_FOLLOWS)
|
|
27534
27534
|
});
|
|
27535
|
+
var RunVersionSchema = external_exports.string().max(32).regex(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/);
|
|
27536
|
+
var UPDATE_REASONS = [
|
|
27537
|
+
"ok",
|
|
27538
|
+
"unhealthy",
|
|
27539
|
+
"hub_unreachable",
|
|
27540
|
+
"proof_failed",
|
|
27541
|
+
"no_attestation",
|
|
27542
|
+
"bad_tar",
|
|
27543
|
+
"bad_version",
|
|
27544
|
+
"bad_instruction",
|
|
27545
|
+
"fetch_failed",
|
|
27546
|
+
"too_large",
|
|
27547
|
+
"bad_redirect",
|
|
27548
|
+
"wrong_package",
|
|
27549
|
+
"stale_trust_root",
|
|
27550
|
+
"node_too_old",
|
|
27551
|
+
"not_forward",
|
|
27552
|
+
"ahead_of_server",
|
|
27553
|
+
"rate_limited",
|
|
27554
|
+
"refused_backoff",
|
|
27555
|
+
"not_quiet_24h",
|
|
27556
|
+
"needs_you",
|
|
27557
|
+
"staged_changed",
|
|
27558
|
+
"nothing_staged",
|
|
27559
|
+
"requested",
|
|
27560
|
+
"other"
|
|
27561
|
+
];
|
|
27562
|
+
var UPDATE_EVENTS = [
|
|
27563
|
+
"updated",
|
|
27564
|
+
"refused",
|
|
27565
|
+
"stepped_back",
|
|
27566
|
+
"needs_you",
|
|
27567
|
+
"held",
|
|
27568
|
+
"switching"
|
|
27569
|
+
];
|
|
27570
|
+
var ReportVersion = RunVersionSchema.or(external_exports.literal(""));
|
|
27571
|
+
var UpdateReport = external_exports.strictObject({
|
|
27572
|
+
...base,
|
|
27573
|
+
type: external_exports.literal("update_report"),
|
|
27574
|
+
event: external_exports.enum(UPDATE_EVENTS),
|
|
27575
|
+
from: ReportVersion,
|
|
27576
|
+
to: ReportVersion,
|
|
27577
|
+
reason: external_exports.enum(UPDATE_REASONS),
|
|
27578
|
+
detail: WellFormedText.pipe(external_exports.string().max(200)).optional(),
|
|
27579
|
+
/** The rescue shim's own version on this machine (0: none). */
|
|
27580
|
+
rescue_version: external_exports.number().int().min(0).max(1e5),
|
|
27581
|
+
at: IsoTimeSchema
|
|
27582
|
+
});
|
|
27583
|
+
var RunVersionPush = external_exports.strictObject({
|
|
27584
|
+
...base,
|
|
27585
|
+
type: external_exports.literal("run_version"),
|
|
27586
|
+
/** null: the owner cleared it, the instance names none (#2719). */
|
|
27587
|
+
run_version: RunVersionSchema.nullable()
|
|
27588
|
+
});
|
|
27589
|
+
var InstallNow = external_exports.strictObject({ ...base, type: external_exports.literal("install_now") });
|
|
27590
|
+
var UpdateAck = external_exports.strictObject({
|
|
27591
|
+
...base,
|
|
27592
|
+
type: external_exports.literal("update_ack"),
|
|
27593
|
+
ok: external_exports.boolean()
|
|
27594
|
+
});
|
|
27535
27595
|
var HelloOk = external_exports.strictObject({
|
|
27536
27596
|
...base,
|
|
27537
27597
|
type: external_exports.literal("hello_ok"),
|
|
@@ -27542,7 +27602,12 @@ var HelloOk = external_exports.strictObject({
|
|
|
27542
27602
|
* What the hub supports (`BUS_CAPS`), sent only to a socket whose hello
|
|
27543
27603
|
* listed caps, so a client that never sends caps never sees it.
|
|
27544
27604
|
*/
|
|
27545
|
-
caps: CapsSchema.optional()
|
|
27605
|
+
caps: CapsSchema.optional(),
|
|
27606
|
+
/**
|
|
27607
|
+
* The version the instance names (BUS_CAPS.runVersion). `null`: it names
|
|
27608
|
+
* none (cleared, #2719); absent: the hub does not know yet, a push follows.
|
|
27609
|
+
*/
|
|
27610
|
+
run_version: RunVersionSchema.nullable().optional()
|
|
27546
27611
|
});
|
|
27547
27612
|
var AgentOk = external_exports.strictObject({
|
|
27548
27613
|
...base,
|
|
@@ -27673,7 +27738,8 @@ var ClientFrameSchema = external_exports.discriminatedUnion("type", [
|
|
|
27673
27738
|
Unfollow,
|
|
27674
27739
|
Following,
|
|
27675
27740
|
LinkBind,
|
|
27676
|
-
WaitingQuery
|
|
27741
|
+
WaitingQuery,
|
|
27742
|
+
UpdateReport
|
|
27677
27743
|
]);
|
|
27678
27744
|
var ServerFrameSchema = external_exports.discriminatedUnion("type", [
|
|
27679
27745
|
HelloOk,
|
|
@@ -27691,7 +27757,10 @@ var ServerFrameSchema = external_exports.discriminatedUnion("type", [
|
|
|
27691
27757
|
Follows,
|
|
27692
27758
|
LinkBound,
|
|
27693
27759
|
WaitingCounts,
|
|
27694
|
-
Acked
|
|
27760
|
+
Acked,
|
|
27761
|
+
RunVersionPush,
|
|
27762
|
+
InstallNow,
|
|
27763
|
+
UpdateAck
|
|
27695
27764
|
]);
|
|
27696
27765
|
var FrameSchema = external_exports.discriminatedUnion("type", [
|
|
27697
27766
|
Hello,
|
|
@@ -27710,6 +27779,7 @@ var FrameSchema = external_exports.discriminatedUnion("type", [
|
|
|
27710
27779
|
Following,
|
|
27711
27780
|
LinkBind,
|
|
27712
27781
|
WaitingQuery,
|
|
27782
|
+
UpdateReport,
|
|
27713
27783
|
HelloOk,
|
|
27714
27784
|
AgentOk,
|
|
27715
27785
|
ReceiptFrame,
|
|
@@ -27725,7 +27795,10 @@ var FrameSchema = external_exports.discriminatedUnion("type", [
|
|
|
27725
27795
|
Follows,
|
|
27726
27796
|
LinkBound,
|
|
27727
27797
|
WaitingCounts,
|
|
27728
|
-
Acked
|
|
27798
|
+
Acked,
|
|
27799
|
+
RunVersionPush,
|
|
27800
|
+
InstallNow,
|
|
27801
|
+
UpdateAck
|
|
27729
27802
|
]);
|
|
27730
27803
|
var MAX_RAW_FRAME_CHARS = 2 * LIMITS.maxMessageBytes + 4096;
|
|
27731
27804
|
|
|
@@ -27744,7 +27817,7 @@ var base2 = { v: external_exports.literal(V), id: external_exports.string().min(
|
|
|
27744
27817
|
var late = { late: external_exports.array(external_exports.string().min(1)).optional() };
|
|
27745
27818
|
var isWellFormed2 = (s) => s.isWellFormed();
|
|
27746
27819
|
var WELL_FORMED = { message: "text is not well-formed unicode" };
|
|
27747
|
-
var CLIENT_VERSION = true ? "0.
|
|
27820
|
+
var CLIENT_VERSION = true ? "0.203.0" : "0.0.0";
|
|
27748
27821
|
var clientVersion = {
|
|
27749
27822
|
client_version: external_exports.string().min(1).max(64).optional()
|
|
27750
27823
|
};
|
package/dist/index.js
CHANGED
|
@@ -31481,7 +31481,15 @@ var init_caps = __esm({
|
|
|
31481
31481
|
* acks are not answered. A daemon listing it keeps an ack record until the
|
|
31482
31482
|
* hub confirmed it, and sends it again on a new link otherwise.
|
|
31483
31483
|
*/
|
|
31484
|
-
ackConfirm: "ack_confirm"
|
|
31484
|
+
ackConfirm: "ack_confirm",
|
|
31485
|
+
/**
|
|
31486
|
+
* The instance names the version (#2552): `hello_ok.run_version`, the
|
|
31487
|
+
* `run_version` push, the fieldless `install_now` push and the `update_ack`
|
|
31488
|
+
* answer go only to a socket whose hello listed it, and a daemon sends
|
|
31489
|
+
* `update_report` only to a hub that listed it in `hello_ok.caps`. Either
|
|
31490
|
+
* side without it sees none of these frames.
|
|
31491
|
+
*/
|
|
31492
|
+
runVersion: "run_version"
|
|
31485
31493
|
};
|
|
31486
31494
|
MAX_CAPS = 16;
|
|
31487
31495
|
CapTokenSchema = external_exports.string().regex(/^[a-z][a-z0-9_-]{0,31}$/);
|
|
@@ -32241,7 +32249,7 @@ function decode3(raw, schema, caps) {
|
|
|
32241
32249
|
function decodeServerFrame(raw) {
|
|
32242
32250
|
return decode3(raw, ServerFrameSchema, SERVER_CAPS);
|
|
32243
32251
|
}
|
|
32244
|
-
var PING, PONG, isWellFormed, WellFormedText, FrameIdSchema, base, BodySchema, InlineBodySchema, distinct, Hello, AgentUp, AgentDown, Sessions, Send, Ack, Refuse, List, Fetch, Status, Rename, FollowRefSchema, Follow, Unfollow, Following, LINK_PROOF_HEADER, LinkProofSchema, LinkProofHashSchema, LinkBind, LinkBound, MAX_WAITING_QUERY, WaitingQuery, WaitingCounts, Acked, MAX_FOLLOWS, FollowEntry, Followed, Unfollowed, Follows, HelloOk, AgentOk, Renamed, ReceiptFrame, RosterAgent, Roster, BodyFrame, AGENT_CAP_MESSAGES, ErrorFrame, Notice, Deliver, ReceiptUpdate, RosterChanged, ClientFrameSchema, ServerFrameSchema, FrameSchema, MAX_RAW_FRAME_CHARS, SERVER_CAPS, MAX_OBJECT_TOKENS, ID_PREFIX_RE;
|
|
32252
|
+
var PING, PONG, isWellFormed, WellFormedText, FrameIdSchema, base, BodySchema, InlineBodySchema, distinct, Hello, AgentUp, AgentDown, Sessions, Send, Ack, Refuse, List, Fetch, Status, Rename, FollowRefSchema, Follow, Unfollow, Following, LINK_PROOF_HEADER, LinkProofSchema, LinkProofHashSchema, LinkBind, LinkBound, MAX_WAITING_QUERY, WaitingQuery, WaitingCounts, Acked, MAX_FOLLOWS, FollowEntry, Followed, Unfollowed, Follows, RunVersionSchema, UPDATE_REASONS, UPDATE_EVENTS, ReportVersion, UpdateReport, RunVersionPush, InstallNow, UpdateAck, HelloOk, AgentOk, Renamed, ReceiptFrame, RosterAgent, Roster, BodyFrame, AGENT_CAP_MESSAGES, ErrorFrame, Notice, Deliver, ReceiptUpdate, RosterChanged, ClientFrameSchema, ServerFrameSchema, FrameSchema, MAX_RAW_FRAME_CHARS, SERVER_CAPS, MAX_OBJECT_TOKENS, ID_PREFIX_RE;
|
|
32245
32253
|
var init_protocol2 = __esm({
|
|
32246
32254
|
"../bus-protocol/src/protocol.ts"() {
|
|
32247
32255
|
"use strict";
|
|
@@ -32458,6 +32466,66 @@ var init_protocol2 = __esm({
|
|
|
32458
32466
|
type: external_exports.literal("follows"),
|
|
32459
32467
|
follows: external_exports.array(FollowEntry).max(MAX_FOLLOWS)
|
|
32460
32468
|
});
|
|
32469
|
+
RunVersionSchema = external_exports.string().max(32).regex(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/);
|
|
32470
|
+
UPDATE_REASONS = [
|
|
32471
|
+
"ok",
|
|
32472
|
+
"unhealthy",
|
|
32473
|
+
"hub_unreachable",
|
|
32474
|
+
"proof_failed",
|
|
32475
|
+
"no_attestation",
|
|
32476
|
+
"bad_tar",
|
|
32477
|
+
"bad_version",
|
|
32478
|
+
"bad_instruction",
|
|
32479
|
+
"fetch_failed",
|
|
32480
|
+
"too_large",
|
|
32481
|
+
"bad_redirect",
|
|
32482
|
+
"wrong_package",
|
|
32483
|
+
"stale_trust_root",
|
|
32484
|
+
"node_too_old",
|
|
32485
|
+
"not_forward",
|
|
32486
|
+
"ahead_of_server",
|
|
32487
|
+
"rate_limited",
|
|
32488
|
+
"refused_backoff",
|
|
32489
|
+
"not_quiet_24h",
|
|
32490
|
+
"needs_you",
|
|
32491
|
+
"staged_changed",
|
|
32492
|
+
"nothing_staged",
|
|
32493
|
+
"requested",
|
|
32494
|
+
"other"
|
|
32495
|
+
];
|
|
32496
|
+
UPDATE_EVENTS = [
|
|
32497
|
+
"updated",
|
|
32498
|
+
"refused",
|
|
32499
|
+
"stepped_back",
|
|
32500
|
+
"needs_you",
|
|
32501
|
+
"held",
|
|
32502
|
+
"switching"
|
|
32503
|
+
];
|
|
32504
|
+
ReportVersion = RunVersionSchema.or(external_exports.literal(""));
|
|
32505
|
+
UpdateReport = external_exports.strictObject({
|
|
32506
|
+
...base,
|
|
32507
|
+
type: external_exports.literal("update_report"),
|
|
32508
|
+
event: external_exports.enum(UPDATE_EVENTS),
|
|
32509
|
+
from: ReportVersion,
|
|
32510
|
+
to: ReportVersion,
|
|
32511
|
+
reason: external_exports.enum(UPDATE_REASONS),
|
|
32512
|
+
detail: WellFormedText.pipe(external_exports.string().max(200)).optional(),
|
|
32513
|
+
/** The rescue shim's own version on this machine (0: none). */
|
|
32514
|
+
rescue_version: external_exports.number().int().min(0).max(1e5),
|
|
32515
|
+
at: IsoTimeSchema
|
|
32516
|
+
});
|
|
32517
|
+
RunVersionPush = external_exports.strictObject({
|
|
32518
|
+
...base,
|
|
32519
|
+
type: external_exports.literal("run_version"),
|
|
32520
|
+
/** null: the owner cleared it, the instance names none (#2719). */
|
|
32521
|
+
run_version: RunVersionSchema.nullable()
|
|
32522
|
+
});
|
|
32523
|
+
InstallNow = external_exports.strictObject({ ...base, type: external_exports.literal("install_now") });
|
|
32524
|
+
UpdateAck = external_exports.strictObject({
|
|
32525
|
+
...base,
|
|
32526
|
+
type: external_exports.literal("update_ack"),
|
|
32527
|
+
ok: external_exports.boolean()
|
|
32528
|
+
});
|
|
32461
32529
|
HelloOk = external_exports.strictObject({
|
|
32462
32530
|
...base,
|
|
32463
32531
|
type: external_exports.literal("hello_ok"),
|
|
@@ -32468,7 +32536,12 @@ var init_protocol2 = __esm({
|
|
|
32468
32536
|
* What the hub supports (`BUS_CAPS`), sent only to a socket whose hello
|
|
32469
32537
|
* listed caps, so a client that never sends caps never sees it.
|
|
32470
32538
|
*/
|
|
32471
|
-
caps: CapsSchema.optional()
|
|
32539
|
+
caps: CapsSchema.optional(),
|
|
32540
|
+
/**
|
|
32541
|
+
* The version the instance names (BUS_CAPS.runVersion). `null`: it names
|
|
32542
|
+
* none (cleared, #2719); absent: the hub does not know yet, a push follows.
|
|
32543
|
+
*/
|
|
32544
|
+
run_version: RunVersionSchema.nullable().optional()
|
|
32472
32545
|
});
|
|
32473
32546
|
AgentOk = external_exports.strictObject({
|
|
32474
32547
|
...base,
|
|
@@ -32603,7 +32676,8 @@ var init_protocol2 = __esm({
|
|
|
32603
32676
|
Unfollow,
|
|
32604
32677
|
Following,
|
|
32605
32678
|
LinkBind,
|
|
32606
|
-
WaitingQuery
|
|
32679
|
+
WaitingQuery,
|
|
32680
|
+
UpdateReport
|
|
32607
32681
|
]);
|
|
32608
32682
|
ServerFrameSchema = external_exports.discriminatedUnion("type", [
|
|
32609
32683
|
HelloOk,
|
|
@@ -32621,7 +32695,10 @@ var init_protocol2 = __esm({
|
|
|
32621
32695
|
Follows,
|
|
32622
32696
|
LinkBound,
|
|
32623
32697
|
WaitingCounts,
|
|
32624
|
-
Acked
|
|
32698
|
+
Acked,
|
|
32699
|
+
RunVersionPush,
|
|
32700
|
+
InstallNow,
|
|
32701
|
+
UpdateAck
|
|
32625
32702
|
]);
|
|
32626
32703
|
FrameSchema = external_exports.discriminatedUnion("type", [
|
|
32627
32704
|
Hello,
|
|
@@ -32640,6 +32717,7 @@ var init_protocol2 = __esm({
|
|
|
32640
32717
|
Following,
|
|
32641
32718
|
LinkBind,
|
|
32642
32719
|
WaitingQuery,
|
|
32720
|
+
UpdateReport,
|
|
32643
32721
|
HelloOk,
|
|
32644
32722
|
AgentOk,
|
|
32645
32723
|
ReceiptFrame,
|
|
@@ -32655,7 +32733,10 @@ var init_protocol2 = __esm({
|
|
|
32655
32733
|
Follows,
|
|
32656
32734
|
LinkBound,
|
|
32657
32735
|
WaitingCounts,
|
|
32658
|
-
Acked
|
|
32736
|
+
Acked,
|
|
32737
|
+
RunVersionPush,
|
|
32738
|
+
InstallNow,
|
|
32739
|
+
UpdateAck
|
|
32659
32740
|
]);
|
|
32660
32741
|
MAX_RAW_FRAME_CHARS = 2 * LIMITS.maxMessageBytes + 4096;
|
|
32661
32742
|
SERVER_CAPS = { depth: 5, tokens: 65536, structural: 131072 };
|
|
@@ -32729,7 +32810,7 @@ var init_frames = __esm({
|
|
|
32729
32810
|
late = { late: external_exports.array(external_exports.string().min(1)).optional() };
|
|
32730
32811
|
isWellFormed2 = (s) => s.isWellFormed();
|
|
32731
32812
|
WELL_FORMED = { message: "text is not well-formed unicode" };
|
|
32732
|
-
CLIENT_VERSION = true ? "0.
|
|
32813
|
+
CLIENT_VERSION = true ? "0.203.0" : "0.0.0";
|
|
32733
32814
|
clientVersion = {
|
|
32734
32815
|
client_version: external_exports.string().min(1).max(64).optional()
|
|
32735
32816
|
};
|
|
@@ -47820,7 +47901,8 @@ var HUB_HELLO_CAPS = [
|
|
|
47820
47901
|
BUS_CAPS.waiting,
|
|
47821
47902
|
BUS_CAPS.waitingQuery,
|
|
47822
47903
|
BUS_CAPS.noticeAck,
|
|
47823
|
-
BUS_CAPS.ackConfirm
|
|
47904
|
+
BUS_CAPS.ackConfirm,
|
|
47905
|
+
BUS_CAPS.runVersion
|
|
47824
47906
|
];
|
|
47825
47907
|
var HubConnection = class {
|
|
47826
47908
|
constructor(opts) {
|
|
@@ -50852,9 +50934,6 @@ function label(s, now) {
|
|
|
50852
50934
|
return s.notified[st.version]?.includes("ready") || readyDue(s, now) ? "Update ready" : "Updating soon";
|
|
50853
50935
|
}
|
|
50854
50936
|
|
|
50855
|
-
// ../bus-daemon/src/update/selfcheck.ts
|
|
50856
|
-
import { existsSync as existsSync4 } from "node:fs";
|
|
50857
|
-
|
|
50858
50937
|
// ../bus-daemon/src/update/reports.ts
|
|
50859
50938
|
import {
|
|
50860
50939
|
chmodSync as chmodSync12,
|
|
@@ -50898,6 +50977,37 @@ function queueReport(home2, r) {
|
|
|
50898
50977
|
rmSync7(tmp, { force: true });
|
|
50899
50978
|
}
|
|
50900
50979
|
}
|
|
50980
|
+
function removeReports(home2, sent) {
|
|
50981
|
+
if (sent.length === 0) return;
|
|
50982
|
+
const tmp = `${reportFile(home2)}.${process.pid}.tmp`;
|
|
50983
|
+
try {
|
|
50984
|
+
const left = [...readReports(home2)];
|
|
50985
|
+
for (const r of sent) {
|
|
50986
|
+
const i = left.findIndex(
|
|
50987
|
+
(x) => x.event === r.event && x.from === r.from && x.to === r.to && x.reason === r.reason && x.at === r.at
|
|
50988
|
+
);
|
|
50989
|
+
if (i >= 0) left.splice(i, 1);
|
|
50990
|
+
}
|
|
50991
|
+
writeFileSync10(tmp, `${JSON.stringify(left)}
|
|
50992
|
+
`, { mode: 384 });
|
|
50993
|
+
chmodSync12(tmp, 384);
|
|
50994
|
+
renameSync12(tmp, reportFile(home2));
|
|
50995
|
+
} catch {
|
|
50996
|
+
rmSync7(tmp, { force: true });
|
|
50997
|
+
}
|
|
50998
|
+
}
|
|
50999
|
+
function readRescueVersion(home2) {
|
|
51000
|
+
try {
|
|
51001
|
+
const head = readFileSync15(join18(home2, "rescue.mjs"), "utf8").slice(0, 200);
|
|
51002
|
+
const n = /Rescue shim (\d{1,6})\./.exec(head)?.[1];
|
|
51003
|
+
return n === void 0 ? 0 : Number(n);
|
|
51004
|
+
} catch {
|
|
51005
|
+
return 0;
|
|
51006
|
+
}
|
|
51007
|
+
}
|
|
51008
|
+
|
|
51009
|
+
// ../bus-daemon/src/update/selfcheck.ts
|
|
51010
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
50901
51011
|
|
|
50902
51012
|
// ../bus-daemon/src/update/state.ts
|
|
50903
51013
|
import {
|
|
@@ -52100,11 +52210,15 @@ var Updater = class {
|
|
|
52100
52210
|
stopTick = () => {
|
|
52101
52211
|
};
|
|
52102
52212
|
working = false;
|
|
52213
|
+
/** One swap at a time: every switchTo caller goes through this. */
|
|
52214
|
+
switching = false;
|
|
52103
52215
|
wanted;
|
|
52104
52216
|
d;
|
|
52105
52217
|
/** Decided once: the loop's flag, and a running version that is x.y.z. */
|
|
52106
52218
|
active;
|
|
52107
52219
|
/** An instance-asked step back held back by a login in progress. */
|
|
52220
|
+
/** Malformed instructions already reported (by their text), at most 20. */
|
|
52221
|
+
reportedBad = /* @__PURE__ */ new Set();
|
|
52108
52222
|
stepBackHeld;
|
|
52109
52223
|
constructor(d) {
|
|
52110
52224
|
this.d = d;
|
|
@@ -52126,6 +52240,52 @@ var Updater = class {
|
|
|
52126
52240
|
stop() {
|
|
52127
52241
|
this.stopTick();
|
|
52128
52242
|
}
|
|
52243
|
+
/** The version the instance last named (hello_ok or a push); "Install now" must match it. */
|
|
52244
|
+
named;
|
|
52245
|
+
/**
|
|
52246
|
+
* The instance names `version` (BUS_CAPS.runVersion). The one kept previous
|
|
52247
|
+
* is a step back; the running version is no instruction at all.
|
|
52248
|
+
*/
|
|
52249
|
+
async instructFromInstance(version2) {
|
|
52250
|
+
if (parseVersion(version2) === void 0) return this.instruct({ version: version2 });
|
|
52251
|
+
this.named = version2;
|
|
52252
|
+
const { running } = this.d;
|
|
52253
|
+
if (running === void 0) return { kind: "disabled" };
|
|
52254
|
+
const s = readPolicy(this.d.home);
|
|
52255
|
+
if (version2 === running) {
|
|
52256
|
+
const old = s.staged?.version;
|
|
52257
|
+
if (old !== void 0 && old !== version2) {
|
|
52258
|
+
clearStaged(this.d.home);
|
|
52259
|
+
this.dropStaged(old);
|
|
52260
|
+
}
|
|
52261
|
+
return { kind: "disabled" };
|
|
52262
|
+
}
|
|
52263
|
+
const stepBack = s.previous === version2 && compareVersions2(version2, running) === -1;
|
|
52264
|
+
return this.instruct({ version: version2, ...stepBack ? { stepBack: true } : {} });
|
|
52265
|
+
}
|
|
52266
|
+
/**
|
|
52267
|
+
* The instance names no version (cleared, #2719): nothing it staged may be
|
|
52268
|
+
* swapped in, whatever was named before. The person's own install request
|
|
52269
|
+
* still works.
|
|
52270
|
+
*/
|
|
52271
|
+
clearNamed() {
|
|
52272
|
+
this.named = void 0;
|
|
52273
|
+
}
|
|
52274
|
+
/**
|
|
52275
|
+
* "Install now" from Settings: a frame with no field. Honored only for the
|
|
52276
|
+
* staged version the instance names, never during a login, never past
|
|
52277
|
+
* `off`, the failed list or the 6 h limit. It skips only the quiet wait.
|
|
52278
|
+
*/
|
|
52279
|
+
async installNowFromInstance() {
|
|
52280
|
+
if (!this.enabled) return { kind: "disabled" };
|
|
52281
|
+
const s = readPolicy(this.d.home);
|
|
52282
|
+
const st = s.staged;
|
|
52283
|
+
if (!st || this.named !== st.version)
|
|
52284
|
+
return { kind: "refused", reason: "nothing_staged" };
|
|
52285
|
+
const d = installNow(s, this.now(), this.d.loginActive());
|
|
52286
|
+
if (!d.ok) return { kind: "refused", reason: d.reason };
|
|
52287
|
+
return this.switchTo(st.version, true);
|
|
52288
|
+
}
|
|
52129
52289
|
/** The version the instance names. Stages it; the swap waits for a quiet moment. */
|
|
52130
52290
|
async instruct(i) {
|
|
52131
52291
|
if (!this.enabled) return { kind: "disabled" };
|
|
@@ -52144,7 +52304,7 @@ var Updater = class {
|
|
|
52144
52304
|
this.stepBackHeld = i;
|
|
52145
52305
|
return { kind: "retry_later" };
|
|
52146
52306
|
}
|
|
52147
|
-
return this.switchTo(i.version, false);
|
|
52307
|
+
return await this.switchTo(i.version, false);
|
|
52148
52308
|
}
|
|
52149
52309
|
if (s.staged?.version === i.version && s.staged.manifest) {
|
|
52150
52310
|
if (treeMatches(versionDir(home2, i.version), s.staged.manifest))
|
|
@@ -52153,14 +52313,33 @@ var Updater = class {
|
|
|
52153
52313
|
return this.stage(i, now);
|
|
52154
52314
|
}
|
|
52155
52315
|
refuse(from, to, d) {
|
|
52156
|
-
if (d.reason
|
|
52157
|
-
|
|
52158
|
-
|
|
52159
|
-
|
|
52160
|
-
|
|
52161
|
-
|
|
52162
|
-
|
|
52163
|
-
|
|
52316
|
+
if (d.reason !== "bad_version" && d.reason !== "ahead_of_server" && d.reason !== "not_forward")
|
|
52317
|
+
return;
|
|
52318
|
+
const named = parseVersion(to) ? to : "";
|
|
52319
|
+
const reason2 = d.reason === "bad_version" ? "bad_instruction" : d.reason;
|
|
52320
|
+
if (named === "") {
|
|
52321
|
+
if (this.reportedBad.has(to)) return;
|
|
52322
|
+
if (this.reportedBad.size < 20) this.reportedBad.add(to);
|
|
52323
|
+
} else {
|
|
52324
|
+
try {
|
|
52325
|
+
const key2 = `refused:${reason2}`;
|
|
52326
|
+
const list = readPolicy(this.d.home).notified[named] ?? [];
|
|
52327
|
+
if (list.includes(key2)) return;
|
|
52328
|
+
editPolicy(this.d.home, (s) => {
|
|
52329
|
+
s.notified[named] = [...s.notified[named] ?? [], key2];
|
|
52330
|
+
});
|
|
52331
|
+
} catch {
|
|
52332
|
+
if (this.reportedBad.has(`${named}:${reason2}`)) return;
|
|
52333
|
+
this.reportedBad.add(`${named}:${reason2}`);
|
|
52334
|
+
}
|
|
52335
|
+
}
|
|
52336
|
+
queueReport(this.d.home, {
|
|
52337
|
+
event: "refused",
|
|
52338
|
+
from,
|
|
52339
|
+
to: named,
|
|
52340
|
+
reason: reason2,
|
|
52341
|
+
at: this.now()
|
|
52342
|
+
});
|
|
52164
52343
|
}
|
|
52165
52344
|
async stage(i, now) {
|
|
52166
52345
|
const { home: home2, running } = this.d;
|
|
@@ -52307,11 +52486,11 @@ var Updater = class {
|
|
|
52307
52486
|
});
|
|
52308
52487
|
if (req) {
|
|
52309
52488
|
if (req.version === st.version && !login2 && now - req.at < REQUEST_MAX_MS)
|
|
52310
|
-
this.switchTo(st.version, true);
|
|
52489
|
+
await this.switchTo(st.version, true, true);
|
|
52311
52490
|
return;
|
|
52312
52491
|
}
|
|
52313
|
-
if (this.quiet.quiet(now) && installNow(s, now, login2).ok)
|
|
52314
|
-
this.switchTo(st.version, true);
|
|
52492
|
+
if (this.named === st.version && this.quiet.quiet(now) && installNow(s, now, login2).ok)
|
|
52493
|
+
await this.switchTo(st.version, true);
|
|
52315
52494
|
} catch (e) {
|
|
52316
52495
|
this.d.log(`update: ${e instanceof Error ? e.message : String(e)}`);
|
|
52317
52496
|
} finally {
|
|
@@ -52322,11 +52501,22 @@ var Updater = class {
|
|
|
52322
52501
|
* The swap: re-hash what was staged, write `pending`, point `bin` at it and
|
|
52323
52502
|
* exit non-zero so the service restarts the daemon from the new folder.
|
|
52324
52503
|
*/
|
|
52325
|
-
switchTo(version2, staged) {
|
|
52504
|
+
async switchTo(version2, staged, person = false) {
|
|
52505
|
+
if (this.switching) return { kind: "retry_later" };
|
|
52506
|
+
this.switching = true;
|
|
52507
|
+
try {
|
|
52508
|
+
return await this.doSwitch(version2, staged, person);
|
|
52509
|
+
} finally {
|
|
52510
|
+
this.switching = false;
|
|
52511
|
+
}
|
|
52512
|
+
}
|
|
52513
|
+
async doSwitch(version2, staged, person) {
|
|
52326
52514
|
const { home: home2, running } = this.d;
|
|
52327
52515
|
const now = this.now();
|
|
52328
52516
|
if (running === void 0 || !isSafeVersion(version2) || version2 === running)
|
|
52329
52517
|
return { kind: "disabled" };
|
|
52518
|
+
if (staged && !person && this.named !== version2)
|
|
52519
|
+
return { kind: "refused", reason: "nothing_staged" };
|
|
52330
52520
|
if (!this.d.hubReady()) return { kind: "retry_later" };
|
|
52331
52521
|
const s = readPolicy(home2);
|
|
52332
52522
|
if (staged) {
|
|
@@ -52354,6 +52544,23 @@ var Updater = class {
|
|
|
52354
52544
|
} else if (!existsSync5(versionDir(home2, version2))) {
|
|
52355
52545
|
return { kind: "refused", reason: "nothing_staged" };
|
|
52356
52546
|
}
|
|
52547
|
+
const proven = s.staged?.manifest;
|
|
52548
|
+
if (!await this.d.announceSwitch(
|
|
52549
|
+
running,
|
|
52550
|
+
version2,
|
|
52551
|
+
person ? "requested" : "ok"
|
|
52552
|
+
))
|
|
52553
|
+
return { kind: "retry_later" };
|
|
52554
|
+
const after = readPolicy(home2);
|
|
52555
|
+
if (after.unreadable || after.off) return { kind: "retry_later" };
|
|
52556
|
+
if (staged && !person && this.named !== version2)
|
|
52557
|
+
return { kind: "retry_later" };
|
|
52558
|
+
if (staged && (after.staged?.version !== version2 || JSON.stringify(after.staged.manifest) !== JSON.stringify(proven) || !after.staged.manifest || !treeMatches(versionDir(home2, version2), after.staged.manifest)))
|
|
52559
|
+
return { kind: "proof_refused", code: "staged_changed" };
|
|
52560
|
+
if (staged && [after.newestRun, after.current, running].some(
|
|
52561
|
+
(v) => v !== void 0 && compareVersions2(version2, v) !== 1
|
|
52562
|
+
))
|
|
52563
|
+
return { kind: "refused", reason: "not_forward" };
|
|
52357
52564
|
try {
|
|
52358
52565
|
setPending(home2, { from: running, to: version2, startedAt: now });
|
|
52359
52566
|
recordAttempt(home2, now);
|
|
@@ -52656,6 +52863,9 @@ function listLeadTemplateNames(h = home()) {
|
|
|
52656
52863
|
|
|
52657
52864
|
// ../bus-daemon/src/index.ts
|
|
52658
52865
|
var NOTICE_RETRY_MS = 3e4;
|
|
52866
|
+
var SWITCH_ACK_MS = 5e3;
|
|
52867
|
+
var REPORT_FLUSH_MS = 5e3;
|
|
52868
|
+
var errText = (e) => e instanceof Error ? e.message : String(e);
|
|
52659
52869
|
var BINDING_IDLE_MS = 24 * 60 * 6e4;
|
|
52660
52870
|
var BINDING_SWEEP_MS = 6e4;
|
|
52661
52871
|
var RENAME_HOLD_MS = 60 * 6e4;
|
|
@@ -53365,6 +53575,32 @@ async function runDaemon(deps2 = {}) {
|
|
|
53365
53575
|
let hubAckConfirm = false;
|
|
53366
53576
|
let codexReplayLink = 0;
|
|
53367
53577
|
let hubVersion;
|
|
53578
|
+
let hubRunCap = false;
|
|
53579
|
+
const switchAcks = /* @__PURE__ */ new Map();
|
|
53580
|
+
let updaterRef;
|
|
53581
|
+
function flushUpdateReports() {
|
|
53582
|
+
if (!hubRunCap || !hubHelloed || !hub.open || !deps2.update) return;
|
|
53583
|
+
const queued = readReports(home());
|
|
53584
|
+
const went = [];
|
|
53585
|
+
const rescue = readRescueVersion(home());
|
|
53586
|
+
for (const r of queued) {
|
|
53587
|
+
const ok = hub.send({
|
|
53588
|
+
v: 1,
|
|
53589
|
+
id: frameId(),
|
|
53590
|
+
type: "update_report",
|
|
53591
|
+
// The 24 h notice is "held" on the wire.
|
|
53592
|
+
event: r.event === "ready_24h" ? "held" : r.event,
|
|
53593
|
+
from: r.from,
|
|
53594
|
+
to: r.to,
|
|
53595
|
+
reason: UPDATE_REASONS.includes(r.reason) ? r.reason : "other",
|
|
53596
|
+
rescue_version: rescue,
|
|
53597
|
+
at: new Date(r.at).toISOString()
|
|
53598
|
+
});
|
|
53599
|
+
if (!ok) break;
|
|
53600
|
+
went.push(r);
|
|
53601
|
+
}
|
|
53602
|
+
removeReports(home(), went);
|
|
53603
|
+
}
|
|
53368
53604
|
let hubWaiting = false;
|
|
53369
53605
|
let hubWaitingQuery = false;
|
|
53370
53606
|
const waitingAsks = /* @__PURE__ */ new Map();
|
|
@@ -53480,6 +53716,21 @@ async function runDaemon(deps2 = {}) {
|
|
|
53480
53716
|
return;
|
|
53481
53717
|
case "link_bound":
|
|
53482
53718
|
return;
|
|
53719
|
+
// #2552: only from a hub that listed the cap; anything else is ignored.
|
|
53720
|
+
case "run_version":
|
|
53721
|
+
if (hubRunCap) {
|
|
53722
|
+
if (frame.run_version === null) updaterRef?.clearNamed();
|
|
53723
|
+
else
|
|
53724
|
+
void updaterRef?.instructFromInstance(frame.run_version).catch((e) => log(`update: ${errText(e)}`));
|
|
53725
|
+
}
|
|
53726
|
+
return;
|
|
53727
|
+
case "install_now":
|
|
53728
|
+
if (hubRunCap)
|
|
53729
|
+
void updaterRef?.installNowFromInstance().catch((e) => log(`update: ${errText(e)}`));
|
|
53730
|
+
return;
|
|
53731
|
+
case "update_ack":
|
|
53732
|
+
switchAcks.get(frame.id)?.(frame.ok);
|
|
53733
|
+
return;
|
|
53483
53734
|
case "acked": {
|
|
53484
53735
|
if (!hubAckConfirm) return;
|
|
53485
53736
|
const sent2 = codexAckIds.take(frame.id);
|
|
@@ -53504,7 +53755,14 @@ async function runDaemon(deps2 = {}) {
|
|
|
53504
53755
|
hubLink = frame.caps?.includes(BUS_CAPS.link) ?? false;
|
|
53505
53756
|
hubLinkArg = frame.caps?.includes(BUS_CAPS.linkArg) ?? false;
|
|
53506
53757
|
hubAckConfirm = frame.caps?.includes(BUS_CAPS.ackConfirm) ?? false;
|
|
53758
|
+
hubRunCap = frame.caps?.includes(BUS_CAPS.runVersion) ?? false;
|
|
53507
53759
|
hubHelloed = true;
|
|
53760
|
+
if (hubRunCap) {
|
|
53761
|
+
if (frame.run_version === null) updaterRef?.clearNamed();
|
|
53762
|
+
else if (frame.run_version !== void 0)
|
|
53763
|
+
void updaterRef?.instructFromInstance(frame.run_version).catch((e) => log(`update: ${errText(e)}`));
|
|
53764
|
+
flushUpdateReports();
|
|
53765
|
+
}
|
|
53508
53766
|
for (const rec of agents.all())
|
|
53509
53767
|
if (rec.live && rec.replaces !== void 0) announceUp(rec);
|
|
53510
53768
|
if (hubNameChosen) {
|
|
@@ -53579,6 +53837,11 @@ async function runDaemon(deps2 = {}) {
|
|
|
53579
53837
|
codexAckIds.clear();
|
|
53580
53838
|
hubWaitingQuery = false;
|
|
53581
53839
|
hubHelloed = false;
|
|
53840
|
+
hubRunCap = false;
|
|
53841
|
+
for (const [id, done] of [...switchAcks]) {
|
|
53842
|
+
switchAcks.delete(id);
|
|
53843
|
+
done(false);
|
|
53844
|
+
}
|
|
53582
53845
|
statusRelay.dropped();
|
|
53583
53846
|
receipts.release();
|
|
53584
53847
|
resends.dropped();
|
|
@@ -54498,13 +54761,47 @@ async function runDaemon(deps2 = {}) {
|
|
|
54498
54761
|
}),
|
|
54499
54762
|
loginActive: () => loginActive(home()),
|
|
54500
54763
|
hubReady: () => hub.open && hubHelloed,
|
|
54764
|
+
announceSwitch: async (from, to, reason2 = "ok") => {
|
|
54765
|
+
if (!hubRunCap || !hub.open) return false;
|
|
54766
|
+
const id = frameId();
|
|
54767
|
+
const answer = new Promise((res) => {
|
|
54768
|
+
const t = setTimeout(() => {
|
|
54769
|
+
switchAcks.delete(id);
|
|
54770
|
+
res(false);
|
|
54771
|
+
}, upd.ackMs ?? SWITCH_ACK_MS);
|
|
54772
|
+
t.unref?.();
|
|
54773
|
+
switchAcks.set(id, (ok) => {
|
|
54774
|
+
clearTimeout(t);
|
|
54775
|
+
switchAcks.delete(id);
|
|
54776
|
+
res(ok);
|
|
54777
|
+
});
|
|
54778
|
+
});
|
|
54779
|
+
const sentOk = hub.send({
|
|
54780
|
+
v: 1,
|
|
54781
|
+
id,
|
|
54782
|
+
type: "update_report",
|
|
54783
|
+
event: "switching",
|
|
54784
|
+
from,
|
|
54785
|
+
to,
|
|
54786
|
+
reason: reason2,
|
|
54787
|
+
rescue_version: readRescueVersion(home()),
|
|
54788
|
+
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
54789
|
+
});
|
|
54790
|
+
if (!sentOk) {
|
|
54791
|
+
switchAcks.get(id)?.(false);
|
|
54792
|
+
}
|
|
54793
|
+
return answer;
|
|
54794
|
+
},
|
|
54501
54795
|
serverVersion: () => hubVersion,
|
|
54502
54796
|
exit: upd.exit,
|
|
54503
54797
|
log,
|
|
54504
54798
|
...upd.enabled !== void 0 ? { enabled: upd.enabled } : {},
|
|
54505
54799
|
...upd.every ? { every: upd.every } : {}
|
|
54506
54800
|
}) : void 0;
|
|
54801
|
+
updaterRef = updater;
|
|
54507
54802
|
updater?.start();
|
|
54803
|
+
const reportTimer = upd ? setInterval(flushUpdateReports, REPORT_FLUSH_MS) : void 0;
|
|
54804
|
+
reportTimer?.unref?.();
|
|
54508
54805
|
return {
|
|
54509
54806
|
hub,
|
|
54510
54807
|
agents,
|
|
@@ -54514,6 +54811,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
54514
54811
|
ev("daemon_stop", { pid: process.pid });
|
|
54515
54812
|
selfCheck?.stop();
|
|
54516
54813
|
updater?.stop();
|
|
54814
|
+
if (reportTimer) clearInterval(reportTimer);
|
|
54517
54815
|
clearInterval(socketWatch);
|
|
54518
54816
|
clearInterval(watcher);
|
|
54519
54817
|
clearInterval(retry);
|
|
@@ -57526,7 +57824,7 @@ var noService = {
|
|
|
57526
57824
|
remove: async () => ({}),
|
|
57527
57825
|
cli: () => ["oa-bus"]
|
|
57528
57826
|
};
|
|
57529
|
-
var VERSION = true ? "0.
|
|
57827
|
+
var VERSION = true ? "0.203.0" : JSON.parse(
|
|
57530
57828
|
readFileSync21(new URL("../package.json", import.meta.url), "utf8")
|
|
57531
57829
|
).version;
|
|
57532
57830
|
var which = (cmd) => {
|
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.203.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": "963addb6a4f3232635cbb5c02330cc7711486dc7"
|
|
33
33
|
}
|
|
34
34
|
}
|