@ai-matrx/desktop-protocol 0.1.0 → 0.1.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.1
4
+
5
+ Automatic changed-only republish (docs/metadata drift since the last tag — see
6
+ `git diff npm/desktop-protocol/v0.1.0..npm/desktop-protocol/v0.1.1 -- apps/shared/desktop-protocol`).
7
+ No source changes intended and no consumer action required.
8
+
3
9
  ## 0.1.0
4
10
 
5
11
  First release — the Matrx 2 phone slice, lane A.
@@ -14,6 +20,13 @@ First release — the Matrx 2 phone slice, lane A.
14
20
  `@ai-matrx/realtime`'s `createBackoff`.
15
21
  - `./react` — `DesktopClientProvider`, `useDesktopConnection`, `useDesktopRequest`,
16
22
  `useDesktopEvent`.
23
+ - Relay ↔ device hop, as built by the relay (lane D): `BROADCAST_CID` (an ENVELOPE frame with
24
+ cid 0 from the device reaches every client), `connectionEndFrame` / `isConnectionEnd` (an
25
+ ENVELOPE frame with FIN and no payload: relay → device "client gone", device → relay "close this
26
+ client"), with zod twins `RelayHopEnvelopeHeader` and `RelayHopConnectionEnd`; the `/call` hop
27
+ shapes `RelayCallHello` (id `hello`) and `RelayCallEnvelope` (id `call`); close codes
28
+ `ABNORMAL` 1006 (how a relay deploy arrives), `DEVICE_RECONNECTED` 1012, `TRY_AGAIN_LATER` 1013,
29
+ and `CloseCodeValue` so Python sees the same table. Corpus cases 40–55.
17
30
  - Generated twins: `generated/desktop-protocol.schema.json` and
18
31
  `aidream/_generated/desktop_protocol.py` (Pydantic, `StrictModel` base, `OPS`/`EVENTS`,
19
32
  `validate_wire`), held identical by `pnpm generate --check`.
@@ -33,3 +46,4 @@ Defects found in the draft and fixed here (not preserved):
33
46
  ### Consumer action
34
47
 
35
48
  None — new package.
49
+
package/README.md CHANGED
@@ -51,7 +51,9 @@ term.write("ls\n");
51
51
  those, never on messages. A dropped socket rejects unary work with `DEVICE_OFFLINE` (retryable).
52
52
  - **Terminal closes** (`4010` revoked, `4003` forbidden, `4004` not found, `4009` replaced, `4426`
53
53
  upgrade) end the client for good; everything else reconnects with the shared
54
- `@ai-matrx/realtime` backoff (stability reset + jitter).
54
+ `@ai-matrx/realtime` backoff (stability reset + jitter) — including `1006` (a relay deploy drops
55
+ every socket without a close frame) and `1012` (the relay's "the device reconnected": hello and
56
+ reattach against the new core session).
55
57
  - Background problems (malformed messages, sequence gaps, heartbeat death, reconnect alarm) go to
56
58
  `onDiagnostic` — loud by default (`console.warn`).
57
59
 
package/dist/client.cjs CHANGED
@@ -283,7 +283,15 @@ var CoreToClientMsg = import_zod3.z.discriminatedUnion("type", [ResponseMsg, Err
283
283
  var CloseCode = {
284
284
  NORMAL: 1e3,
285
285
  GOING_AWAY: 1001,
286
- // relay deploy / app quit — reconnect immediately
286
+ // app quit; relay: the device was silent for 75 s — reconnect
287
+ /** Never sent by anyone: what a socket reports when it drops without a close frame. A relay
288
+ * deploy (every Durable Object restarts) arrives as this — reconnect immediately. */
289
+ ABNORMAL: 1006,
290
+ /** Relay → clients: the device (re)connected, so the core session they spoke to is gone —
291
+ * reconnect, hello, and reattach with since_seq. */
292
+ DEVICE_RECONNECTED: 1012,
293
+ TRY_AGAIN_LATER: 1013,
294
+ // relay: signing keys or the device registry unreachable — retry
287
295
  AUTH_INVALID: 4001,
288
296
  AUTH_FORBIDDEN: 4003,
289
297
  DEVICE_NOT_FOUND: 4004,
@@ -296,6 +304,7 @@ var CloseCode = {
296
304
  PROTOCOL_ERROR: 4400,
297
305
  UPGRADE_REQUIRED: 4426
298
306
  };
307
+ var CloseCodeValue = import_zod3.z.literal([1e3, 1001, 1006, 1012, 1013, 4001, 4003, 4004, 4008, 4009, 4010, 4400, 4426]);
299
308
 
300
309
  // src/schema/frame.ts
301
310
  var import_zod4 = require("zod");
@@ -307,6 +316,22 @@ var FrameHeader = import_zod4.z.strictObject({
307
316
  sid: u32,
308
317
  seq: u32
309
318
  });
319
+ var RelayHopEnvelopeHeader = import_zod4.z.strictObject({
320
+ version: import_zod4.z.literal(FRAME_VERSION),
321
+ flags: import_zod4.z.literal(0),
322
+ channel: import_zod4.z.literal(255),
323
+ cid: u32,
324
+ sid: import_zod4.z.literal(0),
325
+ seq: import_zod4.z.literal(0)
326
+ });
327
+ var RelayHopConnectionEnd = import_zod4.z.strictObject({
328
+ version: import_zod4.z.literal(FRAME_VERSION),
329
+ flags: import_zod4.z.literal(1),
330
+ channel: import_zod4.z.literal(255),
331
+ cid: import_zod4.z.int().min(1).max(4294967295),
332
+ sid: import_zod4.z.literal(0),
333
+ seq: import_zod4.z.literal(0)
334
+ });
310
335
  var DEFAULT_WINDOW_BYTES = 262144;
311
336
  var DEFAULT_MAX_FRAME_PAYLOAD_BYTES = 65536;
312
337
 
@@ -616,6 +641,22 @@ var RelayCallResponse = import_zod9.z.discriminatedUnion("ok", [
616
641
  import_zod9.z.strictObject({ ok: import_zod9.z.literal(true), result: import_zod9.z.unknown() }),
617
642
  import_zod9.z.strictObject({ ok: import_zod9.z.literal(false), error: ProtocolErrorBody })
618
643
  ]);
644
+ var RELAY_CALL_HELLO_ID = "hello";
645
+ var RELAY_CALL_REQUEST_ID = "call";
646
+ var RelayCallHello = import_zod9.z.strictObject({
647
+ type: import_zod9.z.literal("hello"),
648
+ id: import_zod9.z.literal(RELAY_CALL_HELLO_ID),
649
+ protocolVersion: ProtocolVersion,
650
+ clientType: import_zod9.z.literal("server"),
651
+ clientVersion: import_zod9.z.string().min(1).max(32)
652
+ });
653
+ var RelayCallEnvelope = import_zod9.z.strictObject({
654
+ id: import_zod9.z.literal(RELAY_CALL_REQUEST_ID),
655
+ type: import_zod9.z.literal("request"),
656
+ cap: import_zod9.z.string().min(1).max(32),
657
+ op: import_zod9.z.string().min(1).max(64),
658
+ params: import_zod9.z.unknown()
659
+ });
619
660
 
620
661
  // src/schema/registry.ts
621
662
  var FS_ERR = ["NOT_FOUND", "PERMISSION_DENIED_OS", "INVALID_PARAMS", "RESOURCE_BUSY", "INTERNAL"];