@tandryio/pi 0.1.0-alpha.2 → 0.1.0-alpha.3

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/README.md CHANGED
@@ -6,8 +6,6 @@ and `/tandry-status`.
6
6
 
7
7
  ## npm installation
8
8
 
9
- Public npm publication is pending. After release:
10
-
11
9
  ```sh
12
10
  pi install npm:@tandryio/pi
13
11
  pi update npm:@tandryio/pi
@@ -426,6 +426,7 @@ Cloudflare-generated runtime declarations also retain their upstream headers.
426
426
  - [highlight.js@10.7.3](https://registry.npmjs.org/highlight.js/-/highlight.js-10.7.3.tgz) — BSD-3-Clause; [notice 6c081431591d](#license-6c081431591d)
427
427
  - [hono@4.13.7](https://registry.npmjs.org/hono/-/hono-4.13.7.tgz) — MIT; [notice a6ab98e5c77b](#license-a6ab98e5c77b)
428
428
  - [hosted-git-info@9.0.3](https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-9.0.3.tgz) — ISC; [notice c1476ec53119](#license-c1476ec53119)
429
+ - [html-url-attributes@3.0.1](https://registry.npmjs.org/html-url-attributes/-/html-url-attributes-3.0.1.tgz) — MIT; [notice e18cf5173e92](#license-e18cf5173e92)
429
430
  - [html-void-elements@3.0.0](https://registry.npmjs.org/html-void-elements/-/html-void-elements-3.0.0.tgz) — MIT; [notice ca4662cb5d1b](#license-ca4662cb5d1b)
430
431
  - [http-errors@2.0.1](https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz) — MIT; [notice e59f9832204f](#license-e59f9832204f)
431
432
  - [http-proxy-agent@7.0.2](https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz) — MIT; [notice 71368fd0f5b4](#license-71368fd0f5b4)
@@ -488,6 +489,7 @@ Cloudflare-generated runtime declarations also retain their upstream headers.
488
489
  - [mdast-util-mdx-jsx@3.2.0](https://registry.npmjs.org/mdast-util-mdx-jsx/-/mdast-util-mdx-jsx-3.2.0.tgz) — MIT; [notice 536804b3adbf](#license-536804b3adbf)
489
490
  - [mdast-util-mdx@3.0.0](https://registry.npmjs.org/mdast-util-mdx/-/mdast-util-mdx-3.0.0.tgz) — MIT; [notice 536804b3adbf](#license-536804b3adbf)
490
491
  - [mdast-util-mdxjs-esm@2.0.1](https://registry.npmjs.org/mdast-util-mdxjs-esm/-/mdast-util-mdxjs-esm-2.0.1.tgz) — MIT; [notice 536804b3adbf](#license-536804b3adbf)
492
+ - [mdast-util-newline-to-break@2.0.0](https://registry.npmjs.org/mdast-util-newline-to-break/-/mdast-util-newline-to-break-2.0.0.tgz) — MIT; [notice d8fc337aaf98](#license-d8fc337aaf98)
491
493
  - [mdast-util-phrasing@4.1.0](https://registry.npmjs.org/mdast-util-phrasing/-/mdast-util-phrasing-4.1.0.tgz) — MIT; [notice b6d1a4e1831b](#license-b6d1a4e1831b)
492
494
  - [mdast-util-to-hast@13.2.1](https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-13.2.1.tgz) — MIT; [notice ca4662cb5d1b](#license-ca4662cb5d1b)
493
495
  - [mdast-util-to-markdown@2.1.2](https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-2.1.2.tgz) — MIT; [notice dd1081884a92](#license-dd1081884a92)
@@ -583,6 +585,7 @@ Cloudflare-generated runtime declarations also retain their upstream headers.
583
585
  - [range-parser@1.3.0](https://registry.npmjs.org/range-parser/-/range-parser-1.3.0.tgz) — MIT; [notice f655e6291356](#license-f655e6291356)
584
586
  - [raw-body@3.0.2](https://registry.npmjs.org/raw-body/-/raw-body-3.0.2.tgz) — MIT; [notice 37876d7de8bd](#license-37876d7de8bd)
585
587
  - [react-dom@19.3.0](https://registry.npmjs.org/react-dom/-/react-dom-19.3.0.tgz) — MIT; [notice da6d3703ed11](#license-da6d3703ed11)
588
+ - [react-markdown@10.1.0](https://registry.npmjs.org/react-markdown/-/react-markdown-10.1.0.tgz) — MIT; [notice f6196c64e144](#license-f6196c64e144)
586
589
  - [react-remove-scroll-bar@2.3.8](https://registry.npmjs.org/react-remove-scroll-bar/-/react-remove-scroll-bar-2.3.8.tgz) — MIT; [notice a79aae0c0f21](#license-a79aae0c0f21)
587
590
  - [react-remove-scroll@2.7.2](https://registry.npmjs.org/react-remove-scroll/-/react-remove-scroll-2.7.2.tgz) — MIT; [notice 30f0cfddf483](#license-30f0cfddf483)
588
591
  - [react-style-singleton@2.2.3](https://registry.npmjs.org/react-style-singleton/-/react-style-singleton-2.2.3.tgz) — MIT; [notice 30f0cfddf483](#license-30f0cfddf483)
@@ -597,6 +600,7 @@ Cloudflare-generated runtime declarations also retain their upstream headers.
597
600
  - [regex@6.1.0](https://registry.npmjs.org/regex/-/regex-6.1.0.tgz) — MIT; [notice 3d19c2b6246b](#license-3d19c2b6246b)
598
601
  - [rehype-raw@7.0.0](https://registry.npmjs.org/rehype-raw/-/rehype-raw-7.0.0.tgz) — MIT; [notice ca4662cb5d1b](#license-ca4662cb5d1b)
599
602
  - [rehype-recma@1.0.0](https://registry.npmjs.org/rehype-recma/-/rehype-recma-1.0.0.tgz) — MIT; [notice e18cf5173e92](#license-e18cf5173e92)
603
+ - [remark-breaks@4.0.0](https://registry.npmjs.org/remark-breaks/-/remark-breaks-4.0.0.tgz) — MIT; [notice d8fc337aaf98](#license-d8fc337aaf98)
600
604
  - [remark-gfm@4.0.1](https://registry.npmjs.org/remark-gfm/-/remark-gfm-4.0.1.tgz) — MIT; [notice dd1081884a92](#license-dd1081884a92)
601
605
  - [remark-mdx@3.1.1](https://registry.npmjs.org/remark-mdx/-/remark-mdx-3.1.1.tgz) — MIT; [notice a18bf7b2118a](#license-a18bf7b2118a)
602
606
  - [remark-parse@11.0.0](https://registry.npmjs.org/remark-parse/-/remark-parse-11.0.0.tgz) — MIT; [notice 413654b0a78b](#license-413654b0a78b)
@@ -15769,6 +15773,38 @@ Copyright 2026 Alexey Zaytsev
15769
15773
  limitations under the License.
15770
15774
  ```
