@kangentic/protocol 0.2.0 → 0.3.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/version.d.ts CHANGED
@@ -8,5 +8,5 @@
8
8
  * differing prologue produces a differing transcript hash `h` from the
9
9
  * first MixHash call, which cascades into every derived key.
10
10
  */
11
- export declare const PROTOCOL_VERSION = "1";
11
+ export declare const PROTOCOL_VERSION = "2";
12
12
  export declare function encodeProtocolVersion(version?: string): Uint8Array;
@@ -1,4 +1,8 @@
1
1
  import type { BridgeMessage } from './messages';
2
2
  export declare const MAX_FRAME_LENGTH: number;
3
+ /** Upper bound on the JSON a compressed frame may declare/inflate to. */
4
+ export declare const MAX_DECODED_LENGTH: number;
5
+ /** JSON below this size ships raw - deflate overhead is not worth it. */
6
+ export declare const COMPRESSION_THRESHOLD: number;
3
7
  export declare function encodeMessage(message: BridgeMessage): Uint8Array;
4
8
  export declare function decodeMessage(bytes: Uint8Array): BridgeMessage;
@@ -15,10 +15,22 @@
15
15
  */
16
16
  import type { CapabilityVerb } from '../capabilities/verbs';
17
17
  import type { JsonValue } from './messages';
18
- import { type ActivityReasonWire, type ActivityStateWire, type BacklogItemWire, type BoardColumnWire, type BoardTaskWire, type DiffFileContentWire, type DiffFileListWire, type SessionUsageWire } from '../events/payloads';
18
+ import { type ActivityReasonWire, type ActivityStateWire, type BacklogItemWire, type BoardColumnWire, type BoardTaskWire, type DiffFileContentWire, type DiffFileListWire, type SessionUsageWire, type TranscriptEntryWire } from '../events/payloads';
19
19
  export interface ReadStreamRequestPayload {
20
20
  sessionId: string;
21
- action: 'subscribe' | 'unsubscribe';
21
+ /**
22
+ * 'transcript-window' is a one-shot windowed-history read: the newest
23
+ * `limit` transcript entries strictly before `beforeIndex` (or the tail
24
+ * when `beforeIndex` is omitted). The desktop may return fewer entries
25
+ * than `limit` to keep the response frame small - page again from the
26
+ * returned `startIndex`. Live updates after 'subscribe' arrive as
27
+ * incremental TranscriptEvent deltas, never full transcripts.
28
+ */
29
+ action: 'subscribe' | 'unsubscribe' | 'transcript-window';
30
+ /** transcript-window only: fetch entries strictly before this absolute index. Omit for the newest window. */
31
+ beforeIndex?: number;
32
+ /** transcript-window only: maximum entries wanted (the desktop may cap this and may return fewer). */
33
+ limit?: number;
22
34
  }
23
35
  /** Initial snapshot returned on subscribe; live updates arrive as TerminalEvent/ActivityEvent/TranscriptEvent. */
24
36
  export interface ReadStreamResponsePayload {
@@ -33,6 +45,19 @@ export interface ReadStreamResponsePayload {
33
45
  }
34
46
  /** Phone-side narrowing of a read-stream subscribe response. Throws on a malformed required field. */
35
47
  export declare function parseReadStreamResponsePayload(payload: JsonValue): ReadStreamResponsePayload;
48
+ /**
49
+ * A contiguous slice of the transcript, returned by the read-stream
50
+ * 'transcript-window' action. `startIndex` is the absolute index of
51
+ * `entries[0]`; `startIndex > 0` means more history exists above.
52
+ */
53
+ export interface TranscriptWindowResponsePayload {
54
+ revision: number;
55
+ totalEntries: number;
56
+ startIndex: number;
57
+ entries: TranscriptEntryWire[];
58
+ }
59
+ /** Phone-side narrowing of a transcript-window response. Throws on a malformed required field. */
60
+ export declare function parseTranscriptWindowResponsePayload(payload: JsonValue): TranscriptWindowResponsePayload;
36
61
  export interface ReadBoardRequestPayload {
37
62
  projectId?: string;
38
63
  /** Defaults to 'subscribe' when omitted. 'unsubscribe' only has an effect when projectId is set - the no-projectId project list is a one-shot read with no live feed to tear down. */
@@ -121,7 +146,7 @@ export interface CapabilityRequestPayloadMap {
121
146
  'board-tool-write': BoardToolRequestPayload;
122
147
  }
123
148
  export interface CapabilityResponsePayloadMap {
124
- 'read-stream': ReadStreamResponsePayload;
149
+ 'read-stream': ReadStreamResponsePayload | TranscriptWindowResponsePayload;
125
150
  'read-board': ReadBoardResponsePayload;
126
151
  'read-diff': ReadDiffResponsePayload;
127
152
  'send-user-message': SendUserMessageResponsePayload;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kangentic/protocol",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Kangentic mobile bridge wire protocol: framing, Noise-based pairing and session handshakes, signed device roster, and capability verbs shared between desktop and mobile.",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -42,7 +42,8 @@
42
42
  "dependencies": {
43
43
  "@noble/ciphers": "^2.2.0",
44
44
  "@noble/curves": "^2.2.0",
45
- "@noble/hashes": "^2.2.0"
45
+ "@noble/hashes": "^2.2.0",
46
+ "fflate": "^0.8.3"
46
47
  },
47
48
  "devDependencies": {
48
49
  "esbuild": "^0.28.0",