@sjhmars/happy-bridge 0.3.3 → 0.3.4

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 CHANGED
@@ -21,7 +21,7 @@
21
21
  - 新建:只能选已经在网页登记过的工作区。不会在磁盘上 mkdir。App 里「new worktree」会失败(故意不暴露 bash)。
22
22
  - 发文字:已注册 `/命令` 走命令通道;否则当聊天。`/skill名` 仍当普通消息,由 harness 注入。
23
23
  - 发图片:相册/拍照/粘贴后,会随下一条文字(也可以只发图)进同一场电脑对话,模型能看见图。`.java` / `.txt` 等普通文件会先下载到工作区 `happy-inbox/`,再走电脑原来的 `read` 工具读内容(和你在仓库里打开一个文件一样)。PDF、Word 这类不是纯文本的文件,电脑的 `read` 会拒绝,插件也不会自己拆文档。远程档至少「能聊」。输入框左边应有图片按钮;发出后电脑网页会出现图片,手机会转圈等回复。电脑网页贴的图也会按同一套加密上传推到手机。
24
- - 工具批准、计划审阅、选择题:和网页黄框/提问框赛跑,谁先点谁算。手机点「始终允许」只在这次网页进程里记住。选择题走 Happy 表单通道,每道题末尾多一个「✏️ 自定义…」选项:点它之后在输入框写出你的想法直接发送,那条文本就是这道题的答案(其他题已选的项保留);答完后卡片会显示所选内容和自定义文本。旧版 App 没有这条通道,见 `questionChannel`。提问还在等的时候,直接用输入框打字也等于自己填;审阅计划时打字会关掉审阅,这句话当普通聊天发出去。批完/拒完的卡片会停在「已批准/已拒绝」状态,按钮失效。远程档至少「能批」才能从手机点。
24
+ - 工具批准、计划审阅、选择题:和网页黄框/提问框赛跑,谁先点谁算。手机点「始终允许」只在这次网页进程里记住。选择题走 Happy 表单通道,首题末尾带一行提示「自定义回答:直接在下方聊天输入框输入并发送」——想选就点选项提交,想自由回答就直接打字发送,那条文本会作为答案并回显到卡片。旧版 App 没有这条通道,见 `questionChannel`。提问还在等的时候,直接用输入框打字也等于自己填;审阅计划时打字会关掉审阅,这句话当普通聊天发出去。批完/拒完的卡片会停在「已批准/已拒绝」状态,按钮失效。远程档至少「能批」才能从手机点。
25
25
  - 电脑正在生成时,手机可以点停止(Happy App 的 Stop)。远程档至少「能聊」。只看档点了不会停。
26
26
  - 助手回复按整段推到手机(生成中会转圈)。思考收成一行 **Think · 摘要** 的 Note 卡片,点进去看全文。工具用 Happy 认识的名字(Grep / Read / Bash),描述跟网页那一行摘要一样。Happy 没有网页同款图标。
27
27
 
@@ -74,7 +74,7 @@ pnpm dsh web --port 3080
74
74
 
75
75
  `remoteGrant`:`watch` | `chat` | `approve` | `full`。设置页下拉框会写入这份配置。会话里也可以 `/remote approve`(只改当前进程,不写设置)。档位「完整」时,手机换模型和思考强度走电脑同一条 `session.selectModel`,网页模型栏和推理等级会跟着变。电脑自己换模型和思考强度同样会写回手机。网页加了新模型后,已镜像的手机会话会重新收到完整名单。
76
76
 
77
- `questionChannel`:`communications`(默认)| `permission`。选择题走的 Happy 通道。`communications` 是 App 的表单通道:答完卡片常驻显示你选的答案,会话列表也会显示「等回答」;需要较新版 Happy App。`permission` 是旧通道:题目选项仍可见可答,答完卡片不回显。两条通道都没有内联输入框——自由回答都靠每题末尾的「✏️ 自定义…」选项 + 输入框打字(`communications` 下,零选项的题目会弹 App 全屏表单,那里有真正的输入框)。
77
+ `questionChannel`:`communications`(默认)| `permission`。选择题走的 Happy 通道。`communications` 是 App 的表单通道:答完卡片常驻显示你选的答案,会话列表也会显示「等回答」;需要较新版 Happy App。`permission` 是旧通道:题目选项仍可见可答,答完卡片不回显。两条通道都没有内联输入框——自由回答都是直接在聊天输入框打字发送(表单首题末尾有提示行;`communications` 下零选项的题目会弹 App 全屏表单,那里有真正的输入框)。
78
78
 
79
79
  ## 已知限制
80
80
 
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
- "checkbox": "l9rBEq_checkbox",
21
- "label": "l9rBEq_label",
22
20
  "status": "l9rBEq_status",
23
- "headText": "l9rBEq_headText",
24
- "button": "l9rBEq_button",
21
+ "description": "l9rBEq_description",
25
22
  "row": "l9rBEq_row",
26
- "qr": "l9rBEq_qr",
27
- "name": "l9rBEq_name",
28
- "chevron": "l9rBEq_chevron",
29
23
  "error": "l9rBEq_error",
30
24
  "header": "l9rBEq_header",
31
- "body": "l9rBEq_body",
32
- "select": "l9rBEq_select",
25
+ "checkbox": "l9rBEq_checkbox",
33
26
  "card": "l9rBEq_card",
34
- "description": "l9rBEq_description"
27
+ "body": "l9rBEq_body",
28
+ "qr": "l9rBEq_qr",
29
+ "button": "l9rBEq_button",
30
+ "headText": "l9rBEq_headText",
31
+ "name": "l9rBEq_name",
32
+ "chevron": "l9rBEq_chevron",
33
+ "label": "l9rBEq_label",
34
+ "select": "l9rBEq_select"
35
35
  };
