@sjhmars/happy-bridge 0.3.1 → 0.3.3
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/lib/client.js +11 -11
- package/lib/index.js +18 -6
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -17,21 +17,21 @@ window.__ModuleLoader__.load({
|
|
|
17
17
|
document.head.appendChild(tag);
|
|
18
18
|
}
|
|
19
19
|
var HappyBridgeCard_module_css_default = {
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"qr": "l9rBEq_qr",
|
|
23
|
-
"description": "l9rBEq_description",
|
|
24
|
-
"select": "l9rBEq_select",
|
|
25
|
-
"card": "l9rBEq_card",
|
|
26
|
-
"headText": "l9rBEq_headText",
|
|
20
|
+
"checkbox": "l9rBEq_checkbox",
|
|
21
|
+
"label": "l9rBEq_label",
|
|
27
22
|
"status": "l9rBEq_status",
|
|
23
|
+
"headText": "l9rBEq_headText",
|
|
24
|
+
"button": "l9rBEq_button",
|
|
28
25
|
"row": "l9rBEq_row",
|
|
29
|
-
"
|
|
26
|
+
"qr": "l9rBEq_qr",
|
|
27
|
+
"name": "l9rBEq_name",
|
|
30
28
|
"chevron": "l9rBEq_chevron",
|
|
31
|
-
"checkbox": "l9rBEq_checkbox",
|
|
32
29
|
"error": "l9rBEq_error",
|
|
33
|
-
"
|
|
34
|
-
"
|
|
30
|
+
"header": "l9rBEq_header",
|
|
31
|
+
"body": "l9rBEq_body",
|
|
32
|
+
"select": "l9rBEq_select",
|
|
33
|
+
"card": "l9rBEq_card",
|
|
34
|
+
"description": "l9rBEq_description"
|
|
35
35
|
};
|
|
36
36
|
//#endregion
|
|
37
37
|
//#region src/client/HappyBridgeCard.tsx
|
package/lib/index.js
CHANGED
|
@@ -3787,7 +3787,10 @@ var HappyBridge = class {
|
|
|
3787
3787
|
const model = messageModelCode(meta);
|
|
3788
3788
|
const effort = messageEffort(meta);
|
|
3789
3789
|
const permissionMode = meta.permissionMode;
|
|
3790
|
-
|
|
3790
|
+
const publishedModel = this.lastPublished.get(agent.id)?.model;
|
|
3791
|
+
const modelIsEcho = model !== void 0 && publishedModel !== void 0 && sameCatalogPick({ model: publishedModel }, { model });
|
|
3792
|
+
if (model !== void 0) this.log(`手机消息 meta.model=${model}${modelIsEcho ? "(自己发布的回声,忽略)" : "(用户选择,准备应用)"}`);
|
|
3793
|
+
if (modelIsEcho) {} else if (model !== void 0) {
|
|
3791
3794
|
if (!grantAtLeast(this.config.remoteGrant, "full")) link.socket.sendText("service", "改模型需要远程档「完整」,这条消息仍会发出。");
|
|
3792
3795
|
else this.applyModel(agent, model, typeof effort === "string" ? effort : effort === null ? null : void 0);
|
|
3793
3796
|
} else if (effort === null || typeof effort === "string") {
|
|
@@ -3808,6 +3811,7 @@ var HappyBridge = class {
|
|
|
3808
3811
|
if (pick === void 0) return;
|
|
3809
3812
|
const published = this.lastPublished.get(dshId);
|
|
3810
3813
|
if (published === void 0 || sameCatalogPick(published, pick)) return;
|
|
3814
|
+
this.log(`手机模型选择 ${pick.model ?? ""}${pick.effort ?? ""}(上次发布 ${published.model ?? "无"}),准备应用`);
|
|
3811
3815
|
const link = this.links.get(dshId);
|
|
3812
3816
|
const agent = link === void 0 ? void 0 : this.requireAgent(link);
|
|
3813
3817
|
if (agent === void 0) return;
|
|
@@ -3885,6 +3889,7 @@ var HappyBridge = class {
|
|
|
3885
3889
|
*/
|
|
3886
3890
|
onHostModelSelected(sessionId, selection) {
|
|
3887
3891
|
if (this.hostSelectFromPhone) return;
|
|
3892
|
+
this.log(`网页选模型 ${selection.provider}/${selection.model}${selection.reasoningEffort ?? ""},同步到手机`);
|
|
3888
3893
|
const next = {
|
|
3889
3894
|
provider: selection.provider,
|
|
3890
3895
|
model: selection.model,
|
|
@@ -4174,7 +4179,10 @@ var HappyBridge = class {
|
|
|
4174
4179
|
options: [...(question.options ?? []).map((option) => ({
|
|
4175
4180
|
label: option.label,
|
|
4176
4181
|
...option.description === void 0 ? {} : { description: option.description }
|
|
4177
|
-
})), ...(question.options ?? []).length > 0 ? [{
|
|
4182
|
+
})), ...(question.options ?? []).length > 0 ? [{
|
|
4183
|
+
label: CUSTOM_ANSWER_LABEL,
|
|
4184
|
+
description: "选中并提交后,到下方聊天输入框写出你的回答"
|
|
4185
|
+
}] : []],
|
|
4178
4186
|
multiSelect: question.multiSelect === true,
|
|
4179
4187
|
allowCustom: true,
|
|
4180
4188
|
required: true
|
|
@@ -4209,7 +4217,10 @@ var HappyBridge = class {
|
|
|
4209
4217
|
options: [...(question.options ?? []).map((option) => ({
|
|
4210
4218
|
label: option.label,
|
|
4211
4219
|
description: option.description ?? ""
|
|
4212
|
-
})), {
|
|
4220
|
+
})), {
|
|
4221
|
+
label: CUSTOM_ANSWER_LABEL,
|
|
4222
|
+
description: "选中并提交后,到下方聊天输入框写出你的回答"
|
|
4223
|
+
}],
|
|
4213
4224
|
multiSelect: question.multiSelect === true
|
|
4214
4225
|
})) };
|
|
4215
4226
|
link.pendingHuman = {
|
|
@@ -4324,10 +4335,8 @@ var HappyBridge = class {
|
|
|
4324
4335
|
if (link === void 0 || pending === void 0 || pending.kind !== "ask") return;
|
|
4325
4336
|
if (pending.id !== rpc.id || pending.communication === void 0) return;
|
|
4326
4337
|
if (rpc.status !== "answered" || rpc.answers === void 0) {
|
|
4327
|
-
pending.
|
|
4328
|
-
delete link.pendingHuman;
|
|
4338
|
+
pending.deferred ??= {};
|
|
4329
4339
|
this.completeCommunication(link, rpc.id, pending.communication, "cancelled");
|
|
4330
|
-
link.socket.sendToolEnd(rpc.id);
|
|
4331
4340
|
return;
|
|
4332
4341
|
}
|
|
4333
4342
|
const deferred = {};
|
|
@@ -4339,6 +4348,7 @@ var HappyBridge = class {
|
|
|
4339
4348
|
if (wantsCustom) {
|
|
4340
4349
|
pending.deferred = deferred;
|
|
4341
4350
|
this.completeCommunication(link, rpc.id, pending.communication, "answered", rpc.answers);
|
|
4351
|
+
link.socket.sendToolStart(rpc.id, "request_user_input", pending.communication.form, "需要你回答", "已选自定义:请在下方输入框输入你的回答后发送");
|
|
4342
4352
|
link.socket.sendText("service", "已选自定义回答:请在输入框输入你的想法,直接发送即可。");
|
|
4343
4353
|
return;
|
|
4344
4354
|
}
|
|
@@ -4404,8 +4414,10 @@ var HappyBridge = class {
|
|
|
4404
4414
|
}, this.credentials.machineId, sessionLabel(events), link.agent === void 0 ? void 0 : this.currentModel(link.agent), this.config.remoteGrant);
|
|
4405
4415
|
link.socket.updateMetadata(metadata);
|
|
4406
4416
|
const pick = catalogModelPick(metadata);
|
|
4417
|
+
const previousPick = this.lastPublished.get(link.dshId);
|
|
4407
4418
|
if (pick === void 0) this.lastPublished.delete(link.dshId);
|
|
4408
4419
|
else this.lastPublished.set(link.dshId, pick);
|
|
4420
|
+
if (pick === void 0 || sameCatalogPick(previousPick, pick) === false) this.log(`发布目录:模型 ${pick?.model ?? "(无)"} 思考 ${String(pick?.effort ?? "(无)")}`);
|
|
4409
4421
|
}
|
|
4410
4422
|
pushAllMetadata() {
|
|
4411
4423
|
for (const link of this.links.values()) if (!link.parked) this.pushMetadata(link);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sjhmars/happy-bridge",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Remote-control bridge: pair a running dsh web/desktop client with the Happy mobile app by QR code, then remote-control the same harness sessions from the phone (send messages, read replies, approve tool calls, switch models)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deepseek-harness",
|