@primusclaw/personal-agent 0.15.2 → 0.15.3
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 +102 -36
- package/dist/types/claw/model.d.ts +5 -0
- package/dist/types/ports/metrics.d.ts +2 -0
- package/dist/types/proactive/deliver.d.ts +1 -1
- package/dist/types/protocol/claw-api/assistant-events.d.ts +8 -0
- package/dist/types/protocol/claw-api/reviews.d.ts +6 -0
- package/dist/types/remote/board.d.ts +1 -1
- package/dist/types/remote/follow/control.d.ts +1 -1
- package/dist/types/remote/lines.d.ts +1 -1
- package/dist/types/remote/turns/chat-turn.d.ts +1 -1
- package/dist/types/review/handoff.d.ts +6 -0
- package/dist/types/review/progress.d.ts +2 -2
- package/dist/types/review/refusals.d.ts +2 -2
- package/dist/types/review/request-parse.d.ts +2 -0
- package/dist/types/review/review-turn.d.ts +6 -0
- package/dist/types/review/service/follow.d.ts +20 -2
- package/dist/types/review/service/launch.d.ts +6 -0
- package/dist/types/turn/progress/status-message.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2517,7 +2517,8 @@ var noMetrics = {
|
|
|
2517
2517
|
limited: () => void 0,
|
|
2518
2518
|
filesDropped: () => void 0,
|
|
2519
2519
|
probed: () => void 0,
|
|
2520
|
-
inboundRearmed: () => void 0
|
|
2520
|
+
inboundRearmed: () => void 0,
|
|
2521
|
+
outboundUndelivered: () => void 0
|
|
2521
2522
|
};
|
|
2522
2523
|
|
|
2523
2524
|
// packages/core/src/limits/inbound-stats.ts
|
|
@@ -7652,7 +7653,7 @@ ${line3}` : line3));
|
|
|
7652
7653
|
/**
|
|
7653
7654
|
* The chat went on below the stream while the turn runs (the person wrote again, or something else was said there): the stream's
|
|
7654
7655
|
* bubble stays where it opened, above all that. An answer begun in it and continued below would be read from its middle, its first
|
|
7655
|
-
* part out of sight (
|
|
7656
|
+
* part out of sight ("(cont. 2/2)" under a queued message's notice, part 1 above both). So nothing of the agent's goes
|
|
7656
7657
|
* into the bubble from now on: while it shows only a status, that floats on until the turn ends; one that shows words already is
|
|
7657
7658
|
* closed at once. Either way it ends with `line`, and the whole answer comes as messages of its own, below what was said since.
|
|
7658
7659
|
* When it comes while the answer is going out (its first part in the bubble already), the whole answer is sent again below.
|
|
@@ -9794,7 +9795,8 @@ function readOne(raw, followed) {
|
|
|
9794
9795
|
ignored: Array.isArray(ignored) ? ignored.filter((i) => typeof i === "string") : [],
|
|
9795
9796
|
mergeNeedsConfirmation: heldOf(row2),
|
|
9796
9797
|
queued: queuedOf(row2),
|
|
9797
|
-
mergeByRequester: row2["merge_by_requester"] === true
|
|
9798
|
+
mergeByRequester: row2["merge_by_requester"] === true,
|
|
9799
|
+
...row2["origin"] === "on_behalf" ? { origin: "on_behalf" } : {}
|
|
9798
9800
|
};
|
|
9799
9801
|
}
|
|
9800
9802
|
function parseStartedReviews(data, followed = true) {
|
|
@@ -22021,7 +22023,7 @@ var Deliveries = class {
|
|
|
22021
22023
|
* Claw's "on it" line for a turn that has already begun to answer: a say of the turn was delivered (or is being), or the
|
|
22022
22024
|
* receipt under the person's message is showing the reply's words. The line came late (it was decided before the answer,
|
|
22023
22025
|
* or the two crossed on the way here): it is dropped, never put in the receipt's place, where it would replace the words of
|
|
22024
|
-
* a reply that is being written or close it as if it were the answer (
|
|
22026
|
+
* a reply that is being written or close it as if it were the answer (0.3.0 acceptance: a refusal streamed into
|
|
22025
22027
|
* the receipt, the line closed it as "收到,我看一下。", and the refusal came as a message of its own).
|
|
22026
22028
|
*/
|
|
22027
22029
|
lateTurnAck(conversation, event) {
|
|
@@ -22895,7 +22897,7 @@ function githubConfirmButtons(confirmationId, review, lang = "zh") {
|
|
|
22895
22897
|
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.";
|
|
22896
22898
|
var REVIEW_MODES = {
|
|
22897
22899
|
high_risk_confirm: ["\u9AD8\u98CE\u9669\u4EBA\u5DE5\u518D\u786E\u8BA4\u4E00\u6B21\uFF08\u9ED8\u8BA4\uFF09", "A person confirms high-risk changes (default)"],
|
|
22898
|
-
// (not "nobody is asked": a repository that asks for a person still holds a merge under it, and
|
|
22900
|
+
// (not "nobody is asked": a repository that asks for a person still holds a merge under it, and now a review the person
|
|
22899
22901
|
// asks for in the chat merges unasked too)
|
|
22900
22902
|
fully_auto: [
|
|
22901
22903
|
"\u5168\u81EA\u52A8\u5408\u5165\uFF08\u4ED3\u5E93\u81EA\u8EAB\u8981\u6C42\u7684\u68C0\u67E5\u4ECD\u7136\u751F\u6548\uFF09",
|
|
@@ -22931,6 +22933,7 @@ function reviewTurn(fields2) {
|
|
|
22931
22933
|
forReviewer: false,
|
|
22932
22934
|
asItem: void 0,
|
|
22933
22935
|
ack: "",
|
|
22936
|
+
onBehalf: false,
|
|
22934
22937
|
...fields2
|
|
22935
22938
|
};
|
|
22936
22939
|
}
|
|
@@ -22966,7 +22969,8 @@ var FOLLOW_FIELDS = [
|
|
|
22966
22969
|
"reviewOnly:review_only",
|
|
22967
22970
|
"mergeHeld:merge_held",
|
|
22968
22971
|
"lang:lang",
|
|
22969
|
-
"where:where"
|
|
22972
|
+
"where:where",
|
|
22973
|
+
"onBehalf:on_behalf"
|
|
22970
22974
|
];
|
|
22971
22975
|
function followRecord(review, wire) {
|
|
22972
22976
|
if (review.item === void 0) throw new TypeError("a followed review has an item");
|
|
@@ -23003,6 +23007,7 @@ function reviewOfRecord(raw) {
|
|
|
23003
23007
|
mergeHeld: record6.merge_held === true,
|
|
23004
23008
|
lang: record6.lang === "en" ? "en" : "zh",
|
|
23005
23009
|
where: text7(record6.where),
|
|
23010
|
+
onBehalf: record6.on_behalf === true,
|
|
23006
23011
|
pull: pullRef2
|
|
23007
23012
|
});
|
|
23008
23013
|
review.item = {
|
|
@@ -23438,6 +23443,7 @@ function reviewAsk(fields2) {
|
|
|
23438
23443
|
unread: [],
|
|
23439
23444
|
merge: true,
|
|
23440
23445
|
handoffId: "",
|
|
23446
|
+
origin: "",
|
|
23441
23447
|
...fields2
|
|
23442
23448
|
};
|
|
23443
23449
|
}
|
|
@@ -24929,7 +24935,8 @@ function stageVerdict(stage) {
|
|
|
24929
24935
|
if (parts2[0] === "end") return parts2[2] ?? "";
|
|
24930
24936
|
return (parts2[0] === "wait" || parts2[0] === "verdict") && parts2.length > 1 ? parts2[1] ?? "" : "";
|
|
24931
24937
|
}
|
|
24932
|
-
function isNewsStage(stage) {
|
|
24938
|
+
function isNewsStage(stage, onBehalf = false) {
|
|
24939
|
+
if (onBehalf) return stage === "failed";
|
|
24933
24940
|
const [kind, verdict] = stage.split(":");
|
|
24934
24941
|
if (kind === "end" || kind === "failed" || kind === "wait") return true;
|
|
24935
24942
|
return kind === "verdict" && (verdict === "request_changes" || verdict === "comment");
|
|
@@ -25006,6 +25013,7 @@ var REQUESTER_VIEW_LIMIT_SECONDS = 24 * 3600;
|
|
|
25006
25013
|
var VIEW_SETTLE_MS = 9e4;
|
|
25007
25014
|
var VIEW_HOLD_MS = 6e5;
|
|
25008
25015
|
var DEADLINE_TRIES = 10;
|
|
25016
|
+
var DEADLINE_GRACE_SECONDS = 3600;
|
|
25009
25017
|
function waitsNewly(entry, view7) {
|
|
25010
25018
|
return viewWaitsForReviewer(view7) && view7.waitingFor !== "failed" && !entry.reviewerTold;
|
|
25011
25019
|
}
|
|
@@ -25117,27 +25125,36 @@ var AskerFollow = class {
|
|
|
25117
25125
|
first: 0,
|
|
25118
25126
|
last: 0
|
|
25119
25127
|
};
|
|
25128
|
+
const end = deadline + DEADLINE_GRACE_SECONDS;
|
|
25120
25129
|
let tries = 0;
|
|
25130
|
+
let readAtDeadline = false;
|
|
25131
|
+
let readTried = false;
|
|
25121
25132
|
try {
|
|
25122
25133
|
while (state.open.size || state.news.size) {
|
|
25123
25134
|
if (!state.open.size) {
|
|
25124
25135
|
await this.deps.clock.sleep(this.viewMs);
|
|
25125
|
-
if (!await this.tryFlush(entries, conversation, state))
|
|
25126
|
-
|
|
25136
|
+
if (!await this.tryFlush(entries, conversation, state)) {
|
|
25137
|
+
tries += 1;
|
|
25138
|
+
if (tries >= DEADLINE_TRIES || this.deps.store.now() >= end) {
|
|
25139
|
+
if (this.deps.store.now() >= deadline) this.letGo(entries);
|
|
25140
|
+
return;
|
|
25141
|
+
}
|
|
25142
|
+
}
|
|
25127
25143
|
continue;
|
|
25128
25144
|
}
|
|
25129
|
-
|
|
25130
|
-
|
|
25145
|
+
const now = this.deps.store.now();
|
|
25146
|
+
if (now >= deadline) {
|
|
25147
|
+
if (!readAtDeadline && (!readTried || now < end)) {
|
|
25148
|
+
readTried = true;
|
|
25149
|
+
readAtDeadline = await this.safeRound(entries, conversation, state);
|
|
25150
|
+
if (!readAtDeadline) await this.deps.clock.sleep(this.viewMs);
|
|
25151
|
+
continue;
|
|
25152
|
+
}
|
|
25153
|
+
if (await this.atDeadline(entries, conversation, state, ++tries, end)) return;
|
|
25131
25154
|
continue;
|
|
25132
25155
|
}
|
|
25133
25156
|
await this.deps.clock.sleep(this.viewMs);
|
|
25134
|
-
|
|
25135
|
-
await this.round(entries, conversation, state);
|
|
25136
|
-
} catch (err2) {
|
|
25137
|
-
this.deps.logger.warn("a round of following a request's reviews for their asker failed", {
|
|
25138
|
-
error: errorName(err2)
|
|
25139
|
-
});
|
|
25140
|
-
}
|
|
25157
|
+
await this.safeRound(entries, conversation, state);
|
|
25141
25158
|
}
|
|
25142
25159
|
} finally {
|
|
25143
25160
|
for (const entry of entries) {
|
|
@@ -25151,14 +25168,17 @@ var AskerFollow = class {
|
|
|
25151
25168
|
await this.flush(entries, conversation, state);
|
|
25152
25169
|
return true;
|
|
25153
25170
|
} catch (err2) {
|
|
25154
|
-
this.deps.logger.warn("
|
|
25171
|
+
this.deps.logger.warn("what a request's reviews have to tell could not be said to their asker", {
|
|
25155
25172
|
error: errorName(err2)
|
|
25156
25173
|
});
|
|
25157
25174
|
return false;
|
|
25158
25175
|
}
|
|
25159
25176
|
}
|
|
25160
|
-
/**
|
|
25161
|
-
|
|
25177
|
+
/**
|
|
25178
|
+
* The deadline: what is held is said, then that the rest is still open; the rows go once the asker has been told (or the tries ran out, or
|
|
25179
|
+
* `end` came).
|
|
25180
|
+
*/
|
|
25181
|
+
async atDeadline(entries, conversation, state, tries, end) {
|
|
25162
25182
|
const left = [...state.open.values()];
|
|
25163
25183
|
try {
|
|
25164
25184
|
if (state.news.size) await this.flush(entries, conversation, state);
|
|
@@ -25166,14 +25186,18 @@ var AskerFollow = class {
|
|
|
25166
25186
|
if (first !== void 0) await this.sayToAsker(first.review, conversation, unfinishedText(left));
|
|
25167
25187
|
} catch (err2) {
|
|
25168
25188
|
this.deps.logger.warn("the asker could not be told their reviews are still open", { error: errorName(err2) });
|
|
25169
|
-
if (tries < DEADLINE_TRIES) {
|
|
25189
|
+
if (tries < DEADLINE_TRIES && this.deps.store.now() < end) {
|
|
25170
25190
|
await this.deps.clock.sleep(this.viewMs);
|
|
25171
25191
|
return false;
|
|
25172
25192
|
}
|
|
25173
25193
|
}
|
|
25174
|
-
|
|
25194
|
+
this.letGo(entries);
|
|
25175
25195
|
return true;
|
|
25176
25196
|
}
|
|
25197
|
+
/** The follow is over: none of its rows is kept. */
|
|
25198
|
+
letGo(entries) {
|
|
25199
|
+
for (const entry of entries) this.deps.store.reviewDelegation.dropAskerFollow(followedItemId(entry));
|
|
25200
|
+
}
|
|
25177
25201
|
/** The asker's view of one item now; undefined when it is not followed any more, "running" for a moment's trouble. */
|
|
25178
25202
|
async viewOf(entry, state) {
|
|
25179
25203
|
const itemId = followedItemId(entry);
|
|
@@ -25198,8 +25222,24 @@ var AskerFollow = class {
|
|
|
25198
25222
|
return "trouble";
|
|
25199
25223
|
}
|
|
25200
25224
|
}
|
|
25225
|
+
/** One round, never the end of the follow (the items run in Claw all the same); false when a view could not be read or the round failed. */
|
|
25226
|
+
async safeRound(entries, conversation, state) {
|
|
25227
|
+
try {
|
|
25228
|
+
return await this.round(entries, conversation, state);
|
|
25229
|
+
} catch (err2) {
|
|
25230
|
+
this.deps.logger.warn("a round of following a request's reviews for their asker failed", {
|
|
25231
|
+
error: errorName(err2)
|
|
25232
|
+
});
|
|
25233
|
+
return false;
|
|
25234
|
+
}
|
|
25235
|
+
}
|
|
25236
|
+
/**
|
|
25237
|
+
* Reads each open item's view and says what is due; false when a view could not be read just now (a moment's trouble). Only that: news
|
|
25238
|
+
* that could not be said (a chat that is gone) is held for the next round and leaves the views as read as they were.
|
|
25239
|
+
*/
|
|
25201
25240
|
async round(entries, conversation, state) {
|
|
25202
25241
|
let running = false;
|
|
25242
|
+
let read = true;
|
|
25203
25243
|
const waiting = [];
|
|
25204
25244
|
for (const entry of [...state.open.values()]) {
|
|
25205
25245
|
if (await this.endStopped(entry, state)) continue;
|
|
@@ -25207,6 +25247,7 @@ var AskerFollow = class {
|
|
|
25207
25247
|
if (view7 === "gone") continue;
|
|
25208
25248
|
if (view7 === "trouble") {
|
|
25209
25249
|
running = true;
|
|
25250
|
+
read = false;
|
|
25210
25251
|
continue;
|
|
25211
25252
|
}
|
|
25212
25253
|
if (waitsNewly(entry, view7)) waiting.push([entry, view7.prSummary]);
|
|
@@ -25220,7 +25261,8 @@ var AskerFollow = class {
|
|
|
25220
25261
|
}
|
|
25221
25262
|
const now = this.deps.clock.monotonicMs();
|
|
25222
25263
|
const due = !running || !state.open.size || now - state.last >= VIEW_SETTLE_MS || now - state.first >= VIEW_HOLD_MS;
|
|
25223
|
-
if (state.news.size && due) await this.
|
|
25264
|
+
if (state.news.size && due) await this.tryFlush(entries, conversation, state);
|
|
25265
|
+
return read;
|
|
25224
25266
|
}
|
|
25225
25267
|
/** An item the asker stopped on its card: that card is left as the press made it, and said there. */
|
|
25226
25268
|
async endStopped(entry, state) {
|
|
@@ -25254,7 +25296,7 @@ var AskerFollow = class {
|
|
|
25254
25296
|
const itemId = followedItemId(entry);
|
|
25255
25297
|
const stage = entryStage(entry, view7);
|
|
25256
25298
|
const held = state.news.get(itemId);
|
|
25257
|
-
if (stage && stage !== entry.said && !isNewsStage(stage)) {
|
|
25299
|
+
if (stage && stage !== entry.said && !isNewsStage(stage, entry.review.onBehalf)) {
|
|
25258
25300
|
state.news.delete(itemId);
|
|
25259
25301
|
entry.said = stage;
|
|
25260
25302
|
this.deps.store.reviewDelegation.askerFollowSaid(itemId, stage);
|
|
@@ -25640,6 +25682,7 @@ var ReviewItems = class {
|
|
|
25640
25682
|
review.modelReported = true;
|
|
25641
25683
|
}
|
|
25642
25684
|
review.forReviewer = Boolean(request.actingToken);
|
|
25685
|
+
review.onBehalf = review.onBehalf === true && one.origin === "on_behalf";
|
|
25643
25686
|
taken.push(review);
|
|
25644
25687
|
}
|
|
25645
25688
|
return taken;
|
|
@@ -25724,8 +25767,11 @@ function markHeld(reviews, handedOver) {
|
|
|
25724
25767
|
review.mergeHeld = told === true || told === null && review.item !== void 0 && handedOver;
|
|
25725
25768
|
}
|
|
25726
25769
|
}
|
|
25770
|
+
function summedUp(review) {
|
|
25771
|
+
return review.onBehalf === true && review.item !== void 0;
|
|
25772
|
+
}
|
|
25727
25773
|
function stopHint(reviews, group) {
|
|
25728
|
-
if (!reviews.some((r) => r.item !== void 0)) return "";
|
|
25774
|
+
if (!reviews.some((r) => r.item !== void 0) || reviews.every(summedUp)) return "";
|
|
25729
25775
|
return group ? reviewStartText.stopInGroup : reviewStartText.stopHere;
|
|
25730
25776
|
}
|
|
25731
25777
|
var ReviewLaunch = class {
|
|
@@ -25750,7 +25796,8 @@ var ReviewLaunch = class {
|
|
|
25750
25796
|
async launch(s, held, handed) {
|
|
25751
25797
|
const who = s.actor.name || "\u5BF9\u65B9";
|
|
25752
25798
|
const readAs = reviewStartText.readAs(s.ask.repo);
|
|
25753
|
-
|
|
25799
|
+
const unreadNumbers = s.ask.unread.length ? reviewStartText.unreadNumbers(s.ask.unread.map((n) => `#${String(n)}`).join("\u3001")) : "";
|
|
25800
|
+
let unread = unreadNumbers;
|
|
25754
25801
|
const reviewerMode = s.reviews.length ? await modeOf(this.deps, s.actor.userId) : "";
|
|
25755
25802
|
for (const review of s.reviews) review.reviewMode = isReviewMode(reviewerMode) ? reviewerMode : DEFAULT_MODE;
|
|
25756
25803
|
let reviews = s.reviews;
|
|
@@ -25772,7 +25819,7 @@ var ReviewLaunch = class {
|
|
|
25772
25819
|
await this.postCards(s, carded);
|
|
25773
25820
|
return;
|
|
25774
25821
|
}
|
|
25775
|
-
await this.acknowledge(s, reviews, readAs, unread, reviewerMode === "fully_auto");
|
|
25822
|
+
await this.acknowledge(s, reviews, readAs, unread, reviewerMode === "fully_auto", unreadNumbers !== "");
|
|
25776
25823
|
await this.run(s, reviews, handed);
|
|
25777
25824
|
await this.postCards(s, carded);
|
|
25778
25825
|
}
|
|
@@ -25839,7 +25886,7 @@ var ReviewLaunch = class {
|
|
|
25839
25886
|
await say2(this.deps, s.ctx.conversation, text9);
|
|
25840
25887
|
}
|
|
25841
25888
|
/** The acknowledgement: one message for several reviews, else at the top of the review's progress message. */
|
|
25842
|
-
async acknowledge(s, reviews, readAs, unread, auto) {
|
|
25889
|
+
async acknowledge(s, reviews, readAs, unread, auto, numbersLeftOut) {
|
|
25843
25890
|
const who = s.actor.name || "\u5BF9\u65B9";
|
|
25844
25891
|
const [first] = reviews;
|
|
25845
25892
|
if (first === void 0) return;
|
|
@@ -25849,6 +25896,7 @@ var ReviewLaunch = class {
|
|
|
25849
25896
|
reviews.find((r) => r.forReviewer),
|
|
25850
25897
|
s.ctx.conversation.caps.shortName
|
|
25851
25898
|
);
|
|
25899
|
+
if (reviews.every(summedUp) && !this.needsWords(s, reviews, numbersLeftOut || reach !== "")) return;
|
|
25852
25900
|
const setting = [mergeLine(reviews, who, s.ask.merge, auto), reach].filter(Boolean).join("\n\n");
|
|
25853
25901
|
const stop = stopHint(reviews, s.ctx.group);
|
|
25854
25902
|
const verb = s.ask.merge ? "review \u5408\u5165" : "review\uFF08\u53EA review\uFF0C\u4E0D\u5408\u5165\uFF09";
|
|
@@ -25865,6 +25913,14 @@ var ReviewLaunch = class {
|
|
|
25865
25913
|
first.ack = reviewStartText.single(readAs, who, verb, shortName(first.pull), note) + chosen + setting + unread + stop;
|
|
25866
25914
|
}
|
|
25867
25915
|
}
|
|
25916
|
+
/**
|
|
25917
|
+
* Whether the receipt of a request the person's coordinator sent for them says anything: Claw sums up how it ended, so only what they
|
|
25918
|
+
* must act on is said: a review that waits for a slot, one that did not start, a number that was not read as a pull request, and a
|
|
25919
|
+
* reviewer who cannot be reached for a confirmation (`other`).
|
|
25920
|
+
*/
|
|
25921
|
+
needsWords(s, reviews, other) {
|
|
25922
|
+
return other || s.refused.length > 0 || reviews.some((r) => r.item?.queued);
|
|
25923
|
+
}
|
|
25868
25924
|
severalText(s, reviews, p) {
|
|
25869
25925
|
const lined = reviews.some((r) => r.item?.queued);
|
|
25870
25926
|
const head = reviewStartText.several({
|
|
@@ -25985,6 +26041,7 @@ ${p.setting}` : "") + refused3 + p.unread + p.stop;
|
|
|
25985
26041
|
}
|
|
25986
26042
|
/** The cards with Stop, in the asker's own chat (a group's request too). */
|
|
25987
26043
|
async postCards(s, reviews) {
|
|
26044
|
+
if (reviews.every(summedUp)) return;
|
|
25988
26045
|
if (!reviews.some((r) => r.item !== void 0)) return;
|
|
25989
26046
|
let target = s.ctx.conversation;
|
|
25990
26047
|
if (s.ctx.group) {
|
|
@@ -26280,6 +26337,7 @@ function keptOf(row2) {
|
|
|
26280
26337
|
models: Array.isArray(r.models) ? r.models.filter((m) => typeof m === "string" && m !== "") : [],
|
|
26281
26338
|
note: str6(r.note),
|
|
26282
26339
|
handoffId: str6(r.handoffId),
|
|
26340
|
+
origin: r.origin === "on_behalf" ? "on_behalf" : "",
|
|
26283
26341
|
askedAt: typeof r.askedAt === "number" ? r.askedAt : 0,
|
|
26284
26342
|
asked: asked3,
|
|
26285
26343
|
group: r.group === true,
|
|
@@ -26356,6 +26414,7 @@ var ReviewerOnboarding = class {
|
|
|
26356
26414
|
models: [...ask3.models],
|
|
26357
26415
|
note: ctx.text,
|
|
26358
26416
|
handoffId: ask3.handoffId,
|
|
26417
|
+
origin: ask3.origin,
|
|
26359
26418
|
askedAt: epochSeconds(this.deps.clock),
|
|
26360
26419
|
asked: ctx.conversation.ref.wire,
|
|
26361
26420
|
group: ctx.group,
|
|
@@ -26628,7 +26687,9 @@ var ReviewerOnboarding = class {
|
|
|
26628
26687
|
merge: kept.merge,
|
|
26629
26688
|
models: kept.models,
|
|
26630
26689
|
named: [kept.actor.channelUserId],
|
|
26631
|
-
handoffId: fresh ? kept.handoffId : ""
|
|
26690
|
+
handoffId: fresh ? kept.handoffId : "",
|
|
26691
|
+
// (it is Claw's record of the handoff that says where the request came from: an ask without it is an ordinary one)
|
|
26692
|
+
origin: fresh ? kept.origin : ""
|
|
26632
26693
|
});
|
|
26633
26694
|
const message = {
|
|
26634
26695
|
type: "message",
|
|
@@ -27312,7 +27373,8 @@ var ReviewChecks = class {
|
|
|
27312
27373
|
fromGroup: ctx.group,
|
|
27313
27374
|
lang: pickLang(ctx.text),
|
|
27314
27375
|
reviewOnly: !ask3.merge,
|
|
27315
|
-
actorLogin: state.login
|
|
27376
|
+
actorLogin: state.login,
|
|
27377
|
+
onBehalf: ask3.origin === "on_behalf"
|
|
27316
27378
|
});
|
|
27317
27379
|
reviews.push(review);
|
|
27318
27380
|
tickets.set(review, ticket);
|
|
@@ -27680,7 +27742,8 @@ var GithubReview = class {
|
|
|
27680
27742
|
pulls: handoff.pulls,
|
|
27681
27743
|
merge: handoff.merge,
|
|
27682
27744
|
named: [channelUserId],
|
|
27683
|
-
handoffId: handoff.handoffId
|
|
27745
|
+
handoffId: handoff.handoffId,
|
|
27746
|
+
origin: handoff.origin ?? ""
|
|
27684
27747
|
});
|
|
27685
27748
|
const ctx = {
|
|
27686
27749
|
message,
|
|
@@ -27884,7 +27947,9 @@ var handoffSchema = z7.object({
|
|
|
27884
27947
|
merge: z7.boolean(),
|
|
27885
27948
|
requester_note: z7.string().optional().default(""),
|
|
27886
27949
|
handoff_id: z7.string().max(128).optional().default(""),
|
|
27887
|
-
held_says: z7.array(z7.string()).optional().default([])
|
|
27950
|
+
held_says: z7.array(z7.string()).optional().default([]),
|
|
27951
|
+
// (read as what it is, never refused for its value: an optional field a later Claw may widen)
|
|
27952
|
+
origin: z7.unknown().optional()
|
|
27888
27953
|
});
|
|
27889
27954
|
function parseReviewHandoff(raw) {
|
|
27890
27955
|
const parsed = handoffSchema.safeParse(raw);
|
|
@@ -27905,7 +27970,8 @@ function parseReviewHandoff(raw) {
|
|
|
27905
27970
|
merge: data.merge,
|
|
27906
27971
|
note: cpHead(pyStrip(data.requester_note), REQUESTER_NOTE_MAX),
|
|
27907
27972
|
handoffId: pyStrip(data.handoff_id),
|
|
27908
|
-
said: said2
|
|
27973
|
+
said: said2,
|
|
27974
|
+
origin: data.origin === "on_behalf" ? "on_behalf" : ""
|
|
27909
27975
|
};
|
|
27910
27976
|
}
|
|
27911
27977
|
|
|
@@ -31257,7 +31323,7 @@ var StatusBoard = class {
|
|
|
31257
31323
|
/**
|
|
31258
31324
|
* A chat that is the agent's window itself has just asked for a new session: one line says what starts where. Nothing says the
|
|
31259
31325
|
* chat's messages go there yet: that is said once the agent has started (`sayEntered`), and a session that cannot start says
|
|
31260
|
-
* that the messages still go to the bot (
|
|
31326
|
+
* that the messages still go to the bot ("now go to" said before a start that failed, then taken back).
|
|
31261
31327
|
*/
|
|
31262
31328
|
async sayStarting(chatKey, to, state) {
|
|
31263
31329
|
const words3 = remoteAgentText.in(this.state.lang(chatKey));
|
|
@@ -34041,7 +34107,7 @@ var FollowControl = class {
|
|
|
34041
34107
|
/**
|
|
34042
34108
|
* A conversation open in a terminal, watched or typed into: what is typed there is answered there, with no turn of the phone's to
|
|
34043
34109
|
* end it, so its reply is told after a few quiet seconds, as a watch's is. With the half-minute of a session of the phone's own it
|
|
34044
|
-
* came after the person had left (
|
|
34110
|
+
* came after the person had left (a guide re-check: nothing within 20 s, although the card says replies show up here).
|
|
34045
34111
|
* Read each time they are used: a worker that restarted learns only after its reader started whether the session is a terminal's
|
|
34046
34112
|
* (`resume`).
|
|
34047
34113
|
*/
|
|
@@ -104,6 +104,11 @@ export interface ReviewStart {
|
|
|
104
104
|
readonly queued: string;
|
|
105
105
|
/** The reviewer's account merges it; when the reviewer cannot merge, Claw asks the asker whether their own account merges it. */
|
|
106
106
|
readonly mergeByRequester: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* `on_behalf`: Claw recorded the review as sent for the asker by their coordinator and sums up how it ended for them, so it is not pushed
|
|
109
|
+
* to them stage by stage. Absent: Claw does not say so (an older Claw, or a review the person asked), and it is told as any review is.
|
|
110
|
+
*/
|
|
111
|
+
readonly origin?: "on_behalf";
|
|
107
112
|
}
|
|
108
113
|
/** Which GitHub token Claw's GitHub tools use for the token's own user now (never the token). */
|
|
109
114
|
export interface GithubConnection {
|
|
@@ -24,6 +24,8 @@ export interface MetricsPort {
|
|
|
24
24
|
probed?(feedbackMs: number, replyMs: number | null): void;
|
|
25
25
|
/** A receiver of the surface's inbound queue whose call on the broker hung was dropped and taken again (optional). */
|
|
26
26
|
inboundRearmed?(): void;
|
|
27
|
+
/** A message a surface posts to its chat directly was not confirmed as delivered and was thrown to the sender (optional). */
|
|
28
|
+
outboundUndelivered?(): void;
|
|
27
29
|
}
|
|
28
30
|
/** Metrics that go nowhere: the default where a caller passes none. */
|
|
29
31
|
export declare const noMetrics: MetricsPort;
|
|
@@ -36,7 +36,7 @@ export declare class Deliveries {
|
|
|
36
36
|
* Claw's "on it" line for a turn that has already begun to answer: a say of the turn was delivered (or is being), or the
|
|
37
37
|
* receipt under the person's message is showing the reply's words. The line came late (it was decided before the answer,
|
|
38
38
|
* or the two crossed on the way here): it is dropped, never put in the receipt's place, where it would replace the words of
|
|
39
|
-
* a reply that is being written or close it as if it were the answer (
|
|
39
|
+
* a reply that is being written or close it as if it were the answer (0.3.0 acceptance: a refusal streamed into
|
|
40
40
|
* the receipt, the line closed it as "收到,我看一下。", and the refusal came as a message of its own).
|
|
41
41
|
*/
|
|
42
42
|
private lateTurnAck;
|
|
@@ -384,6 +384,14 @@ export interface AssistantReviewHandoff {
|
|
|
384
384
|
}>;
|
|
385
385
|
merge: boolean;
|
|
386
386
|
requester_note: string;
|
|
387
|
+
/**
|
|
388
|
+
* Where the person's message came from, when it was not typed by them: `on_behalf`, a message their coordinator posted into their own
|
|
389
|
+
* chat for them (`channel_context.via` of the message, which Claw keeps in a closed set). The channel then does not push the person the
|
|
390
|
+
* stages of the review (its receipt, its card, its progress): Claw sums its end up for them (`review-digest.ts`), and a failure and a
|
|
391
|
+
* conflict still reach them at once. Absent for a message the person typed, and from a Claw that does not say; a value this field does
|
|
392
|
+
* not know is read as absent.
|
|
393
|
+
*/
|
|
394
|
+
origin?: "on_behalf";
|
|
387
395
|
/**
|
|
388
396
|
* What the router said in the same turn before handing the review over (another question of the person's answered), in order. Held
|
|
389
397
|
* and never delivered on its own (`say-hold.ts`), so the channel's one answer carries it: the channel adds it to that answer. Absent
|
|
@@ -20,6 +20,12 @@ export interface StartedReview {
|
|
|
20
20
|
pr: PrRef;
|
|
21
21
|
/** The turn id of the session's first message (`claw-pending-<id>`), for a caller that follows that turn's stream. */
|
|
22
22
|
message_id: string | null;
|
|
23
|
+
/**
|
|
24
|
+
* Present on a review asked of someone else that Claw recorded as sent for the asker by their coordinator (`origin: "on_behalf"` on the
|
|
25
|
+
* handoff it was started from): Claw sums up how it ended for the asker (`review-digest.ts`), so the channel need not push them its stages.
|
|
26
|
+
* A channel goes quiet only for an item that says so: an older Claw does not, and neither does a request that names no such handoff.
|
|
27
|
+
*/
|
|
28
|
+
origin?: "on_behalf";
|
|
23
29
|
/** What the request named that the review does not take (a review asked of someone else runs on their settings). */
|
|
24
30
|
ignored?: Array<"model" | "effort">;
|
|
25
31
|
/** The review never merges. */
|
|
@@ -98,7 +98,7 @@ export declare class StatusBoard {
|
|
|
98
98
|
/**
|
|
99
99
|
* A chat that is the agent's window itself has just asked for a new session: one line says what starts where. Nothing says the
|
|
100
100
|
* chat's messages go there yet: that is said once the agent has started (`sayEntered`), and a session that cannot start says
|
|
101
|
-
* that the messages still go to the bot (
|
|
101
|
+
* that the messages still go to the bot ("now go to" said before a start that failed, then taken back).
|
|
102
102
|
*/
|
|
103
103
|
sayStarting(chatKey: string, to: Conversation, state: RemoteState): Promise<void>;
|
|
104
104
|
/**
|
|
@@ -27,7 +27,7 @@ export declare class FollowControl {
|
|
|
27
27
|
/**
|
|
28
28
|
* A conversation open in a terminal, watched or typed into: what is typed there is answered there, with no turn of the phone's to
|
|
29
29
|
* end it, so its reply is told after a few quiet seconds, as a watch's is. With the half-minute of a session of the phone's own it
|
|
30
|
-
* came after the person had left (
|
|
30
|
+
* came after the person had left (a guide re-check: nothing within 20 s, although the card says replies show up here).
|
|
31
31
|
* Read each time they are used: a worker that restarted learns only after its reader started whether the session is a terminal's
|
|
32
32
|
* (`resume`).
|
|
33
33
|
*/
|
|
@@ -37,7 +37,7 @@ export declare const TYPED_CHARS_MAX = 4000;
|
|
|
37
37
|
export declare function typedLine(text: string, lang: Lang): string;
|
|
38
38
|
/**
|
|
39
39
|
* Teams' floating status (an informative update) is cut on a phone after a few characters. Microsoft documents only an upper
|
|
40
|
-
* bound (1000 characters) and no display width; the one measurement is a phone
|
|
40
|
+
* bound (1000 characters) and no display width; the one measurement is a phone, which showed four Chinese
|
|
41
41
|
* characters after the icon. So a line saying why a message still waits for its terminal is at most WAIT_LINE_MAX_ZH code points
|
|
42
42
|
* in Chinese and WAIT_LINE_MAX_EN in English, the "⏳ " included.
|
|
43
43
|
*/
|
|
@@ -42,7 +42,7 @@ export declare class RemoteStatusPolicy implements StatusPolicy<RemoteStep> {
|
|
|
42
42
|
* first run of backticks that no later run of the same length closes, and what follows it. Streamed, such a backtick is shown as a
|
|
43
43
|
* look-alike (`inertAnswer`: one the rich text cannot pair), and once the agent closes the span it is a backtick again: the text no
|
|
44
44
|
* longer begins with what the bubble shows, so the bubble ends on that lone character and the answer follows as a message of its own
|
|
45
|
-
* (
|
|
45
|
+
* (a guide re-check: a reply that began with `` `hook.txt` `` ended its bubble on "ˋ"). Escaped backticks open nothing.
|
|
46
46
|
*/
|
|
47
47
|
export declare function withoutOpenCode(text: string): string;
|
|
48
48
|
/** The turn shown in the chat (a stream, else a progress message), as a `TurnDisplay`. */
|
|
@@ -17,6 +17,12 @@ export interface ReviewHandoff {
|
|
|
17
17
|
readonly handoffId: string;
|
|
18
18
|
/** What the assistant said in the same turn before handing this over: the answer to the handoff carries it. */
|
|
19
19
|
readonly said: readonly string[];
|
|
20
|
+
/**
|
|
21
|
+
* `on_behalf`: the person's coordinator posted the message for them (`channel_context.via`), so the review's stages are not pushed to
|
|
22
|
+
* them: Claw sums up how it ended, and a failure still comes at once. '' for a message the person typed, from a Claw that does not say,
|
|
23
|
+
* and for a value this worker does not know. Optional in the type (it is exported): what builds a handoff itself need not say.
|
|
24
|
+
*/
|
|
25
|
+
readonly origin?: "on_behalf" | "";
|
|
20
26
|
}
|
|
21
27
|
/** The `review` of an `assistant.action`, or undefined when it is not one in every field. */
|
|
22
28
|
export declare function parseReviewHandoff(raw: unknown): ReviewHandoff | undefined;
|
|
@@ -41,9 +41,9 @@ export declare function stageVerdict(stage: string): string;
|
|
|
41
41
|
* Whether a change of the view is news to the asker, told at once: an end, a failure, a wait for the reviewer, and a conclusion that
|
|
42
42
|
* needs the author's hands (changes requested, a comment). Not news: that the review waits for a slot, that it started, and an approval
|
|
43
43
|
* that is not merged yet, which the end's line carries within minutes; a review may wait a day for CI, and the conclusions that ask
|
|
44
|
-
* something of the author are told as they come.
|
|
44
|
+
* something of the author are told as they come. For a request the person's coordinator sent for them (`onBehalf`), only a failure is.
|
|
45
45
|
*/
|
|
46
|
-
export declare function isNewsStage(stage: string): boolean;
|
|
46
|
+
export declare function isNewsStage(stage: string, onBehalf?: boolean): boolean;
|
|
47
47
|
/** How a review someone else runs stands, as its asker is told. `started`: it waited for a slot, and has just started. */
|
|
48
48
|
export declare function progressWords(review: ReviewTurn, view: AskerView, started?: boolean): string;
|
|
49
49
|
/**
|
|
@@ -40,7 +40,7 @@ export declare function modelChosenNote(review: ReviewTurn, who: string, asked:
|
|
|
40
40
|
* What the receipt says of how the merges will be made: only what the reviews started say. A review asked of someone else is merged
|
|
41
41
|
* with that reviewer's account once they approve, said plainly, with "they confirm it first" when its merge waits for them; the
|
|
42
42
|
* reviewer's fully automatic setting is said; and when Claw may put the merge to the asker (`mergeByRequester`), that the asker is
|
|
43
|
-
* asked first, only when the reviewer has no permission to merge. Nothing is merged with the asker's account unasked
|
|
44
|
-
*
|
|
43
|
+
* asked first, only when the reviewer has no permission to merge. Nothing is merged with the asker's account unasked.
|
|
44
|
+
* One's own review says only whether its merge waits for one's own confirmation. '' when there is nothing to say.
|
|
45
45
|
*/
|
|
46
46
|
export declare function mergeLine(reviews: readonly ReviewTurn[], who: string, merge: boolean, auto: boolean): string;
|
|
@@ -21,6 +21,8 @@ export interface ReviewAsk {
|
|
|
21
21
|
readonly merge: boolean;
|
|
22
22
|
/** The record Claw kept of a review the assistant handed back; '' for a typed request. */
|
|
23
23
|
readonly handoffId: string;
|
|
24
|
+
/** `on_behalf`: a handed-back review the person's coordinator sent for them (`ReviewHandoff.origin`); '' otherwise. */
|
|
25
|
+
readonly origin: "on_behalf" | "";
|
|
24
26
|
}
|
|
25
27
|
export declare function reviewAsk(fields: Partial<ReviewAsk> & Pick<ReviewAsk, "who" | "pulls">): ReviewAsk;
|
|
26
28
|
/**
|
|
@@ -59,6 +59,12 @@ export interface ReviewTurn {
|
|
|
59
59
|
asItem: (() => Promise<boolean>) | undefined;
|
|
60
60
|
/** The acknowledgement shown at the top of the review's progress message ('' nothing to acknowledge). */
|
|
61
61
|
ack: string;
|
|
62
|
+
/**
|
|
63
|
+
* The person's coordinator sent the request for them (`ReviewHandoff.origin`) and Claw says it recorded that (`ReviewStart.origin`): its
|
|
64
|
+
* receipt, its card and its progress are not pushed to them, Claw sums up how it ended; a failure still comes at once. Kept with the follow, so a restart of the worker keeps it. Optional in
|
|
65
|
+
* the type (it is exported): absent is false.
|
|
66
|
+
*/
|
|
67
|
+
onBehalf?: boolean;
|
|
62
68
|
}
|
|
63
69
|
export type NewReviewTurn = Pick<ReviewTurn, "requesterId" | "requesterName" | "actorId" | "actorUserId" | "actorName" | "actorChannelId" | "pull"> & Partial<ReviewTurn>;
|
|
64
70
|
export declare function reviewTurn(fields: NewReviewTurn): ReviewTurn;
|
|
@@ -9,8 +9,15 @@ export declare const REQUESTER_VIEW_LIMIT_SECONDS: number;
|
|
|
9
9
|
/** News is held this long for more to join it, at most this long in all. */
|
|
10
10
|
export declare const VIEW_SETTLE_MS = 90000;
|
|
11
11
|
export declare const VIEW_HOLD_MS = 600000;
|
|
12
|
-
/** How often a last line is tried before it is left (to the next worker that starts). */
|
|
12
|
+
/** How often a last line is tried before it is left (to the next worker that starts; at the deadline the rows go all the same). */
|
|
13
13
|
export declare const DEADLINE_TRIES = 10;
|
|
14
|
+
/**
|
|
15
|
+
* How long past its deadline (the stored one, so that a restart of the worker does not start it again) a follow goes on trying while Claw
|
|
16
|
+
* cannot answer a read or the chat refuses a line: then the rest is said to be open (or not, if nothing could be said) and the rows go, so
|
|
17
|
+
* that no follow outlives its deadline by more than this and a worker's own count of tries, whatever its restarts do. A worker that starts
|
|
18
|
+
* after it reads once and tries to say once more.
|
|
19
|
+
*/
|
|
20
|
+
export declare const DEADLINE_GRACE_SECONDS = 3600;
|
|
14
21
|
export declare class AskerFollow {
|
|
15
22
|
private readonly deps;
|
|
16
23
|
private readonly cards;
|
|
@@ -37,10 +44,21 @@ export declare class AskerFollow {
|
|
|
37
44
|
/** Reads each open item's view every `viewMs`; news is held a little, then said in one message. */
|
|
38
45
|
private watch;
|
|
39
46
|
private tryFlush;
|
|
40
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* The deadline: what is held is said, then that the rest is still open; the rows go once the asker has been told (or the tries ran out, or
|
|
49
|
+
* `end` came).
|
|
50
|
+
*/
|
|
41
51
|
private atDeadline;
|
|
52
|
+
/** The follow is over: none of its rows is kept. */
|
|
53
|
+
private letGo;
|
|
42
54
|
/** The asker's view of one item now; undefined when it is not followed any more, "running" for a moment's trouble. */
|
|
43
55
|
private viewOf;
|
|
56
|
+
/** One round, never the end of the follow (the items run in Claw all the same); false when a view could not be read or the round failed. */
|
|
57
|
+
private safeRound;
|
|
58
|
+
/**
|
|
59
|
+
* Reads each open item's view and says what is due; false when a view could not be read just now (a moment's trouble). Only that: news
|
|
60
|
+
* that could not be said (a chat that is gone) is held for the next round and leaves the views as read as they were.
|
|
61
|
+
*/
|
|
44
62
|
private round;
|
|
45
63
|
/** An item the asker stopped on its card: that card is left as the press made it, and said there. */
|
|
46
64
|
private endStopped;
|
|
@@ -23,6 +23,12 @@ export declare class ReviewLaunch {
|
|
|
23
23
|
private nothingStarted;
|
|
24
24
|
/** The acknowledgement: one message for several reviews, else at the top of the review's progress message. */
|
|
25
25
|
private acknowledge;
|
|
26
|
+
/**
|
|
27
|
+
* Whether the receipt of a request the person's coordinator sent for them says anything: Claw sums up how it ended, so only what they
|
|
28
|
+
* must act on is said: a review that waits for a slot, one that did not start, a number that was not read as a pull request, and a
|
|
29
|
+
* reviewer who cannot be reached for a confirmation (`other`).
|
|
30
|
+
*/
|
|
31
|
+
private needsWords;
|
|
26
32
|
private severalText;
|
|
27
33
|
/** A turn for each review of one's own; the asker follows the reviews asked of someone else together. */
|
|
28
34
|
private run;
|
|
@@ -120,7 +120,7 @@ export declare class StatusMessage<S> {
|
|
|
120
120
|
/**
|
|
121
121
|
* The chat went on below the stream while the turn runs (the person wrote again, or something else was said there): the stream's
|
|
122
122
|
* bubble stays where it opened, above all that. An answer begun in it and continued below would be read from its middle, its first
|
|
123
|
-
* part out of sight (
|
|
123
|
+
* part out of sight ("(cont. 2/2)" under a queued message's notice, part 1 above both). So nothing of the agent's goes
|
|
124
124
|
* into the bubble from now on: while it shows only a status, that floats on until the turn ends; one that shows words already is
|
|
125
125
|
* closed at once. Either way it ends with `line`, and the whole answer comes as messages of its own, below what was said since.
|
|
126
126
|
* When it comes while the answer is going out (its first part in the bubble already), the whole answer is sent again below.
|