36
36
  //#endregion
37
37
  //#region src/client/HappyBridgeCard.tsx
package/lib/index.js CHANGED
@@ -3788,9 +3788,7 @@ var HappyBridge = class {
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
+ if (model !== void 0 && publishedModel !== void 0 && sameCatalogPick({ model: publishedModel }, { model })) {} else if (model !== void 0) {
3794
3792
  if (!grantAtLeast(this.config.remoteGrant, "full")) link.socket.sendText("service", "改模型需要远程档「完整」,这条消息仍会发出。");
3795
3793
  else this.applyModel(agent, model, typeof effort === "string" ? effort : effort === null ? null : void 0);
3796
3794
  } else if (effort === null || typeof effort === "string") {
@@ -4167,22 +4165,20 @@ var HappyBridge = class {
4167
4165
  return;
4168
4166
  }
4169
4167
  const id = `ask-${createLocalId()}`;
4170
- const questions = request.questions.map((question) => ({
4168
+ const hint = "(自定义回答:直接在下方聊天输入框输入并发送)";
4169
+ const questions = request.questions.map((question, index) => ({
4171
4170
  id: question.id,
4172
- question: question.question
4171
+ question: index === 0 ? `${question.question}\n${hint}` : question.question
4173
4172
  }));
4174
4173
  if (this.config.questionChannel === "communications") {
4175
- const form = request.questions.map((question) => ({
4174
+ const form = request.questions.map((question, index) => ({
4176
4175
  id: question.id,
4177
4176
  header: question.header ?? question.question.slice(0, 24),
4178
- question: question.question,
4179
- options: [...(question.options ?? []).map((option) => ({
4177
+ question: questions[index]?.question ?? question.question,
4178
+ options: (question.options ?? []).map((option) => ({
4180
4179
  label: option.label,
4181
4180
  ...option.description === void 0 ? {} : { description: option.description }
4182
- })), ...(question.options ?? []).length > 0 ? [{
4183
- label: CUSTOM_ANSWER_LABEL,
4184
- description: "选中并提交后,到下方聊天输入框写出你的回答"
4185
- }] : []],
4181
+ })),
4186
4182
  multiSelect: question.multiSelect === true,
4187
4183
  allowCustom: true,
4188
4184
  required: true
@@ -4211,16 +4207,13 @@ var HappyBridge = class {
4211
4207
  this.pushAgentState(link);
4212
4208
  return;
4213
4209
  }
4214
- const arguments_ = { questions: request.questions.map((question) => ({
4215
- question: question.question,
4210
+ const arguments_ = { questions: request.questions.map((question, index) => ({
4211
+ question: questions[index]?.question ?? question.question,
4216
4212
  header: question.header ?? question.question.slice(0, 24),
4217
- options: [...(question.options ?? []).map((option) => ({
4213
+ options: (question.options ?? []).map((option) => ({
4218
4214
  label: option.label,
4219
4215
  description: option.description ?? ""
4220
- })), {
4221
- label: CUSTOM_ANSWER_LABEL,
4222
- description: "选中并提交后,到下方聊天输入框写出你的回答"
4223
- }],
4216
+ })),
4224
4217
  multiSelect: question.multiSelect === true
4225
4218
  })) };
4226
4219
  link.pendingHuman = {
@@ -4306,17 +4299,6 @@ var HappyBridge = class {
4306
4299
  return;
4307
4300
  }
4308
4301
  const mapped = answersFromHappy(rpc.updatedInput?.answers, pending.questions);
4309
- const deferred = {};
4310
- let wantsCustom = false;
4311
- for (const row of mapped) {
4312
- deferred[row.id] = row.selected;
4313
- if (row.selected.includes("✏️ 自定义…")) wantsCustom = true;
4314
- }
4315
- if (wantsCustom) {
4316
- pending.deferred = deferred;
4317
- link.socket.sendText("service", "已选自定义回答:请在输入框输入你的想法,直接发送即可。");
4318
- return;
4319
- }
4320
4302
  pending.resolve({ answers: mapped.map((row) => ({
4321
4303
  id: row.id,
4322
4304
  selected: row.selected
@@ -4339,19 +4321,6 @@ var HappyBridge = class {
4339
4321
  this.completeCommunication(link, rpc.id, pending.communication, "cancelled");
4340
4322
  return;
4341
4323
  }
4342
- const deferred = {};
4343
- let wantsCustom = false;
4344
- for (const [questionId, answer] of Object.entries(rpc.answers)) {
4345
- deferred[questionId] = answer.options;
4346
- if (answer.options.includes("✏️ 自定义…")) wantsCustom = true;
4347
- }
4348
- if (wantsCustom) {
4349
- pending.deferred = deferred;
4350
- this.completeCommunication(link, rpc.id, pending.communication, "answered", rpc.answers);
4351
- link.socket.sendToolStart(rpc.id, "request_user_input", pending.communication.form, "需要你回答", "已选自定义:请在下方输入框输入你的回答后发送");
4352
- link.socket.sendText("service", "已选自定义回答:请在输入框输入你的想法,直接发送即可。");
4353
- return;
4354
- }
4355
4324
  pending.resolve({ answers: answersFromCommunication(rpc.answers, pending.questions) });
4356
4325
  delete link.pendingHuman;
4357
4326
  this.completeCommunication(link, rpc.id, pending.communication, "answered", rpc.answers);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjhmars/happy-bridge",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
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",