@ai-matrx/desktop-protocol 0.5.0 → 0.6.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 +12 -0
- package/dist/client.cjs +5 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +2 -2
- package/dist/client.d.ts +2 -2
- package/dist/client.js +5 -1
- package/dist/client.js.map +1 -1
- package/dist/index.cjs +28 -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 +28 -2
- package/dist/index.js.map +1 -1
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/{registry-BeY9D7h0.d.cts → registry-jTmq1CsI.d.cts} +2 -2
- package/dist/{registry-BeY9D7h0.d.ts → registry-jTmq1CsI.d.ts} +2 -2
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { O as OpName } from './registry-
|
|
3
|
-
export { B as BEARER_PREFIX, e as CancelMsg, f as ClientToCoreMsg, C as ClientType, g as CloseCode, h as CloseCodeValue, j as CoreToClientMsg, k as CreditMsg, D as DesktopProtocolError, d as EVENTS, l as EndMsg, E as EndReason, m as ErrorCode, n as ErrorCodeName, o as ErrorData, p as ErrorMsg, q as ErrorReason, r as ErrorReasonName, s as EventMsg, t as EventName, F as FsPatchEditFailure, H as HelloMsg, L as Limits, N as NAMED_SCHEMAS, u as NamedSchemaId, c as OPS, v as OpDescriptor, a as OpParams, b as OpResult, w as OpSpec, P as PING_TEXT, x as PONG_TEXT, y as ProtocolErrorBody, R as RelayMsg, z as RequestMsg, A as ResponseMsg, G as SUBPROTOCOL, S as StreamMeta, I as StreamMsg, W as Welcome, i as isDesktopProtocolError } from './registry-
|
|
2
|
+
import { O as OpName } from './registry-jTmq1CsI.cjs';
|
|
3
|
+
export { B as BEARER_PREFIX, e as CancelMsg, f as ClientToCoreMsg, C as ClientType, g as CloseCode, h as CloseCodeValue, j as CoreToClientMsg, k as CreditMsg, D as DesktopProtocolError, d as EVENTS, l as EndMsg, E as EndReason, m as ErrorCode, n as ErrorCodeName, o as ErrorData, p as ErrorMsg, q as ErrorReason, r as ErrorReasonName, s as EventMsg, t as EventName, F as FsPatchEditFailure, H as HelloMsg, L as Limits, N as NAMED_SCHEMAS, u as NamedSchemaId, c as OPS, v as OpDescriptor, a as OpParams, b as OpResult, w as OpSpec, P as PING_TEXT, x as PONG_TEXT, y as ProtocolErrorBody, R as RelayMsg, z as RequestMsg, A as ResponseMsg, G as SUBPROTOCOL, S as StreamMeta, I as StreamMsg, W as Welcome, i as isDesktopProtocolError } from './registry-jTmq1CsI.cjs';
|
|
4
4
|
export { BROADCAST_CID, DecodedFrame, FRAME_HEADER_BYTES, FRAME_STRUCT_FORMAT, FRAME_VERSION, FrameChannel, FrameChannelValue, FrameFlag, assertFrameHeader, connectionEndFrame, decodeFrame, encodeFrame, hasFlag, isConnectionEnd, readCid, stampCid } from './frame.cjs';
|
|
5
5
|
|
|
6
6
|
/** @ai-matrx/desktop-protocol — version and primitive schemas. Schema source: lint-enforced rules in scripts/check-schema-source.mjs. */
|
|
@@ -9,7 +9,8 @@ declare const PROTOCOL_MAJOR: 1;
|
|
|
9
9
|
/**
|
|
10
10
|
* Minor history (same major = compatible; see src/versioning.ts for the rule and FIELDS_SINCE):
|
|
11
11
|
* 1.0 — the first contract.
|
|
12
|
-
* 1.1 — fs.patch per-edit results; /call reports the negotiated version
|
|
12
|
+
* 1.1 — fs.patch per-edit results; /call reports the negotiated version;
|
|
13
|
+
* device status since_ms is null for a device that never connected.
|
|
13
14
|
*/
|
|
14
15
|
declare const PROTOCOL_MINOR: 1;
|
|
15
16
|
/** This package's version as the wire spells it ("major.minor"): hello, welcome, relay status. */
|
|
@@ -921,7 +922,7 @@ declare const RELAY_CALL_HELLO_ID: "hello";
|
|
|
921
922
|
declare const RELAY_CALL_REQUEST_ID: "call";
|
|
922
923
|
declare const RelayDeviceStatusEvent: z.ZodObject<{
|
|
923
924
|
online: z.ZodBoolean;
|
|
924
|
-
since_ms: z.ZodInt
|
|
925
|
+
since_ms: z.ZodNullable<z.ZodInt>;
|
|
925
926
|
app_version: z.ZodNullable<z.ZodString>;
|
|
926
927
|
protocol_version: z.ZodNullable<z.ZodString>;
|
|
927
928
|
}, z.core.$strict>;
|
|
@@ -1009,7 +1010,7 @@ type RelayCallResponse = z.output<typeof RelayCallResponse>;
|
|
|
1009
1010
|
/** HTTP GET /v1/devices/{device_id}/status (owner JWT). */
|
|
1010
1011
|
declare const RelayStatusResponse: z.ZodObject<{
|
|
1011
1012
|
online: z.ZodBoolean;
|
|
1012
|
-
since_ms: z.ZodInt
|
|
1013
|
+
since_ms: z.ZodNullable<z.ZodInt>;
|
|
1013
1014
|
app_version: z.ZodNullable<z.ZodString>;
|
|
1014
1015
|
protocol_version: z.ZodNullable<z.ZodString>;
|
|
1015
1016
|
}, z.core.$strict>;
|
|
@@ -1065,6 +1066,28 @@ declare const FIELDS_SINCE: {
|
|
|
1065
1066
|
};
|
|
1066
1067
|
};
|
|
1067
1068
|
type FieldsSincePath = keyof typeof FIELDS_SINCE;
|
|
1069
|
+
/**
|
|
1070
|
+
* 1.0 fields that a later minor lets be null, and what a peer older than that minor is sent
|
|
1071
|
+
* instead (the value that meant the same thing before). Widening a field any other way is a major.
|
|
1072
|
+
*/
|
|
1073
|
+
declare const NULL_SINCE: {
|
|
1074
|
+
readonly "RelayDeviceStatusEvent.since_ms": {
|
|
1075
|
+
readonly since: "1.1";
|
|
1076
|
+
readonly olderPeersGet: 0;
|
|
1077
|
+
};
|
|
1078
|
+
};
|
|
1079
|
+
/** A device status for a reader at `version`: `since_ms` null ("never") becomes 0 before 1.1. */
|
|
1080
|
+
declare function statusForPeer<T extends {
|
|
1081
|
+
since_ms: number | null;
|
|
1082
|
+
}>(status: T, version: string): T;
|
|
1083
|
+
/**
|
|
1084
|
+
* A WebSocket client announces the newest minor it reads at connect time by also offering
|
|
1085
|
+
* `matrx.v<major>.<minor>` beside SUBPROTOCOL (servers still answer SUBPROTOCOL). Before hello is
|
|
1086
|
+
* possible, this is how the relay picks the right shape for its greeting.
|
|
1087
|
+
*/
|
|
1088
|
+
declare function versionSubprotocol(version: string): string;
|
|
1089
|
+
/** The version a client announced in its offered subprotocols; "1.0" when it did not. */
|
|
1090
|
+
declare function announcedVersion(offered: readonly string[]): string;
|
|
1068
1091
|
/** "1.10" > "1.9". Same-major comparison of "major.minor" strings. */
|
|
1069
1092
|
declare function compareVersions(a: string, b: string): number;
|
|
1070
1093
|
/** True when a peer at `version` knows a field added in `since`. */
|
|
@@ -1080,4 +1103,4 @@ declare function forPeer(op: OpName | null, part: "error", value: unknown, versi
|
|
|
1080
1103
|
/** Every op whose result has a versioned field is wired into forPeer (checked by the test). */
|
|
1081
1104
|
declare const VERSIONED_RESULT_OPS: readonly OpName[];
|
|
1082
1105
|
|
|
1083
|
-
export { AbsPath, DEFAULT_MAX_FRAME_PAYLOAD_BYTES, DEFAULT_MAX_MESSAGE_BYTES, DEFAULT_WINDOW_BYTES, DeviceId, ExecCwdEvent, ExecExitedEvent, ExecListParams, ExecListResult, ExecPtyKillParams, ExecPtyKillResult, ExecPtyResizeParams, ExecPtyResizeResult, ExecPtySignalParams, ExecPtySignalResult, ExecPtyStartParams, ExecPtyStartResult, ExecPtyWriteParams, ExecPtyWriteResult, ExecRunParams, ExecRunResult, ExecTitleEvent, FIELDS_SINCE, type FieldsSincePath, FrameHeader, FsChange, FsChangedEvent, FsDeleteParams, FsDeleteResult, FsEncoding, FsEntry, FsKind, FsListParams, FsListResult, FsMkdirParams, FsMkdirResult, FsMoveParams, FsMoveResult, FsPatchEditApplied, FsPatchParams, FsPatchResult, FsReadParams, FsReadResult, FsReadStreamParams, FsReadStreamResult, FsSearchContentParams, FsSearchContentResult, FsSearchPathsParams, FsSearchPathsResult, FsStatParams, FsStatResult, FsWatchParams, FsWatchResult, FsWriteParams, FsWriteResult, OpName, OsPermissionName, PROTOCOL_MAJOR, PROTOCOL_MINOR, PROTOCOL_VERSION, ProtocolVersion, PtyInfo, RELAY_CALL_HELLO_ID, RELAY_CALL_REQUEST_ID, RELAY_CALL_VERSION_HEADER, RelayAuthExpiringEvent, RelayCallEnvelope, RelayCallHello, RelayCallRequest, RelayCallResponse, RelayDeviceStatusEvent, RelayHopConnectionEnd, RelayHopEnvelopeHeader, RelayStatusResponse, RequestId, ResourceId, ResourceInfo, SessionAttachParams, SessionAttachResult, SessionControlChangedEvent, SessionDetachParams, SessionDetachResult, SessionListParams, SessionListResult, SessionReleaseParams, SessionReleaseResult, Signal, SysinfoGetParams, SysinfoGetResult, VERSIONED_RESULT_OPS, compareVersions, epochMs, forPeer, knows, negotiate, nonNegInt, u32 };
|
|
1106
|
+
export { AbsPath, DEFAULT_MAX_FRAME_PAYLOAD_BYTES, DEFAULT_MAX_MESSAGE_BYTES, DEFAULT_WINDOW_BYTES, DeviceId, ExecCwdEvent, ExecExitedEvent, ExecListParams, ExecListResult, ExecPtyKillParams, ExecPtyKillResult, ExecPtyResizeParams, ExecPtyResizeResult, ExecPtySignalParams, ExecPtySignalResult, ExecPtyStartParams, ExecPtyStartResult, ExecPtyWriteParams, ExecPtyWriteResult, ExecRunParams, ExecRunResult, ExecTitleEvent, FIELDS_SINCE, type FieldsSincePath, FrameHeader, FsChange, FsChangedEvent, FsDeleteParams, FsDeleteResult, FsEncoding, FsEntry, FsKind, FsListParams, FsListResult, FsMkdirParams, FsMkdirResult, FsMoveParams, FsMoveResult, FsPatchEditApplied, FsPatchParams, FsPatchResult, FsReadParams, FsReadResult, FsReadStreamParams, FsReadStreamResult, FsSearchContentParams, FsSearchContentResult, FsSearchPathsParams, FsSearchPathsResult, FsStatParams, FsStatResult, FsWatchParams, FsWatchResult, FsWriteParams, FsWriteResult, NULL_SINCE, OpName, OsPermissionName, PROTOCOL_MAJOR, PROTOCOL_MINOR, PROTOCOL_VERSION, ProtocolVersion, PtyInfo, RELAY_CALL_HELLO_ID, RELAY_CALL_REQUEST_ID, RELAY_CALL_VERSION_HEADER, RelayAuthExpiringEvent, RelayCallEnvelope, RelayCallHello, RelayCallRequest, RelayCallResponse, RelayDeviceStatusEvent, RelayHopConnectionEnd, RelayHopEnvelopeHeader, RelayStatusResponse, RequestId, ResourceId, ResourceInfo, SessionAttachParams, SessionAttachResult, SessionControlChangedEvent, SessionDetachParams, SessionDetachResult, SessionListParams, SessionListResult, SessionReleaseParams, SessionReleaseResult, Signal, SysinfoGetParams, SysinfoGetResult, VERSIONED_RESULT_OPS, announcedVersion, compareVersions, epochMs, forPeer, knows, negotiate, nonNegInt, statusForPeer, u32, versionSubprotocol };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { O as OpName } from './registry-
|
|
3
|
-
export { B as BEARER_PREFIX, e as CancelMsg, f as ClientToCoreMsg, C as ClientType, g as CloseCode, h as CloseCodeValue, j as CoreToClientMsg, k as CreditMsg, D as DesktopProtocolError, d as EVENTS, l as EndMsg, E as EndReason, m as ErrorCode, n as ErrorCodeName, o as ErrorData, p as ErrorMsg, q as ErrorReason, r as ErrorReasonName, s as EventMsg, t as EventName, F as FsPatchEditFailure, H as HelloMsg, L as Limits, N as NAMED_SCHEMAS, u as NamedSchemaId, c as OPS, v as OpDescriptor, a as OpParams, b as OpResult, w as OpSpec, P as PING_TEXT, x as PONG_TEXT, y as ProtocolErrorBody, R as RelayMsg, z as RequestMsg, A as ResponseMsg, G as SUBPROTOCOL, S as StreamMeta, I as StreamMsg, W as Welcome, i as isDesktopProtocolError } from './registry-
|
|
2
|
+
import { O as OpName } from './registry-jTmq1CsI.js';
|
|
3
|
+
export { B as BEARER_PREFIX, e as CancelMsg, f as ClientToCoreMsg, C as ClientType, g as CloseCode, h as CloseCodeValue, j as CoreToClientMsg, k as CreditMsg, D as DesktopProtocolError, d as EVENTS, l as EndMsg, E as EndReason, m as ErrorCode, n as ErrorCodeName, o as ErrorData, p as ErrorMsg, q as ErrorReason, r as ErrorReasonName, s as EventMsg, t as EventName, F as FsPatchEditFailure, H as HelloMsg, L as Limits, N as NAMED_SCHEMAS, u as NamedSchemaId, c as OPS, v as OpDescriptor, a as OpParams, b as OpResult, w as OpSpec, P as PING_TEXT, x as PONG_TEXT, y as ProtocolErrorBody, R as RelayMsg, z as RequestMsg, A as ResponseMsg, G as SUBPROTOCOL, S as StreamMeta, I as StreamMsg, W as Welcome, i as isDesktopProtocolError } from './registry-jTmq1CsI.js';
|
|
4
4
|
export { BROADCAST_CID, DecodedFrame, FRAME_HEADER_BYTES, FRAME_STRUCT_FORMAT, FRAME_VERSION, FrameChannel, FrameChannelValue, FrameFlag, assertFrameHeader, connectionEndFrame, decodeFrame, encodeFrame, hasFlag, isConnectionEnd, readCid, stampCid } from './frame.js';
|
|
5
5
|
|
|
6
6
|
/** @ai-matrx/desktop-protocol — version and primitive schemas. Schema source: lint-enforced rules in scripts/check-schema-source.mjs. */
|
|
@@ -9,7 +9,8 @@ declare const PROTOCOL_MAJOR: 1;
|
|
|
9
9
|
/**
|
|
10
10
|
* Minor history (same major = compatible; see src/versioning.ts for the rule and FIELDS_SINCE):
|
|
11
11
|
* 1.0 — the first contract.
|
|
12
|
-
* 1.1 — fs.patch per-edit results; /call reports the negotiated version
|
|
12
|
+
* 1.1 — fs.patch per-edit results; /call reports the negotiated version;
|
|
13
|
+
* device status since_ms is null for a device that never connected.
|
|
13
14
|
*/
|
|
14
15
|
declare const PROTOCOL_MINOR: 1;
|
|
15
16
|
/** This package's version as the wire spells it ("major.minor"): hello, welcome, relay status. */
|
|
@@ -921,7 +922,7 @@ declare const RELAY_CALL_HELLO_ID: "hello";
|
|
|
921
922
|
declare const RELAY_CALL_REQUEST_ID: "call";
|
|
922
923
|
declare const RelayDeviceStatusEvent: z.ZodObject<{
|
|
923
924
|
online: z.ZodBoolean;
|
|
924
|
-
since_ms: z.ZodInt
|
|
925
|
+
since_ms: z.ZodNullable<z.ZodInt>;
|
|
925
926
|
app_version: z.ZodNullable<z.ZodString>;
|
|
926
927
|
protocol_version: z.ZodNullable<z.ZodString>;
|
|
927
928
|
}, z.core.$strict>;
|
|
@@ -1009,7 +1010,7 @@ type RelayCallResponse = z.output<typeof RelayCallResponse>;
|
|
|
1009
1010
|
/** HTTP GET /v1/devices/{device_id}/status (owner JWT). */
|
|
1010
1011
|
declare const RelayStatusResponse: z.ZodObject<{
|
|
1011
1012
|
online: z.ZodBoolean;
|
|
1012
|
-
since_ms: z.ZodInt
|
|
1013
|
+
since_ms: z.ZodNullable<z.ZodInt>;
|
|
1013
1014
|
app_version: z.ZodNullable<z.ZodString>;
|
|
1014
1015
|
protocol_version: z.ZodNullable<z.ZodString>;
|
|
1015
1016
|
}, z.core.$strict>;
|
|
@@ -1065,6 +1066,28 @@ declare const FIELDS_SINCE: {
|
|
|
1065
1066
|
};
|
|
1066
1067
|
};
|
|
1067
1068
|
type FieldsSincePath = keyof typeof FIELDS_SINCE;
|
|
1069
|
+
/**
|
|
1070
|
+
* 1.0 fields that a later minor lets be null, and what a peer older than that minor is sent
|
|
1071
|
+
* instead (the value that meant the same thing before). Widening a field any other way is a major.
|
|
1072
|
+
*/
|
|
1073
|
+
declare const NULL_SINCE: {
|
|
1074
|
+
readonly "RelayDeviceStatusEvent.since_ms": {
|
|
1075
|
+
readonly since: "1.1";
|
|
1076
|
+
readonly olderPeersGet: 0;
|
|
1077
|
+
};
|
|
1078
|
+
};
|
|
1079
|
+
/** A device status for a reader at `version`: `since_ms` null ("never") becomes 0 before 1.1. */
|
|
1080
|
+
declare function statusForPeer<T extends {
|
|
1081
|
+
since_ms: number | null;
|
|
1082
|
+
}>(status: T, version: string): T;
|
|
1083
|
+
/**
|
|
1084
|
+
* A WebSocket client announces the newest minor it reads at connect time by also offering
|
|
1085
|
+
* `matrx.v<major>.<minor>` beside SUBPROTOCOL (servers still answer SUBPROTOCOL). Before hello is
|
|
1086
|
+
* possible, this is how the relay picks the right shape for its greeting.
|
|
1087
|
+
*/
|
|
1088
|
+
declare function versionSubprotocol(version: string): string;
|
|
1089
|
+
/** The version a client announced in its offered subprotocols; "1.0" when it did not. */
|
|
1090
|
+
declare function announcedVersion(offered: readonly string[]): string;
|
|
1068
1091
|
/** "1.10" > "1.9". Same-major comparison of "major.minor" strings. */
|
|
1069
1092
|
declare function compareVersions(a: string, b: string): number;
|
|
1070
1093
|
/** True when a peer at `version` knows a field added in `since`. */
|
|
@@ -1080,4 +1103,4 @@ declare function forPeer(op: OpName | null, part: "error", value: unknown, versi
|
|
|
1080
1103
|
/** Every op whose result has a versioned field is wired into forPeer (checked by the test). */
|
|
1081
1104
|
declare const VERSIONED_RESULT_OPS: readonly OpName[];
|
|
1082
1105
|
|
|
1083
|
-
export { AbsPath, DEFAULT_MAX_FRAME_PAYLOAD_BYTES, DEFAULT_MAX_MESSAGE_BYTES, DEFAULT_WINDOW_BYTES, DeviceId, ExecCwdEvent, ExecExitedEvent, ExecListParams, ExecListResult, ExecPtyKillParams, ExecPtyKillResult, ExecPtyResizeParams, ExecPtyResizeResult, ExecPtySignalParams, ExecPtySignalResult, ExecPtyStartParams, ExecPtyStartResult, ExecPtyWriteParams, ExecPtyWriteResult, ExecRunParams, ExecRunResult, ExecTitleEvent, FIELDS_SINCE, type FieldsSincePath, FrameHeader, FsChange, FsChangedEvent, FsDeleteParams, FsDeleteResult, FsEncoding, FsEntry, FsKind, FsListParams, FsListResult, FsMkdirParams, FsMkdirResult, FsMoveParams, FsMoveResult, FsPatchEditApplied, FsPatchParams, FsPatchResult, FsReadParams, FsReadResult, FsReadStreamParams, FsReadStreamResult, FsSearchContentParams, FsSearchContentResult, FsSearchPathsParams, FsSearchPathsResult, FsStatParams, FsStatResult, FsWatchParams, FsWatchResult, FsWriteParams, FsWriteResult, OpName, OsPermissionName, PROTOCOL_MAJOR, PROTOCOL_MINOR, PROTOCOL_VERSION, ProtocolVersion, PtyInfo, RELAY_CALL_HELLO_ID, RELAY_CALL_REQUEST_ID, RELAY_CALL_VERSION_HEADER, RelayAuthExpiringEvent, RelayCallEnvelope, RelayCallHello, RelayCallRequest, RelayCallResponse, RelayDeviceStatusEvent, RelayHopConnectionEnd, RelayHopEnvelopeHeader, RelayStatusResponse, RequestId, ResourceId, ResourceInfo, SessionAttachParams, SessionAttachResult, SessionControlChangedEvent, SessionDetachParams, SessionDetachResult, SessionListParams, SessionListResult, SessionReleaseParams, SessionReleaseResult, Signal, SysinfoGetParams, SysinfoGetResult, VERSIONED_RESULT_OPS, compareVersions, epochMs, forPeer, knows, negotiate, nonNegInt, u32 };
|
|
1106
|
+
export { AbsPath, DEFAULT_MAX_FRAME_PAYLOAD_BYTES, DEFAULT_MAX_MESSAGE_BYTES, DEFAULT_WINDOW_BYTES, DeviceId, ExecCwdEvent, ExecExitedEvent, ExecListParams, ExecListResult, ExecPtyKillParams, ExecPtyKillResult, ExecPtyResizeParams, ExecPtyResizeResult, ExecPtySignalParams, ExecPtySignalResult, ExecPtyStartParams, ExecPtyStartResult, ExecPtyWriteParams, ExecPtyWriteResult, ExecRunParams, ExecRunResult, ExecTitleEvent, FIELDS_SINCE, type FieldsSincePath, FrameHeader, FsChange, FsChangedEvent, FsDeleteParams, FsDeleteResult, FsEncoding, FsEntry, FsKind, FsListParams, FsListResult, FsMkdirParams, FsMkdirResult, FsMoveParams, FsMoveResult, FsPatchEditApplied, FsPatchParams, FsPatchResult, FsReadParams, FsReadResult, FsReadStreamParams, FsReadStreamResult, FsSearchContentParams, FsSearchContentResult, FsSearchPathsParams, FsSearchPathsResult, FsStatParams, FsStatResult, FsWatchParams, FsWatchResult, FsWriteParams, FsWriteResult, NULL_SINCE, OpName, OsPermissionName, PROTOCOL_MAJOR, PROTOCOL_MINOR, PROTOCOL_VERSION, ProtocolVersion, PtyInfo, RELAY_CALL_HELLO_ID, RELAY_CALL_REQUEST_ID, RELAY_CALL_VERSION_HEADER, RelayAuthExpiringEvent, RelayCallEnvelope, RelayCallHello, RelayCallRequest, RelayCallResponse, RelayDeviceStatusEvent, RelayHopConnectionEnd, RelayHopEnvelopeHeader, RelayStatusResponse, RequestId, ResourceId, ResourceInfo, SessionAttachParams, SessionAttachResult, SessionControlChangedEvent, SessionDetachParams, SessionDetachResult, SessionListParams, SessionListResult, SessionReleaseParams, SessionReleaseResult, Signal, SysinfoGetParams, SysinfoGetResult, VERSIONED_RESULT_OPS, announcedVersion, compareVersions, epochMs, forPeer, knows, negotiate, nonNegInt, statusForPeer, u32, versionSubprotocol };
|
package/dist/index.js
CHANGED
|
@@ -638,7 +638,11 @@ var SessionControlChangedEvent = z8.strictObject({ controller_client_id: z8.stri
|
|
|
638
638
|
import { z as z9 } from "zod";
|
|
639
639
|
var RelayDeviceStatusEvent = z9.strictObject({
|
|
640
640
|
online: z9.boolean(),
|
|
641
|
-
|
|
641
|
+
/**
|
|
642
|
+
* When the device last went online/offline; null = it has never connected (since 1.1 —
|
|
643
|
+
* NULL_SINCE: a 1.0 reader is sent 0, its old meaning).
|
|
644
|
+
*/
|
|
645
|
+
since_ms: epochMs.nullable(),
|
|
642
646
|
app_version: z9.string().max(32).nullable(),
|
|
643
647
|
protocol_version: ProtocolVersion.nullable()
|
|
644
648
|
});
|
|
@@ -825,6 +829,24 @@ var FIELDS_SINCE = {
|
|
|
825
829
|
"RelayCallResponse|0": { protocol_version: "1.1" },
|
|
826
830
|
"RelayCallResponse|1": { protocol_version: "1.1" }
|
|
827
831
|
};
|
|
832
|
+
var NULL_SINCE = {
|
|
833
|
+
"RelayDeviceStatusEvent.since_ms": { since: "1.1", olderPeersGet: 0 }
|
|
834
|
+
};
|
|
835
|
+
function statusForPeer(status, version) {
|
|
836
|
+
const rule = NULL_SINCE["RelayDeviceStatusEvent.since_ms"];
|
|
837
|
+
return status.since_ms === null && !knows(version, rule.since) ? { ...status, since_ms: rule.olderPeersGet } : status;
|
|
838
|
+
}
|
|
839
|
+
function versionSubprotocol(version) {
|
|
840
|
+
return `matrx.v${version}`;
|
|
841
|
+
}
|
|
842
|
+
function announcedVersion(offered) {
|
|
843
|
+
let best = `${PROTOCOL_MAJOR}.0`;
|
|
844
|
+
for (const p of offered) {
|
|
845
|
+
const m = /^matrx\.v(\d+\.\d+)$/.exec(p.trim());
|
|
846
|
+
if (m?.[1] && compareVersions(m[1], best) > 0 && m[1].startsWith(`${PROTOCOL_MAJOR}.`)) best = m[1];
|
|
847
|
+
}
|
|
848
|
+
return best;
|
|
849
|
+
}
|
|
828
850
|
function compareVersions(a, b) {
|
|
829
851
|
const [am = 0, an = 0] = a.split(".").map(Number);
|
|
830
852
|
const [bm = 0, bn = 0] = b.split(".").map(Number);
|
|
@@ -943,6 +965,7 @@ export {
|
|
|
943
965
|
HelloMsg,
|
|
944
966
|
Limits,
|
|
945
967
|
NAMED_SCHEMAS,
|
|
968
|
+
NULL_SINCE,
|
|
946
969
|
OPS,
|
|
947
970
|
OpDescriptor,
|
|
948
971
|
OsPermissionName,
|
|
@@ -989,6 +1012,7 @@ export {
|
|
|
989
1012
|
SysinfoGetResult,
|
|
990
1013
|
VERSIONED_RESULT_OPS,
|
|
991
1014
|
Welcome,
|
|
1015
|
+
announcedVersion,
|
|
992
1016
|
assertFrameHeader,
|
|
993
1017
|
compareVersions,
|
|
994
1018
|
connectionEndFrame,
|
|
@@ -1004,6 +1028,8 @@ export {
|
|
|
1004
1028
|
nonNegInt,
|
|
1005
1029
|
readCid,
|
|
1006
1030
|
stampCid,
|
|
1007
|
-
|
|
1031
|
+
statusForPeer,
|
|
1032
|
+
u32,
|
|
1033
|
+
versionSubprotocol
|
|
1008
1034
|
};
|
|
1009
1035
|
//# sourceMappingURL=index.js.map
|