@open-artifacts/bus 0.137.0 → 0.139.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 +89 -3
- package/assets/oa_bus/copy.py +18 -1
- package/assets/oa_bus/frames.py +43 -2
- package/assets/oa_bus/link.py +1 -1
- package/assets/oa_bus/tools.py +44 -0
- package/dist/index.js +244 -21
- 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.139.0";
|
|
15
15
|
|
|
16
16
|
type Frame = Json & { type: string; id: string };
|
|
17
17
|
type Ctx = {
|
|
@@ -195,7 +195,7 @@ function receiptText(
|
|
|
195
195
|
const tail = (v: string) =>
|
|
196
196
|
r.reason === "recipient_closed"
|
|
197
197
|
? `was not delivered because ${v} closed first.`
|
|
198
|
-
: `was not
|
|
198
|
+
: `was not confirmed as delivered. Mail waits at most ${RETAIN}.`;
|
|
199
199
|
const head = (v: string) => `× Expired: your message to ${v}`;
|
|
200
200
|
if (!quote) return fitLine((v) => `${head(v)} ${tail(v)}`, to);
|
|
201
201
|
return fitLine((v) => quoted(head(v), quote, tail(v)), to);
|
|
@@ -396,6 +396,28 @@ const statusSetText = (state: string, label?: string): string =>
|
|
|
396
396
|
const earlierStatusText = (message: string): string =>
|
|
397
397
|
`Your previous status did not reach the user. ${message}`;
|
|
398
398
|
|
|
399
|
+
/** The `follow` result (#1317). */
|
|
400
|
+
const followText = (url: string): string =>
|
|
401
|
+
`Following ${url}. You get a notice here when it changes.`;
|
|
402
|
+
|
|
403
|
+
/** The `unfollow` result. */
|
|
404
|
+
const unfollowText = (removed: boolean, artifact: string): string =>
|
|
405
|
+
removed
|
|
406
|
+
? `Stopped following ${artifact}.`
|
|
407
|
+
: `You were not following ${artifact}.`;
|
|
408
|
+
|
|
409
|
+
/** The `following` result: one line per artifact, newest first. */
|
|
410
|
+
const followingText = (
|
|
411
|
+
follows: readonly { url: string; followed_at: string }[],
|
|
412
|
+
): string =>
|
|
413
|
+
follows.length
|
|
414
|
+
? follows.map((f) => `${f.url} (since ${f.followed_at})`).join("\n")
|
|
415
|
+
: "You are not following any artifacts.";
|
|
416
|
+
|
|
417
|
+
/** What an agent sees when its daemon is too old for the follow frames. */
|
|
418
|
+
const FOLLOW_OLD_DAEMON =
|
|
419
|
+
"This oa-bus daemon is too old to follow artifacts. Ask the user to update oa-bus.";
|
|
420
|
+
|
|
399
421
|
/** @oa/bus-protocol BAD_NS_CHARS: control, bidi and zero-width characters. */
|
|
400
422
|
const BAD_LABEL_CHARS =
|
|
401
423
|
// biome-ignore lint/suspicious/noControlCharactersInRegex: rejecting them is the point
|
|
@@ -513,6 +535,10 @@ export const copy = {
|
|
|
513
535
|
statusLabelTooLong,
|
|
514
536
|
statusSetText,
|
|
515
537
|
earlierStatusText,
|
|
538
|
+
followText,
|
|
539
|
+
unfollowText,
|
|
540
|
+
followingText,
|
|
541
|
+
FOLLOW_OLD_DAEMON,
|
|
516
542
|
displayKind,
|
|
517
543
|
statusSaysText,
|
|
518
544
|
rosterLine,
|
|
@@ -602,6 +628,35 @@ const TOOLS = [
|
|
|
602
628
|
additionalProperties: false,
|
|
603
629
|
},
|
|
604
630
|
},
|
|
631
|
+
{
|
|
632
|
+
name: "oabus_follow",
|
|
633
|
+
label: "Open Artifacts bus: follow artifact",
|
|
634
|
+
description:
|
|
635
|
+
"Follow an Open Artifacts artifact, by id or link, to get a notice when it changes.",
|
|
636
|
+
parameters: {
|
|
637
|
+
type: "object",
|
|
638
|
+
properties: { artifact: { type: "string" } },
|
|
639
|
+
required: ["artifact"],
|
|
640
|
+
additionalProperties: false,
|
|
641
|
+
},
|
|
642
|
+
},
|
|
643
|
+
{
|
|
644
|
+
name: "oabus_unfollow",
|
|
645
|
+
label: "Open Artifacts bus: unfollow artifact",
|
|
646
|
+
description: "Stop following an artifact, by id or link.",
|
|
647
|
+
parameters: {
|
|
648
|
+
type: "object",
|
|
649
|
+
properties: { artifact: { type: "string" } },
|
|
650
|
+
required: ["artifact"],
|
|
651
|
+
additionalProperties: false,
|
|
652
|
+
},
|
|
653
|
+
},
|
|
654
|
+
{
|
|
655
|
+
name: "oabus_following",
|
|
656
|
+
label: "Open Artifacts bus: list follows",
|
|
657
|
+
description: "List the artifacts you follow.",
|
|
658
|
+
parameters: none,
|
|
659
|
+
},
|
|
605
660
|
] as const;
|
|
606
661
|
|
|
607
662
|
const STATES = ["working", "idle", "blocked", "waiting_on_owner"];
|
|
@@ -915,7 +970,7 @@ function open(
|
|
|
915
970
|
// #1295: this asset decodes away rows and the new refusals.
|
|
916
971
|
// #1525: and a config file that is pending approval.
|
|
917
972
|
// #1635: and may send a rename.
|
|
918
|
-
caps: ["mailbox", "pending", "rename"],
|
|
973
|
+
caps: ["mailbox", "pending", "rename", "follow"],
|
|
919
974
|
attest: start ? { proc_start: start } : {},
|
|
920
975
|
}),
|
|
921
976
|
);
|
|
@@ -1202,11 +1257,42 @@ export default function oaBus(pi: Pi): void {
|
|
|
1202
1257
|
return stripTerminalControls(String(r.body));
|
|
1203
1258
|
}
|
|
1204
1259
|
if (name === "oabus_set_status") return statusTool(args, link);
|
|
1260
|
+
if (
|
|
1261
|
+
name === "oabus_follow" ||
|
|
1262
|
+
name === "oabus_unfollow" ||
|
|
1263
|
+
name === "oabus_following"
|
|
1264
|
+
)
|
|
1265
|
+
return followTool(name.slice("oabus_".length), args, link);
|
|
1205
1266
|
const r = await link.request({ type: "self", row: true });
|
|
1206
1267
|
if (r.type !== "agent") failed(r);
|
|
1207
1268
|
return selfText((r.agent ?? null) as Json | null);
|
|
1208
1269
|
};
|
|
1209
1270
|
|
|
1271
|
+
/** follow, unfollow and following (#1317). Refusals are the hub's or daemon's copy, as-is. */
|
|
1272
|
+
const followTool = async (
|
|
1273
|
+
name: string,
|
|
1274
|
+
args: Json,
|
|
1275
|
+
link: Link,
|
|
1276
|
+
): Promise<string> => {
|
|
1277
|
+
const artifact =
|
|
1278
|
+
typeof args.artifact === "string" ? args.artifact.trim() : "";
|
|
1279
|
+
if (name !== "following" && !artifact)
|
|
1280
|
+
throw new Error("oa-bus: artifact is required (an id or a link)");
|
|
1281
|
+
const r = await link.request(
|
|
1282
|
+
name === "following" ? { type: name } : { type: name, artifact },
|
|
1283
|
+
);
|
|
1284
|
+
if (r.type === "followed") return followText(String(r.url));
|
|
1285
|
+
if (r.type === "unfollowed")
|
|
1286
|
+
return unfollowText(r.removed === true, artifact);
|
|
1287
|
+
if (r.type === "follows")
|
|
1288
|
+
return followingText(
|
|
1289
|
+
(r.follows ?? []) as { url: string; followed_at: string }[],
|
|
1290
|
+
);
|
|
1291
|
+
if (r.type === "error" && r.code === "bad_frame")
|
|
1292
|
+
throw new Error(FOLLOW_OLD_DAEMON);
|
|
1293
|
+
return failed(r);
|
|
1294
|
+
};
|
|
1295
|
+
|
|
1210
1296
|
/** set_status. Arguments are checked first. Refusals are the daemon's copy, as-is. */
|
|
1211
1297
|
const statusTool = async (args: Json, link: Link): Promise<string> => {
|
|
1212
1298
|
const state = String(args.state ?? "");
|
package/assets/oa_bus/copy.py
CHANGED
|
@@ -142,7 +142,7 @@ def receipt_text(r, sent_to, namespaces=None, excerpt=None, moved_to=None, linke
|
|
|
142
142
|
def tail(v):
|
|
143
143
|
if reason == "recipient_closed":
|
|
144
144
|
return f"was not delivered because {v} closed first."
|
|
145
|
-
return f"was not
|
|
145
|
+
return f"was not confirmed as delivered. Mail waits at most {RETAIN}."
|
|
146
146
|
|
|
147
147
|
def head(v):
|
|
148
148
|
return f"× Expired: your message to {v}"
|
|
@@ -343,6 +343,23 @@ def earlier_status_text(message):
|
|
|
343
343
|
return f"Your previous status did not reach the user. {message}"
|
|
344
344
|
|
|
345
345
|
|
|
346
|
+
def follow_text(url):
|
|
347
|
+
return f"Following {url}. You get a notice here when it changes."
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
def unfollow_text(removed, artifact):
|
|
351
|
+
return f"Stopped following {artifact}." if removed else f"You were not following {artifact}."
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
def following_text(follows):
|
|
355
|
+
if not follows:
|
|
356
|
+
return "You are not following any artifacts."
|
|
357
|
+
return "\n".join(f"{f['url']} (since {f['followed_at']})" for f in follows)
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
FOLLOW_OLD_DAEMON = "This oa-bus daemon is too old to follow artifacts. Ask the user to update oa-bus."
|
|
361
|
+
|
|
362
|
+
|
|
346
363
|
def status_label_too_long(n):
|
|
347
364
|
return (
|
|
348
365
|
f"oa-bus: that label is {n} characters, and the limit is 64. "
|
package/assets/oa_bus/frames.py
CHANGED
|
@@ -130,7 +130,18 @@ def _base(frame, types):
|
|
|
130
130
|
|
|
131
131
|
# --- Frames the plugin sends.
|
|
132
132
|
|
|
133
|
-
ADAPTER_TYPES = (
|
|
133
|
+
ADAPTER_TYPES = (
|
|
134
|
+
"hello",
|
|
135
|
+
"send",
|
|
136
|
+
"list",
|
|
137
|
+
"self",
|
|
138
|
+
"fetch",
|
|
139
|
+
"ack",
|
|
140
|
+
"set_status",
|
|
141
|
+
"follow",
|
|
142
|
+
"unfollow",
|
|
143
|
+
"following",
|
|
144
|
+
)
|
|
134
145
|
|
|
135
146
|
|
|
136
147
|
def check_adapter_frame(frame):
|
|
@@ -184,10 +195,17 @@ def check_adapter_frame(frame):
|
|
|
184
195
|
lambda v: _is_str(v, 1, 128) and len([*v]) <= 64 and v == v.strip(),
|
|
185
196
|
"a label of 1 to 64 characters",
|
|
186
197
|
)
|
|
198
|
+
elif t == "follow" or t == "unfollow":
|
|
199
|
+
_need(
|
|
200
|
+
frame,
|
|
201
|
+
"artifact",
|
|
202
|
+
lambda v: _is_str(v, 1, 2048) and well_formed(v),
|
|
203
|
+
"a well-formed artifact id or link",
|
|
204
|
+
)
|
|
187
205
|
elif t == "self":
|
|
188
206
|
if "row" in frame and frame["row"] is not True:
|
|
189
207
|
_fail("row: expected true")
|
|
190
|
-
if t in ("send", "list", "self", "fetch", "set_status"):
|
|
208
|
+
if t in ("send", "list", "self", "fetch", "set_status", "follow", "unfollow", "following"):
|
|
191
209
|
_opt(frame, "late", lambda v: v is True, "true")
|
|
192
210
|
return frame
|
|
193
211
|
|
|
@@ -204,6 +222,9 @@ DAEMON_TYPES = (
|
|
|
204
222
|
"notice",
|
|
205
223
|
"error",
|
|
206
224
|
"status_set",
|
|
225
|
+
"followed",
|
|
226
|
+
"unfollowed",
|
|
227
|
+
"follows",
|
|
207
228
|
)
|
|
208
229
|
|
|
209
230
|
|
|
@@ -280,6 +301,26 @@ def parse_daemon_frame(frame):
|
|
|
280
301
|
elif t == "error":
|
|
281
302
|
_need(frame, "code", _is_str, "a string")
|
|
282
303
|
_need(frame, "message", _is_str, "a string")
|
|
304
|
+
elif t == "followed":
|
|
305
|
+
_need(frame, "artifact_id", _is_str, "a string")
|
|
306
|
+
_need(frame, "url", _is_str, "a string")
|
|
307
|
+
_need(frame, "followed_at", _is_str, "a string")
|
|
308
|
+
elif t == "unfollowed":
|
|
309
|
+
_need(frame, "removed", lambda v: isinstance(v, bool), "a boolean")
|
|
310
|
+
elif t == "follows":
|
|
311
|
+
_need(
|
|
312
|
+
frame,
|
|
313
|
+
"follows",
|
|
314
|
+
lambda v: isinstance(v, list)
|
|
315
|
+
and all(
|
|
316
|
+
isinstance(f, dict)
|
|
317
|
+
and _is_str(f.get("artifact_id"))
|
|
318
|
+
and _is_str(f.get("url"))
|
|
319
|
+
and _is_str(f.get("followed_at"))
|
|
320
|
+
for f in v
|
|
321
|
+
),
|
|
322
|
+
"a list of follows",
|
|
323
|
+
)
|
|
283
324
|
elif t == "status_set":
|
|
284
325
|
_opt(
|
|
285
326
|
frame,
|
package/assets/oa_bus/link.py
CHANGED
|
@@ -44,7 +44,7 @@ class Link:
|
|
|
44
44
|
"pid": pid,
|
|
45
45
|
"cwd": cwd,
|
|
46
46
|
"proposed_name": name,
|
|
47
|
-
"caps": ["mailbox", "pending"],
|
|
47
|
+
"caps": ["mailbox", "pending", "follow"],
|
|
48
48
|
"attest": {"proc_start": proc_start} if proc_start else {},
|
|
49
49
|
}
|
|
50
50
|
self._home = home if home is not None else bus_home()
|
package/assets/oa_bus/tools.py
CHANGED
|
@@ -70,6 +70,31 @@ TOOLS = [
|
|
|
70
70
|
"additionalProperties": False,
|
|
71
71
|
},
|
|
72
72
|
},
|
|
73
|
+
{
|
|
74
|
+
"name": "oabus_follow",
|
|
75
|
+
"description": "Follow an Open Artifacts artifact, by id or link, to get a notice when it changes.",
|
|
76
|
+
"parameters": {
|
|
77
|
+
"type": "object",
|
|
78
|
+
"properties": {"artifact": {"type": "string"}},
|
|
79
|
+
"required": ["artifact"],
|
|
80
|
+
"additionalProperties": False,
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"name": "oabus_unfollow",
|
|
85
|
+
"description": "Stop following an artifact, by id or link.",
|
|
86
|
+
"parameters": {
|
|
87
|
+
"type": "object",
|
|
88
|
+
"properties": {"artifact": {"type": "string"}},
|
|
89
|
+
"required": ["artifact"],
|
|
90
|
+
"additionalProperties": False,
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"name": "oabus_following",
|
|
95
|
+
"description": "List the artifacts you follow.",
|
|
96
|
+
"parameters": _NONE,
|
|
97
|
+
},
|
|
73
98
|
]
|
|
74
99
|
|
|
75
100
|
|
|
@@ -155,12 +180,31 @@ def run(name, args, link):
|
|
|
155
180
|
return copy.strip_terminal_controls(str(r["body"]))
|
|
156
181
|
if name == "oabus_set_status":
|
|
157
182
|
return _status(args, link)
|
|
183
|
+
if name in ("oabus_follow", "oabus_unfollow", "oabus_following"):
|
|
184
|
+
return _follow(name[len("oabus_") :], args, link)
|
|
158
185
|
r = link.request({"type": "self", "row": True})
|
|
159
186
|
if r["type"] != "agent":
|
|
160
187
|
_failed(r)
|
|
161
188
|
return copy.self_text(r.get("agent"))
|
|
162
189
|
|
|
163
190
|
|
|
191
|
+
def _follow(name, args, link):
|
|
192
|
+
"""follow, unfollow and following (#1317). Refusals are the hub's or daemon's copy, as-is."""
|
|
193
|
+
artifact = args.get("artifact").strip() if isinstance(args.get("artifact"), str) else ""
|
|
194
|
+
if name != "following" and not artifact:
|
|
195
|
+
raise ToolError("oa-bus: artifact is required (an id or a link)")
|
|
196
|
+
r = link.request({"type": name} if name == "following" else {"type": name, "artifact": artifact})
|
|
197
|
+
if r["type"] == "followed":
|
|
198
|
+
return copy.follow_text(str(r["url"]))
|
|
199
|
+
if r["type"] == "unfollowed":
|
|
200
|
+
return copy.unfollow_text(r["removed"] is True, artifact)
|
|
201
|
+
if r["type"] == "follows":
|
|
202
|
+
return copy.following_text(r["follows"])
|
|
203
|
+
if r["type"] == "error" and r.get("code") == "bad_frame":
|
|
204
|
+
raise ToolError(copy.FOLLOW_OLD_DAEMON)
|
|
205
|
+
_failed(r)
|
|
206
|
+
|
|
207
|
+
|
|
164
208
|
def _status(args, link):
|
|
165
209
|
"""set_status. Arguments are checked first. Refusals are the daemon's copy, as-is."""
|
|
166
210
|
state = str(args.get("state") or "")
|
package/dist/index.js
CHANGED
|
@@ -31408,7 +31408,15 @@ var init_caps = __esm({
|
|
|
31408
31408
|
* only when its hello listed it, and lists it in `hello_ok.caps`; any other
|
|
31409
31409
|
* socket sees today's isolation.
|
|
31410
31410
|
*/
|
|
31411
|
-
links: "links"
|
|
31411
|
+
links: "links",
|
|
31412
|
+
/**
|
|
31413
|
+
* Follows (#1317): the client may send `follow`, `unfollow` and `following`
|
|
31414
|
+
* and decodes `followed`, `unfollowed`, `follows` and the `follow_limit`
|
|
31415
|
+
* error. The hub answers those frames only on a socket whose hello listed
|
|
31416
|
+
* it (any other gets `bad_frame`, as an old hub would) and lists it in
|
|
31417
|
+
* `hello_ok.caps`; a client sends them only when it did.
|
|
31418
|
+
*/
|
|
31419
|
+
follow: "follow"
|
|
31412
31420
|
};
|
|
31413
31421
|
MAX_CAPS = 16;
|
|
31414
31422
|
CapTokenSchema = external_exports.string().regex(/^[a-z][a-z0-9_-]{0,31}$/);
|
|
@@ -32057,7 +32065,7 @@ function decode3(raw, schema, caps) {
|
|
|
32057
32065
|
function decodeServerFrame(raw) {
|
|
32058
32066
|
return decode3(raw, ServerFrameSchema, SERVER_CAPS);
|
|
32059
32067
|
}
|
|
32060
|
-
var PING, PONG, isWellFormed, WellFormedText, FrameIdSchema, base, BodySchema, InlineBodySchema, distinct, Hello, AgentUp, AgentDown, Sessions, Send, Ack, Refuse, List, Fetch, Status, Rename, 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;
|
|
32068
|
+
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, 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;
|
|
32061
32069
|
var init_protocol2 = __esm({
|
|
32062
32070
|
"../bus-protocol/src/protocol.ts"() {
|
|
32063
32071
|
"use strict";
|
|
@@ -32066,6 +32074,7 @@ var init_protocol2 = __esm({
|
|
|
32066
32074
|
init_ids();
|
|
32067
32075
|
init_kinds();
|
|
32068
32076
|
init_limits();
|
|
32077
|
+
init_meta();
|
|
32069
32078
|
init_names();
|
|
32070
32079
|
init_namespace();
|
|
32071
32080
|
init_receipts();
|
|
@@ -32192,6 +32201,45 @@ var init_protocol2 = __esm({
|
|
|
32192
32201
|
/** A tool rename is `chosen`; a harness reverting to its fallback is `default`. Absent means `chosen`. */
|
|
32193
32202
|
name_kind: NameKindSchema.optional()
|
|
32194
32203
|
});
|
|
32204
|
+
FollowRefSchema = WellFormedText.pipe(external_exports.string().min(1).max(2048));
|
|
32205
|
+
Follow = external_exports.strictObject({
|
|
32206
|
+
...base,
|
|
32207
|
+
type: external_exports.literal("follow"),
|
|
32208
|
+
from_ref: AgentRefSchema,
|
|
32209
|
+
artifact: FollowRefSchema
|
|
32210
|
+
});
|
|
32211
|
+
Unfollow = external_exports.strictObject({
|
|
32212
|
+
...base,
|
|
32213
|
+
type: external_exports.literal("unfollow"),
|
|
32214
|
+
from_ref: AgentRefSchema,
|
|
32215
|
+
artifact: FollowRefSchema
|
|
32216
|
+
});
|
|
32217
|
+
Following = external_exports.strictObject({
|
|
32218
|
+
...base,
|
|
32219
|
+
type: external_exports.literal("following"),
|
|
32220
|
+
from_ref: AgentRefSchema
|
|
32221
|
+
});
|
|
32222
|
+
MAX_FOLLOWS = 200;
|
|
32223
|
+
FollowEntry = external_exports.strictObject({
|
|
32224
|
+
artifact_id: external_exports.string().min(1).max(64),
|
|
32225
|
+
url: external_exports.string().min(1).max(2048),
|
|
32226
|
+
followed_at: IsoTimeSchema
|
|
32227
|
+
});
|
|
32228
|
+
Followed = external_exports.strictObject({
|
|
32229
|
+
...base,
|
|
32230
|
+
type: external_exports.literal("followed"),
|
|
32231
|
+
...FollowEntry.shape
|
|
32232
|
+
});
|
|
32233
|
+
Unfollowed = external_exports.strictObject({
|
|
32234
|
+
...base,
|
|
32235
|
+
type: external_exports.literal("unfollowed"),
|
|
32236
|
+
removed: external_exports.boolean()
|
|
32237
|
+
});
|
|
32238
|
+
Follows = external_exports.strictObject({
|
|
32239
|
+
...base,
|
|
32240
|
+
type: external_exports.literal("follows"),
|
|
32241
|
+
follows: external_exports.array(FollowEntry).max(MAX_FOLLOWS)
|
|
32242
|
+
});
|
|
32195
32243
|
HelloOk = external_exports.strictObject({
|
|
32196
32244
|
...base,
|
|
32197
32245
|
type: external_exports.literal("hello_ok"),
|
|
@@ -32276,7 +32324,9 @@ var init_protocol2 = __esm({
|
|
|
32276
32324
|
"not_found",
|
|
32277
32325
|
"too_large",
|
|
32278
32326
|
"rate_limited",
|
|
32279
|
-
"internal"
|
|
32327
|
+
"internal",
|
|
32328
|
+
/** Only to a socket whose hello listed `BUS_CAPS.follow` (#1317). */
|
|
32329
|
+
"follow_limit"
|
|
32280
32330
|
]),
|
|
32281
32331
|
message: WellFormedText.pipe(external_exports.string().max(1024))
|
|
32282
32332
|
});
|
|
@@ -32289,7 +32339,12 @@ var init_protocol2 = __esm({
|
|
|
32289
32339
|
type: external_exports.literal("deliver"),
|
|
32290
32340
|
msg_id: MsgIdSchema,
|
|
32291
32341
|
to_ref: AgentRefSchema,
|
|
32292
|
-
|
|
32342
|
+
/**
|
|
32343
|
+
* The sender's name, or the instance's reserved sender (#1317: the hub's
|
|
32344
|
+
* server notices). Only a server frame carries the reserved name: every
|
|
32345
|
+
* name an agent can send or register still refuses it (BusNameSchema).
|
|
32346
|
+
*/
|
|
32347
|
+
from_name: external_exports.union([BusNameSchema, external_exports.literal(INSTANCE_SENDER_NAME)]),
|
|
32293
32348
|
/** The sender's agent id on the hub: a reply names it as `to_id`. */
|
|
32294
32349
|
from_id: IdSchema.optional(),
|
|
32295
32350
|
/** The SENDER's namespace, so a reply can set `to_namespace` from it. */
|
|
@@ -32320,7 +32375,10 @@ var init_protocol2 = __esm({
|
|
|
32320
32375
|
List,
|
|
32321
32376
|
Fetch,
|
|
32322
32377
|
Status,
|
|
32323
|
-
Rename
|
|
32378
|
+
Rename,
|
|
32379
|
+
Follow,
|
|
32380
|
+
Unfollow,
|
|
32381
|
+
Following
|
|
32324
32382
|
]);
|
|
32325
32383
|
ServerFrameSchema = external_exports.discriminatedUnion("type", [
|
|
32326
32384
|
HelloOk,
|
|
@@ -32332,7 +32390,10 @@ var init_protocol2 = __esm({
|
|
|
32332
32390
|
Deliver,
|
|
32333
32391
|
ReceiptUpdate,
|
|
32334
32392
|
RosterChanged,
|
|
32335
|
-
Renamed
|
|
32393
|
+
Renamed,
|
|
32394
|
+
Followed,
|
|
32395
|
+
Unfollowed,
|
|
32396
|
+
Follows
|
|
32336
32397
|
]);
|
|
32337
32398
|
FrameSchema = external_exports.discriminatedUnion("type", [
|
|
32338
32399
|
Hello,
|
|
@@ -32346,6 +32407,9 @@ var init_protocol2 = __esm({
|
|
|
32346
32407
|
Fetch,
|
|
32347
32408
|
Status,
|
|
32348
32409
|
Rename,
|
|
32410
|
+
Follow,
|
|
32411
|
+
Unfollow,
|
|
32412
|
+
Following,
|
|
32349
32413
|
HelloOk,
|
|
32350
32414
|
AgentOk,
|
|
32351
32415
|
ReceiptFrame,
|
|
@@ -32355,7 +32419,10 @@ var init_protocol2 = __esm({
|
|
|
32355
32419
|
Deliver,
|
|
32356
32420
|
ReceiptUpdate,
|
|
32357
32421
|
RosterChanged,
|
|
32358
|
-
Renamed
|
|
32422
|
+
Renamed,
|
|
32423
|
+
Followed,
|
|
32424
|
+
Unfollowed,
|
|
32425
|
+
Follows
|
|
32359
32426
|
]);
|
|
32360
32427
|
MAX_RAW_FRAME_CHARS = 2 * LIMITS.maxMessageBytes + 4096;
|
|
32361
32428
|
SERVER_CAPS = { depth: 5, tokens: 65536, structural: 131072 };
|
|
@@ -32411,7 +32478,7 @@ var init_src = __esm({
|
|
|
32411
32478
|
});
|
|
32412
32479
|
|
|
32413
32480
|
// ../bus-ipc/src/frames.ts
|
|
32414
|
-
var V, MAX_BODY_BYTES, MAX_LINE_BYTES, INLINE_CAP_BYTES, KIND, KIND_TOKEN, AGENT_REF, base2, late, isWellFormed2, WELL_FORMED, CLIENT_VERSION, clientVersion, ADAPTER_CAPS, Hello2, SPAWNED_SOURCES, optIn, Send2, List2, Self, Fetch2, Ack2, SetStatus, Rename2, StatusRequest, AdapterFrame, ConfigFile, AgentInfo, Welcome, Receipt, Roster2, Agent, StatusSet, Body, Deliver2, Notice2, ErrorFrame2, StatusReply, DaemonFrame;
|
|
32481
|
+
var V, MAX_BODY_BYTES, MAX_LINE_BYTES, INLINE_CAP_BYTES, KIND, KIND_TOKEN, AGENT_REF, base2, late, isWellFormed2, WELL_FORMED, CLIENT_VERSION, clientVersion, ADAPTER_CAPS, Hello2, SPAWNED_SOURCES, optIn, Send2, List2, Self, Fetch2, Ack2, SetStatus, Rename2, Follow2, Unfollow2, Following2, StatusRequest, AdapterFrame, ConfigFile, AgentInfo, Welcome, Receipt, Roster2, Agent, StatusSet, FollowEntry2, Followed2, Unfollowed2, Follows2, Body, Deliver2, Notice2, ErrorFrame2, StatusReply, DaemonFrame;
|
|
32415
32482
|
var init_frames = __esm({
|
|
32416
32483
|
"../bus-ipc/src/frames.ts"() {
|
|
32417
32484
|
"use strict";
|
|
@@ -32428,7 +32495,7 @@ var init_frames = __esm({
|
|
|
32428
32495
|
late = { late: external_exports.array(external_exports.string().min(1)).optional() };
|
|
32429
32496
|
isWellFormed2 = (s) => s.isWellFormed();
|
|
32430
32497
|
WELL_FORMED = { message: "text is not well-formed unicode" };
|
|
32431
|
-
CLIENT_VERSION = true ? "0.
|
|
32498
|
+
CLIENT_VERSION = true ? "0.139.0" : "0.0.0";
|
|
32432
32499
|
clientVersion = {
|
|
32433
32500
|
client_version: external_exports.string().min(1).max(64).optional()
|
|
32434
32501
|
};
|
|
@@ -32447,7 +32514,15 @@ var init_frames = __esm({
|
|
|
32447
32514
|
* adapter that listed it, and an adapter sends the frame only to a daemon
|
|
32448
32515
|
* whose welcome listed it, so neither side meets a frame its decoder lacks.
|
|
32449
32516
|
*/
|
|
32450
|
-
rename: "rename"
|
|
32517
|
+
rename: "rename",
|
|
32518
|
+
/**
|
|
32519
|
+
* `follow` (#1317): the adapter may send `follow`, `unfollow` and
|
|
32520
|
+
* `following`. The daemon lists `follow` in `welcome.caps` only for an
|
|
32521
|
+
* adapter that listed it, and an adapter sends the frames only to a daemon
|
|
32522
|
+
* whose welcome listed it. The adapter tools are offered either way: a
|
|
32523
|
+
* daemon without it answers them with a plain "update" error instead.
|
|
32524
|
+
*/
|
|
32525
|
+
follow: "follow"
|
|
32451
32526
|
};
|
|
32452
32527
|
Hello2 = external_exports.object({
|
|
32453
32528
|
...base2,
|
|
@@ -32551,6 +32626,23 @@ var init_frames = __esm({
|
|
|
32551
32626
|
type: external_exports.literal("rename"),
|
|
32552
32627
|
name: external_exports.string().min(1).max(64).refine(isWellFormed2, WELL_FORMED)
|
|
32553
32628
|
});
|
|
32629
|
+
Follow2 = external_exports.object({
|
|
32630
|
+
...base2,
|
|
32631
|
+
...optIn,
|
|
32632
|
+
type: external_exports.literal("follow"),
|
|
32633
|
+
artifact: external_exports.string().min(1).max(2048).refine(isWellFormed2, WELL_FORMED)
|
|
32634
|
+
});
|
|
32635
|
+
Unfollow2 = external_exports.object({
|
|
32636
|
+
...base2,
|
|
32637
|
+
...optIn,
|
|
32638
|
+
type: external_exports.literal("unfollow"),
|
|
32639
|
+
artifact: external_exports.string().min(1).max(2048).refine(isWellFormed2, WELL_FORMED)
|
|
32640
|
+
});
|
|
32641
|
+
Following2 = external_exports.object({
|
|
32642
|
+
...base2,
|
|
32643
|
+
...optIn,
|
|
32644
|
+
type: external_exports.literal("following")
|
|
32645
|
+
});
|
|
32554
32646
|
StatusRequest = external_exports.object({
|
|
32555
32647
|
...base2,
|
|
32556
32648
|
...clientVersion,
|
|
@@ -32567,7 +32659,10 @@ var init_frames = __esm({
|
|
|
32567
32659
|
Fetch2,
|
|
32568
32660
|
Ack2,
|
|
32569
32661
|
SetStatus,
|
|
32570
|
-
Rename2
|
|
32662
|
+
Rename2,
|
|
32663
|
+
Follow2,
|
|
32664
|
+
Unfollow2,
|
|
32665
|
+
Following2
|
|
32571
32666
|
]);
|
|
32572
32667
|
ConfigFile = external_exports.object({
|
|
32573
32668
|
file: external_exports.string(),
|
|
@@ -32606,7 +32701,7 @@ var init_frames = __esm({
|
|
|
32606
32701
|
bus_name: external_exports.string(),
|
|
32607
32702
|
namespace: external_exports.string(),
|
|
32608
32703
|
global: external_exports.boolean(),
|
|
32609
|
-
/** What this daemon accepts (ADAPTER_CAPS), only for an adapter that listed `rename`. */
|
|
32704
|
+
/** What this daemon accepts (ADAPTER_CAPS), only for an adapter that listed `rename` or `follow`. */
|
|
32610
32705
|
caps: external_exports.array(external_exports.string().max(32)).max(16).optional()
|
|
32611
32706
|
});
|
|
32612
32707
|
Receipt = external_exports.object({
|
|
@@ -32643,6 +32738,29 @@ var init_frames = __esm({
|
|
|
32643
32738
|
earlier: external_exports.object({ code: external_exports.string(), message: external_exports.string() }).optional(),
|
|
32644
32739
|
...late
|
|
32645
32740
|
});
|
|
32741
|
+
FollowEntry2 = external_exports.object({
|
|
32742
|
+
artifact_id: external_exports.string(),
|
|
32743
|
+
url: external_exports.string(),
|
|
32744
|
+
followed_at: external_exports.string()
|
|
32745
|
+
});
|
|
32746
|
+
Followed2 = external_exports.object({
|
|
32747
|
+
...base2,
|
|
32748
|
+
type: external_exports.literal("followed"),
|
|
32749
|
+
...FollowEntry2.shape,
|
|
32750
|
+
...late
|
|
32751
|
+
});
|
|
32752
|
+
Unfollowed2 = external_exports.object({
|
|
32753
|
+
...base2,
|
|
32754
|
+
type: external_exports.literal("unfollowed"),
|
|
32755
|
+
removed: external_exports.boolean(),
|
|
32756
|
+
...late
|
|
32757
|
+
});
|
|
32758
|
+
Follows2 = external_exports.object({
|
|
32759
|
+
...base2,
|
|
32760
|
+
type: external_exports.literal("follows"),
|
|
32761
|
+
follows: external_exports.array(FollowEntry2),
|
|
32762
|
+
...late
|
|
32763
|
+
});
|
|
32646
32764
|
Body = external_exports.object({
|
|
32647
32765
|
...base2,
|
|
32648
32766
|
type: external_exports.literal("body"),
|
|
@@ -32734,7 +32852,10 @@ var init_frames = __esm({
|
|
|
32734
32852
|
Notice2,
|
|
32735
32853
|
ErrorFrame2,
|
|
32736
32854
|
StatusReply,
|
|
32737
|
-
StatusSet
|
|
32855
|
+
StatusSet,
|
|
32856
|
+
Followed2,
|
|
32857
|
+
Unfollowed2,
|
|
32858
|
+
Follows2
|
|
32738
32859
|
]);
|
|
32739
32860
|
}
|
|
32740
32861
|
});
|
|
@@ -33019,7 +33140,7 @@ function receiptText(r, sentTo, namespaces, excerpt, movedTo2, linkedNs) {
|
|
|
33019
33140
|
case "delivered":
|
|
33020
33141
|
return fitLine((v) => `\u2713 Delivered to ${v}.`, to);
|
|
33021
33142
|
case "expired": {
|
|
33022
|
-
const tail = (v) => r.reason === "recipient_closed" ? `was not delivered because ${v} closed first.` : `was not
|
|
33143
|
+
const tail = (v) => r.reason === "recipient_closed" ? `was not delivered because ${v} closed first.` : `was not confirmed as delivered. Mail waits at most ${RETAIN}.`;
|
|
33023
33144
|
const head = (v) => `\xD7 Expired: your message to ${v}`;
|
|
33024
33145
|
if (!quote) return fitLine((v) => `${head(v)} ${tail(v)}`, to);
|
|
33025
33146
|
return fitLine((v) => quoted(head(v), quote, tail(v)), to);
|
|
@@ -33135,7 +33256,7 @@ function selfText(agent) {
|
|
|
33135
33256
|
};
|
|
33136
33257
|
return JSON.stringify(shown4, null, 2);
|
|
33137
33258
|
}
|
|
33138
|
-
var MAX_COLS, RETAIN, MB, refusals, quoted, TERMINAL_CONTROLS, CUT_OFF, stripTerminalControls, KIND_CHARS, displayKind, neutralizeBody, deliveredText, oversizedText, INVISIBLES, EXCERPT_CHARS, STATUS_COPY, BAD_LABEL_CHARS2, cleanStatusLabel, statusLabelTooLong, statusSetText, earlierStatusText, STATUS_STALE_MS, agoText, displayLabel, awayTime, replyGoneText;
|
|
33259
|
+
var MAX_COLS, RETAIN, MB, refusals, quoted, TERMINAL_CONTROLS, CUT_OFF, stripTerminalControls, KIND_CHARS, displayKind, neutralizeBody, deliveredText, oversizedText, INVISIBLES, EXCERPT_CHARS, STATUS_COPY, BAD_LABEL_CHARS2, cleanStatusLabel, statusLabelTooLong, statusSetText, earlierStatusText, followText, unfollowText, followingText, FOLLOW_OLD_DAEMON, STATUS_STALE_MS, agoText, displayLabel, awayTime, replyGoneText;
|
|
33139
33260
|
var init_copy = __esm({
|
|
33140
33261
|
"../bus-ipc/src/copy.ts"() {
|
|
33141
33262
|
"use strict";
|
|
@@ -33237,6 +33358,10 @@ ${neutralizeBody(m.body)}`;
|
|
|
33237
33358
|
statusLabelTooLong = (n) => `oa-bus: that label is ${n} characters, and the limit is ${LIMITS.maxLabelChars}. Your status did not change. Send a shorter one.`;
|
|
33238
33359
|
statusSetText = (state, label) => `Your status is now ${state}${label ? `: "${label}"` : ""}. The user sees it as your own report.`;
|
|
33239
33360
|
earlierStatusText = (message) => `Your previous status did not reach the user. ${message}`;
|
|
33361
|
+
followText = (url2) => `Following ${url2}. You get a notice here when it changes.`;
|
|
33362
|
+
unfollowText = (removed, artifact) => removed ? `Stopped following ${artifact}.` : `You were not following ${artifact}.`;
|
|
33363
|
+
followingText = (follows) => follows.length ? follows.map((f) => `${f.url} (since ${f.followed_at})`).join("\n") : "You are not following any artifacts.";
|
|
33364
|
+
FOLLOW_OLD_DAEMON = "This oa-bus daemon is too old to follow artifacts. Ask the user to update oa-bus.";
|
|
33240
33365
|
STATUS_STALE_MS = 10 * 6e4;
|
|
33241
33366
|
agoText = (ms) => {
|
|
33242
33367
|
const mins = Math.round(ms / 6e4);
|
|
@@ -33587,6 +33712,8 @@ async function callTool(name, args, client, signal) {
|
|
|
33587
33712
|
async function run(name, args, request) {
|
|
33588
33713
|
try {
|
|
33589
33714
|
if (name === "set_status") return await statusTool(args, request);
|
|
33715
|
+
if (name === "follow" || name === "unfollow" || name === "following")
|
|
33716
|
+
return await followTool(name, args, request);
|
|
33590
33717
|
if (name === "list_agents") {
|
|
33591
33718
|
const r = await request({ type: "list" });
|
|
33592
33719
|
if (r.type !== "roster") return failed(r);
|
|
@@ -33678,6 +33805,18 @@ ${earlierStatusText(r.earlier.message)}` : done,
|
|
|
33678
33805
|
return text(STATUS_COPY.bad_frame, true);
|
|
33679
33806
|
return text(r.message, true);
|
|
33680
33807
|
}
|
|
33808
|
+
async function followTool(name, args, request) {
|
|
33809
|
+
const artifact = typeof args.artifact === "string" ? args.artifact.trim() : "";
|
|
33810
|
+
if (name !== "following" && !artifact)
|
|
33811
|
+
return text("oa-bus: artifact is required (an id or a link)", true);
|
|
33812
|
+
const r = name === "following" ? await request({ type: "following" }) : await request({ type: name, artifact });
|
|
33813
|
+
if (r.type === "followed") return text(followText(r.url));
|
|
33814
|
+
if (r.type === "unfollowed") return text(unfollowText(r.removed, artifact));
|
|
33815
|
+
if (r.type === "follows") return text(followingText(r.follows));
|
|
33816
|
+
if (r.type === "error" && r.code === "bad_frame")
|
|
33817
|
+
return text(FOLLOW_OLD_DAEMON, true);
|
|
33818
|
+
return failed(r);
|
|
33819
|
+
}
|
|
33681
33820
|
async function namespacesOf(name, request) {
|
|
33682
33821
|
try {
|
|
33683
33822
|
const r = await request({ type: "list" });
|
|
@@ -33781,6 +33920,31 @@ var init_tools = __esm({
|
|
|
33781
33920
|
required: ["state"],
|
|
33782
33921
|
additionalProperties: false
|
|
33783
33922
|
}
|
|
33923
|
+
},
|
|
33924
|
+
{
|
|
33925
|
+
name: "follow",
|
|
33926
|
+
description: "Follow an Open Artifacts artifact, by id or link, to get a notice when it changes.",
|
|
33927
|
+
inputSchema: {
|
|
33928
|
+
type: "object",
|
|
33929
|
+
properties: { artifact: { type: "string" } },
|
|
33930
|
+
required: ["artifact"],
|
|
33931
|
+
additionalProperties: false
|
|
33932
|
+
}
|
|
33933
|
+
},
|
|
33934
|
+
{
|
|
33935
|
+
name: "unfollow",
|
|
33936
|
+
description: "Stop following an artifact, by id or link.",
|
|
33937
|
+
inputSchema: {
|
|
33938
|
+
type: "object",
|
|
33939
|
+
properties: { artifact: { type: "string" } },
|
|
33940
|
+
required: ["artifact"],
|
|
33941
|
+
additionalProperties: false
|
|
33942
|
+
}
|
|
33943
|
+
},
|
|
33944
|
+
{
|
|
33945
|
+
name: "following",
|
|
33946
|
+
description: "List the artifacts you follow.",
|
|
33947
|
+
inputSchema: none
|
|
33784
33948
|
}
|
|
33785
33949
|
];
|
|
33786
33950
|
text = (t, isError) => ({
|
|
@@ -33839,7 +34003,7 @@ function codexHello(call, pid, ppid) {
|
|
|
33839
34003
|
pid,
|
|
33840
34004
|
...call.cwd ? { cwd: call.cwd } : {},
|
|
33841
34005
|
proposed_name: "codex",
|
|
33842
|
-
caps: [ADAPTER_CAPS.mailbox, ADAPTER_CAPS.pending],
|
|
34006
|
+
caps: [ADAPTER_CAPS.mailbox, ADAPTER_CAPS.pending, ADAPTER_CAPS.follow],
|
|
33843
34007
|
codex: {
|
|
33844
34008
|
thread_id: call.threadId,
|
|
33845
34009
|
call_id: call.callId,
|
|
@@ -34082,7 +34246,7 @@ function sessionHello(session, pid, cwd) {
|
|
|
34082
34246
|
pid,
|
|
34083
34247
|
cwd,
|
|
34084
34248
|
proposed_name: fitName(session.name, 64) || void 0,
|
|
34085
|
-
caps: [ADAPTER_CAPS.mailbox, ADAPTER_CAPS.pending],
|
|
34249
|
+
caps: [ADAPTER_CAPS.mailbox, ADAPTER_CAPS.pending, ADAPTER_CAPS.follow],
|
|
34086
34250
|
attest: {
|
|
34087
34251
|
session_id: session.sessionId,
|
|
34088
34252
|
socket_path: session.socketPath ?? void 0
|
|
@@ -37975,7 +38139,7 @@ async function handleToolCall(input2) {
|
|
|
37975
38139
|
pid: process.pid,
|
|
37976
38140
|
cwd: session.directory,
|
|
37977
38141
|
proposed_name: nameOf(session.title),
|
|
37978
|
-
caps: [ADAPTER_CAPS.mailbox, ADAPTER_CAPS.pending],
|
|
38142
|
+
caps: [ADAPTER_CAPS.mailbox, ADAPTER_CAPS.pending, ADAPTER_CAPS.follow],
|
|
37979
38143
|
attest: { session_id: sessionId }
|
|
37980
38144
|
});
|
|
37981
38145
|
let client;
|
|
@@ -40317,7 +40481,7 @@ var HubConnection = class {
|
|
|
40317
40481
|
// Reply ids: the hub then names each sender's agent (deliver.from_id).
|
|
40318
40482
|
// Mailboxes: the hub then sends queued/since, away rows and the new
|
|
40319
40483
|
// refusals, and honours agent_up.replaces (#1295).
|
|
40320
|
-
caps: [BUS_CAPS.ids, BUS_CAPS.mailbox, BUS_CAPS.links]
|
|
40484
|
+
caps: [BUS_CAPS.ids, BUS_CAPS.mailbox, BUS_CAPS.links, BUS_CAPS.follow]
|
|
40321
40485
|
});
|
|
40322
40486
|
this.#guard("sessions", () => {
|
|
40323
40487
|
this.send({
|
|
@@ -40812,6 +40976,10 @@ var Pending = class {
|
|
|
40812
40976
|
};
|
|
40813
40977
|
var MACHINE_CAP_COPY = "This machine has too many agents on the bus right now. Close a session you no longer need; this one retries in a few minutes.";
|
|
40814
40978
|
var MEMBER_CAP_COPY = "Your bus has too many agents right now. Close a session you no longer need; this one retries in a few minutes.";
|
|
40979
|
+
var FOLLOW_COPY = {
|
|
40980
|
+
down: "The hub is not connected right now. Try again in a moment.",
|
|
40981
|
+
old_hub: "This Open Artifacts hub is too old to follow artifacts. Ask the user to update it."
|
|
40982
|
+
};
|
|
40815
40983
|
var CAP_COPY = {
|
|
40816
40984
|
machine: MACHINE_CAP_COPY,
|
|
40817
40985
|
member: MEMBER_CAP_COPY
|
|
@@ -40910,6 +41078,47 @@ function routeLocal(frame, hello, reply, ctx) {
|
|
|
40910
41078
|
(f) => reply({ ...f, v: 1, id: frame.id })
|
|
40911
41079
|
);
|
|
40912
41080
|
}
|
|
41081
|
+
case "follow":
|
|
41082
|
+
case "unfollow":
|
|
41083
|
+
case "following": {
|
|
41084
|
+
if (!hello.caps?.includes(ADAPTER_CAPS.follow))
|
|
41085
|
+
return {
|
|
41086
|
+
type: "error",
|
|
41087
|
+
code: "bad_frame",
|
|
41088
|
+
message: "follow is not supported on this connection"
|
|
41089
|
+
};
|
|
41090
|
+
const cap = ctx.limited?.(ref);
|
|
41091
|
+
if (cap)
|
|
41092
|
+
return { type: "error", code: "rate_limited", message: CAP_COPY[cap] };
|
|
41093
|
+
const support = ctx.followSupport?.() ?? "down";
|
|
41094
|
+
if (support !== "ok")
|
|
41095
|
+
return {
|
|
41096
|
+
type: "error",
|
|
41097
|
+
code: support === "old_hub" ? "unsupported" : "hub_unavailable",
|
|
41098
|
+
message: FOLLOW_COPY[support]
|
|
41099
|
+
};
|
|
41100
|
+
const build = (id2) => frame.type === "following" ? { v: 1, id: id2, type: "following", from_ref: ref } : {
|
|
41101
|
+
v: 1,
|
|
41102
|
+
id: id2,
|
|
41103
|
+
type: frame.type,
|
|
41104
|
+
from_ref: ref,
|
|
41105
|
+
artifact: frame.artifact
|
|
41106
|
+
};
|
|
41107
|
+
if (!ClientFrameSchema.safeParse(build("probe")).success)
|
|
41108
|
+
return {
|
|
41109
|
+
type: "error",
|
|
41110
|
+
code: "bad_frame",
|
|
41111
|
+
message: "the frame is not valid on the hub wire"
|
|
41112
|
+
};
|
|
41113
|
+
const id = ctx.pending.open(frame.id, reply);
|
|
41114
|
+
if (ctx.hub.send(build(id))) return void 0;
|
|
41115
|
+
ctx.pending.cancel(id);
|
|
41116
|
+
return {
|
|
41117
|
+
type: "error",
|
|
41118
|
+
code: "hub_unavailable",
|
|
41119
|
+
message: FOLLOW_COPY.down
|
|
41120
|
+
};
|
|
41121
|
+
}
|
|
40913
41122
|
case "list":
|
|
40914
41123
|
case "send":
|
|
40915
41124
|
case "fetch": {
|
|
@@ -42810,6 +43019,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
42810
43019
|
let hubDroppedAt;
|
|
42811
43020
|
let hubIds = false;
|
|
42812
43021
|
let hubMailbox = false;
|
|
43022
|
+
let hubFollow = false;
|
|
42813
43023
|
let hubHelloed = false;
|
|
42814
43024
|
let hubVersion;
|
|
42815
43025
|
const hub = new HubConnection({
|
|
@@ -42912,6 +43122,9 @@ async function runDaemon(deps2 = {}) {
|
|
|
42912
43122
|
return;
|
|
42913
43123
|
}
|
|
42914
43124
|
case "roster":
|
|
43125
|
+
case "followed":
|
|
43126
|
+
case "unfollowed":
|
|
43127
|
+
case "follows":
|
|
42915
43128
|
pending.settle(frame);
|
|
42916
43129
|
return;
|
|
42917
43130
|
case "body":
|
|
@@ -42921,6 +43134,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
42921
43134
|
hubVersion = frame.server_version;
|
|
42922
43135
|
hubIds = frame.caps?.includes(BUS_CAPS.ids) ?? false;
|
|
42923
43136
|
hubMailbox = frame.caps?.includes(BUS_CAPS.mailbox) ?? false;
|
|
43137
|
+
hubFollow = frame.caps?.includes(BUS_CAPS.follow) ?? false;
|
|
42924
43138
|
hubHelloed = true;
|
|
42925
43139
|
for (const rec of agents.all())
|
|
42926
43140
|
if (rec.live && rec.replaces !== void 0) announceUp(rec);
|
|
@@ -42972,6 +43186,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
42972
43186
|
hubVersion = void 0;
|
|
42973
43187
|
hubIds = false;
|
|
42974
43188
|
hubMailbox = false;
|
|
43189
|
+
hubFollow = false;
|
|
42975
43190
|
hubHelloed = false;
|
|
42976
43191
|
statusRelay.dropped();
|
|
42977
43192
|
receipts.release();
|
|
@@ -43101,7 +43316,14 @@ async function runDaemon(deps2 = {}) {
|
|
|
43101
43316
|
};
|
|
43102
43317
|
},
|
|
43103
43318
|
onHello: (hello, closed) => {
|
|
43104
|
-
const capsFor = (h) =>
|
|
43319
|
+
const capsFor = (h) => {
|
|
43320
|
+
const listed2 = [
|
|
43321
|
+
...(h.kind === "pi" || h.kind === "omp") && h.caps?.includes(ADAPTER_CAPS.rename) ? [ADAPTER_CAPS.rename] : [],
|
|
43322
|
+
// #1317: whether the hub takes follows is answered per request.
|
|
43323
|
+
...h.caps?.includes(ADAPTER_CAPS.follow) ? [ADAPTER_CAPS.follow] : []
|
|
43324
|
+
];
|
|
43325
|
+
return listed2.length > 0 ? { caps: listed2 } : {};
|
|
43326
|
+
};
|
|
43105
43327
|
if (hello.cwd === void 0 && hello.kind !== "codex")
|
|
43106
43328
|
return { error: "cwd is required" };
|
|
43107
43329
|
const attested = (pid) => {
|
|
@@ -43229,6 +43451,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
43229
43451
|
limited: (ref) => limited.has(ref) ? caps.get(ref) ?? "machine" : void 0,
|
|
43230
43452
|
version: version2,
|
|
43231
43453
|
configFiles,
|
|
43454
|
+
followSupport: () => !hub.open || !hubHelloed ? "down" : hubFollow ? "ok" : "old_hub",
|
|
43232
43455
|
renamed: (ref, name) => {
|
|
43233
43456
|
const rec = agents.byRef(ref);
|
|
43234
43457
|
if (rec) renameFromAdapter(rec, name);
|
|
@@ -45721,7 +45944,7 @@ var noService = {
|
|
|
45721
45944
|
remove: async () => ({}),
|
|
45722
45945
|
cli: () => ["oa-bus"]
|
|
45723
45946
|
};
|
|
45724
|
-
var VERSION = true ? "0.
|
|
45947
|
+
var VERSION = true ? "0.139.0" : JSON.parse(
|
|
45725
45948
|
readFileSync13(new URL("../package.json", import.meta.url), "utf8")
|
|
45726
45949
|
).version;
|
|
45727
45950
|
var which = (cmd) => {
|