@sjawhar/pi-legion-envoy 1.53.1 → 1.53.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/envoy.js +57 -33
- package/dist/legion.js +10 -3
- package/package.json +1 -1
package/dist/envoy.js
CHANGED
|
@@ -29756,13 +29756,20 @@ var CommentEventPayloadSchema = object({
|
|
|
29756
29756
|
ask_state: _enum2(["open", "answered", "resolved"]).optional(),
|
|
29757
29757
|
ask_waiting_on: _enum2(ASK_TURNS).optional(),
|
|
29758
29758
|
turn: _enum2(ASK_TURNS).nullish(),
|
|
29759
|
-
anchor: object({
|
|
29759
|
+
anchor: object({
|
|
29760
|
+
artifact_id: string2().optional(),
|
|
29761
|
+
block_id: string2().nullable().optional(),
|
|
29762
|
+
mark_id: string2().optional(),
|
|
29763
|
+
orphaned: boolean2().optional(),
|
|
29764
|
+
quote: string2().optional(),
|
|
29765
|
+
version: number2().int().optional()
|
|
29766
|
+
}).nullish(),
|
|
29760
29767
|
suggestion: object({ replace_with: string2().optional() }).nullish(),
|
|
29761
29768
|
author: object({ kind: string2(), id: string2() }).optional(),
|
|
29762
29769
|
created_at: string2().optional(),
|
|
29763
29770
|
mentions: array(CommentMentionSchema).optional(),
|
|
29764
29771
|
deliveries: array(CommentDeliverySchema).optional()
|
|
29765
|
-
});
|
|
29772
|
+
}).passthrough();
|
|
29766
29773
|
var MessageEventPayloadSchema = object({
|
|
29767
29774
|
id: string2().optional(),
|
|
29768
29775
|
body: string2().optional(),
|
|
@@ -31452,10 +31459,12 @@ var DISPATCH_PAYLOAD_SCHEMAS = {
|
|
|
31452
31459
|
"artifact.created": ArtifactCreatedEventPayloadSchema,
|
|
31453
31460
|
"artifact.version": ArtifactVersionEventPayloadSchema,
|
|
31454
31461
|
"ask.opened": AskEventPayloadSchema,
|
|
31462
|
+
"ask.anchor_refreshed": AskEventPayloadSchema,
|
|
31455
31463
|
"ask.edited": AskEditedEventPayloadSchema,
|
|
31456
31464
|
"ask.answered": AskEventPayloadSchema,
|
|
31457
31465
|
"ask.resolved": AskEventPayloadSchema,
|
|
31458
31466
|
"comment.created": CommentEventPayloadSchema,
|
|
31467
|
+
"comment.anchor_refreshed": CommentEventPayloadSchema,
|
|
31459
31468
|
"comment.resolved": CommentEventPayloadSchema,
|
|
31460
31469
|
"comment.reopened": CommentEventPayloadSchema,
|
|
31461
31470
|
"comment.edited": CommentEventPayloadSchema,
|
|
@@ -32954,6 +32963,20 @@ async function resolveOwnerArguments(tool, input, cwd, env, exec, serverUrl, pro
|
|
|
32954
32963
|
const issue = `${repo}#${legionIssue}`;
|
|
32955
32964
|
return { args: { ...args, issue }, ref, owner: { kind: "issue", issue } };
|
|
32956
32965
|
}
|
|
32966
|
+
function artifactByReference(artifacts, artifactReference, owner) {
|
|
32967
|
+
const byIdOrSlug = artifacts.find((candidate) => candidate.id === artifactReference) ?? artifacts.find((candidate) => candidate.slug === artifactReference);
|
|
32968
|
+
if (byIdOrSlug !== undefined)
|
|
32969
|
+
return byIdOrSlug;
|
|
32970
|
+
const byName = artifacts.filter((candidate) => candidate.name === artifactReference);
|
|
32971
|
+
if (byName.length > 1) {
|
|
32972
|
+
throw new Error(documentReferenceProblem(artifactReference, byName, owner, true));
|
|
32973
|
+
}
|
|
32974
|
+
const [artifact] = byName;
|
|
32975
|
+
if (artifact === undefined) {
|
|
32976
|
+
throw new Error(documentReferenceProblem(artifactReference, artifacts, owner));
|
|
32977
|
+
}
|
|
32978
|
+
return artifact;
|
|
32979
|
+
}
|
|
32957
32980
|
async function resolveArtifact(client, owner, artifactReference) {
|
|
32958
32981
|
if (owner.kind === "project") {
|
|
32959
32982
|
if (artifactReference === undefined) {
|
|
@@ -32968,17 +32991,10 @@ async function resolveArtifact(client, owner, artifactReference) {
|
|
|
32968
32991
|
if (!(error instanceof DispatchServiceError) || error.status !== 404)
|
|
32969
32992
|
throw error;
|
|
32970
32993
|
const artifacts = await client.listProjectArtifacts(owner.project, true);
|
|
32971
|
-
|
|
32972
|
-
|
|
32973
|
-
|
|
32974
|
-
|
|
32975
|
-
if (names.length > 1) {
|
|
32976
|
-
throw new Error(documentReferenceProblem(artifactReference, names, "project", true));
|
|
32977
|
-
}
|
|
32978
|
-
if (names[0] === undefined) {
|
|
32979
|
-
throw new Error(documentReferenceProblem(artifactReference, artifacts, "project"));
|
|
32980
|
-
}
|
|
32981
|
-
return { owner, artifact: names[0] };
|
|
32994
|
+
return {
|
|
32995
|
+
owner,
|
|
32996
|
+
artifact: artifactByReference(artifacts, artifactReference, "project")
|
|
32997
|
+
};
|
|
32982
32998
|
}
|
|
32983
32999
|
}
|
|
32984
33000
|
const issue = await client.getIssue(owner.issue);
|
|
@@ -32986,14 +33002,7 @@ async function resolveArtifact(client, owner, artifactReference) {
|
|
|
32986
33002
|
if (artifactReference === undefined || artifactReference === "spec") {
|
|
32987
33003
|
artifact = issue.artifacts.find((candidate) => candidate.primary || candidate.id === issue.primary_artifact_id);
|
|
32988
33004
|
} else {
|
|
32989
|
-
artifact = issue.artifacts
|
|
32990
|
-
if (artifact === undefined) {
|
|
32991
|
-
const names = issue.artifacts.filter((candidate) => candidate.name === artifactReference);
|
|
32992
|
-
if (names.length > 1) {
|
|
32993
|
-
throw new Error(documentReferenceProblem(artifactReference, names, "issue", true));
|
|
32994
|
-
}
|
|
32995
|
-
artifact = names[0];
|
|
32996
|
-
}
|
|
33005
|
+
artifact = artifactByReference(issue.artifacts, artifactReference, "issue");
|
|
32997
33006
|
}
|
|
32998
33007
|
if (!artifact) {
|
|
32999
33008
|
throw new Error(documentReferenceProblem(artifactReference ?? "spec", issue.artifacts, "issue"));
|
|
@@ -33141,12 +33150,14 @@ function logSummary(issue, events) {
|
|
|
33141
33150
|
function eventHead(event) {
|
|
33142
33151
|
switch (event.type) {
|
|
33143
33152
|
case "ask.opened":
|
|
33153
|
+
case "ask.anchor_refreshed":
|
|
33144
33154
|
case "ask.edited":
|
|
33145
33155
|
case "ask.resolved":
|
|
33146
33156
|
return textHead(event.payload.question);
|
|
33147
33157
|
case "ask.answered":
|
|
33148
33158
|
return `${textHead(event.payload.question)} -> ${textHead(askAnswerText(event.payload.answer))}`;
|
|
33149
33159
|
case "comment.created":
|
|
33160
|
+
case "comment.anchor_refreshed":
|
|
33150
33161
|
case "comment.edited":
|
|
33151
33162
|
case "comment.resolved":
|
|
33152
33163
|
case "comment.reopened":
|
|
@@ -33284,19 +33295,21 @@ function messageSummary({ message, replies }, graph) {
|
|
|
33284
33295
|
`);
|
|
33285
33296
|
}
|
|
33286
33297
|
async function openArtifactMarks(client, resolved) {
|
|
33287
|
-
const
|
|
33298
|
+
const asksPromise = resolved.owner.kind === "project" ? client.getArtifactAsks(resolved.artifact.id) : Promise.resolve(resolved.issue?.open_asks ?? []);
|
|
33299
|
+
const commentsPromise = resolved.owner.kind === "project" ? client.getArtifactComments(resolved.artifact.id) : client.getComments(resolved.issue?.key ?? "", resolved.artifact.id);
|
|
33300
|
+
const commentsResultPromise = commentsPromise.then((value) => ({ status: "fulfilled", value }), (reason) => ({ status: "rejected", reason }));
|
|
33301
|
+
const asks = await asksPromise;
|
|
33288
33302
|
const marks = asks.filter((ask) => ask.state === "open" && ask.anchor?.artifact_id === resolved.artifact.id).map((ask) => `ask ${ask.id}`);
|
|
33289
|
-
|
|
33290
|
-
|
|
33291
|
-
|
|
33292
|
-
} catch (error) {
|
|
33293
|
-
if (error instanceof DispatchServiceError && error.status === 404)
|
|
33303
|
+
const commentsResult = await commentsResultPromise;
|
|
33304
|
+
if (commentsResult.status === "rejected") {
|
|
33305
|
+
if (commentsResult.reason instanceof DispatchServiceError && commentsResult.reason.status === 404) {
|
|
33294
33306
|
return marks;
|
|
33295
|
-
|
|
33307
|
+
}
|
|
33308
|
+
throw commentsResult.reason;
|
|
33296
33309
|
}
|
|
33297
33310
|
return [
|
|
33298
33311
|
...marks,
|
|
33299
|
-
...
|
|
33312
|
+
...commentsResult.value.filter((comment) => !comment.resolved && comment.anchor?.artifact_id === resolved.artifact.id).map((comment) => `comment ${comment.id}`)
|
|
33300
33313
|
];
|
|
33301
33314
|
}
|
|
33302
33315
|
async function executeDispatchTool(input) {
|
|
@@ -33715,8 +33728,14 @@ ${followsAsk(askOwner)}`,
|
|
|
33715
33728
|
const artifactReference = optionalString(args, "artifact") ?? (ownerArguments.ref?.kind === "spec" || ownerArguments.ref?.kind === "artifact" ? ownerArguments.ref.id : undefined);
|
|
33716
33729
|
const resolved = await resolveArtifact(client, documentOwner(), artifactReference);
|
|
33717
33730
|
const version = optionalNumber(args, "version") ?? ownerArguments.ref?.version;
|
|
33718
|
-
const
|
|
33719
|
-
const
|
|
33731
|
+
const documentPromise = client.docRead(resolved.artifact.id, version);
|
|
33732
|
+
const marksPromise = openArtifactMarks(client, resolved);
|
|
33733
|
+
const marksResultPromise = marksPromise.then((value) => ({ status: "fulfilled", value }), (reason) => ({ status: "rejected", reason }));
|
|
33734
|
+
const document = await documentPromise;
|
|
33735
|
+
const marksResult = await marksResultPromise;
|
|
33736
|
+
if (marksResult.status === "rejected")
|
|
33737
|
+
throw marksResult.reason;
|
|
33738
|
+
const marks = marksResult.value;
|
|
33720
33739
|
const approval = approvalLine(resolved.artifact);
|
|
33721
33740
|
const trailer = [
|
|
33722
33741
|
...marks.length === 0 ? [] : [`Open anchored asks/comments: ${marks.join(", ")}`],
|
|
@@ -33851,21 +33870,26 @@ ${trailer.join(`
|
|
|
33851
33870
|
}
|
|
33852
33871
|
};
|
|
33853
33872
|
}
|
|
33854
|
-
const
|
|
33873
|
+
const issueKey = issue();
|
|
33855
33874
|
if (ownerArguments.ref?.kind === "log") {
|
|
33875
|
+
const read = await client.read(issueKey);
|
|
33856
33876
|
return {
|
|
33857
33877
|
text: logSummary(read.issue, read.events),
|
|
33858
33878
|
details: { issue: read.issue.key }
|
|
33859
33879
|
};
|
|
33860
33880
|
}
|
|
33861
33881
|
if (ownerArguments.ref?.kind === "children") {
|
|
33882
|
+
const read = await client.read(issueKey);
|
|
33862
33883
|
return {
|
|
33863
33884
|
text: childrenSummary(read.issue),
|
|
33864
33885
|
details: { issue: read.issue.key }
|
|
33865
33886
|
};
|
|
33866
33887
|
}
|
|
33888
|
+
const readPromise = client.read(issueKey);
|
|
33889
|
+
const referencesPromise = issueReferencesOrUnavailable(client, issueKey);
|
|
33890
|
+
const read = await readPromise;
|
|
33867
33891
|
const [references, graph] = await Promise.all([
|
|
33868
|
-
|
|
33892
|
+
referencesPromise,
|
|
33869
33893
|
graphSections(client, dispatchIssueRef(read.issue.key))
|
|
33870
33894
|
]);
|
|
33871
33895
|
return {
|
package/dist/legion.js
CHANGED
|
@@ -16145,7 +16145,7 @@ import { logger } from "@oh-my-pi/pi-utils";
|
|
|
16145
16145
|
// package.json
|
|
16146
16146
|
var package_default = {
|
|
16147
16147
|
name: "@sjawhar/pi-legion-envoy",
|
|
16148
|
-
version: "1.53.
|
|
16148
|
+
version: "1.53.3",
|
|
16149
16149
|
type: "module",
|
|
16150
16150
|
omp: {
|
|
16151
16151
|
extensions: [
|
|
@@ -29075,13 +29075,20 @@ var CommentEventPayloadSchema = object({
|
|
|
29075
29075
|
ask_state: _enum2(["open", "answered", "resolved"]).optional(),
|
|
29076
29076
|
ask_waiting_on: _enum2(ASK_TURNS).optional(),
|
|
29077
29077
|
turn: _enum2(ASK_TURNS).nullish(),
|
|
29078
|
-
anchor: object({
|
|
29078
|
+
anchor: object({
|
|
29079
|
+
artifact_id: string2().optional(),
|
|
29080
|
+
block_id: string2().nullable().optional(),
|
|
29081
|
+
mark_id: string2().optional(),
|
|
29082
|
+
orphaned: boolean2().optional(),
|
|
29083
|
+
quote: string2().optional(),
|
|
29084
|
+
version: number2().int().optional()
|
|
29085
|
+
}).nullish(),
|
|
29079
29086
|
suggestion: object({ replace_with: string2().optional() }).nullish(),
|
|
29080
29087
|
author: object({ kind: string2(), id: string2() }).optional(),
|
|
29081
29088
|
created_at: string2().optional(),
|
|
29082
29089
|
mentions: array(CommentMentionSchema).optional(),
|
|
29083
29090
|
deliveries: array(CommentDeliverySchema).optional()
|
|
29084
|
-
});
|
|
29091
|
+
}).passthrough();
|
|
29085
29092
|
var MessageEventPayloadSchema = object({
|
|
29086
29093
|
id: string2().optional(),
|
|
29087
29094
|
body: string2().optional(),
|