@primusclaw/personal-agent 0.15.1 → 0.15.2

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/dist/index.js CHANGED
@@ -21453,10 +21453,10 @@ var terminalApprovalText = defineCatalog({
21453
21453
  endEarlierFailed: (p) => p.text ? `An earlier turn stopped with an error: ${p.text}${p.count > 1 ? ` (${String(p.count)} earlier turns did; see the terminal)` : ""}` : p.count > 1 ? `${String(p.count)} earlier turns stopped with an error; see the terminal.` : "An earlier turn stopped with an error; see the terminal.",
21454
21454
  endLatest: (p) => `Latest turn: ${p.text}`,
21455
21455
  approvalsUnavailable: "I could not reach the setting just now. Try again in a moment.",
21456
- summaryEvery: (p) => `A terminal conversation that keeps working on its own (turns another session or a schedule started) is summed up at most once every ${p.minutes} minutes; the end of a turn you started, or one that asks you something, comes at once. \`/approvals summary <minutes>|off\` changes it.`,
21457
- summaryNever: "Summaries are off: only the end of a turn you started, or one that asks you something, comes here. `/approvals summary 60` turns them back on.",
21458
- summarySet: (p) => `Done: a conversation that keeps working on its own is summed up at most once every ${p.minutes} minutes.`,
21459
- summaryOff: "Done: no more summaries; the end of a turn you started, or one that asks you something, still comes here.",
21456
+ summaryEvery: (p) => `A terminal conversation that keeps working on its own (turns another session or a schedule started) is summed up at most once every ${p.minutes} minutes; the end of a turn you started, or one that asks you something, comes at once. The reviews others asked of you are summed up the same way, in one message. \`/approvals summary <minutes>|off\` changes it.`,
21457
+ summaryNever: "Summaries are off: only the end of a turn you started, or one that asks you something, comes here, and the reviews others asked of you are not summed up (see /board). `/approvals summary 60` turns them back on.",
21458
+ summarySet: (p) => `Done: a conversation that keeps working on its own, and the reviews others asked of you, are summed up at most once every ${p.minutes} minutes.`,
21459
+ summaryOff: "Done: no more summaries, of terminal conversations or of the reviews others asked of you (see /board); the end of a turn you started, or one that asks you something, still comes here.",
21460
21460
  summaryUsage: "Use `/approvals summary <minutes>` with 15 to 1440 minutes, `/approvals summary off`, or `/approvals summary` to see it."
21461
21461
  },
21462
21462
  zh: {
@@ -21512,10 +21512,10 @@ var terminalApprovalText = defineCatalog({
21512
21512
  endEarlierFailed: (p) => p.text ? `\u65E9\u5148\u4E00\u8F6E\u51FA\u9519\u505C\u4E0B\uFF1A${p.text}${p.count > 1 ? `\uFF08\u65E9\u5148\u5171 ${String(p.count)} \u8F6E\u51FA\u9519\uFF0C\u8BE6\u89C1\u7EC8\u7AEF\uFF09` : ""}` : `\u65E9\u5148\u6709 ${String(p.count)} \u8F6E\u51FA\u9519\u505C\u4E0B\uFF0C\u8BE6\u89C1\u7EC8\u7AEF\u3002`,
21513
21513
  endLatest: (p) => `\u6700\u65B0\u4E00\u8F6E\uFF1A${p.text}`,
21514
21514
  approvalsUnavailable: "\u6682\u65F6\u8BFB\u4E0D\u5230\u8FD9\u4E2A\u8BBE\u7F6E\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5\u3002",
21515
- summaryEvery: (p) => `\u5176\u4ED6\u4F1A\u8BDD\u6216\u5B9A\u65F6\u4EFB\u52A1\u9A71\u52A8\u3001\u6301\u7EED\u5728\u8DD1\u7684\u7EC8\u7AEF\u4F1A\u8BDD\uFF0C\u6700\u591A\u6BCF ${p.minutes} \u5206\u949F\u6C47\u603B\u4E00\u6B21\uFF1B\u4F60\u81EA\u5DF1\u53D1\u8D77\u7684\u56DE\u5408\u3001\u6216\u5728\u95EE\u4F60\u7684\u56DE\u5408\uFF0C\u7ED3\u675F\u65F6\u7ACB\u5373\u63A8\u9001\u3002\u53D1 \`/approvals summary <\u5206\u949F>|off\` \u4FEE\u6539\u3002`,
21516
- summaryNever: "\u6C47\u603B\u5DF2\u5173\u95ED\uFF1A\u53EA\u63A8\u9001\u4F60\u81EA\u5DF1\u53D1\u8D77\u7684\u56DE\u5408\u3001\u6216\u5728\u95EE\u4F60\u7684\u56DE\u5408\u3002\u53D1 `/approvals summary 60` \u91CD\u65B0\u5F00\u542F\u3002",
21517
- summarySet: (p) => `\u5DF2\u8BBE\u7F6E\uFF1A\u6301\u7EED\u5DE5\u4F5C\u7684\u7EC8\u7AEF\u4F1A\u8BDD\u6700\u591A\u6BCF ${p.minutes} \u5206\u949F\u6C47\u603B\u4E00\u6B21\u3002`,
21518
- summaryOff: "\u5DF2\u5173\u95ED\u6C47\u603B\uFF1B\u4F60\u81EA\u5DF1\u53D1\u8D77\u7684\u56DE\u5408\u3001\u6216\u5728\u95EE\u4F60\u7684\u56DE\u5408\uFF0C\u7ED3\u675F\u65F6\u4ECD\u4F1A\u63A8\u9001\u3002",
21515
+ summaryEvery: (p) => `\u5176\u4ED6\u4F1A\u8BDD\u6216\u5B9A\u65F6\u4EFB\u52A1\u9A71\u52A8\u3001\u6301\u7EED\u5728\u8DD1\u7684\u7EC8\u7AEF\u4F1A\u8BDD\uFF0C\u6700\u591A\u6BCF ${p.minutes} \u5206\u949F\u6C47\u603B\u4E00\u6B21\uFF1B\u4F60\u81EA\u5DF1\u53D1\u8D77\u7684\u56DE\u5408\u3001\u6216\u5728\u95EE\u4F60\u7684\u56DE\u5408\uFF0C\u7ED3\u675F\u65F6\u7ACB\u5373\u63A8\u9001\u3002\u522B\u4EBA\u8BF7\u4F60\u4EE3\u5BA1\u7684\u8BC4\u5BA1\u540C\u7406\uFF0C\u5408\u6210\u4E00\u6761\u6C47\u603B\u3002\u53D1 \`/approvals summary <\u5206\u949F>|off\` \u4FEE\u6539\u3002`,
21516
+ summaryNever: "\u6C47\u603B\u5DF2\u5173\u95ED\uFF1A\u53EA\u63A8\u9001\u4F60\u81EA\u5DF1\u53D1\u8D77\u7684\u56DE\u5408\u3001\u6216\u5728\u95EE\u4F60\u7684\u56DE\u5408\uFF1B\u522B\u4EBA\u8BF7\u4F60\u4EE3\u5BA1\u7684\u8BC4\u5BA1\u4E5F\u4E0D\u518D\u6C47\u603B\uFF08\u7ED3\u679C\u89C1 /board\uFF09\u3002\u53D1 `/approvals summary 60` \u91CD\u65B0\u5F00\u542F\u3002",
21517
+ summarySet: (p) => `\u5DF2\u8BBE\u7F6E\uFF1A\u6301\u7EED\u5DE5\u4F5C\u7684\u7EC8\u7AEF\u4F1A\u8BDD\u3001\u4EE5\u53CA\u522B\u4EBA\u8BF7\u4F60\u4EE3\u5BA1\u7684\u8BC4\u5BA1\uFF0C\u6700\u591A\u6BCF ${p.minutes} \u5206\u949F\u6C47\u603B\u4E00\u6B21\u3002`,
21518
+ summaryOff: "\u5DF2\u5173\u95ED\u6C47\u603B\uFF08\u7EC8\u7AEF\u4F1A\u8BDD\u548C\u522B\u4EBA\u8BF7\u4F60\u4EE3\u5BA1\u7684\u8BC4\u5BA1\u90FD\u4E0D\u518D\u6C47\u603B\uFF0C\u7ED3\u679C\u89C1 /board\uFF09\uFF1B\u4F60\u81EA\u5DF1\u53D1\u8D77\u7684\u56DE\u5408\u3001\u6216\u5728\u95EE\u4F60\u7684\u56DE\u5408\uFF0C\u7ED3\u675F\u65F6\u4ECD\u4F1A\u63A8\u9001\u3002",
21519
21519
  summaryUsage: "\u7528 `/approvals summary <\u5206\u949F>`\uFF0815 \u5230 1440\uFF09\uFF0C`/approvals summary off` \u5173\u95ED\uFF0C\u53EA\u53D1 `/approvals summary` \u67E5\u770B\u5F53\u524D\u8BBE\u7F6E\u3002"
21520
21520
  }
21521
21521
  });
@@ -24913,12 +24913,6 @@ function ownItemEndText(review) {
24913
24913
  const merge = statuses.has("merged") ? "\uFF0C\u5DF2\u5408\u5165" : statuses.has("queued") ? "\uFF0C\u5DF2\u52A0\u5165\u5408\u5E76\u961F\u5217" : "\uFF0C\u6CA1\u6709\u5408\u5165";
24914
24914
  return `\u5DF2\u7ED3\u675F\uFF1A${verdict ? `\u7ED3\u8BBA\uFF1A${verdict}` : "\u5DF2\u5B8C\u6210"}${merge}`;
24915
24915
  }
24916
- function reviewerResultText(review, view7) {
24917
- const line3 = prSummaryLine(view7.prSummary);
24918
- return `${askerName(review)}\u8BF7\u4F60\u4EE3\u5BA1\u7684 ${shortName(review.pull)}\uFF1A${viewWords(view7)}\u3002${line3 ? `
24919
- ${line3}
24920
- ` : ""}\u8BE6\u60C5\u5728\u4F60\u7684\u770B\u677F\u4E0A\uFF08/board\uFF09\u3002`;
24921
- }
24922
24916
  function viewStage(view7) {
24923
24917
  if (view7.status === "queued") return "queued";
24924
24918
  if (viewFinished(view7)) return `end:${view7.status}:${view7.verdict}:${view7.merged ? "1" : "0"}`;
@@ -24935,6 +24929,11 @@ function stageVerdict(stage) {
24935
24929
  if (parts2[0] === "end") return parts2[2] ?? "";
24936
24930
  return (parts2[0] === "wait" || parts2[0] === "verdict") && parts2.length > 1 ? parts2[1] ?? "" : "";
24937
24931
  }
24932
+ function isNewsStage(stage) {
24933
+ const [kind, verdict] = stage.split(":");
24934
+ if (kind === "end" || kind === "failed" || kind === "wait") return true;
24935
+ return kind === "verdict" && (verdict === "request_changes" || verdict === "comment");
24936
+ }
24938
24937
  function foundWords(view7) {
24939
24938
  if (view7.findings === null) return "";
24940
24939
  if (view7.findings === 0) return view7.verdict ? "\uFF1B\u6CA1\u6709\u63D0\u51FA\u5F85\u6539\u7684\u95EE\u9898" : "";
@@ -25000,19 +24999,6 @@ function unfinishedText(left) {
25000
24999
  return `${who} \u7684\u4EE3\u5BA1\u8FD8\u6709 ${String(left.length)} \u4E2A\u6CA1\u6709\u7ED3\u675F\uFF0C\u7ED3\u679C\u8BF7\u770B PR\uFF1A
25001
25000
  ${left.map((e) => `- ${pullUrl(e.review.pull)}`).join("\n")}`;
25002
25001
  }
25003
- function reviewerEndedText(ended2) {
25004
- const [first] = ended2;
25005
- if (first === void 0) return "";
25006
- if (ended2.length === 1) return reviewerResultText(first[0].review, first[1]);
25007
- const lines = ended2.map(([e, v]) => {
25008
- const line3 = prSummaryLine(v.prSummary);
25009
- return `- ${shortName(e.review.pull)}\uFF1A${viewWords(v)}${line3 ? `
25010
- ${line3}` : ""}`;
25011
- });
25012
- return `${askerName(first[0].review)}\u8BF7\u4F60\u4EE3\u5BA1\u7684 ${String(ended2.length)} \u4E2A PR \u7ED3\u675F\u4E86\uFF1A
25013
- ${lines.join("\n")}
25014
- \u8BE6\u60C5\u5728\u4F60\u7684\u770B\u677F\u4E0A\uFF08/board\uFF09\u3002`;
25015
- }
25016
25002
 
25017
25003
  // packages/core/src/review/service/follow.ts
25018
25004
  var REQUESTER_VIEW_MS = 3e4;
@@ -25252,9 +25238,27 @@ var AskerFollow = class {
25252
25238
  const itemId = followedItemId(entry);
25253
25239
  if (view7.status === "queued") entry.seenQueued = true;
25254
25240
  else if (!viewFinished(view7) && (entry.seenQueued || entry.said === "queued")) await this.cards.started(itemId);
25241
+ const stage = this.holdNews(entry, view7, state);
25242
+ if (viewFinished(view7)) {
25243
+ state.open.delete(itemId);
25244
+ await this.cards.end(itemId, itemEndText(view7), view7.prSummary);
25245
+ if (stage === entry.said) this.deps.store.reviewDelegation.dropAskerFollow(itemId);
25246
+ }
25247
+ }
25248
+ /**
25249
+ * What the view's stage is to the asker: news to hold for the next message, a change they are not told (an approval not merged yet, that
25250
+ * the review started) or back to what was said. A change not told is kept as what was seen, so that a later message counts the review
25251
+ * right, and it lets go of news held from before it. Returns the stage.
25252
+ */
25253
+ holdNews(entry, view7, state) {
25254
+ const itemId = followedItemId(entry);
25255
25255
  const stage = entryStage(entry, view7);
25256
25256
  const held = state.news.get(itemId);
25257
- if (stage && stage !== entry.said) {
25257
+ if (stage && stage !== entry.said && !isNewsStage(stage)) {
25258
+ state.news.delete(itemId);
25259
+ entry.said = stage;
25260
+ this.deps.store.reviewDelegation.askerFollowSaid(itemId, stage);
25261
+ } else if (stage && stage !== entry.said) {
25258
25262
  if (held === void 0 || entryStage(entry, held[1]) !== stage) {
25259
25263
  const now = this.deps.clock.monotonicMs();
25260
25264
  state.first = state.first || now;
@@ -25264,11 +25268,7 @@ var AskerFollow = class {
25264
25268
  } else if (held !== void 0 && stage === entry.said) {
25265
25269
  state.news.delete(itemId);
25266
25270
  }
25267
- if (viewFinished(view7)) {
25268
- state.open.delete(itemId);
25269
- await this.cards.end(itemId, itemEndText(view7), view7.prSummary);
25270
- if (stage === entry.said) this.deps.store.reviewDelegation.dropAskerFollow(itemId);
25271
- }
25271
+ return stage;
25272
25272
  }
25273
25273
  /** Says the held news in one message; what is said is recorded first, and put back when the message did not go. */
25274
25274
  async flush(entries, conversation, state) {
@@ -25292,9 +25292,6 @@ var AskerFollow = class {
25292
25292
  state.first = state.last = 0;
25293
25293
  for (const [entry, view7] of told)
25294
25294
  if (viewFinished(view7)) this.deps.store.reviewDelegation.dropAskerFollow(followedItemId(entry));
25295
- const ended2 = told.filter(([, v]) => viewFinished(v));
25296
- const [one] = ended2;
25297
- if (one !== void 0) await this.notices.tellReviewer(one[0].review, reviewerEndedText(ended2));
25298
25295
  }
25299
25296
  /** A line for the asker where they asked: in a group it @mentions them (and only them). */
25300
25297
  async sayToAsker(review, conversation, text9) {
@@ -25897,7 +25894,6 @@ ${p.setting}` : "") + refused3 + p.unread + p.stop;
25897
25894
  if (review.forReviewer) {
25898
25895
  if (review.ack) await say2(this.deps, s.ctx.conversation, review.ack);
25899
25896
  followed.push(review);
25900
- await this.notices.tellReviewerStarted(review);
25901
25897
  continue;
25902
25898
  }
25903
25899
  const message = s.several ? { ...s.ctx.message, id: `${s.ctx.message.id}-${String(index + 1)}` } : s.ctx.message;
@@ -25984,7 +25980,6 @@ ${p.setting}` : "") + refused3 + p.unread + p.stop;
25984
25980
  item: started.item?.itemId ?? ""
25985
25981
  });
25986
25982
  this.follows.follow([started], s.ctx.conversation);
25987
- await this.notices.tellReviewerStarted(started);
25988
25983
  await this.postCards(s, [started]);
25989
25984
  return true;
25990
25985
  }
@@ -26058,26 +26053,6 @@ var Notices = class {
26058
26053
  reviewerChat(review) {
26059
26054
  return personalChat(this.deps, { userId: review.actorId, channelUserId: review.actorChannelId }, review.asked);
26060
26055
  }
26061
- async tellReviewer(review, text9) {
26062
- try {
26063
- const chat = await this.reviewerChat(review);
26064
- if (chat !== void 0) await say2(this.deps, chat, text9);
26065
- } catch (err2) {
26066
- this.deps.logger.warn("the reviewer could not be told about a review asked of them", { error: errorName(err2) });
26067
- }
26068
- }
26069
- /** The reviewer hears, in their own chat, that someone asked a review of them and that it is an item on their board. */
26070
- async tellReviewerStarted(review) {
26071
- const item = review.item;
26072
- const seq = item?.seq ? `\uFF08\u4E8B\u9879 #${String(item.seq)}\uFF09` : "";
26073
- const verb = review.reviewOnly ? "review\uFF08\u53EA review\uFF0C\u4E0D\u5408\u5165\uFF09" : "review \u5408\u5165";
26074
- const held = review.mergeHeld && !review.reviewOnly ? "\u5408\u5165\u524D\u4F1A\u5148\u8BF7\u4F60\u786E\u8BA4\uFF08\u5361\u7247\u6309\u94AE\u6216\u56DE\u590D\u300C\u6279\u51C6 #\u7F16\u53F7\u300D\uFF09\uFF0C\u4F60\u786E\u8BA4\u4E4B\u524D\u4E0D\u4F1A\u5408\u5165\u3002" : "";
26075
- const state = item?.queued ? `\u5DF2\u4F5C\u4E3A\u4F60\u770B\u677F\u4E0A\u7684\u4E8B\u9879\u6392\u961F${seq}\uFF08${queueReason(item.queued, "\u4F60", askerName(review), true)}\uFF09\uFF0C\u540D\u989D\u7A7A\u51FA\u540E\u4F1A\u81EA\u52A8\u5F00\u59CB` : `\u5DF2\u4F5C\u4E3A\u4F60\u770B\u677F\u4E0A\u7684\u4E8B\u9879\u5F00\u59CB${seq}`;
26076
- await this.tellReviewer(
26077
- review,
26078
- `${askerName(review)}\u5728${review.where}\u8BF7\u4F60\u4EE3 ${verb} ${shortName(review.pull)}\uFF0C${state}\uFF0C\u7528\u4F60\u7684 GitHub \u8D26\u53F7\u548C\u4F60\u7684\u6A21\u578B\u989D\u5EA6\u3002${held}\u53D1 /board \u67E5\u770B\u6216\u505C\u6B62\u3002`
26079
- );
26080
- }
26081
26056
  /** The reviewer's item as Claw shows it to them, read with their own key; undefined when it cannot be. */
26082
26057
  async reviewersItem(review) {
26083
26058
  const key = review.item ? this.deps.store.links.getKey(review.actorId) : null;
@@ -28354,178 +28329,616 @@ function hiddenOf(agent) {
28354
28329
 
28355
28330
  // packages/core/src/remote/events.ts
28356
28331
  import { z as z8 } from "zod";
28357
- var DIALOG_MAX = 120;
28358
- var NOTHING2 = Object.freeze({
28359
- chunk: null,
28360
- tool: null,
28361
- plan: null,
28362
- permission: null,
28363
- resolved: null,
28364
- mode: null,
28365
- modes: null,
28366
- unattended: null,
28367
- modeFlags: null,
28368
- note: null,
28369
- started: false,
28370
- finished: false,
28371
- endsSeq: null,
28372
- stopReason: "",
28373
- closed: null,
28374
- rejected: null,
28375
- replay: false,
28376
- readOnly: null,
28377
- recovered: null,
28378
- queued: null,
28379
- dialog: null,
28380
- waitLine: null,
28381
- rowUnreadable: false,
28382
- queuedFor: null,
28383
- queuedSeq: null,
28384
- queuedHeld: false,
28385
- typed: null,
28386
- terminal: null,
28387
- terminalMode: null,
28388
- acp: null
28332
+
28333
+ // packages/core/src/locales/connector-reasons.ts
28334
+ var connectorReasonText = defineCatalog({
28335
+ en: {
28336
+ mode_unavailable: 'The agent on that machine does not offer the permission mode this session needs. Most often the connector runs as root and the agent has `approval = "never"`: Claude offers no bypassPermissions mode to root, so a connector older than 0.1.5 refuses the session.',
28337
+ mode_not_enforced: 'The agent could not be put in the permission mode the connector requires (or warned it will no longer ask), so the connector closed the session to stay safe. This happens with Claude running as root (older connectors), or when Claude\'s `permissions.defaultMode` is bypassPermissions and the agent has no `approval = "never"`.',
28338
+ mode_not_confirmed: "The agent did not confirm the permission mode it was asked for, so the connector closed the session to stay safe. Upgrade the connector (it brings a newer agent adapter) and try again.",
28339
+ mode_mismatch: "The agent reported a different permission mode from the one it was asked for, so the connector closed the session to stay safe. Upgrade the connector and try again; if it persists, check Claude's settings there.",
28340
+ mode_not_allowed: 'That mode does not ask before each step, and the agent is not allowed to run that way on that machine. To allow it, set `approval = "never"` on the agent in agents.toml and restart the connector; otherwise pick a mode that asks.',
28341
+ mode_id_required: "The mode switch named no mode. Tap Mode and pick one again.",
28342
+ set_mode_failed: "The agent could not switch its mode; it keeps the one it had.",
28343
+ adapter_gone: "The agent program on that machine has exited.",
28344
+ adapter_start_failed: "The connector could not start the agent program on that machine (often: no access to the npm registry, or the command is missing). Run `claw-connector status` there and look at `run.log` in its state directory.",
28345
+ adapter_unavailable: "The connector could not start the agent program for this turn.",
28346
+ adapter_protocol: "The agent program answered in a way the connector does not expect, most likely a version mismatch. Upgrade the connector and try again.",
28347
+ adapter_cannot_resume: "This agent cannot pick up the earlier conversation.",
28348
+ adapter_error: "The agent program failed. Look at `run.log` in the connector's state directory on that machine.",
28349
+ agent_auth_required: "The agent is not signed in on that machine. Run the agent there once (`claude`, for example) to sign in, then try again.",
28350
+ cwd_outside_roots: "That directory is outside the roots the agent may work in. Pick one inside them, or add it to `roots` in agents.toml and restart the connector.",
28351
+ cwd_not_found: "That folder does not exist on that machine: pick one that exists there, or create it there first.",
28352
+ cwd_not_directory: "That path is not a directory.",
28353
+ cwd_not_absolute: "The directory must be an absolute path (starting with /).",
28354
+ invalid_cwd: "That directory name is not valid.",
28355
+ cwd_mismatch: "That conversation is not in this directory. Pick it again from the list.",
28356
+ unknown_agent: "That machine has no such agent (agents.toml may have changed). Check agents.toml there and restart the connector after a change.",
28357
+ not_delivered: "The machine never got it, so nothing ran: it looked online when it was sent but had gone (a laptop closed, for one). Send it again once the machine is back.",
28358
+ delivery_unconfirmed: "The machine went just as this was sent and did not confirm it got it, so it may not have run. If it does once the machine is back, what it says shows up here.",
28359
+ connector_revoked: "That machine's connector was signed out (logout or `/agent off`), and its sessions closed with it. To go on, sign the connector in again there and start a new session.",
28360
+ machine_reconnected: "That machine registered again (a reinstall, lost local state or a rebuilt container), and the old session closed with its old registration.",
28361
+ unknown_session: "The connector no longer knows this session (it may have restarted).",
28362
+ too_many_sessions: "Too many sessions are open on that machine. Close one with `/agent close` first.",
28363
+ resume_not_supported: "This agent cannot continue an existing session.",
28364
+ attach_unavailable: "This agent cannot take over a terminal conversation. Configure an agent with the `claude-attach` preset for that.",
28365
+ resume_ref_required: "No conversation was named to take over. Pick one from the list.",
28366
+ invalid_resume_ref: "That conversation reference is not valid. Pick one from the list.",
28367
+ already_attached: "That conversation is already open from the phone. Switch to it with `/agent sessions`.",
28368
+ catalog_unavailable: "The connector could not read the list of conversations on that machine.",
28369
+ session_live: "That conversation is still open in a terminal on that machine. Quit it there first, then take it over.",
28370
+ recently_written: "A terminal wrote to that conversation moments ago and may still be using it. Try again in {wait}.",
28371
+ twin_check_failed: "The connector could not check whether the conversation is still open in a terminal, so it did not take it over.",
28372
+ terminal_did_not_exit: "The terminal did not let the conversation go when asked, so it was not taken over; it is still there. Quit it in the terminal first, then take it over.",
28373
+ session_live_elsewhere: "That conversation is open on another machine or container sharing the Claude config directory; it cannot be ended from here, so it was not taken over. Quit it there, then try again.",
28374
+ takeover_not_permitted: "The terminal holding the conversation belongs to another user, so the connector may not end it; it was not taken over.",
28375
+ takeover_failed: "Ending the terminal's hold on the conversation failed, so it was not taken over.",
28376
+ // (since connector 0.1.19 a running turn never holds a message back: Claude Code queues it; only someone's half-typed text in
28377
+ // the box, or a screen scrolled back, held for 10 minutes ends it terminal_busy)
28378
+ terminal_busy: "Someone was typing in the terminal (or had it scrolled back) for 10 minutes, so the message was not typed in. Send it again later.",
28379
+ // (Claude Code took the message into its own queue, then someone at the terminal pulled that queue back into the box)
28380
+ terminal_input_withdrawn: "The message was in Claude Code's queue in the terminal, but someone there pulled the queue back into the input box (up-arrow to edit), so it was not sent as the phone's message; it is now in the terminal's input box. To send it, press Enter in the terminal, or send it again from the phone.",
28381
+ // (a terminal whose Claude Code cannot be told to hold this conversation, for 10 minutes)
28382
+ terminal_state_unknown: "For 10 minutes the connector could not confirm that the terminal's Claude Code still has this conversation open, so the message was not typed in. Look at the terminal, make sure it is still on this conversation, and send again.",
28383
+ terminal_gone: "The terminal's tmux pane is gone, so the message was not typed in.",
28384
+ terminal_switched: "That terminal has moved to another conversation (a /resume or /clear there), so the message was not typed in.",
28385
+ terminal_input_failed: "Typing the message into the terminal failed; it was not sent.",
28386
+ // (a connector after 0.1.22: the paste never showed in the box in the 20 seconds it waited)
28387
+ terminal_input_unseen: "The message was typed into the terminal, but the terminal did not show it for 20 seconds (Claude Code there is busy or not taking input), so nothing was sent. Send it again in a moment.",
28388
+ // (not a failure: the terminal may well have taken it; what the session does next still shows here)
28389
+ terminal_input_unconfirmed: "The message was typed into the terminal, but its transcript did not show it within 20 seconds, so it is not known whether the session took it. Whatever the session answers still shows here. Look at the terminal before you send it again, so it does not run twice.",
28390
+ terminal_input_unavailable: "After a restart the connector could not prove that terminal again, so the message was not typed in. Attach again.",
28391
+ empty_prompt: "The message was empty once its control characters were removed; nothing was typed.",
28392
+ // (a prompt to a session that only watches a terminal's conversation; also a turn_end error)
28393
+ read_only_live_session: "That conversation is open in a terminal on that machine and can only be watched from here, so the message was not sent. Type it in the terminal, or take the conversation over first.",
28394
+ terminal_session: "That conversation is open in a terminal, which keeps its own mode.",
28395
+ terminal_mode_not_allowed: "The terminal's conversation is in a permission mode that does not ask (auto, for example), which this agent's approval setting does not allow from the phone, so the message was not typed in. Switch the terminal to a mode that asks (shift+tab in Claude Code: manual or plan) and send again, or set `approval = \"never\"` for this agent in agents.toml on that machine.",
28396
+ terminal_mode_unknown: "The connector could not read which permission mode the terminal's conversation is in, so nothing was typed. Make sure Claude Code there is up to date and shows its mode below the input box, then send again.",
28397
+ terminal_screen_unknown: "The connector could not read the terminal's screen for 30 seconds (no Claude Code input box, and it did not say it was busy), so the message was not typed in. Look at the terminal, close whatever is on it, and send again.",
28398
+ terminal_command_refused: "A message that starts with ! or / would run a command in that terminal, so it is not typed from the phone. Rephrase it, or run the command at the terminal.",
28399
+ takeover_expired: "The confirmation to take that conversation over reached the machine too late; it was not taken over. Open it again and confirm again.",
28400
+ cwd_ambiguous: "More than one of this agent's roots has a folder by that name. Give its full path.",
28401
+ root_unavailable: "The folder's disk is not answering on that machine (a network mount that is down or not mounted yet). Try again in a minute, or check the mount there.",
28402
+ session_closed: "That session has already closed.",
28403
+ closed: "The session was closed as asked.",
28404
+ stopped: "The connector on that machine was stopped. Start it again there (`claw-connector run`, or the service's `sh keepalive.sh`).",
28405
+ paused: "The connector on that machine is paused. Run `claw-connector resume` there.",
28406
+ revoked: "That machine's connector was revoked. Run `{login}` there to sign in again.",
28407
+ text_required: "The message to the agent was empty.",
28408
+ action_and_option_required: "That answer named no request or option. Tap the card again.",
28409
+ too_many_queued_prompts: "The agent has too many messages waiting; this one was not taken. Send it again when it has caught up.",
28410
+ cancelled: "That message was dropped unrun when the agent was stopped.",
28411
+ unknown_action: "That approval request is gone.",
28412
+ option_not_offered: "That option is not one the agent offered."
28413
+ },
28414
+ zh: {
28415
+ mode_unavailable: '\u90A3\u53F0\u673A\u5668\u4E0A\u7684 agent \u4E0D\u63D0\u4F9B\u8FD9\u4E2A\u4F1A\u8BDD\u9700\u8981\u7684\u6743\u9650\u6A21\u5F0F\u3002\u6700\u5E38\u89C1\u7684\u539F\u56E0\uFF1A\u8FDE\u63A5\u5668\u4EE5 root \u8FD0\u884C\u4E14\u8BE5 agent \u8BBE\u4E86 `approval = "never"`\uFF0Croot \u4E0B\u7684 Claude \u4E0D\u63D0\u4F9B bypassPermissions\uFF0C\u65E7\u7248\u8FDE\u63A5\u5668\uFF080.1.5 \u4E4B\u524D\uFF09\u56E0\u6B64\u62D2\u7EDD\u5F00\u4F1A\u8BDD\u3002',
28416
+ mode_not_enforced: 'agent \u6CA1\u80FD\u5207\u5230\u8FDE\u63A5\u5668\u8981\u6C42\u7684\u6743\u9650\u6A21\u5F0F\uFF08\u6216\u63D0\u793A\u5B83\u4E0D\u4F1A\u518D\u9010\u6B65\u8BE2\u95EE\uFF09\uFF0C\u8FDE\u63A5\u5668\u4E3A\u5B89\u5168\u8D77\u89C1\u5173\u95ED\u4E86\u4F1A\u8BDD\u3002\u5E38\u89C1\u4E8E root \u4E0B\u7684 Claude \uFF08\u65E7\u7248\u8FDE\u63A5\u5668\uFF09\uFF0C\u6216 Claude \u7684 `permissions.defaultMode` \u662F bypassPermissions \u800C\u8BE5 agent \u6CA1\u8BBE `approval = "never"`\u3002',
28417
+ mode_not_confirmed: "agent \u6CA1\u6709\u786E\u8BA4\u5B83\u5DF2\u5207\u5230\u8981\u6C42\u7684\u6743\u9650\u6A21\u5F0F\uFF0C\u8FDE\u63A5\u5668\u4E3A\u5B89\u5168\u8D77\u89C1\u5173\u95ED\u4E86\u4F1A\u8BDD\u3002\u5347\u7EA7\u8FDE\u63A5\u5668\uFF08\u4F1A\u5E26\u4E0A\u8F83\u65B0\u7684 agent \u9002\u914D\u5668\uFF09\u540E\u518D\u8BD5\u3002",
28418
+ mode_mismatch: "agent \u62A5\u544A\u7684\u6743\u9650\u6A21\u5F0F\u548C\u8981\u6C42\u7684\u4E0D\u4E00\u81F4\uFF0C\u8FDE\u63A5\u5668\u4E3A\u5B89\u5168\u8D77\u89C1\u5173\u95ED\u4E86\u4F1A\u8BDD\u3002\u5347\u7EA7\u8FDE\u63A5\u5668\u540E\u518D\u8BD5\uFF1B\u4ECD\u7136\u51FA\u73B0\u7684\u8BDD\uFF0C\u68C0\u67E5\u90A3\u53F0\u673A\u5668\u4E0A Claude \u7684\u8BBE\u7F6E\u3002",
28419
+ mode_not_allowed: '\u8FD9\u4E2A\u6A21\u5F0F\u4E0D\u9010\u6B65\u8BE2\u95EE\u6743\u9650\uFF0C\u800C\u8BE5 agent \u5728\u90A3\u53F0\u673A\u5668\u4E0A\u6CA1\u6709\u88AB\u5141\u8BB8\u8FD9\u6837\u8FD0\u884C\u3002\u8981\u5141\u8BB8\uFF0C\u5728 agents.toml \u91CC\u7ED9\u8BE5 agent \u8BBE `approval = "never"` \u5E76\u91CD\u542F\u8FDE\u63A5\u5668\uFF1B\u5426\u5219\u8BF7\u9009\u4E00\u4E2A\u4F1A\u8BE2\u95EE\u7684\u6A21\u5F0F\u3002',
28420
+ mode_id_required: "\u5207\u6362\u6A21\u5F0F\u7684\u8BF7\u6C42\u91CC\u7F3A\u5C11\u6A21\u5F0F\u540D\u3002\u70B9\u300C\u6A21\u5F0F\u300D\u518D\u9009\u4E00\u6B21\u3002",
28421
+ set_mode_failed: "agent \u6CA1\u80FD\u5207\u6362\u6A21\u5F0F\uFF0C\u4ECD\u662F\u539F\u6765\u7684\u6A21\u5F0F\u3002",
28422
+ adapter_gone: "\u90A3\u53F0\u673A\u5668\u4E0A\u7684 agent \u7A0B\u5E8F\u5DF2\u7ECF\u9000\u51FA\u4E86\u3002",
28423
+ adapter_start_failed: "\u8FDE\u63A5\u5668\u6CA1\u80FD\u5728\u90A3\u53F0\u673A\u5668\u4E0A\u542F\u52A8 agent \u7A0B\u5E8F\uFF08\u5E38\u89C1\u539F\u56E0\uFF1A\u8BBF\u95EE\u4E0D\u4E86 npm \u4ED3\u5E93\u3001\u547D\u4EE4\u4E0D\u5B58\u5728\uFF09\u3002\u5728\u90A3\u53F0\u673A\u5668\u4E0A\u8FD0\u884C `claw-connector status`\uFF0C\u5E76\u770B\u72B6\u6001\u76EE\u5F55\u91CC\u7684 `run.log`\u3002",
28424
+ adapter_unavailable: "\u8FDE\u63A5\u5668\u6CA1\u80FD\u4E3A\u8FD9\u4E00\u8F6E\u542F\u52A8 agent \u7A0B\u5E8F\u3002",
28425
+ adapter_protocol: "agent \u7A0B\u5E8F\u7684\u5E94\u7B54\u548C\u8FDE\u63A5\u5668\u9884\u671F\u7684\u4E0D\u4E00\u81F4\uFF0C\u591A\u534A\u662F\u7248\u672C\u4E0D\u5339\u914D\u3002\u5347\u7EA7\u8FDE\u63A5\u5668\u540E\u518D\u8BD5\u3002",
28426
+ adapter_cannot_resume: "\u8FD9\u4E2A agent \u4E0D\u80FD\u63A5\u7740\u4E4B\u524D\u7684\u5BF9\u8BDD\u7EE7\u7EED\u3002",
28427
+ adapter_error: "agent \u7A0B\u5E8F\u62A5\u9519\u4E86\u3002\u5728\u90A3\u53F0\u673A\u5668\u4E0A\u770B\u8FDE\u63A5\u5668\u72B6\u6001\u76EE\u5F55\u91CC\u7684 `run.log`\u3002",
28428
+ agent_auth_required: "\u90A3\u53F0\u673A\u5668\u4E0A\u7684 agent \u8FD8\u6CA1\u767B\u5F55\u3002\u5728\u90A3\u53F0\u673A\u5668\u4E0A\u8FD0\u884C\u4E00\u6B21 agent\uFF08\u4F8B\u5982 `claude`\uFF09\u5B8C\u6210\u767B\u5F55\uFF0C\u518D\u8BD5\u3002",
28429
+ cwd_outside_roots: "\u8FD9\u4E2A\u76EE\u5F55\u4E0D\u5728\u8BE5 agent \u5141\u8BB8\u7684 roots \u91CC\u3002\u6362\u4E00\u4E2A roots \u91CC\u7684\u76EE\u5F55\uFF0C\u6216\u5728 agents.toml \u7684 `roots` \u91CC\u52A0\u4E0A\u5B83\u5E76\u91CD\u542F\u8FDE\u63A5\u5668\u3002",
28430
+ cwd_not_found: "\u90A3\u53F0\u673A\u5668\u4E0A\u6CA1\u6709\u8FD9\u4E2A\u76EE\u5F55\uFF1A\u9009\u4E00\u4E2A\u90A3\u91CC\u5DF2\u6709\u7684\u76EE\u5F55\uFF0C\u6216\u8005\u5148\u5728\u90A3\u53F0\u673A\u5668\u4E0A\u5EFA\u597D\u5B83\u3002",
28431
+ cwd_not_directory: "\u8FD9\u4E2A\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55\u3002",
28432
+ cwd_not_absolute: "\u76EE\u5F55\u8981\u5199\u6210\u7EDD\u5BF9\u8DEF\u5F84\uFF08\u4EE5 / \u5F00\u5934\uFF09\u3002",
28433
+ invalid_cwd: "\u8FD9\u4E2A\u76EE\u5F55\u540D\u65E0\u6548\uFF0C\u6362\u4E00\u4E2A\u76EE\u5F55\u518D\u8BD5\u3002",
28434
+ cwd_mismatch: "\u6240\u9009\u5BF9\u8BDD\u4E0D\u5728\u8FD9\u4E2A\u76EE\u5F55\u91CC\u3002\u4ECE\u5217\u8868\u91CC\u91CD\u65B0\u9009\u3002",
28435
+ unknown_agent: "\u90A3\u53F0\u673A\u5668\u4E0A\u6CA1\u6709\u8FD9\u4E2A agent\uFF08agents.toml \u53EF\u80FD\u6539\u8FC7\uFF09\u3002\u5728\u90A3\u53F0\u673A\u5668\u4E0A\u68C0\u67E5 agents.toml\uFF0C\u6539\u540E\u91CD\u542F\u8FDE\u63A5\u5668\u3002",
28436
+ not_delivered: "\u90A3\u53F0\u673A\u5668\u6CA1\u6536\u5230\uFF0C\u4EC0\u4E48\u90FD\u6CA1\u6267\u884C\uFF1A\u53D1\u51FA\u65F6\u5B83\u770B\u8D77\u6765\u5728\u7EBF\uFF0C\u4F46\u5DF2\u7ECF\u65AD\u5F00\uFF08\u6BD4\u5982\u7B14\u8BB0\u672C\u5408\u76D6\u4E86\uFF09\u3002\u7B49\u5B83\u91CD\u65B0\u8FDE\u4E0A\u540E\u518D\u53D1\u4E00\u6B21\u3002",
28437
+ delivery_unconfirmed: "\u90A3\u53F0\u673A\u5668\u5728\u8FD9\u6761\u6D88\u606F\u53D1\u51FA\u524D\u540E\u65AD\u5F00\u4E86\uFF0C\u6CA1\u6709\u786E\u8BA4\u6536\u5230\uFF0C\u53EF\u80FD\u6CA1\u6709\u6267\u884C\u3002\u5B83\u91CD\u65B0\u8FDE\u4E0A\u540E\u5982\u679C\u505A\u4E86\uFF0C\u7ED3\u679C\u4F1A\u51FA\u73B0\u5728\u8FD9\u91CC\u3002",
28438
+ connector_revoked: "\u90A3\u53F0\u673A\u5668\u7684\u8FDE\u63A5\u5668\u5DF2\u88AB\u6CE8\u9500\uFF08logout \u6216 `/agent off`\uFF09\uFF0C\u5B83\u4E0A\u9762\u7684\u4F1A\u8BDD\u968F\u4E4B\u5173\u95ED\u3002\u8981\u7EE7\u7EED\uFF0C\u5728\u90A3\u53F0\u673A\u5668\u4E0A\u91CD\u65B0\u767B\u5F55\u8FDE\u63A5\u5668\uFF0C\u518D\u5F00\u65B0\u4F1A\u8BDD\u3002",
28439
+ machine_reconnected: "\u90A3\u53F0\u673A\u5668\u91CD\u65B0\u6CE8\u518C\u8FC7\uFF08\u91CD\u88C5\u3001\u4E22\u4E86\u672C\u5730\u72B6\u6001\u6216\u91CD\u5EFA\u4E86\u5BB9\u5668\uFF09\uFF0C\u65E7\u4F1A\u8BDD\u968F\u65E7\u6CE8\u518C\u5173\u95ED\u4E86\u3002",
28440
+ unknown_session: "\u8FDE\u63A5\u5668\u4E0D\u8BA4\u8BC6\u8FD9\u4E2A\u4F1A\u8BDD\u4E86\uFF08\u53EF\u80FD\u5DF2\u91CD\u542F\u6216\u6E05\u7406\u8FC7\uFF09\u3002",
28441
+ too_many_sessions: "\u90A3\u53F0\u673A\u5668\u4E0A\u540C\u65F6\u5F00\u7740\u7684\u4F1A\u8BDD\u592A\u591A\u4E86\u3002\u5148\u7528 `/agent close` \u5173\u6389\u4E00\u4E2A\u3002",
28442
+ resume_not_supported: "\u8FD9\u4E2A agent \u4E0D\u652F\u6301\u63A5\u7740\u5DF2\u6709\u7684\u4F1A\u8BDD\u7EE7\u7EED\u3002",
28443
+ attach_unavailable: "\u8FD9\u4E2A agent \u4E0D\u652F\u6301\u63A5\u7BA1\u7EC8\u7AEF\u91CC\u7684\u5BF9\u8BDD\u3002\u8981\u63A5\u7BA1\uFF0C\u8BF7\u7528 `claude-attach` \u9884\u8BBE\u914D\u7F6E\u4E00\u4E2A agent\u3002",
28444
+ resume_ref_required: "\u6CA1\u6709\u6307\u660E\u8981\u63A5\u7BA1\u54EA\u6BB5\u5BF9\u8BDD\u3002\u4ECE\u5217\u8868\u91CC\u91CD\u65B0\u9009\u3002",
28445
+ invalid_resume_ref: "\u8981\u63A5\u7BA1\u7684\u5BF9\u8BDD\u7F16\u53F7\u65E0\u6548\u3002\u4ECE\u5217\u8868\u91CC\u91CD\u65B0\u9009\u3002",
28446
+ already_attached: "\u8FD9\u6BB5\u5BF9\u8BDD\u5DF2\u7ECF\u5728\u624B\u673A\u4E0A\u6253\u5F00\u4E86\u3002\u7528 `/agent sessions` \u5207\u8FC7\u53BB\u3002",
28447
+ catalog_unavailable: "\u8FDE\u63A5\u5668\u6682\u65F6\u8BFB\u4E0D\u5230\u90A3\u53F0\u673A\u5668\u4E0A\u7684\u5BF9\u8BDD\u5217\u8868\u3002",
28448
+ session_live: "\u8FD9\u6BB5\u5BF9\u8BDD\u8FD8\u5728\u90A3\u53F0\u673A\u5668\u7684\u7EC8\u7AEF\u91CC\u5F00\u7740\u3002\u5148\u5728\u7EC8\u7AEF\u91CC\u9000\u51FA\u5B83\uFF0C\u518D\u63A5\u7BA1\u3002",
28449
+ recently_written: "\u7EC8\u7AEF\u521A\u5199\u8FC7\u8FD9\u6BB5\u5BF9\u8BDD\uFF0C\u53EF\u80FD\u8FD8\u5728\u7528\u3002\u8FC7 {wait}\u518D\u8BD5\u3002",
28450
+ twin_check_failed: "\u8FDE\u63A5\u5668\u6CA1\u80FD\u786E\u8BA4\u8FD9\u6BB5\u5BF9\u8BDD\u662F\u5426\u8FD8\u5728\u7EC8\u7AEF\u91CC\u5F00\u7740\uFF0C\u4E3A\u5B89\u5168\u8D77\u89C1\u6CA1\u6709\u63A5\u7BA1\u3002",
28451
+ terminal_did_not_exit: "\u7EC8\u7AEF\u91CC\u7684\u8FD9\u6BB5\u5BF9\u8BDD\u6CA1\u6709\u6309\u8981\u6C42\u9000\u51FA\uFF0C\u6240\u4EE5\u6CA1\u6709\u63A5\u7BA1\uFF0C\u5B83\u8FD8\u5728\u7EC8\u7AEF\u91CC\u3002\u5148\u5728\u7EC8\u7AEF\u91CC\u9000\u51FA\u5B83\uFF0C\u518D\u63A5\u7BA1\u3002",
28452
+ session_live_elsewhere: "\u8FD9\u6BB5\u5BF9\u8BDD\u5F00\u5728\u53E6\u4E00\u53F0\u673A\u5668\u6216\u5BB9\u5668\u91CC\uFF08\u5171\u7528\u540C\u4E00\u4E2A Claude \u914D\u7F6E\u76EE\u5F55\uFF09\uFF0C\u8FD9\u91CC\u7ED3\u675F\u4E0D\u4E86\u5B83\uFF0C\u6240\u4EE5\u6CA1\u6709\u63A5\u7BA1\u3002\u5728\u90A3\u8FB9\u9000\u51FA\u5B83\u518D\u8BD5\u3002",
28453
+ takeover_not_permitted: "\u7EC8\u7AEF\u91CC\u7684\u8FD9\u6BB5\u5BF9\u8BDD\u5C5E\u4E8E\u53E6\u4E00\u4E2A\u7CFB\u7EDF\u7528\u6237\uFF0C\u8FDE\u63A5\u5668\u65E0\u6743\u7ED3\u675F\u5B83\uFF0C\u6240\u4EE5\u6CA1\u6709\u63A5\u7BA1\u3002",
28454
+ takeover_failed: "\u7ED3\u675F\u7EC8\u7AEF\u91CC\u7684\u8FD9\u6BB5\u5BF9\u8BDD\u5931\u8D25\u4E86\uFF0C\u6240\u4EE5\u6CA1\u6709\u63A5\u7BA1\u3002",
28455
+ terminal_busy: "\u7EC8\u7AEF\u91CC\u6709\u4EBA\u5728\u8F93\u5165\uFF08\u6216\u6B63\u5728\u56DE\u6EDA\u67E5\u770B\uFF09\uFF0C\u7B49\u4E86 10 \u5206\u949F\u4E5F\u6CA1\u7A7A\u51FA\u6765\uFF0C\u8FD9\u6761\u6D88\u606F\u6CA1\u6709\u53D1\u8FDB\u53BB\u3002\u7A0D\u540E\u518D\u53D1\u3002",
28456
+ terminal_input_withdrawn: "\u8FD9\u6761\u6D88\u606F\u5DF2\u7ECF\u6392\u8FDB\u7EC8\u7AEF\u91CC Claude Code \u7684\u961F\u5217\uFF0C\u4F46\u540E\u6765\u7EC8\u7AEF\u91CC\u6709\u4EBA\u628A\u961F\u5217\u62C9\u56DE\u4E86\u8F93\u5165\u6846\uFF08\u6309\u4E86\u4E0A\u952E\u7F16\u8F91\uFF09\uFF0C\u6240\u4EE5\u5B83\u6CA1\u6709\u4F5C\u4E3A\u624B\u673A\u6D88\u606F\u53D1\u51FA\uFF0C\u73B0\u5728\u5728\u7EC8\u7AEF\u7684\u8F93\u5165\u6846\u91CC\u3002\u8981\u53D1\uFF0C\u8BF7\u5728\u7EC8\u7AEF\u91CC\u56DE\u8F66\uFF0C\u6216\u4ECE\u624B\u673A\u91CD\u53D1\u3002",
28457
+ terminal_state_unknown: "\u8FDE\u63A5\u5668 10 \u5206\u949F\u5185\u90FD\u6CA1\u6CD5\u786E\u8BA4\u90A3\u4E2A\u7EC8\u7AEF\u91CC\u7684 Claude Code \u8FD8\u5F00\u7740\u8FD9\u6BB5\u5BF9\u8BDD\uFF0C\u8FD9\u6761\u6D88\u606F\u6CA1\u6709\u53D1\u8FDB\u53BB\u3002\u770B\u4E00\u773C\u7EC8\u7AEF\uFF0C\u786E\u8BA4\u5B83\u8FD8\u5728\u8FD9\u6BB5\u5BF9\u8BDD\u91CC\uFF0C\u518D\u53D1\u4E00\u6B21\u3002",
28458
+ terminal_gone: "\u7EC8\u7AEF\u90A3\u8FB9\u7684 tmux \u7A97\u683C\u5DF2\u7ECF\u6CA1\u4E86\uFF0C\u8FD9\u6761\u6D88\u606F\u6CA1\u6709\u53D1\u8FDB\u53BB\u3002",
28459
+ terminal_switched: "\u90A3\u4E2A\u7EC8\u7AEF\u5DF2\u7ECF\u6362\u5230\u53E6\u4E00\u6BB5\u5BF9\u8BDD\u4E86\uFF08\u5728\u7EC8\u7AEF\u91CC /resume \u6216 /clear \u8FC7\uFF09\uFF0C\u8FD9\u6761\u6D88\u606F\u6CA1\u6709\u53D1\u8FDB\u53BB\u3002",
28460
+ terminal_input_failed: "\u5F80\u7EC8\u7AEF\u91CC\u8F93\u5165\u8FD9\u6761\u6D88\u606F\u5931\u8D25\u4E86\uFF0C\u6CA1\u6709\u53D1\u8FDB\u53BB\u3002",
28461
+ terminal_input_unseen: "\u8FD9\u6761\u6D88\u606F\u8F93\u8FDB\u7EC8\u7AEF\u540E\uFF0C\u7B49\u4E86 20 \u79D2\u7EC8\u7AEF\u90FD\u6CA1\u6709\u663E\u793A\u5B83\uFF08\u90A3\u8FB9\u7684 Claude Code \u6B63\u5FD9\u6216\u6CA1\u5728\u63A5\u6536\u8F93\u5165\uFF09\uFF0C\u6240\u4EE5\u6CA1\u6709\u53D1\u51FA\u53BB\u3002\u7A0D\u540E\u518D\u53D1\u4E00\u6B21\u3002",
28462
+ terminal_input_unconfirmed: "\u6D88\u606F\u5DF2\u7ECF\u8F93\u5165\u7EC8\u7AEF\uFF0C\u4F46 20 \u79D2\u5185\u7EC8\u7AEF\u7684\u5BF9\u8BDD\u8BB0\u5F55\u91CC\u8FD8\u6CA1\u770B\u5230\u5B83\uFF0C\u6682\u65F6\u4E0D\u80FD\u786E\u8BA4\u90A3\u8FB9\u5DF2\u7ECF\u6536\u5230\u3002\u90A3\u8FB9\u4E4B\u540E\u7684\u56DE\u590D\u4ECD\u4F1A\u53D1\u5230\u8FD9\u91CC\u3002\u8981\u91CD\u53D1\u7684\u8BDD\u5148\u770B\u4E00\u773C\u7EC8\u7AEF\uFF0C\u514D\u5F97\u540C\u4E00\u4EF6\u4E8B\u505A\u4E24\u904D\u3002",
28463
+ terminal_input_unavailable: "\u8FDE\u63A5\u5668\u91CD\u542F\u540E\u6CA1\u80FD\u518D\u786E\u8BA4\u90A3\u4E2A\u7EC8\u7AEF\uFF0C\u8FD9\u6761\u6D88\u606F\u6CA1\u6709\u53D1\u8FDB\u53BB\u3002\u91CD\u65B0 attach \u4E00\u6B21\u3002",
28464
+ empty_prompt: "\u8FD9\u6761\u6D88\u606F\u53BB\u6389\u63A7\u5236\u5B57\u7B26\u540E\u662F\u7A7A\u7684\uFF0C\u6CA1\u6709\u53D1\u8FDB\u7EC8\u7AEF\u3002",
28465
+ read_only_live_session: "\u8FD9\u6BB5\u5BF9\u8BDD\u6B63\u5F00\u5728\u90A3\u53F0\u673A\u5668\u7684\u7EC8\u7AEF\u91CC\uFF0C\u8FD9\u8FB9\u53EA\u80FD\u770B\u3001\u4E0D\u80FD\u8F93\u5165\uFF0C\u8FD9\u6761\u6D88\u606F\u6CA1\u6709\u53D1\u8FDB\u53BB\u3002\u5728\u7EC8\u7AEF\u91CC\u8F93\u5165\uFF0C\u6216\u5148\u63A5\u7BA1\u518D\u53D1\u3002",
28466
+ terminal_session: "\u8FD9\u6BB5\u5BF9\u8BDD\u5F00\u5728\u7EC8\u7AEF\u91CC\uFF0C\u6A21\u5F0F\u7531\u7EC8\u7AEF\u51B3\u5B9A\uFF0C\u8FD9\u91CC\u6539\u4E0D\u4E86\u3002",
28467
+ terminal_mode_not_allowed: '\u7EC8\u7AEF\u91CC\u8FD9\u6BB5\u5BF9\u8BDD\u7684\u6743\u9650\u6A21\u5F0F\uFF08\u4F8B\u5982 auto\uFF09\u4E0D\u9010\u6B65\u8BE2\u95EE\uFF0C\u800C\u8FD9\u4E2A agent \u7684\u5BA1\u6279\u8BBE\u7F6E\u4E0D\u5141\u8BB8\u4ECE\u624B\u673A\u5F80\u8FD9\u79CD\u6A21\u5F0F\u91CC\u8F93\u5165\uFF0C\u8FD9\u6761\u6D88\u606F\u6CA1\u6709\u53D1\u8FDB\u53BB\u3002\u5728\u7EC8\u7AEF\u91CC\u6309 shift+tab \u5207\u5230\u4F1A\u8BE2\u95EE\u7684\u6A21\u5F0F\uFF08manual \u6216 plan\uFF09\u518D\u53D1\uFF1B\u6216\u5728\u90A3\u53F0\u673A\u5668\u7684 agents.toml \u91CC\u7ED9\u8FD9\u4E2A agent \u8BBE `approval = "never"`\u3002',
28468
+ terminal_mode_unknown: "\u8FDE\u63A5\u5668\u8BFB\u4E0D\u51FA\u7EC8\u7AEF\u91CC\u8FD9\u6BB5\u5BF9\u8BDD\u5904\u4E8E\u54EA\u79CD\u6743\u9650\u6A21\u5F0F\uFF0C\u8FD9\u6761\u6D88\u606F\u6CA1\u6709\u53D1\u8FDB\u53BB\u3002\u786E\u8BA4\u90A3\u8FB9\u7684 Claude Code \u662F\u65B0\u7248\u3001\u8F93\u5165\u6846\u4E0B\u65B9\u663E\u793A\u7740\u6A21\u5F0F\uFF0C\u518D\u53D1\u4E00\u6B21\u3002",
28469
+ terminal_screen_unknown: "\u8FDE\u63A5\u5668 30 \u79D2\u5185\u90FD\u8BA4\u4E0D\u51FA\u90A3\u4E2A\u7EC8\u7AEF\u7684\u753B\u9762\uFF08\u4E0D\u662F Claude Code \u7684\u8F93\u5165\u6846\uFF0C\u5B83\u4E5F\u6CA1\u8BF4\u81EA\u5DF1\u5728\u5FD9\uFF09\uFF0C\u8FD9\u6761\u6D88\u606F\u6CA1\u6709\u53D1\u8FDB\u53BB\u3002\u770B\u4E00\u773C\u7EC8\u7AEF\uFF0C\u5173\u6389\u4E0A\u9762\u7684\u4E1C\u897F\u518D\u53D1\u3002",
28470
+ terminal_command_refused: "\u4EE5 ! \u6216 / \u5F00\u5934\u7684\u6D88\u606F\u4F1A\u5728\u90A3\u4E2A\u7EC8\u7AEF\u91CC\u6267\u884C\u547D\u4EE4\uFF0C\u6240\u4EE5\u4E0D\u4ECE\u624B\u673A\u8F93\u5165\u3002\u6362\u4E2A\u8BF4\u6CD5\uFF0C\u6216\u8005\u5728\u7EC8\u7AEF\u91CC\u81EA\u5DF1\u6267\u884C\u3002",
28471
+ takeover_expired: "\u63A5\u7BA1\u786E\u8BA4\u5230\u8FBE\u90A3\u53F0\u673A\u5668\u65F6\u5DF2\u7ECF\u8FC7\u671F\uFF0C\u6CA1\u6709\u63A5\u7BA1\u3002\u91CD\u65B0\u6253\u5F00\u5E76\u518D\u786E\u8BA4\u4E00\u6B21\u3002",
28472
+ cwd_ambiguous: "\u8FD9\u4E2A agent \u6709\u4E0D\u6B62\u4E00\u4E2A\u6839\u76EE\u5F55\u91CC\u6709\u540C\u540D\u6587\u4EF6\u5939\u3002\u8BF7\u5199\u51FA\u5B8C\u6574\u8DEF\u5F84\u3002",
28473
+ root_unavailable: "\u90A3\u53F0\u673A\u5668\u4E0A\u8FD9\u4E2A\u76EE\u5F55\u6240\u5728\u7684\u76D8\u6CA1\u6709\u54CD\u5E94\uFF08\u7F51\u7EDC\u76D8\u65AD\u4E86\u6216\u8FD8\u6CA1\u6302\u4E0A\uFF09\u3002\u8FC7\u4E00\u5206\u949F\u518D\u8BD5\uFF0C\u6216\u5728\u90A3\u53F0\u673A\u5668\u4E0A\u68C0\u67E5\u6302\u8F7D\u3002",
28474
+ session_closed: "\u8FD9\u4E2A\u4F1A\u8BDD\u5DF2\u7ECF\u5173\u4E86\u3002",
28475
+ closed: "\u4F1A\u8BDD\u5DF2\u6309\u8981\u6C42\u5173\u95ED\u3002",
28476
+ stopped: "\u90A3\u53F0\u673A\u5668\u4E0A\u7684\u8FDE\u63A5\u5668\u505C\u4E86\u3002\u5728\u90A3\u53F0\u673A\u5668\u4E0A\u91CD\u65B0\u542F\u52A8\u5B83\uFF08`claw-connector run`\uFF0C\u6216\u670D\u52A1\u7684 `sh keepalive.sh`\uFF09\u3002",
28477
+ paused: "\u90A3\u53F0\u673A\u5668\u4E0A\u7684\u8FDE\u63A5\u5668\u6682\u505C\u4E86\u3002\u5728\u90A3\u53F0\u673A\u5668\u4E0A\u8FD0\u884C `claw-connector resume`\u3002",
28478
+ revoked: "\u90A3\u53F0\u673A\u5668\u7684\u8FDE\u63A5\u5668\u5DF2\u88AB\u6CE8\u9500\u3002\u5728\u90A3\u53F0\u673A\u5668\u4E0A\u8FD0\u884C `{login}` \u91CD\u65B0\u767B\u5F55\u3002",
28479
+ text_required: "\u53D1\u7ED9 agent \u7684\u6D88\u606F\u662F\u7A7A\u7684\u3002",
28480
+ action_and_option_required: "\u8FD9\u6B21\u6279\u51C6\u7F3A\u5C11\u8981\u56DE\u7B54\u7684\u8BF7\u6C42\u6216\u9009\u9879\u3002\u5728\u5361\u7247\u4E0A\u518D\u70B9\u4E00\u6B21\u3002",
28481
+ too_many_queued_prompts: "agent \u624B\u4E0A\u6392\u961F\u7684\u6D88\u606F\u592A\u591A\u4E86\uFF0C\u8FD9\u6761\u6CA1\u6709\u6536\u4E0B\u3002\u7B49\u5B83\u5904\u7406\u5B8C\u518D\u53D1\u3002",
28482
+ cancelled: "\u8FD9\u6761\u6D88\u606F\u8FD8\u6CA1\u8FD0\u884C\u5C31\u56E0\u4E3A\u505C\u6B62\u800C\u88AB\u4E22\u5F03\u4E86\u3002",
28483
+ unknown_action: "\u8FD9\u4E2A\u6279\u51C6\u8BF7\u6C42\u5DF2\u7ECF\u4E0D\u5728\u4E86\u3002",
28484
+ option_not_offered: "\u8FD9\u4E2A\u9009\u9879\u4E0D\u662F agent \u63D0\u4F9B\u7684\u3002"
28485
+ }
28389
28486
  });
28390
- function remoteStep(fields2 = {}) {
28391
- return { ...NOTHING2, ...fields2 };
28392
- }
28393
- var Record_ = z8.record(z8.string(), z8.unknown());
28394
- function record5(value) {
28395
- const parsed = Record_.safeParse(value);
28396
- return parsed.success ? parsed.data : {};
28397
- }
28398
- function str7(value) {
28399
- return typeof value === "string" ? value : "";
28400
- }
28401
- function seqOf(value) {
28402
- return typeof value === "number" && Number.isSafeInteger(value) ? value : null;
28487
+ var connectorReasonHints = defineCatalog({
28488
+ en: {
28489
+ upgrade: (p) => `Upgrade the connector: on that machine run \`${p.command}\` (it installs the new version and restarts the connector on it).`,
28490
+ sandbox: 'Workaround (only when the connector runs as root and the agent has `approval = "never"`): add `env = { IS_SANDBOX = "1" }` under that agent in agents.toml (or `IS_SANDBOX = "1"` in its existing `[agents.env]`), then restart the connector.',
28491
+ status: "Run `claw-connector status` on that machine and look for a warning or problem line.",
28492
+ newSession: "Start a new one with `/agent new`.",
28493
+ retry: "Try again in a moment.",
28494
+ /** A length of time in the sentences that name one (`{wait}`): the connector's own whole seconds. */
28495
+ seconds: (p) => `${String(p.n)} ${p.n === 1 ? "second" : "seconds"}`,
28496
+ unknown: (p) => `The connector gave a reason I do not know (${p.code}). Run \`claw-connector status\` on that machine, or upgrade the connector and try again.`,
28497
+ /** Between a lead and the reason after it, and the end of a lead with none. */
28498
+ leadSep: ": ",
28499
+ leadEnd: "."
28500
+ },
28501
+ zh: {
28502
+ upgrade: (p) => `\u5347\u7EA7\u8FDE\u63A5\u5668\uFF1A\u5728\u90A3\u53F0\u673A\u5668\u4E0A\u8FD0\u884C \`${p.command}\`\uFF08\u4F1A\u88C5\u4E0A\u65B0\u7248\u672C\u5E76\u91CD\u542F\u8FDE\u63A5\u5668\uFF09\u3002`,
28503
+ sandbox: '\u4E34\u65F6\u7ED5\u8FC7\uFF08\u4EC5\u5F53\u8FDE\u63A5\u5668\u4EE5 root \u8FD0\u884C\u3001\u4E14\u8BE5 agent \u8BBE\u4E86 `approval = "never"`\uFF09\uFF1A\u5728 agents.toml \u91CC\u8BE5 agent \u4E0B\u52A0 `env = { IS_SANDBOX = "1" }`\uFF08\u5DF2\u6709 `[agents.env]` \u7684\uFF0C\u5728\u5176\u4E2D\u52A0 `IS_SANDBOX = "1"`\uFF09\uFF0C\u518D\u91CD\u542F\u8FDE\u63A5\u5668\u3002',
28504
+ status: "\u5728\u90A3\u53F0\u673A\u5668\u4E0A\u8FD0\u884C `claw-connector status`\uFF0C\u770B\u6709\u6CA1\u6709 warning \u6216 problem \u884C\u3002",
28505
+ newSession: "\u7528 `/agent new` \u5F00\u4E00\u4E2A\u65B0\u4F1A\u8BDD\u3002",
28506
+ retry: "\u7A0D\u540E\u518D\u8BD5\u4E00\u6B21\u3002",
28507
+ seconds: (p) => `${String(p.n)} \u79D2`,
28508
+ unknown: (p) => `\u8FDE\u63A5\u5668\u7ED9\u51FA\u4E86\u4E00\u4E2A\u6211\u4E0D\u8BA4\u8BC6\u7684\u539F\u56E0\uFF08${p.code}\uFF09\u3002\u5728\u90A3\u53F0\u673A\u5668\u4E0A\u8FD0\u884C \`claw-connector status\` \u770B\u770B\uFF0C\u6216\u5347\u7EA7\u8FDE\u63A5\u5668\u540E\u518D\u8BD5\u3002`,
28509
+ leadSep: "\uFF1A",
28510
+ leadEnd: "\u3002"
28511
+ }
28512
+ });
28513
+
28514
+ // packages/core/src/remote/fields.ts
28515
+ function textOf6(value) {
28516
+ if (typeof value === "string") return value;
28517
+ if (typeof value === "number") return value === 0 ? "" : String(value);
28518
+ return value === true ? "True" : "";
28403
28519
  }
28404
- function flag2(value) {
28405
- return typeof value === "boolean" ? value : null;
28520
+ function recordOf(value) {
28521
+ return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
28406
28522
  }
28407
- function update(payload) {
28408
- const inner = Record_.safeParse(payload["update"]);
28409
- return inner.success ? inner.data : payload;
28410
- }
28411
- function textOf6(payload) {
28412
- const u = update(payload);
28413
- const content = u["content"];
28414
- const inner = Record_.safeParse(content);
28415
- if (inner.success && typeof inner.data["text"] === "string") return inner.data["text"];
28416
- if (typeof content === "string") return content;
28417
- return str7(u["text"]);
28523
+
28524
+ // packages/core/src/locales/connector-setup.ts
28525
+ var connectorSetupText = defineCatalog({
28526
+ en: {
28527
+ noMachine: "You have no machine connected.",
28528
+ /** Between the first line and `runOn`. */
28529
+ sep: " ",
28530
+ runOn: "On the machine you want to use (Node.js 22 or newer), run:",
28531
+ after: "`init` writes agents.toml and prints where: set `roots` there to the folders an agent may work in (the sample uses `~/work`). `login` prints a link and a code: open it where you are signed in and confirm. Then send /agents to see the machine.",
28532
+ /** What differs per system, one line each. */
28533
+ notes: "- Linux: if `service install` asks, also run `loginctl enable-linger $USER` once; in a container or dev pod without systemd, add the two lines it prints to crontab or the container's startup command.\n- macOS: the same commands; launchd keeps it running.\n- Windows: run the same commands inside WSL (for example Ubuntu).\n- npm says `EACCES`: run `npm config set prefix ~/.npm-global` and put `~/.npm-global/bin` on your `PATH` instead of using sudo.",
28534
+ upgrade: (p) => `On that machine, run \`${p.command}\` to upgrade it and restart it.`,
28535
+ versionUnsupported: (p) => `Its connector (${p.version}) is too old for a new session.`,
28536
+ versionOutdated: (p) => `Its connector (${p.version}) is out of date.`,
28537
+ offlineHint: "On that machine, run `claw-connector status` to see why, then `claw-connector service install` to start it again."
28538
+ },
28539
+ zh: {
28540
+ noMachine: "\u4F60\u8FD8\u6CA1\u6709\u8FDE\u63A5\u4EFB\u4F55\u673A\u5668\u3002",
28541
+ sep: "",
28542
+ runOn: "\u5728\u8981\u4F7F\u7528\u7684\u673A\u5668\u4E0A\uFF08\u9700\u8981 Node.js 22 \u53CA\u4EE5\u4E0A\uFF09\u4F9D\u6B21\u8FD0\u884C\uFF1A",
28543
+ after: "`init` \u4F1A\u751F\u6210 agents.toml \u5E76\u6253\u5370\u4F4D\u7F6E\uFF1A\u628A\u5176\u4E2D\u7684 `roots` \u6539\u6210\u5141\u8BB8 agent \u5DE5\u4F5C\u7684\u76EE\u5F55\uFF08\u793A\u4F8B\u662F `~/work`\uFF09\u3002`login` \u4F1A\u6253\u5370\u4E00\u4E2A\u94FE\u63A5\u548C\u9A8C\u8BC1\u7801\uFF1A\u5728\u5DF2\u767B\u5F55\u7684\u6D4F\u89C8\u5668\u91CC\u6253\u5F00\u5E76\u786E\u8BA4\u3002\u4E4B\u540E\u53D1 /agents \u5C31\u80FD\u770B\u5230\u8FD9\u53F0\u673A\u5668\u3002",
28544
+ notes: "- Linux\uFF1A`service install` \u82E5\u63D0\u793A\uFF0C\u518D\u8FD0\u884C\u4E00\u6B21 `loginctl enable-linger $USER`\uFF1B\u5BB9\u5668\u6216 dev pod \u6CA1\u6709 systemd \u65F6\uFF0C\u628A\u5B83\u6253\u5370\u7684\u4E24\u884C\u52A0\u8FDB crontab \u6216\u5BB9\u5668\u542F\u52A8\u547D\u4EE4\u3002\n- macOS\uFF1A\u540C\u6837\u7684\u547D\u4EE4\uFF0C\u7531 launchd \u5E38\u9A7B\u3002\n- Windows\uFF1A\u5728 WSL\uFF08\u4F8B\u5982 Ubuntu\uFF09\u91CC\u8FD0\u884C\u540C\u6837\u7684\u547D\u4EE4\u3002\n- npm \u62A5 `EACCES`\uFF1A\u5148 `npm config set prefix ~/.npm-global`\uFF0C\u628A `~/.npm-global/bin` \u52A0\u8FDB `PATH`\uFF0C\u4E0D\u8981\u7528 sudo\u3002",
28545
+ upgrade: (p) => `\u5728\u90A3\u53F0\u673A\u5668\u4E0A\u8FD0\u884C \`${p.command}\` \u5347\u7EA7\u5E76\u91CD\u542F\u5B83\u3002`,
28546
+ versionUnsupported: (p) => `\u8FDE\u63A5\u5668\u7248\u672C ${p.version} \u592A\u65E7\uFF0C\u4E0D\u80FD\u5F00\u65B0\u4F1A\u8BDD\u3002`,
28547
+ versionOutdated: (p) => `\u8FDE\u63A5\u5668\u7248\u672C ${p.version} \u8F83\u65E7\uFF0C\u5EFA\u8BAE\u5347\u7EA7\u3002`,
28548
+ offlineHint: "\u5728\u90A3\u53F0\u673A\u5668\u4E0A\u8FD0\u884C `claw-connector status` \u770B\u539F\u56E0\uFF0C\u518D\u8FD0\u884C `claw-connector service install` \u91CD\u65B0\u542F\u52A8\u5B83\u3002"
28549
+ }
28550
+ });
28551
+
28552
+ // packages/core/src/remote/connector/setup.ts
28553
+ var CONNECTOR_PACKAGE_NAME = "@primusclaw/connector";
28554
+ var UPGRADE_COMMAND = `npm install -g ${CONNECTOR_PACKAGE_NAME}@latest && claw-connector stop && claw-connector service install`;
28555
+ var SAFE_URL = /^https?:\/\/[A-Za-z0-9.-]{1,253}(?::\d{1,5})?(?:\/[A-Za-z0-9._~-]{1,100}){0,8}$/;
28556
+ var PAIR_CODE = /^[0-9A-HJKMNP-TV-Z]{4}-[0-9A-HJKMNP-TV-Z]{4}-[0-9A-HJKMNP-TV-Z]{4}$/;
28557
+ function safeUrl(value) {
28558
+ const text9 = pyRstrip(pyStrip(textOf6(value)), "/");
28559
+ return SAFE_URL.test(text9) ? text9 : null;
28418
28560
  }
28419
- var STOP_REASONS = /* @__PURE__ */ new Set(["end_turn", "max_tokens", "max_turn_requests", "refusal", "cancelled", "error"]);
28420
- function availableModes(raw) {
28421
- const state = Record_.safeParse(raw);
28422
- return state.success ? state.data["availableModes"] : raw;
28561
+ function originOf(url) {
28562
+ const match = /^(https?):\/\/([^/]+)/u.exec(url);
28563
+ return match ? `${match[1] ?? ""}://${match[2] ?? ""}` : "";
28423
28564
  }
28424
- function modeIds(raw) {
28425
- const list2 = availableModes(raw);
28426
- if (!Array.isArray(list2)) return null;
28427
- const ids = list2.map((m) => {
28428
- const mode = Record_.safeParse(m);
28429
- return mode.success ? mode.data["id"] : m;
28430
- });
28431
- return ids.filter((i) => typeof i === "string" && i !== "").slice(0, 20);
28565
+ function sameHost(a, b3) {
28566
+ return originOf(a).toLowerCase() === originOf(b3).toLowerCase();
28432
28567
  }
28433
- function modeFlags(raw) {
28434
- const list2 = availableModes(raw);
28435
- const flags = /* @__PURE__ */ new Map();
28436
- for (const m of Array.isArray(list2) ? list2 : []) {
28437
- const mode = record5(m);
28438
- const id = mode["id"];
28439
- const unattended = flag2(mode["unattended"]);
28440
- if (typeof id === "string" && id !== "" && unattended !== null) flags.set(id, unattended);
28568
+ var Setup = class {
28569
+ constructor(server, identityUrl) {
28570
+ this.server = server;
28571
+ this.identityUrl = identityUrl;
28441
28572
  }
28442
- return flags.size > 0 ? Object.fromEntries(flags) : null;
28443
- }
28444
- function currentMode(payload) {
28445
- const modes = Record_.safeParse(payload["modes"]);
28446
- for (const source of [update(payload), payload, modes.success ? modes.data : {}]) {
28447
- for (const name of ["currentModeId", "currentMode", "mode", "modeId"]) {
28448
- const value = own(source, name);
28449
- if (typeof value === "string" && value !== "") return value;
28450
- }
28573
+ server;
28574
+ identityUrl;
28575
+ login() {
28576
+ return "claw-connector login" + (this.server ? ` --server ${this.server}` : "") + (this.identityUrl ? ` --identity-url ${this.identityUrl}` : "");
28451
28577
  }
28452
- return null;
28578
+ commands() {
28579
+ return [
28580
+ `npm install -g ${CONNECTOR_PACKAGE_NAME}`,
28581
+ "claw-connector init",
28582
+ this.login(),
28583
+ "claw-connector service install"
28584
+ ];
28585
+ }
28586
+ };
28587
+ function setupFrom(data, baseUrl) {
28588
+ const base = safeUrl(baseUrl);
28589
+ if (!base) return new Setup("", null);
28590
+ const origin = originOf(base);
28591
+ const given = recordOf(data);
28592
+ const server = given ? safeUrl(given.server) : null;
28593
+ if (given && server && sameHost(server, base)) {
28594
+ const identity = safeUrl(given.identity_url);
28595
+ return new Setup(server, identity && sameHost(identity, base) ? identity : origin);
28596
+ }
28597
+ return new Setup(base, origin);
28453
28598
  }
28454
- var PLAN_ITEM_MAX = 80;
28455
- function planLine(payload) {
28456
- const entries = update(payload)["entries"];
28457
- if (!Array.isArray(entries) || entries.length === 0) return null;
28458
- const items = entries.flatMap((e) => {
28459
- const item = Record_.safeParse(e);
28460
- return item.success ? [item.data] : [];
28461
- });
28462
- if (items.length === 0) return null;
28463
- const done = items.filter((e) => e["status"] === "completed").length;
28464
- const current = items.find((e) => e["status"] === "in_progress") ?? items.find((e) => e["status"] !== "completed");
28465
- let line3 = `\u{1F4CB} Plan: ${String(done)} of ${String(items.length)} done`;
28466
- if (current && str7(current["content"])) line3 += `, now: ${neutral2(current["content"], PLAN_ITEM_MAX)}`;
28467
- return line3;
28599
+ function pairCommand(data, baseUrl) {
28600
+ const given = recordOf(data);
28601
+ if (!given) return null;
28602
+ const code3 = textOf6(given.code).trim();
28603
+ const server = safeUrl(given.server);
28604
+ const base = safeUrl(baseUrl) ?? "";
28605
+ if (!PAIR_CODE.test(code3) || !server || !sameHost(server, base)) return null;
28606
+ return `npm install -g --no-update-notifier ${CONNECTOR_PACKAGE_NAME}@latest && claw-connector pair ${code3} --server ${server}`;
28468
28607
  }
28469
- var NOT_TYPED = new RegExp(
28470
- "^(?:<(?:command-|local-command-|system-reminder|bash-|user-prompt-submit-hook|task-notification|cross-session-message|agent-message)|\\[Request interrupted|Another Claude session sent a message:|This session is being continued from a previous conversation)"
28471
- );
28472
- function chunk(payload, kind) {
28473
- const text9 = textOf6(payload);
28474
- if (!text9) return NOTHING2;
28475
- return remoteStep({ chunk: { kind: kind === "agent_message_chunk" ? "message" : "thought", text: text9 } });
28608
+ function connectSteps(setup, lang, lead = "") {
28609
+ const text9 = connectorSetupText.in(lang);
28610
+ return {
28611
+ lead: (lead || text9.noMachine) + text9.sep + text9.runOn,
28612
+ commands: setup.commands(),
28613
+ after: text9.after,
28614
+ notes: text9.notes
28615
+ };
28476
28616
  }
28477
- var PASTED_BLOCK = /\n*<pasted_content id="([^"\s<>]{1,64})">\n([\s\S]*?)\n<\/pasted_content id="\1">\n*/gu;
28478
- function unwrapPasted(text9) {
28479
- if (!text9.includes("<pasted_content ")) return text9;
28480
- return text9.replace(PASTED_BLOCK, (whole4, _id, inner, at, all) => {
28481
- const end = at + whole4.length;
28482
- return `${at > 0 ? "\n" : ""}${inner}${end < all.length ? "\n" : ""}`;
28483
- });
28617
+ function connectMarkdown(setup, lang, lead = "") {
28618
+ const steps = connectSteps(setup, lang, lead);
28619
+ const block = "```\n" + steps.commands.join("\n") + "\n```";
28620
+ return [steps.lead, block, steps.after, steps.notes].join("\n\n");
28484
28621
  }
28485
- function typed(payload) {
28486
- const text9 = pyStrip(unwrapPasted(textOf6(payload)));
28487
- return text9 && !NOT_TYPED.test(text9) ? remoteStep({ typed: text9 }) : NOTHING2;
28622
+ function upgradeText(lang, command = UPGRADE_COMMAND) {
28623
+ return connectorSetupText.in(lang).upgrade({ command });
28488
28624
  }
28489
- var TOOL_NAME = /^[A-Za-z][\w.-]{0,63}$/u;
28490
- function toolNameOf(u) {
28491
- const meta = record5(record5(u["_meta"])["claudeCode"]);
28492
- const named2 = str7(meta["toolName"]);
28493
- if (TOOL_NAME.test(named2)) return named2;
28494
- const head = str7(u["title"]).split(": ", 1)[0] ?? "";
28495
- return head !== str7(u["title"]) && TOOL_NAME.test(head) ? head : "";
28625
+ function versionNote(connector, lang = "en") {
28626
+ const status = connector.versionStatus;
28627
+ if (status !== "outdated" && status !== "unsupported") return null;
28628
+ const version = connector.version.replace(/[^0-9A-Za-z.+-]/gu, "").slice(0, 40) || "?";
28629
+ const text9 = connectorSetupText.in(lang);
28630
+ const head = status === "unsupported" ? text9.versionUnsupported({ version }) : text9.versionOutdated({ version });
28631
+ return head + text9.sep + upgradeText(lang);
28496
28632
  }
28497
- function tool(payload, kind) {
28498
- const u = update(payload);
28499
- const id = str7(u["toolCallId"]) || str7(u["tool_call_id"]) || str7(u["id"]);
28500
- const status = str7(u["status"]) || (kind === "tool_call" ? "pending" : "");
28501
- const name = toolNameOf(u);
28502
- return remoteStep({ tool: { id, title: str7(u["title"]), status, ...name ? { name } : {} } });
28633
+ function offlineHint(lang = "en") {
28634
+ return connectorSetupText.in(lang).offlineHint;
28503
28635
  }
28504
- function terminalQueued(payload) {
28505
- const seq = seqOf(payload["cmd_seq"]);
28506
- const forId = neutral2(str7(payload["cmd_id"]), 80) || (seq !== null ? String(seq) : "");
28507
- return remoteStep({
28508
- queued: str7(payload["reason"]) || "terminal_working",
28509
- queuedFor: forId || null,
28510
- queuedSeq: seq,
28511
- queuedHeld: payload["held"] === "terminal",
28512
- dialog: neutral2(str7(payload["dialog"]), DIALOG_MAX) || null,
28513
- rowUnreadable: payload["registry_row_unreadable"] === true
28514
- });
28636
+ var ConnectorSetup = class {
28637
+ constructor(setup) {
28638
+ this.setup = setup;
28639
+ }
28640
+ setup;
28641
+ connectMarkdown(lang, lead = "") {
28642
+ return connectMarkdown(this.setup, lang, lead);
28643
+ }
28644
+ connectSteps(lang, lead = "") {
28645
+ return connectSteps(this.setup, lang, lead);
28646
+ }
28647
+ versionNote(connector, lang) {
28648
+ return versionNote(connector, lang);
28649
+ }
28650
+ offlineHint(lang) {
28651
+ return offlineHint(lang);
28652
+ }
28653
+ login() {
28654
+ return this.setup.login();
28655
+ }
28656
+ };
28657
+
28658
+ // packages/core/src/remote/connector/reasons.ts
28659
+ var FIXED_IN = [0, 1, 5];
28660
+ var CODE3 = /^[a-z][a-z0-9_]{0,63}$/u;
28661
+ var VERSION = /^v?(\d+)\.(\d+)\.(\d+)/u;
28662
+ var FIGURE_DEFAULT = { recently_written: 10 };
28663
+ var MAX_FIGURE = 3600;
28664
+ var FIGURED = /^([a-z][a-z0-9_]{0,63}):([1-9][0-9]{0,3})$/u;
28665
+ function splitFigure(reason) {
28666
+ const match = FIGURED.exec(reason);
28667
+ const code3 = match?.[1] ?? "";
28668
+ const n = Number(match?.[2]);
28669
+ return match !== null && Object.hasOwn(FIGURE_DEFAULT, code3) && n <= MAX_FIGURE ? { code: code3, n } : null;
28670
+ }
28671
+ function reasonWithWait(reason, wait) {
28672
+ return Object.hasOwn(FIGURE_DEFAULT, reason) && typeof wait === "number" && Number.isInteger(wait) && wait >= 1 && wait <= MAX_FIGURE ? `${reason}:${String(wait)}` : reason;
28515
28673
  }
28516
- function turnEnd(payload, _kind, errors) {
28517
- let reason = str7(payload["stopReason"]) || "end_turn";
28518
- let error = str7(payload["error"]) || str7(payload["message"]);
28519
- if (!STOP_REASONS.has(reason)) {
28520
- error = error || `an internal error (ref ${errors.withhold("remote_stop_reason", reason)})`;
28521
- reason = "error";
28674
+ var both = (fn) => [fn("zh"), fn("en")];
28675
+ var UPGRADE = both((lang) => connectorReasonHints.in(lang).upgrade({ command: UPGRADE_COMMAND }));
28676
+ var SANDBOX = both((lang) => connectorReasonHints.in(lang).sandbox);
28677
+ var STATUS2 = both((lang) => connectorReasonHints.in(lang).status);
28678
+ var OLD_CONNECTOR = /* @__PURE__ */ new Set(["mode_unavailable", "mode_not_enforced"]);
28679
+ var FIXED_LATER = {
28680
+ terminal_input_unconfirmed: [0, 1, 22]
28681
+ };
28682
+ var THEN_NEW = /* @__PURE__ */ new Set([
28683
+ "adapter_gone",
28684
+ "adapter_cannot_resume",
28685
+ "unknown_session",
28686
+ "resume_not_supported",
28687
+ "session_closed",
28688
+ "set_mode_failed",
28689
+ "machine_reconnected"
28690
+ ]);
28691
+ var THEN_RETRY = /* @__PURE__ */ new Set(["catalog_unavailable", "twin_check_failed", "adapter_unavailable"]);
28692
+ var KNOWN = new Set(Object.keys(connectorReasonText.in("en")));
28693
+ function parseVersion2(value) {
28694
+ const match = VERSION.exec(typeof value === "string" ? value.trim() : "");
28695
+ return match ? [Number(match[1]), Number(match[2]), Number(match[3])] : null;
28696
+ }
28697
+ function older(version, than) {
28698
+ for (let i = 0; i < than.length; i++) {
28699
+ const a = version[i] ?? 0;
28700
+ const b3 = than[i] ?? 0;
28701
+ if (a !== b3) return a < b3;
28522
28702
  }
28523
- return remoteStep({
28524
- finished: true,
28525
- endsSeq: seqOf(payload["cmd_seq"]),
28526
- stopReason: reason,
28527
- note: error ? neutral2(errors.publicReason(error, "remote_turn_end"), 300) : null
28528
- });
28703
+ return false;
28704
+ }
28705
+ function isCode(reason) {
28706
+ return CODE3.test(reason) || splitFigure(reason) !== null;
28707
+ }
28708
+ function sentence2(code3, lang, setup, figure) {
28709
+ const text9 = own(connectorReasonText.in(lang), code3) ?? "";
28710
+ const seconds = connectorReasonHints.in(lang).seconds({ n: figure ?? own(FIGURE_DEFAULT, code3) ?? 0 });
28711
+ return (code3 === "revoked" ? text9.replaceAll("{login}", setup.login()) : text9).replaceAll("{wait}", seconds);
28712
+ }
28713
+ function hintAfter(code3, lang, version) {
28714
+ const hints = connectorReasonHints.in(lang);
28715
+ if (OLD_CONNECTOR.has(code3)) {
28716
+ const parsed = parseVersion2(version);
28717
+ if (parsed === null || older(parsed, FIXED_IN))
28718
+ return { sep: "\n\n", hint: `${hints.upgrade({ command: UPGRADE_COMMAND })}
28719
+
28720
+ ${hints.sandbox}
28721
+
28722
+ ` };
28723
+ return { sep: " ", hint: hints.status };
28724
+ }
28725
+ const fixedIn = own(FIXED_LATER, code3);
28726
+ if (fixedIn) {
28727
+ const parsed = parseVersion2(version);
28728
+ if (parsed !== null && older(parsed, fixedIn))
28729
+ return { sep: "\n\n", hint: hints.upgrade({ command: UPGRADE_COMMAND }) };
28730
+ return null;
28731
+ }
28732
+ if (THEN_NEW.has(code3)) return { sep: " ", hint: hints.newSession };
28733
+ if (THEN_RETRY.has(code3)) return { sep: " ", hint: hints.retry };
28734
+ return null;
28735
+ }
28736
+ function explain(reason, version = null, setup = new Setup("", null)) {
28737
+ const figured2 = splitFigure(reason);
28738
+ const code3 = figured2?.code ?? reason;
28739
+ if (!KNOWN.has(code3)) return both((lang) => connectorReasonHints.in(lang).unknown({ code: code3 }));
28740
+ return both((lang) => {
28741
+ const after = hintAfter(code3, lang, version);
28742
+ const own3 = sentence2(code3, lang, setup, figured2?.n);
28743
+ return after ? `${own3}${after.sep}${after.hint}` : own3;
28744
+ });
28745
+ }
28746
+ function bareReason(reason) {
28747
+ return pyStrip(pyRstrip(pyStrip(reason ?? ""), "."));
28748
+ }
28749
+ function inLang(lang, pair) {
28750
+ if (lang === "zh") return pair[0];
28751
+ if (lang === "en") return pair[1];
28752
+ return `${pair[0]}
28753
+ ${pair[1]}`;
28754
+ }
28755
+ function describe2(reason, lang, version = null, setup) {
28756
+ const bare2 = bareReason(reason);
28757
+ if (!bare2) return "";
28758
+ if (!isCode(bare2)) return `${bare2}.`;
28759
+ return inLang(lang, explain(bare2, version, setup));
28760
+ }
28761
+ function ended(lead, reason, lang, version = null, setup) {
28762
+ if (lang === null) return ["zh", "en"].map((one) => ended(lead, reason, one, version, setup)).join("\n");
28763
+ const why = describe2(reason, lang, version, setup);
28764
+ const hints = connectorReasonHints.in(lang);
28765
+ const head = inLang(lang, lead);
28766
+ return why ? `${head}${hints.leadSep}${why}` : `${head}${hints.leadEnd}`;
28767
+ }
28768
+
28769
+ // packages/core/src/remote/events.ts
28770
+ var DIALOG_MAX = 120;
28771
+ var NOTHING2 = Object.freeze({
28772
+ chunk: null,
28773
+ tool: null,
28774
+ plan: null,
28775
+ permission: null,
28776
+ resolved: null,
28777
+ mode: null,
28778
+ modes: null,
28779
+ unattended: null,
28780
+ modeFlags: null,
28781
+ note: null,
28782
+ started: false,
28783
+ finished: false,
28784
+ endsSeq: null,
28785
+ stopReason: "",
28786
+ closed: null,
28787
+ rejected: null,
28788
+ replay: false,
28789
+ readOnly: null,
28790
+ recovered: null,
28791
+ queued: null,
28792
+ dialog: null,
28793
+ waitLine: null,
28794
+ rowUnreadable: false,
28795
+ queuedFor: null,
28796
+ queuedSeq: null,
28797
+ queuedHeld: false,
28798
+ typed: null,
28799
+ terminal: null,
28800
+ terminalMode: null,
28801
+ acp: null
28802
+ });
28803
+ function remoteStep(fields2 = {}) {
28804
+ return { ...NOTHING2, ...fields2 };
28805
+ }
28806
+ var Record_ = z8.record(z8.string(), z8.unknown());
28807
+ function record5(value) {
28808
+ const parsed = Record_.safeParse(value);
28809
+ return parsed.success ? parsed.data : {};
28810
+ }
28811
+ function str7(value) {
28812
+ return typeof value === "string" ? value : "";
28813
+ }
28814
+ function seqOf(value) {
28815
+ return typeof value === "number" && Number.isSafeInteger(value) ? value : null;
28816
+ }
28817
+ function flag2(value) {
28818
+ return typeof value === "boolean" ? value : null;
28819
+ }
28820
+ function update(payload) {
28821
+ const inner = Record_.safeParse(payload["update"]);
28822
+ return inner.success ? inner.data : payload;
28823
+ }
28824
+ function textOf7(payload) {
28825
+ const u = update(payload);
28826
+ const content = u["content"];
28827
+ const inner = Record_.safeParse(content);
28828
+ if (inner.success && typeof inner.data["text"] === "string") return inner.data["text"];
28829
+ if (typeof content === "string") return content;
28830
+ return str7(u["text"]);
28831
+ }
28832
+ var STOP_REASONS = /* @__PURE__ */ new Set(["end_turn", "max_tokens", "max_turn_requests", "refusal", "cancelled", "error"]);
28833
+ function availableModes(raw) {
28834
+ const state = Record_.safeParse(raw);
28835
+ return state.success ? state.data["availableModes"] : raw;
28836
+ }
28837
+ function modeIds(raw) {
28838
+ const list2 = availableModes(raw);
28839
+ if (!Array.isArray(list2)) return null;
28840
+ const ids = list2.map((m) => {
28841
+ const mode = Record_.safeParse(m);
28842
+ return mode.success ? mode.data["id"] : m;
28843
+ });
28844
+ return ids.filter((i) => typeof i === "string" && i !== "").slice(0, 20);
28845
+ }
28846
+ function modeFlags(raw) {
28847
+ const list2 = availableModes(raw);
28848
+ const flags = /* @__PURE__ */ new Map();
28849
+ for (const m of Array.isArray(list2) ? list2 : []) {
28850
+ const mode = record5(m);
28851
+ const id = mode["id"];
28852
+ const unattended = flag2(mode["unattended"]);
28853
+ if (typeof id === "string" && id !== "" && unattended !== null) flags.set(id, unattended);
28854
+ }
28855
+ return flags.size > 0 ? Object.fromEntries(flags) : null;
28856
+ }
28857
+ function currentMode(payload) {
28858
+ const modes = Record_.safeParse(payload["modes"]);
28859
+ for (const source of [update(payload), payload, modes.success ? modes.data : {}]) {
28860
+ for (const name of ["currentModeId", "currentMode", "mode", "modeId"]) {
28861
+ const value = own(source, name);
28862
+ if (typeof value === "string" && value !== "") return value;
28863
+ }
28864
+ }
28865
+ return null;
28866
+ }
28867
+ var PLAN_ITEM_MAX = 80;
28868
+ function planLine(payload) {
28869
+ const entries = update(payload)["entries"];
28870
+ if (!Array.isArray(entries) || entries.length === 0) return null;
28871
+ const items = entries.flatMap((e) => {
28872
+ const item = Record_.safeParse(e);
28873
+ return item.success ? [item.data] : [];
28874
+ });
28875
+ if (items.length === 0) return null;
28876
+ const done = items.filter((e) => e["status"] === "completed").length;
28877
+ const current = items.find((e) => e["status"] === "in_progress") ?? items.find((e) => e["status"] !== "completed");
28878
+ let line3 = `\u{1F4CB} Plan: ${String(done)} of ${String(items.length)} done`;
28879
+ if (current && str7(current["content"])) line3 += `, now: ${neutral2(current["content"], PLAN_ITEM_MAX)}`;
28880
+ return line3;
28881
+ }
28882
+ var NOT_TYPED = new RegExp(
28883
+ "^(?:<(?:command-|local-command-|system-reminder|bash-|user-prompt-submit-hook|task-notification|cross-session-message|agent-message)|\\[Request interrupted|Another Claude session sent a message:|This session is being continued from a previous conversation)"
28884
+ );
28885
+ function chunk(payload, kind) {
28886
+ const text9 = textOf7(payload);
28887
+ if (!text9) return NOTHING2;
28888
+ return remoteStep({ chunk: { kind: kind === "agent_message_chunk" ? "message" : "thought", text: text9 } });
28889
+ }
28890
+ var PASTED_BLOCK = /\n*<pasted_content id="([^"\s<>]{1,64})">\n([\s\S]*?)\n<\/pasted_content id="\1">\n*/gu;
28891
+ function unwrapPasted(text9) {
28892
+ if (!text9.includes("<pasted_content ")) return text9;
28893
+ return text9.replace(PASTED_BLOCK, (whole4, _id, inner, at, all) => {
28894
+ const end = at + whole4.length;
28895
+ return `${at > 0 ? "\n" : ""}${inner}${end < all.length ? "\n" : ""}`;
28896
+ });
28897
+ }
28898
+ function typed(payload) {
28899
+ const text9 = pyStrip(unwrapPasted(textOf7(payload)));
28900
+ return text9 && !NOT_TYPED.test(text9) ? remoteStep({ typed: text9 }) : NOTHING2;
28901
+ }
28902
+ var TOOL_NAME = /^[A-Za-z][\w.-]{0,63}$/u;
28903
+ function toolNameOf(u) {
28904
+ const meta = record5(record5(u["_meta"])["claudeCode"]);
28905
+ const named2 = str7(meta["toolName"]);
28906
+ if (TOOL_NAME.test(named2)) return named2;
28907
+ const head = str7(u["title"]).split(": ", 1)[0] ?? "";
28908
+ return head !== str7(u["title"]) && TOOL_NAME.test(head) ? head : "";
28909
+ }
28910
+ function tool(payload, kind) {
28911
+ const u = update(payload);
28912
+ const id = str7(u["toolCallId"]) || str7(u["tool_call_id"]) || str7(u["id"]);
28913
+ const status = str7(u["status"]) || (kind === "tool_call" ? "pending" : "");
28914
+ const name = toolNameOf(u);
28915
+ return remoteStep({ tool: { id, title: str7(u["title"]), status, ...name ? { name } : {} } });
28916
+ }
28917
+ function terminalQueued(payload) {
28918
+ const seq = seqOf(payload["cmd_seq"]);
28919
+ const forId = neutral2(str7(payload["cmd_id"]), 80) || (seq !== null ? String(seq) : "");
28920
+ return remoteStep({
28921
+ queued: str7(payload["reason"]) || "terminal_working",
28922
+ queuedFor: forId || null,
28923
+ queuedSeq: seq,
28924
+ queuedHeld: payload["held"] === "terminal",
28925
+ dialog: neutral2(str7(payload["dialog"]), DIALOG_MAX) || null,
28926
+ rowUnreadable: payload["registry_row_unreadable"] === true
28927
+ });
28928
+ }
28929
+ function turnEnd(payload, _kind, errors) {
28930
+ let reason = str7(payload["stopReason"]) || "end_turn";
28931
+ let error = str7(payload["error"]) || str7(payload["message"]);
28932
+ if (!STOP_REASONS.has(reason)) {
28933
+ error = error || `an internal error (ref ${errors.withhold("remote_stop_reason", reason)})`;
28934
+ reason = "error";
28935
+ }
28936
+ return remoteStep({
28937
+ finished: true,
28938
+ endsSeq: seqOf(payload["cmd_seq"]),
28939
+ stopReason: reason,
28940
+ note: error ? figured(neutral2(errors.publicReason(error, "remote_turn_end"), 300), payload) : null
28941
+ });
28529
28942
  }
28530
28943
  function sessionStarted(payload) {
28531
28944
  return remoteStep({
@@ -28563,14 +28976,17 @@ function sessionResumed(payload) {
28563
28976
  }
28564
28977
  function sessionClosed(payload, _kind, errors) {
28565
28978
  const reason = str7(payload["reason"]) || str7(payload["message"]) || str7(payload["error"]);
28566
- return remoteStep({ closed: neutral2(errors.publicReason(reason, "remote_session_closed"), 300) });
28979
+ return remoteStep({ closed: figured(neutral2(errors.publicReason(reason, "remote_session_closed"), 300), payload) });
28980
+ }
28981
+ function figured(reason, payload) {
28982
+ return reasonWithWait(reason, payload["wait_s"]);
28567
28983
  }
28568
28984
  function commandRejected(payload, _kind, errors) {
28569
28985
  const reason = str7(payload["reason"]);
28570
28986
  return remoteStep({
28571
28987
  rejected: {
28572
28988
  type: str7(payload["type"]),
28573
- reason: neutral2(errors.publicReason(reason, "remote_command_rejected"), 300),
28989
+ reason: figured(neutral2(errors.publicReason(reason, "remote_command_rejected"), 300), payload),
28574
28990
  cmdSeq: seqOf(payload["cmd_seq"])
28575
28991
  }
28576
28992
  });
@@ -28615,7 +29031,7 @@ function decode(event, errors) {
28615
29031
  }
28616
29032
 
28617
29033
  // packages/core/src/remote/health.ts
28618
- var CODE3 = /^[a-z][a-z0-9_]{0,63}$/;
29034
+ var CODE4 = /^[a-z][a-z0-9_]{0,63}$/;
28619
29035
  var COMMAND_FIX = /^\(?(?:claude|codex|claw-connector|npm|npx|mkdir|chmod|export|loginctl|agent|curl|crontab|sh)\b/;
28620
29036
  function problemsOf(agent) {
28621
29037
  const health = objOrNull(agent.capabilities["health"]);
@@ -28636,7 +29052,7 @@ function machineProblems(connector) {
28636
29052
  for (const raw of list(health.problems).slice(0, HEALTH_READ_MAX)) {
28637
29053
  const problem = objOrNull(raw);
28638
29054
  const code3 = problem?.["code"];
28639
- if (!problem || typeof code3 !== "string" || !CODE3.test(code3)) continue;
29055
+ if (!problem || typeof code3 !== "string" || !CODE4.test(code3)) continue;
28640
29056
  const machineWide = problem["scope"] === "machine";
28641
29057
  const key = JSON.stringify([machineWide ? null : agent.agentId, code3, cpSlice(pyStr(problem["detail"]), 0, 200)]);
28642
29058
  if (seen.has(key)) continue;
@@ -31078,16 +31494,6 @@ var ChatRegistry = class {
31078
31494
  }
31079
31495
  };
31080
31496
 
31081
- // packages/core/src/remote/fields.ts
31082
- function textOf7(value) {
31083
- if (typeof value === "string") return value;
31084
- if (typeof value === "number") return value === 0 ? "" : String(value);
31085
- return value === true ? "True" : "";
31086
- }
31087
- function recordOf(value) {
31088
- return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
31089
- }
31090
-
31091
31497
  // packages/core/src/remote/machines.ts
31092
31498
  function agentRefOf(connector, agent) {
31093
31499
  return `${neutral(connector.name, 80)}/${neutral(agent.agentId, 64)}`.replaceAll("`", "'");
@@ -31479,7 +31885,7 @@ var Targets = class {
31479
31885
  * ticket, once, in time): then the connector ends the terminal first.
31480
31886
  */
31481
31887
  takeoverOf(chatKey, connector, agent, data, now, lang) {
31482
- const entry = resumableOf(agent).find((e) => e.ref === textOf7(data["resume"]));
31888
+ const entry = resumableOf(agent).find((e) => e.ref === textOf6(data["resume"]));
31483
31889
  const no = (sentence3) => ({
31484
31890
  entry: null,
31485
31891
  problem: saidIn(lang, sentence3)
@@ -31487,7 +31893,7 @@ var Targets = class {
31487
31893
  if (entry === void 0) return no("conversationGone");
31488
31894
  if (entry.state === WATCH_STATE && data["takeover"]) {
31489
31895
  const held = this.chats.ticketOf(chatKey);
31490
- const fresh = held !== void 0 && held.connectorId === connector.connectorId && held.agentId === agent.agentId && held.ref === entry.ref && held.ticket === textOf7(data["takeover"]) && held.until >= now;
31896
+ const fresh = held !== void 0 && held.connectorId === connector.connectorId && held.agentId === agent.agentId && held.ref === entry.ref && held.ticket === textOf6(data["takeover"]) && held.until >= now;
31491
31897
  if (!fresh) return no("confirmExpired");
31492
31898
  if (!canTakeOver(agent)) return no("stillInTerminal");
31493
31899
  this.chats.spendTicket(chatKey);
@@ -31508,14 +31914,14 @@ var Targets = class {
31508
31914
  problem: saidIn(lang, sentence3)
31509
31915
  });
31510
31916
  if ("typed" in data) {
31511
- const path = this.chats.typedPath(chatKey, textOf7(data["typed"]), now);
31917
+ const path = this.chats.typedPath(chatKey, textOf6(data["typed"]), now);
31512
31918
  return path ? { path, problem: "" } : no("cardExpired");
31513
31919
  }
31514
31920
  const slot = slotOf(data);
31515
31921
  if (slot < 0) return no("tapInvalidAgents");
31516
31922
  const roots = agentRoots(agent);
31517
31923
  if (roots.length === 0) {
31518
- const path = textOf7(own(data, `dir${String(slot)}`)).trim();
31924
+ const path = textOf6(own(data, `dir${String(slot)}`)).trim();
31519
31925
  return path ? { path, problem: "" } : no("typeFolder");
31520
31926
  }
31521
31927
  const root = own(data, `root${String(slot)}`);
@@ -31545,8 +31951,8 @@ var StartClicks = class {
31545
31951
  /** The connector and agent a tap names, from the person's own list as Claw gives it now; null (said) when gone. */
31546
31952
  async named(click) {
31547
31953
  const { connectors } = await this.p.lists.machines(click.key);
31548
- const connector = connectorById(connectors, textOf7(click.data["connector_id"]));
31549
- const agent = agentById(connector, textOf7(click.data["agent_id"]));
31954
+ const connector = connectorById(connectors, textOf6(click.data["connector_id"]));
31955
+ const agent = agentById(connector, textOf6(click.data["agent_id"]));
31550
31956
  if (connector === void 0 || agent === void 0) {
31551
31957
  await this.c.home(click, saidIn(this.c.lang(click), "agentGone"));
31552
31958
  return null;
@@ -31627,7 +32033,7 @@ var StartClicks = class {
31627
32033
  async attach(click) {
31628
32034
  const lang = this.c.lang(click);
31629
32035
  if (this.p.state.chats.turns.has(click.chatKey)) return this.c.home(click, saidIn(lang, "stopFirst"));
31630
- const wanted = textOf7(click.data["session_id"]);
32036
+ const wanted = textOf6(click.data["session_id"]);
31631
32037
  const session = (await this.p.lists.sessions(click.key)).sessions.find((s) => s.sessionId === wanted);
31632
32038
  if (session === void 0) return this.c.home(click, saidIn(lang, "sessionNotFound"));
31633
32039
  const hooks = this.p.ops.attachHooks(click.chatKey, click.key, click.provider, click.to);
@@ -31649,7 +32055,7 @@ var StartClicks = class {
31649
32055
  const { connector, agent } = named2;
31650
32056
  if (!connector.online)
31651
32057
  return this.c.home(click, remoteAgentText.in(lang).offlineTap({ host: neutral(connector.name, 80) }));
31652
- const entry = resumableOf(agent).find((e) => e.ref === textOf7(click.data["resume"]));
32058
+ const entry = resumableOf(agent).find((e) => e.ref === textOf6(click.data["resume"]));
31653
32059
  if (entry === void 0) return this.c.home(click, saidIn(lang, "conversationGone"));
31654
32060
  if (entry.state !== "live") return this.c.home(click, saidIn(lang, "notInTerminal"));
31655
32061
  if (!canTakeOver(agent)) return this.c.home(click, saidIn(lang, "cannotTakeOver"));
@@ -31663,7 +32069,7 @@ var StartClicks = class {
31663
32069
  });
31664
32070
  await this.c.repost(
31665
32071
  click,
31666
- this.p.ctx.views.takeover(connector, agent, entry, lang, textOf7(click.data["view"]), ticket)
32072
+ this.p.ctx.views.takeover(connector, agent, entry, lang, textOf6(click.data["view"]), ticket)
31667
32073
  );
31668
32074
  }
31669
32075
  /**
@@ -31715,140 +32121,6 @@ var StartClicks = class {
31715
32121
  }
31716
32122
  };
31717
32123
 
31718
- // packages/core/src/locales/connector-setup.ts
31719
- var connectorSetupText = defineCatalog({
31720
- en: {
31721
- noMachine: "You have no machine connected.",
31722
- /** Between the first line and `runOn`. */
31723
- sep: " ",
31724
- runOn: "On the machine you want to use (Node.js 22 or newer), run:",
31725
- after: "`init` writes agents.toml and prints where: set `roots` there to the folders an agent may work in (the sample uses `~/work`). `login` prints a link and a code: open it where you are signed in and confirm. Then send /agents to see the machine.",
31726
- /** What differs per system, one line each. */
31727
- notes: "- Linux: if `service install` asks, also run `loginctl enable-linger $USER` once; in a container or dev pod without systemd, add the two lines it prints to crontab or the container's startup command.\n- macOS: the same commands; launchd keeps it running.\n- Windows: run the same commands inside WSL (for example Ubuntu).\n- npm says `EACCES`: run `npm config set prefix ~/.npm-global` and put `~/.npm-global/bin` on your `PATH` instead of using sudo.",
31728
- upgrade: (p) => `On that machine, run \`${p.command}\` to upgrade it and restart it.`,
31729
- versionUnsupported: (p) => `Its connector (${p.version}) is too old for a new session.`,
31730
- versionOutdated: (p) => `Its connector (${p.version}) is out of date.`,
31731
- offlineHint: "On that machine, run `claw-connector status` to see why, then `claw-connector service install` to start it again."
31732
- },
31733
- zh: {
31734
- noMachine: "\u4F60\u8FD8\u6CA1\u6709\u8FDE\u63A5\u4EFB\u4F55\u673A\u5668\u3002",
31735
- sep: "",
31736
- runOn: "\u5728\u8981\u4F7F\u7528\u7684\u673A\u5668\u4E0A\uFF08\u9700\u8981 Node.js 22 \u53CA\u4EE5\u4E0A\uFF09\u4F9D\u6B21\u8FD0\u884C\uFF1A",
31737
- after: "`init` \u4F1A\u751F\u6210 agents.toml \u5E76\u6253\u5370\u4F4D\u7F6E\uFF1A\u628A\u5176\u4E2D\u7684 `roots` \u6539\u6210\u5141\u8BB8 agent \u5DE5\u4F5C\u7684\u76EE\u5F55\uFF08\u793A\u4F8B\u662F `~/work`\uFF09\u3002`login` \u4F1A\u6253\u5370\u4E00\u4E2A\u94FE\u63A5\u548C\u9A8C\u8BC1\u7801\uFF1A\u5728\u5DF2\u767B\u5F55\u7684\u6D4F\u89C8\u5668\u91CC\u6253\u5F00\u5E76\u786E\u8BA4\u3002\u4E4B\u540E\u53D1 /agents \u5C31\u80FD\u770B\u5230\u8FD9\u53F0\u673A\u5668\u3002",
31738
- notes: "- Linux\uFF1A`service install` \u82E5\u63D0\u793A\uFF0C\u518D\u8FD0\u884C\u4E00\u6B21 `loginctl enable-linger $USER`\uFF1B\u5BB9\u5668\u6216 dev pod \u6CA1\u6709 systemd \u65F6\uFF0C\u628A\u5B83\u6253\u5370\u7684\u4E24\u884C\u52A0\u8FDB crontab \u6216\u5BB9\u5668\u542F\u52A8\u547D\u4EE4\u3002\n- macOS\uFF1A\u540C\u6837\u7684\u547D\u4EE4\uFF0C\u7531 launchd \u5E38\u9A7B\u3002\n- Windows\uFF1A\u5728 WSL\uFF08\u4F8B\u5982 Ubuntu\uFF09\u91CC\u8FD0\u884C\u540C\u6837\u7684\u547D\u4EE4\u3002\n- npm \u62A5 `EACCES`\uFF1A\u5148 `npm config set prefix ~/.npm-global`\uFF0C\u628A `~/.npm-global/bin` \u52A0\u8FDB `PATH`\uFF0C\u4E0D\u8981\u7528 sudo\u3002",
31739
- upgrade: (p) => `\u5728\u90A3\u53F0\u673A\u5668\u4E0A\u8FD0\u884C \`${p.command}\` \u5347\u7EA7\u5E76\u91CD\u542F\u5B83\u3002`,
31740
- versionUnsupported: (p) => `\u8FDE\u63A5\u5668\u7248\u672C ${p.version} \u592A\u65E7\uFF0C\u4E0D\u80FD\u5F00\u65B0\u4F1A\u8BDD\u3002`,
31741
- versionOutdated: (p) => `\u8FDE\u63A5\u5668\u7248\u672C ${p.version} \u8F83\u65E7\uFF0C\u5EFA\u8BAE\u5347\u7EA7\u3002`,
31742
- offlineHint: "\u5728\u90A3\u53F0\u673A\u5668\u4E0A\u8FD0\u884C `claw-connector status` \u770B\u539F\u56E0\uFF0C\u518D\u8FD0\u884C `claw-connector service install` \u91CD\u65B0\u542F\u52A8\u5B83\u3002"
31743
- }
31744
- });
31745
-
31746
- // packages/core/src/remote/connector/setup.ts
31747
- var CONNECTOR_PACKAGE_NAME = "@primusclaw/connector";
31748
- var UPGRADE_COMMAND = `npm install -g ${CONNECTOR_PACKAGE_NAME}@latest && claw-connector stop && claw-connector service install`;
31749
- var SAFE_URL = /^https?:\/\/[A-Za-z0-9.-]{1,253}(?::\d{1,5})?(?:\/[A-Za-z0-9._~-]{1,100}){0,8}$/;
31750
- var PAIR_CODE = /^[0-9A-HJKMNP-TV-Z]{4}-[0-9A-HJKMNP-TV-Z]{4}-[0-9A-HJKMNP-TV-Z]{4}$/;
31751
- function safeUrl(value) {
31752
- const text9 = pyRstrip(pyStrip(textOf7(value)), "/");
31753
- return SAFE_URL.test(text9) ? text9 : null;
31754
- }
31755
- function originOf(url) {
31756
- const match = /^(https?):\/\/([^/]+)/u.exec(url);
31757
- return match ? `${match[1] ?? ""}://${match[2] ?? ""}` : "";
31758
- }
31759
- function sameHost(a, b3) {
31760
- return originOf(a).toLowerCase() === originOf(b3).toLowerCase();
31761
- }
31762
- var Setup = class {
31763
- constructor(server, identityUrl) {
31764
- this.server = server;
31765
- this.identityUrl = identityUrl;
31766
- }
31767
- server;
31768
- identityUrl;
31769
- login() {
31770
- return "claw-connector login" + (this.server ? ` --server ${this.server}` : "") + (this.identityUrl ? ` --identity-url ${this.identityUrl}` : "");
31771
- }
31772
- commands() {
31773
- return [
31774
- `npm install -g ${CONNECTOR_PACKAGE_NAME}`,
31775
- "claw-connector init",
31776
- this.login(),
31777
- "claw-connector service install"
31778
- ];
31779
- }
31780
- };
31781
- function setupFrom(data, baseUrl) {
31782
- const base = safeUrl(baseUrl);
31783
- if (!base) return new Setup("", null);
31784
- const origin = originOf(base);
31785
- const given = recordOf(data);
31786
- const server = given ? safeUrl(given.server) : null;
31787
- if (given && server && sameHost(server, base)) {
31788
- const identity = safeUrl(given.identity_url);
31789
- return new Setup(server, identity && sameHost(identity, base) ? identity : origin);
31790
- }
31791
- return new Setup(base, origin);
31792
- }
31793
- function pairCommand(data, baseUrl) {
31794
- const given = recordOf(data);
31795
- if (!given) return null;
31796
- const code3 = textOf7(given.code).trim();
31797
- const server = safeUrl(given.server);
31798
- const base = safeUrl(baseUrl) ?? "";
31799
- if (!PAIR_CODE.test(code3) || !server || !sameHost(server, base)) return null;
31800
- return `npm install -g --no-update-notifier ${CONNECTOR_PACKAGE_NAME}@latest && claw-connector pair ${code3} --server ${server}`;
31801
- }
31802
- function connectSteps(setup, lang, lead = "") {
31803
- const text9 = connectorSetupText.in(lang);
31804
- return {
31805
- lead: (lead || text9.noMachine) + text9.sep + text9.runOn,
31806
- commands: setup.commands(),
31807
- after: text9.after,
31808
- notes: text9.notes
31809
- };
31810
- }
31811
- function connectMarkdown(setup, lang, lead = "") {
31812
- const steps = connectSteps(setup, lang, lead);
31813
- const block = "```\n" + steps.commands.join("\n") + "\n```";
31814
- return [steps.lead, block, steps.after, steps.notes].join("\n\n");
31815
- }
31816
- function upgradeText(lang, command = UPGRADE_COMMAND) {
31817
- return connectorSetupText.in(lang).upgrade({ command });
31818
- }
31819
- function versionNote(connector, lang = "en") {
31820
- const status = connector.versionStatus;
31821
- if (status !== "outdated" && status !== "unsupported") return null;
31822
- const version = connector.version.replace(/[^0-9A-Za-z.+-]/gu, "").slice(0, 40) || "?";
31823
- const text9 = connectorSetupText.in(lang);
31824
- const head = status === "unsupported" ? text9.versionUnsupported({ version }) : text9.versionOutdated({ version });
31825
- return head + text9.sep + upgradeText(lang);
31826
- }
31827
- function offlineHint(lang = "en") {
31828
- return connectorSetupText.in(lang).offlineHint;
31829
- }
31830
- var ConnectorSetup = class {
31831
- constructor(setup) {
31832
- this.setup = setup;
31833
- }
31834
- setup;
31835
- connectMarkdown(lang, lead = "") {
31836
- return connectMarkdown(this.setup, lang, lead);
31837
- }
31838
- connectSteps(lang, lead = "") {
31839
- return connectSteps(this.setup, lang, lead);
31840
- }
31841
- versionNote(connector, lang) {
31842
- return versionNote(connector, lang);
31843
- }
31844
- offlineHint(lang) {
31845
- return offlineHint(lang);
31846
- }
31847
- login() {
31848
- return this.setup.login();
31849
- }
31850
- };
31851
-
31852
32124
  // packages/core/src/remote/lists.ts
31853
32125
  var RemoteOff = class extends Error {
31854
32126
  name = "RemoteOff";
@@ -31951,438 +32223,164 @@ ${line3}` : line3;
31951
32223
  ])
31952
32224
  ),
31953
32225
  own: this.ctx.sessionNames.remoteSessionAcps(chatKey),
31954
- setup: this.ctx.setup
31955
- });
31956
- if (!machines && card.listing.length === 0) {
31957
- const { text: text9, listing: listing2 } = sessionsText(sessions, listed.connectors, attached, this.now(), lang);
31958
- this.ctx.remoteState.setRemoteListing(chatKey, listing2);
31959
- return { kind: "text", text: (lead ? `${lead}
31960
-
31961
- ` : "") + text9 };
31962
- }
31963
- this.ctx.remoteState.setRemoteListing(chatKey, card.listing);
31964
- return { kind: "card", message: card.message };
31965
- }
31966
- /** Every session the user has, on every machine; its active ones are the numbers of `/agent attach N` from now on. */
31967
- async sessionsView(chatKey, key, lang, lead = "") {
31968
- const listed = await this.machines(key);
31969
- const { sessions } = await this.sessions(key);
31970
- const state = this.ctx.remoteState.attachedRemote(chatKey);
31971
- const card = this.ctx.views.sessions({
31972
- connectors: listed.connectors,
31973
- sessions,
31974
- attached: state?.sessionId ?? null,
31975
- now: this.now(),
31976
- lang,
31977
- lead,
31978
- waiting: this.ctx.permissions.waitingRemoteSessions(chatKey),
31979
- setup: listed.connectors.length === 0 ? await this.setup(key) : this.ctx.setup
31980
- });
31981
- this.ctx.remoteState.setRemoteListing(chatKey, card.listing);
31982
- return card.message;
31983
- }
31984
- };
31985
-
31986
- // packages/core/src/remote/clicks-machine.ts
31987
- var MachineClicks = class {
31988
- constructor(p, c) {
31989
- this.p = p;
31990
- this.c = c;
31991
- }
31992
- p;
31993
- c;
31994
- /** The person's connector the tapped button names, as Claw lists it now; null (said) when it is not theirs any more. */
31995
- async ownConnector(click, includeHidden = false) {
31996
- const { connectors } = await this.p.lists.machines(click.key, includeHidden);
31997
- const found = connectorById(connectors, textOf7(click.data["connector_id"]));
31998
- if (found === void 0) await this.c.home(click, saidIn(this.c.lang(click), "agentGone"));
31999
- return found ?? null;
32000
- }
32001
- /** Hide one conversation (`ref`), or every one no process runs of one agent (`all: idle`), from the list. */
32002
- async hide(click) {
32003
- const connector = await this.ownConnector(click);
32004
- if (connector === null) return;
32005
- const lang = this.c.lang(click);
32006
- let entries;
32007
- if (click.data["all"] === "idle") {
32008
- const agent = connector.agents.find((a) => a.agentId === textOf7(click.data["agent_id"]));
32009
- entries = (agent ? resumableOf(agent) : []).filter((e) => e.state === "idle");
32010
- } else {
32011
- const ref = textOf7(click.data["ref"]);
32012
- entries = connector.agents.flatMap((a) => resumableOf(a).filter((e) => e.ref === ref)).slice(0, 1);
32013
- }
32014
- if (entries.length === 0) return this.c.home(click, saidIn(lang, "conversationGone"));
32015
- const out = await this.p.ctx.claw.hide(
32016
- click.key,
32017
- connector.connectorId,
32018
- entries.map((e) => e.ref),
32019
- true
32020
- );
32021
- const titles = new Map(entries.map((e) => [e.ref, e.title]));
32022
- const words3 = remoteText.in(lang);
32023
- const lines = [words3.hidN({ n: out.changed.length })];
32024
- for (const refused3 of out.refused) {
32025
- if (refused3.reason === "live")
32026
- lines.push(words3.hideLive({ title: neutral(titles.get(refused3.ref) ?? "", 60) || "?" }));
32027
- }
32028
- await this.c.home(click, lines.join(" "));
32029
- }
32030
- /** The conversations hidden on that machine, each with Unhide. */
32031
- async hidden(click) {
32032
- const connector = await this.ownConnector(click, true);
32033
- if (connector === null) return;
32034
- await this.c.repost(
32035
- click,
32036
- this.p.ctx.views.hidden(connector, this.p.ctx.clock.epochMs() / 1e3, this.c.lang(click))
32037
- );
32038
- }
32039
- /** Show one hidden conversation (`ref`) again, or all of that machine's (`all`). */
32040
- async unhide(click) {
32041
- const connector = await this.ownConnector(click, true);
32042
- if (connector === null) return;
32043
- const hidden2 = connector.agents.flatMap((a) => hiddenOf(a));
32044
- const ref = textOf7(click.data["ref"]);
32045
- const refs = click.data["all"] ? hidden2.map((e) => e.ref) : hidden2.filter((e) => e.ref === ref).map((e) => e.ref);
32046
- const lang = this.c.lang(click);
32047
- if (refs.length === 0) return this.c.home(click, saidIn(lang, "conversationGone"));
32048
- const out = await this.p.ctx.claw.hide(click.key, connector.connectorId, refs, false);
32049
- await this.c.home(click, remoteText.in(lang).unhidN({ n: out.changed.length }));
32050
- }
32051
- /**
32052
- * A tap on the disconnect card. The card names a connector id; whose it is is Claw's to say (404 for anyone else's), and the
32053
- * machine's name is read again from the person's own list.
32054
- */
32055
- async off(click) {
32056
- const lang = this.c.lang(click);
32057
- const words3 = remoteOffText.in(lang);
32058
- if (!this.p.ctx.settings.enabled) return this.settled(click, words3.inactive);
32059
- if (click.data["confirm"] !== true) return this.settled(click, words3.kept);
32060
- const connectorId = textOf7(click.data["connector_id"]);
32061
- let connector;
32062
- try {
32063
- connector = connectorById((await this.p.lists.machines(click.key)).connectors, connectorId);
32064
- if (connector === void 0) {
32065
- await this.settled(click, words3.gone);
32066
- return;
32067
- }
32068
- await this.p.ctx.claw.revoke(click.key, connectorId);
32069
- } catch (error) {
32070
- return this.offRefused(click, error, connector?.name ?? "", lang);
32071
- }
32072
- const state = this.p.state.attached(click.chatKey);
32073
- if (state?.connectorId === connectorId) {
32074
- this.p.ops.leave(click.chatKey);
32075
- }
32076
- const login = connector.paired ? "" : (await this.p.lists.setup(click.key)).login();
32077
- await this.c.end(click, disconnectedText(connector.name, login, lang, connector.paired));
32078
- }
32079
- /** The tap ends with `text` in place of the card. */
32080
- async settled(click, text9) {
32081
- await this.c.end(click, text9);
32082
- }
32083
- /** It did not go through: said; where pressing again can help, the card comes back with its buttons. */
32084
- async offRefused(click, error, name, lang) {
32085
- const words3 = remoteOffText.in(lang);
32086
- const connectorId = textOf7(click.data["connector_id"]);
32087
- const again = async (text9) => {
32088
- await this.c.end(click, disconnectAgainCard(text9, connectorId, disconnectTitle(name, lang), lang), text9);
32089
- };
32090
- if (error instanceof RemoteOff) return this.settled(click, saidIn(lang, "notEnabled"));
32091
- if (error instanceof ClawError) {
32092
- if (error.status === 404) return this.settled(click, words3.gone);
32093
- return again(failureText2(error, this.p.ctx.errors, this.p.ctx.clock.epochMs() / 1e3, lang) + words3.nothing);
32094
- }
32095
- if (isTransport2(error)) return again(saidIn(lang, "unreachable") + words3.nothing);
32096
- throw error;
32097
- }
32098
- };
32099
-
32100
- // packages/core/src/locales/remote-leads.ts
32101
- var remoteLeads = {
32102
- sessionEnded: ["\u4F1A\u8BDD\u5DF2\u7ED3\u675F", "The session ended"],
32103
- couldNotStart: ["\u4F1A\u8BDD\u6CA1\u80FD\u542F\u52A8", "The session could not start"],
32104
- /** (`folder`: already shown inert, in backticks) */
32105
- couldNotStartIn: (folder) => [`\u4F1A\u8BDD\u6CA1\u80FD\u5728 ${folder} \u542F\u52A8`, `The session could not start in ${folder}`],
32106
- turnIncomplete: ["\u8FD9\u4E00\u8F6E\u6CA1\u6709\u5B8C\u6210", "The turn did not complete"],
32107
- /** (a message the terminal may have taken: never said as a turn that did not complete) */
32108
- inputUnconfirmed: ["\u8FD8\u6CA1\u786E\u8BA4\u7EC8\u7AEF\u6536\u5230", "Not confirmed by the terminal yet"],
32109
- modeNotSwitched: ["\u6A21\u5F0F\u6CA1\u6709\u5207\u6362", "The mode was not switched"],
32110
- notSwitchedTo: (mode) => [`\u6CA1\u6709\u5207\u5230 \`${mode}\``, `The agent did not switch to \`${mode}\``]
32111
- };
32112
-
32113
- // packages/core/src/locales/connector-reasons.ts
32114
- var connectorReasonText = defineCatalog({
32115
- en: {
32116
- mode_unavailable: 'The agent on that machine does not offer the permission mode this session needs. Most often the connector runs as root and the agent has `approval = "never"`: Claude offers no bypassPermissions mode to root, so a connector older than 0.1.5 refuses the session.',
32117
- mode_not_enforced: 'The agent could not be put in the permission mode the connector requires (or warned it will no longer ask), so the connector closed the session to stay safe. This happens with Claude running as root (older connectors), or when Claude\'s `permissions.defaultMode` is bypassPermissions and the agent has no `approval = "never"`.',
32118
- mode_not_confirmed: "The agent did not confirm the permission mode it was asked for, so the connector closed the session to stay safe. Upgrade the connector (it brings a newer agent adapter) and try again.",
32119
- mode_mismatch: "The agent reported a different permission mode from the one it was asked for, so the connector closed the session to stay safe. Upgrade the connector and try again; if it persists, check Claude's settings there.",
32120
- mode_not_allowed: 'That mode does not ask before each step, and the agent is not allowed to run that way on that machine. To allow it, set `approval = "never"` on the agent in agents.toml and restart the connector; otherwise pick a mode that asks.',
32121
- mode_id_required: "The mode switch named no mode. Tap Mode and pick one again.",
32122
- set_mode_failed: "The agent could not switch its mode; it keeps the one it had.",
32123
- adapter_gone: "The agent program on that machine has exited.",
32124
- adapter_start_failed: "The connector could not start the agent program on that machine (often: no access to the npm registry, or the command is missing). Run `claw-connector status` there and look at `run.log` in its state directory.",
32125
- adapter_unavailable: "The connector could not start the agent program for this turn.",
32126
- adapter_protocol: "The agent program answered in a way the connector does not expect, most likely a version mismatch. Upgrade the connector and try again.",
32127
- adapter_cannot_resume: "This agent cannot pick up the earlier conversation.",
32128
- adapter_error: "The agent program failed. Look at `run.log` in the connector's state directory on that machine.",
32129
- agent_auth_required: "The agent is not signed in on that machine. Run the agent there once (`claude`, for example) to sign in, then try again.",
32130
- cwd_outside_roots: "That directory is outside the roots the agent may work in. Pick one inside them, or add it to `roots` in agents.toml and restart the connector.",
32131
- cwd_not_found: "That folder does not exist on that machine: pick one that exists there, or create it there first.",
32132
- cwd_not_directory: "That path is not a directory.",
32133
- cwd_not_absolute: "The directory must be an absolute path (starting with /).",
32134
- invalid_cwd: "That directory name is not valid.",
32135
- cwd_mismatch: "That conversation is not in this directory. Pick it again from the list.",
32136
- unknown_agent: "That machine has no such agent (agents.toml may have changed). Check agents.toml there and restart the connector after a change.",
32137
- not_delivered: "The machine never got it, so nothing ran: it looked online when it was sent but had gone (a laptop closed, for one). Send it again once the machine is back.",
32138
- delivery_unconfirmed: "The machine went just as this was sent and did not confirm it got it, so it may not have run. If it does once the machine is back, what it says shows up here.",
32139
- connector_revoked: "That machine's connector was signed out (logout or `/agent off`), and its sessions closed with it. To go on, sign the connector in again there and start a new session.",
32140
- machine_reconnected: "That machine registered again (a reinstall, lost local state or a rebuilt container), and the old session closed with its old registration.",
32141
- unknown_session: "The connector no longer knows this session (it may have restarted).",
32142
- too_many_sessions: "Too many sessions are open on that machine. Close one with `/agent close` first.",
32143
- resume_not_supported: "This agent cannot continue an existing session.",
32144
- attach_unavailable: "This agent cannot take over a terminal conversation. Configure an agent with the `claude-attach` preset for that.",
32145
- resume_ref_required: "No conversation was named to take over. Pick one from the list.",
32146
- invalid_resume_ref: "That conversation reference is not valid. Pick one from the list.",
32147
- already_attached: "That conversation is already open from the phone. Switch to it with `/agent sessions`.",
32148
- catalog_unavailable: "The connector could not read the list of conversations on that machine.",
32149
- session_live: "That conversation is still open in a terminal on that machine. Quit it there first, then take it over.",
32150
- recently_written: "A terminal wrote to that conversation moments ago and may still be using it. Try again in a minute.",
32151
- twin_check_failed: "The connector could not check whether the conversation is still open in a terminal, so it did not take it over.",
32152
- terminal_did_not_exit: "The terminal did not let the conversation go when asked, so it was not taken over; it is still there. Quit it in the terminal first, then take it over.",
32153
- session_live_elsewhere: "That conversation is open on another machine or container sharing the Claude config directory; it cannot be ended from here, so it was not taken over. Quit it there, then try again.",
32154
- takeover_not_permitted: "The terminal holding the conversation belongs to another user, so the connector may not end it; it was not taken over.",
32155
- takeover_failed: "Ending the terminal's hold on the conversation failed, so it was not taken over.",
32156
- // (since connector 0.1.19 a running turn never holds a message back: Claude Code queues it; only someone's half-typed text in
32157
- // the box, or a screen scrolled back, held for 10 minutes ends it terminal_busy)
32158
- terminal_busy: "Someone was typing in the terminal (or had it scrolled back) for 10 minutes, so the message was not typed in. Send it again later.",
32159
- // (Claude Code took the message into its own queue, then someone at the terminal pulled that queue back into the box)
32160
- terminal_input_withdrawn: "The message was in Claude Code's queue in the terminal, but someone there pulled the queue back into the input box (up-arrow to edit), so it was not sent as the phone's message; it is now in the terminal's input box. To send it, press Enter in the terminal, or send it again from the phone.",
32161
- // (a terminal whose Claude Code cannot be told to hold this conversation, for 10 minutes)
32162
- terminal_state_unknown: "For 10 minutes the connector could not confirm that the terminal's Claude Code still has this conversation open, so the message was not typed in. Look at the terminal, make sure it is still on this conversation, and send again.",
32163
- terminal_gone: "The terminal's tmux pane is gone, so the message was not typed in.",
32164
- terminal_switched: "That terminal has moved to another conversation (a /resume or /clear there), so the message was not typed in.",
32165
- terminal_input_failed: "Typing the message into the terminal failed; it was not sent.",
32166
- // (a connector after 0.1.22: the paste never showed in the box in the 20 seconds it waited)
32167
- terminal_input_unseen: "The message was typed into the terminal, but the terminal did not show it for 20 seconds (Claude Code there is busy or not taking input), so nothing was sent. Send it again in a moment.",
32168
- // (not a failure: the terminal may well have taken it; what the session does next still shows here)
32169
- terminal_input_unconfirmed: "The message was typed into the terminal, but its transcript did not show it within 20 seconds, so it is not known whether the session took it. Whatever the session answers still shows here. Look at the terminal before you send it again, so it does not run twice.",
32170
- terminal_input_unavailable: "After a restart the connector could not prove that terminal again, so the message was not typed in. Attach again.",
32171
- empty_prompt: "The message was empty once its control characters were removed; nothing was typed.",
32172
- // (a prompt to a session that only watches a terminal's conversation; also a turn_end error)
32173
- read_only_live_session: "That conversation is open in a terminal on that machine and can only be watched from here, so the message was not sent. Type it in the terminal, or take the conversation over first.",
32174
- terminal_session: "That conversation is open in a terminal, which keeps its own mode.",
32175
- terminal_mode_not_allowed: "The terminal's conversation is in a permission mode that does not ask (auto, for example), which this agent's approval setting does not allow from the phone, so the message was not typed in. Switch the terminal to a mode that asks (shift+tab in Claude Code: manual or plan) and send again, or set `approval = \"never\"` for this agent in agents.toml on that machine.",
32176
- terminal_mode_unknown: "The connector could not read which permission mode the terminal's conversation is in, so nothing was typed. Make sure Claude Code there is up to date and shows its mode below the input box, then send again.",
32177
- terminal_screen_unknown: "The connector could not read the terminal's screen for 30 seconds (no Claude Code input box, and it did not say it was busy), so the message was not typed in. Look at the terminal, close whatever is on it, and send again.",
32178
- terminal_command_refused: "A message that starts with ! or / would run a command in that terminal, so it is not typed from the phone. Rephrase it, or run the command at the terminal.",
32179
- takeover_expired: "The confirmation to take that conversation over reached the machine too late; it was not taken over. Open it again and confirm again.",
32180
- cwd_ambiguous: "More than one of this agent's roots has a folder by that name. Give its full path.",
32181
- root_unavailable: "The folder's disk is not answering on that machine (a network mount that is down or not mounted yet). Try again in a minute, or check the mount there.",
32182
- session_closed: "That session has already closed.",
32183
- closed: "The session was closed as asked.",
32184
- stopped: "The connector on that machine was stopped. Start it again there (`claw-connector run`, or the service's `sh keepalive.sh`).",
32185
- paused: "The connector on that machine is paused. Run `claw-connector resume` there.",
32186
- revoked: "That machine's connector was revoked. Run `{login}` there to sign in again.",
32187
- text_required: "The message to the agent was empty.",
32188
- action_and_option_required: "That answer named no request or option. Tap the card again.",
32189
- too_many_queued_prompts: "The agent has too many messages waiting; this one was not taken. Send it again when it has caught up.",
32190
- cancelled: "That message was dropped unrun when the agent was stopped.",
32191
- unknown_action: "That approval request is gone.",
32192
- option_not_offered: "That option is not one the agent offered."
32193
- },
32194
- zh: {
32195
- mode_unavailable: '\u90A3\u53F0\u673A\u5668\u4E0A\u7684 agent \u4E0D\u63D0\u4F9B\u8FD9\u4E2A\u4F1A\u8BDD\u9700\u8981\u7684\u6743\u9650\u6A21\u5F0F\u3002\u6700\u5E38\u89C1\u7684\u539F\u56E0\uFF1A\u8FDE\u63A5\u5668\u4EE5 root \u8FD0\u884C\u4E14\u8BE5 agent \u8BBE\u4E86 `approval = "never"`\uFF0Croot \u4E0B\u7684 Claude \u4E0D\u63D0\u4F9B bypassPermissions\uFF0C\u65E7\u7248\u8FDE\u63A5\u5668\uFF080.1.5 \u4E4B\u524D\uFF09\u56E0\u6B64\u62D2\u7EDD\u5F00\u4F1A\u8BDD\u3002',
32196
- mode_not_enforced: 'agent \u6CA1\u80FD\u5207\u5230\u8FDE\u63A5\u5668\u8981\u6C42\u7684\u6743\u9650\u6A21\u5F0F\uFF08\u6216\u63D0\u793A\u5B83\u4E0D\u4F1A\u518D\u9010\u6B65\u8BE2\u95EE\uFF09\uFF0C\u8FDE\u63A5\u5668\u4E3A\u5B89\u5168\u8D77\u89C1\u5173\u95ED\u4E86\u4F1A\u8BDD\u3002\u5E38\u89C1\u4E8E root \u4E0B\u7684 Claude \uFF08\u65E7\u7248\u8FDE\u63A5\u5668\uFF09\uFF0C\u6216 Claude \u7684 `permissions.defaultMode` \u662F bypassPermissions \u800C\u8BE5 agent \u6CA1\u8BBE `approval = "never"`\u3002',
32197
- mode_not_confirmed: "agent \u6CA1\u6709\u786E\u8BA4\u5B83\u5DF2\u5207\u5230\u8981\u6C42\u7684\u6743\u9650\u6A21\u5F0F\uFF0C\u8FDE\u63A5\u5668\u4E3A\u5B89\u5168\u8D77\u89C1\u5173\u95ED\u4E86\u4F1A\u8BDD\u3002\u5347\u7EA7\u8FDE\u63A5\u5668\uFF08\u4F1A\u5E26\u4E0A\u8F83\u65B0\u7684 agent \u9002\u914D\u5668\uFF09\u540E\u518D\u8BD5\u3002",
32198
- mode_mismatch: "agent \u62A5\u544A\u7684\u6743\u9650\u6A21\u5F0F\u548C\u8981\u6C42\u7684\u4E0D\u4E00\u81F4\uFF0C\u8FDE\u63A5\u5668\u4E3A\u5B89\u5168\u8D77\u89C1\u5173\u95ED\u4E86\u4F1A\u8BDD\u3002\u5347\u7EA7\u8FDE\u63A5\u5668\u540E\u518D\u8BD5\uFF1B\u4ECD\u7136\u51FA\u73B0\u7684\u8BDD\uFF0C\u68C0\u67E5\u90A3\u53F0\u673A\u5668\u4E0A Claude \u7684\u8BBE\u7F6E\u3002",
32199
- mode_not_allowed: '\u8FD9\u4E2A\u6A21\u5F0F\u4E0D\u9010\u6B65\u8BE2\u95EE\u6743\u9650\uFF0C\u800C\u8BE5 agent \u5728\u90A3\u53F0\u673A\u5668\u4E0A\u6CA1\u6709\u88AB\u5141\u8BB8\u8FD9\u6837\u8FD0\u884C\u3002\u8981\u5141\u8BB8\uFF0C\u5728 agents.toml \u91CC\u7ED9\u8BE5 agent \u8BBE `approval = "never"` \u5E76\u91CD\u542F\u8FDE\u63A5\u5668\uFF1B\u5426\u5219\u8BF7\u9009\u4E00\u4E2A\u4F1A\u8BE2\u95EE\u7684\u6A21\u5F0F\u3002',
32200
- mode_id_required: "\u5207\u6362\u6A21\u5F0F\u7684\u8BF7\u6C42\u91CC\u7F3A\u5C11\u6A21\u5F0F\u540D\u3002\u70B9\u300C\u6A21\u5F0F\u300D\u518D\u9009\u4E00\u6B21\u3002",
32201
- set_mode_failed: "agent \u6CA1\u80FD\u5207\u6362\u6A21\u5F0F\uFF0C\u4ECD\u662F\u539F\u6765\u7684\u6A21\u5F0F\u3002",
32202
- adapter_gone: "\u90A3\u53F0\u673A\u5668\u4E0A\u7684 agent \u7A0B\u5E8F\u5DF2\u7ECF\u9000\u51FA\u4E86\u3002",
32203
- adapter_start_failed: "\u8FDE\u63A5\u5668\u6CA1\u80FD\u5728\u90A3\u53F0\u673A\u5668\u4E0A\u542F\u52A8 agent \u7A0B\u5E8F\uFF08\u5E38\u89C1\u539F\u56E0\uFF1A\u8BBF\u95EE\u4E0D\u4E86 npm \u4ED3\u5E93\u3001\u547D\u4EE4\u4E0D\u5B58\u5728\uFF09\u3002\u5728\u90A3\u53F0\u673A\u5668\u4E0A\u8FD0\u884C `claw-connector status`\uFF0C\u5E76\u770B\u72B6\u6001\u76EE\u5F55\u91CC\u7684 `run.log`\u3002",
32204
- adapter_unavailable: "\u8FDE\u63A5\u5668\u6CA1\u80FD\u4E3A\u8FD9\u4E00\u8F6E\u542F\u52A8 agent \u7A0B\u5E8F\u3002",
32205
- adapter_protocol: "agent \u7A0B\u5E8F\u7684\u5E94\u7B54\u548C\u8FDE\u63A5\u5668\u9884\u671F\u7684\u4E0D\u4E00\u81F4\uFF0C\u591A\u534A\u662F\u7248\u672C\u4E0D\u5339\u914D\u3002\u5347\u7EA7\u8FDE\u63A5\u5668\u540E\u518D\u8BD5\u3002",
32206
- adapter_cannot_resume: "\u8FD9\u4E2A agent \u4E0D\u80FD\u63A5\u7740\u4E4B\u524D\u7684\u5BF9\u8BDD\u7EE7\u7EED\u3002",
32207
- adapter_error: "agent \u7A0B\u5E8F\u62A5\u9519\u4E86\u3002\u5728\u90A3\u53F0\u673A\u5668\u4E0A\u770B\u8FDE\u63A5\u5668\u72B6\u6001\u76EE\u5F55\u91CC\u7684 `run.log`\u3002",
32208
- agent_auth_required: "\u90A3\u53F0\u673A\u5668\u4E0A\u7684 agent \u8FD8\u6CA1\u767B\u5F55\u3002\u5728\u90A3\u53F0\u673A\u5668\u4E0A\u8FD0\u884C\u4E00\u6B21 agent\uFF08\u4F8B\u5982 `claude`\uFF09\u5B8C\u6210\u767B\u5F55\uFF0C\u518D\u8BD5\u3002",
32209
- cwd_outside_roots: "\u8FD9\u4E2A\u76EE\u5F55\u4E0D\u5728\u8BE5 agent \u5141\u8BB8\u7684 roots \u91CC\u3002\u6362\u4E00\u4E2A roots \u91CC\u7684\u76EE\u5F55\uFF0C\u6216\u5728 agents.toml \u7684 `roots` \u91CC\u52A0\u4E0A\u5B83\u5E76\u91CD\u542F\u8FDE\u63A5\u5668\u3002",
32210
- cwd_not_found: "\u90A3\u53F0\u673A\u5668\u4E0A\u6CA1\u6709\u8FD9\u4E2A\u76EE\u5F55\uFF1A\u9009\u4E00\u4E2A\u90A3\u91CC\u5DF2\u6709\u7684\u76EE\u5F55\uFF0C\u6216\u8005\u5148\u5728\u90A3\u53F0\u673A\u5668\u4E0A\u5EFA\u597D\u5B83\u3002",
32211
- cwd_not_directory: "\u8FD9\u4E2A\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55\u3002",
32212
- cwd_not_absolute: "\u76EE\u5F55\u8981\u5199\u6210\u7EDD\u5BF9\u8DEF\u5F84\uFF08\u4EE5 / \u5F00\u5934\uFF09\u3002",
32213
- invalid_cwd: "\u8FD9\u4E2A\u76EE\u5F55\u540D\u65E0\u6548\uFF0C\u6362\u4E00\u4E2A\u76EE\u5F55\u518D\u8BD5\u3002",
32214
- cwd_mismatch: "\u6240\u9009\u5BF9\u8BDD\u4E0D\u5728\u8FD9\u4E2A\u76EE\u5F55\u91CC\u3002\u4ECE\u5217\u8868\u91CC\u91CD\u65B0\u9009\u3002",
32215
- unknown_agent: "\u90A3\u53F0\u673A\u5668\u4E0A\u6CA1\u6709\u8FD9\u4E2A agent\uFF08agents.toml \u53EF\u80FD\u6539\u8FC7\uFF09\u3002\u5728\u90A3\u53F0\u673A\u5668\u4E0A\u68C0\u67E5 agents.toml\uFF0C\u6539\u540E\u91CD\u542F\u8FDE\u63A5\u5668\u3002",
32216
- not_delivered: "\u90A3\u53F0\u673A\u5668\u6CA1\u6536\u5230\uFF0C\u4EC0\u4E48\u90FD\u6CA1\u6267\u884C\uFF1A\u53D1\u51FA\u65F6\u5B83\u770B\u8D77\u6765\u5728\u7EBF\uFF0C\u4F46\u5DF2\u7ECF\u65AD\u5F00\uFF08\u6BD4\u5982\u7B14\u8BB0\u672C\u5408\u76D6\u4E86\uFF09\u3002\u7B49\u5B83\u91CD\u65B0\u8FDE\u4E0A\u540E\u518D\u53D1\u4E00\u6B21\u3002",
32217
- delivery_unconfirmed: "\u90A3\u53F0\u673A\u5668\u5728\u8FD9\u6761\u6D88\u606F\u53D1\u51FA\u524D\u540E\u65AD\u5F00\u4E86\uFF0C\u6CA1\u6709\u786E\u8BA4\u6536\u5230\uFF0C\u53EF\u80FD\u6CA1\u6709\u6267\u884C\u3002\u5B83\u91CD\u65B0\u8FDE\u4E0A\u540E\u5982\u679C\u505A\u4E86\uFF0C\u7ED3\u679C\u4F1A\u51FA\u73B0\u5728\u8FD9\u91CC\u3002",
32218
- connector_revoked: "\u90A3\u53F0\u673A\u5668\u7684\u8FDE\u63A5\u5668\u5DF2\u88AB\u6CE8\u9500\uFF08logout \u6216 `/agent off`\uFF09\uFF0C\u5B83\u4E0A\u9762\u7684\u4F1A\u8BDD\u968F\u4E4B\u5173\u95ED\u3002\u8981\u7EE7\u7EED\uFF0C\u5728\u90A3\u53F0\u673A\u5668\u4E0A\u91CD\u65B0\u767B\u5F55\u8FDE\u63A5\u5668\uFF0C\u518D\u5F00\u65B0\u4F1A\u8BDD\u3002",
32219
- machine_reconnected: "\u90A3\u53F0\u673A\u5668\u91CD\u65B0\u6CE8\u518C\u8FC7\uFF08\u91CD\u88C5\u3001\u4E22\u4E86\u672C\u5730\u72B6\u6001\u6216\u91CD\u5EFA\u4E86\u5BB9\u5668\uFF09\uFF0C\u65E7\u4F1A\u8BDD\u968F\u65E7\u6CE8\u518C\u5173\u95ED\u4E86\u3002",
32220
- unknown_session: "\u8FDE\u63A5\u5668\u4E0D\u8BA4\u8BC6\u8FD9\u4E2A\u4F1A\u8BDD\u4E86\uFF08\u53EF\u80FD\u5DF2\u91CD\u542F\u6216\u6E05\u7406\u8FC7\uFF09\u3002",
32221
- too_many_sessions: "\u90A3\u53F0\u673A\u5668\u4E0A\u540C\u65F6\u5F00\u7740\u7684\u4F1A\u8BDD\u592A\u591A\u4E86\u3002\u5148\u7528 `/agent close` \u5173\u6389\u4E00\u4E2A\u3002",
32222
- resume_not_supported: "\u8FD9\u4E2A agent \u4E0D\u652F\u6301\u63A5\u7740\u5DF2\u6709\u7684\u4F1A\u8BDD\u7EE7\u7EED\u3002",
32223
- attach_unavailable: "\u8FD9\u4E2A agent \u4E0D\u652F\u6301\u63A5\u7BA1\u7EC8\u7AEF\u91CC\u7684\u5BF9\u8BDD\u3002\u8981\u63A5\u7BA1\uFF0C\u8BF7\u7528 `claude-attach` \u9884\u8BBE\u914D\u7F6E\u4E00\u4E2A agent\u3002",
32224
- resume_ref_required: "\u6CA1\u6709\u6307\u660E\u8981\u63A5\u7BA1\u54EA\u6BB5\u5BF9\u8BDD\u3002\u4ECE\u5217\u8868\u91CC\u91CD\u65B0\u9009\u3002",
32225
- invalid_resume_ref: "\u8981\u63A5\u7BA1\u7684\u5BF9\u8BDD\u7F16\u53F7\u65E0\u6548\u3002\u4ECE\u5217\u8868\u91CC\u91CD\u65B0\u9009\u3002",
32226
- already_attached: "\u8FD9\u6BB5\u5BF9\u8BDD\u5DF2\u7ECF\u5728\u624B\u673A\u4E0A\u6253\u5F00\u4E86\u3002\u7528 `/agent sessions` \u5207\u8FC7\u53BB\u3002",
32227
- catalog_unavailable: "\u8FDE\u63A5\u5668\u6682\u65F6\u8BFB\u4E0D\u5230\u90A3\u53F0\u673A\u5668\u4E0A\u7684\u5BF9\u8BDD\u5217\u8868\u3002",
32228
- session_live: "\u8FD9\u6BB5\u5BF9\u8BDD\u8FD8\u5728\u90A3\u53F0\u673A\u5668\u7684\u7EC8\u7AEF\u91CC\u5F00\u7740\u3002\u5148\u5728\u7EC8\u7AEF\u91CC\u9000\u51FA\u5B83\uFF0C\u518D\u63A5\u7BA1\u3002",
32229
- recently_written: "\u7EC8\u7AEF\u521A\u5199\u8FC7\u8FD9\u6BB5\u5BF9\u8BDD\uFF0C\u53EF\u80FD\u8FD8\u5728\u7528\u3002\u8FC7\u4E00\u5206\u949F\u518D\u8BD5\u3002",
32230
- twin_check_failed: "\u8FDE\u63A5\u5668\u6CA1\u80FD\u786E\u8BA4\u8FD9\u6BB5\u5BF9\u8BDD\u662F\u5426\u8FD8\u5728\u7EC8\u7AEF\u91CC\u5F00\u7740\uFF0C\u4E3A\u5B89\u5168\u8D77\u89C1\u6CA1\u6709\u63A5\u7BA1\u3002",
32231
- terminal_did_not_exit: "\u7EC8\u7AEF\u91CC\u7684\u8FD9\u6BB5\u5BF9\u8BDD\u6CA1\u6709\u6309\u8981\u6C42\u9000\u51FA\uFF0C\u6240\u4EE5\u6CA1\u6709\u63A5\u7BA1\uFF0C\u5B83\u8FD8\u5728\u7EC8\u7AEF\u91CC\u3002\u5148\u5728\u7EC8\u7AEF\u91CC\u9000\u51FA\u5B83\uFF0C\u518D\u63A5\u7BA1\u3002",
32232
- session_live_elsewhere: "\u8FD9\u6BB5\u5BF9\u8BDD\u5F00\u5728\u53E6\u4E00\u53F0\u673A\u5668\u6216\u5BB9\u5668\u91CC\uFF08\u5171\u7528\u540C\u4E00\u4E2A Claude \u914D\u7F6E\u76EE\u5F55\uFF09\uFF0C\u8FD9\u91CC\u7ED3\u675F\u4E0D\u4E86\u5B83\uFF0C\u6240\u4EE5\u6CA1\u6709\u63A5\u7BA1\u3002\u5728\u90A3\u8FB9\u9000\u51FA\u5B83\u518D\u8BD5\u3002",
32233
- takeover_not_permitted: "\u7EC8\u7AEF\u91CC\u7684\u8FD9\u6BB5\u5BF9\u8BDD\u5C5E\u4E8E\u53E6\u4E00\u4E2A\u7CFB\u7EDF\u7528\u6237\uFF0C\u8FDE\u63A5\u5668\u65E0\u6743\u7ED3\u675F\u5B83\uFF0C\u6240\u4EE5\u6CA1\u6709\u63A5\u7BA1\u3002",
32234
- takeover_failed: "\u7ED3\u675F\u7EC8\u7AEF\u91CC\u7684\u8FD9\u6BB5\u5BF9\u8BDD\u5931\u8D25\u4E86\uFF0C\u6240\u4EE5\u6CA1\u6709\u63A5\u7BA1\u3002",
32235
- terminal_busy: "\u7EC8\u7AEF\u91CC\u6709\u4EBA\u5728\u8F93\u5165\uFF08\u6216\u6B63\u5728\u56DE\u6EDA\u67E5\u770B\uFF09\uFF0C\u7B49\u4E86 10 \u5206\u949F\u4E5F\u6CA1\u7A7A\u51FA\u6765\uFF0C\u8FD9\u6761\u6D88\u606F\u6CA1\u6709\u53D1\u8FDB\u53BB\u3002\u7A0D\u540E\u518D\u53D1\u3002",
32236
- terminal_input_withdrawn: "\u8FD9\u6761\u6D88\u606F\u5DF2\u7ECF\u6392\u8FDB\u7EC8\u7AEF\u91CC Claude Code \u7684\u961F\u5217\uFF0C\u4F46\u540E\u6765\u7EC8\u7AEF\u91CC\u6709\u4EBA\u628A\u961F\u5217\u62C9\u56DE\u4E86\u8F93\u5165\u6846\uFF08\u6309\u4E86\u4E0A\u952E\u7F16\u8F91\uFF09\uFF0C\u6240\u4EE5\u5B83\u6CA1\u6709\u4F5C\u4E3A\u624B\u673A\u6D88\u606F\u53D1\u51FA\uFF0C\u73B0\u5728\u5728\u7EC8\u7AEF\u7684\u8F93\u5165\u6846\u91CC\u3002\u8981\u53D1\uFF0C\u8BF7\u5728\u7EC8\u7AEF\u91CC\u56DE\u8F66\uFF0C\u6216\u4ECE\u624B\u673A\u91CD\u53D1\u3002",
32237
- terminal_state_unknown: "\u8FDE\u63A5\u5668 10 \u5206\u949F\u5185\u90FD\u6CA1\u6CD5\u786E\u8BA4\u90A3\u4E2A\u7EC8\u7AEF\u91CC\u7684 Claude Code \u8FD8\u5F00\u7740\u8FD9\u6BB5\u5BF9\u8BDD\uFF0C\u8FD9\u6761\u6D88\u606F\u6CA1\u6709\u53D1\u8FDB\u53BB\u3002\u770B\u4E00\u773C\u7EC8\u7AEF\uFF0C\u786E\u8BA4\u5B83\u8FD8\u5728\u8FD9\u6BB5\u5BF9\u8BDD\u91CC\uFF0C\u518D\u53D1\u4E00\u6B21\u3002",
32238
- terminal_gone: "\u7EC8\u7AEF\u90A3\u8FB9\u7684 tmux \u7A97\u683C\u5DF2\u7ECF\u6CA1\u4E86\uFF0C\u8FD9\u6761\u6D88\u606F\u6CA1\u6709\u53D1\u8FDB\u53BB\u3002",
32239
- terminal_switched: "\u90A3\u4E2A\u7EC8\u7AEF\u5DF2\u7ECF\u6362\u5230\u53E6\u4E00\u6BB5\u5BF9\u8BDD\u4E86\uFF08\u5728\u7EC8\u7AEF\u91CC /resume \u6216 /clear \u8FC7\uFF09\uFF0C\u8FD9\u6761\u6D88\u606F\u6CA1\u6709\u53D1\u8FDB\u53BB\u3002",
32240
- terminal_input_failed: "\u5F80\u7EC8\u7AEF\u91CC\u8F93\u5165\u8FD9\u6761\u6D88\u606F\u5931\u8D25\u4E86\uFF0C\u6CA1\u6709\u53D1\u8FDB\u53BB\u3002",
32241
- terminal_input_unseen: "\u8FD9\u6761\u6D88\u606F\u8F93\u8FDB\u7EC8\u7AEF\u540E\uFF0C\u7B49\u4E86 20 \u79D2\u7EC8\u7AEF\u90FD\u6CA1\u6709\u663E\u793A\u5B83\uFF08\u90A3\u8FB9\u7684 Claude Code \u6B63\u5FD9\u6216\u6CA1\u5728\u63A5\u6536\u8F93\u5165\uFF09\uFF0C\u6240\u4EE5\u6CA1\u6709\u53D1\u51FA\u53BB\u3002\u7A0D\u540E\u518D\u53D1\u4E00\u6B21\u3002",
32242
- terminal_input_unconfirmed: "\u6D88\u606F\u5DF2\u7ECF\u8F93\u5165\u7EC8\u7AEF\uFF0C\u4F46 20 \u79D2\u5185\u7EC8\u7AEF\u7684\u5BF9\u8BDD\u8BB0\u5F55\u91CC\u8FD8\u6CA1\u770B\u5230\u5B83\uFF0C\u6682\u65F6\u4E0D\u80FD\u786E\u8BA4\u90A3\u8FB9\u5DF2\u7ECF\u6536\u5230\u3002\u90A3\u8FB9\u4E4B\u540E\u7684\u56DE\u590D\u4ECD\u4F1A\u53D1\u5230\u8FD9\u91CC\u3002\u8981\u91CD\u53D1\u7684\u8BDD\u5148\u770B\u4E00\u773C\u7EC8\u7AEF\uFF0C\u514D\u5F97\u540C\u4E00\u4EF6\u4E8B\u505A\u4E24\u904D\u3002",
32243
- terminal_input_unavailable: "\u8FDE\u63A5\u5668\u91CD\u542F\u540E\u6CA1\u80FD\u518D\u786E\u8BA4\u90A3\u4E2A\u7EC8\u7AEF\uFF0C\u8FD9\u6761\u6D88\u606F\u6CA1\u6709\u53D1\u8FDB\u53BB\u3002\u91CD\u65B0 attach \u4E00\u6B21\u3002",
32244
- empty_prompt: "\u8FD9\u6761\u6D88\u606F\u53BB\u6389\u63A7\u5236\u5B57\u7B26\u540E\u662F\u7A7A\u7684\uFF0C\u6CA1\u6709\u53D1\u8FDB\u7EC8\u7AEF\u3002",
32245
- read_only_live_session: "\u8FD9\u6BB5\u5BF9\u8BDD\u6B63\u5F00\u5728\u90A3\u53F0\u673A\u5668\u7684\u7EC8\u7AEF\u91CC\uFF0C\u8FD9\u8FB9\u53EA\u80FD\u770B\u3001\u4E0D\u80FD\u8F93\u5165\uFF0C\u8FD9\u6761\u6D88\u606F\u6CA1\u6709\u53D1\u8FDB\u53BB\u3002\u5728\u7EC8\u7AEF\u91CC\u8F93\u5165\uFF0C\u6216\u5148\u63A5\u7BA1\u518D\u53D1\u3002",
32246
- terminal_session: "\u8FD9\u6BB5\u5BF9\u8BDD\u5F00\u5728\u7EC8\u7AEF\u91CC\uFF0C\u6A21\u5F0F\u7531\u7EC8\u7AEF\u51B3\u5B9A\uFF0C\u8FD9\u91CC\u6539\u4E0D\u4E86\u3002",
32247
- terminal_mode_not_allowed: '\u7EC8\u7AEF\u91CC\u8FD9\u6BB5\u5BF9\u8BDD\u7684\u6743\u9650\u6A21\u5F0F\uFF08\u4F8B\u5982 auto\uFF09\u4E0D\u9010\u6B65\u8BE2\u95EE\uFF0C\u800C\u8FD9\u4E2A agent \u7684\u5BA1\u6279\u8BBE\u7F6E\u4E0D\u5141\u8BB8\u4ECE\u624B\u673A\u5F80\u8FD9\u79CD\u6A21\u5F0F\u91CC\u8F93\u5165\uFF0C\u8FD9\u6761\u6D88\u606F\u6CA1\u6709\u53D1\u8FDB\u53BB\u3002\u5728\u7EC8\u7AEF\u91CC\u6309 shift+tab \u5207\u5230\u4F1A\u8BE2\u95EE\u7684\u6A21\u5F0F\uFF08manual \u6216 plan\uFF09\u518D\u53D1\uFF1B\u6216\u5728\u90A3\u53F0\u673A\u5668\u7684 agents.toml \u91CC\u7ED9\u8FD9\u4E2A agent \u8BBE `approval = "never"`\u3002',
32248
- terminal_mode_unknown: "\u8FDE\u63A5\u5668\u8BFB\u4E0D\u51FA\u7EC8\u7AEF\u91CC\u8FD9\u6BB5\u5BF9\u8BDD\u5904\u4E8E\u54EA\u79CD\u6743\u9650\u6A21\u5F0F\uFF0C\u8FD9\u6761\u6D88\u606F\u6CA1\u6709\u53D1\u8FDB\u53BB\u3002\u786E\u8BA4\u90A3\u8FB9\u7684 Claude Code \u662F\u65B0\u7248\u3001\u8F93\u5165\u6846\u4E0B\u65B9\u663E\u793A\u7740\u6A21\u5F0F\uFF0C\u518D\u53D1\u4E00\u6B21\u3002",
32249
- terminal_screen_unknown: "\u8FDE\u63A5\u5668 30 \u79D2\u5185\u90FD\u8BA4\u4E0D\u51FA\u90A3\u4E2A\u7EC8\u7AEF\u7684\u753B\u9762\uFF08\u4E0D\u662F Claude Code \u7684\u8F93\u5165\u6846\uFF0C\u5B83\u4E5F\u6CA1\u8BF4\u81EA\u5DF1\u5728\u5FD9\uFF09\uFF0C\u8FD9\u6761\u6D88\u606F\u6CA1\u6709\u53D1\u8FDB\u53BB\u3002\u770B\u4E00\u773C\u7EC8\u7AEF\uFF0C\u5173\u6389\u4E0A\u9762\u7684\u4E1C\u897F\u518D\u53D1\u3002",
32250
- terminal_command_refused: "\u4EE5 ! \u6216 / \u5F00\u5934\u7684\u6D88\u606F\u4F1A\u5728\u90A3\u4E2A\u7EC8\u7AEF\u91CC\u6267\u884C\u547D\u4EE4\uFF0C\u6240\u4EE5\u4E0D\u4ECE\u624B\u673A\u8F93\u5165\u3002\u6362\u4E2A\u8BF4\u6CD5\uFF0C\u6216\u8005\u5728\u7EC8\u7AEF\u91CC\u81EA\u5DF1\u6267\u884C\u3002",
32251
- takeover_expired: "\u63A5\u7BA1\u786E\u8BA4\u5230\u8FBE\u90A3\u53F0\u673A\u5668\u65F6\u5DF2\u7ECF\u8FC7\u671F\uFF0C\u6CA1\u6709\u63A5\u7BA1\u3002\u91CD\u65B0\u6253\u5F00\u5E76\u518D\u786E\u8BA4\u4E00\u6B21\u3002",
32252
- cwd_ambiguous: "\u8FD9\u4E2A agent \u6709\u4E0D\u6B62\u4E00\u4E2A\u6839\u76EE\u5F55\u91CC\u6709\u540C\u540D\u6587\u4EF6\u5939\u3002\u8BF7\u5199\u51FA\u5B8C\u6574\u8DEF\u5F84\u3002",
32253
- root_unavailable: "\u90A3\u53F0\u673A\u5668\u4E0A\u8FD9\u4E2A\u76EE\u5F55\u6240\u5728\u7684\u76D8\u6CA1\u6709\u54CD\u5E94\uFF08\u7F51\u7EDC\u76D8\u65AD\u4E86\u6216\u8FD8\u6CA1\u6302\u4E0A\uFF09\u3002\u8FC7\u4E00\u5206\u949F\u518D\u8BD5\uFF0C\u6216\u5728\u90A3\u53F0\u673A\u5668\u4E0A\u68C0\u67E5\u6302\u8F7D\u3002",
32254
- session_closed: "\u8FD9\u4E2A\u4F1A\u8BDD\u5DF2\u7ECF\u5173\u4E86\u3002",
32255
- closed: "\u4F1A\u8BDD\u5DF2\u6309\u8981\u6C42\u5173\u95ED\u3002",
32256
- stopped: "\u90A3\u53F0\u673A\u5668\u4E0A\u7684\u8FDE\u63A5\u5668\u505C\u4E86\u3002\u5728\u90A3\u53F0\u673A\u5668\u4E0A\u91CD\u65B0\u542F\u52A8\u5B83\uFF08`claw-connector run`\uFF0C\u6216\u670D\u52A1\u7684 `sh keepalive.sh`\uFF09\u3002",
32257
- paused: "\u90A3\u53F0\u673A\u5668\u4E0A\u7684\u8FDE\u63A5\u5668\u6682\u505C\u4E86\u3002\u5728\u90A3\u53F0\u673A\u5668\u4E0A\u8FD0\u884C `claw-connector resume`\u3002",
32258
- revoked: "\u90A3\u53F0\u673A\u5668\u7684\u8FDE\u63A5\u5668\u5DF2\u88AB\u6CE8\u9500\u3002\u5728\u90A3\u53F0\u673A\u5668\u4E0A\u8FD0\u884C `{login}` \u91CD\u65B0\u767B\u5F55\u3002",
32259
- text_required: "\u53D1\u7ED9 agent \u7684\u6D88\u606F\u662F\u7A7A\u7684\u3002",
32260
- action_and_option_required: "\u8FD9\u6B21\u6279\u51C6\u7F3A\u5C11\u8981\u56DE\u7B54\u7684\u8BF7\u6C42\u6216\u9009\u9879\u3002\u5728\u5361\u7247\u4E0A\u518D\u70B9\u4E00\u6B21\u3002",
32261
- too_many_queued_prompts: "agent \u624B\u4E0A\u6392\u961F\u7684\u6D88\u606F\u592A\u591A\u4E86\uFF0C\u8FD9\u6761\u6CA1\u6709\u6536\u4E0B\u3002\u7B49\u5B83\u5904\u7406\u5B8C\u518D\u53D1\u3002",
32262
- cancelled: "\u8FD9\u6761\u6D88\u606F\u8FD8\u6CA1\u8FD0\u884C\u5C31\u56E0\u4E3A\u505C\u6B62\u800C\u88AB\u4E22\u5F03\u4E86\u3002",
32263
- unknown_action: "\u8FD9\u4E2A\u6279\u51C6\u8BF7\u6C42\u5DF2\u7ECF\u4E0D\u5728\u4E86\u3002",
32264
- option_not_offered: "\u8FD9\u4E2A\u9009\u9879\u4E0D\u662F agent \u63D0\u4F9B\u7684\u3002"
32226
+ setup: this.ctx.setup
32227
+ });
32228
+ if (!machines && card.listing.length === 0) {
32229
+ const { text: text9, listing: listing2 } = sessionsText(sessions, listed.connectors, attached, this.now(), lang);
32230
+ this.ctx.remoteState.setRemoteListing(chatKey, listing2);
32231
+ return { kind: "text", text: (lead ? `${lead}
32232
+
32233
+ ` : "") + text9 };
32234
+ }
32235
+ this.ctx.remoteState.setRemoteListing(chatKey, card.listing);
32236
+ return { kind: "card", message: card.message };
32265
32237
  }
32266
- });
32267
- var connectorReasonHints = defineCatalog({
32268
- en: {
32269
- upgrade: (p) => `Upgrade the connector: on that machine run \`${p.command}\` (it installs the new version and restarts the connector on it).`,
32270
- sandbox: 'Workaround (only when the connector runs as root and the agent has `approval = "never"`): add `env = { IS_SANDBOX = "1" }` under that agent in agents.toml (or `IS_SANDBOX = "1"` in its existing `[agents.env]`), then restart the connector.',
32271
- status: "Run `claw-connector status` on that machine and look for a warning or problem line.",
32272
- newSession: "Start a new one with `/agent new`.",
32273
- retry: "Try again in a moment.",
32274
- unknown: (p) => `The connector gave a reason I do not know (${p.code}). Run \`claw-connector status\` on that machine, or upgrade the connector and try again.`,
32275
- /** Between a lead and the reason after it, and the end of a lead with none. */
32276
- leadSep: ": ",
32277
- leadEnd: "."
32278
- },
32279
- zh: {
32280
- upgrade: (p) => `\u5347\u7EA7\u8FDE\u63A5\u5668\uFF1A\u5728\u90A3\u53F0\u673A\u5668\u4E0A\u8FD0\u884C \`${p.command}\`\uFF08\u4F1A\u88C5\u4E0A\u65B0\u7248\u672C\u5E76\u91CD\u542F\u8FDE\u63A5\u5668\uFF09\u3002`,
32281
- sandbox: '\u4E34\u65F6\u7ED5\u8FC7\uFF08\u4EC5\u5F53\u8FDE\u63A5\u5668\u4EE5 root \u8FD0\u884C\u3001\u4E14\u8BE5 agent \u8BBE\u4E86 `approval = "never"`\uFF09\uFF1A\u5728 agents.toml \u91CC\u8BE5 agent \u4E0B\u52A0 `env = { IS_SANDBOX = "1" }`\uFF08\u5DF2\u6709 `[agents.env]` \u7684\uFF0C\u5728\u5176\u4E2D\u52A0 `IS_SANDBOX = "1"`\uFF09\uFF0C\u518D\u91CD\u542F\u8FDE\u63A5\u5668\u3002',
32282
- status: "\u5728\u90A3\u53F0\u673A\u5668\u4E0A\u8FD0\u884C `claw-connector status`\uFF0C\u770B\u6709\u6CA1\u6709 warning \u6216 problem \u884C\u3002",
32283
- newSession: "\u7528 `/agent new` \u5F00\u4E00\u4E2A\u65B0\u4F1A\u8BDD\u3002",
32284
- retry: "\u7A0D\u540E\u518D\u8BD5\u4E00\u6B21\u3002",
32285
- unknown: (p) => `\u8FDE\u63A5\u5668\u7ED9\u51FA\u4E86\u4E00\u4E2A\u6211\u4E0D\u8BA4\u8BC6\u7684\u539F\u56E0\uFF08${p.code}\uFF09\u3002\u5728\u90A3\u53F0\u673A\u5668\u4E0A\u8FD0\u884C \`claw-connector status\` \u770B\u770B\uFF0C\u6216\u5347\u7EA7\u8FDE\u63A5\u5668\u540E\u518D\u8BD5\u3002`,
32286
- leadSep: "\uFF1A",
32287
- leadEnd: "\u3002"
32238
+ /** Every session the user has, on every machine; its active ones are the numbers of `/agent attach N` from now on. */
32239
+ async sessionsView(chatKey, key, lang, lead = "") {
32240
+ const listed = await this.machines(key);
32241
+ const { sessions } = await this.sessions(key);
32242
+ const state = this.ctx.remoteState.attachedRemote(chatKey);
32243
+ const card = this.ctx.views.sessions({
32244
+ connectors: listed.connectors,
32245
+ sessions,
32246
+ attached: state?.sessionId ?? null,
32247
+ now: this.now(),
32248
+ lang,
32249
+ lead,
32250
+ waiting: this.ctx.permissions.waitingRemoteSessions(chatKey),
32251
+ setup: listed.connectors.length === 0 ? await this.setup(key) : this.ctx.setup
32252
+ });
32253
+ this.ctx.remoteState.setRemoteListing(chatKey, card.listing);
32254
+ return card.message;
32288
32255
  }
32289
- });
32290
-
32291
- // packages/core/src/remote/connector/reasons.ts
32292
- var FIXED_IN = [0, 1, 5];
32293
- var CODE4 = /^[a-z][a-z0-9_]{0,63}$/u;
32294
- var VERSION = /^v?(\d+)\.(\d+)\.(\d+)/u;
32295
- var both = (fn) => [fn("zh"), fn("en")];
32296
- var UPGRADE = both((lang) => connectorReasonHints.in(lang).upgrade({ command: UPGRADE_COMMAND }));
32297
- var SANDBOX = both((lang) => connectorReasonHints.in(lang).sandbox);
32298
- var STATUS2 = both((lang) => connectorReasonHints.in(lang).status);
32299
- var OLD_CONNECTOR = /* @__PURE__ */ new Set(["mode_unavailable", "mode_not_enforced"]);
32300
- var FIXED_LATER = {
32301
- terminal_input_unconfirmed: [0, 1, 22]
32302
32256
  };
32303
- var THEN_NEW = /* @__PURE__ */ new Set([
32304
- "adapter_gone",
32305
- "adapter_cannot_resume",
32306
- "unknown_session",
32307
- "resume_not_supported",
32308
- "session_closed",
32309
- "set_mode_failed",
32310
- "machine_reconnected"
32311
- ]);
32312
- var THEN_RETRY = /* @__PURE__ */ new Set(["catalog_unavailable", "twin_check_failed", "adapter_unavailable"]);
32313
- var KNOWN = new Set(Object.keys(connectorReasonText.in("en")));
32314
- function parseVersion2(value) {
32315
- const match = VERSION.exec(typeof value === "string" ? value.trim() : "");
32316
- return match ? [Number(match[1]), Number(match[2]), Number(match[3])] : null;
32317
- }
32318
- function older(version, than) {
32319
- for (let i = 0; i < than.length; i++) {
32320
- const a = version[i] ?? 0;
32321
- const b3 = than[i] ?? 0;
32322
- if (a !== b3) return a < b3;
32323
- }
32324
- return false;
32325
- }
32326
- function isCode(reason) {
32327
- return CODE4.test(reason);
32328
- }
32329
- function sentence2(code3, lang, setup) {
32330
- const text9 = own(connectorReasonText.in(lang), code3) ?? "";
32331
- return code3 === "revoked" ? text9.replaceAll("{login}", setup.login()) : text9;
32332
- }
32333
- function hintAfter(code3, lang, version) {
32334
- const hints = connectorReasonHints.in(lang);
32335
- if (OLD_CONNECTOR.has(code3)) {
32336
- const parsed = parseVersion2(version);
32337
- if (parsed === null || older(parsed, FIXED_IN))
32338
- return { sep: "\n\n", hint: `${hints.upgrade({ command: UPGRADE_COMMAND })}
32339
-
32340
- ${hints.sandbox}
32341
32257
 
32342
- ` };
32343
- return { sep: " ", hint: hints.status };
32258
+ // packages/core/src/remote/clicks-machine.ts
32259
+ var MachineClicks = class {
32260
+ constructor(p, c) {
32261
+ this.p = p;
32262
+ this.c = c;
32344
32263
  }
32345
- const fixedIn = own(FIXED_LATER, code3);
32346
- if (fixedIn) {
32347
- const parsed = parseVersion2(version);
32348
- if (parsed !== null && older(parsed, fixedIn))
32349
- return { sep: "\n\n", hint: hints.upgrade({ command: UPGRADE_COMMAND }) };
32350
- return null;
32264
+ p;
32265
+ c;
32266
+ /** The person's connector the tapped button names, as Claw lists it now; null (said) when it is not theirs any more. */
32267
+ async ownConnector(click, includeHidden = false) {
32268
+ const { connectors } = await this.p.lists.machines(click.key, includeHidden);
32269
+ const found = connectorById(connectors, textOf6(click.data["connector_id"]));
32270
+ if (found === void 0) await this.c.home(click, saidIn(this.c.lang(click), "agentGone"));
32271
+ return found ?? null;
32351
32272
  }
32352
- if (THEN_NEW.has(code3)) return { sep: " ", hint: hints.newSession };
32353
- if (THEN_RETRY.has(code3)) return { sep: " ", hint: hints.retry };
32354
- return null;
32355
- }
32356
- function explain(code3, version = null, setup = new Setup("", null)) {
32357
- if (!KNOWN.has(code3)) return both((lang) => connectorReasonHints.in(lang).unknown({ code: code3 }));
32358
- return both((lang) => {
32359
- const after = hintAfter(code3, lang, version);
32360
- const own3 = sentence2(code3, lang, setup);
32361
- return after ? `${own3}${after.sep}${after.hint}` : own3;
32362
- });
32363
- }
32364
- function bareReason(reason) {
32365
- return pyStrip(pyRstrip(pyStrip(reason ?? ""), "."));
32366
- }
32367
- function inLang(lang, pair) {
32368
- if (lang === "zh") return pair[0];
32369
- if (lang === "en") return pair[1];
32370
- return `${pair[0]}
32371
- ${pair[1]}`;
32372
- }
32373
- function describe2(reason, lang, version = null, setup) {
32374
- const bare2 = bareReason(reason);
32375
- if (!bare2) return "";
32376
- if (!isCode(bare2)) return `${bare2}.`;
32377
- return inLang(lang, explain(bare2, version, setup));
32378
- }
32379
- function ended(lead, reason, lang, version = null, setup) {
32380
- if (lang === null) return ["zh", "en"].map((one) => ended(lead, reason, one, version, setup)).join("\n");
32381
- const why = describe2(reason, lang, version, setup);
32382
- const hints = connectorReasonHints.in(lang);
32383
- const head = inLang(lang, lead);
32384
- return why ? `${head}${hints.leadSep}${why}` : `${head}${hints.leadEnd}`;
32385
- }
32273
+ /** Hide one conversation (`ref`), or every one no process runs of one agent (`all: idle`), from the list. */
32274
+ async hide(click) {
32275
+ const connector = await this.ownConnector(click);
32276
+ if (connector === null) return;
32277
+ const lang = this.c.lang(click);
32278
+ let entries;
32279
+ if (click.data["all"] === "idle") {
32280
+ const agent = connector.agents.find((a) => a.agentId === textOf6(click.data["agent_id"]));
32281
+ entries = (agent ? resumableOf(agent) : []).filter((e) => e.state === "idle");
32282
+ } else {
32283
+ const ref = textOf6(click.data["ref"]);
32284
+ entries = connector.agents.flatMap((a) => resumableOf(a).filter((e) => e.ref === ref)).slice(0, 1);
32285
+ }
32286
+ if (entries.length === 0) return this.c.home(click, saidIn(lang, "conversationGone"));
32287
+ const out = await this.p.ctx.claw.hide(
32288
+ click.key,
32289
+ connector.connectorId,
32290
+ entries.map((e) => e.ref),
32291
+ true
32292
+ );
32293
+ const titles = new Map(entries.map((e) => [e.ref, e.title]));
32294
+ const words3 = remoteText.in(lang);
32295
+ const lines = [words3.hidN({ n: out.changed.length })];
32296
+ for (const refused3 of out.refused) {
32297
+ if (refused3.reason === "live")
32298
+ lines.push(words3.hideLive({ title: neutral(titles.get(refused3.ref) ?? "", 60) || "?" }));
32299
+ }
32300
+ await this.c.home(click, lines.join(" "));
32301
+ }
32302
+ /** The conversations hidden on that machine, each with Unhide. */
32303
+ async hidden(click) {
32304
+ const connector = await this.ownConnector(click, true);
32305
+ if (connector === null) return;
32306
+ await this.c.repost(
32307
+ click,
32308
+ this.p.ctx.views.hidden(connector, this.p.ctx.clock.epochMs() / 1e3, this.c.lang(click))
32309
+ );
32310
+ }
32311
+ /** Show one hidden conversation (`ref`) again, or all of that machine's (`all`). */
32312
+ async unhide(click) {
32313
+ const connector = await this.ownConnector(click, true);
32314
+ if (connector === null) return;
32315
+ const hidden2 = connector.agents.flatMap((a) => hiddenOf(a));
32316
+ const ref = textOf6(click.data["ref"]);
32317
+ const refs = click.data["all"] ? hidden2.map((e) => e.ref) : hidden2.filter((e) => e.ref === ref).map((e) => e.ref);
32318
+ const lang = this.c.lang(click);
32319
+ if (refs.length === 0) return this.c.home(click, saidIn(lang, "conversationGone"));
32320
+ const out = await this.p.ctx.claw.hide(click.key, connector.connectorId, refs, false);
32321
+ await this.c.home(click, remoteText.in(lang).unhidN({ n: out.changed.length }));
32322
+ }
32323
+ /**
32324
+ * A tap on the disconnect card. The card names a connector id; whose it is is Claw's to say (404 for anyone else's), and the
32325
+ * machine's name is read again from the person's own list.
32326
+ */
32327
+ async off(click) {
32328
+ const lang = this.c.lang(click);
32329
+ const words3 = remoteOffText.in(lang);
32330
+ if (!this.p.ctx.settings.enabled) return this.settled(click, words3.inactive);
32331
+ if (click.data["confirm"] !== true) return this.settled(click, words3.kept);
32332
+ const connectorId = textOf6(click.data["connector_id"]);
32333
+ let connector;
32334
+ try {
32335
+ connector = connectorById((await this.p.lists.machines(click.key)).connectors, connectorId);
32336
+ if (connector === void 0) {
32337
+ await this.settled(click, words3.gone);
32338
+ return;
32339
+ }
32340
+ await this.p.ctx.claw.revoke(click.key, connectorId);
32341
+ } catch (error) {
32342
+ return this.offRefused(click, error, connector?.name ?? "", lang);
32343
+ }
32344
+ const state = this.p.state.attached(click.chatKey);
32345
+ if (state?.connectorId === connectorId) {
32346
+ this.p.ops.leave(click.chatKey);
32347
+ }
32348
+ const login = connector.paired ? "" : (await this.p.lists.setup(click.key)).login();
32349
+ await this.c.end(click, disconnectedText(connector.name, login, lang, connector.paired));
32350
+ }
32351
+ /** The tap ends with `text` in place of the card. */
32352
+ async settled(click, text9) {
32353
+ await this.c.end(click, text9);
32354
+ }
32355
+ /** It did not go through: said; where pressing again can help, the card comes back with its buttons. */
32356
+ async offRefused(click, error, name, lang) {
32357
+ const words3 = remoteOffText.in(lang);
32358
+ const connectorId = textOf6(click.data["connector_id"]);
32359
+ const again = async (text9) => {
32360
+ await this.c.end(click, disconnectAgainCard(text9, connectorId, disconnectTitle(name, lang), lang), text9);
32361
+ };
32362
+ if (error instanceof RemoteOff) return this.settled(click, saidIn(lang, "notEnabled"));
32363
+ if (error instanceof ClawError) {
32364
+ if (error.status === 404) return this.settled(click, words3.gone);
32365
+ return again(failureText2(error, this.p.ctx.errors, this.p.ctx.clock.epochMs() / 1e3, lang) + words3.nothing);
32366
+ }
32367
+ if (isTransport2(error)) return again(saidIn(lang, "unreachable") + words3.nothing);
32368
+ throw error;
32369
+ }
32370
+ };
32371
+
32372
+ // packages/core/src/locales/remote-leads.ts
32373
+ var remoteLeads = {
32374
+ sessionEnded: ["\u4F1A\u8BDD\u5DF2\u7ED3\u675F", "The session ended"],
32375
+ couldNotStart: ["\u4F1A\u8BDD\u6CA1\u80FD\u542F\u52A8", "The session could not start"],
32376
+ /** (`folder`: already shown inert, in backticks) */
32377
+ couldNotStartIn: (folder) => [`\u4F1A\u8BDD\u6CA1\u80FD\u5728 ${folder} \u542F\u52A8`, `The session could not start in ${folder}`],
32378
+ turnIncomplete: ["\u8FD9\u4E00\u8F6E\u6CA1\u6709\u5B8C\u6210", "The turn did not complete"],
32379
+ /** (a message the terminal may have taken: never said as a turn that did not complete) */
32380
+ inputUnconfirmed: ["\u8FD8\u6CA1\u786E\u8BA4\u7EC8\u7AEF\u6536\u5230", "Not confirmed by the terminal yet"],
32381
+ modeNotSwitched: ["\u6A21\u5F0F\u6CA1\u6709\u5207\u6362", "The mode was not switched"],
32382
+ notSwitchedTo: (mode) => [`\u6CA1\u6709\u5207\u5230 \`${mode}\``, `The agent did not switch to \`${mode}\``]
32383
+ };
32386
32384
 
32387
32385
  // packages/core/src/remote/ended.ts
32388
32386
  async function credentialOf(key, provider) {
@@ -32510,7 +32508,7 @@ function filled(payload) {
32510
32508
  return payload !== null && Object.keys(payload).length > 0;
32511
32509
  }
32512
32510
  function actionIdOf(payload) {
32513
- return textOf7(payload.actionId);
32511
+ return textOf6(payload.actionId);
32514
32512
  }
32515
32513
  async function readTail(read, decode2) {
32516
32514
  const fold = new TailFold();
@@ -33798,7 +33796,7 @@ var SessionClicks = class {
33798
33796
  /** A tap that did not go through: the status card again when it was one of its buttons and still the chat's, else the list. */
33799
33797
  async back(click, lead) {
33800
33798
  const state = this.p.state.attached(click.chatKey);
33801
- const op = textOf7(click.data["op"]);
33799
+ const op = textOf6(click.data["op"]);
33802
33800
  if (state !== null && (["detach", "mode", "set_mode", "row", "stop"].includes(op) || isGroupKey(click.chatKey)) && // (a group: never the list)
33803
33801
  state.sessionId === click.data["session_id"]) {
33804
33802
  await this.end(click, (await this.p.ops.rowCard(click.chatKey, click.key, state, lead)).message, lead);
@@ -33860,7 +33858,7 @@ var SessionClicks = class {
33860
33858
  async send(click) {
33861
33859
  const state = await this.ownSession(click);
33862
33860
  if (state === null) return;
33863
- const text9 = cpSlice(pyStrip(textOf7(own(click.data, INPUT_ID))), 0, INPUT_MAX);
33861
+ const text9 = cpSlice(pyStrip(textOf6(own(click.data, INPUT_ID))), 0, INPUT_MAX);
33864
33862
  const view7 = this.p.state.view(click.chatKey, state);
33865
33863
  if (!text9) {
33866
33864
  await this.closer(click)(remoteAgentText.in(this.lang(click)).emptySend);
@@ -33915,7 +33913,7 @@ ${block}`, { aiGenerated: true }));
33915
33913
  async setMode(click) {
33916
33914
  const state = await this.ownSession(click);
33917
33915
  if (state === null) return;
33918
- const mode = textOf7(click.data["mode"]);
33916
+ const mode = textOf6(click.data["mode"]);
33919
33917
  const refusal4 = await this.commands.changeMode(click, mode);
33920
33918
  const lead = refusal4 ?? remoteAgentText.in(this.lang(click)).askingSwitch({ mode: neutral(mode, MODE_ID_MAX) });
33921
33919
  await this.end(click, (await this.p.ops.rowCard(click.chatKey, click.key, state, lead)).message, lead);
@@ -33943,7 +33941,7 @@ ${block}`, { aiGenerated: true }));
33943
33941
  if (done && click.tapped) this.p.ctx.remoteState.setRemoteStatusCard(click.chatKey, click.tapped);
33944
33942
  }
33945
33943
  async close(click) {
33946
- const wanted = textOf7(click.data["session_id"]);
33944
+ const wanted = textOf6(click.data["session_id"]);
33947
33945
  const { sessions } = await this.p.lists.sessions(click.key);
33948
33946
  const session = sessions.find((s) => s.sessionId === wanted);
33949
33947
  if (session === void 0) return this.home(click, saidIn(this.lang(click), "sessionNotFound"));
@@ -34148,8 +34146,8 @@ var Permissions = class {
34148
34146
  const personal2 = isGroupKey(chatKey) ? this.ctx.references.getReference(personOf2(chatKey)) : null;
34149
34147
  const groupLang = this.state.lang(chatKey);
34150
34148
  const lang = personal2 ? this.state.lang(personOf2(chatKey)) : groupLang;
34151
- const actionId = textOf7(request["actionId"]);
34152
- if (TERMINAL_ORIGINS.has(textOf7(request["origin"]))) return;
34149
+ const actionId = textOf6(request["actionId"]);
34150
+ if (TERMINAL_ORIGINS.has(textOf6(request["origin"]))) return;
34153
34151
  const options = parseOptions(request["options"]);
34154
34152
  if (!actionId || options.length === 0) {
34155
34153
  await to.send(textMessage(saidIn(groupLang, "noAnswerableOption")));
@@ -34157,7 +34155,7 @@ var Permissions = class {
34157
34155
  }
34158
34156
  const expiresAt = this.ctx.clock.epochMs() / 1e3 + secondsOf2(request["timeout_ms"]);
34159
34157
  const words3 = remoteText.in(lang);
34160
- const tool2 = textOf7(request["tool"]) || words3.anAction;
34158
+ const tool2 = textOf6(request["tool"]) || words3.anAction;
34161
34159
  if (!this.ctx.permissions.saveRemotePermission({
34162
34160
  userId: chatKey,
34163
34161
  sessionId,
@@ -34218,7 +34216,7 @@ var Permissions = class {
34218
34216
  /** A click on an option of a permission card (see the module). */
34219
34217
  async decide(click) {
34220
34218
  const [sessionId, actionId, optionId] = ["session_id", "action_id", "option_id"].map(
34221
- (k) => textOf7(own(click.data, k))
34219
+ (k) => textOf6(own(click.data, k))
34222
34220
  );
34223
34221
  const perm = this.ctx.settings.enabled ? this.ctx.permissions.getRemotePermission(sessionId ?? "", actionId ?? "") : null;
34224
34222
  const lang = this.cardLang(perm, click.person);
@@ -34439,7 +34437,8 @@ var Prompts = class {
34439
34437
  this.closeTurn(p.chatKey, state);
34440
34438
  this.runner.stopReading(p.chatKey);
34441
34439
  }
34442
- if (refused3 !== void 0) await this.say(p.to, text9.queuedRefused({ reason: refused3 }));
34440
+ if (refused3 !== void 0)
34441
+ await this.say(p.to, text9.queuedRefused({ reason: describe2(refused3, this.state.lang(p.chatKey)) }));
34443
34442
  return;
34444
34443
  }
34445
34444
  if (reader) return;
@@ -35398,7 +35397,8 @@ var TurnRunner = class {
35398
35397
  }
35399
35398
  display.movedOn?.();
35400
35399
  try {
35401
- await to.send(textMessage(remoteAgentText.in(this.state.lang(chatKey)).queuedRefused({ reason })));
35400
+ const lang = this.state.lang(chatKey);
35401
+ await to.send(textMessage(remoteAgentText.in(lang).queuedRefused({ reason: describe2(reason, lang) })));
35402
35402
  } catch (error) {
35403
35403
  this.ctx.logger.warn("that a queued message was refused could not be told", { error: errorName(error) });
35404
35404
  }