@primusclaw/personal-agent 0.15.0 → 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
@@ -21433,7 +21433,11 @@ var terminalApprovalText = defineCatalog({
21433
21433
  approvalsOff: "Approvals from terminals are off: questions stay in the terminal.",
21434
21434
  approvalsTurnedOn: "Turned on: questions your terminals ask come here too. `/approvals off` stops it.",
21435
21435
  approvalsTurnedOff: "Turned off: questions stay in the terminal. `/approvals on` brings them back.",
21436
- approvalsUsage: "Use `/approvals on`, `/approvals off`, or `/approvals` to see which it is; `/approvals mute #12` (or `unmute #12`) for one terminal conversation, by the number its message names; `/approvals summary 60` (minutes, 15 to 1440, or `off`) for how often a conversation that keeps working on its own is summed up.",
21436
+ approvalsUsage: "Use `/approvals` to see whether approvals from terminals are on, how often summaries come and which conversations are muted; `/approvals on` or `/approvals off` to change the first; `/approvals mute #12` (or `unmute #12`) for one terminal conversation, by the number its message names; `/approvals summary 60` (minutes, 15 to 1440, or `off`) for how often a conversation that keeps working on its own is summed up.",
21437
+ mutedNone: "No conversation is muted. `/approvals mute #12` mutes one, by the number its message names.",
21438
+ mutedHeader: (p) => `Muted conversations (${p.count}): what they ask, wait for or finish stays in their terminals. \`/approvals unmute #12\` brings one back.`,
21439
+ mutedLine: (p) => p.since ? `${p.who} (muted since ${p.since})` : p.who,
21440
+ mutedUnnamed: "a conversation",
21437
21441
  muted: (p) => `Muted #${p.item}${p.where ? ` (${p.where})` : ""}: what that conversation asks, waits for or finishes stays in its terminal. \`/approvals unmute #${p.item}\` brings it back.`,
21438
21442
  unmuted: (p) => `Unmuted #${p.item}${p.where ? ` (${p.where})` : ""}: that conversation's questions and ends come here again.`,
21439
21443
  muteNotFound: (p) => `I have no item #${p.item} of yours.`,
@@ -21449,10 +21453,10 @@ var terminalApprovalText = defineCatalog({
21449
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.",
21450
21454
  endLatest: (p) => `Latest turn: ${p.text}`,
21451
21455
  approvalsUnavailable: "I could not reach the setting just now. Try again in a moment.",
21452
- 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.`,
21453
- 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.",
21454
- summarySet: (p) => `Done: a conversation that keeps working on its own is summed up at most once every ${p.minutes} minutes.`,
21455
- 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.",
21456
21460
  summaryUsage: "Use `/approvals summary <minutes>` with 15 to 1440 minutes, `/approvals summary off`, or `/approvals summary` to see it."
21457
21461
  },
21458
21462
  zh: {
@@ -21488,7 +21492,11 @@ var terminalApprovalText = defineCatalog({
21488
21492
  approvalsOff: "\u7EC8\u7AEF\u5BA1\u6279\u63A8\u9001\u5DF2\u5173\u95ED\uFF1A\u8FD9\u4E9B\u95EE\u9898\u53EA\u5728\u7EC8\u7AEF\u91CC\u95EE\u3002",
21489
21493
  approvalsTurnedOn: "\u5DF2\u5F00\u542F\uFF1A\u7EC8\u7AEF\u91CC\u7684\u95EE\u9898\u4E5F\u4F1A\u63A8\u5230\u8FD9\u91CC\u3002\u53D1 `/approvals off` \u5173\u95ED\u3002",
21490
21494
  approvalsTurnedOff: "\u5DF2\u5173\u95ED\uFF1A\u95EE\u9898\u53EA\u5728\u7EC8\u7AEF\u91CC\u95EE\u3002\u53D1 `/approvals on` \u91CD\u65B0\u5F00\u542F\u3002",
21491
- approvalsUsage: "\u7528 `/approvals on` \u6216 `/approvals off`\uFF1B\u53EA\u53D1 `/approvals` \u770B\u5F53\u524D\u72B6\u6001\uFF1B\u5BF9\u5355\u4E2A\u7EC8\u7AEF\u4F1A\u8BDD\u7528 `/approvals mute #12`\uFF08\u6216 `unmute #12`\uFF09\uFF0C\u7F16\u53F7\u89C1\u63A8\u9001\u6D88\u606F\u91CC\u7684 #N\uFF1B`/approvals summary 60`\uFF08\u5206\u949F\uFF0C15 \u5230 1440\uFF0C\u6216 `off`\uFF09\u8BBE\u7F6E\u6301\u7EED\u5DE5\u4F5C\u7684\u4F1A\u8BDD\u591A\u4E45\u6C47\u603B\u4E00\u6B21\u3002",
21495
+ approvalsUsage: "\u53EA\u53D1 `/approvals` \u770B\u5F53\u524D\u72B6\u6001\uFF08\u7EC8\u7AEF\u5BA1\u6279\u63A8\u9001\u662F\u5426\u5F00\u542F\u3001\u6C47\u603B\u95F4\u9694\u3001\u5DF2\u9759\u97F3\u7684\u4F1A\u8BDD\uFF09\uFF1B\u7528 `/approvals on` \u6216 `/approvals off` \u5F00\u5173\u63A8\u9001\uFF1B\u5BF9\u5355\u4E2A\u7EC8\u7AEF\u4F1A\u8BDD\u7528 `/approvals mute #12`\uFF08\u6216 `unmute #12`\uFF09\uFF0C\u7F16\u53F7\u89C1\u63A8\u9001\u6D88\u606F\u91CC\u7684 #N\uFF1B`/approvals summary 60`\uFF08\u5206\u949F\uFF0C15 \u5230 1440\uFF0C\u6216 `off`\uFF09\u8BBE\u7F6E\u6301\u7EED\u5DE5\u4F5C\u7684\u4F1A\u8BDD\u591A\u4E45\u6C47\u603B\u4E00\u6B21\u3002",
21496
+ mutedNone: "\u6CA1\u6709\u5DF2\u9759\u97F3\u7684\u4F1A\u8BDD\u3002\u53D1 `/approvals mute #12` \u9759\u97F3\u67D0\u4E2A\u4F1A\u8BDD\uFF0C\u7F16\u53F7\u89C1\u63A8\u9001\u6D88\u606F\u91CC\u7684 #N\u3002",
21497
+ mutedHeader: (p) => `\u5DF2\u9759\u97F3\u7684\u4F1A\u8BDD\uFF08${p.count} \u4E2A\uFF09\uFF1A\u5B83\u4EEC\u7684\u63D0\u95EE\u3001\u7B49\u5F85\u548C\u5B8C\u6210\u53EA\u7559\u5728\u7EC8\u7AEF\u91CC\u3002\u53D1 \`/approvals unmute #12\` \u6062\u590D\u5176\u4E2D\u4E00\u4E2A\u3002`,
21498
+ mutedLine: (p) => p.since ? `${p.who}\uFF08${p.since} \u8D77\u9759\u97F3\uFF09` : p.who,
21499
+ mutedUnnamed: "\u4E00\u4E2A\u4F1A\u8BDD",
21492
21500
  muted: (p) => `\u5DF2\u9759\u97F3 #${p.item}${p.where ? `\uFF08${p.where}\uFF09` : ""}\uFF1A\u8FD9\u4E2A\u4F1A\u8BDD\u7684\u63D0\u95EE\u3001\u7B49\u5F85\u548C\u5B8C\u6210\u90FD\u53EA\u7559\u5728\u7EC8\u7AEF\u91CC\u3002\u53D1 \`/approvals unmute #${p.item}\` \u6062\u590D\u3002`,
21493
21501
  unmuted: (p) => `\u5DF2\u6062\u590D #${p.item}${p.where ? `\uFF08${p.where}\uFF09` : ""}\uFF1A\u8FD9\u4E2A\u4F1A\u8BDD\u7684\u63D0\u95EE\u548C\u5B8C\u6210\u4F1A\u91CD\u65B0\u63A8\u5230\u8FD9\u91CC\u3002`,
21494
21502
  muteNotFound: (p) => `\u4F60\u6CA1\u6709\u7F16\u53F7\u4E3A #${p.item} \u7684\u4E8B\u9879\u3002`,
@@ -21504,10 +21512,10 @@ var terminalApprovalText = defineCatalog({
21504
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`,
21505
21513
  endLatest: (p) => `\u6700\u65B0\u4E00\u8F6E\uFF1A${p.text}`,
21506
21514
  approvalsUnavailable: "\u6682\u65F6\u8BFB\u4E0D\u5230\u8FD9\u4E2A\u8BBE\u7F6E\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5\u3002",
21507
- 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`,
21508
- 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",
21509
- 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`,
21510
- 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",
21511
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"
21512
21520
  }
21513
21521
  });
@@ -24905,12 +24913,6 @@ function ownItemEndText(review) {
24905
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";
24906
24914
  return `\u5DF2\u7ED3\u675F\uFF1A${verdict ? `\u7ED3\u8BBA\uFF1A${verdict}` : "\u5DF2\u5B8C\u6210"}${merge}`;
24907
24915
  }
24908
- function reviewerResultText(review, view7) {
24909
- const line3 = prSummaryLine(view7.prSummary);
24910
- return `${askerName(review)}\u8BF7\u4F60\u4EE3\u5BA1\u7684 ${shortName(review.pull)}\uFF1A${viewWords(view7)}\u3002${line3 ? `
24911
- ${line3}
24912
- ` : ""}\u8BE6\u60C5\u5728\u4F60\u7684\u770B\u677F\u4E0A\uFF08/board\uFF09\u3002`;
24913
- }
24914
24916
  function viewStage(view7) {
24915
24917
  if (view7.status === "queued") return "queued";
24916
24918
  if (viewFinished(view7)) return `end:${view7.status}:${view7.verdict}:${view7.merged ? "1" : "0"}`;
@@ -24927,6 +24929,11 @@ function stageVerdict(stage) {
24927
24929
  if (parts2[0] === "end") return parts2[2] ?? "";
24928
24930
  return (parts2[0] === "wait" || parts2[0] === "verdict") && parts2.length > 1 ? parts2[1] ?? "" : "";
24929
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
+ }
24930
24937
  function foundWords(view7) {
24931
24938
  if (view7.findings === null) return "";
24932
24939
  if (view7.findings === 0) return view7.verdict ? "\uFF1B\u6CA1\u6709\u63D0\u51FA\u5F85\u6539\u7684\u95EE\u9898" : "";
@@ -24992,19 +24999,6 @@ function unfinishedText(left) {
24992
24999
  return `${who} \u7684\u4EE3\u5BA1\u8FD8\u6709 ${String(left.length)} \u4E2A\u6CA1\u6709\u7ED3\u675F\uFF0C\u7ED3\u679C\u8BF7\u770B PR\uFF1A
24993
25000
  ${left.map((e) => `- ${pullUrl(e.review.pull)}`).join("\n")}`;
24994
25001
  }
24995
- function reviewerEndedText(ended2) {
24996
- const [first] = ended2;
24997
- if (first === void 0) return "";
24998
- if (ended2.length === 1) return reviewerResultText(first[0].review, first[1]);
24999
- const lines = ended2.map(([e, v]) => {
25000
- const line3 = prSummaryLine(v.prSummary);
25001
- return `- ${shortName(e.review.pull)}\uFF1A${viewWords(v)}${line3 ? `
25002
- ${line3}` : ""}`;
25003
- });
25004
- return `${askerName(first[0].review)}\u8BF7\u4F60\u4EE3\u5BA1\u7684 ${String(ended2.length)} \u4E2A PR \u7ED3\u675F\u4E86\uFF1A
25005
- ${lines.join("\n")}
25006
- \u8BE6\u60C5\u5728\u4F60\u7684\u770B\u677F\u4E0A\uFF08/board\uFF09\u3002`;
25007
- }
25008
25002
 
25009
25003
  // packages/core/src/review/service/follow.ts
25010
25004
  var REQUESTER_VIEW_MS = 3e4;
@@ -25244,9 +25238,27 @@ var AskerFollow = class {
25244
25238
  const itemId = followedItemId(entry);
25245
25239
  if (view7.status === "queued") entry.seenQueued = true;
25246
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);
25247
25255
  const stage = entryStage(entry, view7);
25248
25256
  const held = state.news.get(itemId);
25249
- 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) {
25250
25262
  if (held === void 0 || entryStage(entry, held[1]) !== stage) {
25251
25263
  const now = this.deps.clock.monotonicMs();
25252
25264
  state.first = state.first || now;
@@ -25256,11 +25268,7 @@ var AskerFollow = class {
25256
25268
  } else if (held !== void 0 && stage === entry.said) {
25257
25269
  state.news.delete(itemId);
25258
25270
  }
25259
- if (viewFinished(view7)) {
25260
- state.open.delete(itemId);
25261
- await this.cards.end(itemId, itemEndText(view7), view7.prSummary);
25262
- if (stage === entry.said) this.deps.store.reviewDelegation.dropAskerFollow(itemId);
25263
- }
25271
+ return stage;
25264
25272
  }
25265
25273
  /** Says the held news in one message; what is said is recorded first, and put back when the message did not go. */
25266
25274
  async flush(entries, conversation, state) {
@@ -25284,9 +25292,6 @@ var AskerFollow = class {
25284
25292
  state.first = state.last = 0;
25285
25293
  for (const [entry, view7] of told)
25286
25294
  if (viewFinished(view7)) this.deps.store.reviewDelegation.dropAskerFollow(followedItemId(entry));
25287
- const ended2 = told.filter(([, v]) => viewFinished(v));
25288
- const [one] = ended2;
25289
- if (one !== void 0) await this.notices.tellReviewer(one[0].review, reviewerEndedText(ended2));
25290
25295
  }
25291
25296
  /** A line for the asker where they asked: in a group it @mentions them (and only them). */
25292
25297
  async sayToAsker(review, conversation, text9) {
@@ -25889,7 +25894,6 @@ ${p.setting}` : "") + refused3 + p.unread + p.stop;
25889
25894
  if (review.forReviewer) {
25890
25895
  if (review.ack) await say2(this.deps, s.ctx.conversation, review.ack);
25891
25896
  followed.push(review);
25892
- await this.notices.tellReviewerStarted(review);
25893
25897
  continue;
25894
25898
  }
25895
25899
  const message = s.several ? { ...s.ctx.message, id: `${s.ctx.message.id}-${String(index + 1)}` } : s.ctx.message;
@@ -25976,7 +25980,6 @@ ${p.setting}` : "") + refused3 + p.unread + p.stop;
25976
25980
  item: started.item?.itemId ?? ""
25977
25981
  });
25978
25982
  this.follows.follow([started], s.ctx.conversation);
25979
- await this.notices.tellReviewerStarted(started);
25980
25983
  await this.postCards(s, [started]);
25981
25984
  return true;
25982
25985
  }
@@ -26050,26 +26053,6 @@ var Notices = class {
26050
26053
  reviewerChat(review) {
26051
26054
  return personalChat(this.deps, { userId: review.actorId, channelUserId: review.actorChannelId }, review.asked);
26052
26055
  }
26053
- async tellReviewer(review, text9) {
26054
- try {
26055
- const chat = await this.reviewerChat(review);
26056
- if (chat !== void 0) await say2(this.deps, chat, text9);
26057
- } catch (err2) {
26058
- this.deps.logger.warn("the reviewer could not be told about a review asked of them", { error: errorName(err2) });
26059
- }
26060
- }
26061
- /** The reviewer hears, in their own chat, that someone asked a review of them and that it is an item on their board. */
26062
- async tellReviewerStarted(review) {
26063
- const item = review.item;
26064
- const seq = item?.seq ? `\uFF08\u4E8B\u9879 #${String(item.seq)}\uFF09` : "";
26065
- const verb = review.reviewOnly ? "review\uFF08\u53EA review\uFF0C\u4E0D\u5408\u5165\uFF09" : "review \u5408\u5165";
26066
- 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" : "";
26067
- 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}`;
26068
- await this.tellReviewer(
26069
- review,
26070
- `${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`
26071
- );
26072
- }
26073
26056
  /** The reviewer's item as Claw shows it to them, read with their own key; undefined when it cannot be. */
26074
26057
  async reviewersItem(review) {
26075
26058
  const key = review.item ? this.deps.store.links.getKey(review.actorId) : null;
@@ -28346,178 +28329,616 @@ function hiddenOf(agent) {
28346
28329
 
28347
28330
  // packages/core/src/remote/events.ts
28348
28331
  import { z as z8 } from "zod";
28349
- var DIALOG_MAX = 120;
28350
- var NOTHING2 = Object.freeze({
28351
- chunk: null,
28352
- tool: null,
28353
- plan: null,
28354
- permission: null,
28355
- resolved: null,
28356
- mode: null,
28357
- modes: null,
28358
- unattended: null,
28359
- modeFlags: null,
28360
- note: null,
28361
- started: false,
28362
- finished: false,
28363
- endsSeq: null,
28364
- stopReason: "",
28365
- closed: null,
28366
- rejected: null,
28367
- replay: false,
28368
- readOnly: null,
28369
- recovered: null,
28370
- queued: null,
28371
- dialog: null,
28372
- waitLine: null,
28373
- rowUnreadable: false,
28374
- queuedFor: null,
28375
- queuedSeq: null,
28376
- queuedHeld: false,
28377
- typed: null,
28378
- terminal: null,
28379
- terminalMode: null,
28380
- 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
+ }
28381
28486
  });
28382
- function remoteStep(fields2 = {}) {
28383
- return { ...NOTHING2, ...fields2 };
28384
- }
28385
- var Record_ = z8.record(z8.string(), z8.unknown());
28386
- function record5(value) {
28387
- const parsed = Record_.safeParse(value);
28388
- return parsed.success ? parsed.data : {};
28389
- }
28390
- function str7(value) {
28391
- return typeof value === "string" ? value : "";
28392
- }
28393
- function seqOf(value) {
28394
- 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" : "";
28395
28519
  }
28396
- function flag2(value) {
28397
- return typeof value === "boolean" ? value : null;
28520
+ function recordOf(value) {
28521
+ return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
28398
28522
  }
28399
- function update(payload) {
28400
- const inner = Record_.safeParse(payload["update"]);
28401
- return inner.success ? inner.data : payload;
28402
- }
28403
- function textOf6(payload) {
28404
- const u = update(payload);
28405
- const content = u["content"];
28406
- const inner = Record_.safeParse(content);
28407
- if (inner.success && typeof inner.data["text"] === "string") return inner.data["text"];
28408
- if (typeof content === "string") return content;
28409
- 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;
28410
28560
  }
28411
- var STOP_REASONS = /* @__PURE__ */ new Set(["end_turn", "max_tokens", "max_turn_requests", "refusal", "cancelled", "error"]);
28412
- function availableModes(raw) {
28413
- const state = Record_.safeParse(raw);
28414
- 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] ?? ""}` : "";
28415
28564
  }
28416
- function modeIds(raw) {
28417
- const list2 = availableModes(raw);
28418
- if (!Array.isArray(list2)) return null;
28419
- const ids = list2.map((m) => {
28420
- const mode = Record_.safeParse(m);
28421
- return mode.success ? mode.data["id"] : m;
28422
- });
28423
- return ids.filter((i) => typeof i === "string" && i !== "").slice(0, 20);
28565
+ function sameHost(a, b3) {
28566
+ return originOf(a).toLowerCase() === originOf(b3).toLowerCase();
28424
28567
  }
28425
- function modeFlags(raw) {
28426
- const list2 = availableModes(raw);
28427
- const flags = /* @__PURE__ */ new Map();
28428
- for (const m of Array.isArray(list2) ? list2 : []) {
28429
- const mode = record5(m);
28430
- const id = mode["id"];
28431
- const unattended = flag2(mode["unattended"]);
28432
- 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;
28433
28572
  }
28434
- return flags.size > 0 ? Object.fromEntries(flags) : null;
28435
- }
28436
- function currentMode(payload) {
28437
- const modes = Record_.safeParse(payload["modes"]);
28438
- for (const source of [update(payload), payload, modes.success ? modes.data : {}]) {
28439
- for (const name of ["currentModeId", "currentMode", "mode", "modeId"]) {
28440
- const value = own(source, name);
28441
- if (typeof value === "string" && value !== "") return value;
28442
- }
28573
+ server;
28574
+ identityUrl;
28575
+ login() {
28576
+ return "claw-connector login" + (this.server ? ` --server ${this.server}` : "") + (this.identityUrl ? ` --identity-url ${this.identityUrl}` : "");
28443
28577
  }
28444
- 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);
28445
28598
  }
28446
- var PLAN_ITEM_MAX = 80;
28447
- function planLine(payload) {
28448
- const entries = update(payload)["entries"];
28449
- if (!Array.isArray(entries) || entries.length === 0) return null;
28450
- const items = entries.flatMap((e) => {
28451
- const item = Record_.safeParse(e);
28452
- return item.success ? [item.data] : [];
28453
- });
28454
- if (items.length === 0) return null;
28455
- const done = items.filter((e) => e["status"] === "completed").length;
28456
- const current = items.find((e) => e["status"] === "in_progress") ?? items.find((e) => e["status"] !== "completed");
28457
- let line3 = `\u{1F4CB} Plan: ${String(done)} of ${String(items.length)} done`;
28458
- if (current && str7(current["content"])) line3 += `, now: ${neutral2(current["content"], PLAN_ITEM_MAX)}`;
28459
- 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}`;
28460
28607
  }
28461
- var NOT_TYPED = new RegExp(
28462
- "^(?:<(?: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)"
28463
- );
28464
- function chunk(payload, kind) {
28465
- const text9 = textOf6(payload);
28466
- if (!text9) return NOTHING2;
28467
- 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
+ };
28468
28616
  }
28469
- var PASTED_BLOCK = /\n*<pasted_content id="([^"\s<>]{1,64})">\n([\s\S]*?)\n<\/pasted_content id="\1">\n*/gu;
28470
- function unwrapPasted(text9) {
28471
- if (!text9.includes("<pasted_content ")) return text9;
28472
- return text9.replace(PASTED_BLOCK, (whole4, _id, inner, at, all) => {
28473
- const end = at + whole4.length;
28474
- return `${at > 0 ? "\n" : ""}${inner}${end < all.length ? "\n" : ""}`;
28475
- });
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");
28476
28621
  }
28477
- function typed(payload) {
28478
- const text9 = pyStrip(unwrapPasted(textOf6(payload)));
28479
- return text9 && !NOT_TYPED.test(text9) ? remoteStep({ typed: text9 }) : NOTHING2;
28622
+ function upgradeText(lang, command = UPGRADE_COMMAND) {
28623
+ return connectorSetupText.in(lang).upgrade({ command });
28480
28624
  }
28481
- var TOOL_NAME = /^[A-Za-z][\w.-]{0,63}$/u;
28482
- function toolNameOf(u) {
28483
- const meta = record5(record5(u["_meta"])["claudeCode"]);
28484
- const named2 = str7(meta["toolName"]);
28485
- if (TOOL_NAME.test(named2)) return named2;
28486
- const head = str7(u["title"]).split(": ", 1)[0] ?? "";
28487
- 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);
28488
28632
  }
28489
- function tool(payload, kind) {
28490
- const u = update(payload);
28491
- const id = str7(u["toolCallId"]) || str7(u["tool_call_id"]) || str7(u["id"]);
28492
- const status = str7(u["status"]) || (kind === "tool_call" ? "pending" : "");
28493
- const name = toolNameOf(u);
28494
- return remoteStep({ tool: { id, title: str7(u["title"]), status, ...name ? { name } : {} } });
28633
+ function offlineHint(lang = "en") {
28634
+ return connectorSetupText.in(lang).offlineHint;
28495
28635
  }
28496
- function terminalQueued(payload) {
28497
- const seq = seqOf(payload["cmd_seq"]);
28498
- const forId = neutral2(str7(payload["cmd_id"]), 80) || (seq !== null ? String(seq) : "");
28499
- return remoteStep({
28500
- queued: str7(payload["reason"]) || "terminal_working",
28501
- queuedFor: forId || null,
28502
- queuedSeq: seq,
28503
- queuedHeld: payload["held"] === "terminal",
28504
- dialog: neutral2(str7(payload["dialog"]), DIALOG_MAX) || null,
28505
- rowUnreadable: payload["registry_row_unreadable"] === true
28506
- });
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;
28507
28673
  }
28508
- function turnEnd(payload, _kind, errors) {
28509
- let reason = str7(payload["stopReason"]) || "end_turn";
28510
- let error = str7(payload["error"]) || str7(payload["message"]);
28511
- if (!STOP_REASONS.has(reason)) {
28512
- error = error || `an internal error (ref ${errors.withhold("remote_stop_reason", reason)})`;
28513
- 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;
28514
28702
  }
28515
- return remoteStep({
28516
- finished: true,
28517
- endsSeq: seqOf(payload["cmd_seq"]),
28518
- stopReason: reason,
28519
- note: error ? neutral2(errors.publicReason(error, "remote_turn_end"), 300) : null
28520
- });
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
+ });
28521
28942
  }
28522
28943
  function sessionStarted(payload) {
28523
28944
  return remoteStep({
@@ -28555,14 +28976,17 @@ function sessionResumed(payload) {
28555
28976
  }
28556
28977
  function sessionClosed(payload, _kind, errors) {
28557
28978
  const reason = str7(payload["reason"]) || str7(payload["message"]) || str7(payload["error"]);
28558
- 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"]);
28559
28983
  }
28560
28984
  function commandRejected(payload, _kind, errors) {
28561
28985
  const reason = str7(payload["reason"]);
28562
28986
  return remoteStep({
28563
28987
  rejected: {
28564
28988
  type: str7(payload["type"]),
28565
- reason: neutral2(errors.publicReason(reason, "remote_command_rejected"), 300),
28989
+ reason: figured(neutral2(errors.publicReason(reason, "remote_command_rejected"), 300), payload),
28566
28990
  cmdSeq: seqOf(payload["cmd_seq"])
28567
28991
  }
28568
28992
  });
@@ -28607,7 +29031,7 @@ function decode(event, errors) {
28607
29031
  }
28608
29032
 
28609
29033
  // packages/core/src/remote/health.ts
28610
- var CODE3 = /^[a-z][a-z0-9_]{0,63}$/;
29034
+ var CODE4 = /^[a-z][a-z0-9_]{0,63}$/;
28611
29035
  var COMMAND_FIX = /^\(?(?:claude|codex|claw-connector|npm|npx|mkdir|chmod|export|loginctl|agent|curl|crontab|sh)\b/;
28612
29036
  function problemsOf(agent) {
28613
29037
  const health = objOrNull(agent.capabilities["health"]);
@@ -28628,7 +29052,7 @@ function machineProblems(connector) {
28628
29052
  for (const raw of list(health.problems).slice(0, HEALTH_READ_MAX)) {
28629
29053
  const problem = objOrNull(raw);
28630
29054
  const code3 = problem?.["code"];
28631
- if (!problem || typeof code3 !== "string" || !CODE3.test(code3)) continue;
29055
+ if (!problem || typeof code3 !== "string" || !CODE4.test(code3)) continue;
28632
29056
  const machineWide = problem["scope"] === "machine";
28633
29057
  const key = JSON.stringify([machineWide ? null : agent.agentId, code3, cpSlice(pyStr(problem["detail"]), 0, 200)]);
28634
29058
  if (seen.has(key)) continue;
@@ -31070,16 +31494,6 @@ var ChatRegistry = class {
31070
31494
  }
31071
31495
  };
31072
31496
 
31073
- // packages/core/src/remote/fields.ts
31074
- function textOf7(value) {
31075
- if (typeof value === "string") return value;
31076
- if (typeof value === "number") return value === 0 ? "" : String(value);
31077
- return value === true ? "True" : "";
31078
- }
31079
- function recordOf(value) {
31080
- return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
31081
- }
31082
-
31083
31497
  // packages/core/src/remote/machines.ts
31084
31498
  function agentRefOf(connector, agent) {
31085
31499
  return `${neutral(connector.name, 80)}/${neutral(agent.agentId, 64)}`.replaceAll("`", "'");
@@ -31471,7 +31885,7 @@ var Targets = class {
31471
31885
  * ticket, once, in time): then the connector ends the terminal first.
31472
31886
  */
31473
31887
  takeoverOf(chatKey, connector, agent, data, now, lang) {
31474
- const entry = resumableOf(agent).find((e) => e.ref === textOf7(data["resume"]));
31888
+ const entry = resumableOf(agent).find((e) => e.ref === textOf6(data["resume"]));
31475
31889
  const no = (sentence3) => ({
31476
31890
  entry: null,
31477
31891
  problem: saidIn(lang, sentence3)
@@ -31479,7 +31893,7 @@ var Targets = class {
31479
31893
  if (entry === void 0) return no("conversationGone");
31480
31894
  if (entry.state === WATCH_STATE && data["takeover"]) {
31481
31895
  const held = this.chats.ticketOf(chatKey);
31482
- 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;
31483
31897
  if (!fresh) return no("confirmExpired");
31484
31898
  if (!canTakeOver(agent)) return no("stillInTerminal");
31485
31899
  this.chats.spendTicket(chatKey);
@@ -31500,14 +31914,14 @@ var Targets = class {
31500
31914
  problem: saidIn(lang, sentence3)
31501
31915
  });
31502
31916
  if ("typed" in data) {
31503
- const path = this.chats.typedPath(chatKey, textOf7(data["typed"]), now);
31917
+ const path = this.chats.typedPath(chatKey, textOf6(data["typed"]), now);
31504
31918
  return path ? { path, problem: "" } : no("cardExpired");
31505
31919
  }
31506
31920
  const slot = slotOf(data);
31507
31921
  if (slot < 0) return no("tapInvalidAgents");
31508
31922
  const roots = agentRoots(agent);
31509
31923
  if (roots.length === 0) {
31510
- const path = textOf7(own(data, `dir${String(slot)}`)).trim();
31924
+ const path = textOf6(own(data, `dir${String(slot)}`)).trim();
31511
31925
  return path ? { path, problem: "" } : no("typeFolder");
31512
31926
  }
31513
31927
  const root = own(data, `root${String(slot)}`);
@@ -31537,8 +31951,8 @@ var StartClicks = class {
31537
31951
  /** The connector and agent a tap names, from the person's own list as Claw gives it now; null (said) when gone. */
31538
31952
  async named(click) {
31539
31953
  const { connectors } = await this.p.lists.machines(click.key);
31540
- const connector = connectorById(connectors, textOf7(click.data["connector_id"]));
31541
- 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"]));
31542
31956
  if (connector === void 0 || agent === void 0) {
31543
31957
  await this.c.home(click, saidIn(this.c.lang(click), "agentGone"));
31544
31958
  return null;
@@ -31619,7 +32033,7 @@ var StartClicks = class {
31619
32033
  async attach(click) {
31620
32034
  const lang = this.c.lang(click);
31621
32035
  if (this.p.state.chats.turns.has(click.chatKey)) return this.c.home(click, saidIn(lang, "stopFirst"));
31622
- const wanted = textOf7(click.data["session_id"]);
32036
+ const wanted = textOf6(click.data["session_id"]);
31623
32037
  const session = (await this.p.lists.sessions(click.key)).sessions.find((s) => s.sessionId === wanted);
31624
32038
  if (session === void 0) return this.c.home(click, saidIn(lang, "sessionNotFound"));
31625
32039
  const hooks = this.p.ops.attachHooks(click.chatKey, click.key, click.provider, click.to);
@@ -31641,7 +32055,7 @@ var StartClicks = class {
31641
32055
  const { connector, agent } = named2;
31642
32056
  if (!connector.online)
31643
32057
  return this.c.home(click, remoteAgentText.in(lang).offlineTap({ host: neutral(connector.name, 80) }));
31644
- 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"]));
31645
32059
  if (entry === void 0) return this.c.home(click, saidIn(lang, "conversationGone"));
31646
32060
  if (entry.state !== "live") return this.c.home(click, saidIn(lang, "notInTerminal"));
31647
32061
  if (!canTakeOver(agent)) return this.c.home(click, saidIn(lang, "cannotTakeOver"));
@@ -31655,7 +32069,7 @@ var StartClicks = class {
31655
32069
  });
31656
32070
  await this.c.repost(
31657
32071
  click,
31658
- 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)
31659
32073
  );
31660
32074
  }
31661
32075
  /**
@@ -31707,140 +32121,6 @@ var StartClicks = class {
31707
32121
  }
31708
32122
  };
31709
32123
 
31710
- // packages/core/src/locales/connector-setup.ts
31711
- var connectorSetupText = defineCatalog({
31712
- en: {
31713
- noMachine: "You have no machine connected.",
31714
- /** Between the first line and `runOn`. */
31715
- sep: " ",
31716
- runOn: "On the machine you want to use (Node.js 22 or newer), run:",
31717
- 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.",
31718
- /** What differs per system, one line each. */
31719
- 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.",
31720
- upgrade: (p) => `On that machine, run \`${p.command}\` to upgrade it and restart it.`,
31721
- versionUnsupported: (p) => `Its connector (${p.version}) is too old for a new session.`,
31722
- versionOutdated: (p) => `Its connector (${p.version}) is out of date.`,
31723
- offlineHint: "On that machine, run `claw-connector status` to see why, then `claw-connector service install` to start it again."
31724
- },
31725
- zh: {
31726
- noMachine: "\u4F60\u8FD8\u6CA1\u6709\u8FDE\u63A5\u4EFB\u4F55\u673A\u5668\u3002",
31727
- sep: "",
31728
- runOn: "\u5728\u8981\u4F7F\u7528\u7684\u673A\u5668\u4E0A\uFF08\u9700\u8981 Node.js 22 \u53CA\u4EE5\u4E0A\uFF09\u4F9D\u6B21\u8FD0\u884C\uFF1A",
31729
- 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",
31730
- 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",
31731
- upgrade: (p) => `\u5728\u90A3\u53F0\u673A\u5668\u4E0A\u8FD0\u884C \`${p.command}\` \u5347\u7EA7\u5E76\u91CD\u542F\u5B83\u3002`,
31732
- versionUnsupported: (p) => `\u8FDE\u63A5\u5668\u7248\u672C ${p.version} \u592A\u65E7\uFF0C\u4E0D\u80FD\u5F00\u65B0\u4F1A\u8BDD\u3002`,
31733
- versionOutdated: (p) => `\u8FDE\u63A5\u5668\u7248\u672C ${p.version} \u8F83\u65E7\uFF0C\u5EFA\u8BAE\u5347\u7EA7\u3002`,
31734
- 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"
31735
- }
31736
- });
31737
-
31738
- // packages/core/src/remote/connector/setup.ts
31739
- var CONNECTOR_PACKAGE_NAME = "@primusclaw/connector";
31740
- var UPGRADE_COMMAND = `npm install -g ${CONNECTOR_PACKAGE_NAME}@latest && claw-connector stop && claw-connector service install`;
31741
- var SAFE_URL = /^https?:\/\/[A-Za-z0-9.-]{1,253}(?::\d{1,5})?(?:\/[A-Za-z0-9._~-]{1,100}){0,8}$/;
31742
- var PAIR_CODE = /^[0-9A-HJKMNP-TV-Z]{4}-[0-9A-HJKMNP-TV-Z]{4}-[0-9A-HJKMNP-TV-Z]{4}$/;
31743
- function safeUrl(value) {
31744
- const text9 = pyRstrip(pyStrip(textOf7(value)), "/");
31745
- return SAFE_URL.test(text9) ? text9 : null;
31746
- }
31747
- function originOf(url) {
31748
- const match = /^(https?):\/\/([^/]+)/u.exec(url);
31749
- return match ? `${match[1] ?? ""}://${match[2] ?? ""}` : "";
31750
- }
31751
- function sameHost(a, b3) {
31752
- return originOf(a).toLowerCase() === originOf(b3).toLowerCase();
31753
- }
31754
- var Setup = class {
31755
- constructor(server, identityUrl) {
31756
- this.server = server;
31757
- this.identityUrl = identityUrl;
31758
- }
31759
- server;
31760
- identityUrl;
31761
- login() {
31762
- return "claw-connector login" + (this.server ? ` --server ${this.server}` : "") + (this.identityUrl ? ` --identity-url ${this.identityUrl}` : "");
31763
- }
31764
- commands() {
31765
- return [
31766
- `npm install -g ${CONNECTOR_PACKAGE_NAME}`,
31767
- "claw-connector init",
31768
- this.login(),
31769
- "claw-connector service install"
31770
- ];
31771
- }
31772
- };
31773
- function setupFrom(data, baseUrl) {
31774
- const base = safeUrl(baseUrl);
31775
- if (!base) return new Setup("", null);
31776
- const origin = originOf(base);
31777
- const given = recordOf(data);
31778
- const server = given ? safeUrl(given.server) : null;
31779
- if (given && server && sameHost(server, base)) {
31780
- const identity = safeUrl(given.identity_url);
31781
- return new Setup(server, identity && sameHost(identity, base) ? identity : origin);
31782
- }
31783
- return new Setup(base, origin);
31784
- }
31785
- function pairCommand(data, baseUrl) {
31786
- const given = recordOf(data);
31787
- if (!given) return null;
31788
- const code3 = textOf7(given.code).trim();
31789
- const server = safeUrl(given.server);
31790
- const base = safeUrl(baseUrl) ?? "";
31791
- if (!PAIR_CODE.test(code3) || !server || !sameHost(server, base)) return null;
31792
- return `npm install -g --no-update-notifier ${CONNECTOR_PACKAGE_NAME}@latest && claw-connector pair ${code3} --server ${server}`;
31793
- }
31794
- function connectSteps(setup, lang, lead = "") {
31795
- const text9 = connectorSetupText.in(lang);
31796
- return {
31797
- lead: (lead || text9.noMachine) + text9.sep + text9.runOn,
31798
- commands: setup.commands(),
31799
- after: text9.after,
31800
- notes: text9.notes
31801
- };
31802
- }
31803
- function connectMarkdown(setup, lang, lead = "") {
31804
- const steps = connectSteps(setup, lang, lead);
31805
- const block = "```\n" + steps.commands.join("\n") + "\n```";
31806
- return [steps.lead, block, steps.after, steps.notes].join("\n\n");
31807
- }
31808
- function upgradeText(lang, command = UPGRADE_COMMAND) {
31809
- return connectorSetupText.in(lang).upgrade({ command });
31810
- }
31811
- function versionNote(connector, lang = "en") {
31812
- const status = connector.versionStatus;
31813
- if (status !== "outdated" && status !== "unsupported") return null;
31814
- const version = connector.version.replace(/[^0-9A-Za-z.+-]/gu, "").slice(0, 40) || "?";
31815
- const text9 = connectorSetupText.in(lang);
31816
- const head = status === "unsupported" ? text9.versionUnsupported({ version }) : text9.versionOutdated({ version });
31817
- return head + text9.sep + upgradeText(lang);
31818
- }
31819
- function offlineHint(lang = "en") {
31820
- return connectorSetupText.in(lang).offlineHint;
31821
- }
31822
- var ConnectorSetup = class {
31823
- constructor(setup) {
31824
- this.setup = setup;
31825
- }
31826
- setup;
31827
- connectMarkdown(lang, lead = "") {
31828
- return connectMarkdown(this.setup, lang, lead);
31829
- }
31830
- connectSteps(lang, lead = "") {
31831
- return connectSteps(this.setup, lang, lead);
31832
- }
31833
- versionNote(connector, lang) {
31834
- return versionNote(connector, lang);
31835
- }
31836
- offlineHint(lang) {
31837
- return offlineHint(lang);
31838
- }
31839
- login() {
31840
- return this.setup.login();
31841
- }
31842
- };
31843
-
31844
32124
  // packages/core/src/remote/lists.ts
31845
32125
  var RemoteOff = class extends Error {
31846
32126
  name = "RemoteOff";
@@ -31950,431 +32230,157 @@ ${line3}` : line3;
31950
32230
  this.ctx.remoteState.setRemoteListing(chatKey, listing2);
31951
32231
  return { kind: "text", text: (lead ? `${lead}
31952
32232
 
31953
- ` : "") + text9 };
31954
- }
31955
- this.ctx.remoteState.setRemoteListing(chatKey, card.listing);
31956
- return { kind: "card", message: card.message };
31957
- }
31958
- /** Every session the user has, on every machine; its active ones are the numbers of `/agent attach N` from now on. */
31959
- async sessionsView(chatKey, key, lang, lead = "") {
31960
- const listed = await this.machines(key);
31961
- const { sessions } = await this.sessions(key);
31962
- const state = this.ctx.remoteState.attachedRemote(chatKey);
31963
- const card = this.ctx.views.sessions({
31964
- connectors: listed.connectors,
31965
- sessions,
31966
- attached: state?.sessionId ?? null,
31967
- now: this.now(),
31968
- lang,
31969
- lead,
31970
- waiting: this.ctx.permissions.waitingRemoteSessions(chatKey),
31971
- setup: listed.connectors.length === 0 ? await this.setup(key) : this.ctx.setup
31972
- });
31973
- this.ctx.remoteState.setRemoteListing(chatKey, card.listing);
31974
- return card.message;
31975
- }
31976
- };
31977
-
31978
- // packages/core/src/remote/clicks-machine.ts
31979
- var MachineClicks = class {
31980
- constructor(p, c) {
31981
- this.p = p;
31982
- this.c = c;
31983
- }
31984
- p;
31985
- c;
31986
- /** The person's connector the tapped button names, as Claw lists it now; null (said) when it is not theirs any more. */
31987
- async ownConnector(click, includeHidden = false) {
31988
- const { connectors } = await this.p.lists.machines(click.key, includeHidden);
31989
- const found = connectorById(connectors, textOf7(click.data["connector_id"]));
31990
- if (found === void 0) await this.c.home(click, saidIn(this.c.lang(click), "agentGone"));
31991
- return found ?? null;
31992
- }
31993
- /** Hide one conversation (`ref`), or every one no process runs of one agent (`all: idle`), from the list. */
31994
- async hide(click) {
31995
- const connector = await this.ownConnector(click);
31996
- if (connector === null) return;
31997
- const lang = this.c.lang(click);
31998
- let entries;
31999
- if (click.data["all"] === "idle") {
32000
- const agent = connector.agents.find((a) => a.agentId === textOf7(click.data["agent_id"]));
32001
- entries = (agent ? resumableOf(agent) : []).filter((e) => e.state === "idle");
32002
- } else {
32003
- const ref = textOf7(click.data["ref"]);
32004
- entries = connector.agents.flatMap((a) => resumableOf(a).filter((e) => e.ref === ref)).slice(0, 1);
32005
- }
32006
- if (entries.length === 0) return this.c.home(click, saidIn(lang, "conversationGone"));
32007
- const out = await this.p.ctx.claw.hide(
32008
- click.key,
32009
- connector.connectorId,
32010
- entries.map((e) => e.ref),
32011
- true
32012
- );
32013
- const titles = new Map(entries.map((e) => [e.ref, e.title]));
32014
- const words3 = remoteText.in(lang);
32015
- const lines = [words3.hidN({ n: out.changed.length })];
32016
- for (const refused3 of out.refused) {
32017
- if (refused3.reason === "live")
32018
- lines.push(words3.hideLive({ title: neutral(titles.get(refused3.ref) ?? "", 60) || "?" }));
32019
- }
32020
- await this.c.home(click, lines.join(" "));
32021
- }
32022
- /** The conversations hidden on that machine, each with Unhide. */
32023
- async hidden(click) {
32024
- const connector = await this.ownConnector(click, true);
32025
- if (connector === null) return;
32026
- await this.c.repost(
32027
- click,
32028
- this.p.ctx.views.hidden(connector, this.p.ctx.clock.epochMs() / 1e3, this.c.lang(click))
32029
- );
32030
- }
32031
- /** Show one hidden conversation (`ref`) again, or all of that machine's (`all`). */
32032
- async unhide(click) {
32033
- const connector = await this.ownConnector(click, true);
32034
- if (connector === null) return;
32035
- const hidden2 = connector.agents.flatMap((a) => hiddenOf(a));
32036
- const ref = textOf7(click.data["ref"]);
32037
- const refs = click.data["all"] ? hidden2.map((e) => e.ref) : hidden2.filter((e) => e.ref === ref).map((e) => e.ref);
32038
- const lang = this.c.lang(click);
32039
- if (refs.length === 0) return this.c.home(click, saidIn(lang, "conversationGone"));
32040
- const out = await this.p.ctx.claw.hide(click.key, connector.connectorId, refs, false);
32041
- await this.c.home(click, remoteText.in(lang).unhidN({ n: out.changed.length }));
32042
- }
32043
- /**
32044
- * 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
32045
- * machine's name is read again from the person's own list.
32046
- */
32047
- async off(click) {
32048
- const lang = this.c.lang(click);
32049
- const words3 = remoteOffText.in(lang);
32050
- if (!this.p.ctx.settings.enabled) return this.settled(click, words3.inactive);
32051
- if (click.data["confirm"] !== true) return this.settled(click, words3.kept);
32052
- const connectorId = textOf7(click.data["connector_id"]);
32053
- let connector;
32054
- try {
32055
- connector = connectorById((await this.p.lists.machines(click.key)).connectors, connectorId);
32056
- if (connector === void 0) {
32057
- await this.settled(click, words3.gone);
32058
- return;
32059
- }
32060
- await this.p.ctx.claw.revoke(click.key, connectorId);
32061
- } catch (error) {
32062
- return this.offRefused(click, error, connector?.name ?? "", lang);
32063
- }
32064
- const state = this.p.state.attached(click.chatKey);
32065
- if (state?.connectorId === connectorId) {
32066
- this.p.ops.leave(click.chatKey);
32067
- }
32068
- const login = connector.paired ? "" : (await this.p.lists.setup(click.key)).login();
32069
- await this.c.end(click, disconnectedText(connector.name, login, lang, connector.paired));
32070
- }
32071
- /** The tap ends with `text` in place of the card. */
32072
- async settled(click, text9) {
32073
- await this.c.end(click, text9);
32074
- }
32075
- /** It did not go through: said; where pressing again can help, the card comes back with its buttons. */
32076
- async offRefused(click, error, name, lang) {
32077
- const words3 = remoteOffText.in(lang);
32078
- const connectorId = textOf7(click.data["connector_id"]);
32079
- const again = async (text9) => {
32080
- await this.c.end(click, disconnectAgainCard(text9, connectorId, disconnectTitle(name, lang), lang), text9);
32081
- };
32082
- if (error instanceof RemoteOff) return this.settled(click, saidIn(lang, "notEnabled"));
32083
- if (error instanceof ClawError) {
32084
- if (error.status === 404) return this.settled(click, words3.gone);
32085
- return again(failureText2(error, this.p.ctx.errors, this.p.ctx.clock.epochMs() / 1e3, lang) + words3.nothing);
32086
- }
32087
- if (isTransport2(error)) return again(saidIn(lang, "unreachable") + words3.nothing);
32088
- throw error;
32089
- }
32090
- };
32091
-
32092
- // packages/core/src/locales/remote-leads.ts
32093
- var remoteLeads = {
32094
- sessionEnded: ["\u4F1A\u8BDD\u5DF2\u7ED3\u675F", "The session ended"],
32095
- couldNotStart: ["\u4F1A\u8BDD\u6CA1\u80FD\u542F\u52A8", "The session could not start"],
32096
- /** (`folder`: already shown inert, in backticks) */
32097
- couldNotStartIn: (folder) => [`\u4F1A\u8BDD\u6CA1\u80FD\u5728 ${folder} \u542F\u52A8`, `The session could not start in ${folder}`],
32098
- turnIncomplete: ["\u8FD9\u4E00\u8F6E\u6CA1\u6709\u5B8C\u6210", "The turn did not complete"],
32099
- /** (a message the terminal may have taken: never said as a turn that did not complete) */
32100
- inputUnconfirmed: ["\u8FD8\u6CA1\u786E\u8BA4\u7EC8\u7AEF\u6536\u5230", "Not confirmed by the terminal yet"],
32101
- modeNotSwitched: ["\u6A21\u5F0F\u6CA1\u6709\u5207\u6362", "The mode was not switched"],
32102
- notSwitchedTo: (mode) => [`\u6CA1\u6709\u5207\u5230 \`${mode}\``, `The agent did not switch to \`${mode}\``]
32103
- };
32104
-
32105
- // packages/core/src/locales/connector-reasons.ts
32106
- var connectorReasonText = defineCatalog({
32107
- en: {
32108
- 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.',
32109
- 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"`.',
32110
- 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.",
32111
- 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.",
32112
- 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.',
32113
- mode_id_required: "The mode switch named no mode. Tap Mode and pick one again.",
32114
- set_mode_failed: "The agent could not switch its mode; it keeps the one it had.",
32115
- adapter_gone: "The agent program on that machine has exited.",
32116
- 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.",
32117
- adapter_unavailable: "The connector could not start the agent program for this turn.",
32118
- 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.",
32119
- adapter_cannot_resume: "This agent cannot pick up the earlier conversation.",
32120
- adapter_error: "The agent program failed. Look at `run.log` in the connector's state directory on that machine.",
32121
- 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.",
32122
- 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.",
32123
- cwd_not_found: "That folder does not exist on that machine: pick one that exists there, or create it there first.",
32124
- cwd_not_directory: "That path is not a directory.",
32125
- cwd_not_absolute: "The directory must be an absolute path (starting with /).",
32126
- invalid_cwd: "That directory name is not valid.",
32127
- cwd_mismatch: "That conversation is not in this directory. Pick it again from the list.",
32128
- unknown_agent: "That machine has no such agent (agents.toml may have changed). Check agents.toml there and restart the connector after a change.",
32129
- 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.",
32130
- 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.",
32131
- 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.",
32132
- machine_reconnected: "That machine registered again (a reinstall, lost local state or a rebuilt container), and the old session closed with its old registration.",
32133
- unknown_session: "The connector no longer knows this session (it may have restarted).",
32134
- too_many_sessions: "Too many sessions are open on that machine. Close one with `/agent close` first.",
32135
- resume_not_supported: "This agent cannot continue an existing session.",
32136
- attach_unavailable: "This agent cannot take over a terminal conversation. Configure an agent with the `claude-attach` preset for that.",
32137
- resume_ref_required: "No conversation was named to take over. Pick one from the list.",
32138
- invalid_resume_ref: "That conversation reference is not valid. Pick one from the list.",
32139
- already_attached: "That conversation is already open from the phone. Switch to it with `/agent sessions`.",
32140
- catalog_unavailable: "The connector could not read the list of conversations on that machine.",
32141
- session_live: "That conversation is still open in a terminal on that machine. Quit it there first, then take it over.",
32142
- recently_written: "A terminal wrote to that conversation moments ago and may still be using it. Try again in a minute.",
32143
- twin_check_failed: "The connector could not check whether the conversation is still open in a terminal, so it did not take it over.",
32144
- 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.",
32145
- 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.",
32146
- takeover_not_permitted: "The terminal holding the conversation belongs to another user, so the connector may not end it; it was not taken over.",
32147
- takeover_failed: "Ending the terminal's hold on the conversation failed, so it was not taken over.",
32148
- // (since connector 0.1.19 a running turn never holds a message back: Claude Code queues it; only someone's half-typed text in
32149
- // the box, or a screen scrolled back, held for 10 minutes ends it terminal_busy)
32150
- 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.",
32151
- // (Claude Code took the message into its own queue, then someone at the terminal pulled that queue back into the box)
32152
- 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.",
32153
- // (a terminal whose Claude Code cannot be told to hold this conversation, for 10 minutes)
32154
- 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.",
32155
- terminal_gone: "The terminal's tmux pane is gone, so the message was not typed in.",
32156
- terminal_switched: "That terminal has moved to another conversation (a /resume or /clear there), so the message was not typed in.",
32157
- terminal_input_failed: "Typing the message into the terminal failed; it was not sent.",
32158
- // (a connector after 0.1.22: the paste never showed in the box in the 20 seconds it waited)
32159
- 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.",
32160
- // (not a failure: the terminal may well have taken it; what the session does next still shows here)
32161
- 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.",
32162
- terminal_input_unavailable: "After a restart the connector could not prove that terminal again, so the message was not typed in. Attach again.",
32163
- empty_prompt: "The message was empty once its control characters were removed; nothing was typed.",
32164
- // (a prompt to a session that only watches a terminal's conversation; also a turn_end error)
32165
- 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.",
32166
- terminal_session: "That conversation is open in a terminal, which keeps its own mode.",
32167
- 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.",
32168
- 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.",
32169
- 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.",
32170
- 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.",
32171
- 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.",
32172
- cwd_ambiguous: "More than one of this agent's roots has a folder by that name. Give its full path.",
32173
- 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.",
32174
- session_closed: "That session has already closed.",
32175
- closed: "The session was closed as asked.",
32176
- stopped: "The connector on that machine was stopped. Start it again there (`claw-connector run`, or the service's `sh keepalive.sh`).",
32177
- paused: "The connector on that machine is paused. Run `claw-connector resume` there.",
32178
- revoked: "That machine's connector was revoked. Run `{login}` there to sign in again.",
32179
- text_required: "The message to the agent was empty.",
32180
- action_and_option_required: "That answer named no request or option. Tap the card again.",
32181
- too_many_queued_prompts: "The agent has too many messages waiting; this one was not taken. Send it again when it has caught up.",
32182
- cancelled: "That message was dropped unrun when the agent was stopped.",
32183
- unknown_action: "That approval request is gone.",
32184
- option_not_offered: "That option is not one the agent offered."
32185
- },
32186
- zh: {
32187
- 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',
32188
- 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',
32189
- 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",
32190
- 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",
32191
- 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',
32192
- 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",
32193
- set_mode_failed: "agent \u6CA1\u80FD\u5207\u6362\u6A21\u5F0F\uFF0C\u4ECD\u662F\u539F\u6765\u7684\u6A21\u5F0F\u3002",
32194
- adapter_gone: "\u90A3\u53F0\u673A\u5668\u4E0A\u7684 agent \u7A0B\u5E8F\u5DF2\u7ECF\u9000\u51FA\u4E86\u3002",
32195
- 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",
32196
- adapter_unavailable: "\u8FDE\u63A5\u5668\u6CA1\u80FD\u4E3A\u8FD9\u4E00\u8F6E\u542F\u52A8 agent \u7A0B\u5E8F\u3002",
32197
- 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",
32198
- adapter_cannot_resume: "\u8FD9\u4E2A agent \u4E0D\u80FD\u63A5\u7740\u4E4B\u524D\u7684\u5BF9\u8BDD\u7EE7\u7EED\u3002",
32199
- 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",
32200
- 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",
32201
- 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",
32202
- 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",
32203
- cwd_not_directory: "\u8FD9\u4E2A\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55\u3002",
32204
- cwd_not_absolute: "\u76EE\u5F55\u8981\u5199\u6210\u7EDD\u5BF9\u8DEF\u5F84\uFF08\u4EE5 / \u5F00\u5934\uFF09\u3002",
32205
- invalid_cwd: "\u8FD9\u4E2A\u76EE\u5F55\u540D\u65E0\u6548\uFF0C\u6362\u4E00\u4E2A\u76EE\u5F55\u518D\u8BD5\u3002",
32206
- cwd_mismatch: "\u6240\u9009\u5BF9\u8BDD\u4E0D\u5728\u8FD9\u4E2A\u76EE\u5F55\u91CC\u3002\u4ECE\u5217\u8868\u91CC\u91CD\u65B0\u9009\u3002",
32207
- 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",
32208
- 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",
32209
- 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",
32210
- 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",
32211
- 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",
32212
- 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",
32213
- 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",
32214
- resume_not_supported: "\u8FD9\u4E2A agent \u4E0D\u652F\u6301\u63A5\u7740\u5DF2\u6709\u7684\u4F1A\u8BDD\u7EE7\u7EED\u3002",
32215
- 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",
32216
- resume_ref_required: "\u6CA1\u6709\u6307\u660E\u8981\u63A5\u7BA1\u54EA\u6BB5\u5BF9\u8BDD\u3002\u4ECE\u5217\u8868\u91CC\u91CD\u65B0\u9009\u3002",
32217
- invalid_resume_ref: "\u8981\u63A5\u7BA1\u7684\u5BF9\u8BDD\u7F16\u53F7\u65E0\u6548\u3002\u4ECE\u5217\u8868\u91CC\u91CD\u65B0\u9009\u3002",
32218
- already_attached: "\u8FD9\u6BB5\u5BF9\u8BDD\u5DF2\u7ECF\u5728\u624B\u673A\u4E0A\u6253\u5F00\u4E86\u3002\u7528 `/agent sessions` \u5207\u8FC7\u53BB\u3002",
32219
- catalog_unavailable: "\u8FDE\u63A5\u5668\u6682\u65F6\u8BFB\u4E0D\u5230\u90A3\u53F0\u673A\u5668\u4E0A\u7684\u5BF9\u8BDD\u5217\u8868\u3002",
32220
- 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",
32221
- 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",
32222
- 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",
32223
- 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",
32224
- 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",
32225
- 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",
32226
- takeover_failed: "\u7ED3\u675F\u7EC8\u7AEF\u91CC\u7684\u8FD9\u6BB5\u5BF9\u8BDD\u5931\u8D25\u4E86\uFF0C\u6240\u4EE5\u6CA1\u6709\u63A5\u7BA1\u3002",
32227
- 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",
32228
- 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",
32229
- 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",
32230
- 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",
32231
- 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",
32232
- terminal_input_failed: "\u5F80\u7EC8\u7AEF\u91CC\u8F93\u5165\u8FD9\u6761\u6D88\u606F\u5931\u8D25\u4E86\uFF0C\u6CA1\u6709\u53D1\u8FDB\u53BB\u3002",
32233
- 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",
32234
- 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",
32235
- 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",
32236
- empty_prompt: "\u8FD9\u6761\u6D88\u606F\u53BB\u6389\u63A7\u5236\u5B57\u7B26\u540E\u662F\u7A7A\u7684\uFF0C\u6CA1\u6709\u53D1\u8FDB\u7EC8\u7AEF\u3002",
32237
- 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",
32238
- 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",
32239
- 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',
32240
- 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",
32241
- 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",
32242
- 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",
32243
- 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",
32244
- 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",
32245
- 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",
32246
- session_closed: "\u8FD9\u4E2A\u4F1A\u8BDD\u5DF2\u7ECF\u5173\u4E86\u3002",
32247
- closed: "\u4F1A\u8BDD\u5DF2\u6309\u8981\u6C42\u5173\u95ED\u3002",
32248
- 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",
32249
- 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",
32250
- 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",
32251
- text_required: "\u53D1\u7ED9 agent \u7684\u6D88\u606F\u662F\u7A7A\u7684\u3002",
32252
- 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",
32253
- 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",
32254
- cancelled: "\u8FD9\u6761\u6D88\u606F\u8FD8\u6CA1\u8FD0\u884C\u5C31\u56E0\u4E3A\u505C\u6B62\u800C\u88AB\u4E22\u5F03\u4E86\u3002",
32255
- unknown_action: "\u8FD9\u4E2A\u6279\u51C6\u8BF7\u6C42\u5DF2\u7ECF\u4E0D\u5728\u4E86\u3002",
32256
- option_not_offered: "\u8FD9\u4E2A\u9009\u9879\u4E0D\u662F agent \u63D0\u4F9B\u7684\u3002"
32233
+ ` : "") + text9 };
32234
+ }
32235
+ this.ctx.remoteState.setRemoteListing(chatKey, card.listing);
32236
+ return { kind: "card", message: card.message };
32257
32237
  }
32258
- });
32259
- var connectorReasonHints = defineCatalog({
32260
- en: {
32261
- upgrade: (p) => `Upgrade the connector: on that machine run \`${p.command}\` (it installs the new version and restarts the connector on it).`,
32262
- 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.',
32263
- status: "Run `claw-connector status` on that machine and look for a warning or problem line.",
32264
- newSession: "Start a new one with `/agent new`.",
32265
- retry: "Try again in a moment.",
32266
- 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.`,
32267
- /** Between a lead and the reason after it, and the end of a lead with none. */
32268
- leadSep: ": ",
32269
- leadEnd: "."
32270
- },
32271
- zh: {
32272
- 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`,
32273
- 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',
32274
- status: "\u5728\u90A3\u53F0\u673A\u5668\u4E0A\u8FD0\u884C `claw-connector status`\uFF0C\u770B\u6709\u6CA1\u6709 warning \u6216 problem \u884C\u3002",
32275
- newSession: "\u7528 `/agent new` \u5F00\u4E00\u4E2A\u65B0\u4F1A\u8BDD\u3002",
32276
- retry: "\u7A0D\u540E\u518D\u8BD5\u4E00\u6B21\u3002",
32277
- 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`,
32278
- leadSep: "\uFF1A",
32279
- 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;
32280
32255
  }
32281
- });
32282
-
32283
- // packages/core/src/remote/connector/reasons.ts
32284
- var FIXED_IN = [0, 1, 5];
32285
- var CODE4 = /^[a-z][a-z0-9_]{0,63}$/u;
32286
- var VERSION = /^v?(\d+)\.(\d+)\.(\d+)/u;
32287
- var both = (fn) => [fn("zh"), fn("en")];
32288
- var UPGRADE = both((lang) => connectorReasonHints.in(lang).upgrade({ command: UPGRADE_COMMAND }));
32289
- var SANDBOX = both((lang) => connectorReasonHints.in(lang).sandbox);
32290
- var STATUS2 = both((lang) => connectorReasonHints.in(lang).status);
32291
- var OLD_CONNECTOR = /* @__PURE__ */ new Set(["mode_unavailable", "mode_not_enforced"]);
32292
- var FIXED_LATER = {
32293
- terminal_input_unconfirmed: [0, 1, 22]
32294
32256
  };
32295
- var THEN_NEW = /* @__PURE__ */ new Set([
32296
- "adapter_gone",
32297
- "adapter_cannot_resume",
32298
- "unknown_session",
32299
- "resume_not_supported",
32300
- "session_closed",
32301
- "set_mode_failed",
32302
- "machine_reconnected"
32303
- ]);
32304
- var THEN_RETRY = /* @__PURE__ */ new Set(["catalog_unavailable", "twin_check_failed", "adapter_unavailable"]);
32305
- var KNOWN = new Set(Object.keys(connectorReasonText.in("en")));
32306
- function parseVersion2(value) {
32307
- const match = VERSION.exec(typeof value === "string" ? value.trim() : "");
32308
- return match ? [Number(match[1]), Number(match[2]), Number(match[3])] : null;
32309
- }
32310
- function older(version, than) {
32311
- for (let i = 0; i < than.length; i++) {
32312
- const a = version[i] ?? 0;
32313
- const b3 = than[i] ?? 0;
32314
- if (a !== b3) return a < b3;
32315
- }
32316
- return false;
32317
- }
32318
- function isCode(reason) {
32319
- return CODE4.test(reason);
32320
- }
32321
- function sentence2(code3, lang, setup) {
32322
- const text9 = own(connectorReasonText.in(lang), code3) ?? "";
32323
- return code3 === "revoked" ? text9.replaceAll("{login}", setup.login()) : text9;
32324
- }
32325
- function hintAfter(code3, lang, version) {
32326
- const hints = connectorReasonHints.in(lang);
32327
- if (OLD_CONNECTOR.has(code3)) {
32328
- const parsed = parseVersion2(version);
32329
- if (parsed === null || older(parsed, FIXED_IN))
32330
- return { sep: "\n\n", hint: `${hints.upgrade({ command: UPGRADE_COMMAND })}
32331
32257
 
32332
- ${hints.sandbox}
32333
-
32334
- ` };
32335
- 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;
32336
32263
  }
32337
- const fixedIn = own(FIXED_LATER, code3);
32338
- if (fixedIn) {
32339
- const parsed = parseVersion2(version);
32340
- if (parsed !== null && older(parsed, fixedIn))
32341
- return { sep: "\n\n", hint: hints.upgrade({ command: UPGRADE_COMMAND }) };
32342
- 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;
32343
32272
  }
32344
- if (THEN_NEW.has(code3)) return { sep: " ", hint: hints.newSession };
32345
- if (THEN_RETRY.has(code3)) return { sep: " ", hint: hints.retry };
32346
- return null;
32347
- }
32348
- function explain(code3, version = null, setup = new Setup("", null)) {
32349
- if (!KNOWN.has(code3)) return both((lang) => connectorReasonHints.in(lang).unknown({ code: code3 }));
32350
- return both((lang) => {
32351
- const after = hintAfter(code3, lang, version);
32352
- const own3 = sentence2(code3, lang, setup);
32353
- return after ? `${own3}${after.sep}${after.hint}` : own3;
32354
- });
32355
- }
32356
- function bareReason(reason) {
32357
- return pyStrip(pyRstrip(pyStrip(reason ?? ""), "."));
32358
- }
32359
- function inLang(lang, pair) {
32360
- if (lang === "zh") return pair[0];
32361
- if (lang === "en") return pair[1];
32362
- return `${pair[0]}
32363
- ${pair[1]}`;
32364
- }
32365
- function describe2(reason, lang, version = null, setup) {
32366
- const bare2 = bareReason(reason);
32367
- if (!bare2) return "";
32368
- if (!isCode(bare2)) return `${bare2}.`;
32369
- return inLang(lang, explain(bare2, version, setup));
32370
- }
32371
- function ended(lead, reason, lang, version = null, setup) {
32372
- if (lang === null) return ["zh", "en"].map((one) => ended(lead, reason, one, version, setup)).join("\n");
32373
- const why = describe2(reason, lang, version, setup);
32374
- const hints = connectorReasonHints.in(lang);
32375
- const head = inLang(lang, lead);
32376
- return why ? `${head}${hints.leadSep}${why}` : `${head}${hints.leadEnd}`;
32377
- }
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
+ };
32378
32384
 
32379
32385
  // packages/core/src/remote/ended.ts
32380
32386
  async function credentialOf(key, provider) {
@@ -32502,7 +32508,7 @@ function filled(payload) {
32502
32508
  return payload !== null && Object.keys(payload).length > 0;
32503
32509
  }
32504
32510
  function actionIdOf(payload) {
32505
- return textOf7(payload.actionId);
32511
+ return textOf6(payload.actionId);
32506
32512
  }
32507
32513
  async function readTail(read, decode2) {
32508
32514
  const fold = new TailFold();
@@ -33790,7 +33796,7 @@ var SessionClicks = class {
33790
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. */
33791
33797
  async back(click, lead) {
33792
33798
  const state = this.p.state.attached(click.chatKey);
33793
- const op = textOf7(click.data["op"]);
33799
+ const op = textOf6(click.data["op"]);
33794
33800
  if (state !== null && (["detach", "mode", "set_mode", "row", "stop"].includes(op) || isGroupKey(click.chatKey)) && // (a group: never the list)
33795
33801
  state.sessionId === click.data["session_id"]) {
33796
33802
  await this.end(click, (await this.p.ops.rowCard(click.chatKey, click.key, state, lead)).message, lead);
@@ -33852,7 +33858,7 @@ var SessionClicks = class {
33852
33858
  async send(click) {
33853
33859
  const state = await this.ownSession(click);
33854
33860
  if (state === null) return;
33855
- 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);
33856
33862
  const view7 = this.p.state.view(click.chatKey, state);
33857
33863
  if (!text9) {
33858
33864
  await this.closer(click)(remoteAgentText.in(this.lang(click)).emptySend);
@@ -33907,7 +33913,7 @@ ${block}`, { aiGenerated: true }));
33907
33913
  async setMode(click) {
33908
33914
  const state = await this.ownSession(click);
33909
33915
  if (state === null) return;
33910
- const mode = textOf7(click.data["mode"]);
33916
+ const mode = textOf6(click.data["mode"]);
33911
33917
  const refusal4 = await this.commands.changeMode(click, mode);
33912
33918
  const lead = refusal4 ?? remoteAgentText.in(this.lang(click)).askingSwitch({ mode: neutral(mode, MODE_ID_MAX) });
33913
33919
  await this.end(click, (await this.p.ops.rowCard(click.chatKey, click.key, state, lead)).message, lead);
@@ -33935,7 +33941,7 @@ ${block}`, { aiGenerated: true }));
33935
33941
  if (done && click.tapped) this.p.ctx.remoteState.setRemoteStatusCard(click.chatKey, click.tapped);
33936
33942
  }
33937
33943
  async close(click) {
33938
- const wanted = textOf7(click.data["session_id"]);
33944
+ const wanted = textOf6(click.data["session_id"]);
33939
33945
  const { sessions } = await this.p.lists.sessions(click.key);
33940
33946
  const session = sessions.find((s) => s.sessionId === wanted);
33941
33947
  if (session === void 0) return this.home(click, saidIn(this.lang(click), "sessionNotFound"));
@@ -34140,8 +34146,8 @@ var Permissions = class {
34140
34146
  const personal2 = isGroupKey(chatKey) ? this.ctx.references.getReference(personOf2(chatKey)) : null;
34141
34147
  const groupLang = this.state.lang(chatKey);
34142
34148
  const lang = personal2 ? this.state.lang(personOf2(chatKey)) : groupLang;
34143
- const actionId = textOf7(request["actionId"]);
34144
- if (TERMINAL_ORIGINS.has(textOf7(request["origin"]))) return;
34149
+ const actionId = textOf6(request["actionId"]);
34150
+ if (TERMINAL_ORIGINS.has(textOf6(request["origin"]))) return;
34145
34151
  const options = parseOptions(request["options"]);
34146
34152
  if (!actionId || options.length === 0) {
34147
34153
  await to.send(textMessage(saidIn(groupLang, "noAnswerableOption")));
@@ -34149,7 +34155,7 @@ var Permissions = class {
34149
34155
  }
34150
34156
  const expiresAt = this.ctx.clock.epochMs() / 1e3 + secondsOf2(request["timeout_ms"]);
34151
34157
  const words3 = remoteText.in(lang);
34152
- const tool2 = textOf7(request["tool"]) || words3.anAction;
34158
+ const tool2 = textOf6(request["tool"]) || words3.anAction;
34153
34159
  if (!this.ctx.permissions.saveRemotePermission({
34154
34160
  userId: chatKey,
34155
34161
  sessionId,
@@ -34210,7 +34216,7 @@ var Permissions = class {
34210
34216
  /** A click on an option of a permission card (see the module). */
34211
34217
  async decide(click) {
34212
34218
  const [sessionId, actionId, optionId] = ["session_id", "action_id", "option_id"].map(
34213
- (k) => textOf7(own(click.data, k))
34219
+ (k) => textOf6(own(click.data, k))
34214
34220
  );
34215
34221
  const perm = this.ctx.settings.enabled ? this.ctx.permissions.getRemotePermission(sessionId ?? "", actionId ?? "") : null;
34216
34222
  const lang = this.cardLang(perm, click.person);
@@ -34431,7 +34437,8 @@ var Prompts = class {
34431
34437
  this.closeTurn(p.chatKey, state);
34432
34438
  this.runner.stopReading(p.chatKey);
34433
34439
  }
34434
- 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)) }));
34435
34442
  return;
34436
34443
  }
34437
34444
  if (reader) return;
@@ -35390,7 +35397,8 @@ var TurnRunner = class {
35390
35397
  }
35391
35398
  display.movedOn?.();
35392
35399
  try {
35393
- 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) })));
35394
35402
  } catch (error) {
35395
35403
  this.ctx.logger.warn("that a queued message was refused could not be told", { error: errorName(error) });
35396
35404
  }
@@ -35943,6 +35951,11 @@ function summaryMinutes(arg) {
35943
35951
  const n = Number(arg);
35944
35952
  return n >= SUMMARY_MIN && n <= SUMMARY_MAX3 ? n : null;
35945
35953
  }
35954
+ function mutedLine(m, words3) {
35955
+ const who = [m.item === null ? "" : `#${String(m.item)}`, lit(m.title, 60), lit(m.machine, 40)].filter(Boolean).join(" \xB7 ");
35956
+ const at = parseIsoSeconds(m.muted_since);
35957
+ return words3.mutedLine({ who: who || words3.mutedUnnamed, since: at === null ? "" : utcStamp2(at) });
35958
+ }
35946
35959
  var TerminalApprovalsCommand = class {
35947
35960
  constructor(claw) {
35948
35961
  this.claw = claw;
@@ -35962,7 +35975,7 @@ var TerminalApprovalsCommand = class {
35962
35975
  return true;
35963
35976
  }
35964
35977
  try {
35965
- if (arg === "") await say3(await this.claw.approvals(route.credential) ? words3.approvalsOn : words3.approvalsOff);
35978
+ if (arg === "") await say3(await this.state(route));
35966
35979
  else {
35967
35980
  const enabled = await this.claw.setApprovals(route.credential, arg === "on");
35968
35981
  await say3(enabled ? words3.approvalsTurnedOn : words3.approvalsTurnedOff);
@@ -35973,6 +35986,23 @@ var TerminalApprovalsCommand = class {
35973
35986
  }
35974
35987
  return true;
35975
35988
  }
35989
+ /** The whole state, as one message: the switch, how often a conversation that works on its own is summed up, the muted ones. */
35990
+ async state(route) {
35991
+ const words3 = terminalApprovalText.in(route.lang());
35992
+ const [enabled, every, muted2] = await Promise.all([
35993
+ this.claw.approvals(route.credential),
35994
+ this.claw.summary(route.credential),
35995
+ this.claw.mutedTerminals(route.credential)
35996
+ ]);
35997
+ const lines = [
35998
+ enabled ? words3.approvalsOn : words3.approvalsOff,
35999
+ every === 0 ? words3.summaryNever : words3.summaryEvery({ minutes: String(every) })
36000
+ ];
36001
+ if (muted2.length === 0) lines.push(words3.mutedNone);
36002
+ else
36003
+ lines.push(words3.mutedHeader({ count: String(muted2.length) }), ...muted2.map((m) => `- ${mutedLine(m, words3)}`));
36004
+ return lines.join("\n");
36005
+ }
35976
36006
  async summary(route, arg) {
35977
36007
  const words3 = terminalApprovalText.in(route.lang());
35978
36008
  const say3 = (text9) => route.conversation.send(textMessage(text9));