dsh-browser-firefox 0.4.8 → 0.5.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/README.md +2 -0
- package/cordis.patch.yml +0 -0
- package/lib/index.js +45 -2
- package/lib/protocol.js +0 -0
- package/lib/types/approvals.d.ts +0 -0
- package/lib/types/extension-sessions.d.ts +0 -0
- package/lib/types/gateway-peer.d.ts +27 -0
- package/lib/types/index.d.ts +0 -0
- package/lib/types/protocol.d.ts +0 -0
- package/lib/types/questions.d.ts +0 -0
- package/lib/types/server.d.ts +0 -0
- package/lib/types/session-deferral.d.ts +0 -0
- package/lib/types/session-follow.d.ts +0 -0
- package/lib/types/session-workspace.d.ts +0 -0
- package/lib/types/token.d.ts +0 -0
- package/lib/types/tools.d.ts +0 -0
- package/lib/types/waterfall.d.ts +0 -0
- package/package.json +28 -35
- package/src/approvals.ts +0 -0
- package/src/extension-sessions.ts +0 -0
- package/src/gateway-peer.ts +46 -0
- package/src/index.ts +6 -2
- package/src/protocol.ts +0 -0
- package/src/questions.ts +0 -0
- package/src/server.ts +0 -0
- package/src/session-deferral.ts +0 -0
- package/src/session-follow.ts +0 -0
- package/src/session-workspace.ts +0 -0
- package/src/token.ts +0 -0
- package/src/tools.ts +0 -0
- package/src/waterfall.ts +0 -0
- package/lib/invariant.js +0 -26
- package/lib/types/events.d.ts +0 -59
- package/lib/types/gateway.d.ts +0 -87
- package/lib/types/invariant.d.ts +0 -16
- package/src/invariant.ts +0 -33
package/README.md
CHANGED
package/cordis.patch.yml
CHANGED
|
File without changes
|
package/lib/index.js
CHANGED
|
@@ -1293,6 +1293,46 @@ function withSessionWorkspace(dispatch, workspacePath, warn) {
|
|
|
1293
1293
|
};
|
|
1294
1294
|
}
|
|
1295
1295
|
//#endregion
|
|
1296
|
+
//#region lib/types/gateway-peer.js
|
|
1297
|
+
/**
|
|
1298
|
+
* In-process owner Peer for Typert Remote dispatch.
|
|
1299
|
+
*
|
|
1300
|
+
* dsh 0.2.1 requires every `typertGateway.invoke` / `stream` request to name a
|
|
1301
|
+
* live {@link PeerScope}: the Gateway reads `peer.signal` and `peer.principal`
|
|
1302
|
+
* without a fallback, because the 0.2.0 operator-peer default is gone. The
|
|
1303
|
+
* bridge mounts its own token-authenticated carrier, so it speaks as the host
|
|
1304
|
+
* owner; the Peer lives exactly as long as the plugin fiber.
|
|
1305
|
+
*
|
|
1306
|
+
* @module
|
|
1307
|
+
*/
|
|
1308
|
+
/**
|
|
1309
|
+
* Create the bridge's owner Peer and tie its lifetime to the calling fiber.
|
|
1310
|
+
*
|
|
1311
|
+
* The returned scope is structurally a full `PeerScope`; the Gateway only
|
|
1312
|
+
* needs `id`, `principal`, `signal`, and `interactions` for unary calls and
|
|
1313
|
+
* streams, while `ctx` keeps a future event-stream registration fiber-scoped.
|
|
1314
|
+
*
|
|
1315
|
+
* @param ctx - plugin context whose disposal aborts the peer.
|
|
1316
|
+
* @returns a live owner Peer that is aborted when the plugin unloads.
|
|
1317
|
+
*/
|
|
1318
|
+
function createGatewayPeer(ctx) {
|
|
1319
|
+
const lifetime = new AbortController();
|
|
1320
|
+
const dispose = async () => {
|
|
1321
|
+
if (!lifetime.signal.aborted) lifetime.abort(/* @__PURE__ */ new Error("bridge-browser: gateway peer disposed"));
|
|
1322
|
+
};
|
|
1323
|
+
ctx.effect(() => () => {
|
|
1324
|
+
dispose();
|
|
1325
|
+
}, "bridge-browser: gateway peer");
|
|
1326
|
+
return {
|
|
1327
|
+
id: randomUUID(),
|
|
1328
|
+
ctx,
|
|
1329
|
+
principal: { kind: "owner" },
|
|
1330
|
+
signal: lifetime.signal,
|
|
1331
|
+
interactions: "none",
|
|
1332
|
+
dispose
|
|
1333
|
+
};
|
|
1334
|
+
}
|
|
1335
|
+
//#endregion
|
|
1296
1336
|
//#region lib/types/extension-sessions.js
|
|
1297
1337
|
/**
|
|
1298
1338
|
* Track session ids that the browser extension has driven through the bridge.
|
|
@@ -1857,6 +1897,7 @@ function resolveConfig(config) {
|
|
|
1857
1897
|
async function apply(ctx, config) {
|
|
1858
1898
|
const resolved = resolveConfig(config);
|
|
1859
1899
|
const tokenRes = await resolveToken(resolved.token);
|
|
1900
|
+
const peer = createGatewayPeer(ctx);
|
|
1860
1901
|
const invoke = async (method, args, signal) => {
|
|
1861
1902
|
const slash = method.indexOf("/");
|
|
1862
1903
|
const namespace = slash === -1 ? method : method.slice(0, slash);
|
|
@@ -1868,7 +1909,8 @@ async function apply(ctx, config) {
|
|
|
1868
1909
|
namespace,
|
|
1869
1910
|
method: remoteMethod,
|
|
1870
1911
|
args,
|
|
1871
|
-
signal
|
|
1912
|
+
signal,
|
|
1913
|
+
peer
|
|
1872
1914
|
})
|
|
1873
1915
|
};
|
|
1874
1916
|
} catch (error) {
|
|
@@ -1927,7 +1969,8 @@ async function apply(ctx, config) {
|
|
|
1927
1969
|
namespace,
|
|
1928
1970
|
method: remoteMethod,
|
|
1929
1971
|
args,
|
|
1930
|
-
signal
|
|
1972
|
+
signal,
|
|
1973
|
+
peer
|
|
1931
1974
|
});
|
|
1932
1975
|
},
|
|
1933
1976
|
answerQuestion: (args) => {
|
package/lib/protocol.js
CHANGED
|
File without changes
|
package/lib/types/approvals.d.ts
CHANGED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-process owner Peer for Typert Remote dispatch.
|
|
3
|
+
*
|
|
4
|
+
* dsh 0.2.1 requires every `typertGateway.invoke` / `stream` request to name a
|
|
5
|
+
* live {@link PeerScope}: the Gateway reads `peer.signal` and `peer.principal`
|
|
6
|
+
* without a fallback, because the 0.2.0 operator-peer default is gone. The
|
|
7
|
+
* bridge mounts its own token-authenticated carrier, so it speaks as the host
|
|
8
|
+
* owner; the Peer lives exactly as long as the plugin fiber.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
13
|
+
import type { InvokeRemoteRequest } from '@deepseek-ai/dsh-api-gateway/types';
|
|
14
|
+
/** The Peer a Gateway request must name (required since dsh 0.2.1). */
|
|
15
|
+
export type GatewayPeer = InvokeRemoteRequest['peer'];
|
|
16
|
+
/**
|
|
17
|
+
* Create the bridge's owner Peer and tie its lifetime to the calling fiber.
|
|
18
|
+
*
|
|
19
|
+
* The returned scope is structurally a full `PeerScope`; the Gateway only
|
|
20
|
+
* needs `id`, `principal`, `signal`, and `interactions` for unary calls and
|
|
21
|
+
* streams, while `ctx` keeps a future event-stream registration fiber-scoped.
|
|
22
|
+
*
|
|
23
|
+
* @param ctx - plugin context whose disposal aborts the peer.
|
|
24
|
+
* @returns a live owner Peer that is aborted when the plugin unloads.
|
|
25
|
+
*/
|
|
26
|
+
export declare function createGatewayPeer(ctx: Context): GatewayPeer;
|
|
27
|
+
//# sourceMappingURL=gateway-peer.d.ts.map
|
package/lib/types/index.d.ts
CHANGED
|
File without changes
|
package/lib/types/protocol.d.ts
CHANGED
|
File without changes
|
package/lib/types/questions.d.ts
CHANGED
|
File without changes
|
package/lib/types/server.d.ts
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/lib/types/token.d.ts
CHANGED
|
File without changes
|
package/lib/types/tools.d.ts
CHANGED
|
File without changes
|
package/lib/types/waterfall.d.ts
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-browser-firefox",
|
|
3
3
|
"description": "Firefox browser control for DeepSeek Harness: token-authenticated WebSocket bridge + browser_* tools (native-image screenshots) driving the user's own Firefox via the companion AMO extension, with sidebar ask_user_question answering",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.5.0",
|
|
5
5
|
"author": "tuojc",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -35,38 +35,32 @@
|
|
|
35
35
|
"types": "./lib/types/protocol.d.ts",
|
|
36
36
|
"default": "./lib/protocol.js"
|
|
37
37
|
},
|
|
38
|
-
"./invariant": {
|
|
39
|
-
"types": "./lib/types/invariant.d.ts",
|
|
40
|
-
"default": "./lib/invariant.js"
|
|
41
|
-
},
|
|
42
38
|
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
43
39
|
"./src/*": "./src/*",
|
|
44
40
|
"./package.json": "./package.json"
|
|
45
41
|
},
|
|
46
42
|
"files": [
|
|
47
43
|
"lib/index.js",
|
|
48
|
-
"lib/invariant.js",
|
|
49
44
|
"lib/protocol.js",
|
|
50
45
|
"lib/types/**/*.d.ts",
|
|
51
46
|
"cordis.patch.yml",
|
|
52
47
|
"src"
|
|
53
48
|
],
|
|
54
49
|
"peerDependencies": {
|
|
55
|
-
"@deepseek-ai/cordis": "^4.0.
|
|
56
|
-
"@deepseek-ai/dsh-api-gateway": "^0.2.
|
|
57
|
-
"@deepseek-ai/dsh-api-session-controller": "^0.2.
|
|
58
|
-
"@deepseek-ai/dsh-api-workspace-controller": "^0.2.
|
|
59
|
-
"@deepseek-ai/dsh-attachment": "^0.2.
|
|
60
|
-
"@deepseek-ai/dsh-home-paths": "^0.2.
|
|
61
|
-
"@deepseek-ai/dsh-host-webserver": "^0.2.
|
|
62
|
-
"@deepseek-ai/dsh-
|
|
63
|
-
"@deepseek-ai/dsh-
|
|
64
|
-
"@deepseek-ai/dsh-
|
|
65
|
-
"@deepseek-ai/dsh-user-
|
|
66
|
-
"@deepseek-ai/dsh-user-questions": "^0.2.0-rc.1"
|
|
50
|
+
"@deepseek-ai/cordis": "^4.0.5",
|
|
51
|
+
"@deepseek-ai/dsh-api-gateway": "^0.2.1-rc.5",
|
|
52
|
+
"@deepseek-ai/dsh-api-session-controller": "^0.2.1-rc.5",
|
|
53
|
+
"@deepseek-ai/dsh-api-workspace-controller": "^0.2.1-rc.5",
|
|
54
|
+
"@deepseek-ai/dsh-attachment": "^0.2.1-rc.5",
|
|
55
|
+
"@deepseek-ai/dsh-home-paths": "^0.2.1-rc.5",
|
|
56
|
+
"@deepseek-ai/dsh-host-webserver": "^0.2.1-rc.5",
|
|
57
|
+
"@deepseek-ai/dsh-session": "^0.2.1-rc.5",
|
|
58
|
+
"@deepseek-ai/dsh-tools": "^0.2.1-rc.5",
|
|
59
|
+
"@deepseek-ai/dsh-user-approval": "^0.2.1-rc.5",
|
|
60
|
+
"@deepseek-ai/dsh-user-questions": "^0.2.1-rc.5"
|
|
67
61
|
},
|
|
68
62
|
"dependencies": {
|
|
69
|
-
"@deepseek-ai/schemastery": "^3.18.
|
|
63
|
+
"@deepseek-ai/schemastery": "^3.18.5",
|
|
70
64
|
"ws": "^8.21.0"
|
|
71
65
|
},
|
|
72
66
|
"scripts": {
|
|
@@ -76,26 +70,25 @@
|
|
|
76
70
|
"prepublishOnly": "pnpm run build"
|
|
77
71
|
},
|
|
78
72
|
"devDependencies": {
|
|
79
|
-
"@deepseek-ai/cordis": "4.0.
|
|
80
|
-
"@deepseek-ai/cordis-plugin-include": "1.0.
|
|
81
|
-
"@deepseek-ai/cordis-plugin-loader": "1.0.
|
|
82
|
-
"@deepseek-ai/dsh-api-gateway": "0.2.
|
|
83
|
-
"@deepseek-ai/dsh-api-session-controller": "0.2.
|
|
84
|
-
"@deepseek-ai/dsh-api-workspace-controller": "0.2.
|
|
85
|
-
"@deepseek-ai/dsh-attachment": "0.2.
|
|
86
|
-
"@deepseek-ai/dsh-
|
|
87
|
-
"@deepseek-ai/dsh-
|
|
88
|
-
"@deepseek-ai/dsh-
|
|
89
|
-
"@deepseek-ai/dsh-
|
|
90
|
-
"@deepseek-ai/dsh-
|
|
91
|
-
"@deepseek-ai/dsh-
|
|
92
|
-
"@deepseek-ai/dsh-user-questions": "0.2.
|
|
73
|
+
"@deepseek-ai/cordis": "4.0.5",
|
|
74
|
+
"@deepseek-ai/cordis-plugin-include": "1.0.10",
|
|
75
|
+
"@deepseek-ai/cordis-plugin-loader": "1.0.6",
|
|
76
|
+
"@deepseek-ai/dsh-api-gateway": "0.2.1-rc.5",
|
|
77
|
+
"@deepseek-ai/dsh-api-session-controller": "0.2.1-rc.5",
|
|
78
|
+
"@deepseek-ai/dsh-api-workspace-controller": "0.2.1-rc.5",
|
|
79
|
+
"@deepseek-ai/dsh-attachment": "0.2.1-rc.5",
|
|
80
|
+
"@deepseek-ai/dsh-home-paths": "0.2.1-rc.5",
|
|
81
|
+
"@deepseek-ai/dsh-host-webserver": "0.2.1-rc.5",
|
|
82
|
+
"@deepseek-ai/dsh-session": "0.2.1-rc.5",
|
|
83
|
+
"@deepseek-ai/dsh-system-prompt": "0.2.1-rc.5",
|
|
84
|
+
"@deepseek-ai/dsh-tools": "0.2.1-rc.5",
|
|
85
|
+
"@deepseek-ai/dsh-user-approval": "0.2.1-rc.5",
|
|
86
|
+
"@deepseek-ai/dsh-user-questions": "0.2.1-rc.5",
|
|
93
87
|
"@types/node": "^22.20.0",
|
|
94
88
|
"@types/ws": "^8.18.1",
|
|
95
89
|
"playwright-core": "^1.61.1",
|
|
96
90
|
"tsdown": "0.22.2",
|
|
97
91
|
"typescript": "^6.0.3",
|
|
98
|
-
"vitest": "^4.1.8"
|
|
99
|
-
"@deepseek-ai/dsh-user-approval": "0.2.0-rc.1"
|
|
92
|
+
"vitest": "^4.1.8"
|
|
100
93
|
}
|
|
101
94
|
}
|
package/src/approvals.ts
CHANGED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-process owner Peer for Typert Remote dispatch.
|
|
3
|
+
*
|
|
4
|
+
* dsh 0.2.1 requires every `typertGateway.invoke` / `stream` request to name a
|
|
5
|
+
* live {@link PeerScope}: the Gateway reads `peer.signal` and `peer.principal`
|
|
6
|
+
* without a fallback, because the 0.2.0 operator-peer default is gone. The
|
|
7
|
+
* bridge mounts its own token-authenticated carrier, so it speaks as the host
|
|
8
|
+
* owner; the Peer lives exactly as long as the plugin fiber.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { randomUUID } from 'node:crypto'
|
|
14
|
+
import type { Context } from '@deepseek-ai/cordis'
|
|
15
|
+
import type { InvokeRemoteRequest } from '@deepseek-ai/dsh-api-gateway/types'
|
|
16
|
+
|
|
17
|
+
/** The Peer a Gateway request must name (required since dsh 0.2.1). */
|
|
18
|
+
export type GatewayPeer = InvokeRemoteRequest['peer']
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Create the bridge's owner Peer and tie its lifetime to the calling fiber.
|
|
22
|
+
*
|
|
23
|
+
* The returned scope is structurally a full `PeerScope`; the Gateway only
|
|
24
|
+
* needs `id`, `principal`, `signal`, and `interactions` for unary calls and
|
|
25
|
+
* streams, while `ctx` keeps a future event-stream registration fiber-scoped.
|
|
26
|
+
*
|
|
27
|
+
* @param ctx - plugin context whose disposal aborts the peer.
|
|
28
|
+
* @returns a live owner Peer that is aborted when the plugin unloads.
|
|
29
|
+
*/
|
|
30
|
+
export function createGatewayPeer(ctx: Context): GatewayPeer {
|
|
31
|
+
const lifetime = new AbortController()
|
|
32
|
+
const dispose = async (): Promise<void> => {
|
|
33
|
+
if (!lifetime.signal.aborted) {
|
|
34
|
+
lifetime.abort(new Error('bridge-browser: gateway peer disposed'))
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
ctx.effect(() => () => { void dispose() }, 'bridge-browser: gateway peer')
|
|
38
|
+
return {
|
|
39
|
+
id: randomUUID() as GatewayPeer['id'],
|
|
40
|
+
ctx,
|
|
41
|
+
principal: { kind: 'owner' },
|
|
42
|
+
signal: lifetime.signal,
|
|
43
|
+
interactions: 'none',
|
|
44
|
+
dispose,
|
|
45
|
+
}
|
|
46
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -42,6 +42,7 @@ import { BRIDGE_CONFIG_PATH, BRIDGE_PATH, type RemoteWireResult } from './protoc
|
|
|
42
42
|
import { withSessionDeferral } from './session-deferral.ts'
|
|
43
43
|
import { withSessionWorkspace, type RpcDispatch } from './session-workspace.ts'
|
|
44
44
|
import { resolveToken } from './token.ts'
|
|
45
|
+
import { createGatewayPeer } from './gateway-peer.ts'
|
|
45
46
|
import { ExtensionSessionRegistry, FollowedSessions, resolveInteractionOwnership, type DelegateReason } from './extension-sessions.ts'
|
|
46
47
|
import { asQuestionAnswerArgs, QuestionBridge } from './questions.ts'
|
|
47
48
|
import { ApprovalBridge, asApprovalDecisionArgs } from './approvals.ts'
|
|
@@ -156,6 +157,9 @@ export async function apply(ctx: Context, config: Config): Promise<void> {
|
|
|
156
157
|
const resolved = resolveConfig(config)
|
|
157
158
|
|
|
158
159
|
const tokenRes = await resolveToken(resolved.token)
|
|
160
|
+
// dsh 0.2.1 made the Gateway Peer mandatory; the bridge's token-authenticated
|
|
161
|
+
// carrier speaks as the host owner and aborts the peer when this fiber dies.
|
|
162
|
+
const peer = createGatewayPeer(ctx)
|
|
159
163
|
// Base dispatch: split the slash-joined endpoint and invoke the Remote
|
|
160
164
|
// method; Remote failures are folded into the wire result (never thrown
|
|
161
165
|
// across the bridge), everything else is an internal failure.
|
|
@@ -164,7 +168,7 @@ export async function apply(ctx: Context, config: Config): Promise<void> {
|
|
|
164
168
|
const namespace = slash === -1 ? method : method.slice(0, slash)
|
|
165
169
|
const remoteMethod = slash === -1 ? '' : method.slice(slash + 1)
|
|
166
170
|
try {
|
|
167
|
-
const value = await ctx.typertGateway.invoke({ namespace, method: remoteMethod, args, signal })
|
|
171
|
+
const value = await ctx.typertGateway.invoke({ namespace, method: remoteMethod, args, signal, peer })
|
|
168
172
|
return { ok: true, value }
|
|
169
173
|
} catch (error: unknown) {
|
|
170
174
|
const failure = ctx.typertGateway.wireStream.failure(error)
|
|
@@ -241,7 +245,7 @@ export async function apply(ctx: Context, config: Config): Promise<void> {
|
|
|
241
245
|
const slash = method.indexOf('/')
|
|
242
246
|
const namespace = slash === -1 ? method : method.slice(0, slash)
|
|
243
247
|
const remoteMethod = slash === -1 ? '' : method.slice(slash + 1)
|
|
244
|
-
return ctx.typertGateway.stream({ namespace, method: remoteMethod, args, signal })
|
|
248
|
+
return ctx.typertGateway.stream({ namespace, method: remoteMethod, args, signal, peer })
|
|
245
249
|
},
|
|
246
250
|
answerQuestion: (args) => {
|
|
247
251
|
const parsed = asQuestionAnswerArgs(args)
|
package/src/protocol.ts
CHANGED
|
File without changes
|
package/src/questions.ts
CHANGED
|
File without changes
|
package/src/server.ts
CHANGED
|
File without changes
|
package/src/session-deferral.ts
CHANGED
|
File without changes
|
package/src/session-follow.ts
CHANGED
|
File without changes
|
package/src/session-workspace.ts
CHANGED
|
File without changes
|
package/src/token.ts
CHANGED
|
File without changes
|
package/src/tools.ts
CHANGED
|
File without changes
|
package/src/waterfall.ts
CHANGED
|
File without changes
|
package/lib/invariant.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
//#region lib/types/invariant.js
|
|
2
|
-
/**
|
|
3
|
-
* Package-owned invariant companion for `@deepseek-ai/dsh-bridge-browser`.
|
|
4
|
-
* @module @deepseek-ai/dsh-bridge-browser/invariant
|
|
5
|
-
*/
|
|
6
|
-
const PACKAGE_NAME = "@deepseek-ai/dsh-bridge-browser";
|
|
7
|
-
/** Cordis companion plugin name. */
|
|
8
|
-
const name = "bridge-browser-invariant";
|
|
9
|
-
/** Service required before the companion can reserve package ownership. */
|
|
10
|
-
const inject = ["invariants"];
|
|
11
|
-
/**
|
|
12
|
-
* No runtime invariant: the bridge's connection registry and pending tool map
|
|
13
|
-
* are instance-private (no published event stream to assert against), and the
|
|
14
|
-
* wire contract is pinned by protocol.ts and covered by its unit tests. The
|
|
15
|
-
* tools are plain ctx.tools registrations observed by dsh-tools' own
|
|
16
|
-
* invariant.
|
|
17
|
-
*/
|
|
18
|
-
const install = () => {};
|
|
19
|
-
/**
|
|
20
|
-
* Register this package's invariant companion.
|
|
21
|
-
* @param ctx - Cordis context carrying the invariant service.
|
|
22
|
-
* @returns the installed registration's disposer after setup succeeds.
|
|
23
|
-
*/
|
|
24
|
-
const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
|
|
25
|
-
//#endregion
|
|
26
|
-
export { apply, inject, name };
|
package/lib/types/events.d.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Session event pump: the alpha replacement for the rc `events.mux` SSE
|
|
3
|
-
* aggregate. alpha exposes per-session `session/follow` Remote streams, so
|
|
4
|
-
* this module maintains one follow stream per session the extension has
|
|
5
|
-
* touched and fans their event frames out to every connected bridge client,
|
|
6
|
-
* translated back to the rc `session/event` mux shape the extension renders.
|
|
7
|
-
*
|
|
8
|
-
* Snapshot frames are never replayed: the panel reconciles through
|
|
9
|
-
* `session.history` at turn boundaries, so replaying the opening window would
|
|
10
|
-
* duplicate rows it already drew.
|
|
11
|
-
*
|
|
12
|
-
* @module
|
|
13
|
-
*/
|
|
14
|
-
import type { TypertGateway } from '@deepseek-ai/dsh-api-gateway/types';
|
|
15
|
-
import type { SessionWireEvent } from '@deepseek-ai/dsh-api-session-controller/types';
|
|
16
|
-
/** One translated event envelope, the bridge's local replacement for rc MuxFrame pushes. */
|
|
17
|
-
export interface SessionEventEnvelope {
|
|
18
|
-
readonly rpcId: string;
|
|
19
|
-
readonly payload: {
|
|
20
|
-
readonly type: 'session/event';
|
|
21
|
-
readonly sessionId: string;
|
|
22
|
-
readonly event: SessionWireEvent;
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Multiplex `session/follow` streams onto bridge event subscribers. Shared by
|
|
27
|
-
* all connections of one plugin instance; dispose with {@link close}.
|
|
28
|
-
*/
|
|
29
|
-
export declare class SessionEventMux {
|
|
30
|
-
private readonly gateway;
|
|
31
|
-
private readonly warn;
|
|
32
|
-
private readonly listeners;
|
|
33
|
-
private readonly streams;
|
|
34
|
-
private readonly warned;
|
|
35
|
-
private closed;
|
|
36
|
-
constructor(gateway: TypertGateway, warn: (message: string) => void);
|
|
37
|
-
/**
|
|
38
|
-
* Record that the extension addressed this session. The first touch opens
|
|
39
|
-
* the session's follow stream; later touches are no-ops.
|
|
40
|
-
*/
|
|
41
|
-
touch(sessionId: string): void;
|
|
42
|
-
/** Stop every follow stream and drop all subscribers. */
|
|
43
|
-
close(): void;
|
|
44
|
-
/**
|
|
45
|
-
* Subscribe one bridge connection: yields translated `session/event`
|
|
46
|
-
* envelopes until the signal aborts. Late subscribers hear only future
|
|
47
|
-
* events — history reconciliation owns the backlog.
|
|
48
|
-
*/
|
|
49
|
-
openEvents(signal: AbortSignal): AsyncIterable<SessionEventEnvelope>;
|
|
50
|
-
/**
|
|
51
|
-
* One session's follow loop. Event frames are translated and broadcast;
|
|
52
|
-
* failures reopen the stream after {@link FOLLOW_RETRY_MS} until the mux is
|
|
53
|
-
* closed (a stream can outlive its session's visibility, and transient
|
|
54
|
-
* resume failures must not silence a live session).
|
|
55
|
-
*/
|
|
56
|
-
private follow;
|
|
57
|
-
private broadcast;
|
|
58
|
-
}
|
|
59
|
-
//# sourceMappingURL=events.d.ts.map
|
package/lib/types/gateway.d.ts
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* rc→alpha gateway translation for the bridge RPC path.
|
|
3
|
-
*
|
|
4
|
-
* The browser extension speaks the rc-line bridge protocol: dot-joined method
|
|
5
|
-
* names (`session.create`) and rc-shaped response envelopes. The alpha line
|
|
6
|
-
* removed `ctx.apiProxy`; its `/api` carrier expects slash-joined endpoints
|
|
7
|
-
* (`session/create`) and a strict `{ args: { request | _request } }` payload
|
|
8
|
-
* envelope. This module is the ONLY place that knows both dialects: unary
|
|
9
|
-
* methods are re-enveloped onto Connection's shared fetch handler, while
|
|
10
|
-
* `workspace.list` and `session.history` (deleted in alpha) are synthesized
|
|
11
|
-
* from the `workspace/follow` and `session/follow` Remote streams.
|
|
12
|
-
*
|
|
13
|
-
* @module
|
|
14
|
-
*/
|
|
15
|
-
import type { ConnectionFetchHandler } from '@deepseek-ai/dsh-client-connection';
|
|
16
|
-
import type { TypertGateway } from '@deepseek-ai/dsh-api-gateway/types';
|
|
17
|
-
/** Success/failure result inside one server-response body. */
|
|
18
|
-
export type GatewayResult = {
|
|
19
|
-
readonly ok: true;
|
|
20
|
-
readonly value: unknown;
|
|
21
|
-
} | {
|
|
22
|
-
readonly ok: false;
|
|
23
|
-
readonly error: {
|
|
24
|
-
readonly code: string;
|
|
25
|
-
readonly message: string;
|
|
26
|
-
readonly details?: object;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
/** The response body relayed verbatim as the extension's `rpc.result.result`. */
|
|
30
|
-
export interface GatewayResponse {
|
|
31
|
-
readonly type: 'server-response';
|
|
32
|
-
readonly rpcId: string;
|
|
33
|
-
readonly result: GatewayResult;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* One dispatch of a bridge RPC frame: dot-joined method plus the extension's
|
|
37
|
-
* raw payload, answered with the rc-shaped server-response body. Business
|
|
38
|
-
* failures ride the envelope (`result.ok: false`); only carrier-level
|
|
39
|
-
* failures reject (see {@link GatewayDispatchError}).
|
|
40
|
-
*/
|
|
41
|
-
export type RpcDispatch = (rpcId: string, method: string, payload: unknown) => Promise<GatewayResponse>;
|
|
42
|
-
/** Carrier-level dispatch failure; `code` becomes the `rpc.result` error code. */
|
|
43
|
-
export declare class GatewayDispatchError extends Error {
|
|
44
|
-
readonly code: 'http' | 'internal';
|
|
45
|
-
constructor(code: 'http' | 'internal', message: string);
|
|
46
|
-
}
|
|
47
|
-
/** Wrap one business value in the rc-shaped server-response body. */
|
|
48
|
-
export declare function okResponse(rpcId: string, value: unknown): GatewayResponse;
|
|
49
|
-
/** Wrap one business failure in the rc-shaped server-response body. */
|
|
50
|
-
export declare function failResponse(rpcId: string, code: string, message: string, details?: object): GatewayResponse;
|
|
51
|
-
/** Callback the gateway uses to report sessions the extension has addressed. */
|
|
52
|
-
export type TouchSession = (sessionId: string) => void;
|
|
53
|
-
export interface BridgeGatewayDeps {
|
|
54
|
-
/** Authenticated `/api` carrier from `ctx.connection.createSharedFetchHandler('/api')`. */
|
|
55
|
-
readonly fetchHandler: ConnectionFetchHandler;
|
|
56
|
-
/** Live Typert Remote dispatcher (stream methods only; unary goes through the carrier). */
|
|
57
|
-
readonly gateway: TypertGateway;
|
|
58
|
-
/** Notified with every session id the extension addresses (drives the event pump). */
|
|
59
|
-
readonly touch: TouchSession;
|
|
60
|
-
/** Logger for degraded synthesized methods. */
|
|
61
|
-
readonly warn: (message: string) => void;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* The bridge's alpha gateway face: unary translation onto the shared `/api`
|
|
65
|
-
* carrier plus the two synthesized rc methods. Construct once per plugin
|
|
66
|
-
* instance; wrap with the session-workspace/session-deferral interceptors,
|
|
67
|
-
* then hand the outermost {@link RpcDispatch} to the bridge server.
|
|
68
|
-
*/
|
|
69
|
-
export declare class BridgeGateway {
|
|
70
|
-
private readonly deps;
|
|
71
|
-
private readonly workspaces;
|
|
72
|
-
constructor(deps: BridgeGatewayDeps);
|
|
73
|
-
/** Bound dispatch, safe to wrap and hand to the bridge server. */
|
|
74
|
-
readonly dispatch: RpcDispatch;
|
|
75
|
-
/** Start the workspace/follow stream backing `workspace.list`. */
|
|
76
|
-
start(): void;
|
|
77
|
-
/** Stop owned streams (plugin dispose). */
|
|
78
|
-
close(): void;
|
|
79
|
-
private dispatchImpl;
|
|
80
|
-
/**
|
|
81
|
-
* alpha has no `session/history`: one short-lived `session/follow` stream
|
|
82
|
-
* supplies its opening snapshot, whose records replay exactly what the rc
|
|
83
|
-
* tail page carried (`{ event }` entries plus `hasMore`).
|
|
84
|
-
*/
|
|
85
|
-
private sessionHistory;
|
|
86
|
-
}
|
|
87
|
-
//# sourceMappingURL=gateway.d.ts.map
|
package/lib/types/invariant.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Package-owned invariant companion for `@deepseek-ai/dsh-bridge-browser`.
|
|
3
|
-
* @module @deepseek-ai/dsh-bridge-browser/invariant
|
|
4
|
-
*/
|
|
5
|
-
import type { Context } from '@deepseek-ai/cordis';
|
|
6
|
-
/** Cordis companion plugin name. */
|
|
7
|
-
export declare const name = "bridge-browser-invariant";
|
|
8
|
-
/** Service required before the companion can reserve package ownership. */
|
|
9
|
-
export declare const inject: string[];
|
|
10
|
-
/**
|
|
11
|
-
* Register this package's invariant companion.
|
|
12
|
-
* @param ctx - Cordis context carrying the invariant service.
|
|
13
|
-
* @returns the installed registration's disposer after setup succeeds.
|
|
14
|
-
*/
|
|
15
|
-
export declare const apply: (ctx: Context) => Promise<() => void>;
|
|
16
|
-
//# sourceMappingURL=invariant.d.ts.map
|
package/src/invariant.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Package-owned invariant companion for `@deepseek-ai/dsh-bridge-browser`.
|
|
3
|
-
* @module @deepseek-ai/dsh-bridge-browser/invariant
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/* jscpd:ignore-start */
|
|
7
|
-
import type { Context } from '@deepseek-ai/cordis'
|
|
8
|
-
import type { InvariantInstaller } from '@deepseek-ai/dsh-invariants'
|
|
9
|
-
|
|
10
|
-
const PACKAGE_NAME = '@deepseek-ai/dsh-bridge-browser'
|
|
11
|
-
|
|
12
|
-
/** Cordis companion plugin name. */
|
|
13
|
-
export const name = 'bridge-browser-invariant'
|
|
14
|
-
/** Service required before the companion can reserve package ownership. */
|
|
15
|
-
export const inject = ['invariants']
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* No runtime invariant: the bridge's connection registry and pending tool map
|
|
19
|
-
* are instance-private (no published event stream to assert against), and the
|
|
20
|
-
* wire contract is pinned by protocol.ts and covered by its unit tests. The
|
|
21
|
-
* tools are plain ctx.tools registrations observed by dsh-tools' own
|
|
22
|
-
* invariant.
|
|
23
|
-
*/
|
|
24
|
-
const install: InvariantInstaller = () => {}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Register this package's invariant companion.
|
|
28
|
-
* @param ctx - Cordis context carrying the invariant service.
|
|
29
|
-
* @returns the installed registration's disposer after setup succeeds.
|
|
30
|
-
*/
|
|
31
|
-
export const apply = (ctx: Context): Promise<() => void> =>
|
|
32
|
-
Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install))
|
|
33
|
-
/* jscpd:ignore-end */
|