@joe-broadhead/opencode-messaging 0.4.0 → 0.5.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/dist/messaging.js CHANGED
@@ -5746,7 +5746,8 @@ looseObject({
5746
5746
  jti: string$1().regex(/^[\x21-\x7e]{1,128}$/, "printable jti"),
5747
5747
  iss: string$1().max(2048).optional(),
5748
5748
  dev: string$1().max(200).optional(),
5749
- cls: string$1().max(32).optional()
5749
+ cls: string$1().max(32).optional(),
5750
+ mbr: string$1().max(200).optional()
5750
5751
  });
5751
5752
  looseObject({
5752
5753
  aud: string$1().min(1).max(2048),
@@ -6312,7 +6313,8 @@ object({
6312
6313
  label: MachineLabel,
6313
6314
  sessions: array(SessionInfo).max(LIMITS.presenceSessions),
6314
6315
  features: array(string$1().max(64)).max(32).optional(),
6315
- direct: array(DirectEndpoint).min(1).max(4).optional()
6316
+ direct: array(DirectEndpoint).min(1).max(4).optional(),
6317
+ away: literal(true).optional()
6316
6318
  });
6317
6319
  const Provenance = object({
6318
6320
  envelopeId: Ulid,
@@ -6532,78 +6534,104 @@ const Size = number$1().int().positive();
6532
6534
  const Handle = string$1().regex(/^[a-z][a-z0-9-]{0,31}$/, "lowercase handle");
6533
6535
  const Email = string$1().max(254).regex(/^[^\s@A-Z]{1,64}@(?:[a-z0-9-]+\.)+[a-z0-9-]+$/, "lower-case email address");
6534
6536
  const OrgId = string$1().min(1).max(200);
6535
- discriminatedUnion("t", [
6536
- object({
6537
- t: literal("dir.bind"),
6538
- req: Req,
6539
- entry: LogEntry
6540
- }),
6541
- object({
6542
- t: literal("hello"),
6543
- realm: RealmId,
6537
+ const DirBindFrame = object({
6538
+ t: literal("dir.bind"),
6539
+ req: Req,
6540
+ entry: LogEntry
6541
+ });
6542
+ const HostedHelloFrame = object({
6543
+ t: literal("hello"),
6544
+ realm: RealmId,
6545
+ person: HostedPersonId,
6546
+ device: DeviceId,
6547
+ ts: Millis,
6548
+ sig: Base64Url
6549
+ });
6550
+ const DirAppendFrame = object({
6551
+ t: literal("dir.append"),
6552
+ req: Req,
6553
+ entry: LogEntry
6554
+ });
6555
+ const DirKeysFrame = object({
6556
+ t: literal("dir.keys"),
6557
+ req: Req,
6558
+ stmt: KeysStatement
6559
+ });
6560
+ const DirSthFrame = object({
6561
+ t: literal("dir.sth"),
6562
+ req: Req,
6563
+ size: Size.optional(),
6564
+ from: Size.optional(),
6565
+ epoch: number$1().int().nonnegative().optional()
6566
+ });
6567
+ const DirLookupFrame = object({
6568
+ t: literal("dir.lookup"),
6569
+ req: Req,
6570
+ persons: array(object({
6544
6571
  person: HostedPersonId,
6545
- device: DeviceId,
6546
- ts: Millis,
6547
- sig: Base64Url
6548
- }),
6549
- object({
6550
- t: literal("dir.append"),
6551
- req: Req,
6552
- entry: LogEntry
6553
- }),
6554
- object({
6555
- t: literal("dir.keys"),
6556
- req: Req,
6557
- stmt: KeysStatement
6558
- }),
6559
- object({
6560
- t: literal("dir.sth"),
6561
- req: Req,
6562
- size: Size.optional(),
6563
- from: Size.optional(),
6564
- epoch: number$1().int().nonnegative().optional()
6565
- }),
6566
- object({
6567
- t: literal("dir.lookup"),
6568
- req: Req,
6569
- persons: array(object({
6570
- person: HostedPersonId,
6571
- knownSeq: number$1().int().nonnegative().optional()
6572
- })).min(1).max(LIMITS.dirLookupPersons),
6573
- size: Size.optional()
6574
- }),
6575
- object({
6576
- t: literal("dir.device"),
6577
- req: Req,
6578
- device: DeviceId
6579
- }),
6580
- object({
6581
- t: literal("dir.resolve"),
6582
- req: Req,
6583
- handle: Handle.optional(),
6584
- email: Email.optional()
6585
- }).refine((frame) => frame.handle === void 0 !== (frame.email === void 0), { message: "exactly one of handle and email" }),
6586
- object({
6587
- t: literal("dir.search"),
6588
- req: Req,
6589
- query: string$1().min(1).max(64),
6590
- limit: number$1().int().min(1).max(LIMITS.dirSearchResults)
6591
- }),
6592
- object({
6593
- t: literal("dir.watch"),
6594
- req: Req,
6595
- persons: array(HostedPersonId).max(LIMITS.watchPersons)
6596
- }),
6572
+ knownSeq: number$1().int().nonnegative().optional()
6573
+ })).min(1).max(LIMITS.dirLookupPersons),
6574
+ size: Size.optional()
6575
+ });
6576
+ const DirDeviceFrame = object({
6577
+ t: literal("dir.device"),
6578
+ req: Req,
6579
+ device: DeviceId
6580
+ });
6581
+ const DirResolveFrame = object({
6582
+ t: literal("dir.resolve"),
6583
+ req: Req,
6584
+ handle: Handle.optional(),
6585
+ email: Email.optional()
6586
+ }).refine((frame) => frame.handle === void 0 !== (frame.email === void 0), { message: "exactly one of handle and email" });
6587
+ const DirSearchFrame = object({
6588
+ t: literal("dir.search"),
6589
+ req: Req,
6590
+ query: string$1().min(1).max(64),
6591
+ limit: number$1().int().min(1).max(LIMITS.dirSearchResults)
6592
+ });
6593
+ const DirWatchFrame = object({
6594
+ t: literal("dir.watch"),
6595
+ req: Req,
6596
+ persons: array(HostedPersonId).max(LIMITS.watchPersons)
6597
+ });
6598
+ const PresenceWatchFrame = object({
6599
+ t: literal("presence.watch"),
6600
+ req: Req,
6601
+ persons: array(HostedPersonId).max(LIMITS.watchPersons)
6602
+ });
6603
+ const DirEraseFrame = object({
6604
+ t: literal("dir.erase"),
6605
+ req: Req,
6606
+ entries: array(LogEntry).min(1).max(LIMITS.devicesPerPerson),
6607
+ token: Jws
6608
+ });
6609
+ const WAKE_TICKET_BYTES = 4096;
6610
+ const WakeUrl = string$1().max(2048).regex(/^https?:\/\/[^/?#@\s]+\/hosts\/hst_[A-Za-z0-9._:-]{1,123}\/wake$/, "a Jelly ID wake URL");
6611
+ discriminatedUnion("t", [
6612
+ DirBindFrame,
6613
+ HostedHelloFrame,
6614
+ DirAppendFrame,
6615
+ DirKeysFrame,
6616
+ DirSthFrame,
6617
+ DirLookupFrame,
6618
+ DirDeviceFrame,
6619
+ DirResolveFrame,
6620
+ DirSearchFrame,
6621
+ DirWatchFrame,
6622
+ PresenceWatchFrame,
6623
+ DirEraseFrame,
6597
6624
  object({
6598
- t: literal("presence.watch"),
6625
+ t: literal("wake.arm"),
6599
6626
  req: Req,
6600
- persons: array(HostedPersonId).max(LIMITS.watchPersons)
6627
+ url: WakeUrl,
6628
+ ticket: Jws.refine((ticket) => ticket.length <= WAKE_TICKET_BYTES, { message: `at most ${WAKE_TICKET_BYTES} bytes` }),
6629
+ agents: array(SessionName).max(64),
6630
+ awaiting: array(Ulid).max(500)
6601
6631
  }),
6602
6632
  object({
6603
- t: literal("dir.erase"),
6604
- req: Req,
6605
- entries: array(LogEntry).min(1).max(LIMITS.devicesPerPerson),
6606
- token: Jws
6633
+ t: literal("wake.disarm"),
6634
+ req: Req
6607
6635
  })
6608
6636
  ]);
6609
6637
  const HostedWelcomeFrame = object({
@@ -6800,6 +6828,19 @@ const LoginState = discriminatedUnion("state", [
6800
6828
  purpose: LoginPurpose
6801
6829
  })
6802
6830
  ]);
6831
+ const DeviceRemoveParams = strictObject({
6832
+ device: MachineId,
6833
+ reason: _enum([
6834
+ "self",
6835
+ "removed",
6836
+ "lost"
6837
+ ]).optional(),
6838
+ token: Jws.optional()
6839
+ });
6840
+ const DeviceApproveParams = strictObject({
6841
+ link: LinkText,
6842
+ sas: Sas
6843
+ });
6803
6844
  const DEVICE_METHODS = {
6804
6845
  "device.status": {
6805
6846
  params: strictObject({}),
@@ -6822,15 +6863,7 @@ const DEVICE_METHODS = {
6822
6863
  result: object({ devices: array(DeviceListEntry) })
6823
6864
  },
6824
6865
  "device.remove": {
6825
- params: strictObject({
6826
- device: MachineId,
6827
- reason: _enum([
6828
- "self",
6829
- "removed",
6830
- "lost"
6831
- ]).optional(),
6832
- token: Jws.optional()
6833
- }),
6866
+ params: DeviceRemoveParams,
6834
6867
  result: object({ seq: number$1().int().nonnegative() })
6835
6868
  },
6836
6869
  "device.link": {
@@ -6867,14 +6900,11 @@ const DEVICE_METHODS = {
6867
6900
  result: object({ ok: literal(true) })
6868
6901
  },
6869
6902
  "device.approve.preview": {
6870
- params: strictObject({ link: LinkText }),
6903
+ params: DeviceApproveParams.partial({ sas: true }),
6871
6904
  result: LinkPreview
6872
6905
  },
6873
6906
  "device.approve": {
6874
- params: strictObject({
6875
- link: LinkText,
6876
- sas: Sas
6877
- }),
6907
+ params: DeviceApproveParams,
6878
6908
  result: object({
6879
6909
  device: MachineId,
6880
6910
  seq: number$1().int().nonnegative()
@@ -7099,6 +7129,16 @@ const PersonReach = object({
7099
7129
  source: _enum(["card", "default"]),
7100
7130
  at: Millis.optional()
7101
7131
  });
7132
+ const RequestAnswerParams = strictObject({
7133
+ id: Ulid,
7134
+ answer: RequestAnswer,
7135
+ all: boolean().optional()
7136
+ });
7137
+ const ContactRequestParams = strictObject({
7138
+ email: Email,
7139
+ text: RequestText,
7140
+ suggestion: Ulid.optional()
7141
+ });
7102
7142
  const CONSENT_METHODS = {
7103
7143
  "grant.list": {
7104
7144
  params: strictObject({ subject: GrantTarget.optional() }),
@@ -7120,19 +7160,35 @@ const CONSENT_METHODS = {
7120
7160
  result: object({ requests: array(HeldRequest).max(LIMITS.heldTotal * 3) })
7121
7161
  },
7122
7162
  "request.answer": {
7123
- params: strictObject({
7124
- id: Ulid,
7125
- answer: RequestAnswer,
7126
- all: boolean().optional()
7127
- }),
7163
+ params: RequestAnswerParams,
7128
7164
  result: object({ answered: array(Ulid).max(LIMITS.heldTotal) })
7129
7165
  },
7166
+ "request.answer.preview": {
7167
+ params: RequestAnswerParams,
7168
+ result: object({
7169
+ kind: _enum([
7170
+ "message",
7171
+ "task",
7172
+ "contact",
7173
+ "suggestion"
7174
+ ]),
7175
+ from: object({
7176
+ name: string$1().max(200),
7177
+ email: string$1().max(320).optional(),
7178
+ org: _enum([
7179
+ "same",
7180
+ "other",
7181
+ "none"
7182
+ ])
7183
+ }),
7184
+ agent: SessionName.optional(),
7185
+ to: SessionName.optional(),
7186
+ count: number$1().int().positive(),
7187
+ sentence: string$1().max(500)
7188
+ })
7189
+ },
7130
7190
  "contact.request": {
7131
- params: strictObject({
7132
- email: Email,
7133
- text: RequestText,
7134
- suggestion: Ulid.optional()
7135
- }),
7191
+ params: ContactRequestParams,
7136
7192
  result: object({
7137
7193
  id: Ulid,
7138
7194
  conversation: RoomRef,
@@ -7140,7 +7196,7 @@ const CONSENT_METHODS = {
7140
7196
  })
7141
7197
  },
7142
7198
  "contact.request.preview": {
7143
- params: strictObject({ email: Email }),
7199
+ params: ContactRequestParams.partial({ text: true }),
7144
7200
  result: object({ found: boolean() })
7145
7201
  },
7146
7202
  "card.get": {
@@ -7308,7 +7364,8 @@ const SURFACE_METHODS = {
7308
7364
  result: PersonSummary.extend({ devices: array(object({
7309
7365
  device: MachineId,
7310
7366
  label: MachineLabel,
7311
- self: boolean()
7367
+ self: boolean(),
7368
+ away: literal(true).optional()
7312
7369
  })) })
7313
7370
  }
7314
7371
  };
@@ -7426,8 +7483,45 @@ const JELLY_METHODS = {
7426
7483
  params: strictObject({ ids: array(NoticeId).min(1).max(200) }),
7427
7484
  result: object({ ok: literal(true) })
7428
7485
  },
7486
+ "daemon.woke": {
7487
+ params: strictObject({}),
7488
+ result: object({ ok: literal(true) })
7489
+ },
7490
+ "person.attached": {
7491
+ params: strictObject({ attached: boolean() }),
7492
+ result: object({ ok: literal(true) })
7493
+ },
7494
+ "wake.arm": {
7495
+ params: strictObject({
7496
+ url: WakeUrl,
7497
+ ticket: Jws.refine((ticket) => ticket.length <= WAKE_TICKET_BYTES, { message: `at most ${WAKE_TICKET_BYTES} bytes` }),
7498
+ agents: array(SessionName).max(64)
7499
+ }),
7500
+ result: object({
7501
+ relay: _enum(["armed", "pending"]),
7502
+ awaiting: number$1().int().nonnegative()
7503
+ })
7504
+ },
7505
+ "wake.disarm": {
7506
+ params: strictObject({}),
7507
+ result: object({ relay: _enum(["disarmed", "pending"]) })
7508
+ },
7509
+ "daemon.snapshot": {
7510
+ params: strictObject({ done: literal(true).optional() }),
7511
+ result: union$1([object({
7512
+ folder: string$1().max(4096),
7513
+ files: array(object({
7514
+ name: string$1().max(64),
7515
+ bytes: number$1().int().nonnegative(),
7516
+ sha256: string$1().regex(/^[0-9a-f]{64}$/)
7517
+ })).max(8),
7518
+ storeSchema: number$1().int().positive(),
7519
+ at: Millis,
7520
+ until: Millis
7521
+ }), object({ released: boolean() })])
7522
+ },
7429
7523
  "device.remove.preview": {
7430
- params: strictObject({ device: MachineId }),
7524
+ params: DeviceRemoveParams,
7431
7525
  result: object({
7432
7526
  label: MachineLabel,
7433
7527
  kind: DeviceKind.optional(),
@@ -7800,6 +7894,63 @@ const AGENT_METHODS = [
7800
7894
  "task.update",
7801
7895
  "task.cancel"
7802
7896
  ];
7897
+ const HUMAN_METHODS = [
7898
+ "conv.list",
7899
+ "conv.read",
7900
+ "conv.markRead",
7901
+ "conv.subscribe",
7902
+ "person.send",
7903
+ "people.search",
7904
+ "people.get",
7905
+ "grant.list",
7906
+ "grant.set",
7907
+ "grant.set.preview",
7908
+ "request.list",
7909
+ "request.answer",
7910
+ "request.answer.preview",
7911
+ "contact.request",
7912
+ "contact.request.preview",
7913
+ "card.get",
7914
+ "agents.list",
7915
+ "agents.read",
7916
+ "notice.subscribe",
7917
+ "notice.list",
7918
+ "notice.ack",
7919
+ "device.approve.preview",
7920
+ "device.remove.preview",
7921
+ "channel.create",
7922
+ "channel.invite",
7923
+ "channel.leave",
7924
+ "channel.remove"
7925
+ ];
7926
+ const ADMIN_METHODS = [
7927
+ "daemon.stop",
7928
+ "daemon.woke",
7929
+ "person.attached",
7930
+ "daemon.snapshot",
7931
+ "wake.arm",
7932
+ "wake.disarm",
7933
+ "device.list",
7934
+ "device.remove",
7935
+ "device.link",
7936
+ "device.login",
7937
+ "device.login.status",
7938
+ "device.login.cancel",
7939
+ "device.approve",
7940
+ "identity.rotateEnc",
7941
+ "team.create",
7942
+ "team.invite",
7943
+ "team.join",
7944
+ "team.members",
7945
+ "team.remove",
7946
+ "team.role",
7947
+ "team.revokeInvite",
7948
+ "team.add",
7949
+ "team.pair",
7950
+ "team.claim",
7951
+ "team.pairCancel",
7952
+ "team.prepare"
7953
+ ];
7803
7954
  const IpcEvent = discriminatedUnion("type", [
7804
7955
  object({
7805
7956
  type: literal("inbox"),
@@ -7870,7 +8021,7 @@ function utf8(text) {
7870
8021
  return Buffer.from(text, "utf8");
7871
8022
  }
7872
8023
  // packages/core/dist/version.js
7873
- const VERSION = "0.4.0";
8024
+ const VERSION = "0.5.0";
7874
8025
  // packages/core/dist/jcs.js
7875
8026
  const LONE_SURROGATE = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/;
7876
8027
  function hasLoneSurrogate(text) {
@@ -8258,6 +8409,28 @@ Envelope.omit({
8258
8409
  body: true,
8259
8410
  sig: true
8260
8411
  });
8412
+ // packages/core/dist/jelly-host.js
8413
+ const CHAT_METHODS = [
8414
+ "person.send",
8415
+ "conv.markRead",
8416
+ "notice.ack"
8417
+ ];
8418
+ const VIEW_METHODS = [
8419
+ "conv.list",
8420
+ "conv.read",
8421
+ "conv.subscribe",
8422
+ "people.search",
8423
+ "people.get",
8424
+ "grant.list",
8425
+ "request.list",
8426
+ "agents.list",
8427
+ "agents.read",
8428
+ "notice.subscribe",
8429
+ "notice.list",
8430
+ "device.list"
8431
+ ];
8432
+ const classOf = (method) => CHAT_METHODS.includes(method) ? "chat" : VIEW_METHODS.includes(method) ? "view" : "local";
8433
+ Object.freeze(Object.fromEntries([...HUMAN_METHODS, ...ADMIN_METHODS].map((method) => [method, classOf(method)])));
8261
8434
  object({
8262
8435
  iss: string$1().min(1).max(2048),
8263
8436
  sub: JellySubject
@@ -10484,7 +10657,7 @@ var MessagingClient = class MessagingClient {
10484
10657
  timer = setTimeout(() => reject(new DaemonMismatchError(`the process on the Messaging daemon socket did not say which version it is within ${wait} ms: it is a messagingd from before this version, or it is stuck. ${REMEDY}`)), wait);
10485
10658
  })]);
10486
10659
  if (pointer !== void 0 && hello.pid !== pointer.pid) throw new MessagingError("forbidden", "the process on the Messaging daemon's pipe is not the daemon that published it");
10487
- const expected = options.version ?? "0.4.0";
10660
+ const expected = options.version ?? "0.5.0";
10488
10661
  if (hello.protocol !== 1 || hello.version !== expected) throw new DaemonMismatchError(`the Messaging daemon for this home is version ${shown(hello.version)} (IPC protocol ${hello.protocol}), and this client is version ${shown(expected)} (IPC protocol 1). ${REMEDY}`, hello);
10489
10662
  client.daemonHello = hello;
10490
10663
  return client;