@primusclaw/personal-agent 0.10.3 → 0.11.0
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 +872 -105
- package/dist/types/assistant/confirm-outcome.d.ts +7 -0
- package/dist/types/assistant/events.d.ts +1 -1
- package/dist/types/assistant/views.d.ts +2 -0
- package/dist/types/claw/model.d.ts +1 -1
- package/dist/types/locales/assistant-actions.d.ts +7 -0
- package/dist/types/locales/assistant-cards.d.ts +1 -0
- package/dist/types/locales/remote-leads.d.ts +2 -0
- package/dist/types/locales/remote.d.ts +5 -0
- package/dist/types/locales/review-onboarding.d.ts +48 -0
- package/dist/types/locales/review-start.d.ts +0 -2
- package/dist/types/ports/store/github.d.ts +58 -2
- package/dist/types/ports/store/policy.d.ts +2 -0
- package/dist/types/protocol/claw-api/assistant-events.d.ts +11 -2
- package/dist/types/protocol/claw-api/reviews.d.ts +5 -1
- package/dist/types/protocol/remote-agents.d.ts +36 -0
- package/dist/types/remote/chats.d.ts +4 -0
- package/dist/types/remote/connector/reasons.d.ts +6 -0
- package/dist/types/remote/events.d.ts +8 -0
- package/dist/types/remote/lines.d.ts +10 -0
- package/dist/types/remote/turns/display.d.ts +5 -0
- package/dist/types/remote/turns/runner.d.ts +15 -0
- package/dist/types/remote/turns/window-turn.d.ts +2 -0
- package/dist/types/review/index.d.ts +1 -0
- package/dist/types/review/refusals.d.ts +5 -3
- package/dist/types/review/service/account.d.ts +5 -0
- package/dist/types/review/service/context.d.ts +12 -0
- package/dist/types/review/service/github-review.d.ts +3 -0
- package/dist/types/review/service/notices.d.ts +7 -0
- package/dist/types/review/service/onboarding.d.ts +85 -0
- package/dist/types/review/service/start.d.ts +9 -13
- package/dist/types/turn/progress/status-message.d.ts +15 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -515,6 +515,7 @@ var MAX_HELD_PER_USER = 100;
|
|
|
515
515
|
var HELD_TTL_SECONDS = 7 * DAY;
|
|
516
516
|
var APPROVAL_TTL_SECONDS = 7 * DAY;
|
|
517
517
|
var ACTING_SESSION_KEEP_SECONDS = 30 * DAY;
|
|
518
|
+
var REVIEW_ONBOARDING_KEEP_SECONDS = 7 * DAY;
|
|
518
519
|
var RECENT_REPOS = 5;
|
|
519
520
|
var PENDING_REPO_TTL_SECONDS = DAY;
|
|
520
521
|
var SESSION_LIST = 5;
|
|
@@ -3129,9 +3130,9 @@ function mentionId(mention) {
|
|
|
3129
3130
|
function keysOfWho(who, mentions) {
|
|
3130
3131
|
const refs = markerIndexes(who).filter((i) => i < mentions.length);
|
|
3131
3132
|
const named2 = refs.map((r) => mentions[r]?.name ?? "");
|
|
3132
|
-
const
|
|
3133
|
+
const names3 = named2.length ? named2 : [withoutMarkers(who)];
|
|
3133
3134
|
const keys2 = new Set(refs.map((r) => `id:${mentionId(mentions[r])}`));
|
|
3134
|
-
for (const n of
|
|
3135
|
+
for (const n of names3) {
|
|
3135
3136
|
if (tokens(n).length) keys2.add(`w:${sortedCp(tokens(withoutParens(n))).join("")}`);
|
|
3136
3137
|
if (flat(n)) keys2.add(`f:${flat(withoutParens(n))}`);
|
|
3137
3138
|
}
|
|
@@ -3994,7 +3995,14 @@ var assistantActionText = defineCatalog({
|
|
|
3994
3995
|
sent: (p) => `Sent to ${p.agent} on ${p.machine}${p.seq ? ` as #${p.seq}` : ""}. I will tell you when it is done or needs your approval.`,
|
|
3995
3996
|
notSent: "OK, not sent.",
|
|
3996
3997
|
sendExpired: "That card has expired; nothing was sent. Ask me again if you want it.",
|
|
3997
|
-
notSentWhy: (p) => `It could not be sent (${p.why})
|
|
3998
|
+
notSentWhy: (p) => `It could not be sent (${p.why}).`,
|
|
3999
|
+
githubMerged: "Merged.",
|
|
4000
|
+
githubQueued: "Put in the merge queue; it merges once its checks pass.",
|
|
4001
|
+
githubApproved: "Approval posted.",
|
|
4002
|
+
githubNotMerged: "OK, not merged.",
|
|
4003
|
+
githubNotApproved: "OK, the approval was not posted.",
|
|
4004
|
+
githubStale: "The pull request got new commits since, so nothing was done. Ask me to review it again.",
|
|
4005
|
+
githubRetry: "PrimusClaw could not try it just now, and it still waits for you. Press it again in a moment."
|
|
3998
4006
|
},
|
|
3999
4007
|
zh: {
|
|
4000
4008
|
...buttons,
|
|
@@ -4016,7 +4024,14 @@ var assistantActionText = defineCatalog({
|
|
|
4016
4024
|
sent: (p) => `\u5DF2\u53D1\u7ED9 ${p.machine} \u4E0A\u7684 ${p.agent}${p.seq ? `\uFF08#${p.seq}\uFF09` : ""}\u3002\u505A\u5B8C\u6216\u9700\u8981\u4F60\u6279\u51C6\u65F6\u6211\u4F1A\u544A\u8BC9\u4F60\u3002`,
|
|
4017
4025
|
notSent: "\u597D\u7684\uFF0C\u6CA1\u6709\u53D1\u9001\u3002",
|
|
4018
4026
|
sendExpired: "\u8FD9\u5F20\u5361\u5DF2\u8FC7\u671F\uFF0C\u4EC0\u4E48\u90FD\u6CA1\u53D1\u3002\u9700\u8981\u7684\u8BDD\u8BF7\u518D\u8DDF\u6211\u8BF4\u4E00\u6B21\u3002",
|
|
4019
|
-
notSentWhy: (p) => `\u6CA1\u80FD\u53D1\u9001\uFF08${p.why}\uFF09\u3002
|
|
4027
|
+
notSentWhy: (p) => `\u6CA1\u80FD\u53D1\u9001\uFF08${p.why}\uFF09\u3002`,
|
|
4028
|
+
githubMerged: "\u5DF2\u5408\u5165\u3002",
|
|
4029
|
+
githubQueued: "\u5DF2\u653E\u8FDB\u5408\u5E76\u961F\u5217\uFF0C\u68C0\u67E5\u901A\u8FC7\u540E\u5408\u5165\u3002",
|
|
4030
|
+
githubApproved: "\u6279\u51C6\u5DF2\u53D1\u51FA\u3002",
|
|
4031
|
+
githubNotMerged: "\u597D\u7684\uFF0C\u6CA1\u6709\u5408\u5165\u3002",
|
|
4032
|
+
githubNotApproved: "\u597D\u7684\uFF0C\u6CA1\u6709\u53D1\u51FA\u6279\u51C6\u3002",
|
|
4033
|
+
githubStale: "\u8FD9\u4E2A PR \u4E4B\u540E\u6709\u4E86\u65B0\u63D0\u4EA4\uFF0C\u6240\u4EE5\u4EC0\u4E48\u90FD\u6CA1\u505A\u3002\u9700\u8981\u7684\u8BDD\u8BA9\u6211\u518D\u5BA1\u4E00\u6B21\u3002",
|
|
4034
|
+
githubRetry: "PrimusClaw \u6682\u65F6\u6CA1\u80FD\u6267\u884C\uFF0C\u5B83\u8FD8\u5728\u7B49\u4F60\u786E\u8BA4\uFF0C\u8BF7\u8FC7\u4E00\u4F1A\u513F\u518D\u6309\u4E00\u6B21\u3002"
|
|
4020
4035
|
}
|
|
4021
4036
|
});
|
|
4022
4037
|
|
|
@@ -4065,6 +4080,7 @@ var assistantCardText = defineCatalog({
|
|
|
4065
4080
|
confirmTitle: "Please confirm",
|
|
4066
4081
|
confirm: "Confirm",
|
|
4067
4082
|
deny: "Don't",
|
|
4083
|
+
denyMerge: "Don't merge",
|
|
4068
4084
|
boardTitle: "Your tasks",
|
|
4069
4085
|
boardWaiting: (p) => `${String(p.n)} waiting for you`,
|
|
4070
4086
|
boardNothing: "Nothing waits for you",
|
|
@@ -4113,6 +4129,7 @@ var assistantCardText = defineCatalog({
|
|
|
4113
4129
|
confirmTitle: "\u9700\u8981\u4F60\u786E\u8BA4",
|
|
4114
4130
|
confirm: "\u786E\u8BA4",
|
|
4115
4131
|
deny: "\u4E0D\u8981",
|
|
4132
|
+
denyMerge: "\u4E0D\u5408",
|
|
4116
4133
|
boardTitle: "\u4F60\u7684\u4E8B\u9879",
|
|
4117
4134
|
boardWaiting: (p) => `${String(p.n)} \u4EF6\u7B49\u4F60\u5904\u7406`,
|
|
4118
4135
|
boardNothing: "\u6CA1\u6709\u7B49\u4F60\u5904\u7406\u7684\u4E8B",
|
|
@@ -5261,6 +5278,31 @@ var isCount = (v) => typeof v === "number" && Number.isSafeInteger(v) && v >= 0;
|
|
|
5261
5278
|
function parseRemoteId(v) {
|
|
5262
5279
|
return typeof v === "string" && UUID_RE.test(v) ? v.toLowerCase() : null;
|
|
5263
5280
|
}
|
|
5281
|
+
var REMOTE_OUTBOX_REPORT_MAX_SESSIONS = 20;
|
|
5282
|
+
var OUTBOX_MAX_MS = 864e5;
|
|
5283
|
+
var OUTBOX_ERROR_RE = /^(?:http_[1-5]\d\d|network|error)$/;
|
|
5284
|
+
function parseOutboxReport(raw) {
|
|
5285
|
+
if (!isObject(raw)) return null;
|
|
5286
|
+
const { pending, oldest_age_ms: oldest, failures, failing_ms: failing, last_error: lastError, sessions } = raw;
|
|
5287
|
+
if (!isCount(pending) || !isCount(oldest) || !isCount(failures) || !isCount(failing)) return null;
|
|
5288
|
+
const out = [];
|
|
5289
|
+
if (Array.isArray(sessions)) {
|
|
5290
|
+
for (const s of sessions.slice(0, REMOTE_OUTBOX_REPORT_MAX_SESSIONS)) {
|
|
5291
|
+
if (!isObject(s)) continue;
|
|
5292
|
+
const sid = parseRemoteId(s.session_id);
|
|
5293
|
+
if (!sid || !isCount(s.pending) || !isCount(s.oldest_age_ms)) continue;
|
|
5294
|
+
out.push({ sessionId: sid, pending: s.pending, oldestAgeMs: Math.min(s.oldest_age_ms, OUTBOX_MAX_MS) });
|
|
5295
|
+
}
|
|
5296
|
+
}
|
|
5297
|
+
return {
|
|
5298
|
+
pending,
|
|
5299
|
+
oldestAgeMs: Math.min(oldest, OUTBOX_MAX_MS),
|
|
5300
|
+
failures,
|
|
5301
|
+
failingMs: Math.min(failing, OUTBOX_MAX_MS),
|
|
5302
|
+
lastError: typeof lastError === "string" && OUTBOX_ERROR_RE.test(lastError) ? lastError : null,
|
|
5303
|
+
sessions: out
|
|
5304
|
+
};
|
|
5305
|
+
}
|
|
5264
5306
|
function parseVersion(v) {
|
|
5265
5307
|
if (v === void 0 || v === null) return { ok: true, value: null };
|
|
5266
5308
|
if (typeof v !== "string" || v.length > 64 || !NAME_RE.test(v)) return fail("invalid_version");
|
|
@@ -5302,7 +5344,7 @@ function parseHeartbeat(body) {
|
|
|
5302
5344
|
if (!isCount(body.cmd_cursor)) return fail("invalid_cmd_cursor");
|
|
5303
5345
|
cmdCursor = body.cmd_cursor;
|
|
5304
5346
|
}
|
|
5305
|
-
return { ok: true, value: { version, agents, cmdCursor } };
|
|
5347
|
+
return { ok: true, value: { version, agents, cmdCursor, outbox: parseOutboxReport(body.outbox) } };
|
|
5306
5348
|
}
|
|
5307
5349
|
function parseEventBatch(body) {
|
|
5308
5350
|
if (!isObject(body)) return fail("body_required");
|
|
@@ -7183,6 +7225,8 @@ var StatusMessage = class {
|
|
|
7183
7225
|
streamOver = false;
|
|
7184
7226
|
/** The turn was cancelled (`close(true)`). */
|
|
7185
7227
|
hard = false;
|
|
7228
|
+
/** The answer is on its way (`finish`): the progress message is the answer's to retire. */
|
|
7229
|
+
finishing = false;
|
|
7186
7230
|
constructor(surface, options) {
|
|
7187
7231
|
this.surface = surface;
|
|
7188
7232
|
this.clock = options.clock;
|
|
@@ -7436,32 +7480,48 @@ ${line2}` : line2));
|
|
|
7436
7480
|
}
|
|
7437
7481
|
/**
|
|
7438
7482
|
* Stop sending progress. A sleeping flusher is cancelled; one that is mid-send finishes that one send, unless the turn
|
|
7439
|
-
* itself was cancelled (`hard`).
|
|
7440
|
-
*
|
|
7483
|
+
* itself was cancelled (`hard`). When the turn is cancelled, what shows it is ended in the background: a stream still open
|
|
7484
|
+
* is closed with INTERRUPTED (the floating status must not spin until the chat's limit), and the progress message is
|
|
7485
|
+
* retired (no answer follows it, so it must not stay in the chat as stale progress).
|
|
7441
7486
|
*/
|
|
7442
7487
|
close(hard = false) {
|
|
7443
7488
|
this.closed = true;
|
|
7444
|
-
this.hard = this.hard || hard;
|
|
7445
7489
|
this.stopPreparingTimer();
|
|
7446
7490
|
if (this.flusher && !this.flusher.done && (hard || !this.sending)) this.flusher.cancel();
|
|
7447
|
-
if (hard)
|
|
7448
|
-
|
|
7491
|
+
if (hard) this.cancelled();
|
|
7492
|
+
}
|
|
7493
|
+
/** The turn was cancelled: nothing more is repeated, and what shows it is ended (the first time only). */
|
|
7494
|
+
cancelled() {
|
|
7495
|
+
const first = !this.hard;
|
|
7496
|
+
this.hard = true;
|
|
7497
|
+
for (const task of [this.again, this.expiry, this.choice]) task?.cancel();
|
|
7498
|
+
if (this.live?.closable && !this.streamOver) {
|
|
7449
7499
|
this.streamOver = true;
|
|
7450
7500
|
const live = this.live;
|
|
7451
7501
|
detach(() => this.interrupt(live));
|
|
7452
7502
|
}
|
|
7503
|
+
if (first && this.posted && !this.finishing) detach(() => this.retireCancelled());
|
|
7453
7504
|
}
|
|
7454
7505
|
async interrupt(stream) {
|
|
7455
7506
|
const closed = await stream.final(plainMessage(turnText.in(this.lang).interrupted));
|
|
7456
7507
|
if (!closed.ok)
|
|
7457
7508
|
this.log.warn("the stream of a cancelled turn could not be closed; the chat closes it at its limit");
|
|
7458
7509
|
}
|
|
7510
|
+
/**
|
|
7511
|
+
* The turn was cancelled with its progress message on screen: no answer follows to replace it, so it is retired here
|
|
7512
|
+
* (deleted, or edited down to INTERRUPTED where the chat will not delete it). Never fails the turn.
|
|
7513
|
+
*/
|
|
7514
|
+
async retireCancelled() {
|
|
7515
|
+
const messageId = await this.messageId();
|
|
7516
|
+
if (messageId) await this.retire(messageId, plainMessage(turnText.in(this.lang).interrupted));
|
|
7517
|
+
}
|
|
7459
7518
|
/**
|
|
7460
7519
|
* The turn is over: the user gets `parts`, in order. With a stream the first part is its final message (in the place
|
|
7461
7520
|
* of the status) and the others follow; without one they are NEW messages, and the progress message is then retired.
|
|
7462
7521
|
* The thumbs (`feedback`) and suggested replies go under the LAST part, and nowhere else.
|
|
7463
7522
|
*/
|
|
7464
7523
|
async finish(parts2, options = {}) {
|
|
7524
|
+
this.finishing = true;
|
|
7465
7525
|
await this.quiesce();
|
|
7466
7526
|
const messages = answerMessages(parts2, options);
|
|
7467
7527
|
if (this.stream && this.stream.open && !this.streamOver) {
|
|
@@ -7527,10 +7587,11 @@ ${line2}` : line2));
|
|
|
7527
7587
|
if (wait > 0) await sleepSeconds(this.clock, wait);
|
|
7528
7588
|
}
|
|
7529
7589
|
/**
|
|
7530
|
-
* The answer is posted below: delete the progress message. The chat may
|
|
7531
|
-
* is then edited down to one line, so it does not sit
|
|
7590
|
+
* The answer is posted below, or none will come (the turn was cancelled): delete the progress message. The chat may
|
|
7591
|
+
* refuse, and a queue cannot delete; the message is then edited down to one line (`line`), so it does not sit in the
|
|
7592
|
+
* chat as stale progress. Never fails the turn.
|
|
7532
7593
|
*/
|
|
7533
|
-
async retire(messageId) {
|
|
7594
|
+
async retire(messageId, line2 = plainMessage(turnEnglish.doneLine)) {
|
|
7534
7595
|
await this.settle();
|
|
7535
7596
|
let removed;
|
|
7536
7597
|
try {
|
|
@@ -7541,9 +7602,8 @@ ${line2}` : line2));
|
|
|
7541
7602
|
}
|
|
7542
7603
|
if (removed) return;
|
|
7543
7604
|
this.log.warn("the progress message was not deleted; leaving it as one line");
|
|
7544
|
-
|
|
7545
|
-
|
|
7546
|
-
this.reassert(messageId, done);
|
|
7605
|
+
await this.update(messageId, line2);
|
|
7606
|
+
this.reassert(messageId, line2);
|
|
7547
7607
|
}
|
|
7548
7608
|
/** Live edits went out, so one may still arrive after `message` replaced the progress message: send it once more. */
|
|
7549
7609
|
reassert(messageId, message) {
|
|
@@ -11212,15 +11272,15 @@ function categoryBlocks(lang, chat, values) {
|
|
|
11212
11272
|
function oneToOneBlock(lang, chat, bot) {
|
|
11213
11273
|
const zh = lang === "zh";
|
|
11214
11274
|
const oneToOne = { ...chat, group: false, understanding: false };
|
|
11215
|
-
const
|
|
11275
|
+
const names3 = [];
|
|
11216
11276
|
const items = CAPABILITIES.filter((c) => c.where === "dm" && (zh ? c.dmZh : c.dmEn) !== "" && shown(c, oneToOne));
|
|
11217
11277
|
for (const c of [...items.filter((c2) => c2.category === "remote"), ...items.filter((c2) => c2.category !== "remote")]) {
|
|
11218
11278
|
const name = zh ? c.dmZh : c.dmEn;
|
|
11219
|
-
if (!
|
|
11279
|
+
if (!names3.includes(name)) names3.push(name);
|
|
11220
11280
|
}
|
|
11221
|
-
if (
|
|
11281
|
+
if (names3.length === 0) return void 0;
|
|
11222
11282
|
const lines = [zh ? "**\u79C1\u804A\u6211\u8FD8\u53EF\u4EE5**" : "**More in a 1:1 chat with me**"];
|
|
11223
|
-
for (const name of
|
|
11283
|
+
for (const name of names3) lines.push(`- ${name}`);
|
|
11224
11284
|
lines.push(
|
|
11225
11285
|
zh ? `\u8FD9\u4E9B\u5728\u548C\u6211\u7684 1:1 \u804A\u5929\u91CC\u7528\uFF1A\u70B9 ${bot} \u7684\u540D\u5B57\uFF0C\u53D1\u8D77\u79C1\u804A\u5C31\u884C\u3002` : `These are in a 1:1 chat with me: select ${bot}'s name and start a chat.`
|
|
11226
11286
|
);
|
|
@@ -12725,13 +12785,13 @@ var AccountCommands = class {
|
|
|
12725
12785
|
const { store, github } = this.ctx.deps;
|
|
12726
12786
|
const prefs = store.prefs.getPrefs(chat.sender.id);
|
|
12727
12787
|
const [on, off] = zh ? ["\u5F00", "\u5173"] : ["on", "off"];
|
|
12728
|
-
const
|
|
12788
|
+
const names3 = LANG_NAMES[chat.lang()];
|
|
12729
12789
|
const how = langHow(prefs.langSet, prefs.lang !== "", zh, chat.conversation.caps.shortName);
|
|
12730
12790
|
const values = {
|
|
12731
12791
|
timezone: prefs.timezone,
|
|
12732
12792
|
quiet: prefs.quietEnabled ? `${prefs.quietStart}-${prefs.quietEnd}` : off,
|
|
12733
12793
|
brief: prefs.briefTriggerId ? on : off,
|
|
12734
|
-
lang:
|
|
12794
|
+
lang: names3[zh ? 0 : 1] + how
|
|
12735
12795
|
};
|
|
12736
12796
|
if (prefs.pausedUntil !== null && store.now() < prefs.pausedUntil) values["pause"] = zh ? "\u6682\u505C\u4E2D" : "paused";
|
|
12737
12797
|
if (key) values["account"] = zh ? "\u5DF2\u8FDE\u63A5" : "connected";
|
|
@@ -16569,9 +16629,35 @@ function skillSaveOutcome(status, out, lang) {
|
|
|
16569
16629
|
if (status === "expired") return t4.expired;
|
|
16570
16630
|
return s.refused({ why: or(result["message"], or(result["error"], status)) });
|
|
16571
16631
|
}
|
|
16632
|
+
function isGithubWrite(kind) {
|
|
16633
|
+
return kind === "github_merge" || kind === "github_review";
|
|
16634
|
+
}
|
|
16635
|
+
function githubWriteOutcome(kind, out, lang) {
|
|
16636
|
+
const t4 = assistantActionText.in(lang);
|
|
16637
|
+
const merge = kind === "github_merge";
|
|
16638
|
+
switch (or(out["status"], "")) {
|
|
16639
|
+
case "merged":
|
|
16640
|
+
return t4.githubMerged;
|
|
16641
|
+
case "queued":
|
|
16642
|
+
return t4.githubQueued;
|
|
16643
|
+
case "submitted":
|
|
16644
|
+
return t4.githubApproved;
|
|
16645
|
+
case "denied":
|
|
16646
|
+
return merge ? t4.githubNotMerged : t4.githubNotApproved;
|
|
16647
|
+
case "stale":
|
|
16648
|
+
return t4.githubStale;
|
|
16649
|
+
case "expired":
|
|
16650
|
+
return t4.expired;
|
|
16651
|
+
case "retry":
|
|
16652
|
+
return t4.githubRetry;
|
|
16653
|
+
default:
|
|
16654
|
+
return t4.notDone({ why: or(out["reason"], or(out["status"], "?")) });
|
|
16655
|
+
}
|
|
16656
|
+
}
|
|
16572
16657
|
function confirmOutcome(kind, out, lang) {
|
|
16573
16658
|
const t4 = assistantActionText.in(lang);
|
|
16574
16659
|
const status = or(out["status"], "");
|
|
16660
|
+
if (isGithubWrite(kind)) return githubWriteOutcome(kind, out, lang);
|
|
16575
16661
|
const create2 = kind === "trigger_create";
|
|
16576
16662
|
if (kind === "devenv_send") return devenvSendOutcome(status, out, lang);
|
|
16577
16663
|
if (kind === "devenv_hide") return devenvHideOutcome(status, out, lang);
|
|
@@ -16712,6 +16798,11 @@ var AssistantActions = class {
|
|
|
16712
16798
|
await this.notAnswered(click, card, error);
|
|
16713
16799
|
return;
|
|
16714
16800
|
}
|
|
16801
|
+
if (isGithubWrite(card.kind) && pyStr(out["status"]) === "retry") {
|
|
16802
|
+
store.assistantButtons.moveConfirmCard(card.cardId, "open");
|
|
16803
|
+
await this.again(click, card, confirmOutcome(card.kind, out, click.lang()));
|
|
16804
|
+
return;
|
|
16805
|
+
}
|
|
16715
16806
|
store.assistantButtons.moveConfirmCard(card.cardId, "done");
|
|
16716
16807
|
await finish(click, confirmOutcome(card.kind, out, click.lang()));
|
|
16717
16808
|
}
|
|
@@ -16752,7 +16843,7 @@ var AssistantActions = class {
|
|
|
16752
16843
|
}
|
|
16753
16844
|
/** Nothing was answered: the card comes back with `note`, and pressing it again can help. */
|
|
16754
16845
|
async again(click, card, note) {
|
|
16755
|
-
const model = { text: note, cardId: card.cardId, allowLabel: card.label, lang: click.lang() };
|
|
16846
|
+
const model = { text: note, cardId: card.cardId, allowLabel: card.label, kind: card.kind, lang: click.lang() };
|
|
16756
16847
|
await click.settle(viewMessage2({ name: "confirmWrite", model }), { fallback: note });
|
|
16757
16848
|
}
|
|
16758
16849
|
};
|
|
@@ -17831,7 +17922,9 @@ var CONFIRM_KINDS = [
|
|
|
17831
17922
|
"devenv_send",
|
|
17832
17923
|
"github_comment",
|
|
17833
17924
|
"devenv_hide",
|
|
17834
|
-
"skill_save"
|
|
17925
|
+
"skill_save",
|
|
17926
|
+
"github_merge",
|
|
17927
|
+
"github_review"
|
|
17835
17928
|
];
|
|
17836
17929
|
var ASSISTANT_SUGGESTED_REPLIES = {
|
|
17837
17930
|
zh: [
|
|
@@ -18127,7 +18220,7 @@ ${text8}`;
|
|
|
18127
18220
|
held.kind,
|
|
18128
18221
|
held.allowLabel
|
|
18129
18222
|
);
|
|
18130
|
-
const model = { text: inCard || held.allowLabel, cardId: cardId2, allowLabel: held.allowLabel, lang };
|
|
18223
|
+
const model = { text: inCard || held.allowLabel, cardId: cardId2, allowLabel: held.allowLabel, kind: held.kind, lang };
|
|
18131
18224
|
return view3({ name: "confirmWrite", model });
|
|
18132
18225
|
}
|
|
18133
18226
|
const confirm = confirmActionOf(event, this.deps.exactCommand);
|
|
@@ -19219,6 +19312,9 @@ ${p.quoted}`,
|
|
|
19219
19312
|
unsolicitedOwn: (p) => `**${p.label}**, on its own:`,
|
|
19220
19313
|
unattendedNote: "Unattended: runs without asking for approval",
|
|
19221
19314
|
noAsk: (p) => `\u26A0\uFE0F This terminal is in ${p.name} mode: what you send from here runs at once, with no approval card.`,
|
|
19315
|
+
dialogAsks: (p) => `\u23F3 The terminal is waiting for your confirmation: ${p.what}`,
|
|
19316
|
+
dialogAsksBare: "\u23F3 The terminal is waiting for your confirmation",
|
|
19317
|
+
rowUnreadable: "\u2139\uFE0F Claude Code's session record for this terminal cannot be read, so the connector recognizes the session only by the name on its input box, and a confirmation on the screen hides it. Exit Claude Code there and reopen this conversation with `claude --resume`: then it is recognized reliably.",
|
|
19222
19318
|
noTextOutput: "Done. There was no text output.",
|
|
19223
19319
|
answerShortened: "\n\n... (shortened: ask the agent to continue, or read the rest on your machine)",
|
|
19224
19320
|
pairBody: (p) => `On the machine you want to connect, open a terminal in the folder the agents may work in and run this one line (it works once, within ${p.minutes} minutes):
|
|
@@ -19400,6 +19496,9 @@ ${p.quoted}`,
|
|
|
19400
19496
|
unsolicitedOwn: (p) => `**${p.label}**\uFF0C\u81EA\u5DF1\u8BF4\u7684\uFF1A`,
|
|
19401
19497
|
unattendedNote: "\u26A0\uFE0F \u65E0\u4EBA\u503C\u5B88\uFF1A\u6267\u884C\u524D\u4E0D\u4F1A\u8BF7\u6C42\u6279\u51C6",
|
|
19402
19498
|
noAsk: (p) => `\u26A0\uFE0F \u8FD9\u4E2A\u7EC8\u7AEF\u662F ${p.name} \u6A21\u5F0F\uFF1A\u624B\u673A\u53D1\u7684\u6307\u4EE4\u4F1A\u76F4\u63A5\u6267\u884C\uFF0C\u4E0D\u4F1A\u518D\u5F39\u5BA1\u6279\u5361\u3002`,
|
|
19499
|
+
dialogAsks: (p) => `\u23F3 \u7EC8\u7AEF\u5728\u7B49\u4F60\u786E\u8BA4\uFF1A${p.what}`,
|
|
19500
|
+
dialogAsksBare: "\u23F3 \u7EC8\u7AEF\u5728\u7B49\u4F60\u786E\u8BA4",
|
|
19501
|
+
rowUnreadable: "\u2139\uFE0F \u8FD9\u4E2A\u7EC8\u7AEF\u91CC Claude Code \u7684\u4F1A\u8BDD\u767B\u8BB0\u8BFB\u4E0D\u51FA\u6765\uFF0C\u8FDE\u63A5\u5668\u53EA\u80FD\u9760\u8F93\u5165\u6846\u4E0A\u7684\u4F1A\u8BDD\u540D\u8BA4\u51FA\u5B83\uFF0C\u7EC8\u7AEF\u5F39\u51FA\u786E\u8BA4\u65F6\u5C31\u8BA4\u4E0D\u51FA\u4E86\u3002\u5728\u7EC8\u7AEF\u91CC\u9000\u51FA Claude Code\uFF0C\u518D\u7528 `claude --resume` \u91CD\u65B0\u6253\u5F00\u8FD9\u6BB5\u4F1A\u8BDD\uFF0C\u4E4B\u540E\u5C31\u80FD\u7A33\u5B9A\u8BC6\u522B\u3002",
|
|
19403
19502
|
noTextOutput: "\u5B8C\u6210\u4E86\uFF0C\u6CA1\u6709\u6587\u5B57\u8F93\u51FA\u3002",
|
|
19404
19503
|
answerShortened: "\n\n\u2026\u2026\uFF08\u5DF2\u622A\u65AD\uFF1A\u8BA9 agent \u63A5\u7740\u8BF4\uFF0C\u6216\u5728\u4F60\u7684\u673A\u5668\u4E0A\u770B\u5176\u4F59\u90E8\u5206\uFF09",
|
|
19405
19504
|
pairBody: (p) => `\u5728\u8981\u8FDE\u63A5\u7684\u673A\u5668\u4E0A\u6253\u5F00\u7EC8\u7AEF\uFF0C\u8FDB\u5165 agent \u53EF\u4EE5\u5DE5\u4F5C\u7684\u76EE\u5F55\uFF0C\u8FD0\u884C\u4E0B\u9762\u8FD9\u4E00\u884C\uFF08${p.minutes} \u5206\u949F\u5185\u6709\u6548\uFF0C\u53EA\u80FD\u7528\u4E00\u6B21\uFF09\uFF1A
|
|
@@ -19443,7 +19542,7 @@ var remoteQueuedText = defineCatalog({
|
|
|
19443
19542
|
en: {
|
|
19444
19543
|
terminalWorking: "Queued",
|
|
19445
19544
|
terminalWaiting: "Needs confirm",
|
|
19446
|
-
terminalDialog: "
|
|
19545
|
+
terminalDialog: "Confirm there",
|
|
19447
19546
|
terminalTyping: "Box in use",
|
|
19448
19547
|
terminalScrolled: "Scrolled back",
|
|
19449
19548
|
other: "Waiting"
|
|
@@ -19451,7 +19550,7 @@ var remoteQueuedText = defineCatalog({
|
|
|
19451
19550
|
zh: {
|
|
19452
19551
|
terminalWorking: "\u5DF2\u6392\u961F",
|
|
19453
19552
|
terminalWaiting: "\u5F85\u786E\u8BA4",
|
|
19454
|
-
terminalDialog: "\u7B49\
|
|
19553
|
+
terminalDialog: "\u7B49\u4F60\u786E\u8BA4",
|
|
19455
19554
|
terminalTyping: "\u8F93\u5165\u6846\u5FD9",
|
|
19456
19555
|
terminalScrolled: "\u56DE\u6EDA\u4E2D",
|
|
19457
19556
|
other: "\u7B49\u7EC8\u7AEF"
|
|
@@ -21802,7 +21901,12 @@ function githubConfirmButtons(confirmationId, review, lang = "zh") {
|
|
|
21802
21901
|
var TYPED_MODE_HINT = "\u6309\u94AE\u70B9\u4E0D\u4E86\u65F6\uFF0C\u76F4\u63A5\u56DE\u590D\u300C\u786E\u8BA4\u5168\u81EA\u52A8\u300D\u6216\u300C\u786E\u8BA4\u9AD8\u98CE\u9669\u518D\u95EE\u6211\u300D\u5373\u53EF\u3002 / If the buttons do not work, reply \u786E\u8BA4\u5168\u81EA\u52A8 or \u786E\u8BA4\u9AD8\u98CE\u9669\u518D\u95EE\u6211.";
|
|
21803
21902
|
var REVIEW_MODES = {
|
|
21804
21903
|
high_risk_confirm: ["\u9AD8\u98CE\u9669\u4EBA\u5DE5\u518D\u786E\u8BA4\u4E00\u6B21\uFF08\u9ED8\u8BA4\uFF09", "A person confirms high-risk changes (default)"],
|
|
21805
|
-
|
|
21904
|
+
// (not "nobody is asked": a repository that asks for a person still holds a merge under it, and since 2026-11-18 a review the person
|
|
21905
|
+
// asks for in the chat merges unasked too)
|
|
21906
|
+
fully_auto: [
|
|
21907
|
+
"\u5168\u81EA\u52A8\u5408\u5165\uFF08\u4ED3\u5E93\u81EA\u8EAB\u8981\u6C42\u7684\u68C0\u67E5\u4ECD\u7136\u751F\u6548\uFF09",
|
|
21908
|
+
"Fully automatic merge (the repository's own requirements still apply)"
|
|
21909
|
+
]
|
|
21806
21910
|
};
|
|
21807
21911
|
|
|
21808
21912
|
// packages/core/src/review/review-turn.ts
|
|
@@ -22463,12 +22567,12 @@ function parseReviewAsk(text8, mentions) {
|
|
|
22463
22567
|
function personKeys(who, mentions) {
|
|
22464
22568
|
const refs = markerIndexes(who).filter((i) => i < mentions.length);
|
|
22465
22569
|
const ids = new Set(refs.map((r) => mentionId(mentions[r])));
|
|
22466
|
-
const
|
|
22570
|
+
const names3 = refs.length ? [normName(refs.map((r) => pyStrip(mentions[r]?.name ?? "")).join(" "))] : [normName(bareName(withoutMarkers(who)))];
|
|
22467
22571
|
const keys2 = /* @__PURE__ */ new Set();
|
|
22468
|
-
for (const n of
|
|
22572
|
+
for (const n of names3) {
|
|
22469
22573
|
for (const v of [n, withoutParens(n)]) if (tokens(v).length) keys2.add(sortedCp(tokens(v)).join(""));
|
|
22470
22574
|
}
|
|
22471
|
-
for (const n of
|
|
22575
|
+
for (const n of names3) for (const v of [n, withoutParens(n)]) if (flat(v)) keys2.add(flat(v));
|
|
22472
22576
|
return { ids, names: keys2 };
|
|
22473
22577
|
}
|
|
22474
22578
|
function otherReviewers(ask3) {
|
|
@@ -22476,8 +22580,8 @@ function otherReviewers(ask3) {
|
|
|
22476
22580
|
const others = [];
|
|
22477
22581
|
for (const who of ask3.again) {
|
|
22478
22582
|
if (!bareName(who)) continue;
|
|
22479
|
-
const { ids, names:
|
|
22480
|
-
const same2 = ids.size && first.ids.size ? ids.size === first.ids.size && [...ids].every((i) => first.ids.has(i)) : [...
|
|
22583
|
+
const { ids, names: names3 } = personKeys(who, ask3.mentions);
|
|
22584
|
+
const same2 = ids.size && first.ids.size ? ids.size === first.ids.size && [...ids].every((i) => first.ids.has(i)) : [...names3].some((n) => first.names.has(n));
|
|
22481
22585
|
if (same2) continue;
|
|
22482
22586
|
const mentioned = markerIndexes(who).filter((i) => i < ask3.mentions.length).map((i) => ask3.mentions[i]?.name ?? "").join(" ");
|
|
22483
22587
|
const shown3 = mentioned || pyStrip(withoutMarkers(who));
|
|
@@ -22603,6 +22707,16 @@ var GithubAccount = class {
|
|
|
22603
22707
|
binding = /* @__PURE__ */ new Map();
|
|
22604
22708
|
/** Teams user -> the confirmation setting chosen while their binding is made. */
|
|
22605
22709
|
modeChosen = /* @__PURE__ */ new Map();
|
|
22710
|
+
/** Told after a person connected GitHub or switched their standing authorization (errors are logged, never thrown). */
|
|
22711
|
+
changed;
|
|
22712
|
+
async tellChanged(userId, change) {
|
|
22713
|
+
if (this.changed === void 0) return;
|
|
22714
|
+
try {
|
|
22715
|
+
await this.changed(userId, change);
|
|
22716
|
+
} catch (err2) {
|
|
22717
|
+
this.deps.logger.warn("what waits on a person's GitHub binding could not be told", { error: errorName(err2) });
|
|
22718
|
+
}
|
|
22719
|
+
}
|
|
22606
22720
|
/** Settles when every device flow started so far has ended (for tests and an orderly stop). */
|
|
22607
22721
|
async idle() {
|
|
22608
22722
|
await Promise.all([...this.binding.values()].map((b3) => b3.done));
|
|
@@ -22746,11 +22860,12 @@ var GithubAccount = class {
|
|
|
22746
22860
|
const written3 = await writeMode(this.deps, sender.id, chosen);
|
|
22747
22861
|
if (short) {
|
|
22748
22862
|
await sayQuietly(this.deps, conversation, accountText2.connectedShort(state.login), "github bind");
|
|
22749
|
-
|
|
22863
|
+
} else {
|
|
22864
|
+
const [zh, en2] = REVIEW_MODES[chosen];
|
|
22865
|
+
const confirmation = written3 === true ? `${en2} / ${zh}` : written3 === NOT_YET ? NOT_YET_TEXT : accountText2.choiceNotSaved;
|
|
22866
|
+
await sayQuietly(this.deps, conversation, accountText2.connected(state.login, confirmation), "github bind");
|
|
22750
22867
|
}
|
|
22751
|
-
|
|
22752
|
-
const confirmation = written3 === true ? `${en2} / ${zh}` : written3 === NOT_YET ? NOT_YET_TEXT : accountText2.choiceNotSaved;
|
|
22753
|
-
await sayQuietly(this.deps, conversation, accountText2.connected(state.login, confirmation), "github bind");
|
|
22868
|
+
await this.tellChanged(sender.id, "bound");
|
|
22754
22869
|
return [true, state.login];
|
|
22755
22870
|
}
|
|
22756
22871
|
/** A click on one of the two confirmation settings: the clicker's own binding is the only one changed. */
|
|
@@ -22894,6 +23009,7 @@ ${readsLine(connection, known)}` : "";
|
|
|
22894
23009
|
return set.error;
|
|
22895
23010
|
}
|
|
22896
23011
|
await say2(this.deps, conversation, set.value.delegation ? accountText2.autoMergeOn : accountText2.autoMergeOff);
|
|
23012
|
+
await this.tellChanged(sender.id, set.value.delegation ? "delegation_on" : "delegation_off");
|
|
22897
23013
|
return void 0;
|
|
22898
23014
|
}
|
|
22899
23015
|
};
|
|
@@ -23323,10 +23439,10 @@ function activeItemsText(data, who) {
|
|
|
23323
23439
|
}
|
|
23324
23440
|
function modelsAllowedText(data) {
|
|
23325
23441
|
const models = Array.isArray(data.models) ? data.models : [];
|
|
23326
|
-
const
|
|
23442
|
+
const names3 = models.flatMap(
|
|
23327
23443
|
(m) => typeof m === "object" && m !== null && typeof m.name === "string" ? [m.name] : []
|
|
23328
23444
|
);
|
|
23329
|
-
const listed =
|
|
23445
|
+
const listed = names3.slice(0, MAX_MODELS_LISTED).map((n) => cpHead(n.replace(/[^A-Za-z0-9._:/-]/gu, ""), 100)).join("\u3001");
|
|
23330
23446
|
return `\u6307\u5B9A\u7684\u6A21\u578B\u4E0D\u5728 PrimusClaw \u5141\u8BB8\u7684\u6A21\u578B\u91CC\uFF0C\u6240\u4EE5\u6CA1\u6709\u5F00\u59CB review\u3002${listed ? `\u53EF\u4EE5\u7528\u7684\u6A21\u578B\uFF1A${listed}\u3002` : ""}`;
|
|
23331
23447
|
}
|
|
23332
23448
|
function batchRefusal(err2, who, count5, errors) {
|
|
@@ -23410,13 +23526,19 @@ function modelChosenNote(review, who, asked3) {
|
|
|
23410
23526
|
function mergeLine(reviews, who, merge, auto) {
|
|
23411
23527
|
if (!merge || !reviews.length) return "";
|
|
23412
23528
|
const held = reviews.filter((r) => r.mergeHeld);
|
|
23413
|
-
|
|
23414
|
-
const
|
|
23415
|
-
const
|
|
23416
|
-
const
|
|
23417
|
-
|
|
23418
|
-
|
|
23419
|
-
|
|
23529
|
+
const all = held.length === reviews.length;
|
|
23530
|
+
const names3 = held.map((r) => shortName(r.pull)).join("\u3001");
|
|
23531
|
+
const automatic = auto && !all ? `${who} \u5DF2\u8BBE\u4E3A\u5168\u81EA\u52A8\u5408\u5165\uFF08\u65E0\u9700\u4EBA\u5DE5\u786E\u8BA4\uFF0C\u53EA\u6709\u4ED3\u5E93\u81EA\u5DF1\u8981\u6C42\u786E\u8BA4\u7684\u624D\u4F1A\u95EE TA\uFF09\u3002` : "";
|
|
23532
|
+
const askable = reviews.some((r) => r.item?.mergeByRequester === true);
|
|
23533
|
+
if (!held.length && !auto && !askable) return "";
|
|
23534
|
+
if (reviews.every(selfReview)) {
|
|
23535
|
+
if (all) return `\u5408\u5165\u8981\u7B49 ${who} \u672C\u4EBA\u786E\u8BA4\uFF0CTA \u786E\u8BA4\u4E4B\u524D\u4E0D\u4F1A\u5408\u5165\u3002`;
|
|
23536
|
+
return automatic + (held.length ? `\u5176\u4E2D ${names3} \u7684\u5408\u5165\u8981\u7B49 ${who} \u672C\u4EBA\u786E\u8BA4\u3002` : "");
|
|
23537
|
+
}
|
|
23538
|
+
const confirm = all ? `\uFF08${who} \u9700\u8981\u786E\u8BA4\uFF0CTA \u786E\u8BA4\u4E4B\u524D\u4E0D\u4F1A\u5408\u5165\uFF09` : held.length ? `\uFF08\u5176\u4E2D ${names3} \u7684\u5408\u5165 ${who} \u9700\u8981\u786E\u8BA4\uFF09` : "";
|
|
23539
|
+
const byReviewer = `${who} \u6279\u51C6\u540E\uFF0C\u7528 ${who} \u7684\u8D26\u53F7\u5408\u5165${confirm}\u3002`;
|
|
23540
|
+
const asker = askable ? `${who} \u6CA1\u6709\u5408\u5165\u6743\u9650\u65F6\uFF0C\u4F1A\u5148\u95EE\u4F60\u8981\u4E0D\u8981\u7528\u4F60\u81EA\u5DF1\u7684\u8D26\u53F7\u5408\u5165\u3002` : "";
|
|
23541
|
+
return byReviewer + automatic + asker;
|
|
23420
23542
|
}
|
|
23421
23543
|
|
|
23422
23544
|
// packages/core/src/review/service/confirm.ts
|
|
@@ -24580,8 +24702,6 @@ var reviewStartText = {
|
|
|
24580
24702
|
unsureWho: (bot) => `\u6211\u4E0D\u786E\u5B9A\u4F60\u8BF7\u7684\u662F\u8C01\uFF0C\u6240\u4EE5\u6CA1\u6709\u5F00\u59CB review\u3002\u8BF7\u5199\u51FA reviewer \u7684\u540D\u5B57\uFF0C\u4F8B\u5982 ${howToAsk(bot)}`,
|
|
24581
24703
|
unsureWhoFull: (bot) => `\u6211\u4E0D\u786E\u5B9A\u4F60\u8BF7\u7684\u662F\u8C01\uFF0C\u6240\u4EE5\u6CA1\u6709\u5F00\u59CB review\u3002\u8BF7\u5199\u51FA reviewer \u7684\u5168\u540D\uFF0C\u4F8B\u5982 ${howToAsk(bot)}`,
|
|
24582
24704
|
githubUnknown: (who) => `\u6682\u65F6\u65E0\u6CD5\u786E\u8BA4 ${who} \u7684 GitHub \u7ED1\u5B9A\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5\u3002`,
|
|
24583
|
-
notAuthorized: (who, merge) => `${who} \u8FD8\u6CA1\u6709\u6388\u6743\u6211\u4EE3 TA ${merge ? "review \u5408\u5165" : "review"}\uFF08\u9700\u8981 TA \u5728 1:1 \u91CC\u53D1 \`/github auto-merge on\` \u5F00\u542F\u4E00\u6B21\u957F\u671F\u6388\u6743\uFF09\uFF0C\u6211\u4E0D\u4F1A\u52A8\u7528 TA \u7684 GitHub \u8D26\u53F7\uFF0C\u6240\u4EE5\u6CA1\u6709\u5F00\u59CB review\u3002\u8BF7 ${who} \u6388\u6743\u540E\u518D @ \u6211\u4E00\u6B21\u3002`,
|
|
24584
|
-
reviewerNotLinked: (who, bot) => `${who} \u8FD8\u6CA1\u6709\u5728 ${bot} \u91CC\u8FDE\u63A5\u81EA\u5DF1\u7684 Primus key\uFF081:1 \u91CC\u53D1 \`/link\`\uFF09\uFF0C\u4EE3 TA review \u8981\u7528 TA \u81EA\u5DF1\u7684\u8D26\u53F7\u548C\u6A21\u578B\u989D\u5EA6\uFF0C\u6240\u4EE5\u6CA1\u6709\u5F00\u59CB review\u3002\u8BF7 ${who} \u5148\u8FDE\u63A5\uFF0C\u7136\u540E\u518D @ \u6211\u4E00\u6B21\u3002`,
|
|
24585
24705
|
reviewerNotConnected: (who, bot) => `${who} \u8FD8\u6CA1\u6709\u901A\u8FC7 Primus \u8EAB\u4EFD\u670D\u52A1\u8FDE\u63A5 ${bot}\uFF0C\u6211\u6CA1\u6CD5\u4EE5 TA \u7684\u8EAB\u4EFD\u5F00\u59CB\uFF0C\u6240\u4EE5\u6CA1\u6709\u5F00\u59CB review\u3002\u8BF7 ${who} \u5148\u5728 1:1 \u91CC\u5B8C\u6210\u8FDE\u63A5\uFF0C\u7136\u540E\u518D @ \u6211\u4E00\u6B21\u3002`,
|
|
24586
24706
|
reviewerPlatformDown: (who) => `\u6211\u6682\u65F6\u8054\u7CFB\u4E0D\u4E0A Primus \u5E73\u53F0\uFF0C\u6CA1\u80FD\u786E\u8BA4 ${who} \u7684\u8EAB\u4EFD\uFF0C\u6240\u4EE5\u6CA1\u6709\u5F00\u59CB review\u3002\u8BF7\u7A0D\u540E\u518D @ \u6211\u4E00\u6B21\u3002`,
|
|
24587
24707
|
modelsUnknown: (whose, model) => `\u6682\u65F6\u6CA1\u6CD5\u5411 PrimusClaw \u786E\u8BA4${whose} key \u80FD\u7528\u54EA\u4E9B\u6A21\u578B\uFF0C\u6240\u4EE5\u6CA1\u6709\u7528 ${model} \u5F00\u59CB review\u3002\u8BF7\u7A0D\u540E\u518D\u8BD5\uFF0C\u6216\u4E0D\u6307\u5B9A\u6A21\u578B\u3002`,
|
|
@@ -25013,15 +25133,27 @@ ${how}`;
|
|
|
25013
25133
|
}
|
|
25014
25134
|
/** Sends what `send` says into the person's own chat, at most once a day for this kind; true when they have it. */
|
|
25015
25135
|
async onceADay(person, via, kind, send) {
|
|
25136
|
+
return await this.onceADayOutcome(person, via, kind, send) !== "failed";
|
|
25137
|
+
}
|
|
25138
|
+
/**
|
|
25139
|
+
* As `onceADay`, telling apart sent now ("sent"), held back because a notice of this kind already went to them today
|
|
25140
|
+
* ("earlier": what that one said may not be this), and not sent ("failed").
|
|
25141
|
+
*/
|
|
25142
|
+
async onceADayOutcome(person, via, kind, send) {
|
|
25016
25143
|
const delegation = this.deps.store.reviewDelegation;
|
|
25017
|
-
if (!delegation.claimGithubNotice(person.userId, kind, BIND_NOTICE_SECONDS)) return
|
|
25018
|
-
|
|
25144
|
+
if (!delegation.claimGithubNotice(person.userId, kind, BIND_NOTICE_SECONDS)) return "earlier";
|
|
25145
|
+
if (await this.toPerson(person, via, send)) return "sent";
|
|
25146
|
+
delegation.releaseGithubNotice(person.userId, kind);
|
|
25147
|
+
return "failed";
|
|
25148
|
+
}
|
|
25149
|
+
/** Sends what `send` says into the person's own chat, with no daily limit; true when it went. */
|
|
25150
|
+
async toPerson(person, via, send) {
|
|
25019
25151
|
try {
|
|
25152
|
+
const chat = await personalChat(this.deps, person, via);
|
|
25020
25153
|
if (chat === void 0) throw new Error("no 1:1 chat with this person");
|
|
25021
25154
|
await send(chat);
|
|
25022
25155
|
} catch (err2) {
|
|
25023
25156
|
this.deps.logger.warn("the steps for a person a review needs could not be sent", { error: errorName(err2) });
|
|
25024
|
-
delegation.releaseGithubNotice(person.userId, kind);
|
|
25025
25157
|
return false;
|
|
25026
25158
|
}
|
|
25027
25159
|
return true;
|
|
@@ -25066,6 +25198,500 @@ ${sender.name || "\u6709\u540C\u4E8B"}${group ? "\u5728\u7FA4\u91CC" : ""}\u8BF7
|
|
|
25066
25198
|
}
|
|
25067
25199
|
};
|
|
25068
25200
|
|
|
25201
|
+
// packages/core/src/locales/review-onboarding.ts
|
|
25202
|
+
var ONBOARDING_STEPS = ["identity", "bind", "auto_merge", "link"];
|
|
25203
|
+
var STEP_EN = {
|
|
25204
|
+
identity: "Connect your Primus account: press Confirm on the identity service card I sent you",
|
|
25205
|
+
bind: "Connect GitHub: send me `/github bind` here, enter the code it shows on GitHub and approve (the token is kept only in the Primus identity service)",
|
|
25206
|
+
auto_merge: "Allow reviews as you: send me `/github auto-merge on` here, so that I may use your GitHub account when a colleague asks you for a review (`/github auto-merge off` turns it off at any time)",
|
|
25207
|
+
link: "Link your own PrimusClaw key: send me `/link` here (a review asked of you runs on your own model quota)"
|
|
25208
|
+
};
|
|
25209
|
+
var STEP_ZH = {
|
|
25210
|
+
identity: "\u8FDE\u63A5\u4F60\u7684 Primus \u8D26\u53F7\uFF1A\u70B9\u6211\u53D1\u7ED9\u4F60\u7684\u8EAB\u4EFD\u670D\u52A1\u5361\u7247\u4E0A\u7684\u786E\u8BA4",
|
|
25211
|
+
bind: "\u8FDE\u63A5 GitHub\uFF1A\u5728\u8FD9\u91CC\u53D1 `/github bind`\uFF0C\u6309\u63D0\u793A\u5728 GitHub \u8F93\u5165\u9A8C\u8BC1\u7801\u5E76\u6279\u51C6\uFF08\u4EE4\u724C\u53EA\u5B58\u5728 Primus \u8EAB\u4EFD\u670D\u52A1\uFF09",
|
|
25212
|
+
auto_merge: "\u5F00\u542F\u4EE3\u5BA1\u6388\u6743\uFF1A\u5728\u8FD9\u91CC\u53D1 `/github auto-merge on`\uFF0C\u540C\u4E8B\u8BF7\u4F60\u4EE3\u5BA1\u65F6\u6211\u624D\u80FD\u7528\u4F60\u7684 GitHub \u8D26\u53F7\uFF08\u968F\u65F6\u53EF\u4EE5 `/github auto-merge off` \u5173\u95ED\uFF09",
|
|
25213
|
+
link: "\u8FDE\u63A5\u4F60\u81EA\u5DF1\u7684 PrimusClaw key\uFF1A\u5728\u8FD9\u91CC\u53D1 `/link`\uFF08\u4EE3\u5BA1\u7528\u4F60\u81EA\u5DF1\u7684\u6A21\u578B\u989D\u5EA6\uFF09"
|
|
25214
|
+
};
|
|
25215
|
+
var STEP_SHORT = {
|
|
25216
|
+
identity: "\u8FDE\u63A5 Primus \u8D26\u53F7",
|
|
25217
|
+
bind: "\u53D1 `/github bind` \u8FDE\u63A5 GitHub",
|
|
25218
|
+
auto_merge: "\u53D1 `/github auto-merge on` \u5F00\u542F\u4EE3\u5BA1\u6388\u6743",
|
|
25219
|
+
link: "\u53D1 `/link` \u8FDE\u63A5\u81EA\u5DF1\u7684 PrimusClaw key"
|
|
25220
|
+
};
|
|
25221
|
+
function stepsShown(withLink) {
|
|
25222
|
+
return withLink ? ONBOARDING_STEPS : ONBOARDING_STEPS.slice(0, 3);
|
|
25223
|
+
}
|
|
25224
|
+
function checklist(steps, current, zh) {
|
|
25225
|
+
const at = steps.indexOf(current);
|
|
25226
|
+
return steps.map((step, i) => {
|
|
25227
|
+
const mark = i < at ? zh ? "\uFF08\u5DF2\u5B8C\u6210\uFF09" : " (done)" : i === at ? zh ? " \u2190 \u73B0\u5728\u8FD9\u4E00\u6B65" : " <- this step now" : "";
|
|
25228
|
+
return `${String(i + 1)}. ${(zh ? STEP_ZH : STEP_EN)[step]}${mark}`;
|
|
25229
|
+
}).join("\n");
|
|
25230
|
+
}
|
|
25231
|
+
var onboardingText2 = {
|
|
25232
|
+
/** The reviewer's first message: what was asked of them, and every step with the one to do now marked. */
|
|
25233
|
+
first: (asked3, steps, current) => {
|
|
25234
|
+
const n = String(steps.length);
|
|
25235
|
+
const verbEn = asked3.merge ? "review and merge" : "review";
|
|
25236
|
+
const verbZh = asked3.merge ? "review \u5408\u5165" : "review";
|
|
25237
|
+
return `${asked3.asker || "A colleague"} asked me${asked3.group ? " in a group chat" : ""} to ${verbEn} ${asked3.pulls} as you; I have done nothing yet. To allow it there are ${n} steps, and as each is done I tell you the next:
|
|
25238
|
+
${checklist(steps, current, false)}
|
|
25239
|
+
|
|
25240
|
+
${asked3.asker || "\u6709\u540C\u4E8B"}${asked3.group ? "\u5728\u7FA4\u91CC" : ""}\u8BF7\u6211\u4EE5\u4F60\u7684\u540D\u4E49 ${verbZh} ${asked3.pulls}\uFF0C\u6211\u8FD8\u4EC0\u4E48\u90FD\u6CA1\u6709\u505A\u3002\u5982\u8981\u5141\u8BB8\uFF0C\u9700\u8981\u5B8C\u6210\u4E0B\u9762 ${n} \u6B65\uFF0C\u6BCF\u5B8C\u6210\u4E00\u6B65\u6211\u4F1A\u544A\u8BC9\u4F60\u4E0B\u4E00\u6B65\uFF1A
|
|
25241
|
+
${checklist(steps, current, true)}`;
|
|
25242
|
+
},
|
|
25243
|
+
/** A step (or more) was done: the next one, with every step marked. */
|
|
25244
|
+
next: (askers, steps, current) => {
|
|
25245
|
+
const at = String(steps.indexOf(current) + 1);
|
|
25246
|
+
return `Done so far, thank you. Next is step ${at} of ${String(steps.length)}, so that ${askers || "your colleague"} can have me review as you:
|
|
25247
|
+
${checklist(steps, current, false)}
|
|
25248
|
+
|
|
25249
|
+
\u524D\u9762\u7684\u6B65\u9AA4\u5DF2\u5B8C\u6210\u3002\u4E0B\u4E00\u6B65\u662F\u7B2C ${at} \u6B65\uFF08\u5171 ${String(steps.length)} \u6B65\uFF09\uFF0C\u5B8C\u6210\u540E ${askers || "\u540C\u4E8B"} \u5C31\u80FD\u8BF7\u6211\u4EE5\u4F60\u7684\u540D\u4E49\u4EE3\u5BA1\uFF1A
|
|
25250
|
+
` + checklist(steps, current, true);
|
|
25251
|
+
},
|
|
25252
|
+
/** Every step is done. */
|
|
25253
|
+
allDone: (askers) => `All steps are done. I told ${askers || "your colleague"} that a review can be asked of you now; nothing starts until they ask again.
|
|
25254
|
+
|
|
25255
|
+
\u5168\u90E8\u5B8C\u6210\u3002\u6211\u5DF2\u544A\u8BC9 ${askers || "\u540C\u4E8B"} \u73B0\u5728\u53EF\u4EE5\u8BF7\u4F60\u4EE3\u5BA1\u4E86\uFF1BTA \u91CD\u65B0\u53D1\u8D77\u4E4B\u524D\u4E0D\u4F1A\u5F00\u59CB\u4EFB\u4F55\u4E8B\u3002`,
|
|
25256
|
+
/** The buttons' card under a step. */
|
|
25257
|
+
bindPrompt: "Connect GitHub now? / \u73B0\u5728\u8FDE\u63A5 GitHub\uFF1F",
|
|
25258
|
+
bindButton: "Connect GitHub / \u8FDE\u63A5 GitHub",
|
|
25259
|
+
autoMergePrompt: "Allow reviews as you now? You can turn it off at any time with `/github auto-merge off`. / \u73B0\u5728\u5F00\u542F\u4EE3\u5BA1\u6388\u6743\uFF1F\u968F\u65F6\u53EF\u4EE5\u7528 `/github auto-merge off` \u5173\u95ED\u3002",
|
|
25260
|
+
autoMergeButton: "Allow / \u5F00\u542F\u4EE3\u5BA1\u6388\u6743",
|
|
25261
|
+
declineButton: "Not now / \u6682\u4E0D\u5F00\u542F",
|
|
25262
|
+
binding: "Connecting GitHub: the code follows. / \u6B63\u5728\u8FDE\u63A5 GitHub\uFF0C\u9A8C\u8BC1\u7801\u89C1\u4E0B\u4E00\u6761\u3002",
|
|
25263
|
+
allowed: "Done. / \u5DF2\u5904\u7406\u3002",
|
|
25264
|
+
declined: "Understood: reviews as you stay off, and the colleague is told. / \u597D\u7684\uFF0C\u4E0D\u5F00\u542F\u4EE3\u5BA1\u6388\u6743\uFF0C\u6211\u4F1A\u544A\u8BC9\u540C\u4E8B\u3002",
|
|
25265
|
+
notYours: "This button is for someone else. / \u8FD9\u4E2A\u6309\u94AE\u4E0D\u662F\u7ED9\u4F60\u7684\u3002",
|
|
25266
|
+
inactive: "This button is no longer active. / \u8FD9\u4E2A\u6309\u94AE\u5DF2\u5931\u6548\u3002",
|
|
25267
|
+
oneToOne: "Please do this in your 1:1 chat with me. / \u8BF7\u5728\u548C\u6211\u7684 1:1 \u804A\u5929\u91CC\u64CD\u4F5C\u3002",
|
|
25268
|
+
/** The asker, where they asked: which step the reviewer has left, and what happens next. */
|
|
25269
|
+
missing: (who, steps, current, sent, group) => {
|
|
25270
|
+
const at = steps.indexOf(current) + 1;
|
|
25271
|
+
const all = steps.map((s, i) => `${String(i + 1)}. ${STEP_SHORT[s]}`).join("\uFF1B");
|
|
25272
|
+
const lead = `${who} \u8FD8\u4E0D\u80FD\u88AB\u6211\u4EE3\u5BA1\uFF1A\u8FD8\u5DEE\u7B2C ${String(at)} \u6B65\u300C${STEP_SHORT[current]}\u300D\uFF08\u5171 ${String(steps.length)} \u6B65\uFF1A${all}\uFF09\uFF0C\u6240\u4EE5\u6CA1\u6709\u5F00\u59CB review\u3002`;
|
|
25273
|
+
const here = group ? "\u8FD9\u4E2A\u7FA4\u91CC" : "\u8FD9\u91CC";
|
|
25274
|
+
return sent ? `${lead}\u6211\u5DF2\u79C1\u4FE1 TA \u8FD9\u51E0\u6B65\uFF1BTA \u6BCF\u5B8C\u6210\u4E00\u6B65\u6211\u4F1A\u63D0\u793A\u4E0B\u4E00\u6B65\uFF0C\u5168\u90E8\u5B8C\u6210\u540E\u6211\u4F1A\u5728${here}\u544A\u8BC9\u4F60\uFF0C\u70B9\u4E00\u4E0B\u5C31\u80FD\u6309\u539F\u8BF7\u6C42\u91CD\u65B0\u53D1\u8D77\u3002` : `${lead}\u6211\u6CA1\u80FD\u79C1\u4FE1 ${who}\uFF1B\u8BF7 ${who} \u5728 1:1 \u91CC\u7ED9\u6211\u53D1\u4EFB\u610F\u4E00\u6761\u6D88\u606F\uFF0C\u6211\u4F1A\u544A\u8BC9 TA \u5269\u4E0B\u7684\u6B65\u9AA4\uFF0C\u5168\u90E8\u5B8C\u6210\u540E\u6211\u4F1A\u5728${here}\u544A\u8BC9\u4F60\u3002`;
|
|
25275
|
+
},
|
|
25276
|
+
/** The asker, where they asked, once every step is done. */
|
|
25277
|
+
ready: (who, pulls, merge) => `${who} \u5DF2\u5B8C\u6210\u6388\u6743\uFF0C\u53EF\u4EE5\u5F00\u59CB\u4EE3\u5BA1\u4E86\u3002\u70B9\u4E0B\u9762\u7684\u6309\u94AE\uFF0C\u6309\u539F\u6765\u7684\u8BF7\u6C42\u91CD\u65B0\u53D1\u8D77\uFF08${pulls}\uFF0C${merge ? "review \u5408\u5165" : "\u53EA review"}\uFF09\u3002`,
|
|
25278
|
+
readyTitle: "\u53EF\u4EE5\u5F00\u59CB\u4EE3\u5BA1\u4E86",
|
|
25279
|
+
retryButton: "\u91CD\u65B0\u53D1\u8D77\u4EE3\u5BA1",
|
|
25280
|
+
retried: (pulls) => `\u5DF2\u6309\u539F\u6765\u7684\u8BF7\u6C42\u91CD\u65B0\u53D1\u8D77\uFF1A${pulls}\u3002`,
|
|
25281
|
+
onlyAsker: "\u53EA\u6709\u53D1\u8D77\u8FD9\u6B21\u4EE3\u5BA1\u7684\u4EBA\u53EF\u4EE5\u91CD\u65B0\u53D1\u8D77\u3002",
|
|
25282
|
+
retryGone: "\u8FD9\u4E2A\u6309\u94AE\u5DF2\u5931\u6548\uFF08\u5DF2\u7528\u8FC7\u6216\u5DF2\u8FC7\u671F\uFF09\uFF0C\u9700\u8981\u7684\u8BDD\u8BF7\u518D\u53D1\u4E00\u6B21\u8BF7\u6C42\u3002",
|
|
25283
|
+
/** The asker, where they asked, when the reviewer said no. */
|
|
25284
|
+
refused: (who, pulls) => `${who} \u9009\u62E9\u6682\u4E0D\u5F00\u542F\u4EE3\u5BA1\u6388\u6743\uFF0C\u6240\u4EE5 ${pulls} \u7684\u4EE3\u5BA1\u4E0D\u4F1A\u5F00\u59CB\u3002\u9700\u8981\u7684\u8BDD\u8BF7\u53E6\u8BF7\u4E00\u4F4D reviewer\u3002`
|
|
25285
|
+
};
|
|
25286
|
+
|
|
25287
|
+
// packages/core/src/review/service/onboarding.ts
|
|
25288
|
+
var ONBOARDING_SWEEP_MS = 6e4;
|
|
25289
|
+
var ONBOARDING_CLICK = "review_onboarding";
|
|
25290
|
+
var HANDOFF_REUSE_SECONDS = 23 * 3600;
|
|
25291
|
+
var RANK = { identity: 1, bind: 2, auto_merge: 3, link: 4, ready: 5 };
|
|
25292
|
+
var str6 = (value) => typeof value === "string" ? value : "";
|
|
25293
|
+
function actorOf(value) {
|
|
25294
|
+
const o = typeof value === "object" && value !== null ? value : {};
|
|
25295
|
+
return { userId: str6(o.userId), name: str6(o.name), channelUserId: str6(o.channelUserId) };
|
|
25296
|
+
}
|
|
25297
|
+
function keptOf(row2) {
|
|
25298
|
+
const r = row2.request;
|
|
25299
|
+
const pulls = Array.isArray(r.pulls) ? r.pulls.flatMap((p) => {
|
|
25300
|
+
const o = typeof p === "object" && p !== null ? p : {};
|
|
25301
|
+
const number = Number(o.number);
|
|
25302
|
+
return str6(o.owner) && str6(o.repo) && Number.isInteger(number) && number > 0 ? [pullRef(str6(o.owner), str6(o.repo), number)] : [];
|
|
25303
|
+
}) : [];
|
|
25304
|
+
const asked3 = r.asked;
|
|
25305
|
+
if (!pulls.length || typeof asked3 !== "object" || asked3 === null || Array.isArray(asked3)) return void 0;
|
|
25306
|
+
return {
|
|
25307
|
+
actor: actorOf(r.actor),
|
|
25308
|
+
requester: actorOf(r.requester),
|
|
25309
|
+
pulls,
|
|
25310
|
+
merge: r.merge === true,
|
|
25311
|
+
models: Array.isArray(r.models) ? r.models.filter((m) => typeof m === "string" && m !== "") : [],
|
|
25312
|
+
note: str6(r.note),
|
|
25313
|
+
handoffId: str6(r.handoffId),
|
|
25314
|
+
askedAt: typeof r.askedAt === "number" ? r.askedAt : 0,
|
|
25315
|
+
asked: asked3,
|
|
25316
|
+
group: r.group === true,
|
|
25317
|
+
where: str6(r.where)
|
|
25318
|
+
};
|
|
25319
|
+
}
|
|
25320
|
+
var names2 = (rows) => [...new Set(rows.map((k) => k.requester.name).filter(Boolean))].join("\u3001");
|
|
25321
|
+
var ReviewerOnboarding = class {
|
|
25322
|
+
constructor(deps, notices, random, retry, github) {
|
|
25323
|
+
this.deps = deps;
|
|
25324
|
+
this.notices = notices;
|
|
25325
|
+
this.random = random;
|
|
25326
|
+
this.retry = retry;
|
|
25327
|
+
this.github = github;
|
|
25328
|
+
}
|
|
25329
|
+
deps;
|
|
25330
|
+
notices;
|
|
25331
|
+
random;
|
|
25332
|
+
retry;
|
|
25333
|
+
github;
|
|
25334
|
+
running = /* @__PURE__ */ new Set();
|
|
25335
|
+
/** Settles when the reads started by messages have ended. For tests. */
|
|
25336
|
+
async idle() {
|
|
25337
|
+
while (this.running.size) await Promise.all([...this.running]);
|
|
25338
|
+
}
|
|
25339
|
+
/** The step this person is to do now for a review asked of them, or undefined when it cannot be read just now. */
|
|
25340
|
+
async progress(userId) {
|
|
25341
|
+
let status;
|
|
25342
|
+
try {
|
|
25343
|
+
status = await this.deps.credentials.status(userId);
|
|
25344
|
+
} catch (err2) {
|
|
25345
|
+
this.deps.logger.info("a reviewer's steps could not be read", { error: errorName(err2) });
|
|
25346
|
+
return void 0;
|
|
25347
|
+
}
|
|
25348
|
+
if (!status.ok) return status.error.kind === "not_bound" ? "identity" : void 0;
|
|
25349
|
+
if (!usable(status.value)) return "bind";
|
|
25350
|
+
if (!status.value.delegation) return "auto_merge";
|
|
25351
|
+
return this.linked(userId) ? "ready" : "link";
|
|
25352
|
+
}
|
|
25353
|
+
linked(userId) {
|
|
25354
|
+
return (this.deps.store.links.getKey(userId) ?? "").startsWith("ak-");
|
|
25355
|
+
}
|
|
25356
|
+
/**
|
|
25357
|
+
* A review for someone else did not start because `step` is theirs to do: kept, the steps sent to them (once a day, the
|
|
25358
|
+
* identity card too while the identity service does not know them), and one line where it was asked naming the step.
|
|
25359
|
+
*/
|
|
25360
|
+
async refused(ctx, ask3, actor, pulls, step) {
|
|
25361
|
+
const steps = stepsShown(!this.linked(actor.userId));
|
|
25362
|
+
const asked3 = {
|
|
25363
|
+
asker: ctx.sender.name,
|
|
25364
|
+
group: ctx.group,
|
|
25365
|
+
pulls: pulls.map(shortName).join(", "),
|
|
25366
|
+
merge: ask3.merge
|
|
25367
|
+
};
|
|
25368
|
+
const person = { id: actor.userId, channelUserId: actor.channelUserId, name: actor.name, email: "" };
|
|
25369
|
+
const store = this.deps.store.reviewDelegation;
|
|
25370
|
+
const regressed = this.behind(actor.userId, RANK[step]);
|
|
25371
|
+
const prior = Math.max(0, ...store.openReviewOnboardings(actor.userId).map((o) => o.toldRank));
|
|
25372
|
+
const send = async (chat) => {
|
|
25373
|
+
await say2(this.deps, chat, onboardingText2.first(asked3, steps, step));
|
|
25374
|
+
await this.cardAfterText(chat, person, step);
|
|
25375
|
+
};
|
|
25376
|
+
let sent = prior >= RANK[step];
|
|
25377
|
+
if (!sent) {
|
|
25378
|
+
const outcome = await this.notices.onceADayOutcome(actor, ctx.conversation.ref, "bind", send);
|
|
25379
|
+
sent = outcome === "sent" || outcome === "earlier" && await this.notices.toPerson(actor, ctx.conversation.ref, send);
|
|
25380
|
+
}
|
|
25381
|
+
const request = {
|
|
25382
|
+
actor: { ...actor },
|
|
25383
|
+
requester: { userId: ctx.sender.id, name: ctx.sender.name, channelUserId: ctx.sender.channelUserId },
|
|
25384
|
+
pulls: pulls.map((p) => ({ owner: p.owner, repo: p.repo, number: p.number })),
|
|
25385
|
+
merge: ask3.merge,
|
|
25386
|
+
// (the model the asker named runs the retry too, through the same model checks a new request gets)
|
|
25387
|
+
models: [...ask3.models],
|
|
25388
|
+
note: ctx.text,
|
|
25389
|
+
handoffId: ask3.handoffId,
|
|
25390
|
+
askedAt: epochSeconds(this.deps.clock),
|
|
25391
|
+
asked: ctx.conversation.ref.wire,
|
|
25392
|
+
group: ctx.group,
|
|
25393
|
+
where: ctx.group ? ctx.message.conversationName : ""
|
|
25394
|
+
};
|
|
25395
|
+
store.saveReviewOnboarding({
|
|
25396
|
+
onboardingId: this.random.hexId(),
|
|
25397
|
+
actorId: actor.userId,
|
|
25398
|
+
requesterId: ctx.sender.id,
|
|
25399
|
+
pulls: pulls.map(shortName).join(" "),
|
|
25400
|
+
request,
|
|
25401
|
+
// (not reached: their next message, or the sweep, sends the steps)
|
|
25402
|
+
toldRank: sent ? RANK[step] : prior
|
|
25403
|
+
});
|
|
25404
|
+
if (regressed && sent) store.claimOnboardingStep(actor.userId, RANK[step]);
|
|
25405
|
+
await say2(this.deps, ctx.conversation, onboardingText2.missing(actor.name || "\u5BF9\u65B9", steps, step, sent, ctx.group));
|
|
25406
|
+
}
|
|
25407
|
+
/**
|
|
25408
|
+
* What goes with a step, after its text went: a card that could not be sent is not worth saying the step again for
|
|
25409
|
+
* (the text names what to type), so it is only logged and the step counts as said.
|
|
25410
|
+
*/
|
|
25411
|
+
async cardAfterText(chat, person, step) {
|
|
25412
|
+
try {
|
|
25413
|
+
await this.stepCard(chat, person, step);
|
|
25414
|
+
} catch (err2) {
|
|
25415
|
+
this.deps.logger.warn("the card under a reviewer's step could not be sent", { error: errorName(err2) });
|
|
25416
|
+
}
|
|
25417
|
+
}
|
|
25418
|
+
/** What goes with a step: the identity card, or a button that does the step. */
|
|
25419
|
+
async stepCard(chat, person, step) {
|
|
25420
|
+
if (step === "identity") {
|
|
25421
|
+
await this.deps.host.connectIdentity(person, chat, "");
|
|
25422
|
+
return;
|
|
25423
|
+
}
|
|
25424
|
+
const button = (title, op, style) => ({
|
|
25425
|
+
title,
|
|
25426
|
+
verb: `primusclaw.${ONBOARDING_CLICK}`,
|
|
25427
|
+
data: { primusclaw: ONBOARDING_CLICK, op },
|
|
25428
|
+
...style ? { style } : {}
|
|
25429
|
+
});
|
|
25430
|
+
if (step === "bind")
|
|
25431
|
+
await chat.send(noteMessage({ text: onboardingText2.bindPrompt, buttons: [button(onboardingText2.bindButton, "bind", "positive")] }));
|
|
25432
|
+
else if (step === "auto_merge")
|
|
25433
|
+
await chat.send(
|
|
25434
|
+
noteMessage({
|
|
25435
|
+
text: onboardingText2.autoMergePrompt,
|
|
25436
|
+
buttons: [button(onboardingText2.autoMergeButton, "auto_merge_on", "positive"), button(onboardingText2.declineButton, "decline")]
|
|
25437
|
+
})
|
|
25438
|
+
);
|
|
25439
|
+
}
|
|
25440
|
+
/**
|
|
25441
|
+
* A reviewer who undid a step they had done (`/github unbind`, or an identity service that no longer knows them) is
|
|
25442
|
+
* behind what they were told: each open ask told further than `rank` is put just below it, so the step they are at
|
|
25443
|
+
* now is said again (once, by whoever raises it first). True when any was.
|
|
25444
|
+
*/
|
|
25445
|
+
behind(userId, rank) {
|
|
25446
|
+
const store = this.deps.store.reviewDelegation;
|
|
25447
|
+
let any = false;
|
|
25448
|
+
for (const row2 of store.openReviewOnboardings(userId))
|
|
25449
|
+
if (row2.toldRank > rank) {
|
|
25450
|
+
store.releaseOnboardingStep(row2.onboardingId, row2.toldRank, rank - 1);
|
|
25451
|
+
any = true;
|
|
25452
|
+
}
|
|
25453
|
+
return any;
|
|
25454
|
+
}
|
|
25455
|
+
/** A message of this person's: when something waits for them, their state is read again (in the background). */
|
|
25456
|
+
activity(userId) {
|
|
25457
|
+
if (!this.deps.store.reviewDelegation.openReviewOnboardings(userId).length) return;
|
|
25458
|
+
const task = this.advance(userId).catch((err2) => {
|
|
25459
|
+
this.deps.logger.warn("a reviewer's next step could not be sent", { error: errorName(err2) });
|
|
25460
|
+
});
|
|
25461
|
+
this.running.add(task);
|
|
25462
|
+
void task.finally(() => this.running.delete(task));
|
|
25463
|
+
}
|
|
25464
|
+
/** Every reviewer something waits for, read again; every asker still owed a reviewer's no, told. */
|
|
25465
|
+
async sweep() {
|
|
25466
|
+
try {
|
|
25467
|
+
await this.tellDeclined(this.deps.store.reviewDelegation.declinedReviewOnboardings());
|
|
25468
|
+
} catch (err2) {
|
|
25469
|
+
this.deps.logger.warn("an asker could not be told that the reviewer said no", { error: errorName(err2) });
|
|
25470
|
+
}
|
|
25471
|
+
for (const userId of this.deps.store.reviewDelegation.onboardingReviewers()) {
|
|
25472
|
+
try {
|
|
25473
|
+
await this.advance(userId);
|
|
25474
|
+
} catch (err2) {
|
|
25475
|
+
this.deps.logger.warn("a reviewer's next step could not be sent", { error: errorName(err2) });
|
|
25476
|
+
}
|
|
25477
|
+
}
|
|
25478
|
+
}
|
|
25479
|
+
/**
|
|
25480
|
+
* This person's state, read again: a step further than they were told is answered with the next one (once, whoever
|
|
25481
|
+
* reads it first), and so is a step they undid; all done, each asker is told where they asked. A step that could not
|
|
25482
|
+
* be said is claimed back, so the next read (their next message, or the sweep) says it.
|
|
25483
|
+
*/
|
|
25484
|
+
async advance(userId) {
|
|
25485
|
+
const store = this.deps.store.reviewDelegation;
|
|
25486
|
+
if (!store.openReviewOnboardings(userId).length) return;
|
|
25487
|
+
const now = await this.progress(userId);
|
|
25488
|
+
if (now === void 0) return;
|
|
25489
|
+
const rank = RANK[now];
|
|
25490
|
+
this.behind(userId, rank);
|
|
25491
|
+
const open = store.openReviewOnboardings(userId);
|
|
25492
|
+
if (!open.length) return;
|
|
25493
|
+
if (!store.claimOnboardingStep(userId, rank)) return;
|
|
25494
|
+
const unclaim = (rows) => {
|
|
25495
|
+
for (const row2 of rows)
|
|
25496
|
+
if (row2.toldRank < rank) store.releaseOnboardingStep(row2.onboardingId, rank, row2.toldRank);
|
|
25497
|
+
};
|
|
25498
|
+
if (now === "ready") {
|
|
25499
|
+
const before = new Map(open.map((o) => [o.onboardingId, o.toldRank]));
|
|
25500
|
+
await this.ready(store.openReviewOnboardings(userId), rank, (id) => before.get(id) ?? 0);
|
|
25501
|
+
return;
|
|
25502
|
+
}
|
|
25503
|
+
let said2 = false;
|
|
25504
|
+
try {
|
|
25505
|
+
said2 = await this.tell(userId, open, now);
|
|
25506
|
+
} finally {
|
|
25507
|
+
if (!said2) unclaim(open);
|
|
25508
|
+
}
|
|
25509
|
+
}
|
|
25510
|
+
/** The step `now` said in the reviewer's own chat; false when that chat could not be reached. */
|
|
25511
|
+
async tell(userId, open, now) {
|
|
25512
|
+
const kept = open.flatMap((row2) => keptOf(row2) ?? []);
|
|
25513
|
+
const first = kept[0];
|
|
25514
|
+
if (first === void 0) return false;
|
|
25515
|
+
const chat = await personalChat(this.deps, first.actor, this.via(first));
|
|
25516
|
+
if (chat === void 0) {
|
|
25517
|
+
this.deps.logger.info("a reviewer's next step waits for their chat to be reachable");
|
|
25518
|
+
return false;
|
|
25519
|
+
}
|
|
25520
|
+
const person = { id: userId, channelUserId: first.actor.channelUserId, name: first.actor.name, email: "" };
|
|
25521
|
+
const steps = stepsShown(!this.linked(userId));
|
|
25522
|
+
const text8 = open.every((o) => o.toldRank === 0) ? onboardingText2.first(
|
|
25523
|
+
{ asker: names2(kept), group: first.group, pulls: first.pulls.map(shortName).join(", "), merge: first.merge },
|
|
25524
|
+
steps,
|
|
25525
|
+
now
|
|
25526
|
+
) : onboardingText2.next(names2(kept), steps, now);
|
|
25527
|
+
await say2(this.deps, chat, text8);
|
|
25528
|
+
await this.cardAfterText(chat, person, now);
|
|
25529
|
+
return true;
|
|
25530
|
+
}
|
|
25531
|
+
via(kept) {
|
|
25532
|
+
return this.deps.restoreRef(kept.asked);
|
|
25533
|
+
}
|
|
25534
|
+
/**
|
|
25535
|
+
* Every step is done: each asker, where they asked, hears it with the button that asks again, and only then is the
|
|
25536
|
+
* request marked told; one that could not be told is claimed back (from `rank`) and told on the next read. The
|
|
25537
|
+
* reviewer hears it too.
|
|
25538
|
+
*/
|
|
25539
|
+
async ready(open, rank, toldBefore) {
|
|
25540
|
+
const store = this.deps.store.reviewDelegation;
|
|
25541
|
+
const told = [];
|
|
25542
|
+
for (const row2 of open) {
|
|
25543
|
+
const kept = keptOf(row2);
|
|
25544
|
+
const where = kept === void 0 ? void 0 : stored(this.deps, kept.asked);
|
|
25545
|
+
if (kept === void 0 || where === void 0) {
|
|
25546
|
+
store.finishReviewOnboarding(row2.onboardingId);
|
|
25547
|
+
continue;
|
|
25548
|
+
}
|
|
25549
|
+
const pulls = kept.pulls.map(shortName).join(", ");
|
|
25550
|
+
const text8 = onboardingText2.ready(kept.actor.name || "\u5BF9\u65B9", pulls, kept.merge);
|
|
25551
|
+
const retry = {
|
|
25552
|
+
title: onboardingText2.retryButton,
|
|
25553
|
+
verb: `primusclaw.${ONBOARDING_CLICK}`,
|
|
25554
|
+
data: { primusclaw: ONBOARDING_CLICK, op: "retry", id: row2.onboardingId },
|
|
25555
|
+
style: "positive"
|
|
25556
|
+
};
|
|
25557
|
+
try {
|
|
25558
|
+
await where.send(
|
|
25559
|
+
noteMessage({ text: this.deps.mask(text8), title: onboardingText2.readyTitle, tone: "good", buttons: [retry] })
|
|
25560
|
+
);
|
|
25561
|
+
} catch (err2) {
|
|
25562
|
+
this.deps.logger.warn("the asker could not be told that the reviewer is ready", { error: errorName(err2) });
|
|
25563
|
+
store.releaseOnboardingStep(row2.onboardingId, rank, toldBefore(row2.onboardingId));
|
|
25564
|
+
continue;
|
|
25565
|
+
}
|
|
25566
|
+
if (store.finishReviewOnboarding(row2.onboardingId)) told.push(kept);
|
|
25567
|
+
}
|
|
25568
|
+
const first = told[0];
|
|
25569
|
+
if (first === void 0) return;
|
|
25570
|
+
try {
|
|
25571
|
+
const chat = await personalChat(this.deps, first.actor, this.via(first));
|
|
25572
|
+
if (chat !== void 0) await say2(this.deps, chat, onboardingText2.allDone(names2(told)));
|
|
25573
|
+
} catch (err2) {
|
|
25574
|
+
this.deps.logger.warn("the reviewer could not be told that every step is done", { error: errorName(err2) });
|
|
25575
|
+
}
|
|
25576
|
+
}
|
|
25577
|
+
/**
|
|
25578
|
+
* The reviewer turned their standing authorization off, or said not now: each asker waiting on them is told, once. Each
|
|
25579
|
+
* is marked declined first (nothing waits for the reviewer any more), and stays owed to its asker until the telling
|
|
25580
|
+
* went, so a send that fails is tried again by the sweep.
|
|
25581
|
+
*/
|
|
25582
|
+
async declined(userId) {
|
|
25583
|
+
const store = this.deps.store.reviewDelegation;
|
|
25584
|
+
for (const row2 of store.openReviewOnboardings(userId)) store.declineReviewOnboarding(row2.onboardingId);
|
|
25585
|
+
await this.tellDeclined(store.declinedReviewOnboardings(userId));
|
|
25586
|
+
}
|
|
25587
|
+
/** Each asker owed a reviewer's no is told it where they asked (once, whoever takes it first); then it is dropped. */
|
|
25588
|
+
async tellDeclined(rows) {
|
|
25589
|
+
const store = this.deps.store.reviewDelegation;
|
|
25590
|
+
for (const row2 of rows) {
|
|
25591
|
+
if (!store.claimDeclinedOnboarding(row2.onboardingId)) continue;
|
|
25592
|
+
const kept = keptOf(row2);
|
|
25593
|
+
const where = kept === void 0 ? void 0 : stored(this.deps, kept.asked);
|
|
25594
|
+
if (kept === void 0 || where === void 0) {
|
|
25595
|
+
store.dropReviewOnboarding(row2.onboardingId);
|
|
25596
|
+
continue;
|
|
25597
|
+
}
|
|
25598
|
+
try {
|
|
25599
|
+
await say2(this.deps, where, onboardingText2.refused(kept.actor.name || "\u5BF9\u65B9", kept.pulls.map(shortName).join(", ")));
|
|
25600
|
+
} catch (err2) {
|
|
25601
|
+
this.deps.logger.warn("the asker could not be told that the reviewer said no", { error: errorName(err2) });
|
|
25602
|
+
store.releaseDeclinedOnboarding(row2.onboardingId);
|
|
25603
|
+
continue;
|
|
25604
|
+
}
|
|
25605
|
+
store.dropReviewOnboarding(row2.onboardingId);
|
|
25606
|
+
}
|
|
25607
|
+
}
|
|
25608
|
+
/** A press of one of the buttons this sent. */
|
|
25609
|
+
async click(click) {
|
|
25610
|
+
const data = click.action.data;
|
|
25611
|
+
const op = data.op;
|
|
25612
|
+
if (op === "retry") {
|
|
25613
|
+
await this.retryClick(click, str6(data.id));
|
|
25614
|
+
return;
|
|
25615
|
+
}
|
|
25616
|
+
if (op !== "bind" && op !== "auto_merge_on" && op !== "decline") {
|
|
25617
|
+
await click.settle(onboardingText2.inactive);
|
|
25618
|
+
return;
|
|
25619
|
+
}
|
|
25620
|
+
if (click.conversation.ref.kind !== "personal") {
|
|
25621
|
+
await click.settle(onboardingText2.oneToOne);
|
|
25622
|
+
return;
|
|
25623
|
+
}
|
|
25624
|
+
if (op === "decline") {
|
|
25625
|
+
await click.settle(onboardingText2.declined);
|
|
25626
|
+
await this.declined(click.sender.id);
|
|
25627
|
+
return;
|
|
25628
|
+
}
|
|
25629
|
+
await click.settle(op === "bind" ? onboardingText2.binding : onboardingText2.allowed);
|
|
25630
|
+
await this.github(click.sender, op === "bind" ? "bind" : "auto-merge on", click.conversation);
|
|
25631
|
+
}
|
|
25632
|
+
/** The asker's press of "ask again": the same request, started again through every check, once. */
|
|
25633
|
+
async retryClick(click, id) {
|
|
25634
|
+
const store = this.deps.store.reviewDelegation;
|
|
25635
|
+
const row2 = id ? store.getReviewOnboarding(id) : null;
|
|
25636
|
+
const kept = row2 === null || !row2.done || row2.declined ? void 0 : keptOf(row2);
|
|
25637
|
+
if (row2 === null || kept === void 0) {
|
|
25638
|
+
await click.settle(onboardingText2.retryGone);
|
|
25639
|
+
return;
|
|
25640
|
+
}
|
|
25641
|
+
if (click.sender.id !== row2.requesterId) {
|
|
25642
|
+
const retry = {
|
|
25643
|
+
title: onboardingText2.retryButton,
|
|
25644
|
+
verb: `primusclaw.${ONBOARDING_CLICK}`,
|
|
25645
|
+
data: { primusclaw: ONBOARDING_CLICK, op: "retry", id }
|
|
25646
|
+
};
|
|
25647
|
+
await click.settle(noteMessage({ text: onboardingText2.onlyAsker, title: onboardingText2.readyTitle, buttons: [retry] }), {
|
|
25648
|
+
fallback: onboardingText2.onlyAsker
|
|
25649
|
+
});
|
|
25650
|
+
return;
|
|
25651
|
+
}
|
|
25652
|
+
store.dropReviewOnboarding(row2.onboardingId);
|
|
25653
|
+
const pulls = kept.pulls.map(shortName).join(", ");
|
|
25654
|
+
await click.settle(onboardingText2.retried(pulls));
|
|
25655
|
+
const fresh = epochSeconds(this.deps.clock) - kept.askedAt < HANDOFF_REUSE_SECONDS;
|
|
25656
|
+
const ask3 = reviewAsk({
|
|
25657
|
+
who: kept.actor.name,
|
|
25658
|
+
pulls: kept.pulls,
|
|
25659
|
+
merge: kept.merge,
|
|
25660
|
+
models: kept.models,
|
|
25661
|
+
named: [kept.actor.channelUserId],
|
|
25662
|
+
handoffId: fresh ? kept.handoffId : ""
|
|
25663
|
+
});
|
|
25664
|
+
const message = {
|
|
25665
|
+
type: "message",
|
|
25666
|
+
id: `${click.action.id || row2.onboardingId}-retry`,
|
|
25667
|
+
sender: click.sender,
|
|
25668
|
+
conversation: click.conversation.ref,
|
|
25669
|
+
locale: click.action.locale,
|
|
25670
|
+
clientPlatform: click.action.clientPlatform,
|
|
25671
|
+
text: kept.note,
|
|
25672
|
+
mentioned: true,
|
|
25673
|
+
targeted: false,
|
|
25674
|
+
namesBotFirst: false,
|
|
25675
|
+
conversationName: kept.where,
|
|
25676
|
+
mentions: [],
|
|
25677
|
+
links: [],
|
|
25678
|
+
quotes: [],
|
|
25679
|
+
files: [],
|
|
25680
|
+
unreadableFiles: [],
|
|
25681
|
+
provenance: "typed"
|
|
25682
|
+
};
|
|
25683
|
+
const ctx = {
|
|
25684
|
+
message,
|
|
25685
|
+
sender: click.sender,
|
|
25686
|
+
conversation: click.conversation,
|
|
25687
|
+
scope: click.scope,
|
|
25688
|
+
text: kept.note,
|
|
25689
|
+
group: click.conversation.ref.kind !== "personal"
|
|
25690
|
+
};
|
|
25691
|
+
await this.retry(ctx, ask3, kept.actor);
|
|
25692
|
+
}
|
|
25693
|
+
};
|
|
25694
|
+
|
|
25069
25695
|
// packages/core/src/review/intent-check.ts
|
|
25070
25696
|
var BARE_NUMBER = pyFullmatch(String.raw`#?\s*\d{1,7}`);
|
|
25071
25697
|
var INTENTS = ["review_merge", "review", "none"];
|
|
@@ -25471,17 +26097,19 @@ async function withTimeout(deps, promise, ms) {
|
|
|
25471
26097
|
// packages/core/src/review/service/start.ts
|
|
25472
26098
|
var asked2 = (ctx) => ctx.conversation.ref;
|
|
25473
26099
|
var ReviewChecks = class {
|
|
25474
|
-
constructor(deps, reviewers, items, notices, launch) {
|
|
26100
|
+
constructor(deps, reviewers, items, notices, onboarding, launch) {
|
|
25475
26101
|
this.deps = deps;
|
|
25476
26102
|
this.reviewers = reviewers;
|
|
25477
26103
|
this.items = items;
|
|
25478
26104
|
this.notices = notices;
|
|
26105
|
+
this.onboarding = onboarding;
|
|
25479
26106
|
this.launch = launch;
|
|
25480
26107
|
}
|
|
25481
26108
|
deps;
|
|
25482
26109
|
reviewers;
|
|
25483
26110
|
items;
|
|
25484
26111
|
notices;
|
|
26112
|
+
onboarding;
|
|
25485
26113
|
launch;
|
|
25486
26114
|
say(ctx, text8) {
|
|
25487
26115
|
return say2(this.deps, ctx.conversation, text8);
|
|
@@ -25556,35 +26184,40 @@ var ReviewChecks = class {
|
|
|
25556
26184
|
}
|
|
25557
26185
|
return actor;
|
|
25558
26186
|
}
|
|
25559
|
-
/**
|
|
26187
|
+
/**
|
|
26188
|
+
* The reviewer's GitHub binding, usable and authorized, or undefined when the asker was told why not. A review asked of
|
|
26189
|
+
* someone else who has a step left is kept until they have done it (`ReviewerOnboarding`), and the asker is told which.
|
|
26190
|
+
*/
|
|
25560
26191
|
async reviewerState(ctx, ask3, actor, pulls) {
|
|
25561
26192
|
const status = await this.deps.credentials.status(actor.userId);
|
|
25562
|
-
if (!status.ok) {
|
|
25563
|
-
if (status.error.kind === "not_bound") {
|
|
25564
|
-
await this.notices.noGithub(asked2(ctx), ctx.group, ctx.sender, actor, pulls, ctx.conversation, false);
|
|
25565
|
-
return void 0;
|
|
25566
|
-
}
|
|
26193
|
+
if (!status.ok && status.error.kind !== "not_bound") {
|
|
25567
26194
|
this.deps.logger.warn("github status call failed", { error: describeRefusal(status.error) });
|
|
25568
26195
|
await this.say(ctx, reviewStartText.githubUnknown(actor.name || "\u5BF9\u65B9"));
|
|
25569
26196
|
return void 0;
|
|
25570
26197
|
}
|
|
25571
|
-
if (
|
|
25572
|
-
|
|
26198
|
+
if (actor.userId === ctx.sender.id) {
|
|
26199
|
+
if (status.ok && usable(status.value)) return status.value;
|
|
26200
|
+
await this.notices.noGithub(asked2(ctx), ctx.group, ctx.sender, actor, pulls, ctx.conversation, status.ok);
|
|
26201
|
+
return void 0;
|
|
26202
|
+
}
|
|
26203
|
+
if (!status.ok) {
|
|
26204
|
+
await this.onboarding.refused(ctx, ask3, actor, pulls, "identity");
|
|
25573
26205
|
return void 0;
|
|
25574
26206
|
}
|
|
25575
|
-
|
|
25576
|
-
|
|
26207
|
+
const step = !usable(status.value) ? "bind" : !status.value.delegation ? "auto_merge" : void 0;
|
|
26208
|
+
if (step !== void 0) {
|
|
26209
|
+
await this.onboarding.refused(ctx, ask3, actor, pulls, step);
|
|
25577
26210
|
return void 0;
|
|
25578
26211
|
}
|
|
25579
26212
|
return status.value;
|
|
25580
26213
|
}
|
|
25581
26214
|
/** A review asked of someone else runs on their own token and key: both, or undefined when the asker was told. */
|
|
25582
|
-
async actingCredentials(ctx, actor) {
|
|
26215
|
+
async actingCredentials(ctx, ask3, actor, pulls) {
|
|
25583
26216
|
if (actor.userId === ctx.sender.id) return { token: "", key: "" };
|
|
25584
26217
|
const who = actor.name || "\u5BF9\u65B9";
|
|
25585
26218
|
const key = this.deps.store.links.getKey(actor.userId) ?? "";
|
|
25586
26219
|
if (!key.startsWith("ak-")) {
|
|
25587
|
-
await this.
|
|
26220
|
+
await this.onboarding.refused(ctx, ask3, actor, pulls, "link");
|
|
25588
26221
|
return void 0;
|
|
25589
26222
|
}
|
|
25590
26223
|
const token = await tokenFor(this.deps, actor.userId);
|
|
@@ -25631,7 +26264,7 @@ var ReviewChecks = class {
|
|
|
25631
26264
|
}
|
|
25632
26265
|
const state = await this.reviewerState(ctx, ask3, actor, pulls);
|
|
25633
26266
|
if (state === void 0) return;
|
|
25634
|
-
const acting = await this.actingCredentials(ctx, actor);
|
|
26267
|
+
const acting = await this.actingCredentials(ctx, ask3, actor, pulls);
|
|
25635
26268
|
if (acting === void 0) return;
|
|
25636
26269
|
const who = actor.name || "\u5BF9\u65B9";
|
|
25637
26270
|
const model = await this.modelFor(ctx, ask3, token, acting.key || modelKey, Boolean(acting.key), who);
|
|
@@ -25949,11 +26582,20 @@ var GithubReview = class {
|
|
|
25949
26582
|
this.held = new HeldWrites(deps, this.notices, this.account);
|
|
25950
26583
|
this.turns.offerHeld = (review, item, asked3) => this.held.offer(review, item, asked3);
|
|
25951
26584
|
this.launch = new ReviewLaunch(deps, this.items, this.notices, this.cards, this.follows, this.turns);
|
|
26585
|
+
this.onboarding = new ReviewerOnboarding(
|
|
26586
|
+
deps,
|
|
26587
|
+
this.notices,
|
|
26588
|
+
random,
|
|
26589
|
+
(ctx, ask3, actor) => this.checks.request(ctx, ask3, actor),
|
|
26590
|
+
(sender, args, conversation) => this.account.command(sender, args, conversation)
|
|
26591
|
+
);
|
|
26592
|
+
this.account.changed = (userId, change) => change === "delegation_off" ? this.onboarding.declined(userId) : this.onboarding.advance(userId);
|
|
25952
26593
|
this.checks = new ReviewChecks(
|
|
25953
26594
|
deps,
|
|
25954
26595
|
this.reviewers,
|
|
25955
26596
|
this.items,
|
|
25956
26597
|
this.notices,
|
|
26598
|
+
this.onboarding,
|
|
25957
26599
|
(s, held, handed) => this.launch.launch(s, held, handed)
|
|
25958
26600
|
);
|
|
25959
26601
|
this.turns.retryAsItem = (review, s) => this.launch.asItem(review, s);
|
|
@@ -25971,15 +26613,22 @@ var GithubReview = class {
|
|
|
25971
26613
|
held;
|
|
25972
26614
|
checks;
|
|
25973
26615
|
launch;
|
|
26616
|
+
onboarding;
|
|
25974
26617
|
/** Settles when the background work started so far (device flows, follows, hints) has ended. For tests. */
|
|
25975
26618
|
async idle() {
|
|
25976
26619
|
await Promise.all([this.account.idle(), this.follows.idle(), this.connect.idle()]);
|
|
26620
|
+
await this.onboarding.idle();
|
|
25977
26621
|
}
|
|
25978
26622
|
/** Which channel id is whose, from a message of theirs: a mention in a group can then be read without the member list. */
|
|
25979
26623
|
remember(message) {
|
|
25980
26624
|
const sender = message.sender;
|
|
25981
26625
|
if (sender.channelUserId)
|
|
25982
26626
|
this.deps.store.members.rememberMember(sender.channelUserId, sender.id, sender.name, sender.email);
|
|
26627
|
+
this.onboarding.activity(sender.id);
|
|
26628
|
+
}
|
|
26629
|
+
/** The reviewers a review waits for, read again: each step done is answered with the next (every ONBOARDING_SWEEP_MS). */
|
|
26630
|
+
sweepOnboarding() {
|
|
26631
|
+
return this.onboarding.sweep();
|
|
25983
26632
|
}
|
|
25984
26633
|
context(route) {
|
|
25985
26634
|
return {
|
|
@@ -26206,10 +26855,17 @@ var GithubReview = class {
|
|
|
26206
26855
|
clicks: [
|
|
26207
26856
|
{
|
|
26208
26857
|
// (the action's `verb` is its card data's `primusclaw` kind, as the adapter reads it; never the channel's verb)
|
|
26209
|
-
verbs: ["github_mode", "github_confirm", "github_connect"],
|
|
26858
|
+
verbs: ["github_mode", "github_confirm", "github_connect", ONBOARDING_CLICK],
|
|
26210
26859
|
beforeCredential: async (click) => {
|
|
26211
26860
|
await this.click(click);
|
|
26212
26861
|
return true;
|
|
26862
|
+
},
|
|
26863
|
+
// (the ready card goes where the asker asked, a group too: only its retry is answered there, and only to the
|
|
26864
|
+
// asker; it runs on the reviewer's own credential, never the group's or the presser's)
|
|
26865
|
+
inGroup: async (click) => {
|
|
26866
|
+
if (click.action.data.primusclaw !== ONBOARDING_CLICK) return false;
|
|
26867
|
+
await this.onboarding.click(click);
|
|
26868
|
+
return true;
|
|
26213
26869
|
}
|
|
26214
26870
|
}
|
|
26215
26871
|
]
|
|
@@ -26218,7 +26874,9 @@ var GithubReview = class {
|
|
|
26218
26874
|
async click(click) {
|
|
26219
26875
|
const data = click.action.data;
|
|
26220
26876
|
const settle = (card, fallback) => click.settle(card, fallback === void 0 ? {} : { fallback });
|
|
26221
|
-
if (data.primusclaw ===
|
|
26877
|
+
if (data.primusclaw === ONBOARDING_CLICK) await this.onboarding.click(click);
|
|
26878
|
+
else if (data.primusclaw === "github_mode")
|
|
26879
|
+
await this.account.modeClick(click.sender, data, settle, click.conversation);
|
|
26222
26880
|
else if (data.primusclaw === "github_confirm")
|
|
26223
26881
|
await this.held.click(click.sender, data, settle, click.conversation);
|
|
26224
26882
|
else await this.connect.dismiss(click.sender, data, click.lang(), settle);
|
|
@@ -26447,6 +27105,7 @@ __export(remote_exports, {
|
|
|
26447
27105
|
SUBFOLDER_MAX: () => SUBFOLDER_MAX,
|
|
26448
27106
|
TAKEOVER_STATES: () => TAKEOVER_STATES,
|
|
26449
27107
|
TERMINAL_CLOSED: () => TERMINAL_CLOSED,
|
|
27108
|
+
TERMINAL_INPUT_UNCONFIRMED: () => TERMINAL_INPUT_UNCONFIRMED,
|
|
26450
27109
|
THOUGHT_MAX: () => THOUGHT_MAX,
|
|
26451
27110
|
TOOL_TITLE_MAX: () => TOOL_TITLE_MAX,
|
|
26452
27111
|
TYPED_CHARS_MAX: () => TYPED_CHARS_MAX,
|
|
@@ -26498,12 +27157,14 @@ __export(remote_exports, {
|
|
|
26498
27157
|
placeOf: () => placeOf,
|
|
26499
27158
|
plain: () => plain3,
|
|
26500
27159
|
queuedLine: () => queuedLine,
|
|
27160
|
+
queuedNote: () => queuedNote,
|
|
26501
27161
|
readOnlyRefused: () => readOnlyRefused,
|
|
26502
27162
|
recoveredLine: () => recoveredLine,
|
|
26503
27163
|
remoteButton: () => remoteButton,
|
|
26504
27164
|
remoteData: () => remoteData,
|
|
26505
27165
|
remoteStep: () => remoteStep,
|
|
26506
27166
|
resumableOf: () => resumableOf,
|
|
27167
|
+
rowUnreadableLine: () => rowUnreadableLine,
|
|
26507
27168
|
sessionFacts: () => sessionFacts,
|
|
26508
27169
|
sessionPageUrl: () => sessionPageUrl,
|
|
26509
27170
|
sessionTitle: () => sessionTitle,
|
|
@@ -26519,6 +27180,7 @@ __export(remote_exports, {
|
|
|
26519
27180
|
typesInto: () => typesInto,
|
|
26520
27181
|
unattendedAllowed: () => unattendedAllowed,
|
|
26521
27182
|
unsolicitedParts: () => unsolicitedParts,
|
|
27183
|
+
unwrapPasted: () => unwrapPasted,
|
|
26522
27184
|
watchesLive: () => watchesLive,
|
|
26523
27185
|
whereLine: () => whereLine,
|
|
26524
27186
|
withdraws: () => withdraws
|
|
@@ -26694,6 +27356,7 @@ function hiddenOf(agent) {
|
|
|
26694
27356
|
|
|
26695
27357
|
// packages/core/src/remote/events.ts
|
|
26696
27358
|
import { z as z8 } from "zod";
|
|
27359
|
+
var DIALOG_MAX = 120;
|
|
26697
27360
|
var NOTHING2 = Object.freeze({
|
|
26698
27361
|
chunk: null,
|
|
26699
27362
|
tool: null,
|
|
@@ -26715,6 +27378,9 @@ var NOTHING2 = Object.freeze({
|
|
|
26715
27378
|
readOnly: null,
|
|
26716
27379
|
recovered: null,
|
|
26717
27380
|
queued: null,
|
|
27381
|
+
dialog: null,
|
|
27382
|
+
waitLine: null,
|
|
27383
|
+
rowUnreadable: false,
|
|
26718
27384
|
queuedFor: null,
|
|
26719
27385
|
queuedSeq: null,
|
|
26720
27386
|
queuedHeld: false,
|
|
@@ -26731,7 +27397,7 @@ function record5(value) {
|
|
|
26731
27397
|
const parsed = Record_.safeParse(value);
|
|
26732
27398
|
return parsed.success ? parsed.data : {};
|
|
26733
27399
|
}
|
|
26734
|
-
function
|
|
27400
|
+
function str7(value) {
|
|
26735
27401
|
return typeof value === "string" ? value : "";
|
|
26736
27402
|
}
|
|
26737
27403
|
function seqOf(value) {
|
|
@@ -26750,7 +27416,7 @@ function textOf5(payload) {
|
|
|
26750
27416
|
const inner = Record_.safeParse(content);
|
|
26751
27417
|
if (inner.success && typeof inner.data["text"] === "string") return inner.data["text"];
|
|
26752
27418
|
if (typeof content === "string") return content;
|
|
26753
|
-
return
|
|
27419
|
+
return str7(u["text"]);
|
|
26754
27420
|
}
|
|
26755
27421
|
var STOP_REASONS = /* @__PURE__ */ new Set(["end_turn", "max_tokens", "max_turn_requests", "refusal", "cancelled", "error"]);
|
|
26756
27422
|
function availableModes(raw) {
|
|
@@ -26799,7 +27465,7 @@ function planLine(payload) {
|
|
|
26799
27465
|
const done = items.filter((e) => e["status"] === "completed").length;
|
|
26800
27466
|
const current = items.find((e) => e["status"] === "in_progress") ?? items.find((e) => e["status"] !== "completed");
|
|
26801
27467
|
let line2 = `\u{1F4CB} Plan: ${String(done)} of ${String(items.length)} done`;
|
|
26802
|
-
if (current &&
|
|
27468
|
+
if (current && str7(current["content"])) line2 += `, now: ${neutral2(current["content"], PLAN_ITEM_MAX)}`;
|
|
26803
27469
|
return line2;
|
|
26804
27470
|
}
|
|
26805
27471
|
var NOT_TYPED = new RegExp(
|
|
@@ -26810,38 +27476,48 @@ function chunk(payload, kind) {
|
|
|
26810
27476
|
if (!text8) return NOTHING2;
|
|
26811
27477
|
return remoteStep({ chunk: { kind: kind === "agent_message_chunk" ? "message" : "thought", text: text8 } });
|
|
26812
27478
|
}
|
|
27479
|
+
var PASTED_BLOCK = /\n*<pasted_content id="([^"\s<>]{1,64})">\n([\s\S]*?)\n<\/pasted_content id="\1">\n*/gu;
|
|
27480
|
+
function unwrapPasted(text8) {
|
|
27481
|
+
if (!text8.includes("<pasted_content ")) return text8;
|
|
27482
|
+
return text8.replace(PASTED_BLOCK, (whole4, _id, inner, at, all) => {
|
|
27483
|
+
const end = at + whole4.length;
|
|
27484
|
+
return `${at > 0 ? "\n" : ""}${inner}${end < all.length ? "\n" : ""}`;
|
|
27485
|
+
});
|
|
27486
|
+
}
|
|
26813
27487
|
function typed(payload) {
|
|
26814
|
-
const text8 = pyStrip(textOf5(payload));
|
|
27488
|
+
const text8 = pyStrip(unwrapPasted(textOf5(payload)));
|
|
26815
27489
|
return text8 && !NOT_TYPED.test(text8) ? remoteStep({ typed: text8 }) : NOTHING2;
|
|
26816
27490
|
}
|
|
26817
27491
|
var TOOL_NAME = /^[A-Za-z][\w.-]{0,63}$/u;
|
|
26818
27492
|
function toolNameOf(u) {
|
|
26819
27493
|
const meta = record5(record5(u["_meta"])["claudeCode"]);
|
|
26820
|
-
const named2 =
|
|
27494
|
+
const named2 = str7(meta["toolName"]);
|
|
26821
27495
|
if (TOOL_NAME.test(named2)) return named2;
|
|
26822
|
-
const head =
|
|
26823
|
-
return head !==
|
|
27496
|
+
const head = str7(u["title"]).split(": ", 1)[0] ?? "";
|
|
27497
|
+
return head !== str7(u["title"]) && TOOL_NAME.test(head) ? head : "";
|
|
26824
27498
|
}
|
|
26825
27499
|
function tool(payload, kind) {
|
|
26826
27500
|
const u = update(payload);
|
|
26827
|
-
const id =
|
|
26828
|
-
const status =
|
|
27501
|
+
const id = str7(u["toolCallId"]) || str7(u["tool_call_id"]) || str7(u["id"]);
|
|
27502
|
+
const status = str7(u["status"]) || (kind === "tool_call" ? "pending" : "");
|
|
26829
27503
|
const name = toolNameOf(u);
|
|
26830
|
-
return remoteStep({ tool: { id, title:
|
|
27504
|
+
return remoteStep({ tool: { id, title: str7(u["title"]), status, ...name ? { name } : {} } });
|
|
26831
27505
|
}
|
|
26832
27506
|
function terminalQueued(payload) {
|
|
26833
27507
|
const seq = seqOf(payload["cmd_seq"]);
|
|
26834
|
-
const forId = neutral2(
|
|
27508
|
+
const forId = neutral2(str7(payload["cmd_id"]), 80) || (seq !== null ? String(seq) : "");
|
|
26835
27509
|
return remoteStep({
|
|
26836
|
-
queued:
|
|
27510
|
+
queued: str7(payload["reason"]) || "terminal_working",
|
|
26837
27511
|
queuedFor: forId || null,
|
|
26838
27512
|
queuedSeq: seq,
|
|
26839
|
-
queuedHeld: payload["held"] === "terminal"
|
|
27513
|
+
queuedHeld: payload["held"] === "terminal",
|
|
27514
|
+
dialog: neutral2(str7(payload["dialog"]), DIALOG_MAX) || null,
|
|
27515
|
+
rowUnreadable: payload["registry_row_unreadable"] === true
|
|
26840
27516
|
});
|
|
26841
27517
|
}
|
|
26842
27518
|
function turnEnd(payload, _kind, errors) {
|
|
26843
|
-
let reason =
|
|
26844
|
-
let error =
|
|
27519
|
+
let reason = str7(payload["stopReason"]) || "end_turn";
|
|
27520
|
+
let error = str7(payload["error"]) || str7(payload["message"]);
|
|
26845
27521
|
if (!STOP_REASONS.has(reason)) {
|
|
26846
27522
|
error = error || `an internal error (ref ${errors.withhold("remote_stop_reason", reason)})`;
|
|
26847
27523
|
reason = "error";
|
|
@@ -26862,8 +27538,9 @@ function sessionStarted(payload) {
|
|
|
26862
27538
|
modeFlags: modeFlags(payload["modes"]),
|
|
26863
27539
|
readOnly: flag2(payload["read_only"]) ?? false,
|
|
26864
27540
|
terminal: payload["input"] === "terminal",
|
|
26865
|
-
terminalMode: neutral2(
|
|
26866
|
-
acp: neutral2(
|
|
27541
|
+
terminalMode: neutral2(str7(payload["terminal_mode"]), 40) || null,
|
|
27542
|
+
acp: neutral2(str7(payload["acp_session_id"]), RESUME_REF_MAX) || null,
|
|
27543
|
+
rowUnreadable: payload["registry_row_unreadable"] === true
|
|
26867
27544
|
});
|
|
26868
27545
|
}
|
|
26869
27546
|
function modeUpdate(payload) {
|
|
@@ -26887,21 +27564,21 @@ function sessionResumed(payload) {
|
|
|
26887
27564
|
});
|
|
26888
27565
|
}
|
|
26889
27566
|
function sessionClosed(payload, _kind, errors) {
|
|
26890
|
-
const reason =
|
|
27567
|
+
const reason = str7(payload["reason"]) || str7(payload["message"]) || str7(payload["error"]);
|
|
26891
27568
|
return remoteStep({ closed: neutral2(errors.publicReason(reason, "remote_session_closed"), 300) });
|
|
26892
27569
|
}
|
|
26893
27570
|
function commandRejected(payload, _kind, errors) {
|
|
26894
|
-
const reason =
|
|
27571
|
+
const reason = str7(payload["reason"]);
|
|
26895
27572
|
return remoteStep({
|
|
26896
27573
|
rejected: {
|
|
26897
|
-
type:
|
|
27574
|
+
type: str7(payload["type"]),
|
|
26898
27575
|
reason: neutral2(errors.publicReason(reason, "remote_command_rejected"), 300),
|
|
26899
27576
|
cmdSeq: seqOf(payload["cmd_seq"])
|
|
26900
27577
|
}
|
|
26901
27578
|
});
|
|
26902
27579
|
}
|
|
26903
27580
|
function failed2(payload, _kind, errors) {
|
|
26904
|
-
const text8 =
|
|
27581
|
+
const text8 = str7(payload["message"]) || str7(payload["error"]) || str7(payload["reason"]);
|
|
26905
27582
|
return remoteStep({
|
|
26906
27583
|
finished: true,
|
|
26907
27584
|
stopReason: "error",
|
|
@@ -27010,6 +27687,7 @@ var DELIVERY_UNCONFIRMED = "delivery_unconfirmed";
|
|
|
27010
27687
|
var READ_ONLY_REASONS = ["read_only_live_session", "session_read_only"];
|
|
27011
27688
|
var TERMINAL_CLOSED = "terminal_closed";
|
|
27012
27689
|
var CONNECTOR_RESTARTED = "connector_restarted";
|
|
27690
|
+
var TERMINAL_INPUT_UNCONFIRMED = "terminal_input_unconfirmed";
|
|
27013
27691
|
var NO_ASK_MODES = {
|
|
27014
27692
|
bypassPermissions: "bypass permissions",
|
|
27015
27693
|
auto: "auto",
|
|
@@ -27066,6 +27744,15 @@ function queuedLine(reason, lang) {
|
|
|
27066
27744
|
const key = QUEUED_KEYS.get(reason);
|
|
27067
27745
|
return `\u23F3 ${key ? words3[key] : words3.other}`;
|
|
27068
27746
|
}
|
|
27747
|
+
function queuedNote(reason, dialog, lang) {
|
|
27748
|
+
if (reason !== "terminal_dialog") return queuedLine(reason, lang);
|
|
27749
|
+
const words3 = remoteText.in(lang);
|
|
27750
|
+
const what = dialog ? neutral2(masked2(dialog), 120) : "";
|
|
27751
|
+
return what ? words3.dialogAsks({ what }) : words3.dialogAsksBare;
|
|
27752
|
+
}
|
|
27753
|
+
function rowUnreadableLine(lang) {
|
|
27754
|
+
return remoteText.in(lang).rowUnreadable;
|
|
27755
|
+
}
|
|
27069
27756
|
function readOnlyRefused(lang, takeover = false) {
|
|
27070
27757
|
const words3 = remoteText.in(lang);
|
|
27071
27758
|
return words3.readOnly + (takeover ? words3.readOnlyTakeoverTail : "");
|
|
@@ -27633,15 +28320,15 @@ function sessionRows(input, shown3) {
|
|
|
27633
28320
|
});
|
|
27634
28321
|
}
|
|
27635
28322
|
function joinedOf(input, shown3) {
|
|
27636
|
-
const
|
|
28323
|
+
const names3 = input.names ?? /* @__PURE__ */ new Map();
|
|
27637
28324
|
const shownIds = shown3.map((s) => s.sessionId);
|
|
27638
28325
|
const mine = /* @__PURE__ */ new Set();
|
|
27639
28326
|
for (const [sid, acp] of input.own ?? /* @__PURE__ */ new Map()) {
|
|
27640
|
-
if (shownIds.includes(sid) && !
|
|
28327
|
+
if (shownIds.includes(sid) && !names3.get(sid)?.ref) mine.add(acp);
|
|
27641
28328
|
}
|
|
27642
28329
|
const connected = /* @__PURE__ */ new Map();
|
|
27643
28330
|
shownIds.forEach((sid, i) => {
|
|
27644
|
-
const ref =
|
|
28331
|
+
const ref = names3.get(sid)?.ref;
|
|
27645
28332
|
if (ref) connected.set(ref, { number: i + 1, sessionId: sid });
|
|
27646
28333
|
});
|
|
27647
28334
|
return { connected, mine };
|
|
@@ -27751,7 +28438,7 @@ var RemoteLiveView = class {
|
|
|
27751
28438
|
apply(step) {
|
|
27752
28439
|
const before = this.render();
|
|
27753
28440
|
const waited = this.waiting;
|
|
27754
|
-
if (step.queued !== null) this.waiting = step.note ?? "";
|
|
28441
|
+
if (step.queued !== null) this.waiting = step.waitLine ?? step.note ?? "";
|
|
27755
28442
|
else if (showsTheTurn(step)) this.waiting = "";
|
|
27756
28443
|
if (step.chunk) this.addText(step.chunk.kind, step.chunk.text);
|
|
27757
28444
|
else if (step.tool) {
|
|
@@ -29206,6 +29893,8 @@ var ChatRegistry = class {
|
|
|
29206
29893
|
readOnly = /* @__PURE__ */ new Map();
|
|
29207
29894
|
readOnlyKnown = /* @__PURE__ */ new Map();
|
|
29208
29895
|
terminalInput = /* @__PURE__ */ new Map();
|
|
29896
|
+
/** The session each chat was told its terminal's registry row cannot be read for (once per attach). */
|
|
29897
|
+
rowHinted = /* @__PURE__ */ new Map();
|
|
29209
29898
|
tickets = /* @__PURE__ */ new Map();
|
|
29210
29899
|
/** How many messages wait behind the chat's running turn. */
|
|
29211
29900
|
queuedCount(chatKey) {
|
|
@@ -29299,6 +29988,12 @@ var ChatRegistry = class {
|
|
|
29299
29988
|
if (terminal) this.terminalInput.set(chatKey, sessionId);
|
|
29300
29989
|
else if (this.terminalInput.get(chatKey) === sessionId) this.terminalInput.delete(chatKey);
|
|
29301
29990
|
}
|
|
29991
|
+
/** True the first time for a chat's session: the chat is to be told its terminal's registry row cannot be read. */
|
|
29992
|
+
firstRowHint(chatKey, sessionId) {
|
|
29993
|
+
if (!sessionId || this.rowHinted.get(chatKey) === sessionId) return false;
|
|
29994
|
+
this.rowHinted.set(chatKey, sessionId);
|
|
29995
|
+
return true;
|
|
29996
|
+
}
|
|
29302
29997
|
/** What is sent to the chat's session is typed into a terminal on the machine. */
|
|
29303
29998
|
typesIntoTerminal(chatKey, sessionId) {
|
|
29304
29999
|
return sessionId !== null && this.terminalInput.get(chatKey) === sessionId;
|
|
@@ -29338,6 +30033,7 @@ var ChatRegistry = class {
|
|
|
29338
30033
|
this.agentUnattended.delete(chatKey);
|
|
29339
30034
|
this.readOnly.delete(chatKey);
|
|
29340
30035
|
this.readOnlyKnown.delete(chatKey);
|
|
30036
|
+
this.rowHinted.delete(chatKey);
|
|
29341
30037
|
this.queuedPrompts.delete(chatKey);
|
|
29342
30038
|
this.refusals.delete(chatKey);
|
|
29343
30039
|
}
|
|
@@ -29421,8 +30117,8 @@ function resolveAgent(connectors, ref, now, lang = "en") {
|
|
|
29421
30117
|
const only2 = online[0];
|
|
29422
30118
|
if (online.length === 1 && only2 !== void 0) return only2;
|
|
29423
30119
|
if (online.length > 1) {
|
|
29424
|
-
const
|
|
29425
|
-
return refusal2(remoteAgentText.in(lang).agentOnMachines({ names:
|
|
30120
|
+
const names3 = online.map((p) => `\`${agentRefOf(p.connector, p.agent)}\``).join(", ");
|
|
30121
|
+
return refusal2(remoteAgentText.in(lang).agentOnMachines({ names: names3 }));
|
|
29426
30122
|
}
|
|
29427
30123
|
return refusal2(offlineText(first.connector, now, lang));
|
|
29428
30124
|
}
|
|
@@ -29689,8 +30385,8 @@ var Targets = class {
|
|
|
29689
30385
|
if (/^\d+$/u.test(ref)) return refusal3(saidIn(lang, "whichSession"));
|
|
29690
30386
|
const chosen = resolveAgent(connectors, ref, now, lang);
|
|
29691
30387
|
if (chosen.kind === "machine") {
|
|
29692
|
-
const
|
|
29693
|
-
return refusal3(remoteAgentText.in(lang).agentsOnHost({ host: neutral(chosen.connector.name, 80), names:
|
|
30388
|
+
const names3 = chosen.agents.map((a) => `\`${agentRefOf(chosen.connector, a)}\``).join(", ");
|
|
30389
|
+
return refusal3(remoteAgentText.in(lang).agentsOnHost({ host: neutral(chosen.connector.name, 80), names: names3 }));
|
|
29694
30390
|
}
|
|
29695
30391
|
if (chosen.kind === "refusal") {
|
|
29696
30392
|
if (found.length > 0 || chosen.text === noAgentCalled(ref, lang))
|
|
@@ -30360,6 +31056,8 @@ var remoteLeads = {
|
|
|
30360
31056
|
sessionEnded: ["\u4F1A\u8BDD\u5DF2\u7ED3\u675F", "The session ended"],
|
|
30361
31057
|
couldNotStart: ["\u4F1A\u8BDD\u6CA1\u80FD\u542F\u52A8", "The session could not start"],
|
|
30362
31058
|
turnIncomplete: ["\u8FD9\u4E00\u8F6E\u6CA1\u6709\u5B8C\u6210", "The turn did not complete"],
|
|
31059
|
+
/** (a message the terminal may have taken: never said as a turn that did not complete) */
|
|
31060
|
+
inputUnconfirmed: ["\u8FD8\u6CA1\u786E\u8BA4\u7EC8\u7AEF\u6536\u5230", "Not confirmed by the terminal yet"],
|
|
30363
31061
|
modeNotSwitched: ["\u6A21\u5F0F\u6CA1\u6709\u5207\u6362", "The mode was not switched"],
|
|
30364
31062
|
notSwitchedTo: (mode) => [`\u6CA1\u6709\u5207\u5230 \`${mode}\``, `The agent did not switch to \`${mode}\``]
|
|
30365
31063
|
};
|
|
@@ -30419,7 +31117,8 @@ var connectorReasonText = defineCatalog({
|
|
|
30419
31117
|
terminal_input_failed: "Typing the message into the terminal failed; it was not sent.",
|
|
30420
31118
|
// (a connector after 0.1.22: the paste never showed in the box in the 20 seconds it waited)
|
|
30421
31119
|
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.",
|
|
30422
|
-
|
|
31120
|
+
// (not a failure: the terminal may well have taken it; what the session does next still shows here)
|
|
31121
|
+
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.",
|
|
30423
31122
|
terminal_input_unavailable: "After a restart the connector could not prove that terminal again, so the message was not typed in. Attach again.",
|
|
30424
31123
|
empty_prompt: "The message was empty once its control characters were removed; nothing was typed.",
|
|
30425
31124
|
// (a prompt to a session that only watches a terminal's conversation; also a turn_end error)
|
|
@@ -30492,7 +31191,7 @@ var connectorReasonText = defineCatalog({
|
|
|
30492
31191
|
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",
|
|
30493
31192
|
terminal_input_failed: "\u5F80\u7EC8\u7AEF\u91CC\u8F93\u5165\u8FD9\u6761\u6D88\u606F\u5931\u8D25\u4E86\uFF0C\u6CA1\u6709\u53D1\u8FDB\u53BB\u3002",
|
|
30494
31193
|
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",
|
|
30495
|
-
terminal_input_unconfirmed: "\u6D88\u606F\u5DF2\u7ECF\u8F93\u5165\u7EC8\u7AEF\uFF0C\u4F46\u7EC8\u7AEF\u7684\u8BB0\u5F55\u91CC\u6CA1\u770B\u5230\u5B83\uFF0C\
|
|
31194
|
+
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",
|
|
30496
31195
|
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",
|
|
30497
31196
|
empty_prompt: "\u8FD9\u6761\u6D88\u606F\u53BB\u6389\u63A7\u5236\u5B57\u7B26\u540E\u662F\u7A7A\u7684\uFF0C\u6CA1\u6709\u53D1\u8FDB\u7EC8\u7AEF\u3002",
|
|
30498
31197
|
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",
|
|
@@ -30550,6 +31249,9 @@ var UPGRADE = both((lang) => connectorReasonHints.in(lang).upgrade({ command: UP
|
|
|
30550
31249
|
var SANDBOX = both((lang) => connectorReasonHints.in(lang).sandbox);
|
|
30551
31250
|
var STATUS2 = both((lang) => connectorReasonHints.in(lang).status);
|
|
30552
31251
|
var OLD_CONNECTOR = /* @__PURE__ */ new Set(["mode_unavailable", "mode_not_enforced"]);
|
|
31252
|
+
var FIXED_LATER = {
|
|
31253
|
+
terminal_input_unconfirmed: [0, 1, 22]
|
|
31254
|
+
};
|
|
30553
31255
|
var THEN_NEW = /* @__PURE__ */ new Set([
|
|
30554
31256
|
"adapter_gone",
|
|
30555
31257
|
"adapter_cannot_resume",
|
|
@@ -30592,6 +31294,13 @@ ${hints.sandbox}
|
|
|
30592
31294
|
` };
|
|
30593
31295
|
return { sep: " ", hint: hints.status };
|
|
30594
31296
|
}
|
|
31297
|
+
const fixedIn = own(FIXED_LATER, code3);
|
|
31298
|
+
if (fixedIn) {
|
|
31299
|
+
const parsed = parseVersion2(version);
|
|
31300
|
+
if (parsed !== null && older(parsed, fixedIn))
|
|
31301
|
+
return { sep: "\n\n", hint: hints.upgrade({ command: UPGRADE_COMMAND }) };
|
|
31302
|
+
return null;
|
|
31303
|
+
}
|
|
30595
31304
|
if (THEN_NEW.has(code3)) return { sep: " ", hint: hints.newSession };
|
|
30596
31305
|
if (THEN_RETRY.has(code3)) return { sep: " ", hint: hints.retry };
|
|
30597
31306
|
return null;
|
|
@@ -30645,7 +31354,8 @@ var EndedWords = class {
|
|
|
30645
31354
|
* sentence then offers the upgrade, which cannot hurt).
|
|
30646
31355
|
*/
|
|
30647
31356
|
async connectorVersion(key, provider, connectorId, reason) {
|
|
30648
|
-
|
|
31357
|
+
const code3 = (reason ?? "").trim();
|
|
31358
|
+
if (!(OLD_CONNECTOR.has(code3) || Object.hasOwn(FIXED_LATER, code3)) || !connectorId) return null;
|
|
30649
31359
|
try {
|
|
30650
31360
|
const credential2 = await credentialOf(key, provider);
|
|
30651
31361
|
if (!credential2) return null;
|
|
@@ -31518,6 +32228,8 @@ var Watches = class {
|
|
|
31518
32228
|
const lang = this.state.lang(w.chatKey);
|
|
31519
32229
|
const warning = step.terminal === true ? noAskLine(step.terminalMode, lang) : null;
|
|
31520
32230
|
if (warning) await w.to.send(textMessage(warning));
|
|
32231
|
+
if (step.terminal === true && step.rowUnreadable && this.state.chats.firstRowHint(w.chatKey, w.sessionId))
|
|
32232
|
+
await w.to.send(textMessage(rowUnreadableLine(lang)));
|
|
31521
32233
|
const switched = w.want ? await this.approvalNote(w, w.want, signal) : "";
|
|
31522
32234
|
const state = this.state.attached(w.chatKey);
|
|
31523
32235
|
if (state?.sessionId !== w.sessionId) return;
|
|
@@ -31879,9 +32591,9 @@ ${left}` : "";
|
|
|
31879
32591
|
else if (state) chosen = connectors.filter((c) => c.connectorId === state.connectorId);
|
|
31880
32592
|
const only2 = chosen[0];
|
|
31881
32593
|
if (chosen.length !== 1 || only2 === void 0) {
|
|
31882
|
-
const
|
|
32594
|
+
const names3 = connectors.map((c) => `\`${neutral(c.name, 60)}\``).join(", ");
|
|
31883
32595
|
const words3 = remoteAgentText.in("en");
|
|
31884
|
-
return this.say(call,
|
|
32596
|
+
return this.say(call, names3 ? words3.whichMachine({ names: names3 }) : words3.whichMachineNone);
|
|
31885
32597
|
}
|
|
31886
32598
|
const setup = await this.p.lists.setup(call.key);
|
|
31887
32599
|
await call.to.send(this.p.ctx.views.disconnect(only2.name, only2.connectorId, setup, this.lang(call), only2.paired));
|
|
@@ -33375,6 +34087,8 @@ var TurnRunner = class {
|
|
|
33375
34087
|
ended;
|
|
33376
34088
|
show;
|
|
33377
34089
|
displayFor;
|
|
34090
|
+
/** The questions on the terminal each turn's display said in the chat (by their line). */
|
|
34091
|
+
questionsTold = /* @__PURE__ */ new WeakMap();
|
|
33378
34092
|
/** Per chat: what it was told of each message (Claw's number) waiting for a busy terminal (`tellBusy`), oldest first. */
|
|
33379
34093
|
toldBusy = /* @__PURE__ */ new Map();
|
|
33380
34094
|
/** Watch the turn that is open on the chat's session. */
|
|
@@ -33461,7 +34175,14 @@ var TurnRunner = class {
|
|
|
33461
34175
|
splitErrorTail: (text8) => this.ctx.errors.splitErrorTail(text8),
|
|
33462
34176
|
withhold: (detail) => this.ctx.errors.withhold("remote_turn_failed", detail, { session: state.sessionId }),
|
|
33463
34177
|
sessionEnded: (reason) => this.ended.sessionEnded(chatKey, request.key, request.provider, state.connectorId, reason),
|
|
33464
|
-
turnIncomplete: (code3) => this.ended.said(
|
|
34178
|
+
turnIncomplete: (code3) => this.ended.said(
|
|
34179
|
+
chatKey,
|
|
34180
|
+
code3 === TERMINAL_INPUT_UNCONFIRMED ? remoteLeads.inputUnconfirmed : remoteLeads.turnIncomplete,
|
|
34181
|
+
request.key,
|
|
34182
|
+
request.provider,
|
|
34183
|
+
state.connectorId,
|
|
34184
|
+
code3
|
|
34185
|
+
),
|
|
33465
34186
|
...signer ? { sign: (parts2) => signer.later(parts2) } : {}
|
|
33466
34187
|
}
|
|
33467
34188
|
);
|
|
@@ -33538,9 +34259,9 @@ var TurnRunner = class {
|
|
|
33538
34259
|
if (step.rejected?.type === "prompt" && step.rejected.cmdSeq !== null) {
|
|
33539
34260
|
await this.queuedRefused(chatKey, to, step.rejected.cmdSeq, step.rejected.reason);
|
|
33540
34261
|
}
|
|
33541
|
-
|
|
33542
|
-
display.progress(
|
|
33543
|
-
if (step.
|
|
34262
|
+
if (step.queued !== null) await this.showWait(request, step, display);
|
|
34263
|
+
else display.progress(step);
|
|
34264
|
+
if (step.rowUnreadable) await this.sayRowUnreadable(chatKey, sid, to);
|
|
33544
34265
|
if (saysModes(step)) this.ctx.remoteState.setRemoteModes(chatKey, sid, step);
|
|
33545
34266
|
if (step.permission !== null) await this.show(chatKey, sid, step.permission, to);
|
|
33546
34267
|
if (step.resolved !== null) this.ctx.permissions.closeRemotePermission(sid, actionIdOf(step.resolved), "decided");
|
|
@@ -33590,6 +34311,46 @@ var TurnRunner = class {
|
|
|
33590
34311
|
this.ctx.logger.warn("that a queued message was refused could not be told", { error: errorName(error) });
|
|
33591
34312
|
}
|
|
33592
34313
|
}
|
|
34314
|
+
/**
|
|
34315
|
+
* Why the message still waits for the terminal, in the chat's language: the whole line in the turn's live view and on the session
|
|
34316
|
+
* card, a short one in the floating status; what a question on the terminal asks is also said in the chat when the display does
|
|
34317
|
+
* not show the whole line; that it waits for a busy terminal is said in the chat at once (`tellBusy`).
|
|
34318
|
+
*/
|
|
34319
|
+
async showWait(request, step, display) {
|
|
34320
|
+
const { chatKey, to } = request;
|
|
34321
|
+
const lang = this.state.lang(chatKey);
|
|
34322
|
+
const reason = step.queued ?? "";
|
|
34323
|
+
const note = queuedNote(reason, step.dialog, lang);
|
|
34324
|
+
display.progress({ ...step, note, waitLine: queuedLine(reason, lang) });
|
|
34325
|
+
if (reason === "terminal_dialog" && !display.showsWaits) await this.sayQuestion(display, note, to);
|
|
34326
|
+
if (BUSY_REASONS.has(reason)) await this.tellBusy(request, step);
|
|
34327
|
+
}
|
|
34328
|
+
/**
|
|
34329
|
+
* What a question on the terminal asks, while the message waits for it: said in the chat once per question and turn (the stream's
|
|
34330
|
+
* floating status has room for a few characters only, and the person must answer it at the terminal before anything runs).
|
|
34331
|
+
*/
|
|
34332
|
+
async sayQuestion(display, line2, to) {
|
|
34333
|
+
const told = this.questionsTold.get(display) ?? /* @__PURE__ */ new Set();
|
|
34334
|
+
if (told.has(line2)) return;
|
|
34335
|
+
told.add(line2);
|
|
34336
|
+
this.questionsTold.set(display, told);
|
|
34337
|
+
try {
|
|
34338
|
+
await to.send(textMessage(line2));
|
|
34339
|
+
} catch (error) {
|
|
34340
|
+
this.ctx.logger.warn("what the terminal's question asks could not be told", { error: errorName(error) });
|
|
34341
|
+
}
|
|
34342
|
+
}
|
|
34343
|
+
/** Once per attach: the terminal's registry row cannot be read, and a restart of it there makes it known again. */
|
|
34344
|
+
async sayRowUnreadable(chatKey, sid, to) {
|
|
34345
|
+
if (!this.state.chats.firstRowHint(chatKey, sid)) return;
|
|
34346
|
+
try {
|
|
34347
|
+
await to.send(textMessage(rowUnreadableLine(this.state.lang(chatKey))));
|
|
34348
|
+
} catch (error) {
|
|
34349
|
+
this.ctx.logger.warn("that the terminal's registry row cannot be read could not be told", {
|
|
34350
|
+
error: errorName(error)
|
|
34351
|
+
});
|
|
34352
|
+
}
|
|
34353
|
+
}
|
|
33593
34354
|
async sayRecovered(chatKey, to, interrupted, continuing) {
|
|
33594
34355
|
const state = this.ctx.remoteState.getRemote(chatKey);
|
|
33595
34356
|
if (!state?.sessionId) return;
|
|
@@ -33637,6 +34398,8 @@ var WindowTurn = class {
|
|
|
33637
34398
|
board;
|
|
33638
34399
|
cutError;
|
|
33639
34400
|
tail = "";
|
|
34401
|
+
/** (the card's state line says why a message waits, whole) */
|
|
34402
|
+
showsWaits = true;
|
|
33640
34403
|
segments = [];
|
|
33641
34404
|
newSegment = true;
|
|
33642
34405
|
closed = false;
|
|
@@ -34261,6 +35024,7 @@ export {
|
|
|
34261
35024
|
ONBOARDING_DM_BUDGET_SECONDS,
|
|
34262
35025
|
ONBOARDING_INTERVAL_SECONDS,
|
|
34263
35026
|
ONBOARDING_REQUEST_MINUTES,
|
|
35027
|
+
ONBOARDING_SWEEP_MS,
|
|
34264
35028
|
OPTIONS_MAX,
|
|
34265
35029
|
OPTION_MAX,
|
|
34266
35030
|
ObserveBoard,
|
|
@@ -34311,6 +35075,7 @@ export {
|
|
|
34311
35075
|
REMOTE_HIDE_LIMITS,
|
|
34312
35076
|
REMOTE_LINE,
|
|
34313
35077
|
REMOTE_ORIGIN_TERMINAL_HOOK,
|
|
35078
|
+
REMOTE_OUTBOX_REPORT_MAX_SESSIONS,
|
|
34314
35079
|
REMOTE_PERMISSION_KEEP_SECONDS,
|
|
34315
35080
|
WATCH_TIMINGS as REMOTE_WATCH_TIMINGS,
|
|
34316
35081
|
REPO,
|
|
@@ -34323,6 +35088,7 @@ export {
|
|
|
34323
35088
|
REVIEW_HANDOFF_ACTION,
|
|
34324
35089
|
REVIEW_MODES,
|
|
34325
35090
|
REVIEW_MODE_NAMES,
|
|
35091
|
+
REVIEW_ONBOARDING_KEEP_SECONDS,
|
|
34326
35092
|
RULE_MAX_BYTES,
|
|
34327
35093
|
RULE_TTL_MS,
|
|
34328
35094
|
Receipts,
|
|
@@ -34609,6 +35375,7 @@ export {
|
|
|
34609
35375
|
parseLimits,
|
|
34610
35376
|
parseLinkCode,
|
|
34611
35377
|
parseObserve,
|
|
35378
|
+
parseOutboxReport,
|
|
34612
35379
|
parseQuietWindow,
|
|
34613
35380
|
parseRemoteId,
|
|
34614
35381
|
parseRepo,
|