deskbuddy 0.2.0-beta.0 → 0.2.0-beta.1

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.
Files changed (2) hide show
  1. package/dist/cli.js +50 -15
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -167,6 +167,8 @@ function write(path, content) {
167
167
  mkdirSync2(dirname(path), { recursive: true });
168
168
  writeFileSync2(path, content, "utf8");
169
169
  }
170
+ var BOOTSTRAP_RETRIES = 10;
171
+ var BOOTSTRAP_RETRY_MS = 500;
170
172
  async function installAutostart(t, platform = process.platform) {
171
173
  try {
172
174
  if (platform === "darwin") {
@@ -174,13 +176,22 @@ async function installAutostart(t, platform = process.platform) {
174
176
  write(p, launchAgentPlist(t));
175
177
  await run("launchctl", ["bootout", `gui/${process.getuid?.() ?? 501}/${LAUNCH_LABEL}`]).catch(() => {
176
178
  });
177
- await run("launchctl", ["bootstrap", `gui/${process.getuid?.() ?? 501}`, p]);
179
+ for (let i = 0; ; i++) {
180
+ try {
181
+ await run("launchctl", ["bootstrap", `gui/${process.getuid?.() ?? 501}`, p]);
182
+ break;
183
+ } catch (e) {
184
+ if (i >= BOOTSTRAP_RETRIES) throw e;
185
+ await new Promise((r) => setTimeout(r, BOOTSTRAP_RETRY_MS));
186
+ }
187
+ }
178
188
  return { ok: true, message: "\u5DF2\u8BBE\u7F6E\u5F00\u673A\u81EA\u542F\uFF08launchd\uFF09" };
179
189
  }
180
190
  if (platform === "linux") {
181
191
  write(systemdUnitPath(), systemdUnit(t));
182
192
  await run("systemctl", ["--user", "daemon-reload"]);
183
193
  await run("systemctl", ["--user", "enable", "--now", SYSTEMD_UNIT]);
194
+ await run("systemctl", ["--user", "restart", SYSTEMD_UNIT]);
184
195
  return { ok: true, message: "\u5DF2\u8BBE\u7F6E\u5F00\u673A\u81EA\u542F\uFF08systemd --user\uFF09" };
185
196
  }
186
197
  if (platform === "win32") {
@@ -992,21 +1003,21 @@ function materialize(plan, tool, d = defaultLocateDeps()) {
992
1003
  env: { ...plan.env, PATH: childPath(d) }
993
1004
  };
994
1005
  }
995
- function isDeferred(stdout6) {
1006
+ function isDeferred(stdout7) {
996
1007
  try {
997
- return JSON.parse(stdout6).stop_reason === "tool_deferred";
1008
+ return JSON.parse(stdout7).stop_reason === "tool_deferred";
998
1009
  } catch {
999
1010
  return false;
1000
1011
  }
1001
1012
  }
1002
- function parseClaudeSessionId(stdout6) {
1013
+ function parseClaudeSessionId(stdout7) {
1003
1014
  const pick = (o) => {
1004
1015
  const d = o ?? {};
1005
1016
  const v = d.session_id ?? d.sessionId;
1006
1017
  return typeof v === "string" && v ? v : null;
1007
1018
  };
1008
1019
  try {
1009
- const d = JSON.parse(stdout6);
1020
+ const d = JSON.parse(stdout7);
1010
1021
  if (Array.isArray(d)) {
1011
1022
  for (const m of d) {
1012
1023
  const id = pick(m);
@@ -1019,8 +1030,8 @@ function parseClaudeSessionId(stdout6) {
1019
1030
  return null;
1020
1031
  }
1021
1032
  }
1022
- function parseCodexSessionId(stdout6) {
1023
- for (const line of stdout6.split("\n")) {
1033
+ function parseCodexSessionId(stdout7) {
1034
+ for (const line of stdout7.split("\n")) {
1024
1035
  const t = line.trim();
1025
1036
  if (!t) continue;
1026
1037
  try {
@@ -1034,8 +1045,8 @@ function parseCodexSessionId(stdout6) {
1034
1045
  }
1035
1046
  return null;
1036
1047
  }
1037
- function parseOpencodeSessionId(stdout6) {
1038
- for (const line of stdout6.split("\n")) {
1048
+ function parseOpencodeSessionId(stdout7) {
1049
+ for (const line of stdout7.split("\n")) {
1039
1050
  const t = line.trim();
1040
1051
  if (!t) continue;
1041
1052
  try {
@@ -1048,10 +1059,10 @@ function parseOpencodeSessionId(stdout6) {
1048
1059
  }
1049
1060
  return null;
1050
1061
  }
1051
- function parseSessionId(tool, stdout6) {
1052
- if (tool === "codex") return parseCodexSessionId(stdout6);
1053
- if (tool === "opencode") return parseOpencodeSessionId(stdout6);
1054
- return parseClaudeSessionId(stdout6);
1062
+ function parseSessionId(tool, stdout7) {
1063
+ if (tool === "codex") return parseCodexSessionId(stdout7);
1064
+ if (tool === "opencode") return parseOpencodeSessionId(stdout7);
1065
+ return parseClaudeSessionId(stdout7);
1055
1066
  }
1056
1067
  function startCommand(plan, tool, limitMs = EXEC_TIMEOUT_MS) {
1057
1068
  let remaining = limitMs;
@@ -1078,10 +1089,10 @@ function startCommand(plan, tool, limitMs = EXEC_TIMEOUT_MS) {
1078
1089
  // agent 自己要读 PATH 里的东西,环境原样继承
1079
1090
  env: { ...process.env, ...plan.env }
1080
1091
  },
1081
- (err, stdout6) => {
1092
+ (err, stdout7) => {
1082
1093
  finished = true;
1083
1094
  if (timer) clearTimeout(timer);
1084
- const out = String(stdout6 ?? "");
1095
+ const out = String(stdout7 ?? "");
1085
1096
  if (err || timedOut) {
1086
1097
  const msg = timedOut ? `\u6267\u884C\u8D85\u8FC7 ${Math.round(limitMs / 1e3)} \u79D2\u6D3B\u52A8\u65F6\u95F4\uFF0C\u5DF2\u7EC8\u6B62` : err.message;
1087
1098
  resolve3({ ok: false, sessionId: parseSessionId(tool, out), stdout: out, error: msg });
@@ -3696,6 +3707,26 @@ function runStatus(opts = {}) {
3696
3707
  return 0;
3697
3708
  }
3698
3709
 
3710
+ // src/commands/update.ts
3711
+ function stdout6(line) {
3712
+ process.stdout.write(line + "\n");
3713
+ }
3714
+ async function runUpdate(opts = {}) {
3715
+ const out = opts.out ?? stdout6;
3716
+ const cfg = loadConfig();
3717
+ if (!cfg.boundAt) {
3718
+ out("\u8FD8\u6CA1\u6709\u6388\u6743\u3002\u8BF7\u5148\u8FD0\u884C\uFF1Adeskbuddy setup");
3719
+ return 1;
3720
+ }
3721
+ if (cfg.enabledTools.length === 0) {
3722
+ out("\u672C\u673A\u8FD8\u6CA1\u6709\u542F\u7528\u4EFB\u4F55\u5DE5\u5177\uFF0C\u6CA1\u4EC0\u4E48\u8981\u5347\u7EA7\u7684\u3002\u7528 deskbuddy enable <tool> \u542F\u7528");
3723
+ return 1;
3724
+ }
3725
+ out(`\u5347\u7EA7\u5230 DeskBuddy ${packageVersion()}\uFF0C\u91CD\u88C5\u5DF2\u542F\u7528\u7684\uFF1A${cfg.enabledTools.join(", ")}`);
3726
+ out("");
3727
+ return runEnable([...cfg.enabledTools], opts);
3728
+ }
3729
+
3699
3730
  // src/cli.ts
3700
3731
  var USAGE = `deskbuddy \u2014\u2014 \u628A AI \u7F16\u7801\u667A\u80FD\u4F53\u6BCF\u4E2A\u4F1A\u8BDD\u7A97\u53E3\u7684\u72B6\u6001\u540C\u6B65\u5230\u684C\u9762\u786C\u4EF6\u5C4F\u5E55
3701
3732
 
@@ -3703,6 +3734,8 @@ var USAGE = `deskbuddy \u2014\u2014 \u628A AI \u7F16\u7801\u667A\u80FD\u4F53\u6B
3703
3734
  deskbuddy setup [--api-base <url>] \u626B\u7801\u6388\u6743\uFF08--api-base \u6307\u5B9A\u7F51\u5173\u5E76\u8BB0\u4F4F\uFF0C\u9ED8\u8BA4\u751F\u4EA7\uFF09
3704
3735
  deskbuddy enable <tool[,tool]> \u5B89\u88C5\u91C7\u96C6 hook\uFF08\u5982 claude_code,codex\uFF09
3705
3736
  deskbuddy disable [tool[,tool]] \u79FB\u9664\u91C7\u96C6 hook\uFF08\u4E0D\u5E26\u53C2\u6570=\u5168\u90E8\uFF09
3737
+ deskbuddy update \u5347\u7EA7\u5230\u5F53\u524D\u8FD9\u7248\uFF1A\u91CD\u88C5\u5DF2\u542F\u7528\u5DE5\u5177\u7684 hook\u3001\u91CD\u542F daemon
3738
+ \uFF08npx deskbuddy@<\u7248\u672C> update\uFF09
3706
3739
  deskbuddy daemon [--foreground] \u5E38\u9A7B\u6536\u53D6\u8BBE\u5907\u4E0B\u53D1\u7684\u6307\u4EE4\uFF08\u5F00\u673A\u81EA\u542F\u4F1A\u81EA\u52A8\u62C9\u8D77\uFF09
3707
3740
  deskbuddy status \u770B\u91C7\u96C6\u5230\u4E86\u4EC0\u4E48\u3001\u4E0A\u62A5\u4E86\u54EA\u4E9B\u5B57\u6BB5
3708
3741
  deskbuddy logout [--yes] \u79FB\u9664 hook \u5E76\u6E05\u9664\u672C\u673A\u6570\u636E
@@ -3737,6 +3770,8 @@ async function main(argv) {
3737
3770
  return runEnable(parseTools(arg));
3738
3771
  case "disable":
3739
3772
  return runDisable(parseTools(arg));
3773
+ case "update":
3774
+ return runUpdate();
3740
3775
  case "daemon":
3741
3776
  return runDaemonCommand({ foreground: argv.includes("--foreground") || argv.includes("-f") });
3742
3777
  case "status":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deskbuddy",
3
- "version": "0.2.0-beta.0",
3
+ "version": "0.2.0-beta.1",
4
4
  "description": "把 Claude Code、Codex 等 AI 编码智能体每个会话窗口的状态,实时同步到桌面硬件屏幕",
5
5
  "keywords": [
6
6
  "ai",