@ai-matrx/desktop-protocol 0.5.0 → 0.7.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/CHANGELOG.md +25 -0
- package/dist/client.cjs +47 -13
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +4 -2
- package/dist/client.d.ts +4 -2
- package/dist/client.js +47 -13
- package/dist/client.js.map +1 -1
- package/dist/index.cjs +57 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -6
- package/dist/index.d.ts +29 -6
- package/dist/index.js +57 -2
- package/dist/index.js.map +1 -1
- package/dist/react.d.cts +20 -1
- package/dist/react.d.ts +20 -1
- package/dist/{registry-BeY9D7h0.d.cts → registry-Duc_VFN8.d.cts} +93 -3
- package/dist/{registry-BeY9D7h0.d.ts → registry-Duc_VFN8.d.ts} +93 -3
- package/package.json +1 -1
|
@@ -22,6 +22,96 @@ interface ErrorData {
|
|
|
22
22
|
} | undefined;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* What a connecting side does after each WebSocket close — the ONE table every client reads (the
|
|
27
|
+
* package client, the desktop's relay transport, any other dialer). Never keep a local list of
|
|
28
|
+
* "terminal" codes: a code added to CloseCode without a rule here fails to compile.
|
|
29
|
+
*
|
|
30
|
+
* reconnect_now the far side went away on purpose or the socket died; dial again at once if the
|
|
31
|
+
* connection had opened, with backoff otherwise (a dead network never spins).
|
|
32
|
+
* reconnect transient refusal; dial again with backoff.
|
|
33
|
+
* reauth the token was refused; get a FRESH token and dial once more. A second refusal in
|
|
34
|
+
* a row (no successful open between) is terminal with outcome "signed_out".
|
|
35
|
+
* stop retrying cannot help: stop dialing until something changes (a new sign-in, a
|
|
36
|
+
* new device, an update) and show the outcome.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
type CloseAction = "reconnect_now" | "reconnect" | "reauth" | "stop";
|
|
40
|
+
/** The one state a person is shown when dialing stops. */
|
|
41
|
+
type CloseOutcome = "signed_out" | "not_owned" | "removed" | "revoked" | "replaced" | "upgrade_required";
|
|
42
|
+
interface CloseRule {
|
|
43
|
+
readonly action: CloseAction;
|
|
44
|
+
/** Set for `stop` and `reauth` (the outcome when the fresh token is refused too). */
|
|
45
|
+
readonly outcome?: CloseOutcome;
|
|
46
|
+
/** The error a caller's pending work is failed with. */
|
|
47
|
+
readonly error: readonly [ErrorCodeName, string];
|
|
48
|
+
}
|
|
49
|
+
declare const CLOSE_RULES: {
|
|
50
|
+
readonly 1000: {
|
|
51
|
+
readonly action: "reconnect";
|
|
52
|
+
readonly error: readonly ["DEVICE_OFFLINE", "Connection closed"];
|
|
53
|
+
};
|
|
54
|
+
readonly 1001: {
|
|
55
|
+
readonly action: "reconnect_now";
|
|
56
|
+
readonly error: readonly ["DEVICE_OFFLINE", "Connection lost"];
|
|
57
|
+
};
|
|
58
|
+
readonly 1006: {
|
|
59
|
+
readonly action: "reconnect_now";
|
|
60
|
+
readonly error: readonly ["DEVICE_OFFLINE", "Connection lost"];
|
|
61
|
+
};
|
|
62
|
+
readonly 1012: {
|
|
63
|
+
readonly action: "reconnect_now";
|
|
64
|
+
readonly error: readonly ["DEVICE_OFFLINE", "Device reconnected"];
|
|
65
|
+
};
|
|
66
|
+
readonly 1013: {
|
|
67
|
+
readonly action: "reconnect";
|
|
68
|
+
readonly error: readonly ["DEVICE_OFFLINE", "Relay busy; retrying"];
|
|
69
|
+
};
|
|
70
|
+
readonly 4001: {
|
|
71
|
+
readonly action: "reauth";
|
|
72
|
+
readonly outcome: "signed_out";
|
|
73
|
+
readonly error: readonly ["AUTH_INVALID", "Sign-in was not accepted"];
|
|
74
|
+
};
|
|
75
|
+
readonly 4003: {
|
|
76
|
+
readonly action: "stop";
|
|
77
|
+
readonly outcome: "not_owned";
|
|
78
|
+
readonly error: readonly ["AUTH_FORBIDDEN", "Not this device's owner"];
|
|
79
|
+
};
|
|
80
|
+
readonly 4004: {
|
|
81
|
+
readonly action: "stop";
|
|
82
|
+
readonly outcome: "removed";
|
|
83
|
+
readonly error: readonly ["NOT_FOUND", "Device not found"];
|
|
84
|
+
};
|
|
85
|
+
readonly 4008: {
|
|
86
|
+
readonly action: "reauth";
|
|
87
|
+
readonly outcome: "signed_out";
|
|
88
|
+
readonly error: readonly ["AUTH_EXPIRED", "Sign-in expired"];
|
|
89
|
+
};
|
|
90
|
+
readonly 4009: {
|
|
91
|
+
readonly action: "stop";
|
|
92
|
+
readonly outcome: "replaced";
|
|
93
|
+
readonly error: readonly ["CONFLICT", "Replaced by a newer connection"];
|
|
94
|
+
};
|
|
95
|
+
readonly 4010: {
|
|
96
|
+
readonly action: "stop";
|
|
97
|
+
readonly outcome: "revoked";
|
|
98
|
+
readonly error: readonly ["AUTH_DEVICE_REVOKED", "This device was revoked"];
|
|
99
|
+
};
|
|
100
|
+
readonly 4400: {
|
|
101
|
+
readonly action: "reconnect";
|
|
102
|
+
readonly error: readonly ["PROTOCOL_ERROR", "Connection reset by the relay"];
|
|
103
|
+
};
|
|
104
|
+
readonly 4426: {
|
|
105
|
+
readonly action: "stop";
|
|
106
|
+
readonly outcome: "upgrade_required";
|
|
107
|
+
readonly error: readonly ["PROTOCOL_VERSION_UNSUPPORTED", "Protocol upgrade required"];
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
/** The rule for any close code; one this table does not know (or null: no close frame) reconnects with backoff. */
|
|
111
|
+
declare function closeRule(code: number | null | undefined): CloseRule;
|
|
112
|
+
/** True when dialing must stop after this close (no retry will help). */
|
|
113
|
+
declare function isTerminalClose(code: number | null | undefined): boolean;
|
|
114
|
+
|
|
25
115
|
/**
|
|
26
116
|
* The one error type every package entry throws. It carries the wire ErrorCode (SPEC §5), so a
|
|
27
117
|
* caller branches on `code`/`retryable`/`data.reason` and never parses a message. Zod-free on
|
|
@@ -1247,7 +1337,7 @@ declare const EVENTS: {
|
|
|
1247
1337
|
}, z.core.$strict>;
|
|
1248
1338
|
readonly "relay.device_status": z.ZodObject<{
|
|
1249
1339
|
online: z.ZodBoolean;
|
|
1250
|
-
since_ms: z.ZodInt
|
|
1340
|
+
since_ms: z.ZodNullable<z.ZodInt>;
|
|
1251
1341
|
app_version: z.ZodNullable<z.ZodString>;
|
|
1252
1342
|
protocol_version: z.ZodNullable<z.ZodString>;
|
|
1253
1343
|
}, z.core.$strict>;
|
|
@@ -2331,7 +2421,7 @@ declare const NAMED_SCHEMAS: {
|
|
|
2331
2421
|
}, z.core.$strict>;
|
|
2332
2422
|
readonly RelayDeviceStatusEvent: z.ZodObject<{
|
|
2333
2423
|
online: z.ZodBoolean;
|
|
2334
|
-
since_ms: z.ZodInt
|
|
2424
|
+
since_ms: z.ZodNullable<z.ZodInt>;
|
|
2335
2425
|
app_version: z.ZodNullable<z.ZodString>;
|
|
2336
2426
|
protocol_version: z.ZodNullable<z.ZodString>;
|
|
2337
2427
|
}, z.core.$strict>;
|
|
@@ -2445,4 +2535,4 @@ declare const NAMED_SCHEMAS: {
|
|
|
2445
2535
|
};
|
|
2446
2536
|
type NamedSchemaId = keyof typeof NAMED_SCHEMAS;
|
|
2447
2537
|
|
|
2448
|
-
export {
|
|
2538
|
+
export { type OpSpec as A, BEARER_PREFIX as B, type CloseOutcome as C, DesktopProtocolError as D, EndReason as E, FsPatchEditFailure as F, PONG_TEXT as G, HelloMsg as H, ProtocolErrorBody as I, RequestMsg as J, ResponseMsg as K, Limits as L, SUBPROTOCOL as M, NAMED_SCHEMAS as N, type OpName as O, PING_TEXT as P, StreamMsg as Q, RelayMsg as R, StreamMeta as S, closeRule as T, isTerminalClose as U, Welcome as W, type OpParams as a, type OpResult as b, OPS as c, EVENTS as d, ClientType as e, CLOSE_RULES as f, CancelMsg as g, ClientToCoreMsg as h, isDesktopProtocolError as i, type CloseAction as j, CloseCode as k, CloseCodeValue as l, type CloseRule as m, CoreToClientMsg as n, CreditMsg as o, EndMsg as p, ErrorCode as q, type ErrorCodeName as r, type ErrorData as s, ErrorMsg as t, ErrorReason as u, type ErrorReasonName as v, EventMsg as w, type EventName as x, type NamedSchemaId as y, OpDescriptor as z };
|
|
@@ -22,6 +22,96 @@ interface ErrorData {
|
|
|
22
22
|
} | undefined;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* What a connecting side does after each WebSocket close — the ONE table every client reads (the
|
|
27
|
+
* package client, the desktop's relay transport, any other dialer). Never keep a local list of
|
|
28
|
+
* "terminal" codes: a code added to CloseCode without a rule here fails to compile.
|
|
29
|
+
*
|
|
30
|
+
* reconnect_now the far side went away on purpose or the socket died; dial again at once if the
|
|
31
|
+
* connection had opened, with backoff otherwise (a dead network never spins).
|
|
32
|
+
* reconnect transient refusal; dial again with backoff.
|
|
33
|
+
* reauth the token was refused; get a FRESH token and dial once more. A second refusal in
|
|
34
|
+
* a row (no successful open between) is terminal with outcome "signed_out".
|
|
35
|
+
* stop retrying cannot help: stop dialing until something changes (a new sign-in, a
|
|
36
|
+
* new device, an update) and show the outcome.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
type CloseAction = "reconnect_now" | "reconnect" | "reauth" | "stop";
|
|
40
|
+
/** The one state a person is shown when dialing stops. */
|
|
41
|
+
type CloseOutcome = "signed_out" | "not_owned" | "removed" | "revoked" | "replaced" | "upgrade_required";
|
|
42
|
+
interface CloseRule {
|
|
43
|
+
readonly action: CloseAction;
|
|
44
|
+
/** Set for `stop` and `reauth` (the outcome when the fresh token is refused too). */
|
|
45
|
+
readonly outcome?: CloseOutcome;
|
|
46
|
+
/** The error a caller's pending work is failed with. */
|
|
47
|
+
readonly error: readonly [ErrorCodeName, string];
|
|
48
|
+
}
|
|
49
|
+
declare const CLOSE_RULES: {
|
|
50
|
+
readonly 1000: {
|
|
51
|
+
readonly action: "reconnect";
|
|
52
|
+
readonly error: readonly ["DEVICE_OFFLINE", "Connection closed"];
|
|
53
|
+
};
|
|
54
|
+
readonly 1001: {
|
|
55
|
+
readonly action: "reconnect_now";
|
|
56
|
+
readonly error: readonly ["DEVICE_OFFLINE", "Connection lost"];
|
|
57
|
+
};
|
|
58
|
+
readonly 1006: {
|
|
59
|
+
readonly action: "reconnect_now";
|
|
60
|
+
readonly error: readonly ["DEVICE_OFFLINE", "Connection lost"];
|
|
61
|
+
};
|
|
62
|
+
readonly 1012: {
|
|
63
|
+
readonly action: "reconnect_now";
|
|
64
|
+
readonly error: readonly ["DEVICE_OFFLINE", "Device reconnected"];
|
|
65
|
+
};
|
|
66
|
+
readonly 1013: {
|
|
67
|
+
readonly action: "reconnect";
|
|
68
|
+
readonly error: readonly ["DEVICE_OFFLINE", "Relay busy; retrying"];
|
|
69
|
+
};
|
|
70
|
+
readonly 4001: {
|
|
71
|
+
readonly action: "reauth";
|
|
72
|
+
readonly outcome: "signed_out";
|
|
73
|
+
readonly error: readonly ["AUTH_INVALID", "Sign-in was not accepted"];
|
|
74
|
+
};
|
|
75
|
+
readonly 4003: {
|
|
76
|
+
readonly action: "stop";
|
|
77
|
+
readonly outcome: "not_owned";
|
|
78
|
+
readonly error: readonly ["AUTH_FORBIDDEN", "Not this device's owner"];
|
|
79
|
+
};
|
|
80
|
+
readonly 4004: {
|
|
81
|
+
readonly action: "stop";
|
|
82
|
+
readonly outcome: "removed";
|
|
83
|
+
readonly error: readonly ["NOT_FOUND", "Device not found"];
|
|
84
|
+
};
|
|
85
|
+
readonly 4008: {
|
|
86
|
+
readonly action: "reauth";
|
|
87
|
+
readonly outcome: "signed_out";
|
|
88
|
+
readonly error: readonly ["AUTH_EXPIRED", "Sign-in expired"];
|
|
89
|
+
};
|
|
90
|
+
readonly 4009: {
|
|
91
|
+
readonly action: "stop";
|
|
92
|
+
readonly outcome: "replaced";
|
|
93
|
+
readonly error: readonly ["CONFLICT", "Replaced by a newer connection"];
|
|
94
|
+
};
|
|
95
|
+
readonly 4010: {
|
|
96
|
+
readonly action: "stop";
|
|
97
|
+
readonly outcome: "revoked";
|
|
98
|
+
readonly error: readonly ["AUTH_DEVICE_REVOKED", "This device was revoked"];
|
|
99
|
+
};
|
|
100
|
+
readonly 4400: {
|
|
101
|
+
readonly action: "reconnect";
|
|
102
|
+
readonly error: readonly ["PROTOCOL_ERROR", "Connection reset by the relay"];
|
|
103
|
+
};
|
|
104
|
+
readonly 4426: {
|
|
105
|
+
readonly action: "stop";
|
|
106
|
+
readonly outcome: "upgrade_required";
|
|
107
|
+
readonly error: readonly ["PROTOCOL_VERSION_UNSUPPORTED", "Protocol upgrade required"];
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
/** The rule for any close code; one this table does not know (or null: no close frame) reconnects with backoff. */
|
|
111
|
+
declare function closeRule(code: number | null | undefined): CloseRule;
|
|
112
|
+
/** True when dialing must stop after this close (no retry will help). */
|
|
113
|
+
declare function isTerminalClose(code: number | null | undefined): boolean;
|
|
114
|
+
|
|
25
115
|
/**
|
|
26
116
|
* The one error type every package entry throws. It carries the wire ErrorCode (SPEC §5), so a
|
|
27
117
|
* caller branches on `code`/`retryable`/`data.reason` and never parses a message. Zod-free on
|
|
@@ -1247,7 +1337,7 @@ declare const EVENTS: {
|
|
|
1247
1337
|
}, z.core.$strict>;
|
|
1248
1338
|
readonly "relay.device_status": z.ZodObject<{
|
|
1249
1339
|
online: z.ZodBoolean;
|
|
1250
|
-
since_ms: z.ZodInt
|
|
1340
|
+
since_ms: z.ZodNullable<z.ZodInt>;
|
|
1251
1341
|
app_version: z.ZodNullable<z.ZodString>;
|
|
1252
1342
|
protocol_version: z.ZodNullable<z.ZodString>;
|
|
1253
1343
|
}, z.core.$strict>;
|
|
@@ -2331,7 +2421,7 @@ declare const NAMED_SCHEMAS: {
|
|
|
2331
2421
|
}, z.core.$strict>;
|
|
2332
2422
|
readonly RelayDeviceStatusEvent: z.ZodObject<{
|
|
2333
2423
|
online: z.ZodBoolean;
|
|
2334
|
-
since_ms: z.ZodInt
|
|
2424
|
+
since_ms: z.ZodNullable<z.ZodInt>;
|
|
2335
2425
|
app_version: z.ZodNullable<z.ZodString>;
|
|
2336
2426
|
protocol_version: z.ZodNullable<z.ZodString>;
|
|
2337
2427
|
}, z.core.$strict>;
|
|
@@ -2445,4 +2535,4 @@ declare const NAMED_SCHEMAS: {
|
|
|
2445
2535
|
};
|
|
2446
2536
|
type NamedSchemaId = keyof typeof NAMED_SCHEMAS;
|
|
2447
2537
|
|
|
2448
|
-
export {
|
|
2538
|
+
export { type OpSpec as A, BEARER_PREFIX as B, type CloseOutcome as C, DesktopProtocolError as D, EndReason as E, FsPatchEditFailure as F, PONG_TEXT as G, HelloMsg as H, ProtocolErrorBody as I, RequestMsg as J, ResponseMsg as K, Limits as L, SUBPROTOCOL as M, NAMED_SCHEMAS as N, type OpName as O, PING_TEXT as P, StreamMsg as Q, RelayMsg as R, StreamMeta as S, closeRule as T, isTerminalClose as U, Welcome as W, type OpParams as a, type OpResult as b, OPS as c, EVENTS as d, ClientType as e, CLOSE_RULES as f, CancelMsg as g, ClientToCoreMsg as h, isDesktopProtocolError as i, type CloseAction as j, CloseCode as k, CloseCodeValue as l, type CloseRule as m, CoreToClientMsg as n, CreditMsg as o, EndMsg as p, ErrorCode as q, type ErrorCodeName as r, type ErrorData as s, ErrorMsg as t, ErrorReason as u, type ErrorReasonName as v, EventMsg as w, type EventName as x, type NamedSchemaId as y, OpDescriptor as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-matrx/desktop-protocol",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "The one wire contract between Matrx 2 (the desktop app) and every client that drives it — phone, web app, extension, server: zod schemas for the envelope and every cap.op, the 16-byte binary frame codec, a reconnecting request/stream/credit/reattach client, React hooks, and a generated JSON Schema + Pydantic twin that CI keeps byte-identical.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|