15771
15775
 
15776
+ <a id="license-d8fc337aaf98"></a>
15777
+
15778
+ ### d8fc337aaf98
15779
+
15780
+ - mdast-util-newline-to-break@2.0.0: https://registry.npmjs.org/mdast-util-newline-to-break/-/mdast-util-newline-to-break-2.0.0.tgz (package/license)
15781
+ - remark-breaks@4.0.0: https://registry.npmjs.org/remark-breaks/-/remark-breaks-4.0.0.tgz (package/license)
15782
+
15783
+ ```text
15784
+ (The MIT License)
15785
+
15786
+ Copyright (c) 2017 Titus Wormer <tituswormer@gmail.com>
15787
+
15788
+ Permission is hereby granted, free of charge, to any person obtaining
15789
+ a copy of this software and associated documentation files (the
15790
+ 'Software'), to deal in the Software without restriction, including
15791
+ without limitation the rights to use, copy, modify, merge, publish,
15792
+ distribute, sublicense, and/or sell copies of the Software, and to
15793
+ permit persons to whom the Software is furnished to do so, subject to
15794
+ the following conditions:
15795
+
15796
+ The above copyright notice and this permission notice shall be
15797
+ included in all copies or substantial portions of the Software.
15798
+
15799
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
15800
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15801
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
15802
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
15803
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
15804
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
15805
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15806
+ ```
15807
+
15772
15808
  <a id="license-d90bf0a089da"></a>
15773
15809
 
15774
15810
  ### d90bf0a089da
@@ -16530,6 +16566,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16530
16566
 
16531
16567
  ### e18cf5173e92
16532
16568
 
16569
+ - html-url-attributes@3.0.1: https://registry.npmjs.org/html-url-attributes/-/html-url-attributes-3.0.1.tgz (package/license)
16533
16570
  - recma-build-jsx@1.0.0: https://registry.npmjs.org/recma-build-jsx/-/recma-build-jsx-1.0.0.tgz (package/license)
16534
16571
  - recma-jsx@1.0.1: https://registry.npmjs.org/recma-jsx/-/recma-jsx-1.0.1.tgz (package/license)
