@open-artifacts/bus 0.253.1 → 0.256.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 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.253.1";
14
+ const CLIENT_VERSION = "0.256.0";
15
15
 
16
16
  type Frame = Json & { type: string; id: string };
17
17
  type Ctx = {
@@ -573,11 +573,19 @@ function rosterLine(
573
573
  }
574
574
 
575
575
  /** @oa/bus-protocol isFallbackName: a name only the harness gave the session. */
576
+ const KIND_DEFAULT_NAMES: Readonly<Record<string, string>> = {
577
+ antigravity: "agy",
578
+ };
579
+
576
580
  const isFallbackName = (name: string, kind: string): boolean => {
577
581
  const lname = name.toLowerCase();
582
+ const d = Object.hasOwn(KIND_DEFAULT_NAMES, kind)
583
+ ? KIND_DEFAULT_NAMES[kind]
584
+ : undefined;
578
585
  return (
579
586
  lname === kind ||
580
587
  lname.startsWith(`${kind}-`) ||
588
+ (d !== undefined && (lname === d || lname.startsWith(`${d}-`))) ||
581
589
  lname === "agent" ||
582
590
  /^claude-\d+$/.test(lname)
583
591
  );
@@ -493,10 +493,20 @@ def roster_line(a, now_ms, home=None):
493
493
  return f"- {a['name']} ({', '.join(parts)}){mark}{tail}"
494
494
 
495
495
 
496
+ KIND_DEFAULT_NAMES = {"antigravity": "agy"}
497
+
498
+
496
499
  def is_fallback_name(name, kind):
497
500
  """bus-protocol isFallbackName: a name only the harness gave the session."""
498
501
  low = name.lower()
499
- return low == kind or low.startswith(f"{kind}-") or low == "agent" or re.fullmatch(r"claude-\d+", low) is not None
502
+ d = KIND_DEFAULT_NAMES.get(kind)
503
+ return (
504
+ low == kind
505
+ or low.startswith(f"{kind}-")
506
+ or (d is not None and (low == d or low.startswith(f"{d}-")))
507
+ or low == "agent"
508
+ or re.fullmatch(r"claude-\d+", low) is not None
509
+ )
500
510
 
501
511
 
502
512
  AWAY_RECENT_MS = 60 * 60_000
@@ -27212,9 +27212,13 @@ var KindTokenSchema = external_exports.string().regex(/^[a-z][a-z0-9-]{0,31}$/);
27212
27212
 
27213
27213
  // ../bus-protocol/src/meta.ts
27214
27214
  var FALLBACK_BUS_NAME = "agent";
27215
+ var KIND_DEFAULT_NAMES = {
27216
+ antigravity: "agy"
27217
+ };
27215
27218
  function isFallbackName(name, kind) {
27216
27219
  const lname = name.toLowerCase();
27217
- return lname === kind || lname.startsWith(`${kind}-`) || lname === FALLBACK_BUS_NAME || /^claude-\d+$/.test(lname);
27220
+ const d = Object.hasOwn(KIND_DEFAULT_NAMES, kind) ? KIND_DEFAULT_NAMES[kind] : void 0;
27221
+ return lname === kind || lname.startsWith(`${kind}-`) || d !== void 0 && (lname === d || lname.startsWith(`${d}-`)) || lname === FALLBACK_BUS_NAME || /^claude-\d+$/.test(lname);
27218
27222
  }
27219
27223
  var INSTANCE_SENDER_NAME = "open-artifacts";
27220
27224
  var BUS_CMD = "npx @open-artifacts/bus";
@@ -27401,12 +27405,25 @@ var Sessions = external_exports.strictObject({
27401
27405
  ...base,
27402
27406
  type: external_exports.literal("sessions"),
27403
27407
  open: external_exports.array(AgentRefSchema).max(LIMITS.maxRosterAgents),
27404
- closed: external_exports.array(AgentRefSchema).max(LIMITS.maxRosterAgents)
27408
+ closed: external_exports.array(AgentRefSchema).max(LIMITS.maxRosterAgents),
27409
+ /**
27410
+ * #3208 (`BUS_CAPS.sessionsGone`): refs of closed sessions that will never
27411
+ * reopen (a subset of `closed`). The hub expires their pending mail as
27412
+ * `recipient_closed` and drops their away reservations. Sent only after
27413
+ * `hello_ok.caps` listed `sessions_gone` (older hubs refuse the key).
27414
+ */
27415
+ gone: external_exports.array(AgentRefSchema).max(LIMITS.maxRosterAgents).optional()
27405
27416
  }).refine((f) => {
27406
27417
  if (!distinct(f.open) || !distinct(f.closed)) return false;
27407
27418
  const open2 = new Set(f.open);
27408
- return !f.closed.some((r) => open2.has(r));
27409
- }, "duplicate or overlapping session refs");
27419
+ if (f.closed.some((r) => open2.has(r))) return false;
27420
+ if (f.gone !== void 0) {
27421
+ if (!distinct(f.gone)) return false;
27422
+ const closed = new Set(f.closed);
27423
+ if (f.gone.some((r) => !closed.has(r))) return false;
27424
+ }
27425
+ return true;
27426
+ }, "duplicate, overlapping, or unclosed gone session refs");
27410
27427
  var Send = external_exports.strictObject({
27411
27428
  ...base,
27412
27429
  type: external_exports.literal("send"),
@@ -27786,7 +27803,9 @@ var Deliver = external_exports.strictObject({
27786
27803
  body: InlineBodySchema.optional(),
27787
27804
  notice: Notice.optional(),
27788
27805
  /** Only from the reserved sender, only with BUS_CAPS.noticeMeta (#2768). */
27789
- meta: NoticeMetaSchema.optional()
27806
+ meta: NoticeMetaSchema.optional(),
27807
+ /** When the hub drops this message if it is still unacked; set only with BUS_CAPS.mailExpiry. */
27808
+ expires_at: IsoTimeSchema.optional()
27790
27809
  }).refine(
27791
27810
  (f) => f.meta === void 0 || f.from_name === INSTANCE_SENDER_NAME,
27792
27811
  "meta only from the instance"
@@ -27910,7 +27929,7 @@ var base2 = { v: external_exports.literal(V), id: external_exports.string().min(
27910
27929
  var late = { late: external_exports.array(external_exports.string().min(1)).optional() };
27911
27930
  var isWellFormed2 = (s) => s.isWellFormed();
27912
27931
  var WELL_FORMED = { message: "text is not well-formed unicode" };
27913
- var CLIENT_VERSION = true ? "0.253.1" : "0.0.0";
27932
+ var CLIENT_VERSION = true ? "0.256.0" : "0.0.0";
27914
27933
  var clientVersion = {
27915
27934
  client_version: external_exports.string().min(1).max(64).optional()
27916
27935
  };
@@ -27952,7 +27971,15 @@ var ADAPTER_CAPS = {
27952
27971
  * `welcome.caps` only for an adapter that listed it, and an adapter sends
27953
27972
  * the frame only to a daemon whose welcome listed it.
27954
27973
  */
27955
- link: "link"
27974
+ link: "link",
27975
+ /**
27976
+ * `agy_watch` (agy S3): this antigravity connection is the watcher of one
27977
+ * agy process, not a conversation. Its hello names the watcher's own pid
27978
+ * and the agy process's start time; the daemon walks the watcher's parents
27979
+ * to that agy process and pushes it `agy_deliver` frames, which it answers
27980
+ * with `ack` or `agy_failed`. Any other request on it is refused.
27981
+ */
27982
+ agyWatch: "agy_watch"
27956
27983
  };
27957
27984
  var Hello2 = external_exports.object({
27958
27985
  ...base2,
@@ -28110,6 +28137,12 @@ var AdapterLinkProof = external_exports.object({
28110
28137
  type: external_exports.literal("link_proof"),
28111
28138
  hash: LinkProofHashSchema
28112
28139
  }).strict();
28140
+ var AgyFailed = external_exports.object({
28141
+ ...base2,
28142
+ type: external_exports.literal("agy_failed"),
28143
+ msg_id: MsgIdSchema,
28144
+ outcome: external_exports.literal("unknown").optional()
28145
+ });
28113
28146
  var AdapterFrame = external_exports.discriminatedUnion("type", [
28114
28147
  Hello2,
28115
28148
  Send2,
@@ -28124,7 +28157,8 @@ var AdapterFrame = external_exports.discriminatedUnion("type", [
28124
28157
  Following2,
28125
28158
  ProposeReach,
28126
28159
  Habits,
28127
- AdapterLinkProof
28160
+ AdapterLinkProof,
28161
+ AgyFailed
28128
28162
  ]);
28129
28163
  var ConfigFile = external_exports.object({
28130
28164
  file: external_exports.string(),
@@ -28261,6 +28295,13 @@ var Deliver2 = external_exports.object({
28261
28295
  }).refine((d) => d.body === void 0 !== (d.notice === void 0), {
28262
28296
  message: "deliver needs exactly one of body or notice"
28263
28297
  });
28298
+ var AgyDeliver = external_exports.object({
28299
+ ...base2,
28300
+ type: external_exports.literal("agy_deliver"),
28301
+ msg_id: MsgIdSchema,
28302
+ conversation_id: AGENT_REF,
28303
+ text: external_exports.string().min(1)
28304
+ });
28264
28305
  var Notice2 = external_exports.object({
28265
28306
  ...base2,
28266
28307
  type: external_exports.literal("notice"),
@@ -28384,6 +28425,7 @@ var DaemonFrame = external_exports.discriminatedUnion("type", [
28384
28425
  Agent,
28385
28426
  Body,
28386
28427
  Deliver2,
28428
+ AgyDeliver,
28387
28429
  Notice2,
28388
28430
  ErrorFrame2,
28389
28431
  StatusReply,
@@ -28449,6 +28491,10 @@ async function connectDaemon(opts) {
28449
28491
  const early = [];
28450
28492
  let notice;
28451
28493
  const earlyNotices = [];
28494
+ let agyDeliver;
28495
+ const earlyAgy = [];
28496
+ const closers = [];
28497
+ let closedOnce = false;
28452
28498
  const report = opts.onError ?? ((e) => console.error("onDeliver threw", e));
28453
28499
  const dispatch = (f) => {
28454
28500
  try {
@@ -28477,6 +28523,16 @@ async function connectDaemon(opts) {
28477
28523
  else early.push(frame);
28478
28524
  continue;
28479
28525
  }
28526
+ if (frame.type === "agy_deliver") {
28527
+ if (!agyDeliver) earlyAgy.push(frame);
28528
+ else
28529
+ try {
28530
+ agyDeliver(frame);
28531
+ } catch (e) {
28532
+ report(e);
28533
+ }
28534
+ continue;
28535
+ }
28480
28536
  if (frame.type === "notice") {
28481
28537
  if (notice) {
28482
28538
  try {
@@ -28502,7 +28558,12 @@ async function connectDaemon(opts) {
28502
28558
  }
28503
28559
  });
28504
28560
  sock.on("error", (e) => failAll(e));
28505
- sock.on("close", () => failAll(new Error("daemon connection closed")));
28561
+ sock.on("close", () => {
28562
+ failAll(new Error("daemon connection closed"));
28563
+ if (closedOnce) return;
28564
+ closedOnce = true;
28565
+ for (const cb of closers.splice(0)) cb();
28566
+ });
28506
28567
  let timer;
28507
28568
  const welcomeRaw = await new Promise((resolve3, reject) => {
28508
28569
  waiters.push({ resolve: resolve3, reject });
@@ -28565,6 +28626,28 @@ async function connectDaemon(opts) {
28565
28626
  notice = cb;
28566
28627
  for (const t of earlyNotices.splice(0)) cb(t);
28567
28628
  },
28629
+ onAgyDeliver: (cb) => {
28630
+ agyDeliver = cb;
28631
+ for (const f of earlyAgy.splice(0)) cb(f);
28632
+ },
28633
+ agyFailed: (msg_id) => {
28634
+ if (state === "closed") return;
28635
+ sock.write(
28636
+ `${JSON.stringify({ v: 1, type: "agy_failed", id: `agyf-${++seq}`, msg_id })}
28637
+ `
28638
+ );
28639
+ },
28640
+ agyUnknown: (msg_id) => {
28641
+ if (state === "closed") return;
28642
+ sock.write(
28643
+ `${JSON.stringify({ v: 1, type: "agy_failed", id: `agyf-${++seq}`, msg_id, outcome: "unknown" })}
28644
+ `
28645
+ );
28646
+ },
28647
+ onClose: (cb) => {
28648
+ if (closedOnce) cb();
28649
+ else closers.push(cb);
28650
+ },
28568
28651
  close: () => sock.destroy()
28569
28652
  };
28570
28653
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oa-bus",
3
- "version": "0.253.1",
3
+ "version": "0.256.0",
4
4
  "type": "module",
5
5
  "openclaw": {
6
6
  "extensions": [