@sjawhar/claude-envoy 4.3.1 → 4.5.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/.claude-plugin/plugin.json +1 -1
- package/.omp-plugin/plugin.json +1 -1
- package/dist/codex-hook.js +110 -24
- package/dist/dispatch.js +110 -24
- package/dist/envoy-channel.js +111 -25
- package/dist/session-hook.js +110 -24
- package/package.json +1 -1
package/.omp-plugin/plugin.json
CHANGED
package/dist/codex-hook.js
CHANGED
|
@@ -14854,6 +14854,15 @@ var dispatchToolSpecs = [
|
|
|
14854
14854
|
validation: handoffValidation,
|
|
14855
14855
|
strict: true
|
|
14856
14856
|
},
|
|
14857
|
+
{
|
|
14858
|
+
name: "dispatch_steps",
|
|
14859
|
+
example: { issue: "DSP-1" },
|
|
14860
|
+
description: "Print each step that ran on an issue, as the Legion daemon recorded it at the step's " + "start and at its end. The first line is `<KEY>: <n> steps in <m> tasks`. Then each run " + "of a step prints one line, task by task, in the order each task first ran: `<task> " + "<step> <kind> <role> <type> attempt <attempt> <agent> <model> <started_at> <ended_at> " + "<result>`. kind is step, retro or merge. step is the step's place in its task, from 1, " + "and 0 for a retro or a merge. attempt counts the runs of the same task, step and kind, " + "from 1. agent is the claim of the role that ran the step, and model is the model that " + "answered it, as provider/model. result is passed, failed or stopped. A field with no " + "value prints -, and a run that has not ended prints running for its end and its result. " + "A closed issue's steps read too. An issue that no step ran on prints 0 steps in 0 tasks, " + "and a key Dispatch does not hold fails as dispatch read fails for it, NOT_FOUND: not " + `found. ${ISSUE_REFERENCE}`,
|
|
14861
|
+
arguments: (z) => ({
|
|
14862
|
+
issue: z.string().describe(ISSUE_REFERENCE)
|
|
14863
|
+
}),
|
|
14864
|
+
strict: true
|
|
14865
|
+
},
|
|
14857
14866
|
{
|
|
14858
14867
|
name: "dispatch_inbox",
|
|
14859
14868
|
example: {},
|
|
@@ -15230,6 +15239,7 @@ var commentEventPayloadFields = {
|
|
|
15230
15239
|
ask_question: string2().optional(),
|
|
15231
15240
|
ask_state: askFields.state.optional(),
|
|
15232
15241
|
ask_waiting_on: _enum2(ASK_TURNS).optional(),
|
|
15242
|
+
ask_sessions: array(string2()).optional(),
|
|
15233
15243
|
...referenceChangesFields,
|
|
15234
15244
|
...threadLoginsFields,
|
|
15235
15245
|
...carriedBodyFields
|
|
@@ -15237,6 +15247,7 @@ var commentEventPayloadFields = {
|
|
|
15237
15247
|
var WrittenCommentEventPayloadSchema = strictObject(commentEventPayloadFields).readonly();
|
|
15238
15248
|
var CommentEventPayloadSchema = object({
|
|
15239
15249
|
id: commentFields.id.optional(),
|
|
15250
|
+
artifact_id: commentFields.artifact_id,
|
|
15240
15251
|
artifact_name: commentEventPayloadFields.artifact_name.optional(),
|
|
15241
15252
|
project_key: commentEventPayloadFields.project_key,
|
|
15242
15253
|
artifact_slug: commentEventPayloadFields.artifact_slug,
|
|
@@ -15246,6 +15257,7 @@ var CommentEventPayloadSchema = object({
|
|
|
15246
15257
|
ask_question: commentEventPayloadFields.ask_question,
|
|
15247
15258
|
ask_state: commentEventPayloadFields.ask_state,
|
|
15248
15259
|
ask_waiting_on: commentEventPayloadFields.ask_waiting_on,
|
|
15260
|
+
ask_sessions: commentEventPayloadFields.ask_sessions,
|
|
15249
15261
|
turn: commentFields.turn.optional(),
|
|
15250
15262
|
anchor: object({
|
|
15251
15263
|
artifact_id: anchorFields.artifact_id.optional(),
|
|
@@ -18985,6 +18997,9 @@ class DispatchClient {
|
|
|
18985
18997
|
async handoff(id) {
|
|
18986
18998
|
return this.#json("GET", ["api", "v1", "handoffs", id]);
|
|
18987
18999
|
}
|
|
19000
|
+
async listSteps(issue) {
|
|
19001
|
+
return this.#json("GET", ["api", "v1", "issues", await this.#resolveIssue(issue), "steps"]);
|
|
19002
|
+
}
|
|
18988
19003
|
async getIssueReferences(issue) {
|
|
18989
19004
|
return this.#json("GET", ["api", "v1", "issues", await this.#resolveIssue(issue), "references"], undefined, { versions: "latest" });
|
|
18990
19005
|
}
|
|
@@ -19375,6 +19390,27 @@ ${body}${fence}${note ? `
|
|
|
19375
19390
|
${HUMAN_EDIT_DIFF_CUT_NOTE}` : ""}`;
|
|
19376
19391
|
}
|
|
19377
19392
|
|
|
19393
|
+
// ../envoy-client/src/session-answer-relations.ts
|
|
19394
|
+
var RELATION_PHRASES = {
|
|
19395
|
+
answered_your_ask: "answered your ask",
|
|
19396
|
+
answered_an_ask: "answered an ask",
|
|
19397
|
+
declined_your_ask: "declined to answer your ask",
|
|
19398
|
+
declined_an_ask: "declined to answer an ask",
|
|
19399
|
+
replied_on_your_ask: "replied on your ask",
|
|
19400
|
+
replied_in_a_comment_thread: "replied in a comment thread",
|
|
19401
|
+
commented_on_a_document: "commented on a document",
|
|
19402
|
+
commented_on_an_issue: "commented on an issue",
|
|
19403
|
+
mentioned_you: "mentioned you",
|
|
19404
|
+
sent_you_a_message: "sent you a message",
|
|
19405
|
+
replied_to_your_message: "replied to your message"
|
|
19406
|
+
};
|
|
19407
|
+
function isSessionAnswerRelation(value) {
|
|
19408
|
+
return Object.hasOwn(RELATION_PHRASES, value);
|
|
19409
|
+
}
|
|
19410
|
+
function sessionAnswerRelationPhrase(relation) {
|
|
19411
|
+
return isSessionAnswerRelation(relation) ? RELATION_PHRASES[relation] : relation;
|
|
19412
|
+
}
|
|
19413
|
+
|
|
19378
19414
|
// ../envoy-client/src/delivery.ts
|
|
19379
19415
|
var KNOWN_SOURCES = EnvelopeSchema.shape.source.enum;
|
|
19380
19416
|
var FOREIGN_SESSION_ID = /\b01a0[0-9a-f]{4}-[0-9a-f]{4}-7[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}\b/g;
|
|
@@ -19581,8 +19617,11 @@ function carriedItem(event) {
|
|
|
19581
19617
|
return;
|
|
19582
19618
|
return { resource, id, issueKey: event.issue_key };
|
|
19583
19619
|
}
|
|
19620
|
+
function payloadWasOmitted(payload) {
|
|
19621
|
+
return isObject2(payload) && payload["payload_omitted"] === true;
|
|
19622
|
+
}
|
|
19584
19623
|
function bodyWasCut(payload) {
|
|
19585
|
-
return isObject2(payload) &&
|
|
19624
|
+
return isObject2(payload) && payload["body_truncated"] === true || payloadWasOmitted(payload);
|
|
19586
19625
|
}
|
|
19587
19626
|
function wholeItemRoute(item) {
|
|
19588
19627
|
return `GET /api/v1/${item.resource === "comment" ? "comments" : "messages"}/${item.id}`;
|
|
@@ -19590,7 +19629,7 @@ function wholeItemRoute(item) {
|
|
|
19590
19629
|
function carriedBodyNote(event) {
|
|
19591
19630
|
if (!bodyWasCut(event.payload))
|
|
19592
19631
|
return;
|
|
19593
|
-
const what =
|
|
19632
|
+
const what = payloadWasOmitted(event.payload) ? "this event carries no body: it was too large for the bus" : "the body is its first part only";
|
|
19594
19633
|
const item = carriedItem(event);
|
|
19595
19634
|
return item === undefined ? what : `${what}; read it whole with ${wholeItemRoute(item)}`;
|
|
19596
19635
|
}
|
|
@@ -19693,6 +19732,24 @@ function dispatchCommentReplyWith(event, topic, comment) {
|
|
|
19693
19732
|
})
|
|
19694
19733
|
};
|
|
19695
19734
|
}
|
|
19735
|
+
function ownsRepliedAsk(comment, sessionID) {
|
|
19736
|
+
if (comment?.ask_id === undefined || comment.ask_id === null)
|
|
19737
|
+
return;
|
|
19738
|
+
return comment.ask_sessions?.includes(sessionID);
|
|
19739
|
+
}
|
|
19740
|
+
function repliedAskRelation(event, comment, owns, mentioned) {
|
|
19741
|
+
if (owns)
|
|
19742
|
+
return "replied_on_your_ask";
|
|
19743
|
+
if (mentioned)
|
|
19744
|
+
return "mentioned_you";
|
|
19745
|
+
if (comment.reply_to !== undefined && comment.reply_to !== null) {
|
|
19746
|
+
return "replied_in_a_comment_thread";
|
|
19747
|
+
}
|
|
19748
|
+
if (comment.artifact_id !== undefined && comment.artifact_id !== null || comment.anchor?.artifact_id !== undefined || event.issue_key === null) {
|
|
19749
|
+
return "commented_on_a_document";
|
|
19750
|
+
}
|
|
19751
|
+
return "commented_on_an_issue";
|
|
19752
|
+
}
|
|
19696
19753
|
function askResolutionText(resolution) {
|
|
19697
19754
|
if (resolution === null || resolution === undefined)
|
|
19698
19755
|
return;
|
|
@@ -19702,7 +19759,7 @@ function askResolutionText(resolution) {
|
|
|
19702
19759
|
const words = dispatchWordsText(resolution.dispatch_words);
|
|
19703
19760
|
return words === undefined ? closed : `${closed} \xB7 ${words}`;
|
|
19704
19761
|
}
|
|
19705
|
-
function dispatchCompact(event, comment) {
|
|
19762
|
+
function dispatchCompact(event, comment, ownsAsk) {
|
|
19706
19763
|
if (event.type === "artifact.human_edited") {
|
|
19707
19764
|
const edit = ArtifactHumanEditedEventPayloadSchema.safeParse(event.payload);
|
|
19708
19765
|
if (!edit.success)
|
|
@@ -19719,7 +19776,7 @@ function dispatchCompact(event, comment) {
|
|
|
19719
19776
|
...question === undefined ? {} : { question },
|
|
19720
19777
|
reply: comment.body ?? "",
|
|
19721
19778
|
...comment.ask_state === undefined ? {} : { state: comment.ask_state },
|
|
19722
|
-
...comment.ask_waiting_on === undefined ? {} : { waiting_on: comment.ask_waiting_on }
|
|
19779
|
+
...comment.ask_waiting_on === undefined || ownsAsk === false ? {} : { waiting_on: comment.ask_waiting_on }
|
|
19723
19780
|
}
|
|
19724
19781
|
};
|
|
19725
19782
|
}
|
|
@@ -19926,7 +19983,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
19926
19983
|
let bodyNote;
|
|
19927
19984
|
let cutItem;
|
|
19928
19985
|
let inReplyTo = envelope.in_reply_to;
|
|
19929
|
-
let
|
|
19986
|
+
let payloadSessions = [];
|
|
19930
19987
|
let trailer = "";
|
|
19931
19988
|
const dispatchRendered = envelope.source === "dispatch" && envelope.payload !== undefined;
|
|
19932
19989
|
if (envelope.source === "dispatch") {
|
|
@@ -19971,11 +20028,13 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
19971
20028
|
}
|
|
19972
20029
|
const comment = frame.event.type === "comment.created" ? CommentEventPayloadSchema.safeParse(frame.event.payload) : undefined;
|
|
19973
20030
|
const commentPayload = comment?.success === true ? comment.data : undefined;
|
|
19974
|
-
const
|
|
20031
|
+
const ownsAsk = ownsRepliedAsk(commentPayload, sessionID);
|
|
20032
|
+
const compact = dispatchCompact(frame.event, commentPayload, ownsAsk);
|
|
20033
|
+
payloadSessions = commentPayload?.ask_sessions ?? [];
|
|
19975
20034
|
if (frame.event.type.startsWith("ask.")) {
|
|
19976
20035
|
const asked = AskAuthorPayloadSchema.safeParse(frame.event.payload);
|
|
19977
20036
|
if (asked.success && asked.data.author.kind === "session") {
|
|
19978
|
-
|
|
20037
|
+
payloadSessions = [asked.data.author.id];
|
|
19979
20038
|
}
|
|
19980
20039
|
}
|
|
19981
20040
|
if (inReplyTo !== undefined) {
|
|
@@ -20023,6 +20082,10 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
20023
20082
|
};
|
|
20024
20083
|
}
|
|
20025
20084
|
}
|
|
20085
|
+
const mentioned = delivery !== undefined;
|
|
20086
|
+
const relation = ownsAsk === undefined || commentPayload === undefined ? undefined : sessionAnswerRelationPhrase(repliedAskRelation(frame.event, commentPayload, ownsAsk, mentioned));
|
|
20087
|
+
if (ownsAsk === false && !mentioned)
|
|
20088
|
+
dispatchReply = undefined;
|
|
20026
20089
|
const compactRecord = compact === undefined ? undefined : inReplyTo !== undefined || compact.askId === undefined ? compact.record : {
|
|
20027
20090
|
ask: dispatchReplyRef(frame.event, topic, compact.askId, commentPayload),
|
|
20028
20091
|
...compact.record
|
|
@@ -20031,6 +20094,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
20031
20094
|
owner: dispatchOwner(frame.event, topic),
|
|
20032
20095
|
type: frame.event.type,
|
|
20033
20096
|
actor: frame.event.actor,
|
|
20097
|
+
...relation === undefined ? {} : { relation },
|
|
20034
20098
|
...compactRecord ?? { payload: dispatchPayloadForReader(frame.event, sessionID) }
|
|
20035
20099
|
};
|
|
20036
20100
|
dispatchActor = frame.event.actor;
|
|
@@ -20064,7 +20128,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
20064
20128
|
let foreignSession;
|
|
20065
20129
|
for (const part of [envelope.payload_summary ?? "", envelope.payload ?? ""]) {
|
|
20066
20130
|
for (const match of part.matchAll(FOREIGN_SESSION_ID)) {
|
|
20067
|
-
if (match[0] !== envelope.source_session && match[0] !== sessionID && match[0]
|
|
20131
|
+
if (match[0] !== envelope.source_session && match[0] !== sessionID && !payloadSessions.includes(match[0])) {
|
|
20068
20132
|
foreignSession = match[0];
|
|
20069
20133
|
break;
|
|
20070
20134
|
}
|
|
@@ -24640,25 +24704,11 @@ var NO_ROUTE_BACKOFF_MS = 5 * 60000;
|
|
|
24640
24704
|
var SESSION_ANSWERS_MARKER = "[Dispatch: what people wrote to this session in the last 72 hours, newest first, word for word. Reference, not a new request.]";
|
|
24641
24705
|
var FAILURE_MARKER = "[Dispatch: people's answers from the last 72 hours could not be read (";
|
|
24642
24706
|
var NO_ANSWERS_ROUTE_REASON = "this Dispatch build has no answers route";
|
|
24643
|
-
var RELATION_PHRASES = {
|
|
24644
|
-
answered_your_ask: "answered your ask",
|
|
24645
|
-
declined_your_ask: "declined to answer your ask",
|
|
24646
|
-
replied_on_your_ask: "replied on your ask",
|
|
24647
|
-
replied_in_a_comment_thread: "replied in a comment thread",
|
|
24648
|
-
commented_on_a_document: "commented on a document",
|
|
24649
|
-
commented_on_an_issue: "commented on an issue",
|
|
24650
|
-
mentioned_you: "mentioned you",
|
|
24651
|
-
sent_you_a_message: "sent you a message",
|
|
24652
|
-
replied_to_your_message: "replied to your message"
|
|
24653
|
-
};
|
|
24654
|
-
function isSessionAnswerRelation(value) {
|
|
24655
|
-
return Object.hasOwn(RELATION_PHRASES, value);
|
|
24656
|
-
}
|
|
24657
24707
|
function isNoAnswersRoute(error) {
|
|
24658
24708
|
return isNoRoute(error) || error instanceof DispatchNoRouteError;
|
|
24659
24709
|
}
|
|
24660
24710
|
function renderSessionAnswerItem(item) {
|
|
24661
|
-
const phrase =
|
|
24711
|
+
const phrase = sessionAnswerRelationPhrase(item.relation);
|
|
24662
24712
|
const relation = `${phrase}${item.replaced === true ? " (replaces an earlier answer)" : ""}`;
|
|
24663
24713
|
const head = [item.at, actorActText(`user ${item.author.id}`, item.author.act), relation];
|
|
24664
24714
|
if (item.edited_at !== undefined)
|
|
@@ -24699,7 +24749,8 @@ function sessionAnswersWords(items) {
|
|
|
24699
24749
|
item.at,
|
|
24700
24750
|
item.edited_at ?? null,
|
|
24701
24751
|
item.selected ?? null,
|
|
24702
|
-
item.text
|
|
24752
|
+
item.text,
|
|
24753
|
+
item.relation
|
|
24703
24754
|
]));
|
|
24704
24755
|
}
|
|
24705
24756
|
var MAX_CHARS_TEXT = SESSION_ANSWERS_MAX_CHARS.toLocaleString("en-US");
|
|
@@ -25128,6 +25179,40 @@ async function inboxCommand(context) {
|
|
|
25128
25179
|
};
|
|
25129
25180
|
}
|
|
25130
25181
|
|
|
25182
|
+
// ../envoy-client/src/dispatch-commands/steps.ts
|
|
25183
|
+
function orDash(value) {
|
|
25184
|
+
return value === null || value === "" ? "-" : value;
|
|
25185
|
+
}
|
|
25186
|
+
function stepLine(record) {
|
|
25187
|
+
return [
|
|
25188
|
+
record.task,
|
|
25189
|
+
record.step,
|
|
25190
|
+
record.kind,
|
|
25191
|
+
record.role,
|
|
25192
|
+
orDash(record.type),
|
|
25193
|
+
"attempt",
|
|
25194
|
+
record.attempt,
|
|
25195
|
+
orDash(record.agent),
|
|
25196
|
+
orDash(record.model),
|
|
25197
|
+
orDash(record.started_at),
|
|
25198
|
+
...record.ended_at === null ? ["running", "running"] : [record.ended_at, orDash(record.result)]
|
|
25199
|
+
].join(" ");
|
|
25200
|
+
}
|
|
25201
|
+
async function stepsCommand(context) {
|
|
25202
|
+
const { client, issue } = context;
|
|
25203
|
+
const read = await client.listSteps(issue());
|
|
25204
|
+
const tasks = (read.tasks ?? []).map((task) => ({ task: task.task, steps: task.steps ?? [] }));
|
|
25205
|
+
const records = tasks.flatMap((task) => task.steps);
|
|
25206
|
+
return {
|
|
25207
|
+
text: [
|
|
25208
|
+
`${read.issue}: ${records.length} steps in ${tasks.length} tasks`,
|
|
25209
|
+
...records.map(stepLine)
|
|
25210
|
+
].join(`
|
|
25211
|
+
`),
|
|
25212
|
+
details: { issue: read.issue, tasks }
|
|
25213
|
+
};
|
|
25214
|
+
}
|
|
25215
|
+
|
|
25131
25216
|
// ../envoy-client/src/dispatch-commands/table.ts
|
|
25132
25217
|
function acting(run) {
|
|
25133
25218
|
return { origin: "resolved", run };
|
|
@@ -25166,6 +25251,7 @@ var dispatchCommands = {
|
|
|
25166
25251
|
dispatch_artifact: acting(artifactCommand),
|
|
25167
25252
|
dispatch_handoff_write: acting(handoffWriteCommand),
|
|
25168
25253
|
dispatch_handoff_read: acting(handoffReadCommand),
|
|
25254
|
+
dispatch_steps: acting(stepsCommand),
|
|
25169
25255
|
dispatch_read: acting(readCommand),
|
|
25170
25256
|
dispatch_answers: onSession(answersCommand),
|
|
25171
25257
|
dispatch_whoami: onSession(whoamiCommand),
|
package/dist/dispatch.js
CHANGED
|
@@ -15918,6 +15918,15 @@ var dispatchToolSpecs = [
|
|
|
15918
15918
|
validation: handoffValidation,
|
|
15919
15919
|
strict: true
|
|
15920
15920
|
},
|
|
15921
|
+
{
|
|
15922
|
+
name: "dispatch_steps",
|
|
15923
|
+
example: { issue: "DSP-1" },
|
|
15924
|
+
description: "Print each step that ran on an issue, as the Legion daemon recorded it at the step's " + "start and at its end. The first line is `<KEY>: <n> steps in <m> tasks`. Then each run " + "of a step prints one line, task by task, in the order each task first ran: `<task> " + "<step> <kind> <role> <type> attempt <attempt> <agent> <model> <started_at> <ended_at> " + "<result>`. kind is step, retro or merge. step is the step's place in its task, from 1, " + "and 0 for a retro or a merge. attempt counts the runs of the same task, step and kind, " + "from 1. agent is the claim of the role that ran the step, and model is the model that " + "answered it, as provider/model. result is passed, failed or stopped. A field with no " + "value prints -, and a run that has not ended prints running for its end and its result. " + "A closed issue's steps read too. An issue that no step ran on prints 0 steps in 0 tasks, " + "and a key Dispatch does not hold fails as dispatch read fails for it, NOT_FOUND: not " + `found. ${ISSUE_REFERENCE}`,
|
|
15925
|
+
arguments: (z) => ({
|
|
15926
|
+
issue: z.string().describe(ISSUE_REFERENCE)
|
|
15927
|
+
}),
|
|
15928
|
+
strict: true
|
|
15929
|
+
},
|
|
15921
15930
|
{
|
|
15922
15931
|
name: "dispatch_inbox",
|
|
15923
15932
|
example: {},
|
|
@@ -16294,6 +16303,7 @@ var commentEventPayloadFields = {
|
|
|
16294
16303
|
ask_question: string2().optional(),
|
|
16295
16304
|
ask_state: askFields.state.optional(),
|
|
16296
16305
|
ask_waiting_on: _enum2(ASK_TURNS).optional(),
|
|
16306
|
+
ask_sessions: array(string2()).optional(),
|
|
16297
16307
|
...referenceChangesFields,
|
|
16298
16308
|
...threadLoginsFields,
|
|
16299
16309
|
...carriedBodyFields
|
|
@@ -16301,6 +16311,7 @@ var commentEventPayloadFields = {
|
|
|
16301
16311
|
var WrittenCommentEventPayloadSchema = strictObject(commentEventPayloadFields).readonly();
|
|
16302
16312
|
var CommentEventPayloadSchema = object({
|
|
16303
16313
|
id: commentFields.id.optional(),
|
|
16314
|
+
artifact_id: commentFields.artifact_id,
|
|
16304
16315
|
artifact_name: commentEventPayloadFields.artifact_name.optional(),
|
|
16305
16316
|
project_key: commentEventPayloadFields.project_key,
|
|
16306
16317
|
artifact_slug: commentEventPayloadFields.artifact_slug,
|
|
@@ -16310,6 +16321,7 @@ var CommentEventPayloadSchema = object({
|
|
|
16310
16321
|
ask_question: commentEventPayloadFields.ask_question,
|
|
16311
16322
|
ask_state: commentEventPayloadFields.ask_state,
|
|
16312
16323
|
ask_waiting_on: commentEventPayloadFields.ask_waiting_on,
|
|
16324
|
+
ask_sessions: commentEventPayloadFields.ask_sessions,
|
|
16313
16325
|
turn: commentFields.turn.optional(),
|
|
16314
16326
|
anchor: object({
|
|
16315
16327
|
artifact_id: anchorFields.artifact_id.optional(),
|
|
@@ -19263,6 +19275,9 @@ class DispatchClient {
|
|
|
19263
19275
|
async handoff(id) {
|
|
19264
19276
|
return this.#json("GET", ["api", "v1", "handoffs", id]);
|
|
19265
19277
|
}
|
|
19278
|
+
async listSteps(issue) {
|
|
19279
|
+
return this.#json("GET", ["api", "v1", "issues", await this.#resolveIssue(issue), "steps"]);
|
|
19280
|
+
}
|
|
19266
19281
|
async getIssueReferences(issue) {
|
|
19267
19282
|
return this.#json("GET", ["api", "v1", "issues", await this.#resolveIssue(issue), "references"], undefined, { versions: "latest" });
|
|
19268
19283
|
}
|
|
@@ -20500,6 +20515,27 @@ ${body}${fence}${note ? `
|
|
|
20500
20515
|
${HUMAN_EDIT_DIFF_CUT_NOTE}` : ""}`;
|
|
20501
20516
|
}
|
|
20502
20517
|
|
|
20518
|
+
// ../envoy-client/src/session-answer-relations.ts
|
|
20519
|
+
var RELATION_PHRASES = {
|
|
20520
|
+
answered_your_ask: "answered your ask",
|
|
20521
|
+
answered_an_ask: "answered an ask",
|
|
20522
|
+
declined_your_ask: "declined to answer your ask",
|
|
20523
|
+
declined_an_ask: "declined to answer an ask",
|
|
20524
|
+
replied_on_your_ask: "replied on your ask",
|
|
20525
|
+
replied_in_a_comment_thread: "replied in a comment thread",
|
|
20526
|
+
commented_on_a_document: "commented on a document",
|
|
20527
|
+
commented_on_an_issue: "commented on an issue",
|
|
20528
|
+
mentioned_you: "mentioned you",
|
|
20529
|
+
sent_you_a_message: "sent you a message",
|
|
20530
|
+
replied_to_your_message: "replied to your message"
|
|
20531
|
+
};
|
|
20532
|
+
function isSessionAnswerRelation(value) {
|
|
20533
|
+
return Object.hasOwn(RELATION_PHRASES, value);
|
|
20534
|
+
}
|
|
20535
|
+
function sessionAnswerRelationPhrase(relation) {
|
|
20536
|
+
return isSessionAnswerRelation(relation) ? RELATION_PHRASES[relation] : relation;
|
|
20537
|
+
}
|
|
20538
|
+
|
|
20503
20539
|
// ../envoy-client/src/delivery.ts
|
|
20504
20540
|
var KNOWN_SOURCES = EnvelopeSchema.shape.source.enum;
|
|
20505
20541
|
var FOREIGN_SESSION_ID = /\b01a0[0-9a-f]{4}-[0-9a-f]{4}-7[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}\b/g;
|
|
@@ -20706,8 +20742,11 @@ function carriedItem(event) {
|
|
|
20706
20742
|
return;
|
|
20707
20743
|
return { resource, id, issueKey: event.issue_key };
|
|
20708
20744
|
}
|
|
20745
|
+
function payloadWasOmitted(payload) {
|
|
20746
|
+
return isObject2(payload) && payload["payload_omitted"] === true;
|
|
20747
|
+
}
|
|
20709
20748
|
function bodyWasCut(payload) {
|
|
20710
|
-
return isObject2(payload) &&
|
|
20749
|
+
return isObject2(payload) && payload["body_truncated"] === true || payloadWasOmitted(payload);
|
|
20711
20750
|
}
|
|
20712
20751
|
function wholeItemRoute(item) {
|
|
20713
20752
|
return `GET /api/v1/${item.resource === "comment" ? "comments" : "messages"}/${item.id}`;
|
|
@@ -20715,7 +20754,7 @@ function wholeItemRoute(item) {
|
|
|
20715
20754
|
function carriedBodyNote(event) {
|
|
20716
20755
|
if (!bodyWasCut(event.payload))
|
|
20717
20756
|
return;
|
|
20718
|
-
const what =
|
|
20757
|
+
const what = payloadWasOmitted(event.payload) ? "this event carries no body: it was too large for the bus" : "the body is its first part only";
|
|
20719
20758
|
const item = carriedItem(event);
|
|
20720
20759
|
return item === undefined ? what : `${what}; read it whole with ${wholeItemRoute(item)}`;
|
|
20721
20760
|
}
|
|
@@ -20818,6 +20857,24 @@ function dispatchCommentReplyWith(event, topic, comment) {
|
|
|
20818
20857
|
})
|
|
20819
20858
|
};
|
|
20820
20859
|
}
|
|
20860
|
+
function ownsRepliedAsk(comment, sessionID) {
|
|
20861
|
+
if (comment?.ask_id === undefined || comment.ask_id === null)
|
|
20862
|
+
return;
|
|
20863
|
+
return comment.ask_sessions?.includes(sessionID);
|
|
20864
|
+
}
|
|
20865
|
+
function repliedAskRelation(event, comment, owns, mentioned) {
|
|
20866
|
+
if (owns)
|
|
20867
|
+
return "replied_on_your_ask";
|
|
20868
|
+
if (mentioned)
|
|
20869
|
+
return "mentioned_you";
|
|
20870
|
+
if (comment.reply_to !== undefined && comment.reply_to !== null) {
|
|
20871
|
+
return "replied_in_a_comment_thread";
|
|
20872
|
+
}
|
|
20873
|
+
if (comment.artifact_id !== undefined && comment.artifact_id !== null || comment.anchor?.artifact_id !== undefined || event.issue_key === null) {
|
|
20874
|
+
return "commented_on_a_document";
|
|
20875
|
+
}
|
|
20876
|
+
return "commented_on_an_issue";
|
|
20877
|
+
}
|
|
20821
20878
|
function askResolutionText(resolution) {
|
|
20822
20879
|
if (resolution === null || resolution === undefined)
|
|
20823
20880
|
return;
|
|
@@ -20827,7 +20884,7 @@ function askResolutionText(resolution) {
|
|
|
20827
20884
|
const words = dispatchWordsText(resolution.dispatch_words);
|
|
20828
20885
|
return words === undefined ? closed : `${closed} \xB7 ${words}`;
|
|
20829
20886
|
}
|
|
20830
|
-
function dispatchCompact(event, comment) {
|
|
20887
|
+
function dispatchCompact(event, comment, ownsAsk) {
|
|
20831
20888
|
if (event.type === "artifact.human_edited") {
|
|
20832
20889
|
const edit = ArtifactHumanEditedEventPayloadSchema.safeParse(event.payload);
|
|
20833
20890
|
if (!edit.success)
|
|
@@ -20844,7 +20901,7 @@ function dispatchCompact(event, comment) {
|
|
|
20844
20901
|
...question === undefined ? {} : { question },
|
|
20845
20902
|
reply: comment.body ?? "",
|
|
20846
20903
|
...comment.ask_state === undefined ? {} : { state: comment.ask_state },
|
|
20847
|
-
...comment.ask_waiting_on === undefined ? {} : { waiting_on: comment.ask_waiting_on }
|
|
20904
|
+
...comment.ask_waiting_on === undefined || ownsAsk === false ? {} : { waiting_on: comment.ask_waiting_on }
|
|
20848
20905
|
}
|
|
20849
20906
|
};
|
|
20850
20907
|
}
|
|
@@ -21051,7 +21108,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
21051
21108
|
let bodyNote;
|
|
21052
21109
|
let cutItem;
|
|
21053
21110
|
let inReplyTo = envelope.in_reply_to;
|
|
21054
|
-
let
|
|
21111
|
+
let payloadSessions = [];
|
|
21055
21112
|
let trailer = "";
|
|
21056
21113
|
const dispatchRendered = envelope.source === "dispatch" && envelope.payload !== undefined;
|
|
21057
21114
|
if (envelope.source === "dispatch") {
|
|
@@ -21096,11 +21153,13 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
21096
21153
|
}
|
|
21097
21154
|
const comment = frame.event.type === "comment.created" ? CommentEventPayloadSchema.safeParse(frame.event.payload) : undefined;
|
|
21098
21155
|
const commentPayload = comment?.success === true ? comment.data : undefined;
|
|
21099
|
-
const
|
|
21156
|
+
const ownsAsk = ownsRepliedAsk(commentPayload, sessionID);
|
|
21157
|
+
const compact = dispatchCompact(frame.event, commentPayload, ownsAsk);
|
|
21158
|
+
payloadSessions = commentPayload?.ask_sessions ?? [];
|
|
21100
21159
|
if (frame.event.type.startsWith("ask.")) {
|
|
21101
21160
|
const asked = AskAuthorPayloadSchema.safeParse(frame.event.payload);
|
|
21102
21161
|
if (asked.success && asked.data.author.kind === "session") {
|
|
21103
|
-
|
|
21162
|
+
payloadSessions = [asked.data.author.id];
|
|
21104
21163
|
}
|
|
21105
21164
|
}
|
|
21106
21165
|
if (inReplyTo !== undefined) {
|
|
@@ -21148,6 +21207,10 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
21148
21207
|
};
|
|
21149
21208
|
}
|
|
21150
21209
|
}
|
|
21210
|
+
const mentioned = delivery !== undefined;
|
|
21211
|
+
const relation = ownsAsk === undefined || commentPayload === undefined ? undefined : sessionAnswerRelationPhrase(repliedAskRelation(frame.event, commentPayload, ownsAsk, mentioned));
|
|
21212
|
+
if (ownsAsk === false && !mentioned)
|
|
21213
|
+
dispatchReply = undefined;
|
|
21151
21214
|
const compactRecord = compact === undefined ? undefined : inReplyTo !== undefined || compact.askId === undefined ? compact.record : {
|
|
21152
21215
|
ask: dispatchReplyRef(frame.event, topic, compact.askId, commentPayload),
|
|
21153
21216
|
...compact.record
|
|
@@ -21156,6 +21219,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
21156
21219
|
owner: dispatchOwner(frame.event, topic),
|
|
21157
21220
|
type: frame.event.type,
|
|
21158
21221
|
actor: frame.event.actor,
|
|
21222
|
+
...relation === undefined ? {} : { relation },
|
|
21159
21223
|
...compactRecord ?? { payload: dispatchPayloadForReader(frame.event, sessionID) }
|
|
21160
21224
|
};
|
|
21161
21225
|
dispatchActor = frame.event.actor;
|
|
@@ -21189,7 +21253,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
21189
21253
|
let foreignSession;
|
|
21190
21254
|
for (const part of [envelope.payload_summary ?? "", envelope.payload ?? ""]) {
|
|
21191
21255
|
for (const match of part.matchAll(FOREIGN_SESSION_ID)) {
|
|
21192
|
-
if (match[0] !== envelope.source_session && match[0] !== sessionID && match[0]
|
|
21256
|
+
if (match[0] !== envelope.source_session && match[0] !== sessionID && !payloadSessions.includes(match[0])) {
|
|
21193
21257
|
foreignSession = match[0];
|
|
21194
21258
|
break;
|
|
21195
21259
|
}
|
|
@@ -25673,25 +25737,11 @@ var NO_ROUTE_BACKOFF_MS = 5 * 60000;
|
|
|
25673
25737
|
var SESSION_ANSWERS_MARKER = "[Dispatch: what people wrote to this session in the last 72 hours, newest first, word for word. Reference, not a new request.]";
|
|
25674
25738
|
var FAILURE_MARKER = "[Dispatch: people's answers from the last 72 hours could not be read (";
|
|
25675
25739
|
var NO_ANSWERS_ROUTE_REASON = "this Dispatch build has no answers route";
|
|
25676
|
-
var RELATION_PHRASES = {
|
|
25677
|
-
answered_your_ask: "answered your ask",
|
|
25678
|
-
declined_your_ask: "declined to answer your ask",
|
|
25679
|
-
replied_on_your_ask: "replied on your ask",
|
|
25680
|
-
replied_in_a_comment_thread: "replied in a comment thread",
|
|
25681
|
-
commented_on_a_document: "commented on a document",
|
|
25682
|
-
commented_on_an_issue: "commented on an issue",
|
|
25683
|
-
mentioned_you: "mentioned you",
|
|
25684
|
-
sent_you_a_message: "sent you a message",
|
|
25685
|
-
replied_to_your_message: "replied to your message"
|
|
25686
|
-
};
|
|
25687
|
-
function isSessionAnswerRelation(value) {
|
|
25688
|
-
return Object.hasOwn(RELATION_PHRASES, value);
|
|
25689
|
-
}
|
|
25690
25740
|
function isNoAnswersRoute(error) {
|
|
25691
25741
|
return isNoRoute(error) || error instanceof DispatchNoRouteError;
|
|
25692
25742
|
}
|
|
25693
25743
|
function renderSessionAnswerItem(item) {
|
|
25694
|
-
const phrase =
|
|
25744
|
+
const phrase = sessionAnswerRelationPhrase(item.relation);
|
|
25695
25745
|
const relation = `${phrase}${item.replaced === true ? " (replaces an earlier answer)" : ""}`;
|
|
25696
25746
|
const head = [item.at, actorActText(`user ${item.author.id}`, item.author.act), relation];
|
|
25697
25747
|
if (item.edited_at !== undefined)
|
|
@@ -25732,7 +25782,8 @@ function sessionAnswersWords(items) {
|
|
|
25732
25782
|
item.at,
|
|
25733
25783
|
item.edited_at ?? null,
|
|
25734
25784
|
item.selected ?? null,
|
|
25735
|
-
item.text
|
|
25785
|
+
item.text,
|
|
25786
|
+
item.relation
|
|
25736
25787
|
]));
|
|
25737
25788
|
}
|
|
25738
25789
|
var MAX_CHARS_TEXT = SESSION_ANSWERS_MAX_CHARS.toLocaleString("en-US");
|
|
@@ -26161,6 +26212,40 @@ async function inboxCommand(context) {
|
|
|
26161
26212
|
};
|
|
26162
26213
|
}
|
|
26163
26214
|
|
|
26215
|
+
// ../envoy-client/src/dispatch-commands/steps.ts
|
|
26216
|
+
function orDash(value) {
|
|
26217
|
+
return value === null || value === "" ? "-" : value;
|
|
26218
|
+
}
|
|
26219
|
+
function stepLine(record) {
|
|
26220
|
+
return [
|
|
26221
|
+
record.task,
|
|
26222
|
+
record.step,
|
|
26223
|
+
record.kind,
|
|
26224
|
+
record.role,
|
|
26225
|
+
orDash(record.type),
|
|
26226
|
+
"attempt",
|
|
26227
|
+
record.attempt,
|
|
26228
|
+
orDash(record.agent),
|
|
26229
|
+
orDash(record.model),
|
|
26230
|
+
orDash(record.started_at),
|
|
26231
|
+
...record.ended_at === null ? ["running", "running"] : [record.ended_at, orDash(record.result)]
|
|
26232
|
+
].join(" ");
|
|
26233
|
+
}
|
|
26234
|
+
async function stepsCommand(context) {
|
|
26235
|
+
const { client, issue } = context;
|
|
26236
|
+
const read = await client.listSteps(issue());
|
|
26237
|
+
const tasks = (read.tasks ?? []).map((task) => ({ task: task.task, steps: task.steps ?? [] }));
|
|
26238
|
+
const records = tasks.flatMap((task) => task.steps);
|
|
26239
|
+
return {
|
|
26240
|
+
text: [
|
|
26241
|
+
`${read.issue}: ${records.length} steps in ${tasks.length} tasks`,
|
|
26242
|
+
...records.map(stepLine)
|
|
26243
|
+
].join(`
|
|
26244
|
+
`),
|
|
26245
|
+
details: { issue: read.issue, tasks }
|
|
26246
|
+
};
|
|
26247
|
+
}
|
|
26248
|
+
|
|
26164
26249
|
// ../envoy-client/src/dispatch-commands/table.ts
|
|
26165
26250
|
function acting(run) {
|
|
26166
26251
|
return { origin: "resolved", run };
|
|
@@ -26199,6 +26284,7 @@ var dispatchCommands = {
|
|
|
26199
26284
|
dispatch_artifact: acting(artifactCommand),
|
|
26200
26285
|
dispatch_handoff_write: acting(handoffWriteCommand),
|
|
26201
26286
|
dispatch_handoff_read: acting(handoffReadCommand),
|
|
26287
|
+
dispatch_steps: acting(stepsCommand),
|
|
26202
26288
|
dispatch_read: acting(readCommand),
|
|
26203
26289
|
dispatch_answers: onSession(answersCommand),
|
|
26204
26290
|
dispatch_whoami: onSession(whoamiCommand),
|
package/dist/envoy-channel.js
CHANGED
|
@@ -37510,6 +37510,15 @@ var dispatchToolSpecs = [
|
|
|
37510
37510
|
validation: handoffValidation,
|
|
37511
37511
|
strict: true
|
|
37512
37512
|
},
|
|
37513
|
+
{
|
|
37514
|
+
name: "dispatch_steps",
|
|
37515
|
+
example: { issue: "DSP-1" },
|
|
37516
|
+
description: "Print each step that ran on an issue, as the Legion daemon recorded it at the step's " + "start and at its end. The first line is `<KEY>: <n> steps in <m> tasks`. Then each run " + "of a step prints one line, task by task, in the order each task first ran: `<task> " + "<step> <kind> <role> <type> attempt <attempt> <agent> <model> <started_at> <ended_at> " + "<result>`. kind is step, retro or merge. step is the step's place in its task, from 1, " + "and 0 for a retro or a merge. attempt counts the runs of the same task, step and kind, " + "from 1. agent is the claim of the role that ran the step, and model is the model that " + "answered it, as provider/model. result is passed, failed or stopped. A field with no " + "value prints -, and a run that has not ended prints running for its end and its result. " + "A closed issue's steps read too. An issue that no step ran on prints 0 steps in 0 tasks, " + "and a key Dispatch does not hold fails as dispatch read fails for it, NOT_FOUND: not " + `found. ${ISSUE_REFERENCE}`,
|
|
37517
|
+
arguments: (z) => ({
|
|
37518
|
+
issue: z.string().describe(ISSUE_REFERENCE)
|
|
37519
|
+
}),
|
|
37520
|
+
strict: true
|
|
37521
|
+
},
|
|
37513
37522
|
{
|
|
37514
37523
|
name: "dispatch_inbox",
|
|
37515
37524
|
example: {},
|
|
@@ -37886,6 +37895,7 @@ var commentEventPayloadFields = {
|
|
|
37886
37895
|
ask_question: string2().optional(),
|
|
37887
37896
|
ask_state: askFields.state.optional(),
|
|
37888
37897
|
ask_waiting_on: _enum2(ASK_TURNS).optional(),
|
|
37898
|
+
ask_sessions: array(string2()).optional(),
|
|
37889
37899
|
...referenceChangesFields,
|
|
37890
37900
|
...threadLoginsFields,
|
|
37891
37901
|
...carriedBodyFields
|
|
@@ -37893,6 +37903,7 @@ var commentEventPayloadFields = {
|
|
|
37893
37903
|
var WrittenCommentEventPayloadSchema = strictObject(commentEventPayloadFields).readonly();
|
|
37894
37904
|
var CommentEventPayloadSchema = object({
|
|
37895
37905
|
id: commentFields.id.optional(),
|
|
37906
|
+
artifact_id: commentFields.artifact_id,
|
|
37896
37907
|
artifact_name: commentEventPayloadFields.artifact_name.optional(),
|
|
37897
37908
|
project_key: commentEventPayloadFields.project_key,
|
|
37898
37909
|
artifact_slug: commentEventPayloadFields.artifact_slug,
|
|
@@ -37902,6 +37913,7 @@ var CommentEventPayloadSchema = object({
|
|
|
37902
37913
|
ask_question: commentEventPayloadFields.ask_question,
|
|
37903
37914
|
ask_state: commentEventPayloadFields.ask_state,
|
|
37904
37915
|
ask_waiting_on: commentEventPayloadFields.ask_waiting_on,
|
|
37916
|
+
ask_sessions: commentEventPayloadFields.ask_sessions,
|
|
37905
37917
|
turn: commentFields.turn.optional(),
|
|
37906
37918
|
anchor: object({
|
|
37907
37919
|
artifact_id: anchorFields.artifact_id.optional(),
|
|
@@ -44302,6 +44314,9 @@ class DispatchClient {
|
|
|
44302
44314
|
async handoff(id) {
|
|
44303
44315
|
return this.#json("GET", ["api", "v1", "handoffs", id]);
|
|
44304
44316
|
}
|
|
44317
|
+
async listSteps(issue) {
|
|
44318
|
+
return this.#json("GET", ["api", "v1", "issues", await this.#resolveIssue(issue), "steps"]);
|
|
44319
|
+
}
|
|
44305
44320
|
async getIssueReferences(issue) {
|
|
44306
44321
|
return this.#json("GET", ["api", "v1", "issues", await this.#resolveIssue(issue), "references"], undefined, { versions: "latest" });
|
|
44307
44322
|
}
|
|
@@ -46342,6 +46357,27 @@ ${body}${fence}${note ? `
|
|
|
46342
46357
|
${HUMAN_EDIT_DIFF_CUT_NOTE}` : ""}`;
|
|
46343
46358
|
}
|
|
46344
46359
|
|
|
46360
|
+
// ../envoy-client/src/session-answer-relations.ts
|
|
46361
|
+
var RELATION_PHRASES = {
|
|
46362
|
+
answered_your_ask: "answered your ask",
|
|
46363
|
+
answered_an_ask: "answered an ask",
|
|
46364
|
+
declined_your_ask: "declined to answer your ask",
|
|
46365
|
+
declined_an_ask: "declined to answer an ask",
|
|
46366
|
+
replied_on_your_ask: "replied on your ask",
|
|
46367
|
+
replied_in_a_comment_thread: "replied in a comment thread",
|
|
46368
|
+
commented_on_a_document: "commented on a document",
|
|
46369
|
+
commented_on_an_issue: "commented on an issue",
|
|
46370
|
+
mentioned_you: "mentioned you",
|
|
46371
|
+
sent_you_a_message: "sent you a message",
|
|
46372
|
+
replied_to_your_message: "replied to your message"
|
|
46373
|
+
};
|
|
46374
|
+
function isSessionAnswerRelation(value) {
|
|
46375
|
+
return Object.hasOwn(RELATION_PHRASES, value);
|
|
46376
|
+
}
|
|
46377
|
+
function sessionAnswerRelationPhrase(relation) {
|
|
46378
|
+
return isSessionAnswerRelation(relation) ? RELATION_PHRASES[relation] : relation;
|
|
46379
|
+
}
|
|
46380
|
+
|
|
46345
46381
|
// ../envoy-client/src/delivery.ts
|
|
46346
46382
|
var KNOWN_SOURCES = EnvelopeSchema.shape.source.enum;
|
|
46347
46383
|
var FOREIGN_SESSION_ID = /\b01a0[0-9a-f]{4}-[0-9a-f]{4}-7[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}\b/g;
|
|
@@ -46548,8 +46584,11 @@ function carriedItem(event) {
|
|
|
46548
46584
|
return;
|
|
46549
46585
|
return { resource, id, issueKey: event.issue_key };
|
|
46550
46586
|
}
|
|
46587
|
+
function payloadWasOmitted(payload) {
|
|
46588
|
+
return isObject3(payload) && payload["payload_omitted"] === true;
|
|
46589
|
+
}
|
|
46551
46590
|
function bodyWasCut(payload) {
|
|
46552
|
-
return isObject3(payload) &&
|
|
46591
|
+
return isObject3(payload) && payload["body_truncated"] === true || payloadWasOmitted(payload);
|
|
46553
46592
|
}
|
|
46554
46593
|
function wholeItemRoute(item) {
|
|
46555
46594
|
return `GET /api/v1/${item.resource === "comment" ? "comments" : "messages"}/${item.id}`;
|
|
@@ -46557,7 +46596,7 @@ function wholeItemRoute(item) {
|
|
|
46557
46596
|
function carriedBodyNote(event) {
|
|
46558
46597
|
if (!bodyWasCut(event.payload))
|
|
46559
46598
|
return;
|
|
46560
|
-
const what =
|
|
46599
|
+
const what = payloadWasOmitted(event.payload) ? "this event carries no body: it was too large for the bus" : "the body is its first part only";
|
|
46561
46600
|
const item = carriedItem(event);
|
|
46562
46601
|
return item === undefined ? what : `${what}; read it whole with ${wholeItemRoute(item)}`;
|
|
46563
46602
|
}
|
|
@@ -46660,6 +46699,24 @@ function dispatchCommentReplyWith(event, topic, comment) {
|
|
|
46660
46699
|
})
|
|
46661
46700
|
};
|
|
46662
46701
|
}
|
|
46702
|
+
function ownsRepliedAsk(comment, sessionID) {
|
|
46703
|
+
if (comment?.ask_id === undefined || comment.ask_id === null)
|
|
46704
|
+
return;
|
|
46705
|
+
return comment.ask_sessions?.includes(sessionID);
|
|
46706
|
+
}
|
|
46707
|
+
function repliedAskRelation(event, comment, owns, mentioned) {
|
|
46708
|
+
if (owns)
|
|
46709
|
+
return "replied_on_your_ask";
|
|
46710
|
+
if (mentioned)
|
|
46711
|
+
return "mentioned_you";
|
|
46712
|
+
if (comment.reply_to !== undefined && comment.reply_to !== null) {
|
|
46713
|
+
return "replied_in_a_comment_thread";
|
|
46714
|
+
}
|
|
46715
|
+
if (comment.artifact_id !== undefined && comment.artifact_id !== null || comment.anchor?.artifact_id !== undefined || event.issue_key === null) {
|
|
46716
|
+
return "commented_on_a_document";
|
|
46717
|
+
}
|
|
46718
|
+
return "commented_on_an_issue";
|
|
46719
|
+
}
|
|
46663
46720
|
function askResolutionText(resolution) {
|
|
46664
46721
|
if (resolution === null || resolution === undefined)
|
|
46665
46722
|
return;
|
|
@@ -46669,7 +46726,7 @@ function askResolutionText(resolution) {
|
|
|
46669
46726
|
const words = dispatchWordsText(resolution.dispatch_words);
|
|
46670
46727
|
return words === undefined ? closed : `${closed} \xB7 ${words}`;
|
|
46671
46728
|
}
|
|
46672
|
-
function dispatchCompact(event, comment) {
|
|
46729
|
+
function dispatchCompact(event, comment, ownsAsk) {
|
|
46673
46730
|
if (event.type === "artifact.human_edited") {
|
|
46674
46731
|
const edit = ArtifactHumanEditedEventPayloadSchema.safeParse(event.payload);
|
|
46675
46732
|
if (!edit.success)
|
|
@@ -46686,7 +46743,7 @@ function dispatchCompact(event, comment) {
|
|
|
46686
46743
|
...question === undefined ? {} : { question },
|
|
46687
46744
|
reply: comment.body ?? "",
|
|
46688
46745
|
...comment.ask_state === undefined ? {} : { state: comment.ask_state },
|
|
46689
|
-
...comment.ask_waiting_on === undefined ? {} : { waiting_on: comment.ask_waiting_on }
|
|
46746
|
+
...comment.ask_waiting_on === undefined || ownsAsk === false ? {} : { waiting_on: comment.ask_waiting_on }
|
|
46690
46747
|
}
|
|
46691
46748
|
};
|
|
46692
46749
|
}
|
|
@@ -46893,7 +46950,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
46893
46950
|
let bodyNote;
|
|
46894
46951
|
let cutItem;
|
|
46895
46952
|
let inReplyTo = envelope.in_reply_to;
|
|
46896
|
-
let
|
|
46953
|
+
let payloadSessions = [];
|
|
46897
46954
|
let trailer = "";
|
|
46898
46955
|
const dispatchRendered = envelope.source === "dispatch" && envelope.payload !== undefined;
|
|
46899
46956
|
if (envelope.source === "dispatch") {
|
|
@@ -46938,11 +46995,13 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
46938
46995
|
}
|
|
46939
46996
|
const comment = frame.event.type === "comment.created" ? CommentEventPayloadSchema.safeParse(frame.event.payload) : undefined;
|
|
46940
46997
|
const commentPayload = comment?.success === true ? comment.data : undefined;
|
|
46941
|
-
const
|
|
46998
|
+
const ownsAsk = ownsRepliedAsk(commentPayload, sessionID);
|
|
46999
|
+
const compact = dispatchCompact(frame.event, commentPayload, ownsAsk);
|
|
47000
|
+
payloadSessions = commentPayload?.ask_sessions ?? [];
|
|
46942
47001
|
if (frame.event.type.startsWith("ask.")) {
|
|
46943
47002
|
const asked = AskAuthorPayloadSchema.safeParse(frame.event.payload);
|
|
46944
47003
|
if (asked.success && asked.data.author.kind === "session") {
|
|
46945
|
-
|
|
47004
|
+
payloadSessions = [asked.data.author.id];
|
|
46946
47005
|
}
|
|
46947
47006
|
}
|
|
46948
47007
|
if (inReplyTo !== undefined) {
|
|
@@ -46990,6 +47049,10 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
46990
47049
|
};
|
|
46991
47050
|
}
|
|
46992
47051
|
}
|
|
47052
|
+
const mentioned = delivery !== undefined;
|
|
47053
|
+
const relation = ownsAsk === undefined || commentPayload === undefined ? undefined : sessionAnswerRelationPhrase(repliedAskRelation(frame.event, commentPayload, ownsAsk, mentioned));
|
|
47054
|
+
if (ownsAsk === false && !mentioned)
|
|
47055
|
+
dispatchReply = undefined;
|
|
46993
47056
|
const compactRecord = compact === undefined ? undefined : inReplyTo !== undefined || compact.askId === undefined ? compact.record : {
|
|
46994
47057
|
ask: dispatchReplyRef(frame.event, topic, compact.askId, commentPayload),
|
|
46995
47058
|
...compact.record
|
|
@@ -46998,6 +47061,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
46998
47061
|
owner: dispatchOwner(frame.event, topic),
|
|
46999
47062
|
type: frame.event.type,
|
|
47000
47063
|
actor: frame.event.actor,
|
|
47064
|
+
...relation === undefined ? {} : { relation },
|
|
47001
47065
|
...compactRecord ?? { payload: dispatchPayloadForReader(frame.event, sessionID) }
|
|
47002
47066
|
};
|
|
47003
47067
|
dispatchActor = frame.event.actor;
|
|
@@ -47031,7 +47095,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
47031
47095
|
let foreignSession;
|
|
47032
47096
|
for (const part of [envelope.payload_summary ?? "", envelope.payload ?? ""]) {
|
|
47033
47097
|
for (const match of part.matchAll(FOREIGN_SESSION_ID)) {
|
|
47034
|
-
if (match[0] !== envelope.source_session && match[0] !== sessionID && match[0]
|
|
47098
|
+
if (match[0] !== envelope.source_session && match[0] !== sessionID && !payloadSessions.includes(match[0])) {
|
|
47035
47099
|
foreignSession = match[0];
|
|
47036
47100
|
break;
|
|
47037
47101
|
}
|
|
@@ -51575,25 +51639,11 @@ var NO_ROUTE_BACKOFF_MS = 5 * 60000;
|
|
|
51575
51639
|
var SESSION_ANSWERS_MARKER = "[Dispatch: what people wrote to this session in the last 72 hours, newest first, word for word. Reference, not a new request.]";
|
|
51576
51640
|
var FAILURE_MARKER = "[Dispatch: people's answers from the last 72 hours could not be read (";
|
|
51577
51641
|
var NO_ANSWERS_ROUTE_REASON = "this Dispatch build has no answers route";
|
|
51578
|
-
var RELATION_PHRASES = {
|
|
51579
|
-
answered_your_ask: "answered your ask",
|
|
51580
|
-
declined_your_ask: "declined to answer your ask",
|
|
51581
|
-
replied_on_your_ask: "replied on your ask",
|
|
51582
|
-
replied_in_a_comment_thread: "replied in a comment thread",
|
|
51583
|
-
commented_on_a_document: "commented on a document",
|
|
51584
|
-
commented_on_an_issue: "commented on an issue",
|
|
51585
|
-
mentioned_you: "mentioned you",
|
|
51586
|
-
sent_you_a_message: "sent you a message",
|
|
51587
|
-
replied_to_your_message: "replied to your message"
|
|
51588
|
-
};
|
|
51589
|
-
function isSessionAnswerRelation(value) {
|
|
51590
|
-
return Object.hasOwn(RELATION_PHRASES, value);
|
|
51591
|
-
}
|
|
51592
51642
|
function isNoAnswersRoute(error) {
|
|
51593
51643
|
return isNoRoute(error) || error instanceof DispatchNoRouteError;
|
|
51594
51644
|
}
|
|
51595
51645
|
function renderSessionAnswerItem(item) {
|
|
51596
|
-
const phrase =
|
|
51646
|
+
const phrase = sessionAnswerRelationPhrase(item.relation);
|
|
51597
51647
|
const relation = `${phrase}${item.replaced === true ? " (replaces an earlier answer)" : ""}`;
|
|
51598
51648
|
const head = [item.at, actorActText(`user ${item.author.id}`, item.author.act), relation];
|
|
51599
51649
|
if (item.edited_at !== undefined)
|
|
@@ -51634,7 +51684,8 @@ function sessionAnswersWords(items) {
|
|
|
51634
51684
|
item.at,
|
|
51635
51685
|
item.edited_at ?? null,
|
|
51636
51686
|
item.selected ?? null,
|
|
51637
|
-
item.text
|
|
51687
|
+
item.text,
|
|
51688
|
+
item.relation
|
|
51638
51689
|
]));
|
|
51639
51690
|
}
|
|
51640
51691
|
var MAX_CHARS_TEXT = SESSION_ANSWERS_MAX_CHARS.toLocaleString("en-US");
|
|
@@ -52063,6 +52114,40 @@ async function inboxCommand(context) {
|
|
|
52063
52114
|
};
|
|
52064
52115
|
}
|
|
52065
52116
|
|
|
52117
|
+
// ../envoy-client/src/dispatch-commands/steps.ts
|
|
52118
|
+
function orDash(value) {
|
|
52119
|
+
return value === null || value === "" ? "-" : value;
|
|
52120
|
+
}
|
|
52121
|
+
function stepLine(record) {
|
|
52122
|
+
return [
|
|
52123
|
+
record.task,
|
|
52124
|
+
record.step,
|
|
52125
|
+
record.kind,
|
|
52126
|
+
record.role,
|
|
52127
|
+
orDash(record.type),
|
|
52128
|
+
"attempt",
|
|
52129
|
+
record.attempt,
|
|
52130
|
+
orDash(record.agent),
|
|
52131
|
+
orDash(record.model),
|
|
52132
|
+
orDash(record.started_at),
|
|
52133
|
+
...record.ended_at === null ? ["running", "running"] : [record.ended_at, orDash(record.result)]
|
|
52134
|
+
].join(" ");
|
|
52135
|
+
}
|
|
52136
|
+
async function stepsCommand(context) {
|
|
52137
|
+
const { client, issue } = context;
|
|
52138
|
+
const read = await client.listSteps(issue());
|
|
52139
|
+
const tasks = (read.tasks ?? []).map((task) => ({ task: task.task, steps: task.steps ?? [] }));
|
|
52140
|
+
const records = tasks.flatMap((task) => task.steps);
|
|
52141
|
+
return {
|
|
52142
|
+
text: [
|
|
52143
|
+
`${read.issue}: ${records.length} steps in ${tasks.length} tasks`,
|
|
52144
|
+
...records.map(stepLine)
|
|
52145
|
+
].join(`
|
|
52146
|
+
`),
|
|
52147
|
+
details: { issue: read.issue, tasks }
|
|
52148
|
+
};
|
|
52149
|
+
}
|
|
52150
|
+
|
|
52066
52151
|
// ../envoy-client/src/dispatch-commands/table.ts
|
|
52067
52152
|
function acting(run) {
|
|
52068
52153
|
return { origin: "resolved", run };
|
|
@@ -52101,6 +52186,7 @@ var dispatchCommands = {
|
|
|
52101
52186
|
dispatch_artifact: acting(artifactCommand),
|
|
52102
52187
|
dispatch_handoff_write: acting(handoffWriteCommand),
|
|
52103
52188
|
dispatch_handoff_read: acting(handoffReadCommand),
|
|
52189
|
+
dispatch_steps: acting(stepsCommand),
|
|
52104
52190
|
dispatch_read: acting(readCommand),
|
|
52105
52191
|
dispatch_answers: onSession(answersCommand),
|
|
52106
52192
|
dispatch_whoami: onSession(whoamiCommand),
|
|
@@ -57782,7 +57868,7 @@ var import_nats2 = __toESM(require_mod4(), 1);
|
|
|
57782
57868
|
|
|
57783
57869
|
// package.json
|
|
57784
57870
|
var name2 = "@sjawhar/claude-envoy";
|
|
57785
|
-
var version2 = "4.
|
|
57871
|
+
var version2 = "4.5.0";
|
|
57786
57872
|
var legion = {
|
|
57787
57873
|
daemonApiVersion: 152
|
|
57788
57874
|
};
|
package/dist/session-hook.js
CHANGED
|
@@ -14855,6 +14855,15 @@ var dispatchToolSpecs = [
|
|
|
14855
14855
|
validation: handoffValidation,
|
|
14856
14856
|
strict: true
|
|
14857
14857
|
},
|
|
14858
|
+
{
|
|
14859
|
+
name: "dispatch_steps",
|
|
14860
|
+
example: { issue: "DSP-1" },
|
|
14861
|
+
description: "Print each step that ran on an issue, as the Legion daemon recorded it at the step's " + "start and at its end. The first line is `<KEY>: <n> steps in <m> tasks`. Then each run " + "of a step prints one line, task by task, in the order each task first ran: `<task> " + "<step> <kind> <role> <type> attempt <attempt> <agent> <model> <started_at> <ended_at> " + "<result>`. kind is step, retro or merge. step is the step's place in its task, from 1, " + "and 0 for a retro or a merge. attempt counts the runs of the same task, step and kind, " + "from 1. agent is the claim of the role that ran the step, and model is the model that " + "answered it, as provider/model. result is passed, failed or stopped. A field with no " + "value prints -, and a run that has not ended prints running for its end and its result. " + "A closed issue's steps read too. An issue that no step ran on prints 0 steps in 0 tasks, " + "and a key Dispatch does not hold fails as dispatch read fails for it, NOT_FOUND: not " + `found. ${ISSUE_REFERENCE}`,
|
|
14862
|
+
arguments: (z) => ({
|
|
14863
|
+
issue: z.string().describe(ISSUE_REFERENCE)
|
|
14864
|
+
}),
|
|
14865
|
+
strict: true
|
|
14866
|
+
},
|
|
14858
14867
|
{
|
|
14859
14868
|
name: "dispatch_inbox",
|
|
14860
14869
|
example: {},
|
|
@@ -15231,6 +15240,7 @@ var commentEventPayloadFields = {
|
|
|
15231
15240
|
ask_question: string2().optional(),
|
|
15232
15241
|
ask_state: askFields.state.optional(),
|
|
15233
15242
|
ask_waiting_on: _enum2(ASK_TURNS).optional(),
|
|
15243
|
+
ask_sessions: array(string2()).optional(),
|
|
15234
15244
|
...referenceChangesFields,
|
|
15235
15245
|
...threadLoginsFields,
|
|
15236
15246
|
...carriedBodyFields
|
|
@@ -15238,6 +15248,7 @@ var commentEventPayloadFields = {
|
|
|
15238
15248
|
var WrittenCommentEventPayloadSchema = strictObject(commentEventPayloadFields).readonly();
|
|
15239
15249
|
var CommentEventPayloadSchema = object({
|
|
15240
15250
|
id: commentFields.id.optional(),
|
|
15251
|
+
artifact_id: commentFields.artifact_id,
|
|
15241
15252
|
artifact_name: commentEventPayloadFields.artifact_name.optional(),
|
|
15242
15253
|
project_key: commentEventPayloadFields.project_key,
|
|
15243
15254
|
artifact_slug: commentEventPayloadFields.artifact_slug,
|
|
@@ -15247,6 +15258,7 @@ var CommentEventPayloadSchema = object({
|
|
|
15247
15258
|
ask_question: commentEventPayloadFields.ask_question,
|
|
15248
15259
|
ask_state: commentEventPayloadFields.ask_state,
|
|
15249
15260
|
ask_waiting_on: commentEventPayloadFields.ask_waiting_on,
|
|
15261
|
+
ask_sessions: commentEventPayloadFields.ask_sessions,
|
|
15250
15262
|
turn: commentFields.turn.optional(),
|
|
15251
15263
|
anchor: object({
|
|
15252
15264
|
artifact_id: anchorFields.artifact_id.optional(),
|
|
@@ -18986,6 +18998,9 @@ class DispatchClient {
|
|
|
18986
18998
|
async handoff(id) {
|
|
18987
18999
|
return this.#json("GET", ["api", "v1", "handoffs", id]);
|
|
18988
19000
|
}
|
|
19001
|
+
async listSteps(issue) {
|
|
19002
|
+
return this.#json("GET", ["api", "v1", "issues", await this.#resolveIssue(issue), "steps"]);
|
|
19003
|
+
}
|
|
18989
19004
|
async getIssueReferences(issue) {
|
|
18990
19005
|
return this.#json("GET", ["api", "v1", "issues", await this.#resolveIssue(issue), "references"], undefined, { versions: "latest" });
|
|
18991
19006
|
}
|
|
@@ -19376,6 +19391,27 @@ ${body}${fence}${note ? `
|
|
|
19376
19391
|
${HUMAN_EDIT_DIFF_CUT_NOTE}` : ""}`;
|
|
19377
19392
|
}
|
|
19378
19393
|
|
|
19394
|
+
// ../envoy-client/src/session-answer-relations.ts
|
|
19395
|
+
var RELATION_PHRASES = {
|
|
19396
|
+
answered_your_ask: "answered your ask",
|
|
19397
|
+
answered_an_ask: "answered an ask",
|
|
19398
|
+
declined_your_ask: "declined to answer your ask",
|
|
19399
|
+
declined_an_ask: "declined to answer an ask",
|
|
19400
|
+
replied_on_your_ask: "replied on your ask",
|
|
19401
|
+
replied_in_a_comment_thread: "replied in a comment thread",
|
|
19402
|
+
commented_on_a_document: "commented on a document",
|
|
19403
|
+
commented_on_an_issue: "commented on an issue",
|
|
19404
|
+
mentioned_you: "mentioned you",
|
|
19405
|
+
sent_you_a_message: "sent you a message",
|
|
19406
|
+
replied_to_your_message: "replied to your message"
|
|
19407
|
+
};
|
|
19408
|
+
function isSessionAnswerRelation(value) {
|
|
19409
|
+
return Object.hasOwn(RELATION_PHRASES, value);
|
|
19410
|
+
}
|
|
19411
|
+
function sessionAnswerRelationPhrase(relation) {
|
|
19412
|
+
return isSessionAnswerRelation(relation) ? RELATION_PHRASES[relation] : relation;
|
|
19413
|
+
}
|
|
19414
|
+
|
|
19379
19415
|
// ../envoy-client/src/delivery.ts
|
|
19380
19416
|
var KNOWN_SOURCES = EnvelopeSchema.shape.source.enum;
|
|
19381
19417
|
var FOREIGN_SESSION_ID = /\b01a0[0-9a-f]{4}-[0-9a-f]{4}-7[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}\b/g;
|
|
@@ -19582,8 +19618,11 @@ function carriedItem(event) {
|
|
|
19582
19618
|
return;
|
|
19583
19619
|
return { resource, id, issueKey: event.issue_key };
|
|
19584
19620
|
}
|
|
19621
|
+
function payloadWasOmitted(payload) {
|
|
19622
|
+
return isObject2(payload) && payload["payload_omitted"] === true;
|
|
19623
|
+
}
|
|
19585
19624
|
function bodyWasCut(payload) {
|
|
19586
|
-
return isObject2(payload) &&
|
|
19625
|
+
return isObject2(payload) && payload["body_truncated"] === true || payloadWasOmitted(payload);
|
|
19587
19626
|
}
|
|
19588
19627
|
function wholeItemRoute(item) {
|
|
19589
19628
|
return `GET /api/v1/${item.resource === "comment" ? "comments" : "messages"}/${item.id}`;
|
|
@@ -19591,7 +19630,7 @@ function wholeItemRoute(item) {
|
|
|
19591
19630
|
function carriedBodyNote(event) {
|
|
19592
19631
|
if (!bodyWasCut(event.payload))
|
|
19593
19632
|
return;
|
|
19594
|
-
const what =
|
|
19633
|
+
const what = payloadWasOmitted(event.payload) ? "this event carries no body: it was too large for the bus" : "the body is its first part only";
|
|
19595
19634
|
const item = carriedItem(event);
|
|
19596
19635
|
return item === undefined ? what : `${what}; read it whole with ${wholeItemRoute(item)}`;
|
|
19597
19636
|
}
|
|
@@ -19694,6 +19733,24 @@ function dispatchCommentReplyWith(event, topic, comment) {
|
|
|
19694
19733
|
})
|
|
19695
19734
|
};
|
|
19696
19735
|
}
|
|
19736
|
+
function ownsRepliedAsk(comment, sessionID) {
|
|
19737
|
+
if (comment?.ask_id === undefined || comment.ask_id === null)
|
|
19738
|
+
return;
|
|
19739
|
+
return comment.ask_sessions?.includes(sessionID);
|
|
19740
|
+
}
|
|
19741
|
+
function repliedAskRelation(event, comment, owns, mentioned) {
|
|
19742
|
+
if (owns)
|
|
19743
|
+
return "replied_on_your_ask";
|
|
19744
|
+
if (mentioned)
|
|
19745
|
+
return "mentioned_you";
|
|
19746
|
+
if (comment.reply_to !== undefined && comment.reply_to !== null) {
|
|
19747
|
+
return "replied_in_a_comment_thread";
|
|
19748
|
+
}
|
|
19749
|
+
if (comment.artifact_id !== undefined && comment.artifact_id !== null || comment.anchor?.artifact_id !== undefined || event.issue_key === null) {
|
|
19750
|
+
return "commented_on_a_document";
|
|
19751
|
+
}
|
|
19752
|
+
return "commented_on_an_issue";
|
|
19753
|
+
}
|
|
19697
19754
|
function askResolutionText(resolution) {
|
|
19698
19755
|
if (resolution === null || resolution === undefined)
|
|
19699
19756
|
return;
|
|
@@ -19703,7 +19760,7 @@ function askResolutionText(resolution) {
|
|
|
19703
19760
|
const words = dispatchWordsText(resolution.dispatch_words);
|
|
19704
19761
|
return words === undefined ? closed : `${closed} \xB7 ${words}`;
|
|
19705
19762
|
}
|
|
19706
|
-
function dispatchCompact(event, comment) {
|
|
19763
|
+
function dispatchCompact(event, comment, ownsAsk) {
|
|
19707
19764
|
if (event.type === "artifact.human_edited") {
|
|
19708
19765
|
const edit = ArtifactHumanEditedEventPayloadSchema.safeParse(event.payload);
|
|
19709
19766
|
if (!edit.success)
|
|
@@ -19720,7 +19777,7 @@ function dispatchCompact(event, comment) {
|
|
|
19720
19777
|
...question === undefined ? {} : { question },
|
|
19721
19778
|
reply: comment.body ?? "",
|
|
19722
19779
|
...comment.ask_state === undefined ? {} : { state: comment.ask_state },
|
|
19723
|
-
...comment.ask_waiting_on === undefined ? {} : { waiting_on: comment.ask_waiting_on }
|
|
19780
|
+
...comment.ask_waiting_on === undefined || ownsAsk === false ? {} : { waiting_on: comment.ask_waiting_on }
|
|
19724
19781
|
}
|
|
19725
19782
|
};
|
|
19726
19783
|
}
|
|
@@ -19927,7 +19984,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
19927
19984
|
let bodyNote;
|
|
19928
19985
|
let cutItem;
|
|
19929
19986
|
let inReplyTo = envelope.in_reply_to;
|
|
19930
|
-
let
|
|
19987
|
+
let payloadSessions = [];
|
|
19931
19988
|
let trailer = "";
|
|
19932
19989
|
const dispatchRendered = envelope.source === "dispatch" && envelope.payload !== undefined;
|
|
19933
19990
|
if (envelope.source === "dispatch") {
|
|
@@ -19972,11 +20029,13 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
19972
20029
|
}
|
|
19973
20030
|
const comment = frame.event.type === "comment.created" ? CommentEventPayloadSchema.safeParse(frame.event.payload) : undefined;
|
|
19974
20031
|
const commentPayload = comment?.success === true ? comment.data : undefined;
|
|
19975
|
-
const
|
|
20032
|
+
const ownsAsk = ownsRepliedAsk(commentPayload, sessionID);
|
|
20033
|
+
const compact = dispatchCompact(frame.event, commentPayload, ownsAsk);
|
|
20034
|
+
payloadSessions = commentPayload?.ask_sessions ?? [];
|
|
19976
20035
|
if (frame.event.type.startsWith("ask.")) {
|
|
19977
20036
|
const asked = AskAuthorPayloadSchema.safeParse(frame.event.payload);
|
|
19978
20037
|
if (asked.success && asked.data.author.kind === "session") {
|
|
19979
|
-
|
|
20038
|
+
payloadSessions = [asked.data.author.id];
|
|
19980
20039
|
}
|
|
19981
20040
|
}
|
|
19982
20041
|
if (inReplyTo !== undefined) {
|
|
@@ -20024,6 +20083,10 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
20024
20083
|
};
|
|
20025
20084
|
}
|
|
20026
20085
|
}
|
|
20086
|
+
const mentioned = delivery !== undefined;
|
|
20087
|
+
const relation = ownsAsk === undefined || commentPayload === undefined ? undefined : sessionAnswerRelationPhrase(repliedAskRelation(frame.event, commentPayload, ownsAsk, mentioned));
|
|
20088
|
+
if (ownsAsk === false && !mentioned)
|
|
20089
|
+
dispatchReply = undefined;
|
|
20027
20090
|
const compactRecord = compact === undefined ? undefined : inReplyTo !== undefined || compact.askId === undefined ? compact.record : {
|
|
20028
20091
|
ask: dispatchReplyRef(frame.event, topic, compact.askId, commentPayload),
|
|
20029
20092
|
...compact.record
|
|
@@ -20032,6 +20095,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
20032
20095
|
owner: dispatchOwner(frame.event, topic),
|
|
20033
20096
|
type: frame.event.type,
|
|
20034
20097
|
actor: frame.event.actor,
|
|
20098
|
+
...relation === undefined ? {} : { relation },
|
|
20035
20099
|
...compactRecord ?? { payload: dispatchPayloadForReader(frame.event, sessionID) }
|
|
20036
20100
|
};
|
|
20037
20101
|
dispatchActor = frame.event.actor;
|
|
@@ -20065,7 +20129,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
20065
20129
|
let foreignSession;
|
|
20066
20130
|
for (const part of [envelope.payload_summary ?? "", envelope.payload ?? ""]) {
|
|
20067
20131
|
for (const match of part.matchAll(FOREIGN_SESSION_ID)) {
|
|
20068
|
-
if (match[0] !== envelope.source_session && match[0] !== sessionID && match[0]
|
|
20132
|
+
if (match[0] !== envelope.source_session && match[0] !== sessionID && !payloadSessions.includes(match[0])) {
|
|
20069
20133
|
foreignSession = match[0];
|
|
20070
20134
|
break;
|
|
20071
20135
|
}
|
|
@@ -24641,25 +24705,11 @@ var NO_ROUTE_BACKOFF_MS = 5 * 60000;
|
|
|
24641
24705
|
var SESSION_ANSWERS_MARKER = "[Dispatch: what people wrote to this session in the last 72 hours, newest first, word for word. Reference, not a new request.]";
|
|
24642
24706
|
var FAILURE_MARKER = "[Dispatch: people's answers from the last 72 hours could not be read (";
|
|
24643
24707
|
var NO_ANSWERS_ROUTE_REASON = "this Dispatch build has no answers route";
|
|
24644
|
-
var RELATION_PHRASES = {
|
|
24645
|
-
answered_your_ask: "answered your ask",
|
|
24646
|
-
declined_your_ask: "declined to answer your ask",
|
|
24647
|
-
replied_on_your_ask: "replied on your ask",
|
|
24648
|
-
replied_in_a_comment_thread: "replied in a comment thread",
|
|
24649
|
-
commented_on_a_document: "commented on a document",
|
|
24650
|
-
commented_on_an_issue: "commented on an issue",
|
|
24651
|
-
mentioned_you: "mentioned you",
|
|
24652
|
-
sent_you_a_message: "sent you a message",
|
|
24653
|
-
replied_to_your_message: "replied to your message"
|
|
24654
|
-
};
|
|
24655
|
-
function isSessionAnswerRelation(value) {
|
|
24656
|
-
return Object.hasOwn(RELATION_PHRASES, value);
|
|
24657
|
-
}
|
|
24658
24708
|
function isNoAnswersRoute(error) {
|
|
24659
24709
|
return isNoRoute(error) || error instanceof DispatchNoRouteError;
|
|
24660
24710
|
}
|
|
24661
24711
|
function renderSessionAnswerItem(item) {
|
|
24662
|
-
const phrase =
|
|
24712
|
+
const phrase = sessionAnswerRelationPhrase(item.relation);
|
|
24663
24713
|
const relation = `${phrase}${item.replaced === true ? " (replaces an earlier answer)" : ""}`;
|
|
24664
24714
|
const head = [item.at, actorActText(`user ${item.author.id}`, item.author.act), relation];
|
|
24665
24715
|
if (item.edited_at !== undefined)
|
|
@@ -24700,7 +24750,8 @@ function sessionAnswersWords(items) {
|
|
|
24700
24750
|
item.at,
|
|
24701
24751
|
item.edited_at ?? null,
|
|
24702
24752
|
item.selected ?? null,
|
|
24703
|
-
item.text
|
|
24753
|
+
item.text,
|
|
24754
|
+
item.relation
|
|
24704
24755
|
]));
|
|
24705
24756
|
}
|
|
24706
24757
|
var MAX_CHARS_TEXT = SESSION_ANSWERS_MAX_CHARS.toLocaleString("en-US");
|
|
@@ -25129,6 +25180,40 @@ async function inboxCommand(context) {
|
|
|
25129
25180
|
};
|
|
25130
25181
|
}
|
|
25131
25182
|
|
|
25183
|
+
// ../envoy-client/src/dispatch-commands/steps.ts
|
|
25184
|
+
function orDash(value) {
|
|
25185
|
+
return value === null || value === "" ? "-" : value;
|
|
25186
|
+
}
|
|
25187
|
+
function stepLine(record) {
|
|
25188
|
+
return [
|
|
25189
|
+
record.task,
|
|
25190
|
+
record.step,
|
|
25191
|
+
record.kind,
|
|
25192
|
+
record.role,
|
|
25193
|
+
orDash(record.type),
|
|
25194
|
+
"attempt",
|
|
25195
|
+
record.attempt,
|
|
25196
|
+
orDash(record.agent),
|
|
25197
|
+
orDash(record.model),
|
|
25198
|
+
orDash(record.started_at),
|
|
25199
|
+
...record.ended_at === null ? ["running", "running"] : [record.ended_at, orDash(record.result)]
|
|
25200
|
+
].join(" ");
|
|
25201
|
+
}
|
|
25202
|
+
async function stepsCommand(context) {
|
|
25203
|
+
const { client, issue } = context;
|
|
25204
|
+
const read = await client.listSteps(issue());
|
|
25205
|
+
const tasks = (read.tasks ?? []).map((task) => ({ task: task.task, steps: task.steps ?? [] }));
|
|
25206
|
+
const records = tasks.flatMap((task) => task.steps);
|
|
25207
|
+
return {
|
|
25208
|
+
text: [
|
|
25209
|
+
`${read.issue}: ${records.length} steps in ${tasks.length} tasks`,
|
|
25210
|
+
...records.map(stepLine)
|
|
25211
|
+
].join(`
|
|
25212
|
+
`),
|
|
25213
|
+
details: { issue: read.issue, tasks }
|
|
25214
|
+
};
|
|
25215
|
+
}
|
|
25216
|
+
|
|
25132
25217
|
// ../envoy-client/src/dispatch-commands/table.ts
|
|
25133
25218
|
function acting(run) {
|
|
25134
25219
|
return { origin: "resolved", run };
|
|
@@ -25167,6 +25252,7 @@ var dispatchCommands = {
|
|
|
25167
25252
|
dispatch_artifact: acting(artifactCommand),
|
|
25168
25253
|
dispatch_handoff_write: acting(handoffWriteCommand),
|
|
25169
25254
|
dispatch_handoff_read: acting(handoffReadCommand),
|
|
25255
|
+
dispatch_steps: acting(stepsCommand),
|
|
25170
25256
|
dispatch_read: acting(readCommand),
|
|
25171
25257
|
dispatch_answers: onSession(answersCommand),
|
|
25172
25258
|
dispatch_whoami: onSession(whoamiCommand),
|