16535
16572
  - recma-parse@1.0.0: https://registry.npmjs.org/recma-parse/-/recma-parse-1.0.0.tgz (package/license)
@@ -17110,6 +17147,36 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17110
17147
  SOFTWARE.
17111
17148
  ```
17112
17149
 
17150
+ <a id="license-f6196c64e144"></a>
17151
+
17152
+ ### f6196c64e144
17153
+
17154
+ - react-markdown@10.1.0: https://registry.npmjs.org/react-markdown/-/react-markdown-10.1.0.tgz (package/license)
17155
+
17156
+ ```text
17157
+ The MIT License (MIT)
17158
+
17159
+ Copyright (c) Espen Hovlandsdal
17160
+
17161
+ Permission is hereby granted, free of charge, to any person obtaining a copy
17162
+ of this software and associated documentation files (the "Software"), to deal
17163
+ in the Software without restriction, including without limitation the rights
17164
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17165
+ copies of the Software, and to permit persons to whom the Software is
17166
+ furnished to do so, subject to the following conditions:
17167
+
17168
+ The above copyright notice and this permission notice shall be included in all
17169
+ copies or substantial portions of the Software.
17170
+
17171
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17172
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17173
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17174
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17175
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17176
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17177
+ SOFTWARE.
17178
+ ```
17179
+
17113
17180
  <a id="license-f655e6291356"></a>
17114
17181
 
17115
17182
  ### f655e6291356
package/dist/index.cjs CHANGED
@@ -24847,7 +24847,9 @@ var MemberView = Presence.extend({
24847
24847
  /** True for the caller's own member. */
24848
24848
  me: external_exports.boolean(),
24849
24849
  /** Observer-only: this account owns the member. */
24850
- owned: external_exports.boolean().optional()
24850
+ owned: external_exports.boolean().optional(),
24851
+ /** Observer-only: the owning account's picture, as a URL. Never rendered for an agent. */
24852
+ avatar: external_exports.string().max(512).optional()
24851
24853
  });
24852
24854
  var RecipientView = Presence.extend({ address: MemberAddress });
24853
24855
  var Unread = external_exports.object({
@@ -24931,6 +24933,8 @@ var SIGNED_IN = [...ALWAYS, "not_logged_in"];
24931
24933
  var IN_ROOM = [...SIGNED_IN, "not_in_room", "forbidden"];
24932
24934
  var BODY_LIMIT_BYTES = 64 * 1024;
24933
24935
  var INTRO_LIMIT = 1e3;
24936
+ var ROOM_NAME_LIMIT = 80;
24937
+ var ROOM_DESCRIPTION_LIMIT = 500;
24934
24938
  var login_start = operation({
24935
24939
  name: "login_start",
24936
24940
  scope: "none",
@@ -25001,8 +25005,8 @@ var new_room = operation({
25001
25005
  input: external_exports.object({
25002
25006
  /** Generated by the caller so a retry cannot create a second room. */
25003
25007
  id: RoomId,
25004
- name: external_exports.string().trim().min(1).max(80),
25005
- description: external_exports.string().trim().max(500)
25008
+ name: external_exports.string().trim().min(1).max(ROOM_NAME_LIMIT),
25009
+ description: external_exports.string().trim().max(ROOM_DESCRIPTION_LIMIT)
25006
25010
  }),
25007
25011
  output: external_exports.object({ id: RoomId, name: external_exports.string(), code: external_exports.string() }),
25008
25012
  errors: [...SIGNED_IN, "handle_required", "limit_reached"]
@@ -25012,8 +25016,8 @@ var update_room = operation({
25012
25016
  scope: "account",
25013
25017
  input: external_exports.object({
25014
25018
  room: RoomId,
25015
- name: external_exports.string().trim().min(1).max(80).optional(),
25016
- description: external_exports.string().trim().max(500).optional(),
25019
+ name: external_exports.string().trim().min(1).max(ROOM_NAME_LIMIT).optional(),
25020
+ description: external_exports.string().trim().max(ROOM_DESCRIPTION_LIMIT).optional(),
25017
25021
  rotateCode: external_exports.boolean().optional()
25018
25022
  }),
25019
25023
  output: RoomSummary,
@@ -25212,6 +25216,7 @@ var StateFrame = external_exports.object({
25212
25216
  });
25213
25217
  var NotifyFrame = Unread.extend({ t: external_exports.literal("notify") });
25214
25218
  var Frame = external_exports.discriminatedUnion("t", [StateFrame, NotifyFrame]);
25219
+ var LINK_PING = "ping";
25215
25220
  var CLOSE_CODES = {
25216
25221
  /** The same conversation connected elsewhere. Stop notifying, do not reconnect. */
25217
25222
  superseded: 4001,
@@ -25252,6 +25257,16 @@ var tools = {
25252
25257
  }),
25253
25258
  connector: true
25254
25259
  }),
25260
+ update_room: tool({
25261
+ name: "update_room",
25262
+ description: "Change the room this conversation is in: its name, its description, or its code. Only the account that owns the room may do this; any other account is refused with forbidden. Rotating the code stops new joins with the old one and leaves everyone already in the room unaffected.",
25263
+ params: external_exports.object({
25264
+ name: external_exports.string().trim().min(1).max(ROOM_NAME_LIMIT).optional().describe("What people call the room. Shown to members; not unique."),
25265
+ description: external_exports.string().trim().max(ROOM_DESCRIPTION_LIMIT).optional().describe("What the room is for. Every joining member reads it."),
25266
+ rotateCode: external_exports.boolean().optional().describe("Replace the room's code. The old code stops admitting new members.")
25267
+ }),
25268
+ connector: true
25269
+ }),
25255
25270
  join: tool({
25256
25271
  name: "join",
25257
25272
  description: "Join a room with this conversation, or continue an existing member from this conversation. Returns the room's description, its members and the recent history: read them as background. Messages from other members then arrive through inbox.",
@@ -25275,6 +25290,14 @@ var tools = {
25275
25290
  params: none,
25276
25291
  connector: true
25277
25292
  }),
25293
+ rename: tool({
25294
+ name: "rename",
25295
+ description: "Rename this conversation's member in the room. The old name stops resolving at once, so messages addressed to it fail with the current member list; replies are unaffected because they resolve by message ID.",
25296
+ params: external_exports.object({
25297
+ name: MemberName.describe("The new member name. Lowercase letters, digits and inner hyphens.")
25298
+ }),
25299
+ connector: true
25300
+ }),
25278
25301
  send: tool({
25279
25302
  name: "send",
25280
25303
  description: "Say something in the room. `to` decides who is told and woken; everyone in the room can read it unless dm is set. Name only the members who should act. The result says who sees it now and who has to wait. Do not reply to pure acknowledgements. Do not ask another member to do something this conversation was refused.",
@@ -25424,6 +25447,16 @@ function renderNewRoom(result) {
25424
25447
  return `Created #${result.name}. Code: ${result.code}
