@blue-soda/dsh-remote 0.5.6 → 0.5.7
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/README.md +2 -2
- package/cordis.patch.yml +30 -30
- package/dist/client.github.js +1 -1
- package/dist/client.js +1 -1
- package/dist/index.js +321 -57
- package/dist/index.js.map +3 -3
- package/dsh-plugin.json +41 -41
- package/package.json +165 -165
- package/dist/acp.d.ts +0 -75
- package/dist/acp.d.ts.map +0 -1
- package/dist/acp.js +0 -61
- package/dist/acp.js.map +0 -1
- package/dist/api-proxy-switch.d.ts +0 -33
- package/dist/api-proxy-switch.d.ts.map +0 -1
- package/dist/api-proxy-switch.js +0 -109
- package/dist/api-proxy-switch.js.map +0 -1
- package/dist/atomic-file.d.ts +0 -16
- package/dist/atomic-file.d.ts.map +0 -1
- package/dist/atomic-file.js +0 -81
- package/dist/atomic-file.js.map +0 -1
- package/dist/bin/doctor.d.ts +0 -3
- package/dist/bin/doctor.d.ts.map +0 -1
- package/dist/bin/doctor.js +0 -13
- package/dist/bin/doctor.js.map +0 -1
- package/dist/cli.d.ts +0 -32
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -289
- package/dist/cli.js.map +0 -1
- package/dist/client-runtime.d.ts +0 -375
- package/dist/client-runtime.d.ts.map +0 -1
- package/dist/client-runtime.js +0 -1768
- package/dist/client-runtime.js.map +0 -1
- package/dist/client-secure-transport.d.ts +0 -23
- package/dist/client-secure-transport.d.ts.map +0 -1
- package/dist/client-secure-transport.js +0 -144
- package/dist/client-secure-transport.js.map +0 -1
- package/dist/client-target-store.d.ts +0 -40
- package/dist/client-target-store.d.ts.map +0 -1
- package/dist/client-target-store.js +0 -79
- package/dist/client-target-store.js.map +0 -1
- package/dist/client.d.ts +0 -13
- package/dist/client.d.ts.map +0 -1
- package/dist/codex/app-server.d.ts +0 -71
- package/dist/codex/app-server.d.ts.map +0 -1
- package/dist/codex/app-server.js +0 -268
- package/dist/codex/app-server.js.map +0 -1
- package/dist/codex/codex-image-codec.d.ts +0 -7
- package/dist/codex/codex-image-codec.d.ts.map +0 -1
- package/dist/codex/codex-image-codec.js +0 -288
- package/dist/codex/codex-image-codec.js.map +0 -1
- package/dist/codex/domain.d.ts +0 -102
- package/dist/codex/domain.d.ts.map +0 -1
- package/dist/codex/domain.js +0 -1323
- package/dist/codex/domain.js.map +0 -1
- package/dist/codex/method-policy.d.ts +0 -338
- package/dist/codex/method-policy.d.ts.map +0 -1
- package/dist/codex/method-policy.js +0 -141
- package/dist/codex/method-policy.js.map +0 -1
- package/dist/codex/peer-bridge.d.ts +0 -57
- package/dist/codex/peer-bridge.d.ts.map +0 -1
- package/dist/codex/peer-bridge.js +0 -299
- package/dist/codex/peer-bridge.js.map +0 -1
- package/dist/codex/permissions.d.ts +0 -4
- package/dist/codex/permissions.d.ts.map +0 -1
- package/dist/codex/permissions.js +0 -21
- package/dist/codex/permissions.js.map +0 -1
- package/dist/codex/session-id.d.ts +0 -10
- package/dist/codex/session-id.d.ts.map +0 -1
- package/dist/codex/session-id.js +0 -15
- package/dist/codex/session-id.js.map +0 -1
- package/dist/codex/virtual-harness.d.ts +0 -209
- package/dist/codex/virtual-harness.d.ts.map +0 -1
- package/dist/codex/virtual-harness.js +0 -2650
- package/dist/codex/virtual-harness.js.map +0 -1
- package/dist/codex-workspace-bridge.d.ts +0 -108
- package/dist/codex-workspace-bridge.d.ts.map +0 -1
- package/dist/codex-workspace-bridge.js +0 -502
- package/dist/codex-workspace-bridge.js.map +0 -1
- package/dist/config.d.ts +0 -99
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -127
- package/dist/config.js.map +0 -1
- package/dist/connection-controller.d.ts +0 -44
- package/dist/connection-controller.d.ts.map +0 -1
- package/dist/connection-controller.js +0 -185
- package/dist/connection-controller.js.map +0 -1
- package/dist/control-route.d.ts +0 -34
- package/dist/control-route.d.ts.map +0 -1
- package/dist/control-route.js +0 -136
- package/dist/control-route.js.map +0 -1
- package/dist/control-runtime.d.ts +0 -138
- package/dist/control-runtime.d.ts.map +0 -1
- package/dist/control-runtime.js +0 -543
- package/dist/control-runtime.js.map +0 -1
- package/dist/control-stream.d.ts +0 -67
- package/dist/control-stream.d.ts.map +0 -1
- package/dist/control-stream.js +0 -179
- package/dist/control-stream.js.map +0 -1
- package/dist/defaults.d.ts +0 -9
- package/dist/defaults.d.ts.map +0 -1
- package/dist/defaults.js +0 -9
- package/dist/defaults.js.map +0 -1
- package/dist/file-viewer-bridge.d.ts +0 -30
- package/dist/file-viewer-bridge.d.ts.map +0 -1
- package/dist/file-viewer-bridge.js +0 -128
- package/dist/file-viewer-bridge.js.map +0 -1
- package/dist/file-viewer-contract.d.ts +0 -5
- package/dist/file-viewer-contract.d.ts.map +0 -1
- package/dist/file-viewer-contract.js +0 -4
- package/dist/file-viewer-contract.js.map +0 -1
- package/dist/harness-api-bridge.d.ts +0 -81
- package/dist/harness-api-bridge.d.ts.map +0 -1
- package/dist/harness-api-bridge.js +0 -862
- package/dist/harness-api-bridge.js.map +0 -1
- package/dist/harness-api-history.d.ts +0 -3
- package/dist/harness-api-history.d.ts.map +0 -1
- package/dist/harness-api-history.js +0 -59
- package/dist/harness-api-history.js.map +0 -1
- package/dist/harness-remote-bridge.d.ts +0 -60
- package/dist/harness-remote-bridge.d.ts.map +0 -1
- package/dist/harness-remote-bridge.js +0 -540
- package/dist/harness-remote-bridge.js.map +0 -1
- package/dist/harness-version.d.ts +0 -23
- package/dist/harness-version.d.ts.map +0 -1
- package/dist/harness-version.js +0 -95
- package/dist/harness-version.js.map +0 -1
- package/dist/identity-store.d.ts +0 -45
- package/dist/identity-store.d.ts.map +0 -1
- package/dist/identity-store.js +0 -186
- package/dist/identity-store.js.map +0 -1
- package/dist/ids.d.ts +0 -2
- package/dist/ids.d.ts.map +0 -1
- package/dist/ids.js +0 -17
- package/dist/ids.js.map +0 -1
- package/dist/index.d.ts +0 -78
- package/dist/index.d.ts.map +0 -1
- package/dist/logging.d.ts +0 -18
- package/dist/logging.d.ts.map +0 -1
- package/dist/logging.js +0 -30
- package/dist/logging.js.map +0 -1
- package/dist/loopback-host.d.ts +0 -20
- package/dist/loopback-host.d.ts.map +0 -1
- package/dist/loopback-host.js +0 -245
- package/dist/loopback-host.js.map +0 -1
- package/dist/loopback-preview.d.ts +0 -19
- package/dist/loopback-preview.d.ts.map +0 -1
- package/dist/loopback-preview.js +0 -232
- package/dist/loopback-preview.js.map +0 -1
- package/dist/native-rtc-helper.d.ts +0 -14
- package/dist/native-rtc-helper.d.ts.map +0 -1
- package/dist/native-rtc-helper.js +0 -575
- package/dist/native-rtc-helper.js.map +0 -1
- package/dist/remote-api-proxy.d.ts +0 -17
- package/dist/remote-api-proxy.d.ts.map +0 -1
- package/dist/remote-api-proxy.js +0 -451
- package/dist/remote-api-proxy.js.map +0 -1
- package/dist/remote-directory-browser.d.ts +0 -16
- package/dist/remote-directory-browser.d.ts.map +0 -1
- package/dist/remote-directory-browser.js +0 -48
- package/dist/remote-directory-browser.js.map +0 -1
- package/dist/remote-file-content-provider.d.ts +0 -48
- package/dist/remote-file-content-provider.d.ts.map +0 -1
- package/dist/remote-file-content-provider.js +0 -93
- package/dist/remote-file-content-provider.js.map +0 -1
- package/dist/remote-typert-gateway.d.ts +0 -20
- package/dist/remote-typert-gateway.d.ts.map +0 -1
- package/dist/remote-typert-gateway.js +0 -334
- package/dist/remote-typert-gateway.js.map +0 -1
- package/dist/rpc-binary-attachments.d.ts +0 -33
- package/dist/rpc-binary-attachments.d.ts.map +0 -1
- package/dist/rpc-binary-attachments.js +0 -142
- package/dist/rpc-binary-attachments.js.map +0 -1
- package/dist/rpc-router.d.ts +0 -31
- package/dist/rpc-router.d.ts.map +0 -1
- package/dist/rpc-router.js +0 -201
- package/dist/rpc-router.js.map +0 -1
- package/dist/safe-error.d.ts +0 -8
- package/dist/safe-error.d.ts.map +0 -1
- package/dist/safe-error.js +0 -20
- package/dist/safe-error.js.map +0 -1
- package/dist/server-api.d.ts +0 -109
- package/dist/server-api.d.ts.map +0 -1
- package/dist/server-api.js +0 -520
- package/dist/server-api.js.map +0 -1
- package/dist/server-connection.d.ts +0 -79
- package/dist/server-connection.d.ts.map +0 -1
- package/dist/server-connection.js +0 -1023
- package/dist/server-connection.js.map +0 -1
- package/dist/server-credentials.d.ts +0 -55
- package/dist/server-credentials.d.ts.map +0 -1
- package/dist/server-credentials.js +0 -108
- package/dist/server-credentials.js.map +0 -1
- package/dist/service.d.ts +0 -151
- package/dist/service.d.ts.map +0 -1
- package/dist/service.js +0 -448
- package/dist/service.js.map +0 -1
- package/dist/session-format-compat.d.ts +0 -3
- package/dist/session-format-compat.d.ts.map +0 -1
- package/dist/session-format-compat.js +0 -183
- package/dist/session-format-compat.js.map +0 -1
- package/dist/status-stream.d.ts +0 -48
- package/dist/status-stream.d.ts.map +0 -1
- package/dist/status-stream.js +0 -133
- package/dist/status-stream.js.map +0 -1
- package/dist/terminal-policy.d.ts +0 -21
- package/dist/terminal-policy.d.ts.map +0 -1
- package/dist/terminal-policy.js +0 -68
- package/dist/terminal-policy.js.map +0 -1
- package/dist/tui-command.d.ts +0 -13
- package/dist/tui-command.d.ts.map +0 -1
- package/dist/tui-command.js +0 -392
- package/dist/tui-command.js.map +0 -1
- package/dist/typert-gateway-contract.d.ts +0 -59
- package/dist/typert-gateway-contract.d.ts.map +0 -1
- package/dist/typert-gateway-contract.js +0 -2
- package/dist/typert-gateway-contract.js.map +0 -1
- package/dist/typert-gateway-switch.d.ts +0 -85
- package/dist/typert-gateway-switch.d.ts.map +0 -1
- package/dist/typert-gateway-switch.js +0 -448
- package/dist/typert-gateway-switch.js.map +0 -1
- package/dist/types.d.ts +0 -20
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/version.d.ts +0 -12
- package/dist/version.d.ts.map +0 -1
- package/dist/version.js +0 -12
- package/dist/version.js.map +0 -1
- package/dist/werift-rtc.d.ts +0 -121
- package/dist/werift-rtc.d.ts.map +0 -1
- package/dist/werift-rtc.js +0 -490
- package/dist/werift-rtc.js.map +0 -1
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Rehydrate the out-of-band byte attachments DSH puts beside a Gateway result.
|
|
3
|
-
*
|
|
4
|
-
* The Harness Gateway encodes a result containing a `Uint8Array` as a placeholder plus an
|
|
5
|
-
* attachment list — `{ ok: true, value: { data: null, … }, attachments: [{ path: ['data'],
|
|
6
|
-
* bytes }] }` — and its own connection layer copies `bytes` back to `path` before the value is
|
|
7
|
-
* validated against the generated schema (`z.instanceof(Uint8Array)`, emitted by
|
|
8
|
-
* `typert/generator`). A native Remote call never touches that layer, so our carrier sees the
|
|
9
|
-
* envelope raw, JSON-encoded: the placeholder stays `null` and the bytes arrive as
|
|
10
|
-
* `{ "0": 137, "1": 80, … }`. Handing that to DSH fails with
|
|
11
|
-
* `expected "Uint8Array", path: ["data"]`, which is exactly the image-preview failure.
|
|
12
|
-
*
|
|
13
|
-
* Hydrating here keeps the carrier compatible with any Host version: a Host that never sends
|
|
14
|
-
* attachments passes through untouched.
|
|
15
|
-
*/
|
|
16
|
-
export function hydrateRpcAttachments(result) {
|
|
17
|
-
if (!isRecord(result))
|
|
18
|
-
return result;
|
|
19
|
-
const envelope = result;
|
|
20
|
-
if (!Array.isArray(envelope.attachments) || envelope.attachments.length === 0)
|
|
21
|
-
return result;
|
|
22
|
-
const { attachments, ...rest } = result;
|
|
23
|
-
const base = Object.hasOwn(rest, 'value') ? rest.value : undefined;
|
|
24
|
-
for (const attachment of attachments) {
|
|
25
|
-
const entry = attachment;
|
|
26
|
-
const path = Array.isArray(entry.path) ? entry.path : undefined;
|
|
27
|
-
if (path === undefined || path.length === 0) {
|
|
28
|
-
throw new Error('The remote Host returned a byte attachment without a path.');
|
|
29
|
-
}
|
|
30
|
-
assignAtPath(base, path, decodeAttachmentBytes(entry.bytes));
|
|
31
|
-
}
|
|
32
|
-
// DSH's own client drops the envelope; downstream code must see the identical shape.
|
|
33
|
-
return rest;
|
|
34
|
-
}
|
|
35
|
-
function assignAtPath(base, path, bytes) {
|
|
36
|
-
if (base === null || typeof base !== 'object') {
|
|
37
|
-
throw new Error('The remote Host returned a byte attachment that its result cannot hold.');
|
|
38
|
-
}
|
|
39
|
-
let cursor = base;
|
|
40
|
-
for (let index = 0; index < path.length - 1; index += 1) {
|
|
41
|
-
const key = pathKey(path[index]);
|
|
42
|
-
const next = cursor[key];
|
|
43
|
-
if (next === null || typeof next !== 'object') {
|
|
44
|
-
throw new Error('The remote Host returned a byte attachment at an unknown result path.');
|
|
45
|
-
}
|
|
46
|
-
cursor = next;
|
|
47
|
-
}
|
|
48
|
-
cursor[pathKey(path[path.length - 1])] = bytes;
|
|
49
|
-
}
|
|
50
|
-
function pathKey(segment) {
|
|
51
|
-
if (typeof segment === 'string')
|
|
52
|
-
return segment;
|
|
53
|
-
if (typeof segment === 'number' && Number.isInteger(segment) && segment >= 0)
|
|
54
|
-
return String(segment);
|
|
55
|
-
throw new Error('The remote Host returned a byte attachment with an invalid path segment.');
|
|
56
|
-
}
|
|
57
|
-
/** Accepts every shape a `Uint8Array` takes after a JSON round trip, plus the original. */
|
|
58
|
-
function decodeAttachmentBytes(value) {
|
|
59
|
-
if (value instanceof Uint8Array)
|
|
60
|
-
return value;
|
|
61
|
-
if (typeof value === 'string')
|
|
62
|
-
return decodeBase64(value);
|
|
63
|
-
if (Array.isArray(value))
|
|
64
|
-
return Uint8Array.from(value);
|
|
65
|
-
if (!isRecord(value))
|
|
66
|
-
throw new Error('The remote Host returned invalid byte attachment data.');
|
|
67
|
-
if (Array.isArray(value.data)) {
|
|
68
|
-
// Node's Buffer.toJSON() produces { type: 'Buffer', data: [...] }.
|
|
69
|
-
return Uint8Array.from(value.data);
|
|
70
|
-
}
|
|
71
|
-
const keys = Object.keys(value);
|
|
72
|
-
if (keys.every(key => /^\d+$/u.test(key))) {
|
|
73
|
-
// JSON.stringify(new Uint8Array([9, 0])) produces { "0": 9, "1": 0 }.
|
|
74
|
-
const ordered = keys.map(Number).sort((left, right) => left - right);
|
|
75
|
-
return Uint8Array.from(ordered.map(key => value[String(key)]));
|
|
76
|
-
}
|
|
77
|
-
throw new Error('The remote Host returned invalid byte attachment data.');
|
|
78
|
-
}
|
|
79
|
-
function decodeBase64(value) {
|
|
80
|
-
const binary = atob(value);
|
|
81
|
-
const bytes = new Uint8Array(binary.length);
|
|
82
|
-
for (let index = 0; index < binary.length; index += 1)
|
|
83
|
-
bytes[index] = binary.charCodeAt(index);
|
|
84
|
-
return bytes;
|
|
85
|
-
}
|
|
86
|
-
function isRecord(value) {
|
|
87
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Mirror of the same wire form for our own Host half.
|
|
91
|
-
*
|
|
92
|
-
* A native Remote call leaves the Host through this plugin's tunnel, which JSON-encodes whatever the
|
|
93
|
-
* Gateway returned. DSH rehydrates its own result before the Host plugin sees it, so the bytes arrive
|
|
94
|
-
* as a real \`Uint8Array\` again - and \`JSON.stringify\` turns that into \`{"0":137,"1":80,…}\`, a shape no
|
|
95
|
-
* generated schema accepts. Sending DSH's own form instead (a placeholder plus \`attachments\`) keeps one
|
|
96
|
-
* convention on both sides of the tunnel and lets \`hydrateRpcAttachments\` put the bytes back. A result
|
|
97
|
-
* without bytes is returned untouched, and tagging twice changes nothing.
|
|
98
|
-
*
|
|
99
|
-
* @param result - Gateway result about to be JSON-encoded for the client.
|
|
100
|
-
* @returns the same result, or one carrying byte attachments.
|
|
101
|
-
*/
|
|
102
|
-
export function collectRpcAttachments(result) {
|
|
103
|
-
if (!isRecord(result) || !Object.hasOwn(result, 'value'))
|
|
104
|
-
return result;
|
|
105
|
-
const attachments = [];
|
|
106
|
-
const value = replaceBytes(result.value, [], attachments);
|
|
107
|
-
if (attachments.length === 0)
|
|
108
|
-
return result;
|
|
109
|
-
return { ...result, value, attachments };
|
|
110
|
-
}
|
|
111
|
-
function replaceBytes(value, path, attachments) {
|
|
112
|
-
if (value instanceof Uint8Array) {
|
|
113
|
-
attachments.push({ path: [...path], bytes: encodeBase64(value) });
|
|
114
|
-
// The placeholder has to stay assignable at the same path; hydration overwrites it.
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
117
|
-
if (Array.isArray(value))
|
|
118
|
-
return value.map((item, index) => replaceBytes(item, [...path, index], attachments));
|
|
119
|
-
if (!isRecord(value))
|
|
120
|
-
return value;
|
|
121
|
-
const clone = {};
|
|
122
|
-
for (const [key, item] of Object.entries(value))
|
|
123
|
-
clone[key] = replaceBytes(item, [...path, key], attachments);
|
|
124
|
-
return clone;
|
|
125
|
-
}
|
|
126
|
-
function encodeBase64(bytes) {
|
|
127
|
-
let binary = '';
|
|
128
|
-
for (let offset = 0; offset < bytes.byteLength; offset += 0x8000) {
|
|
129
|
-
binary += String.fromCharCode(...bytes.subarray(offset, offset + 0x8000));
|
|
130
|
-
}
|
|
131
|
-
return btoa(binary);
|
|
132
|
-
}
|
|
133
|
-
/** Decode one byte value in any shape a JSON hop can produce, or undefined when it is not bytes. */
|
|
134
|
-
export function decodeByteValue(value) {
|
|
135
|
-
try {
|
|
136
|
-
return decodeAttachmentBytes(value);
|
|
137
|
-
}
|
|
138
|
-
catch {
|
|
139
|
-
return undefined;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
//# sourceMappingURL=rpc-binary-attachments.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-binary-attachments.js","sourceRoot":"","sources":["../src/rpc-binary-attachments.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAQH,MAAM,UAAU,qBAAqB,CAAC,MAAe;IACnD,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAA;IACpC,MAAM,QAAQ,GAAG,MAA4B,CAAA;IAC7C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,WAA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KAAK,IAAI,MAAM,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,UAAU,EAAE,MAAM,IAAI,MAAM,EAAE,CAAC;QACjE,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,CAAA;IAC3E,CAAC;IACD,OAAO,IAAI,CAAC,MAAM,CAAC,CAAA;AACrB,CAAC;AAED,oGAAoG;AACpG,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,IAAI,CAAC;QACH,OAAO,qBAAqB,CAAC,KAAK,CAAC,CAAA;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC"}
|
package/dist/rpc-router.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { type RemoteMessage } from '@dsh-remote/protocol';
|
|
2
|
-
import type { LoopbackHost } from './loopback-host.js';
|
|
3
|
-
import type { RemoteFileViewerBridge } from './file-viewer-bridge.js';
|
|
4
|
-
import type { HarnessApiBridge } from './harness-api-bridge.js';
|
|
5
|
-
import type { HarnessRemoteBridge } from './harness-remote-bridge.js';
|
|
6
|
-
import type { SafeLogger } from './logging.js';
|
|
7
|
-
import type { CodexPeerBridge } from './codex/peer-bridge.js';
|
|
8
|
-
import type { AcpGateway } from './acp.js';
|
|
9
|
-
export { RpcError } from './safe-error.js';
|
|
10
|
-
export declare const HOST_CAPABILITIES: readonly ["harness.api.v1", "harness.api.transfer.v1", "harness.remote.v1", "harness.remote.transfer.v1", "fileviewer.read.v1", "codex.appserver.v1", "codex.appserver.transfer.v1", "agent.acp.v1"];
|
|
11
|
-
export declare class RpcRouter {
|
|
12
|
-
private readonly harnessApi;
|
|
13
|
-
private readonly maxPending;
|
|
14
|
-
private readonly logger?;
|
|
15
|
-
private readonly fileViewer?;
|
|
16
|
-
private readonly harnessRemote?;
|
|
17
|
-
private readonly capabilities;
|
|
18
|
-
private readonly codex?;
|
|
19
|
-
private readonly acp?;
|
|
20
|
-
private readonly loopback?;
|
|
21
|
-
private active;
|
|
22
|
-
constructor(harnessApi: HarnessApiBridge | undefined, maxPending?: number, logger?: SafeLogger | undefined, fileViewer?: RemoteFileViewerBridge | undefined, harnessRemote?: HarnessRemoteBridge | undefined, capabilities?: () => readonly string[], codex?: CodexPeerBridge | undefined, acp?: AcpGateway | undefined, loopback?: LoopbackHost | undefined);
|
|
23
|
-
closePeerStreams(): Promise<void>;
|
|
24
|
-
handle(message: RemoteMessage): Promise<RemoteMessage>;
|
|
25
|
-
private invoke;
|
|
26
|
-
private requireApiProxy;
|
|
27
|
-
private requireRemoteGateway;
|
|
28
|
-
private requireAcp;
|
|
29
|
-
private requireCodex;
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=rpc-router.d.ts.map
|
package/dist/rpc-router.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-router.d.ts","sourceRoot":"","sources":["../src/rpc-router.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,aAAa,EAGnB,MAAM,sBAAsB,CAAA;AAE7B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AACrE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAE7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE1C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAsC1C,eAAO,MAAM,iBAAiB,sMASpB,CAAA;AAEV,qBAAa,SAAS;IAIlB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;IACxB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC;IAC5B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC;IAC/B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC;IACvB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;IACrB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAX5B,OAAO,CAAC,MAAM,CAAI;gBAGC,UAAU,EAAE,gBAAgB,GAAG,SAAS,EACxC,UAAU,SAAM,EAChB,MAAM,CAAC,EAAE,UAAU,YAAA,EACnB,UAAU,CAAC,EAAE,sBAAsB,YAAA,EACnC,aAAa,CAAC,EAAE,mBAAmB,YAAA,EACnC,YAAY,GAAE,MAAM,SAAS,MAAM,EAA4B,EAC/D,KAAK,CAAC,EAAE,eAAe,YAAA,EACvB,GAAG,CAAC,EAAE,UAAU,YAAA,EAChB,QAAQ,CAAC,EAAE,YAAY,YAAA;IAGpC,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IASjC,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IAoC5D,OAAO,CAAC,MAAM;IAqDd,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,oBAAoB;IAO5B,OAAO,CAAC,UAAU;IAKlB,OAAO,CAAC,YAAY;CAMrB"}
|
package/dist/rpc-router.js
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import { createRpcError, createRpcResponse, } from '@dsh-remote/protocol';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { RpcError, safeErrorCode } from './safe-error.js';
|
|
4
|
-
export { RpcError } from './safe-error.js';
|
|
5
|
-
const wireRequestSchema = z.object({ method: z.string().min(1), params: z.unknown() }).strict();
|
|
6
|
-
const emptyParamsSchema = z.object({}).strict();
|
|
7
|
-
const apiMethods = new Set([
|
|
8
|
-
'harness.transport.describe',
|
|
9
|
-
'harness.api.call',
|
|
10
|
-
'harness.api.transfer.open',
|
|
11
|
-
'harness.api.transfer.chunk',
|
|
12
|
-
'harness.api.transfer.commit',
|
|
13
|
-
'harness.api.transfer.read',
|
|
14
|
-
'harness.api.transfer.close',
|
|
15
|
-
'harness.api.respond',
|
|
16
|
-
'harness.api.stream.open',
|
|
17
|
-
'harness.api.stream.close',
|
|
18
|
-
'harness.remote.call',
|
|
19
|
-
'harness.remote.transfer.open',
|
|
20
|
-
'harness.remote.transfer.chunk',
|
|
21
|
-
'harness.remote.transfer.commit',
|
|
22
|
-
'harness.remote.transfer.read',
|
|
23
|
-
'harness.remote.transfer.close',
|
|
24
|
-
'harness.remote.stream.open',
|
|
25
|
-
'harness.remote.stream.close',
|
|
26
|
-
'loopback.call',
|
|
27
|
-
'fileviewer.call',
|
|
28
|
-
'codex.app.call',
|
|
29
|
-
'codex.app.respond',
|
|
30
|
-
'codex.app.stream.open',
|
|
31
|
-
'codex.app.stream.close',
|
|
32
|
-
'codex.app.transfer.open',
|
|
33
|
-
'codex.app.transfer.chunk',
|
|
34
|
-
'codex.app.transfer.commit',
|
|
35
|
-
'codex.app.transfer.read',
|
|
36
|
-
'codex.app.transfer.close',
|
|
37
|
-
'acp.initialize', 'acp.session.new', 'acp.session.load', 'acp.session.prompt',
|
|
38
|
-
'acp.session.respond_permission', 'acp.session.cancel', 'acp.session.set_mode',
|
|
39
|
-
]);
|
|
40
|
-
export const HOST_CAPABILITIES = [
|
|
41
|
-
'harness.api.v1',
|
|
42
|
-
'harness.api.transfer.v1',
|
|
43
|
-
'harness.remote.v1',
|
|
44
|
-
'harness.remote.transfer.v1',
|
|
45
|
-
'fileviewer.read.v1',
|
|
46
|
-
'codex.appserver.v1',
|
|
47
|
-
'codex.appserver.transfer.v1',
|
|
48
|
-
'agent.acp.v1',
|
|
49
|
-
];
|
|
50
|
-
export class RpcRouter {
|
|
51
|
-
harnessApi;
|
|
52
|
-
maxPending;
|
|
53
|
-
logger;
|
|
54
|
-
fileViewer;
|
|
55
|
-
harnessRemote;
|
|
56
|
-
capabilities;
|
|
57
|
-
codex;
|
|
58
|
-
acp;
|
|
59
|
-
loopback;
|
|
60
|
-
active = 0;
|
|
61
|
-
constructor(harnessApi, maxPending = 128, logger, fileViewer, harnessRemote, capabilities = () => HOST_CAPABILITIES, codex, acp, loopback) {
|
|
62
|
-
this.harnessApi = harnessApi;
|
|
63
|
-
this.maxPending = maxPending;
|
|
64
|
-
this.logger = logger;
|
|
65
|
-
this.fileViewer = fileViewer;
|
|
66
|
-
this.harnessRemote = harnessRemote;
|
|
67
|
-
this.capabilities = capabilities;
|
|
68
|
-
this.codex = codex;
|
|
69
|
-
this.acp = acp;
|
|
70
|
-
this.loopback = loopback;
|
|
71
|
-
}
|
|
72
|
-
async closePeerStreams() {
|
|
73
|
-
this.loopback?.closeAll();
|
|
74
|
-
await Promise.all([
|
|
75
|
-
this.harnessApi?.closeAll(),
|
|
76
|
-
this.harnessRemote?.closeAll(),
|
|
77
|
-
this.codex?.closeAll(),
|
|
78
|
-
]);
|
|
79
|
-
}
|
|
80
|
-
async handle(message) {
|
|
81
|
-
if (message.type !== 'rpc.request') {
|
|
82
|
-
return createRpcError(message.id, 'INVALID_MESSAGE', 'Only RPC requests are accepted on the Host business channel.');
|
|
83
|
-
}
|
|
84
|
-
const parsedPayload = wireRequestSchema.safeParse(message.payload);
|
|
85
|
-
if (!parsedPayload.success)
|
|
86
|
-
return createRpcError(message.id, 'INVALID_MESSAGE', 'The RPC request payload is invalid.');
|
|
87
|
-
if (!apiMethods.has(parsedPayload.data.method)) {
|
|
88
|
-
return createRpcError(message.id, 'METHOD_NOT_FOUND', 'The requested method does not exist.');
|
|
89
|
-
}
|
|
90
|
-
const request = message;
|
|
91
|
-
if (this.active >= this.maxPending) {
|
|
92
|
-
return createRpcError(request.id, 'RATE_LIMITED', 'Too many Host requests are already pending.', undefined, true);
|
|
93
|
-
}
|
|
94
|
-
this.active += 1;
|
|
95
|
-
const startedAt = performance.now();
|
|
96
|
-
try {
|
|
97
|
-
const result = await this.invoke(request.payload.method, request.payload.params);
|
|
98
|
-
this.logger?.debug('host rpc ok', {
|
|
99
|
-
method: request.payload.method,
|
|
100
|
-
durationMs: Math.round(performance.now() - startedAt),
|
|
101
|
-
});
|
|
102
|
-
return createRpcResponse(request.id, result);
|
|
103
|
-
}
|
|
104
|
-
catch (error) {
|
|
105
|
-
const response = errorResponse(request.id, error);
|
|
106
|
-
this.logger?.warn('host rpc failed', {
|
|
107
|
-
method: request.payload.method,
|
|
108
|
-
durationMs: Math.round(performance.now() - startedAt),
|
|
109
|
-
code: response.payload.code,
|
|
110
|
-
retryable: response.payload.retryable,
|
|
111
|
-
});
|
|
112
|
-
return response;
|
|
113
|
-
}
|
|
114
|
-
finally {
|
|
115
|
-
this.active -= 1;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
invoke(method, params) {
|
|
119
|
-
switch (method) {
|
|
120
|
-
case 'harness.transport.describe': {
|
|
121
|
-
emptyParamsSchema.parse(params);
|
|
122
|
-
return { capabilities: [...this.capabilities()] };
|
|
123
|
-
}
|
|
124
|
-
case 'harness.api.call': return this.requireApiProxy().call(params);
|
|
125
|
-
case 'harness.api.transfer.open': return this.requireApiProxy().openTransfer(params);
|
|
126
|
-
case 'harness.api.transfer.chunk': return this.requireApiProxy().appendTransfer(params);
|
|
127
|
-
case 'harness.api.transfer.commit': return this.requireApiProxy().commitTransfer(params);
|
|
128
|
-
case 'harness.api.transfer.read': return this.requireApiProxy().readTransfer(params);
|
|
129
|
-
case 'harness.api.transfer.close': return this.requireApiProxy().closeTransfer(params);
|
|
130
|
-
case 'harness.api.respond': return this.requireApiProxy().respond(params);
|
|
131
|
-
case 'harness.api.stream.open': return this.requireApiProxy().openStream(params);
|
|
132
|
-
case 'harness.api.stream.close': return this.requireApiProxy().closeStream(params);
|
|
133
|
-
case 'harness.remote.call': return this.requireRemoteGateway().call(params);
|
|
134
|
-
case 'harness.remote.transfer.open': return this.requireRemoteGateway().openTransfer(params);
|
|
135
|
-
case 'harness.remote.transfer.chunk': return this.requireRemoteGateway().appendTransfer(params);
|
|
136
|
-
case 'harness.remote.transfer.commit': return this.requireRemoteGateway().commitTransfer(params);
|
|
137
|
-
case 'harness.remote.transfer.read': return this.requireRemoteGateway().readTransfer(params);
|
|
138
|
-
case 'harness.remote.transfer.close': return this.requireRemoteGateway().closeTransfer(params);
|
|
139
|
-
case 'harness.remote.stream.open': return this.requireRemoteGateway().openStream(params);
|
|
140
|
-
case 'harness.remote.stream.close': return this.requireRemoteGateway().closeStream(params);
|
|
141
|
-
case 'loopback.call': {
|
|
142
|
-
if (this.loopback === undefined)
|
|
143
|
-
throw new RpcError('FEATURE_NOT_SUPPORTED', 'Loopback preview is unavailable on this Host.');
|
|
144
|
-
return this.loopback.call(params);
|
|
145
|
-
}
|
|
146
|
-
case 'fileviewer.call': {
|
|
147
|
-
if (this.fileViewer === undefined) {
|
|
148
|
-
throw new RpcError('FILE_VIEWER_UNAVAILABLE', 'The Remote Host does not have DSH File Viewer available.');
|
|
149
|
-
}
|
|
150
|
-
return this.fileViewer.call(params);
|
|
151
|
-
}
|
|
152
|
-
case 'codex.app.call': return this.requireCodex().call(params);
|
|
153
|
-
case 'codex.app.respond': return this.requireCodex().respond(params);
|
|
154
|
-
case 'codex.app.stream.open': return this.requireCodex().openStream(params);
|
|
155
|
-
case 'codex.app.stream.close': return this.requireCodex().closeStream(params);
|
|
156
|
-
case 'codex.app.transfer.open': return this.requireCodex().openTransfer(params);
|
|
157
|
-
case 'codex.app.transfer.chunk': return this.requireCodex().appendTransfer(params);
|
|
158
|
-
case 'codex.app.transfer.commit': return this.requireCodex().commitTransfer(params);
|
|
159
|
-
case 'codex.app.transfer.read': return this.requireCodex().readTransfer(params);
|
|
160
|
-
case 'codex.app.transfer.close': return this.requireCodex().closeTransfer(params);
|
|
161
|
-
case 'acp.initialize': return this.requireAcp().initialize(params);
|
|
162
|
-
case 'acp.session.new': return this.requireAcp().sessionNew(params);
|
|
163
|
-
case 'acp.session.load': return this.requireAcp().sessionLoad(params);
|
|
164
|
-
case 'acp.session.prompt': return this.requireAcp().prompt(params, async () => undefined);
|
|
165
|
-
case 'acp.session.respond_permission': return this.requireAcp().respondPermission(params);
|
|
166
|
-
case 'acp.session.cancel': return this.requireAcp().cancel(params);
|
|
167
|
-
case 'acp.session.set_mode': return this.requireAcp().setMode(params);
|
|
168
|
-
default: throw new RpcError('METHOD_NOT_FOUND', 'The requested method does not exist.');
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
requireApiProxy() {
|
|
172
|
-
if (this.harnessApi === undefined) {
|
|
173
|
-
throw new RpcError('FEATURE_NOT_SUPPORTED', 'This Harness version does not provide the legacy ApiProxy transport.');
|
|
174
|
-
}
|
|
175
|
-
return this.harnessApi;
|
|
176
|
-
}
|
|
177
|
-
requireRemoteGateway() {
|
|
178
|
-
if (this.harnessRemote === undefined) {
|
|
179
|
-
throw new RpcError('FEATURE_NOT_SUPPORTED', 'This Harness version does not provide the Remote Gateway transport.');
|
|
180
|
-
}
|
|
181
|
-
return this.harnessRemote;
|
|
182
|
-
}
|
|
183
|
-
requireAcp() {
|
|
184
|
-
if (!this.acp)
|
|
185
|
-
throw new RpcError('CAPABILITY_NOT_SUPPORTED', 'ACP is not configured on this Host.');
|
|
186
|
-
return this.acp;
|
|
187
|
-
}
|
|
188
|
-
requireCodex() {
|
|
189
|
-
if (this.codex === undefined) {
|
|
190
|
-
throw new RpcError('FEATURE_NOT_SUPPORTED', 'Codex Remote is disabled or unavailable on this Host.');
|
|
191
|
-
}
|
|
192
|
-
return this.codex;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
function errorResponse(requestId, error) {
|
|
196
|
-
const code = safeErrorCode(error);
|
|
197
|
-
if (error instanceof RpcError)
|
|
198
|
-
return createRpcError(requestId, code, error.message, error.details, error.retryable);
|
|
199
|
-
return createRpcError(requestId, code, code === 'INVALID_MESSAGE' ? 'The RPC parameters are invalid.' : 'The Host could not complete the request.');
|
|
200
|
-
}
|
|
201
|
-
//# sourceMappingURL=rpc-router.js.map
|
package/dist/rpc-router.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-router.js","sourceRoot":"","sources":["../src/rpc-router.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,iBAAiB,GAIlB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAOvB,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAGzD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAE1C,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAA;AAC/F,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAA;AAC/C,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC;IACzB,4BAA4B;IAC5B,kBAAkB;IAClB,2BAA2B;IAC3B,4BAA4B;IAC5B,6BAA6B;IAC7B,2BAA2B;IAC3B,4BAA4B;IAC5B,qBAAqB;IACrB,yBAAyB;IACzB,0BAA0B;IAC1B,qBAAqB;IACrB,8BAA8B;IAC9B,+BAA+B;IAC/B,gCAAgC;IAChC,8BAA8B;IAC9B,+BAA+B;IAC/B,4BAA4B;IAC5B,6BAA6B;IAC7B,eAAe;IACf,iBAAiB;IACjB,gBAAgB;IAChB,mBAAmB;IACnB,uBAAuB;I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,IAAI,CAAC,UAAU,CAAA;IACxB,CAAC;IAEO,oBAAoB;QAC1B,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;YACrC,MAAM,IAAI,QAAQ,CAAC,uBAAuB,EAAE,qEAAqE,CAAC,CAAA;QACpH,CAAC;QACD,OAAO,IAAI,CAAC,aAAa,CAAA;IAC3B,CAAC;IAEO,UAAU;QAChB,IAAI,CAAC,IAAI,CAAC,GAAG;YAAE,MAAM,IAAI,QAAQ,CAAC,0BAA0B,EAAE,qCAAqC,CAAC,CAAA;QACpG,OAAO,IAAI,CAAC,GAAG,CAAA;IACjB,CAAC;IAEO,YAAY;QAClB,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAC7B,MAAM,IAAI,QAAQ,CAAC,uBAAuB,EAAE,uDAAuD,CAAC,CAAA;QACtG,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;CACF;AAED,SAAS,aAAa,CAAC,SAAiB,EAAE,KAAc;IACtD,MAAM,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,CAAA;IACjC,IAAI,KAAK,YAAY,QAAQ;QAAE,OAAO,cAAc,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,CAAA;IACpH,OAAO,cAAc,CACnB,SAAS,EACT,IAAI,EACJ,IAAI,KAAK,iBAAiB,CAAC,CAAC,CAAC,iCAAiC,CAAC,CAAC,CAAC,0CAA0C,CAC5G,CAAA;AACH,CAAC"}
|
package/dist/safe-error.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare class RpcError extends Error {
|
|
2
|
-
readonly code: string;
|
|
3
|
-
readonly details?: unknown | undefined;
|
|
4
|
-
readonly retryable: boolean;
|
|
5
|
-
constructor(code: string, message: string, details?: unknown | undefined, retryable?: boolean);
|
|
6
|
-
}
|
|
7
|
-
export declare function safeErrorCode(error: unknown): string;
|
|
8
|
-
//# sourceMappingURL=safe-error.d.ts.map
|
package/dist/safe-error.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"safe-error.d.ts","sourceRoot":"","sources":["../src/safe-error.ts"],"names":[],"mappings":"AAEA,qBAAa,QAAS,SAAQ,KAAK;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM;IAAmB,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO;IAAE,QAAQ,CAAC,SAAS;gBAA7E,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAW,OAAO,CAAC,EAAE,OAAO,YAAA,EAAW,SAAS,UAAQ;CAC3G;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAIpD"}
|
package/dist/safe-error.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export class RpcError extends Error {
|
|
3
|
-
code;
|
|
4
|
-
details;
|
|
5
|
-
retryable;
|
|
6
|
-
constructor(code, message, details, retryable = false) {
|
|
7
|
-
super(message);
|
|
8
|
-
this.code = code;
|
|
9
|
-
this.details = details;
|
|
10
|
-
this.retryable = retryable;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
export function safeErrorCode(error) {
|
|
14
|
-
if (error instanceof RpcError)
|
|
15
|
-
return error.code;
|
|
16
|
-
if (error instanceof z.ZodError)
|
|
17
|
-
return 'INVALID_MESSAGE';
|
|
18
|
-
return 'INTERNAL_ERROR';
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=safe-error.js.map
|
package/dist/safe-error.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"safe-error.js","sourceRoot":"","sources":["../src/safe-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,OAAO,QAAS,SAAQ,KAAK;IACZ;IAAwC;IAA4B;IAAzF,YAAqB,IAAY,EAAE,OAAe,EAAW,OAAiB,EAAW,YAAY,KAAK;QAAI,KAAK,CAAC,OAAO,CAAC,CAAA;QAAvG,SAAI,GAAJ,IAAI,CAAQ;QAA4B,YAAO,GAAP,OAAO,CAAU;QAAW,cAAS,GAAT,SAAS,CAAQ;IAAmB,CAAC;CAC/H;AAED,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,IAAI,KAAK,YAAY,QAAQ;QAAE,OAAO,KAAK,CAAC,IAAI,CAAA;IAChD,IAAI,KAAK,YAAY,CAAC,CAAC,QAAQ;QAAE,OAAO,iBAAiB,CAAA;IACzD,OAAO,gBAAgB,CAAA;AACzB,CAAC"}
|
package/dist/server-api.d.ts
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import type { RtcIceServer } from '@dsh-remote/webrtc';
|
|
2
|
-
import type { HostIdentity } from './identity-store.js';
|
|
3
|
-
import { type ServerCredentialStore, type ServerCredentials } from './server-credentials.js';
|
|
4
|
-
export interface OAuthQrSession {
|
|
5
|
-
qrId: string;
|
|
6
|
-
scanUrl: string;
|
|
7
|
-
expiresIn: number;
|
|
8
|
-
}
|
|
9
|
-
export type OAuthProvider = 'wechat' | 'zhihu' | 'github';
|
|
10
|
-
/**
|
|
11
|
-
* QR-login providers this build offers. The self-hosted server implements
|
|
12
|
-
* WeChat; Zhihu and GitHub remain implemented for the hosted server but are not
|
|
13
|
-
* offered here. This is the one place to enable or retire a provider.
|
|
14
|
-
*/
|
|
15
|
-
export declare const ENABLED_QR_PROVIDERS: readonly OAuthProvider[];
|
|
16
|
-
/**
|
|
17
|
-
* Whether a caller-supplied string names an offered provider. Narrows the value
|
|
18
|
-
* so downstream calls receive a validated `OAuthProvider` rather than `string`.
|
|
19
|
-
*/
|
|
20
|
-
export declare function isEnabledQrProvider(value: string): value is OAuthProvider;
|
|
21
|
-
/** Human-readable provider name for diagnostics and prompts. */
|
|
22
|
-
export declare function oauthProviderName(provider: OAuthProvider): string;
|
|
23
|
-
export type OAuthQrPollResult = {
|
|
24
|
-
status: 'pending' | 'expired';
|
|
25
|
-
} | {
|
|
26
|
-
status: 'complete';
|
|
27
|
-
authorization: DeviceAuthorization;
|
|
28
|
-
};
|
|
29
|
-
export interface DeviceAuthorization {
|
|
30
|
-
method: 'account' | 'host_registration_code' | 'owned_device';
|
|
31
|
-
account?: string;
|
|
32
|
-
expiresAt?: number;
|
|
33
|
-
isAdmin?: boolean;
|
|
34
|
-
}
|
|
35
|
-
export type FetchImplementation = typeof fetch;
|
|
36
|
-
export interface ServerHostDevice {
|
|
37
|
-
deviceId: string;
|
|
38
|
-
name: string;
|
|
39
|
-
platform: string;
|
|
40
|
-
membershipId: string;
|
|
41
|
-
online?: boolean;
|
|
42
|
-
lastSeenAt?: number;
|
|
43
|
-
clientVersion?: string;
|
|
44
|
-
harnessVersion?: string;
|
|
45
|
-
}
|
|
46
|
-
export interface AuthorizedPeerDevice extends ServerHostDevice {
|
|
47
|
-
role: 'host' | 'client';
|
|
48
|
-
identityKey: string;
|
|
49
|
-
}
|
|
50
|
-
export declare class HostServerApi {
|
|
51
|
-
private readonly store;
|
|
52
|
-
private readonly fetchImplementation;
|
|
53
|
-
private readonly role;
|
|
54
|
-
readonly baseUrl: string;
|
|
55
|
-
private identity?;
|
|
56
|
-
private credentials?;
|
|
57
|
-
private credentialsPromise?;
|
|
58
|
-
private harnessVersion?;
|
|
59
|
-
constructor(serverUrl: string, store: ServerCredentialStore, fetchImplementation?: FetchImplementation, role?: 'host' | 'client');
|
|
60
|
-
bindIdentity(identity: HostIdentity): void;
|
|
61
|
-
setHarnessVersion(version: string | undefined): void;
|
|
62
|
-
currentAuthorization(): DeviceAuthorization | undefined;
|
|
63
|
-
/** Check the persisted device credential without issuing or refreshing one. */
|
|
64
|
-
hasStoredAuthorization(): Promise<boolean>;
|
|
65
|
-
clearAuthorization(): Promise<void>;
|
|
66
|
-
revokeCurrentDevice(): Promise<void>;
|
|
67
|
-
authorizeWithAccount(identity: HostIdentity, email: string, password: string): Promise<DeviceAuthorization>;
|
|
68
|
-
/**
|
|
69
|
-
* Authorize this device with the DSH DeepSeek account grant.
|
|
70
|
-
*
|
|
71
|
-
* The grant is forwarded once so the Server can ask the account platform who
|
|
72
|
-
* it belongs to; the Server then discards it and issues its own account
|
|
73
|
-
* session, exactly like a password sign-in.
|
|
74
|
-
*/
|
|
75
|
-
authorizeWithDeepSeek(identity: HostIdentity, token: string): Promise<DeviceAuthorization>;
|
|
76
|
-
startOAuthQrLogin(provider?: OAuthProvider): Promise<OAuthQrSession>;
|
|
77
|
-
pollOAuthQrLogin(identity: HostIdentity, qrId: string, recoverIdentity?: () => Promise<HostIdentity>): Promise<OAuthQrPollResult>;
|
|
78
|
-
authorizeHostWithCode(identity: HostIdentity, code: string): Promise<DeviceAuthorization>;
|
|
79
|
-
authorizeOwnedRole(identity: HostIdentity, authorizingAccessToken: string, account?: string): Promise<DeviceAuthorization>;
|
|
80
|
-
authenticate(identity?: HostIdentity): Promise<ServerCredentials>;
|
|
81
|
-
refreshCredentials(rejectedAccessToken?: string | undefined): Promise<ServerCredentials>;
|
|
82
|
-
private withRefreshLock;
|
|
83
|
-
private rotateCredentials;
|
|
84
|
-
listDevices(): Promise<ServerHostDevice[]>;
|
|
85
|
-
deviceFor(peerDeviceId: string): Promise<AuthorizedPeerDevice>;
|
|
86
|
-
turnCredentials(connectionId: string): Promise<RtcIceServer[]>;
|
|
87
|
-
presenceFor(deviceId: string): Promise<{
|
|
88
|
-
online: boolean;
|
|
89
|
-
lastSeenAt?: number;
|
|
90
|
-
}>;
|
|
91
|
-
private loadOrIssue;
|
|
92
|
-
private register;
|
|
93
|
-
private deviceDescriptor;
|
|
94
|
-
private saveTokens;
|
|
95
|
-
private request;
|
|
96
|
-
private publicRequest;
|
|
97
|
-
private requireIdentity;
|
|
98
|
-
}
|
|
99
|
-
export declare class ClientServerApi extends HostServerApi {
|
|
100
|
-
constructor(serverUrl: string, store: ServerCredentialStore, fetchImplementation?: FetchImplementation);
|
|
101
|
-
}
|
|
102
|
-
export declare class ServerApiError extends Error {
|
|
103
|
-
readonly code: string;
|
|
104
|
-
readonly retryable: boolean;
|
|
105
|
-
readonly status?: number | undefined;
|
|
106
|
-
readonly phase?: "credential_refresh" | undefined;
|
|
107
|
-
constructor(code: string, message: string, retryable: boolean, status?: number | undefined, phase?: "credential_refresh" | undefined);
|
|
108
|
-
}
|
|
109
|
-
//# sourceMappingURL=server-api.d.ts.map
|
package/dist/server-api.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server-api.d.ts","sourceRoot":"","sources":["../src/server-api.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAA8B,KAAK,qBAAqB,EAAE,KAAK,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAiBxH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAA;AAEzD;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,EAAE,SAAS,aAAa,EAAe,CAAA;AAExE;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,aAAa,CAEzE;AAED,gEAAgE;AAChE,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,CAEjE;AAED,MAAM,MAAM,iBAAiB,GACzB;IAAE,MAAM,EAAE,SAAS,GAAG,SAAS,CAAA;CAAE,GACjC;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,aAAa,EAAE,mBAAmB,CAAA;CAAE,CAAA;AAE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