@mind-harness/mh-browser 0.2.3 → 0.2.5
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/THIRD-PARTY-NOTICES +23 -0
- package/extension/manifest.json +1 -1
- package/lib/client.cjs +446 -0
- package/lib/index.js +524 -274
- package/lib/typert.host.js +1 -1
- package/lib/typert.remote-client.js +1 -1
- package/lib/types/card.d.ts +24 -0
- package/lib/types/client.d.ts +53 -0
- package/lib/types/locales.d.ts +15 -0
- package/lib/types/row.d.ts +69 -0
- package/lib/types/service/abortable.d.ts +24 -0
- package/lib/types/service/extension.d.ts +7 -6
- package/lib/types/service/windows.d.ts +11 -3
- package/lib/types/tools/given.d.ts +5 -0
- package/package.json +24 -4
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
lib/client.cjs includes code from @deepseek-ai/dsh-typert-protocol, distributed under the following license.
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2026 DeepSeek
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE.
|
package/extension/manifest.json
CHANGED
package/lib/client.cjs
ADDED
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "@mind-harness/mh-browser",
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
var module = { exports: {} };
|
|
5
|
+
var exports = module.exports;
|
|
6
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
+
let zod = require("zod");
|
|
8
|
+
let react = require("react");
|
|
9
|
+
//#region ../../node_modules/.pnpm/@deepseek-ai+dsh-typert-protocol@0.2.2-rc.1_@deepseek-ai+cordis@4.1.0/node_modules/@deepseek-ai/dsh-typert-protocol/lib/types/remote-info.js
|
|
10
|
+
/** Lazy assembly of generated Remote definitions using caller-supplied Zod; no runtime imports. */
|
|
11
|
+
/**
|
|
12
|
+
* Retain one generated definition per endpoint without constructing parsers or projections.
|
|
13
|
+
* The class instance builds its shared descriptor/method index on first access;
|
|
14
|
+
* input schemas and JSON Schema projections are cached only when requested.
|
|
15
|
+
* @param spec - compiler-produced method facts and Zod factories.
|
|
16
|
+
* @param zod - the generated artifact's Zod runtime for named-input parsers.
|
|
17
|
+
* @returns a lazy, mountable info instance with no registration or transport effects.
|
|
18
|
+
*/
|
|
19
|
+
function createTypertRemoteInfo(spec, zod) {
|
|
20
|
+
return new RemoteInfo(spec, zod);
|
|
21
|
+
}
|
|
22
|
+
var RemoteInfo = class {
|
|
23
|
+
spec;
|
|
24
|
+
zod;
|
|
25
|
+
index;
|
|
26
|
+
constructor(spec, zod) {
|
|
27
|
+
this.spec = spec;
|
|
28
|
+
this.zod = zod;
|
|
29
|
+
}
|
|
30
|
+
get package() {
|
|
31
|
+
return this.spec.package;
|
|
32
|
+
}
|
|
33
|
+
get descriptors() {
|
|
34
|
+
return this.resolve().descriptors;
|
|
35
|
+
}
|
|
36
|
+
get methods() {
|
|
37
|
+
return this.resolve().methods;
|
|
38
|
+
}
|
|
39
|
+
resolve() {
|
|
40
|
+
if (this.index !== void 0) return this.index;
|
|
41
|
+
const zod = this.zod;
|
|
42
|
+
const descriptors = [];
|
|
43
|
+
const methods = Object.create(null);
|
|
44
|
+
for (const [endpoint, definition] of Object.entries(this.spec.methods)) {
|
|
45
|
+
const separator = endpoint.indexOf("/");
|
|
46
|
+
const namespace = endpoint.slice(0, separator);
|
|
47
|
+
const method = endpoint.slice(separator + 1);
|
|
48
|
+
const parameters = definition.parameters.map((parameter) => ({
|
|
49
|
+
...parameter,
|
|
50
|
+
wire: parameter.wire ?? parameter.name
|
|
51
|
+
}));
|
|
52
|
+
const descriptor = {
|
|
53
|
+
...definition,
|
|
54
|
+
id: `${this.spec.package}#${endpoint}`,
|
|
55
|
+
namespace,
|
|
56
|
+
method,
|
|
57
|
+
parameters,
|
|
58
|
+
result: definition.result.description === void 0 ? definition.result : new ResultValue(definition.result)
|
|
59
|
+
};
|
|
60
|
+
if (definition.invocation.kind === "direct") {
|
|
61
|
+
const inputs = [];
|
|
62
|
+
methods[endpoint] = Object.assign(descriptor, {
|
|
63
|
+
input(options) {
|
|
64
|
+
const strict = options?.strict === true;
|
|
65
|
+
return inputs[strict ? 1 : 0] ??= new NamedInput(parameters, strict, zod);
|
|
66
|
+
},
|
|
67
|
+
invoke(remote, input, signal) {
|
|
68
|
+
const named = input;
|
|
69
|
+
const values = parameters.map((parameter) => named[parameter.wire]);
|
|
70
|
+
if (definition.cancellation !== void 0) values.push(signal);
|
|
71
|
+
const receiver = Reflect.get(remote, namespace);
|
|
72
|
+
return Reflect.get(receiver, method).apply(receiver, values);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
descriptors.push(descriptor);
|
|
77
|
+
}
|
|
78
|
+
return this.index = {
|
|
79
|
+
descriptors,
|
|
80
|
+
methods
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
function optional(parameter) {
|
|
85
|
+
return parameter.source === "json" && parameter.acceptsUndefined === true;
|
|
86
|
+
}
|
|
87
|
+
var NamedInput = class {
|
|
88
|
+
parameters;
|
|
89
|
+
strict;
|
|
90
|
+
zod;
|
|
91
|
+
schema;
|
|
92
|
+
projection;
|
|
93
|
+
constructor(parameters, strict, zod) {
|
|
94
|
+
this.parameters = parameters;
|
|
95
|
+
this.strict = strict;
|
|
96
|
+
this.zod = zod;
|
|
97
|
+
}
|
|
98
|
+
codec(parameter) {
|
|
99
|
+
return this.strict ? parameter.strictCodec : parameter.codec;
|
|
100
|
+
}
|
|
101
|
+
create = () => this.schema ??= this.zod.strictObject(Object.fromEntries(this.parameters.map((parameter) => {
|
|
102
|
+
const value = this.codec(parameter).create();
|
|
103
|
+
return [parameter.wire, optional(parameter) ? value.optional() : value.nonoptional()];
|
|
104
|
+
})));
|
|
105
|
+
get jsonSchema() {
|
|
106
|
+
return this.project().jsonSchema;
|
|
107
|
+
}
|
|
108
|
+
get jsonSchemaError() {
|
|
109
|
+
return this.project().jsonSchemaError;
|
|
110
|
+
}
|
|
111
|
+
project() {
|
|
112
|
+
if (this.projection !== void 0) return this.projection;
|
|
113
|
+
const unavailable = this.parameters.find((parameter) => this.codec(parameter).jsonSchema === void 0);
|
|
114
|
+
if (unavailable !== void 0) return this.projection = { jsonSchemaError: this.codec(unavailable).jsonSchemaError ?? `No JSON Schema for parameter ${unavailable.wire}` };
|
|
115
|
+
return this.projection = { jsonSchema: {
|
|
116
|
+
type: "object",
|
|
117
|
+
properties: Object.fromEntries(this.parameters.map((parameter) => [parameter.wire, {
|
|
118
|
+
...this.codec(parameter).jsonSchema,
|
|
119
|
+
...parameter.description === void 0 ? {} : { description: parameter.description }
|
|
120
|
+
}])),
|
|
121
|
+
required: this.parameters.filter((parameter) => !optional(parameter)).map((parameter) => parameter.wire),
|
|
122
|
+
additionalProperties: false
|
|
123
|
+
} };
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
var ResultValue = class {
|
|
127
|
+
spec;
|
|
128
|
+
projection;
|
|
129
|
+
constructor(spec) {
|
|
130
|
+
this.spec = spec;
|
|
131
|
+
}
|
|
132
|
+
get mode() {
|
|
133
|
+
return this.spec.mode;
|
|
134
|
+
}
|
|
135
|
+
get typeSymbol() {
|
|
136
|
+
return this.spec.typeSymbol;
|
|
137
|
+
}
|
|
138
|
+
get create() {
|
|
139
|
+
return this.spec.create;
|
|
140
|
+
}
|
|
141
|
+
get decode() {
|
|
142
|
+
return this.spec.decode;
|
|
143
|
+
}
|
|
144
|
+
get encode() {
|
|
145
|
+
return this.spec.encode;
|
|
146
|
+
}
|
|
147
|
+
get description() {
|
|
148
|
+
return this.spec.description;
|
|
149
|
+
}
|
|
150
|
+
get jsonSchemaError() {
|
|
151
|
+
return this.spec.jsonSchemaError;
|
|
152
|
+
}
|
|
153
|
+
get jsonSchema() {
|
|
154
|
+
if (this.projection === void 0) {
|
|
155
|
+
const schema = this.spec.jsonSchema;
|
|
156
|
+
this.projection = { value: schema === void 0 ? void 0 : {
|
|
157
|
+
...schema,
|
|
158
|
+
description: this.spec.description
|
|
159
|
+
} };
|
|
160
|
+
}
|
|
161
|
+
return this.projection.value;
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region lib/typert.remote-client.js
|
|
166
|
+
let _mind_harness_mh_browser_mhBrowser_revealHandover_parameter_0$schema$value;
|
|
167
|
+
const _mind_harness_mh_browser_mhBrowser_revealHandover_parameter_0$schema = () => _mind_harness_mh_browser_mhBrowser_revealHandover_parameter_0$schema$value ??= zod.z.string();
|
|
168
|
+
let _mind_harness_mh_browser_mhBrowser_revealHandover_result$schema$value;
|
|
169
|
+
const _mind_harness_mh_browser_mhBrowser_revealHandover_result$schema = () => _mind_harness_mh_browser_mhBrowser_revealHandover_result$schema$value ??= zod.z.object({ "status": zod.z.union([
|
|
170
|
+
zod.z.literal("revealed"),
|
|
171
|
+
zod.z.literal("not-handing-over"),
|
|
172
|
+
zod.z.literal("no-tab")
|
|
173
|
+
]) });
|
|
174
|
+
let _mind_harness_mh_browser_mhBrowser_revealHandover_parameter_0_strict$schema$value;
|
|
175
|
+
const _mind_harness_mh_browser_mhBrowser_revealHandover_parameter_0_strict$schema = () => _mind_harness_mh_browser_mhBrowser_revealHandover_parameter_0_strict$schema$value ??= zod.z.string();
|
|
176
|
+
const TYPERT_REMOTE = createTypertRemoteInfo({
|
|
177
|
+
package: "@mind-harness/mh-browser",
|
|
178
|
+
methods: { "mhBrowser/revealHandover": {
|
|
179
|
+
service: "mhBrowser",
|
|
180
|
+
description: "The person asked to see the page this Session handed over.",
|
|
181
|
+
invocation: { kind: "direct" },
|
|
182
|
+
parameters: [{
|
|
183
|
+
name: "sessionId",
|
|
184
|
+
source: "json",
|
|
185
|
+
codec: {
|
|
186
|
+
mode: "strict",
|
|
187
|
+
typeSymbol: "@mind-harness/mh-browser#mhBrowser/revealHandover:sessionId",
|
|
188
|
+
create: _mind_harness_mh_browser_mhBrowser_revealHandover_parameter_0$schema,
|
|
189
|
+
jsonSchema: { "type": "string" }
|
|
190
|
+
},
|
|
191
|
+
strictCodec: {
|
|
192
|
+
mode: "strict",
|
|
193
|
+
typeSymbol: "@mind-harness/mh-browser#mhBrowser/revealHandover:sessionId",
|
|
194
|
+
create: _mind_harness_mh_browser_mhBrowser_revealHandover_parameter_0_strict$schema,
|
|
195
|
+
jsonSchema: { "type": "string" }
|
|
196
|
+
}
|
|
197
|
+
}],
|
|
198
|
+
cancellation: { parameter: "signal" },
|
|
199
|
+
result: {
|
|
200
|
+
mode: "strict",
|
|
201
|
+
typeSymbol: "@mind-harness/mh-browser#mhBrowser/revealHandover:result",
|
|
202
|
+
create: _mind_harness_mh_browser_mhBrowser_revealHandover_result$schema,
|
|
203
|
+
jsonSchema: {
|
|
204
|
+
"type": "object",
|
|
205
|
+
"properties": { "status": {
|
|
206
|
+
"type": "string",
|
|
207
|
+
"enum": [
|
|
208
|
+
"revealed",
|
|
209
|
+
"not-handing-over",
|
|
210
|
+
"no-tab"
|
|
211
|
+
]
|
|
212
|
+
} },
|
|
213
|
+
"required": ["status"],
|
|
214
|
+
"additionalProperties": true
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
sourceLocation: {
|
|
218
|
+
"file": "packages/mh-browser/src/service/service.ts",
|
|
219
|
+
"line": 684,
|
|
220
|
+
"column": 9
|
|
221
|
+
}
|
|
222
|
+
} }
|
|
223
|
+
}, zod.z);
|
|
224
|
+
//#endregion
|
|
225
|
+
//#region src/client/card.ts
|
|
226
|
+
/** Host theme tokens only; the rules unmount with the row. */
|
|
227
|
+
const STYLE = `
|
|
228
|
+
.mh-br { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; color: var(--dsw-alias-label-primary); font-size: 14px; line-height: 20px; }
|
|
229
|
+
.mh-br-line { margin: 0; }
|
|
230
|
+
.mh-br-status { margin: 0; color: var(--dsw-alias-label-secondary); }
|
|
231
|
+
.mh-br-button { padding: 4px 10px; border: 0.5px solid var(--dsw-alias-border-l3); border-radius: var(--dsw-radius-md); background: transparent; color: var(--dsw-alias-label-primary); font: inherit; cursor: pointer; }
|
|
232
|
+
`;
|
|
233
|
+
/** The open handover: the reason and the button that raises its window. */
|
|
234
|
+
function HandoverRow(props) {
|
|
235
|
+
const [note, setNote] = (0, react.useState)(void 0);
|
|
236
|
+
return (0, react.createElement)("section", { className: "mh-br" }, (0, react.createElement)("style", null, STYLE), (0, react.createElement)("p", { className: "mh-br-line" }, props.t("waiting", { reason: props.reason })), (0, react.createElement)("button", {
|
|
237
|
+
type: "button",
|
|
238
|
+
className: "mh-br-button",
|
|
239
|
+
onClick: () => {
|
|
240
|
+
props.reveal(props.sessionId, new AbortController().signal).then((result) => {
|
|
241
|
+
setNote(noteFor(result, props.t));
|
|
242
|
+
}).catch(() => {
|
|
243
|
+
setNote(props.t("failed"));
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
}, props.t("reveal")), note !== void 0 ? (0, react.createElement)("p", { className: "mh-br-status" }, note) : null);
|
|
247
|
+
}
|
|
248
|
+
/** `revealed` adds no status line. */
|
|
249
|
+
function noteFor(result, t) {
|
|
250
|
+
if (!result.ok) return t("failed");
|
|
251
|
+
if (result.value.status === "not-handing-over") return t("notHandingOver");
|
|
252
|
+
if (result.value.status === "no-tab") return t("noTab");
|
|
253
|
+
}
|
|
254
|
+
//#endregion
|
|
255
|
+
//#region src/client/locales.ts
|
|
256
|
+
/** Dictionary namespace for the handover row. */
|
|
257
|
+
const NS = "mh-browser";
|
|
258
|
+
const zh = {
|
|
259
|
+
waiting: "浏览器交给你了:{reason}",
|
|
260
|
+
reveal: "去浏览器",
|
|
261
|
+
notHandingOver: "这次交接已经结束",
|
|
262
|
+
noTab: "没有可以去的页面",
|
|
263
|
+
failed: "没能切到浏览器"
|
|
264
|
+
};
|
|
265
|
+
const en = {
|
|
266
|
+
waiting: "The browser is yours: {reason}",
|
|
267
|
+
reveal: "Go to the browser",
|
|
268
|
+
notHandingOver: "This handover has already ended",
|
|
269
|
+
noTab: "There is no page to open",
|
|
270
|
+
failed: "Could not switch to the browser"
|
|
271
|
+
};
|
|
272
|
+
//#endregion
|
|
273
|
+
//#region src/client/row.ts
|
|
274
|
+
/**
|
|
275
|
+
* One chat row for the open `browser_handover` in a turn.
|
|
276
|
+
* `groupTree: 'turn'` stands outside the process group. A settled call keeps
|
|
277
|
+
* the same key and hides the row; a hidden row is omitted from group order.
|
|
278
|
+
*/
|
|
279
|
+
const HANDOVER_KIND = "browser-handover";
|
|
280
|
+
const HANDOVER_TOOL = "browser_handover";
|
|
281
|
+
function isRecord(value) {
|
|
282
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
283
|
+
}
|
|
284
|
+
function turnOf(data) {
|
|
285
|
+
if (!isRecord(data) || typeof data.turn !== "number") return void 0;
|
|
286
|
+
return data.turn;
|
|
287
|
+
}
|
|
288
|
+
function reasonOf(value) {
|
|
289
|
+
if (typeof value !== "string") return "";
|
|
290
|
+
try {
|
|
291
|
+
const parsed = JSON.parse(value);
|
|
292
|
+
if (!isRecord(parsed) || typeof parsed.reason !== "string") return "";
|
|
293
|
+
return parsed.reason;
|
|
294
|
+
} catch {
|
|
295
|
+
return "";
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
function callOf(data) {
|
|
299
|
+
if (!isRecord(data) || typeof data.callId !== "string" || typeof data.name !== "string") return void 0;
|
|
300
|
+
return {
|
|
301
|
+
callId: data.callId,
|
|
302
|
+
name: data.name,
|
|
303
|
+
arguments: data.arguments
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
/** A result names its call on `message.source` and again on `message.toolCallId`. */
|
|
307
|
+
function callIdOf(data) {
|
|
308
|
+
if (!isRecord(data) || !isRecord(data.message)) return void 0;
|
|
309
|
+
const message = data.message;
|
|
310
|
+
if (isRecord(message.source) && typeof message.source.callId === "string" && message.source.callId !== "") return message.source.callId;
|
|
311
|
+
if (typeof message.toolCallId === "string" && message.toolCallId !== "") return message.toolCallId;
|
|
312
|
+
}
|
|
313
|
+
function hidden(current) {
|
|
314
|
+
return {
|
|
315
|
+
...current,
|
|
316
|
+
visibility: "hidden",
|
|
317
|
+
data: { reason: "" }
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* The row for one turn. Absent until a handover in that turn has been seen;
|
|
322
|
+
* hidden, with the same key, once the open call settles.
|
|
323
|
+
*/
|
|
324
|
+
function buildHandoverView(context) {
|
|
325
|
+
const current = context.current.get("chat") ?? null;
|
|
326
|
+
const anchorSeq = context.state?.anchorSeq;
|
|
327
|
+
if (anchorSeq === void 0) return current === null ? null : hidden(current);
|
|
328
|
+
const open = context.state?.open;
|
|
329
|
+
return {
|
|
330
|
+
key: context.key,
|
|
331
|
+
kind: HANDOVER_KIND,
|
|
332
|
+
id: context.id,
|
|
333
|
+
target: "chat",
|
|
334
|
+
anchorSeq,
|
|
335
|
+
location: context.start?.location ?? { kind: "unresolved" },
|
|
336
|
+
visibility: open === void 0 ? "hidden" : "visible",
|
|
337
|
+
groupTree: "turn",
|
|
338
|
+
data: { reason: open?.reason ?? "" }
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
const handoverRowDefinition = {
|
|
342
|
+
kind: HANDOVER_KIND,
|
|
343
|
+
target: "chat",
|
|
344
|
+
match(event) {
|
|
345
|
+
const turn = turnOf(event.data);
|
|
346
|
+
if (turn === void 0) return null;
|
|
347
|
+
const id = String(turn);
|
|
348
|
+
if (event.type === "turn/start") return {
|
|
349
|
+
id,
|
|
350
|
+
role: "start"
|
|
351
|
+
};
|
|
352
|
+
if (event.type === "tool/call") return callOf(event.data)?.name === HANDOVER_TOOL ? {
|
|
353
|
+
id,
|
|
354
|
+
role: "update"
|
|
355
|
+
} : null;
|
|
356
|
+
if (event.type === "tool/result" && callIdOf(event.data) !== void 0) return {
|
|
357
|
+
id,
|
|
358
|
+
role: "update"
|
|
359
|
+
};
|
|
360
|
+
return null;
|
|
361
|
+
},
|
|
362
|
+
start() {
|
|
363
|
+
return {
|
|
364
|
+
open: void 0,
|
|
365
|
+
anchorSeq: void 0
|
|
366
|
+
};
|
|
367
|
+
},
|
|
368
|
+
update(context, match) {
|
|
369
|
+
const event = match.event;
|
|
370
|
+
if (event.type === "tool/call") {
|
|
371
|
+
const call = callOf(event.data);
|
|
372
|
+
if (call === void 0 || call.name !== HANDOVER_TOOL) return context.state;
|
|
373
|
+
return {
|
|
374
|
+
open: {
|
|
375
|
+
callId: call.callId,
|
|
376
|
+
reason: reasonOf(call.arguments),
|
|
377
|
+
seq: event.seq
|
|
378
|
+
},
|
|
379
|
+
anchorSeq: event.seq
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
if (event.type === "tool/result") {
|
|
383
|
+
const callId = callIdOf(event.data);
|
|
384
|
+
if (context.state.open === void 0 || callId !== context.state.open.callId) return context.state;
|
|
385
|
+
return {
|
|
386
|
+
open: void 0,
|
|
387
|
+
anchorSeq: context.state.anchorSeq
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
return context.state;
|
|
391
|
+
},
|
|
392
|
+
buildViewNode(context) {
|
|
393
|
+
return buildHandoverView(context);
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
//#endregion
|
|
397
|
+
//#region src/client/client.ts
|
|
398
|
+
/**
|
|
399
|
+
* Cordis services this client reads. `dsh.client.inject` is package load
|
|
400
|
+
* order, not this list. `remote.mhBrowser` is absent until `$mount`.
|
|
401
|
+
*/
|
|
402
|
+
const inject = [
|
|
403
|
+
"slots",
|
|
404
|
+
"locale",
|
|
405
|
+
"remote",
|
|
406
|
+
"uiConversation"
|
|
407
|
+
];
|
|
408
|
+
const namespaceInject = [...inject, "remote.mhBrowser"];
|
|
409
|
+
async function apply(ctx) {
|
|
410
|
+
const unmount = await ctx.remote.$mount(TYPERT_REMOTE);
|
|
411
|
+
let release = () => void 0;
|
|
412
|
+
await ctx.inject(namespaceInject, (inner) => {
|
|
413
|
+
release = start(inner);
|
|
414
|
+
});
|
|
415
|
+
return async () => {
|
|
416
|
+
release();
|
|
417
|
+
await unmount();
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
/** Register the handover row. The tool call itself keeps the generic tool row. */
|
|
421
|
+
function start(ctx) {
|
|
422
|
+
ctx.effect(() => ctx.locale.register(NS, {
|
|
423
|
+
zh,
|
|
424
|
+
en
|
|
425
|
+
}));
|
|
426
|
+
ctx.effect(() => ctx.uiConversation.events.register(handoverRowDefinition));
|
|
427
|
+
const remote = ctx.remote.mhBrowser;
|
|
428
|
+
ctx.slots.inject("conversation.chat.node", () => ctx.slots.register({
|
|
429
|
+
name: "conversation.chat.node",
|
|
430
|
+
key: HANDOVER_KIND,
|
|
431
|
+
locale: NS
|
|
432
|
+
}, (props) => (0, react.createElement)(HandoverRow, {
|
|
433
|
+
sessionId: props.sessionId,
|
|
434
|
+
reason: props.node.data.reason,
|
|
435
|
+
t: props.t,
|
|
436
|
+
reveal: (sessionId, signal) => remote.revealHandover(sessionId, signal)
|
|
437
|
+
})));
|
|
438
|
+
return () => void 0;
|
|
439
|
+
}
|
|
440
|
+
//#endregion
|
|
441
|
+
exports.apply = apply;
|
|
442
|
+
exports.inject = inject;
|
|
443
|
+
exports.start = start;
|
|
444
|
+
return module.exports;
|
|
445
|
+
}
|
|
446
|
+
});
|