@sjawhar/opencode-legion-envoy 1.42.1 → 1.42.2
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/src/server.js +44 -31
- package/package.json +1 -1
package/dist/src/server.js
CHANGED
|
@@ -15832,6 +15832,20 @@ async function resolveOwnerArguments(tool, input, cwd, env, exec, serverUrl, pro
|
|
|
15832
15832
|
const issue = `${repo}#${legionIssue}`;
|
|
15833
15833
|
return { args: { ...args, issue }, ref, owner: { kind: "issue", issue } };
|
|
15834
15834
|
}
|
|
15835
|
+
function artifactByReference(artifacts, artifactReference, owner) {
|
|
15836
|
+
const byIdOrSlug = artifacts.find((candidate) => candidate.id === artifactReference) ?? artifacts.find((candidate) => candidate.slug === artifactReference);
|
|
15837
|
+
if (byIdOrSlug !== undefined)
|
|
15838
|
+
return byIdOrSlug;
|
|
15839
|
+
const byName = artifacts.filter((candidate) => candidate.name === artifactReference);
|
|
15840
|
+
if (byName.length > 1) {
|
|
15841
|
+
throw new Error(documentReferenceProblem(artifactReference, byName, owner, true));
|
|
15842
|
+
}
|
|
15843
|
+
const [artifact] = byName;
|
|
15844
|
+
if (artifact === undefined) {
|
|
15845
|
+
throw new Error(documentReferenceProblem(artifactReference, artifacts, owner));
|
|
15846
|
+
}
|
|
15847
|
+
return artifact;
|
|
15848
|
+
}
|
|
15835
15849
|
async function resolveArtifact(client, owner, artifactReference) {
|
|
15836
15850
|
if (owner.kind === "project") {
|
|
15837
15851
|
if (artifactReference === undefined) {
|
|
@@ -15846,17 +15860,10 @@ async function resolveArtifact(client, owner, artifactReference) {
|
|
|
15846
15860
|
if (!(error instanceof DispatchServiceError) || error.status !== 404)
|
|
15847
15861
|
throw error;
|
|
15848
15862
|
const artifacts = await client.listProjectArtifacts(owner.project, true);
|
|
15849
|
-
|
|
15850
|
-
|
|
15851
|
-
|
|
15852
|
-
|
|
15853
|
-
if (names.length > 1) {
|
|
15854
|
-
throw new Error(documentReferenceProblem(artifactReference, names, "project", true));
|
|
15855
|
-
}
|
|
15856
|
-
if (names[0] === undefined) {
|
|
15857
|
-
throw new Error(documentReferenceProblem(artifactReference, artifacts, "project"));
|
|
15858
|
-
}
|
|
15859
|
-
return { owner, artifact: names[0] };
|
|
15863
|
+
return {
|
|
15864
|
+
owner,
|
|
15865
|
+
artifact: artifactByReference(artifacts, artifactReference, "project")
|
|
15866
|
+
};
|
|
15860
15867
|
}
|
|
15861
15868
|
}
|
|
15862
15869
|
const issue = await client.getIssue(owner.issue);
|
|
@@ -15864,14 +15871,7 @@ async function resolveArtifact(client, owner, artifactReference) {
|
|
|
15864
15871
|
if (artifactReference === undefined || artifactReference === "spec") {
|
|
15865
15872
|
artifact = issue.artifacts.find((candidate) => candidate.primary || candidate.id === issue.primary_artifact_id);
|
|
15866
15873
|
} else {
|
|
15867
|
-
artifact = issue.artifacts
|
|
15868
|
-
if (artifact === undefined) {
|
|
15869
|
-
const names = issue.artifacts.filter((candidate) => candidate.name === artifactReference);
|
|
15870
|
-
if (names.length > 1) {
|
|
15871
|
-
throw new Error(documentReferenceProblem(artifactReference, names, "issue", true));
|
|
15872
|
-
}
|
|
15873
|
-
artifact = names[0];
|
|
15874
|
-
}
|
|
15874
|
+
artifact = artifactByReference(issue.artifacts, artifactReference, "issue");
|
|
15875
15875
|
}
|
|
15876
15876
|
if (!artifact) {
|
|
15877
15877
|
throw new Error(documentReferenceProblem(artifactReference ?? "spec", issue.artifacts, "issue"));
|
|
@@ -16164,19 +16164,21 @@ function messageSummary({ message, replies }, graph) {
|
|
|
16164
16164
|
`);
|
|
16165
16165
|
}
|
|
16166
16166
|
async function openArtifactMarks(client, resolved) {
|
|
16167
|
-
const
|
|
16167
|
+
const asksPromise = resolved.owner.kind === "project" ? client.getArtifactAsks(resolved.artifact.id) : Promise.resolve(resolved.issue?.open_asks ?? []);
|
|
16168
|
+
const commentsPromise = resolved.owner.kind === "project" ? client.getArtifactComments(resolved.artifact.id) : client.getComments(resolved.issue?.key ?? "", resolved.artifact.id);
|
|
16169
|
+
const commentsResultPromise = commentsPromise.then((value) => ({ status: "fulfilled", value }), (reason) => ({ status: "rejected", reason }));
|
|
16170
|
+
const asks = await asksPromise;
|
|
16168
16171
|
const marks = asks.filter((ask) => ask.state === "open" && ask.anchor?.artifact_id === resolved.artifact.id).map((ask) => `ask ${ask.id}`);
|
|
16169
|
-
|
|
16170
|
-
|
|
16171
|
-
|
|
16172
|
-
} catch (error) {
|
|
16173
|
-
if (error instanceof DispatchServiceError && error.status === 404)
|
|
16172
|
+
const commentsResult = await commentsResultPromise;
|
|
16173
|
+
if (commentsResult.status === "rejected") {
|
|
16174
|
+
if (commentsResult.reason instanceof DispatchServiceError && commentsResult.reason.status === 404) {
|
|
16174
16175
|
return marks;
|
|
16175
|
-
|
|
16176
|
+
}
|
|
16177
|
+
throw commentsResult.reason;
|
|
16176
16178
|
}
|
|
16177
16179
|
return [
|
|
16178
16180
|
...marks,
|
|
16179
|
-
...
|
|
16181
|
+
...commentsResult.value.filter((comment) => !comment.resolved && comment.anchor?.artifact_id === resolved.artifact.id).map((comment) => `comment ${comment.id}`)
|
|
16180
16182
|
];
|
|
16181
16183
|
}
|
|
16182
16184
|
async function executeDispatchTool(input) {
|
|
@@ -16595,8 +16597,14 @@ ${followsAsk(askOwner)}`,
|
|
|
16595
16597
|
const artifactReference = optionalString(args, "artifact") ?? (ownerArguments.ref?.kind === "spec" || ownerArguments.ref?.kind === "artifact" ? ownerArguments.ref.id : undefined);
|
|
16596
16598
|
const resolved = await resolveArtifact(client, documentOwner(), artifactReference);
|
|
16597
16599
|
const version = optionalNumber(args, "version") ?? ownerArguments.ref?.version;
|
|
16598
|
-
const
|
|
16599
|
-
const
|
|
16600
|
+
const documentPromise = client.docRead(resolved.artifact.id, version);
|
|
16601
|
+
const marksPromise = openArtifactMarks(client, resolved);
|
|
16602
|
+
const marksResultPromise = marksPromise.then((value) => ({ status: "fulfilled", value }), (reason) => ({ status: "rejected", reason }));
|
|
16603
|
+
const document = await documentPromise;
|
|
16604
|
+
const marksResult = await marksResultPromise;
|
|
16605
|
+
if (marksResult.status === "rejected")
|
|
16606
|
+
throw marksResult.reason;
|
|
16607
|
+
const marks = marksResult.value;
|
|
16600
16608
|
const approval = approvalLine(resolved.artifact);
|
|
16601
16609
|
const trailer = [
|
|
16602
16610
|
...marks.length === 0 ? [] : [`Open anchored asks/comments: ${marks.join(", ")}`],
|
|
@@ -16731,21 +16739,26 @@ ${trailer.join(`
|
|
|
16731
16739
|
}
|
|
16732
16740
|
};
|
|
16733
16741
|
}
|
|
16734
|
-
const
|
|
16742
|
+
const issueKey = issue();
|
|
16735
16743
|
if (ownerArguments.ref?.kind === "log") {
|
|
16744
|
+
const read = await client.read(issueKey);
|
|
16736
16745
|
return {
|
|
16737
16746
|
text: logSummary(read.issue, read.events),
|
|
16738
16747
|
details: { issue: read.issue.key }
|
|
16739
16748
|
};
|
|
16740
16749
|
}
|
|
16741
16750
|
if (ownerArguments.ref?.kind === "children") {
|
|
16751
|
+
const read = await client.read(issueKey);
|
|
16742
16752
|
return {
|
|
16743
16753
|
text: childrenSummary(read.issue),
|
|
16744
16754
|
details: { issue: read.issue.key }
|
|
16745
16755
|
};
|
|
16746
16756
|
}
|
|
16757
|
+
const readPromise = client.read(issueKey);
|
|
16758
|
+
const referencesPromise = issueReferencesOrUnavailable(client, issueKey);
|
|
16759
|
+
const read = await readPromise;
|
|
16747
16760
|
const [references, graph] = await Promise.all([
|
|
16748
|
-
|
|
16761
|
+
referencesPromise,
|
|
16749
16762
|
graphSections(client, dispatchIssueRef(read.issue.key))
|
|
16750
16763
|
]);
|
|
16751
16764
|
return {
|