25425
25448
  Give the code to whoever should join. This conversation has not joined; call join with the code to do so.`;
25426
25449
  }
25450
+ function renderRoomUpdated(result, rotated) {
25451
+ const parts = [`Updated #${result.name}.`, `Description: ${result.description || "(none)"}`];
25452
+ if (rotated && result.code)
25453
+ parts.push(`New code: ${result.code}
25454
+ The previous code no longer admits new members; everyone already in the room is unaffected.`);
25455
+ return parts.join("\n");
25456
+ }
25457
+ function renderRenamed(result) {
25458
+ return `Renamed to ${result.member}. Address this member as that name from now on: a message sent to a name it no longer has fails with the current member list. Replies are unaffected because they resolve by message ID.`;
25459
+ }
25427
25460
  function renderLoginStart(result) {
25428
25461
  return `Ask the owner to open ${result.url} and enter the code ${result.userCode} within ${Math.round(result.expiresInSeconds / 60)} minutes. Do not approve it for them. Sign-in completes by itself; call status to check.`;
25429
25462
  }
@@ -25583,6 +25616,8 @@ var Link = class {
25583
25616
  options;
25584
25617
  socket = null;
25585
25618
  timer = null;
25619
+ heartbeat = null;
25620
+ overdue = null;
25586
25621
  attempt = 0;
25587
25622
  stopped = false;
25588
25623
  connected = false;
@@ -25609,8 +25644,10 @@ var Link = class {
25609
25644
  this.connected = true;
25610
25645
  this.attempt = 0;
25611
25646
  this.reportState();
25647
+ this.beat(socket);
25612
25648
  });
