@av-pi-studio/protocol 0.0.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.
Files changed (38) hide show
  1. package/dist/.tsbuildinfo +1 -0
  2. package/dist/binary-frames/file-transfer-protocol.d.ts +63 -0
  3. package/dist/binary-frames/file-transfer-protocol.d.ts.map +1 -0
  4. package/dist/binary-frames/file-transfer-protocol.js +108 -0
  5. package/dist/binary-frames/file-transfer-protocol.js.map +1 -0
  6. package/dist/binary-frames/index.d.ts +3 -0
  7. package/dist/binary-frames/index.d.ts.map +1 -0
  8. package/dist/binary-frames/index.js +4 -0
  9. package/dist/binary-frames/index.js.map +1 -0
  10. package/dist/binary-frames/terminal-stream-protocol.d.ts +67 -0
  11. package/dist/binary-frames/terminal-stream-protocol.d.ts.map +1 -0
  12. package/dist/binary-frames/terminal-stream-protocol.js +104 -0
  13. package/dist/binary-frames/terminal-stream-protocol.js.map +1 -0
  14. package/dist/client-capabilities.d.ts +46 -0
  15. package/dist/client-capabilities.d.ts.map +1 -0
  16. package/dist/client-capabilities.js +75 -0
  17. package/dist/client-capabilities.js.map +1 -0
  18. package/dist/endpoint.d.ts +27 -0
  19. package/dist/endpoint.d.ts.map +1 -0
  20. package/dist/endpoint.js +75 -0
  21. package/dist/endpoint.js.map +1 -0
  22. package/dist/index.d.ts +9 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +17 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/messages.d.ts +6119 -0
  27. package/dist/messages.d.ts.map +1 -0
  28. package/dist/messages.js +372 -0
  29. package/dist/messages.js.map +1 -0
  30. package/dist/provider-manifest.d.ts +176 -0
  31. package/dist/provider-manifest.d.ts.map +1 -0
  32. package/dist/provider-manifest.js +43 -0
  33. package/dist/provider-manifest.js.map +1 -0
  34. package/dist/validation.d.ts +77 -0
  35. package/dist/validation.d.ts.map +1 -0
  36. package/dist/validation.js +54 -0
  37. package/dist/validation.js.map +1 -0
  38. package/package.json +23 -0
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Daemon endpoint / host parsing (MAIN-SCOPE §4 protocol responsibilities).
3
+ *
4
+ * Parses a daemon target into a normalized descriptor. Supported forms:
5
+ * - `host:port` / `host` → direct (default port 6767)
6
+ * - `tcp://host:port?ssl=&password=` → direct, with ssl/password params
7
+ * - `ws://host:port` / `wss://host:port` → direct (wss ⇒ ssl)
8
+ * - `relay://relayHost[:port]/<relayId>?...` → relay
9
+ */
10
+ /** Default daemon listen port (MAIN-SCOPE §2: `127.0.0.1:6767`). */
11
+ export declare const DEFAULT_DAEMON_PORT = 6767;
12
+ export interface EndpointDescriptor {
13
+ kind: "direct" | "relay";
14
+ host: string;
15
+ port: number;
16
+ ssl: boolean;
17
+ password?: string;
18
+ /** Relay channel/server id (relay endpoints only). */
19
+ relayId?: string;
20
+ /** The original input string. */
21
+ raw: string;
22
+ }
23
+ /** Parse a daemon target string into a normalized {@link EndpointDescriptor}. */
24
+ export declare function parseEndpoint(input: string, opts?: {
25
+ defaultPort?: number;
26
+ }): EndpointDescriptor;
27
+ //# sourceMappingURL=endpoint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint.d.ts","sourceRoot":"","sources":["../src/endpoint.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,oEAAoE;AACpE,eAAO,MAAM,mBAAmB,OAAO,CAAC;AAExC,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,OAAO,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sDAAsD;IACtD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iCAAiC;IACjC,GAAG,EAAE,MAAM,CAAC;CACb;AAsBD,iFAAiF;AACjF,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,kBAAkB,CA4ChG"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Daemon endpoint / host parsing (MAIN-SCOPE §4 protocol responsibilities).
3
+ *
4
+ * Parses a daemon target into a normalized descriptor. Supported forms:
5
+ * - `host:port` / `host` → direct (default port 6767)
6
+ * - `tcp://host:port?ssl=&password=` → direct, with ssl/password params
7
+ * - `ws://host:port` / `wss://host:port` → direct (wss ⇒ ssl)
8
+ * - `relay://relayHost[:port]/<relayId>?...` → relay
9
+ */
10
+ /** Default daemon listen port (MAIN-SCOPE §2: `127.0.0.1:6767`). */
11
+ export const DEFAULT_DAEMON_PORT = 6767;
12
+ function truthyFlag(value) {
13
+ if (value === null)
14
+ return false;
15
+ const v = value.trim().toLowerCase();
16
+ return v === "" ? true : v === "1" || v === "true" || v === "yes" || v === "on";
17
+ }
18
+ function splitHostPort(authority, defaultPort) {
19
+ // IPv6 literal in brackets: [::1]:6767
20
+ const bracket = authority.match(/^\[(.+)\](?::(\d+))?$/);
21
+ if (bracket) {
22
+ return { host: bracket[1], port: bracket[2] ? Number(bracket[2]) : defaultPort };
23
+ }
24
+ const idx = authority.lastIndexOf(":");
25
+ if (idx === -1)
26
+ return { host: authority, port: defaultPort };
27
+ const host = authority.slice(0, idx);
28
+ const portStr = authority.slice(idx + 1);
29
+ const port = Number(portStr);
30
+ return { host, port: Number.isFinite(port) && portStr !== "" ? port : defaultPort };
31
+ }
32
+ /** Parse a daemon target string into a normalized {@link EndpointDescriptor}. */
33
+ export function parseEndpoint(input, opts) {
34
+ const raw = input.trim();
35
+ if (raw === "")
36
+ throw new Error("empty endpoint");
37
+ const defaultPort = opts?.defaultPort ?? DEFAULT_DAEMON_PORT;
38
+ const schemeMatch = raw.match(/^([a-z][a-z0-9+.-]*):\/\//i);
39
+ if (!schemeMatch) {
40
+ // Bare `host` or `host:port`.
41
+ const { host, port } = splitHostPort(raw, defaultPort);
42
+ return { kind: "direct", host, port, ssl: false, raw };
43
+ }
44
+ const scheme = schemeMatch[1].toLowerCase();
45
+ const url = new URL(raw);
46
+ const params = url.searchParams;
47
+ const password = params.get("password") ?? undefined;
48
+ if (scheme === "relay") {
49
+ const port = url.port ? Number(url.port) : defaultPort;
50
+ const relayId = url.pathname.replace(/^\/+/, "") || params.get("relayId") || undefined;
51
+ const ssl = truthyFlag(params.get("ssl")) || truthyFlag(params.get("tls"));
52
+ return {
53
+ kind: "relay",
54
+ host: url.hostname,
55
+ port,
56
+ ssl,
57
+ ...(password !== undefined ? { password } : {}),
58
+ ...(relayId ? { relayId } : {}),
59
+ raw,
60
+ };
61
+ }
62
+ // direct schemes: tcp, ws, wss, http, https
63
+ const sslFromScheme = scheme === "wss" || scheme === "https";
64
+ const ssl = sslFromScheme || truthyFlag(params.get("ssl")) || truthyFlag(params.get("tls"));
65
+ const port = url.port ? Number(url.port) : defaultPort;
66
+ return {
67
+ kind: "direct",
68
+ host: url.hostname,
69
+ port,
70
+ ssl,
71
+ ...(password !== undefined ? { password } : {}),
72
+ raw,
73
+ };
74
+ }
75
+ //# sourceMappingURL=endpoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint.js","sourceRoot":"","sources":["../src/endpoint.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,oEAAoE;AACpE,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAcxC,SAAS,UAAU,CAAC,KAAoB;IACtC,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IACjC,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACrC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,MAAM,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,IAAI,CAAC;AAClF,CAAC;AA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C,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC/B,GAAG;SACJ,CAAC;IACJ,CAAC;IAED,4CAA4C;IAC5C,MAAM,aAAa,GAAG,MAAM,KAAK,KAAK,IAAI,MAAM,KAAK,OAAO,CAAC;IAC7D,MAAM,GAAG,GAAG,aAAa,IAAI,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IAC5F,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC;IACvD,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,GAAG,CAAC,QAAQ;QAClB,IAAI;QACJ,GAAG;QACH,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/C,GAAG;KACJ,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ /** Protocol package version marker; real wire schemas land in sprint-002. */
2
+ export declare const PROTOCOL_PACKAGE: "@av-pi-studio/protocol";
3
+ export * from "./validation.js";
4
+ export * from "./messages.js";
5
+ export * from "./client-capabilities.js";
6
+ export * from "./binary-frames/index.js";
7
+ export * from "./endpoint.js";
8
+ export * from "./provider-manifest.js";
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,6EAA6E;AAC7E,eAAO,MAAM,gBAAgB,EAAG,wBAAiC,CAAC;AAGlE,cAAc,iBAAiB,CAAC;AAGhC,cAAc,eAAe,CAAC;AAG9B,cAAc,0BAA0B,CAAC;AAGzC,cAAc,0BAA0B,CAAC;AAGzC,cAAc,eAAe,CAAC;AAG9B,cAAc,wBAAwB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,17 @@
1
+ // @av-pi-studio/protocol — shared wire schemas, codecs, capability flags.
2
+ // Depends on no other workspace package (see MAIN-SCOPE.md §3).
3
+ /** Protocol package version marker; real wire schemas land in sprint-002. */
4
+ export const PROTOCOL_PACKAGE = "@av-pi-studio/protocol";
5
+ // Shared validation conventions + base primitive schemas (reused by protocol + persistence).
6
+ export * from "./validation.js";
7
+ // WebSocket wire schemas: top-level envelopes, handshake, session messages.
8
+ export * from "./messages.js";
9
+ // Capability flags + serialization-time gating.
10
+ export * from "./client-capabilities.js";
11
+ // Binary frame codecs (terminal stream + file transfer).
12
+ export * from "./binary-frames/index.js";
13
+ // Endpoint/host parsing.
14
+ export * from "./endpoint.js";
15
+ // Provider manifest types.
16
+ export * from "./provider-manifest.js";
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,gEAAgE;AAEhE,6EAA6E;AAC7E,MAAM,CAAC,MAAM,gBAAgB,GAAG,wBAAiC,CAAC;AAElE,6FAA6F;AAC7F,cAAc,iBAAiB,CAAC;AAEhC,4EAA4E;AAC5E,cAAc,eAAe,CAAC;AAE9B,gDAAgD;AAChD,cAAc,0BAA0B,CAAC;AAEzC,yDAAyD;AACzD,cAAc,0BAA0B,CAAC;AAEzC,yBAAyB;AACzB,cAAc,eAAe,CAAC;AAE9B,2BAA2B;AAC3B,cAAc,wBAAwB,CAAC"}