@primusclaw/personal-agent 0.14.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +224 -6
- package/dist/types/assistant/events.d.ts +28 -0
- package/dist/types/locales/terminal-approvals.d.ts +38 -0
- package/dist/types/ports/claw/remote-agents.d.ts +13 -1
- package/dist/types/proactive/deliver.d.ts +5 -0
- package/dist/types/protocol/claw-api/assistant-events.d.ts +40 -0
- package/dist/types/protocol/remote-agents.d.ts +45 -1
- package/dist/types/remote/approvals-command.d.ts +6 -1
- package/dist/types/remote-view/index.d.ts +3 -0
- package/dist/types/remote-view/terminal-ask-view.d.ts +2 -0
- package/dist/types/remote-view/terminal-end-view.d.ts +44 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5621,6 +5621,30 @@ function parseApprovalsSetting(body) {
|
|
|
5621
5621
|
if (!isObject(body) || typeof body.enabled !== "boolean") return fail("enabled_required");
|
|
5622
5622
|
return { ok: true, value: { enabled: body.enabled } };
|
|
5623
5623
|
}
|
|
5624
|
+
var ASK_TAIL = 300;
|
|
5625
|
+
var ASK_WORDS = [
|
|
5626
|
+
/(?:要不要|是否需要|是否要|是否继续|可以吗|行吗|好吗|同意吗|你看呢|选哪个|选哪一个|哪个方案)/u,
|
|
5627
|
+
/(?:请|麻烦)(?:你|您)?(?:确认|决定|拍板|选择|批准|审批|回复|告诉我)/u,
|
|
5628
|
+
/(?:等你|等您|需要你|需要您)(?:的)?(?:确认|决定|拍板|选择|批准|回复|答复|同意|授权)/u,
|
|
5629
|
+
/(?:你来|您来)(?:定|决定|选)/u,
|
|
5630
|
+
/\b(?:should I|shall I|do you want(?: me)? to|would you like(?: me)? to|want me to|let me know (?:if|whether|which|how)|please (?:confirm|approve|decide|choose|advise)|(?:waiting|wait) (?:for|on) your|need your (?:input|decision|approval|confirmation|go-ahead)|your call|which (?:option|one) (?:do you|would you|should))\b/iu
|
|
5631
|
+
];
|
|
5632
|
+
function turnAsksPerson(message) {
|
|
5633
|
+
const text9 = message.replace(/\r\n?/gu, "\n").trim();
|
|
5634
|
+
if (!text9) return false;
|
|
5635
|
+
const blocks2 = text9.split(/\n\s*\n/u).map((b3) => b3.trim()).filter(Boolean);
|
|
5636
|
+
const last = (blocks2[blocks2.length - 1] ?? "").replace(/[`*_~>#]+/gu, "").trim();
|
|
5637
|
+
const tail = Array.from(last).slice(-ASK_TAIL).join("");
|
|
5638
|
+
if (/[??][\s))」』"'”’\]】]*[\p{Extended_Pictographic}\s]*$/u.test(tail)) return true;
|
|
5639
|
+
return ASK_WORDS.some((re2) => re2.test(tail));
|
|
5640
|
+
}
|
|
5641
|
+
var TERMINAL_SUMMARY = { defaultMinutes: 60, minMinutes: 15, maxMinutes: 24 * 60 };
|
|
5642
|
+
function parseTerminalSummarySetting(body) {
|
|
5643
|
+
if (!isObject(body) || typeof body.minutes !== "number" || !Number.isSafeInteger(body.minutes)) return fail("minutes_required");
|
|
5644
|
+
const m = body.minutes;
|
|
5645
|
+
if (m !== 0 && (m < TERMINAL_SUMMARY.minMinutes || m > TERMINAL_SUMMARY.maxMinutes)) return fail("minutes_out_of_range");
|
|
5646
|
+
return { ok: true, value: { minutes: m } };
|
|
5647
|
+
}
|
|
5624
5648
|
function parseTerminalMute(body) {
|
|
5625
5649
|
if (!isObject(body) || typeof body.muted !== "boolean") return fail("muted_required");
|
|
5626
5650
|
if (typeof body.item !== "number" || !Number.isSafeInteger(body.item) || body.item < 1) return fail("item_required");
|
|
@@ -18807,6 +18831,45 @@ function choiceOf(event) {
|
|
|
18807
18831
|
if (options.length < CHOICE_OPTIONS_MIN || options.length > CHOICE_OPTIONS_MAX) return void 0;
|
|
18808
18832
|
return { options, multiple: choice["multiple"] === true };
|
|
18809
18833
|
}
|
|
18834
|
+
var END_NAME_MAX = 120;
|
|
18835
|
+
var END_ERROR_MAX = 60;
|
|
18836
|
+
var END_SUMMARY_MAX = 400;
|
|
18837
|
+
var END_FULL_MAX = 2e3;
|
|
18838
|
+
var END_ATTACH = /^\/agent attach [A-Za-z0-9._:-]{6,128}$/u;
|
|
18839
|
+
var clipText = (value, max) => typeof value === "string" ? Array.from(value).slice(0, max).join("") : "";
|
|
18840
|
+
var END_EARLIER_MAX = 400;
|
|
18841
|
+
function terminalEarlierOf(value) {
|
|
18842
|
+
if (!Array.isArray(value)) return [];
|
|
18843
|
+
const out = [];
|
|
18844
|
+
for (const entry of value.slice(0, 2)) {
|
|
18845
|
+
const e = record2(entry);
|
|
18846
|
+
const kind = e?.["kind"];
|
|
18847
|
+
const count6 = e?.["count"];
|
|
18848
|
+
if (e === void 0 || kind !== "asked" && kind !== "failed" || out.some((o) => o.kind === kind)) continue;
|
|
18849
|
+
if (typeof count6 !== "number" || !Number.isSafeInteger(count6) || count6 <= 0) continue;
|
|
18850
|
+
out.push({ kind, text: clipText(e["text"], END_EARLIER_MAX), count: Math.min(count6, 1e4) });
|
|
18851
|
+
}
|
|
18852
|
+
return out;
|
|
18853
|
+
}
|
|
18854
|
+
function terminalEndOf(remote) {
|
|
18855
|
+
const kind = remote["kind"];
|
|
18856
|
+
const end = record2(remote["end"]);
|
|
18857
|
+
if (end === void 0 || kind !== "done" && kind !== "error") return void 0;
|
|
18858
|
+
const seq = end["item_seq"];
|
|
18859
|
+
if (typeof seq !== "number" || !Number.isSafeInteger(seq) || seq <= 0) return void 0;
|
|
18860
|
+
const attach = typeof end["attach"] === "string" && END_ATTACH.test(end["attach"]) ? end["attach"] : "";
|
|
18861
|
+
return {
|
|
18862
|
+
itemSeq: seq,
|
|
18863
|
+
name: clipText(end["name"], END_NAME_MAX),
|
|
18864
|
+
folder: clipText(end["folder"], END_NAME_MAX),
|
|
18865
|
+
error: kind === "error" ? clipText(end["error"], END_ERROR_MAX) : "",
|
|
18866
|
+
summary: clipText(end["summary"], END_SUMMARY_MAX),
|
|
18867
|
+
full: clipText(end["full"], END_FULL_MAX),
|
|
18868
|
+
more: end["more"] === true,
|
|
18869
|
+
attach,
|
|
18870
|
+
earlier: terminalEarlierOf(end["earlier"])
|
|
18871
|
+
};
|
|
18872
|
+
}
|
|
18810
18873
|
var REMOTE_KINDS = /* @__PURE__ */ new Set(["done", "needs_you", "error", "resolved", "progress"]);
|
|
18811
18874
|
var SEAT_ALIAS_MAX = 40;
|
|
18812
18875
|
function seatOf(remote, ask3) {
|
|
@@ -18840,8 +18903,10 @@ function remoteNoticeOf(event) {
|
|
|
18840
18903
|
const resolved = kind === "resolved" ? resolvedOf(remote) : void 0;
|
|
18841
18904
|
if (kind === "resolved" && resolved === void 0) return void 0;
|
|
18842
18905
|
const ask3 = record2(remote["ask"]);
|
|
18906
|
+
const end = terminalEndOf(remote);
|
|
18843
18907
|
return {
|
|
18844
18908
|
...resolved ? { resolved } : {},
|
|
18909
|
+
...end ? { end } : {},
|
|
18845
18910
|
...seatOf(remote, ask3),
|
|
18846
18911
|
kind,
|
|
18847
18912
|
sessionId,
|
|
@@ -21368,12 +21433,31 @@ var terminalApprovalText = defineCatalog({
|
|
|
21368
21433
|
approvalsOff: "Approvals from terminals are off: questions stay in the terminal.",
|
|
21369
21434
|
approvalsTurnedOn: "Turned on: questions your terminals ask come here too. `/approvals off` stops it.",
|
|
21370
21435
|
approvalsTurnedOff: "Turned off: questions stay in the terminal. `/approvals on` brings them back.",
|
|
21371
|
-
approvalsUsage: "Use `/approvals on
|
|
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",
|
|
21372
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.`,
|
|
21373
21442
|
unmuted: (p) => `Unmuted #${p.item}${p.where ? ` (${p.where})` : ""}: that conversation's questions and ends come here again.`,
|
|
21374
21443
|
muteNotFound: (p) => `I have no item #${p.item} of yours.`,
|
|
21375
21444
|
muteNotTerminal: (p) => `#${p.item} is not a conversation open in one of your terminals, so there is nothing to mute.`,
|
|
21376
|
-
|
|
21445
|
+
endDone: "finished",
|
|
21446
|
+
endError: (p) => `stopped with an error (${p.error})`,
|
|
21447
|
+
endIdle: "terminal idle",
|
|
21448
|
+
endFull: "Show all",
|
|
21449
|
+
endRest: "The rest is in the terminal.",
|
|
21450
|
+
endAttach: "Attach",
|
|
21451
|
+
endMute: "Mute this conversation",
|
|
21452
|
+
endEarlierAsked: (p) => p.text ? `An earlier turn asked: ${p.text}${p.count > 1 ? ` (${String(p.count)} earlier turns asked; see the terminal)` : ""}` : p.count > 1 ? `${String(p.count)} earlier turns asked you something; see the terminal.` : "An earlier turn asked you something; see the terminal.",
|
|
21453
|
+
endEarlierFailed: (p) => p.text ? `An earlier turn stopped with an error: ${p.text}${p.count > 1 ? ` (${String(p.count)} earlier turns did; see the terminal)` : ""}` : p.count > 1 ? `${String(p.count)} earlier turns stopped with an error; see the terminal.` : "An earlier turn stopped with an error; see the terminal.",
|
|
21454
|
+
endLatest: (p) => `Latest turn: ${p.text}`,
|
|
21455
|
+
approvalsUnavailable: "I could not reach the setting just now. Try again in a moment.",
|
|
21456
|
+
summaryEvery: (p) => `A terminal conversation that keeps working on its own (turns another session or a schedule started) is summed up at most once every ${p.minutes} minutes; the end of a turn you started, or one that asks you something, comes at once. \`/approvals summary <minutes>|off\` changes it.`,
|
|
21457
|
+
summaryNever: "Summaries are off: only the end of a turn you started, or one that asks you something, comes here. `/approvals summary 60` turns them back on.",
|
|
21458
|
+
summarySet: (p) => `Done: a conversation that keeps working on its own is summed up at most once every ${p.minutes} minutes.`,
|
|
21459
|
+
summaryOff: "Done: no more summaries; the end of a turn you started, or one that asks you something, still comes here.",
|
|
21460
|
+
summaryUsage: "Use `/approvals summary <minutes>` with 15 to 1440 minutes, `/approvals summary off`, or `/approvals summary` to see it."
|
|
21377
21461
|
},
|
|
21378
21462
|
zh: {
|
|
21379
21463
|
title: "\u7EC8\u7AEF\u5728\u7B49\u4F60\u56DE\u7B54",
|
|
@@ -21408,12 +21492,31 @@ var terminalApprovalText = defineCatalog({
|
|
|
21408
21492
|
approvalsOff: "\u7EC8\u7AEF\u5BA1\u6279\u63A8\u9001\u5DF2\u5173\u95ED\uFF1A\u8FD9\u4E9B\u95EE\u9898\u53EA\u5728\u7EC8\u7AEF\u91CC\u95EE\u3002",
|
|
21409
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",
|
|
21410
21494
|
approvalsTurnedOff: "\u5DF2\u5173\u95ED\uFF1A\u95EE\u9898\u53EA\u5728\u7EC8\u7AEF\u91CC\u95EE\u3002\u53D1 `/approvals on` \u91CD\u65B0\u5F00\u542F\u3002",
|
|
21411
|
-
approvalsUsage: "\u7528 `/approvals on` \u6216 `/approvals off
|
|
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",
|
|
21412
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`,
|
|
21413
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`,
|
|
21414
21502
|
muteNotFound: (p) => `\u4F60\u6CA1\u6709\u7F16\u53F7\u4E3A #${p.item} \u7684\u4E8B\u9879\u3002`,
|
|
21415
21503
|
muteNotTerminal: (p) => `#${p.item} \u4E0D\u662F\u4F60\u7EC8\u7AEF\u91CC\u6253\u5F00\u7684\u4F1A\u8BDD\uFF0C\u6CA1\u6709\u53EF\u9759\u97F3\u7684\u3002`,
|
|
21416
|
-
|
|
21504
|
+
endDone: "\u505A\u5B8C\u4E86",
|
|
21505
|
+
endError: (p) => `\u51FA\u9519\u505C\u4E0B\uFF08${p.error}\uFF09`,
|
|
21506
|
+
endIdle: "\u7EC8\u7AEF\u7A7A\u95F2",
|
|
21507
|
+
endFull: "\u5168\u6587",
|
|
21508
|
+
endRest: "\u5168\u6587\u89C1\u7EC8\u7AEF\u3002",
|
|
21509
|
+
endAttach: "\u63A5\u5165\u4F1A\u8BDD",
|
|
21510
|
+
endMute: "\u9759\u97F3\u6B64\u4F1A\u8BDD",
|
|
21511
|
+
endEarlierAsked: (p) => p.text ? `\u65E9\u5148\u4E00\u8F6E\u5728\u95EE\u4F60\uFF1A${p.text}${p.count > 1 ? `\uFF08\u65E9\u5148\u5171 ${String(p.count)} \u8F6E\u5728\u95EE\u4F60\uFF0C\u8BE6\u89C1\u7EC8\u7AEF\uFF09` : ""}` : `\u65E9\u5148\u6709 ${String(p.count)} \u8F6E\u5728\u95EE\u4F60\uFF0C\u8BE6\u89C1\u7EC8\u7AEF\u3002`,
|
|
21512
|
+
endEarlierFailed: (p) => p.text ? `\u65E9\u5148\u4E00\u8F6E\u51FA\u9519\u505C\u4E0B\uFF1A${p.text}${p.count > 1 ? `\uFF08\u65E9\u5148\u5171 ${String(p.count)} \u8F6E\u51FA\u9519\uFF0C\u8BE6\u89C1\u7EC8\u7AEF\uFF09` : ""}` : `\u65E9\u5148\u6709 ${String(p.count)} \u8F6E\u51FA\u9519\u505C\u4E0B\uFF0C\u8BE6\u89C1\u7EC8\u7AEF\u3002`,
|
|
21513
|
+
endLatest: (p) => `\u6700\u65B0\u4E00\u8F6E\uFF1A${p.text}`,
|
|
21514
|
+
approvalsUnavailable: "\u6682\u65F6\u8BFB\u4E0D\u5230\u8FD9\u4E2A\u8BBE\u7F6E\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5\u3002",
|
|
21515
|
+
summaryEvery: (p) => `\u5176\u4ED6\u4F1A\u8BDD\u6216\u5B9A\u65F6\u4EFB\u52A1\u9A71\u52A8\u3001\u6301\u7EED\u5728\u8DD1\u7684\u7EC8\u7AEF\u4F1A\u8BDD\uFF0C\u6700\u591A\u6BCF ${p.minutes} \u5206\u949F\u6C47\u603B\u4E00\u6B21\uFF1B\u4F60\u81EA\u5DF1\u53D1\u8D77\u7684\u56DE\u5408\u3001\u6216\u5728\u95EE\u4F60\u7684\u56DE\u5408\uFF0C\u7ED3\u675F\u65F6\u7ACB\u5373\u63A8\u9001\u3002\u53D1 \`/approvals summary <\u5206\u949F>|off\` \u4FEE\u6539\u3002`,
|
|
21516
|
+
summaryNever: "\u6C47\u603B\u5DF2\u5173\u95ED\uFF1A\u53EA\u63A8\u9001\u4F60\u81EA\u5DF1\u53D1\u8D77\u7684\u56DE\u5408\u3001\u6216\u5728\u95EE\u4F60\u7684\u56DE\u5408\u3002\u53D1 `/approvals summary 60` \u91CD\u65B0\u5F00\u542F\u3002",
|
|
21517
|
+
summarySet: (p) => `\u5DF2\u8BBE\u7F6E\uFF1A\u6301\u7EED\u5DE5\u4F5C\u7684\u7EC8\u7AEF\u4F1A\u8BDD\u6700\u591A\u6BCF ${p.minutes} \u5206\u949F\u6C47\u603B\u4E00\u6B21\u3002`,
|
|
21518
|
+
summaryOff: "\u5DF2\u5173\u95ED\u6C47\u603B\uFF1B\u4F60\u81EA\u5DF1\u53D1\u8D77\u7684\u56DE\u5408\u3001\u6216\u5728\u95EE\u4F60\u7684\u56DE\u5408\uFF0C\u7ED3\u675F\u65F6\u4ECD\u4F1A\u63A8\u9001\u3002",
|
|
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"
|
|
21417
21520
|
}
|
|
21418
21521
|
});
|
|
21419
21522
|
|
|
@@ -21731,6 +21834,44 @@ function projectOf(ask3) {
|
|
|
21731
21834
|
return str4(ask3["cwd"]).split("/").filter(Boolean).pop() ?? "";
|
|
21732
21835
|
}
|
|
21733
21836
|
|
|
21837
|
+
// packages/core/src/remote-view/terminal-end-view.ts
|
|
21838
|
+
function terminalEndView(input) {
|
|
21839
|
+
const { end, lang } = input;
|
|
21840
|
+
const words3 = terminalApprovalText.in(lang);
|
|
21841
|
+
const failed3 = end.error !== "";
|
|
21842
|
+
const name = lit(end.name, 80) || lit(input.agent, 40);
|
|
21843
|
+
const status = failed3 ? words3.endError({ error: lit(end.error, 40) }) : words3.endDone;
|
|
21844
|
+
const where = [
|
|
21845
|
+
end.name ? lit(input.agent, 40) : "",
|
|
21846
|
+
lit(input.machine, 60),
|
|
21847
|
+
lit(end.folder, 80),
|
|
21848
|
+
words3.endIdle,
|
|
21849
|
+
`#${String(end.itemSeq)}`
|
|
21850
|
+
].filter(Boolean);
|
|
21851
|
+
const earlier = end.earlier.map((e) => {
|
|
21852
|
+
const said2 = { text: lit(e.text, 400), count: e.count };
|
|
21853
|
+
return e.kind === "asked" ? words3.endEarlierAsked(said2) : words3.endEarlierFailed(said2);
|
|
21854
|
+
});
|
|
21855
|
+
const lines = end.summary.split("\n").map((line3) => lit(line3, 400)).filter(Boolean);
|
|
21856
|
+
const summary = (earlier.length && lines.length ? [words3.endLatest({ text: lines[0] ?? "" }), ...lines.slice(1)] : lines).join("\n\n");
|
|
21857
|
+
const full = end.more && end.full.trim() ? wordsText(end.full.trim()) : "";
|
|
21858
|
+
const buttons2 = [];
|
|
21859
|
+
if (end.attach) buttons2.push({ title: words3.endAttach, command: end.attach });
|
|
21860
|
+
buttons2.push({ title: words3.endMute, command: `/approvals mute #${String(end.itemSeq)}` });
|
|
21861
|
+
return {
|
|
21862
|
+
lang,
|
|
21863
|
+
title: `${name} ${status}`,
|
|
21864
|
+
failed: failed3,
|
|
21865
|
+
where: where.join(" \xB7 "),
|
|
21866
|
+
earlier,
|
|
21867
|
+
summary,
|
|
21868
|
+
full,
|
|
21869
|
+
fullLabel: words3.endFull,
|
|
21870
|
+
rest: end.more && !full ? words3.endRest : "",
|
|
21871
|
+
buttons: buttons2
|
|
21872
|
+
};
|
|
21873
|
+
}
|
|
21874
|
+
|
|
21734
21875
|
// packages/core/src/proactive/deliver.ts
|
|
21735
21876
|
var PROMPT_TITLE_MAX = 60;
|
|
21736
21877
|
function view6(v) {
|
|
@@ -21841,8 +21982,22 @@ var Deliveries = class {
|
|
|
21841
21982
|
}
|
|
21842
21983
|
if (remote?.kind === "needs_you" && remote.ask !== void 0)
|
|
21843
21984
|
return this.sendRemoteAsk(userId, conversation, event, remote);
|
|
21985
|
+
if (remote?.end !== void 0) return this.sendTerminalEnd(userId, conversation, event, remote, remote.end);
|
|
21844
21986
|
return void 0;
|
|
21845
21987
|
}
|
|
21988
|
+
/**
|
|
21989
|
+
* A turn that ended in a terminal while nobody was at it: its own card (which conversation, what it did, its whole answer on a tap,
|
|
21990
|
+
* and buttons that attach the chat to it or mute it); a channel that cannot show the card says Claw's words instead.
|
|
21991
|
+
*/
|
|
21992
|
+
async sendTerminalEnd(userId, conversation, event, remote, end) {
|
|
21993
|
+
if (!conversation.caps.views) return void 0;
|
|
21994
|
+
const lang = answerLang(this.deps.store.prefs.getPrefs(userId).lang, this.clientLocale(), event["text"]);
|
|
21995
|
+
const model = terminalEndView({ end, machine: remote.machine, agent: remote.agent, lang });
|
|
21996
|
+
await conversation.send({
|
|
21997
|
+
body: { type: "view", view: { name: "terminalEnd", model }, fallbackText: str5(event["text"]) }
|
|
21998
|
+
});
|
|
21999
|
+
return true;
|
|
22000
|
+
}
|
|
21846
22001
|
/**
|
|
21847
22002
|
* What the assistant said, then, when its turn was refused something for want of a confirmed identity (`needs_identity`) and
|
|
21848
22003
|
* this is the person's own chat (a group binding's key has `#`), the card that confirms it. A card that could not be sent never
|
|
@@ -28863,7 +29018,9 @@ __export(remote_view_exports, {
|
|
|
28863
29018
|
takeoverView: () => takeoverView,
|
|
28864
29019
|
terminalAskView: () => terminalAskView,
|
|
28865
29020
|
terminalAsksOf: () => terminalAsksOf,
|
|
28866
|
-
|
|
29021
|
+
terminalEndView: () => terminalEndView,
|
|
29022
|
+
windowView: () => windowView,
|
|
29023
|
+
wordsText: () => wordsText
|
|
28867
29024
|
});
|
|
28868
29025
|
|
|
28869
29026
|
// packages/core/src/remote-view/machine-views.ts
|
|
@@ -35785,6 +35942,20 @@ var RemoteAgents = class {
|
|
|
35785
35942
|
};
|
|
35786
35943
|
|
|
35787
35944
|
// packages/core/src/remote/approvals-command.ts
|
|
35945
|
+
var SUMMARY_MIN = 15;
|
|
35946
|
+
var SUMMARY_MAX3 = 24 * 60;
|
|
35947
|
+
function summaryMinutes(arg) {
|
|
35948
|
+
if (arg === "") return void 0;
|
|
35949
|
+
if (arg === "off" || arg === "0") return 0;
|
|
35950
|
+
if (!/^\d{1,4}$/.test(arg)) return null;
|
|
35951
|
+
const n = Number(arg);
|
|
35952
|
+
return n >= SUMMARY_MIN && n <= SUMMARY_MAX3 ? n : null;
|
|
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
|
+
}
|
|
35788
35959
|
var TerminalApprovalsCommand = class {
|
|
35789
35960
|
constructor(claw) {
|
|
35790
35961
|
this.claw = claw;
|
|
@@ -35797,12 +35968,14 @@ var TerminalApprovalsCommand = class {
|
|
|
35797
35968
|
const arg = args.trim().toLowerCase();
|
|
35798
35969
|
const one = /^(mute|unmute)\s+#?(\d{1,9})$/.exec(arg);
|
|
35799
35970
|
if (one) return this.mute(route, one[1] === "mute", Number(one[2]));
|
|
35971
|
+
const [word2, ...rest] = arg.split(/\s+/u);
|
|
35972
|
+
if (word2 === "summary") return this.summary(route, rest.join(" "));
|
|
35800
35973
|
if (arg !== "" && arg !== "on" && arg !== "off") {
|
|
35801
35974
|
await say3(words3.approvalsUsage);
|
|
35802
35975
|
return true;
|
|
35803
35976
|
}
|
|
35804
35977
|
try {
|
|
35805
|
-
if (arg === "") await say3(await this.
|
|
35978
|
+
if (arg === "") await say3(await this.state(route));
|
|
35806
35979
|
else {
|
|
35807
35980
|
const enabled = await this.claw.setApprovals(route.credential, arg === "on");
|
|
35808
35981
|
await say3(enabled ? words3.approvalsTurnedOn : words3.approvalsTurnedOff);
|
|
@@ -35813,6 +35986,48 @@ var TerminalApprovalsCommand = class {
|
|
|
35813
35986
|
}
|
|
35814
35987
|
return true;
|
|
35815
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
|
+
}
|
|
36006
|
+
async summary(route, arg) {
|
|
36007
|
+
const words3 = terminalApprovalText.in(route.lang());
|
|
36008
|
+
const say3 = (text9) => route.conversation.send(textMessage(text9));
|
|
36009
|
+
const minutes = summaryMinutes(arg);
|
|
36010
|
+
if (minutes === null) {
|
|
36011
|
+
await say3(words3.summaryUsage);
|
|
36012
|
+
return true;
|
|
36013
|
+
}
|
|
36014
|
+
try {
|
|
36015
|
+
const every = minutes === void 0 ? await this.claw.summary(route.credential) : await this.claw.setSummary(route.credential, minutes);
|
|
36016
|
+
if (minutes === void 0)
|
|
36017
|
+
await say3(every === 0 ? words3.summaryNever : words3.summaryEvery({ minutes: String(every) }));
|
|
36018
|
+
else await say3(every === 0 ? words3.summaryOff : words3.summarySet({ minutes: String(every) }));
|
|
36019
|
+
} catch (error) {
|
|
36020
|
+
await say3(this.refusal(error, words3));
|
|
36021
|
+
}
|
|
36022
|
+
return true;
|
|
36023
|
+
}
|
|
36024
|
+
/** What to say when Claw refused or could not be reached; anything else is not this command's to answer. */
|
|
36025
|
+
refusal(error, words3) {
|
|
36026
|
+
if (error instanceof ClawError && error.status === 400) return words3.summaryUsage;
|
|
36027
|
+
if (error instanceof ClawError || error instanceof ClawAnswerInvalid || isTransport2(error))
|
|
36028
|
+
return words3.approvalsUnavailable;
|
|
36029
|
+
throw error;
|
|
36030
|
+
}
|
|
35816
36031
|
async mute(route, muted2, item) {
|
|
35817
36032
|
const words3 = terminalApprovalText.in(route.lang());
|
|
35818
36033
|
const say3 = (text9) => route.conversation.send(textMessage(text9));
|
|
@@ -36116,6 +36331,7 @@ export {
|
|
|
36116
36331
|
TERMINAL_ASKS,
|
|
36117
36332
|
TERMINAL_HOOK_COMMANDS,
|
|
36118
36333
|
TERMINAL_SESSION_LIMITS,
|
|
36334
|
+
TERMINAL_SUMMARY,
|
|
36119
36335
|
THUMB_COMMENT_MAX,
|
|
36120
36336
|
TITLE_ID,
|
|
36121
36337
|
TOKEN,
|
|
@@ -36373,6 +36589,7 @@ export {
|
|
|
36373
36589
|
parseStartedReviews,
|
|
36374
36590
|
parseTerminalMute,
|
|
36375
36591
|
parseTerminalSessionOpen,
|
|
36592
|
+
parseTerminalSummarySetting,
|
|
36376
36593
|
parseTimezone,
|
|
36377
36594
|
parseWorkItem,
|
|
36378
36595
|
parseWorkspacesReport,
|
|
@@ -36497,6 +36714,7 @@ export {
|
|
|
36497
36714
|
toolOf,
|
|
36498
36715
|
turn_exports as turn,
|
|
36499
36716
|
turnApprovals,
|
|
36717
|
+
turnAsksPerson,
|
|
36500
36718
|
turnIdOf,
|
|
36501
36719
|
two,
|
|
36502
36720
|
typedAnswerText,
|
|
@@ -128,6 +128,34 @@ export interface RemoteNotice {
|
|
|
128
128
|
* request whose card may be in the chat already.
|
|
129
129
|
*/
|
|
130
130
|
readonly parked?: boolean;
|
|
131
|
+
/** A turn of a conversation open in a terminal that ended while nobody was at it (`remote.end`, with `kind` done or error). */
|
|
132
|
+
readonly end?: TerminalEnd;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* A terminal's turn that ended while nobody was at that terminal, as Claw describes it for a card (`remote.end`). Every string is the
|
|
136
|
+
* agent's or its machine's: shown as inert text, never followed.
|
|
137
|
+
*/
|
|
138
|
+
export interface TerminalEnd {
|
|
139
|
+
readonly itemSeq: number;
|
|
140
|
+
readonly name: string;
|
|
141
|
+
readonly folder: string;
|
|
142
|
+
/** Why it stopped ("" for a turn that finished). */
|
|
143
|
+
readonly error: string;
|
|
144
|
+
readonly summary: string;
|
|
145
|
+
readonly full: string;
|
|
146
|
+
readonly more: boolean;
|
|
147
|
+
/** `/agent attach <ref>` for the conversation, as Claw wrote it ("" when its connector does not list it). */
|
|
148
|
+
readonly attach: string;
|
|
149
|
+
/**
|
|
150
|
+
* Earlier turns folded into this end that asked the person something or failed, said before `summary` (the latest turn's): that
|
|
151
|
+
* turn's words ("" when Claw no longer has them) and how many did. Empty when none did.
|
|
152
|
+
*/
|
|
153
|
+
readonly earlier: readonly TerminalEarlier[];
|
|
154
|
+
}
|
|
155
|
+
export interface TerminalEarlier {
|
|
156
|
+
readonly kind: "asked" | "failed";
|
|
157
|
+
readonly text: string;
|
|
158
|
+
readonly count: number;
|
|
131
159
|
}
|
|
132
160
|
/** What an `assistant.say` says of an agent session on the person's machine, or undefined for any other message. */
|
|
133
161
|
export declare function remoteNoticeOf(event: Event): RemoteNotice | undefined;
|
|
@@ -45,6 +45,15 @@ export declare const terminalApprovalText: import("./catalog.js").Catalog<{
|
|
|
45
45
|
approvalsTurnedOn: string;
|
|
46
46
|
approvalsTurnedOff: string;
|
|
47
47
|
approvalsUsage: string;
|
|
48
|
+
mutedNone: string;
|
|
49
|
+
mutedHeader: (p: {
|
|
50
|
+
count: string;
|
|
51
|
+
}) => string;
|
|
52
|
+
mutedLine: (p: {
|
|
53
|
+
who: string;
|
|
54
|
+
since: string;
|
|
55
|
+
}) => string;
|
|
56
|
+
mutedUnnamed: string;
|
|
48
57
|
muted: (p: {
|
|
49
58
|
item: string;
|
|
50
59
|
where: string;
|
|
@@ -59,5 +68,34 @@ export declare const terminalApprovalText: import("./catalog.js").Catalog<{
|
|
|
59
68
|
muteNotTerminal: (p: {
|
|
60
69
|
item: string;
|
|
61
70
|
}) => string;
|
|
71
|
+
endDone: string;
|
|
72
|
+
endError: (p: {
|
|
73
|
+
error: string;
|
|
74
|
+
}) => string;
|
|
75
|
+
endIdle: string;
|
|
76
|
+
endFull: string;
|
|
77
|
+
endRest: string;
|
|
78
|
+
endAttach: string;
|
|
79
|
+
endMute: string;
|
|
80
|
+
endEarlierAsked: (p: {
|
|
81
|
+
text: string;
|
|
82
|
+
count: number;
|
|
83
|
+
}) => string;
|
|
84
|
+
endEarlierFailed: (p: {
|
|
85
|
+
text: string;
|
|
86
|
+
count: number;
|
|
87
|
+
}) => string;
|
|
88
|
+
endLatest: (p: {
|
|
89
|
+
text: string;
|
|
90
|
+
}) => string;
|
|
62
91
|
approvalsUnavailable: string;
|
|
92
|
+
summaryEvery: (p: {
|
|
93
|
+
minutes: string;
|
|
94
|
+
}) => string;
|
|
95
|
+
summaryNever: string;
|
|
96
|
+
summarySet: (p: {
|
|
97
|
+
minutes: string;
|
|
98
|
+
}) => string;
|
|
99
|
+
summaryOff: string;
|
|
100
|
+
summaryUsage: string;
|
|
63
101
|
}>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { JsonObject } from "../../json.js";
|
|
2
|
-
import type { RemoteHidden } from "../../protocol.js";
|
|
2
|
+
import type { RemoteHidden, RemoteMutedConversation } from "../../protocol.js";
|
|
3
3
|
import type { ClawCredential } from "../../claw/credential.js";
|
|
4
4
|
import type { SseEvent } from "../../claw/model.js";
|
|
5
5
|
import type { RemoteConnector, RemoteEventRow, RemotePairing, RemoteSession, RemoteSetup } from "../../claw/remote.js";
|
|
@@ -55,6 +55,18 @@ export interface ClawRemoteAgentsPort {
|
|
|
55
55
|
* is pushed while muted (`PUT /approvals/mutes`). Answers what Claw stored, and the machine and conversation it names.
|
|
56
56
|
*/
|
|
57
57
|
muteTerminal(key: ClawCredential, item: number, muted: boolean): Promise<TerminalMute>;
|
|
58
|
+
/**
|
|
59
|
+
* The conversations the caller muted, newest first (`GET /approvals/mutes`): each with its machine, its name now, since when and the
|
|
60
|
+
* `#<item>` that unmutes it (null when no item of it is left).
|
|
61
|
+
*/
|
|
62
|
+
mutedTerminals(key: ClawCredential): Promise<RemoteMutedConversation[]>;
|
|
63
|
+
/**
|
|
64
|
+
* How often (minutes; 0 never) a conversation of the caller's that keeps working in a terminal on its own is summed up
|
|
65
|
+
* (`GET /approvals`, `summary_minutes`; an hour unless they set otherwise).
|
|
66
|
+
*/
|
|
67
|
+
summary(key: ClawCredential): Promise<number>;
|
|
68
|
+
/** Set it (`PUT /approvals/summary`: 0, or 15 to 1440); answers what Claw stored. ClawError(400) for anything else. */
|
|
69
|
+
setSummary(key: ClawCredential, minutes: number): Promise<number>;
|
|
58
70
|
createSession(key: ClawCredential, session: NewRemoteSession): Promise<RemoteSession>;
|
|
59
71
|
sessions(key: ClawCredential): Promise<RemoteSession[]>;
|
|
60
72
|
session(key: ClawCredential, sessionId: string): Promise<RemoteSession>;
|
|
@@ -21,6 +21,11 @@ export declare class Deliveries {
|
|
|
21
21
|
* question (its card edited). Undefined when the message goes on as words.
|
|
22
22
|
*/
|
|
23
23
|
private remoteCard;
|
|
24
|
+
/**
|
|
25
|
+
* A turn that ended in a terminal while nobody was at it: its own card (which conversation, what it did, its whole answer on a tap,
|
|
26
|
+
* and buttons that attach the chat to it or mute it); a channel that cannot show the card says Claw's words instead.
|
|
27
|
+
*/
|
|
28
|
+
private sendTerminalEnd;
|
|
24
29
|
/**
|
|
25
30
|
* What the assistant said, then, when its turn was refused something for want of a confirmed identity (`needs_identity`) and
|
|
26
31
|
* this is the person's own chat (a group binding's key has `#`), the card that confirms it. A card that could not be sent never
|
|
@@ -199,6 +199,46 @@ export interface AssistantRemoteNotice {
|
|
|
199
199
|
seat_id: string;
|
|
200
200
|
alias: string | null;
|
|
201
201
|
};
|
|
202
|
+
/**
|
|
203
|
+
* With `kind` `done` or `error`, a turn of a conversation open in a terminal that ended while nobody was at that terminal: what a
|
|
204
|
+
* channel draws its own card from (the text says the same for a channel that does not).
|
|
205
|
+
*/
|
|
206
|
+
end?: AssistantTerminalEnd;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* A turn of a conversation open in a terminal that ended while nobody was at it, as a channel's card shows it. Plain one-line text but
|
|
210
|
+
* `summary` (up to three lines) and `full`; what the agent wrote (`summary`, `full`) is its own words, never instructions.
|
|
211
|
+
*/
|
|
212
|
+
export interface AssistantTerminalEnd {
|
|
213
|
+
/** The work item the conversation is filed under (`#N`), which `/approvals mute #N` names. */
|
|
214
|
+
item_seq: number;
|
|
215
|
+
/** The conversation's own name (its connector's list), else its title, else the tool's name. */
|
|
216
|
+
name: string;
|
|
217
|
+
/** The last two parts of its folder ("" none). */
|
|
218
|
+
folder: string;
|
|
219
|
+
/** Why a turn that failed did (Claude Code's `StopFailure` reason, such as `rate_limit`); absent for one that finished. */
|
|
220
|
+
error?: string;
|
|
221
|
+
/** What it did, from the start of its last answer (or the block that sums it up): whole sentences, at most a few lines. */
|
|
222
|
+
summary: string;
|
|
223
|
+
/** The end of its last answer as its connector posted it (at most 2000 characters, "…" first when cut), for "show all". */
|
|
224
|
+
full: string;
|
|
225
|
+
/** Whether `summary` left something of the answer out. */
|
|
226
|
+
more: boolean;
|
|
227
|
+
/** The command that attaches the chat to this conversation (`/agent attach <ref>`), when its connector lists it. */
|
|
228
|
+
attach?: string;
|
|
229
|
+
/**
|
|
230
|
+
* Earlier turns folded into this end that the person must hear of, said before `summary` (which is the latest turn's): the latest
|
|
231
|
+
* that asked them something, and the latest that failed, each with how many did. `text` is that turn's words in whole sentences
|
|
232
|
+
* (untrusted), "" when its connector no longer carries them (the terminal has them). Absent when no earlier turn asked or failed.
|
|
233
|
+
*/
|
|
234
|
+
earlier?: AssistantTerminalEarlier[];
|
|
235
|
+
}
|
|
236
|
+
/** An earlier turn folded into a terminal's end that asked the person something (`asked`) or failed (`failed`). */
|
|
237
|
+
export interface AssistantTerminalEarlier {
|
|
238
|
+
kind: "asked" | "failed";
|
|
239
|
+
text: string;
|
|
240
|
+
/** How many earlier turns of the run did (at least 1). */
|
|
241
|
+
count: number;
|
|
202
242
|
}
|
|
203
243
|
/** A permission request a development environment's agent waits on (`permissionRequest`), as its connector posted it. */
|
|
204
244
|
export interface AssistantRemoteAsk {
|
|
@@ -89,7 +89,13 @@ export declare const PERMISSION_PARK_MAX_MS: number;
|
|
|
89
89
|
* away_ms}`. `message` is the end of what the agent last said (untrusted text); `error` names why a turn that failed did
|
|
90
90
|
* (Claude Code's `StopFailure` reason, such as `rate_limit`). The connector posts it only once the terminal has had no input for a
|
|
91
91
|
* minute after the turn ended, and never while a chat follows the conversation; Claw tells the owner, unless they turned the
|
|
92
|
-
* terminal pushes off or muted that conversation.
|
|
92
|
+
* terminal pushes off or muted that conversation. From connector 0.3.4 it also says who started the turn, as Claude Code's transcript
|
|
93
|
+
* records it (`origin`: "person" or "automation"; absent when that is not known), and an end that stands for a run of turns nobody
|
|
94
|
+
* typed carries `turns` (how many), `earlier` (the earlier ones' last words, oldest first, at most five), `since` (ISO time of the
|
|
95
|
+
* first), `failed_earlier` and `asked_earlier` (how many of the earlier ones failed, or asked the person something, when any did),
|
|
96
|
+
* and `earlier_failed` (the positions in `earlier` of the words of turns that failed, when any are carried). Claw pushes at once only
|
|
97
|
+
* a person's turn, one that asks the person something, or one that failed (in any turn of the run: the push then leads with that
|
|
98
|
+
* earlier question or failure); it sums up the others.
|
|
93
99
|
*/
|
|
94
100
|
export declare const REMOTE_EVENT_TERMINAL_TURN_END = "terminal_turn_end";
|
|
95
101
|
/**
|
|
@@ -295,11 +301,49 @@ export declare function parseTerminalSessionOpen(body: unknown): Parsed<RemoteTe
|
|
|
295
301
|
export declare function parseApprovalsSetting(body: unknown): Parsed<{
|
|
296
302
|
enabled: boolean;
|
|
297
303
|
}>;
|
|
304
|
+
/**
|
|
305
|
+
* Whether what the agent last said asks the person something or waits for their decision: its last paragraph ends in a question, or
|
|
306
|
+
* says in so many words that it waits for them (a choice, an approval, a confirmation), in Chinese or English. Deterministic and narrow
|
|
307
|
+
* on purpose: only the end of the answer is read (where an answer that needs the person says so); a question quoted earlier in a report
|
|
308
|
+
* does not count. Shared: the connector counts the questions of the ends it folds into one, and Claw decides what to push with it.
|
|
309
|
+
*/
|
|
310
|
+
export declare function turnAsksPerson(message: string): boolean;
|
|
311
|
+
/**
|
|
312
|
+
* The summary of a conversation open in a terminal that keeps working on its own (turns another session or a schedule started):
|
|
313
|
+
* at most one every `minutes` per conversation, of what it did since the last one. `0` turns the summaries off. Each owner sets theirs
|
|
314
|
+
* (`PUT /v1/remote-agents/approvals/summary`, `/approvals summary <minutes>|off`); no setting: every hour.
|
|
315
|
+
*/
|
|
316
|
+
export declare const TERMINAL_SUMMARY: {
|
|
317
|
+
readonly defaultMinutes: 60;
|
|
318
|
+
readonly minMinutes: 15;
|
|
319
|
+
readonly maxMinutes: number;
|
|
320
|
+
};
|
|
321
|
+
/** `PUT /v1/remote-agents/approvals/summary`: how often (minutes) such a summary may come, or 0 for never. */
|
|
322
|
+
export declare function parseTerminalSummarySetting(body: unknown): Parsed<{
|
|
323
|
+
minutes: number;
|
|
324
|
+
}>;
|
|
298
325
|
/** `PUT /v1/remote-agents/approvals/mutes`: mute (or unmute) the conversation behind work item `#item`, one open in a terminal. */
|
|
299
326
|
export declare function parseTerminalMute(body: unknown): Parsed<{
|
|
300
327
|
item: number;
|
|
301
328
|
muted: boolean;
|
|
302
329
|
}>;
|
|
330
|
+
/**
|
|
331
|
+
* One conversation open in a terminal whose pushes its owner muted, as `GET /v1/remote-agents/approvals/mutes` lists them (newest
|
|
332
|
+
* mute first; `/approvals` says them).
|
|
333
|
+
*/
|
|
334
|
+
export interface RemoteMutedConversation {
|
|
335
|
+
/**
|
|
336
|
+
* The owner's latest work item of the conversation: the `#<item>` `/approvals unmute` and `PUT /v1/remote-agents/approvals/mutes`
|
|
337
|
+
* name it by. Null when no item of it is left to name it by.
|
|
338
|
+
*/
|
|
339
|
+
item: number | null;
|
|
340
|
+
/** Its machine's name; null when that machine is gone. */
|
|
341
|
+
machine: string | null;
|
|
342
|
+
/** The conversation's name now, as its machine lists it, else the title its item had when it was muted; null: it has none. */
|
|
343
|
+
title: string | null;
|
|
344
|
+
/** When it was muted (ISO 8601). */
|
|
345
|
+
muted_since: string;
|
|
346
|
+
}
|
|
303
347
|
/**
|
|
304
348
|
* Hiding conversations of a machine from its owner's lists (`POST /v1/remote-agents/connectors/:cid/hidden`), and the
|
|
305
349
|
* listing that leaves them out (`GET /v1/remote-agents/connectors`, `?hidden=include` to list them too). Nothing on the
|
|
@@ -3,7 +3,12 @@ import type { CommandHandler, CommandRoute } from "../ports/routing.js";
|
|
|
3
3
|
export declare class TerminalApprovalsCommand implements CommandHandler {
|
|
4
4
|
private readonly claw;
|
|
5
5
|
readonly name = "approvals";
|
|
6
|
-
constructor(claw: Pick<ClawRemoteAgentsPort, "approvals" | "setApprovals" | "muteTerminal">);
|
|
6
|
+
constructor(claw: Pick<ClawRemoteAgentsPort, "approvals" | "setApprovals" | "muteTerminal" | "mutedTerminals" | "summary" | "setSummary">);
|
|
7
7
|
run(route: CommandRoute, args: string): Promise<boolean>;
|
|
8
|
+
/** The whole state, as one message: the switch, how often a conversation that works on its own is summed up, the muted ones. */
|
|
9
|
+
private state;
|
|
10
|
+
private summary;
|
|
11
|
+
/** What to say when Claw refused or could not be reached; anything else is not this command's to answer. */
|
|
12
|
+
private refusal;
|
|
8
13
|
private mute;
|
|
9
14
|
}
|
|
@@ -9,6 +9,7 @@ import type { DecidedView, PermissionView, RemoteAskView } from "./permission-vi
|
|
|
9
9
|
import type { SessionsView } from "./sessions-view.js";
|
|
10
10
|
import type { StatusView } from "./status-view.js";
|
|
11
11
|
import type { TerminalAskView } from "./terminal-ask-view.js";
|
|
12
|
+
import type { TerminalEndView } from "./terminal-end-view.js";
|
|
12
13
|
import type { HiddenView } from "./hidden-view.js";
|
|
13
14
|
import type { WindowCardView } from "./window-view.js";
|
|
14
15
|
export * from "./agents-view.js";
|
|
@@ -20,6 +21,7 @@ export * from "./permission-view.js";
|
|
|
20
21
|
export * from "./sessions-view.js";
|
|
21
22
|
export * from "./status-view.js";
|
|
22
23
|
export * from "./terminal-ask-view.js";
|
|
24
|
+
export * from "./terminal-end-view.js";
|
|
23
25
|
export * from "./window-view.js";
|
|
24
26
|
export { remoteHealthText, remoteOffText, remoteQueuedText, remoteStopText, remoteText } from "../locales/remote.js";
|
|
25
27
|
export { remoteWindowCardText } from "../locales/remote-window-card.js";
|
|
@@ -31,6 +33,7 @@ declare module "../ports/surface.js" {
|
|
|
31
33
|
remotePermission: PermissionView;
|
|
32
34
|
remoteAsk: RemoteAskView;
|
|
33
35
|
terminalAsk: TerminalAskView;
|
|
36
|
+
terminalEnd: TerminalEndView;
|
|
34
37
|
remoteDecided: DecidedView;
|
|
35
38
|
remoteDisconnect: DisconnectView;
|
|
36
39
|
remoteTakeover: TakeoverView;
|
|
@@ -74,5 +74,7 @@ export interface TerminalAsk {
|
|
|
74
74
|
export declare function terminalAsksOf(ask: Reported): TerminalAsks | undefined;
|
|
75
75
|
/** Whether `remote.ask` is a question a terminal asks (a connector's approval hooks), not one an agent Claw started asks. */
|
|
76
76
|
export declare function isTerminalAsk(ask: Reported | undefined): boolean;
|
|
77
|
+
/** Text whose markdown (lists, bold) is kept, but no link can be built from it (`](` gets a zero-width space inside). */
|
|
78
|
+
export declare const wordsText: (v: string) => string;
|
|
77
79
|
/** The card of a question a terminal asks. */
|
|
78
80
|
export declare function terminalAskView(input: TerminalAsk, lang?: Lang): TerminalAskView;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The card of a turn that ended in a terminal while nobody was at it (Claw's `remote.end`, `kind` done or error): which conversation,
|
|
3
|
+
* at a glance (its name and its status in the title; the tool, the machine, the folder, that the terminal sat idle and the item number
|
|
4
|
+
* in one small line under it), what the agent did in a few lines, its last answer whole behind "Show all", and buttons that send the
|
|
5
|
+
* commands for it as the person's own message: attach the chat to that conversation (`/agent attach <ref>`, when Claw offers it) and
|
|
6
|
+
* mute it (`/approvals mute #N`). Everything the agent or its machine wrote is inert text.
|
|
7
|
+
*/
|
|
8
|
+
import type { TerminalEnd } from "../assistant/events.js";
|
|
9
|
+
import type { Lang } from "../locales/lang.js";
|
|
10
|
+
/** A button that sends `command` as if the person typed it (Teams: an imBack). */
|
|
11
|
+
export interface CommandButton {
|
|
12
|
+
readonly title: string;
|
|
13
|
+
readonly command: string;
|
|
14
|
+
}
|
|
15
|
+
export interface TerminalEndView {
|
|
16
|
+
readonly lang: Lang;
|
|
17
|
+
/** The conversation's name and its status: "ops 做完了". */
|
|
18
|
+
readonly title: string;
|
|
19
|
+
readonly failed: boolean;
|
|
20
|
+
/** The tool, the machine, the folder, the terminal idle and the item, in one small line. */
|
|
21
|
+
readonly where: string;
|
|
22
|
+
/**
|
|
23
|
+
* Earlier turns folded into this end that asked the person something or failed, one line each, said before `summary` (markup
|
|
24
|
+
* escaped, links broken); empty when none did.
|
|
25
|
+
*/
|
|
26
|
+
readonly earlier: readonly string[];
|
|
27
|
+
/** What it did (markup escaped, links broken), "Latest turn:" first when `earlier` says something; "" when it said nothing. */
|
|
28
|
+
readonly summary: string;
|
|
29
|
+
/** Its last answer whole (markdown kept, links broken), shown on "Show all"; "" when the summary is all of it. */
|
|
30
|
+
readonly full: string;
|
|
31
|
+
readonly fullLabel: string;
|
|
32
|
+
/** "The rest is in the terminal." when something was left out and there is no whole answer to show; else "". */
|
|
33
|
+
readonly rest: string;
|
|
34
|
+
readonly buttons: readonly CommandButton[];
|
|
35
|
+
}
|
|
36
|
+
export interface TerminalEndInput {
|
|
37
|
+
readonly end: TerminalEnd;
|
|
38
|
+
readonly machine: string;
|
|
39
|
+
/** The tool's name as people know it (Claude Code, Codex), or the agent's id. */
|
|
40
|
+
readonly agent: string;
|
|
41
|
+
readonly lang: Lang;
|
|
42
|
+
}
|
|
43
|
+
/** The view of one turn's end, as Claw described it. */
|
|
44
|
+
export declare function terminalEndView(input: TerminalEndInput): TerminalEndView;
|