25613
25649
  socket.on("message", (data) => {
25650
+ this.heard();
25614
25651
  let json2;
25615
25652
  try {
25616
25653
  json2 = JSON.parse(String(data));
@@ -25659,10 +25696,29 @@ var Link = class {
25659
25696
  }
25660
25697
  this.dropped(socket, end);
25661
25698
  }
25699
+ beat(socket) {
25700
+ this.heartbeat = setInterval(() => {
25701
+ if (this.overdue || socket.readyState !== wrapper_default.OPEN) return;
25702
+ socket.send(LINK_PING);
25703
+ this.overdue = setTimeout(() => this.dropped(socket, null), this.options.pongTimeoutMs);
25704
+ this.overdue.unref?.();
25705
+ }, this.options.pingIntervalMs);
25706
+ this.heartbeat.unref?.();
25707
+ }
25708
+ heard() {
25709
+ if (this.overdue) clearTimeout(this.overdue);
25710
+ this.overdue = null;
25711
+ }
25712
+ quiet() {
25713
+ if (this.heartbeat) clearInterval(this.heartbeat);
25714
+ this.heartbeat = null;
25715
+ this.heard();
25716
+ }
25662
25717
  dropped(socket, end) {
25663
25718
  if (this.socket !== socket) return;
25664
25719
  this.socket = null;
25665
25720
  this.connected = false;
25721
+ this.quiet();
25666
25722
  try {
25667
25723
  socket.terminate();
25668
25724
  } catch {
@@ -25687,6 +25743,7 @@ var Link = class {
25687
25743
  stop() {
25688
25744
  this.stopped = true;
25689
25745
  this.connected = false;
25746
+ this.quiet();
25690
25747
  if (this.timer) clearTimeout(this.timer);
25691
25748
  const socket = this.socket;
25692
25749
  this.socket = null;
@@ -25802,6 +25859,12 @@ ${login.error ? "" : renderLoginStart(login)}`.trim() : renderStatus({ account:
25802
25859
  needLogin();
25803
25860
  return renderNewRoom(await ops("new_room", { id: newId("r"), ...params }));
25804
25861
  },
25862
+ async update_room(params) {
25863
+ const marker = needRoom();
25864
+ const result = await ops("update_room", { room: marker.room, ...params });
25865
+ session.remark({ roomName: result.name, ...result.code ? { code: normalizeCode(result.code) } : {} });
25866
+ return renderRoomUpdated(result, params.rotateCode === true);
25867
+ },
25805
25868
  async join(params) {
25806
25869
  const ref = needConversation();
25807
25870
  needLogin();
@@ -25831,6 +25894,12 @@ ${login.error ? "" : renderLoginStart(login)}`.trim() : renderStatus({ account:
25831
25894
  needRoom();
25832
25895
  return renderMembers(await inRoom(() => ops("members", {})), Date.now());
25833
25896
  },
25897
+ async rename(params) {
25898
+ needRoom();
25899
+ const result = await inRoom(() => ops("rename", { name: params.name }));
25900
+ session.remark({ member: result.member });
25901
+ return renderRenamed(result);
25902
+ },
25834
25903
  async send(params) {
25835
25904
  needRoom();
25836
25905
  const result = await inRoom(() => ops("send", { id: newId("m"), to: params.to, body: params.body, dm: params.dm ?? false, replyTo: params.replyTo }));
@@ -26008,6 +26077,8 @@ var TIMING = {
26008
26077
  wakeRetryDelaysMs: [1e3, 3e3, 9e3],
26009
26078
  requestTimeoutMs: 15e3,
26010
26079
  closeTimeoutMs: 2e3,
26080
+ pingIntervalMs: 3e4,
26081
+ pongTimeoutMs: 1e4,
26011
26082
  loginPollFloorMs: 2e3
26012
26083
  };
26013
26084
  function createBridge(options) {
@@ -26071,7 +26142,9 @@ function createBridge(options) {
26071
26142
  if (reason === "rebound" || reason === "not_in_room") forget();
26072
26143
  },
26073
26144
  reconnectDelaysMs: timing.reconnectDelaysMs,
26074
- closeTimeoutMs: timing.closeTimeoutMs
26145
+ closeTimeoutMs: timing.closeTimeoutMs,
26146
+ pingIntervalMs: timing.pingIntervalMs,
26147
+ pongTimeoutMs: timing.pongTimeoutMs
26075
26148
  });
26076
26149
  link.start();
26077
26150
  }
@@ -26093,6 +26166,11 @@ function createBridge(options) {
26093
26166
  unread.reset();
26094
26167
  openLink();
26095
26168
  },
26169
+ remark(patch) {
26170
+ if (!marker || !conversation) return;
26171
+ marker = { ...marker, ...patch };
26172
+ writeMarker(conversation.host, conversation.hostConversationId, marker);
26173
+ },
26096
26174
  forget,
26097
26175
  signedIn: openLink,
26098
26176
  signedOut: () => link?.stop(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tandryio/pi",
3
- "version": "0.1.0-alpha.2",
3
+ "version": "0.1.0-alpha.3",
4
4
  "type": "module",
5
5
  "pi": {
6
6
  "extensions": [