@sjawhar/pi-legion-envoy 1.56.4 → 1.56.6
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 +60 -16
- package/dist/legion.js +1 -1
- package/package.json +1 -1
package/dist/envoy.js
CHANGED
|
@@ -31551,16 +31551,63 @@ function dispatchCommentReplyWith(event, topic, comment) {
|
|
|
31551
31551
|
args: { project, artifact, [thread]: threadID, body: "..." }
|
|
31552
31552
|
};
|
|
31553
31553
|
}
|
|
31554
|
-
function
|
|
31555
|
-
if (
|
|
31554
|
+
function askResolutionText(resolution) {
|
|
31555
|
+
if (resolution === null || resolution === undefined)
|
|
31556
31556
|
return;
|
|
31557
|
-
const
|
|
31557
|
+
const kind = resolution.kind ?? "resolved";
|
|
31558
|
+
const reason = resolution.reason ?? "";
|
|
31559
|
+
return reason === "" ? kind : `${kind}: ${reason}`;
|
|
31560
|
+
}
|
|
31561
|
+
function dispatchCompact(event, comment) {
|
|
31562
|
+
if (event.type === "comment.created") {
|
|
31563
|
+
if (comment?.ask_id === undefined || comment.ask_id === null)
|
|
31564
|
+
return;
|
|
31565
|
+
const question = dispatchAskQuestion(comment);
|
|
31566
|
+
return {
|
|
31567
|
+
askId: comment.ask_id,
|
|
31568
|
+
record: {
|
|
31569
|
+
...question === undefined ? {} : { question },
|
|
31570
|
+
reply: comment.body ?? "",
|
|
31571
|
+
...comment.ask_state === undefined ? {} : { state: comment.ask_state },
|
|
31572
|
+
...comment.ask_waiting_on === undefined ? {} : { waiting_on: comment.ask_waiting_on }
|
|
31573
|
+
}
|
|
31574
|
+
};
|
|
31575
|
+
}
|
|
31576
|
+
if (!event.type.startsWith("ask."))
|
|
31577
|
+
return;
|
|
31578
|
+
const ask = (event.type === "ask.edited" ? AskEditedEventPayloadSchema : AskEventPayloadSchema).safeParse(event.payload);
|
|
31558
31579
|
if (!ask.success)
|
|
31559
31580
|
return;
|
|
31560
|
-
|
|
31561
|
-
|
|
31562
|
-
|
|
31563
|
-
|
|
31581
|
+
let record = { question: textHead(ask.data.question ?? "") };
|
|
31582
|
+
switch (event.type) {
|
|
31583
|
+
case "ask.opened":
|
|
31584
|
+
case "ask.edited": {
|
|
31585
|
+
const options = (ask.data.options ?? []).map((option) => option.label ?? "").filter((label) => label !== "");
|
|
31586
|
+
const quote = ask.data.anchor?.quote;
|
|
31587
|
+
const { project, slug } = ask.data.anchor_artifact ?? {};
|
|
31588
|
+
const document = project !== undefined && project !== "" && slug !== undefined && slug !== "" ? `${project}/${slug}` : undefined;
|
|
31589
|
+
const previous = "previous" in ask.data && ask.data.previous !== undefined ? textHead(ask.data.previous.question) : undefined;
|
|
31590
|
+
record = {
|
|
31591
|
+
...record,
|
|
31592
|
+
...options.length === 0 ? {} : { options },
|
|
31593
|
+
...quote === undefined || quote === "" ? {} : { quote: textHead(quote) },
|
|
31594
|
+
...document === undefined ? {} : { document },
|
|
31595
|
+
...previous === undefined ? {} : { previous }
|
|
31596
|
+
};
|
|
31597
|
+
break;
|
|
31598
|
+
}
|
|
31599
|
+
case "ask.answered":
|
|
31600
|
+
record = { ...record, answer: askAnswerText(ask.data.answer) };
|
|
31601
|
+
break;
|
|
31602
|
+
case "ask.resolved": {
|
|
31603
|
+
const resolved = askResolutionText(ask.data.resolution);
|
|
31604
|
+
record = resolved === undefined ? record : { ...record, resolved };
|
|
31605
|
+
break;
|
|
31606
|
+
}
|
|
31607
|
+
default:
|
|
31608
|
+
break;
|
|
31609
|
+
}
|
|
31610
|
+
return { askId: ask.data.id, record };
|
|
31564
31611
|
}
|
|
31565
31612
|
function dispatchPayload(event) {
|
|
31566
31613
|
const schema = DISPATCH_PAYLOAD_SCHEMAS[event.type];
|
|
@@ -31736,8 +31783,7 @@ function renderInbound(raw, sessionID, subject) {
|
|
|
31736
31783
|
}
|
|
31737
31784
|
const comment = frame.event.type === "comment.created" ? CommentEventPayloadSchema.safeParse(frame.event.payload) : undefined;
|
|
31738
31785
|
const commentPayload = comment?.success === true ? comment.data : undefined;
|
|
31739
|
-
const
|
|
31740
|
-
const question = answered?.question ?? dispatchAskQuestion(commentPayload);
|
|
31786
|
+
const compact = dispatchCompact(frame.event, commentPayload);
|
|
31741
31787
|
if (frame.event.type.startsWith("ask.")) {
|
|
31742
31788
|
const asked = AskAuthorPayloadSchema.safeParse(frame.event.payload);
|
|
31743
31789
|
if (asked.success && asked.data.author.kind === "session") {
|
|
@@ -31785,17 +31831,15 @@ function renderInbound(raw, sessionID, subject) {
|
|
|
31785
31831
|
};
|
|
31786
31832
|
}
|
|
31787
31833
|
}
|
|
31834
|
+
const compactRecord = compact === undefined ? undefined : inReplyTo !== undefined || compact.askId === undefined ? compact.record : {
|
|
31835
|
+
ask: dispatchReplyRef(frame.event, topic, compact.askId, commentPayload),
|
|
31836
|
+
...compact.record
|
|
31837
|
+
};
|
|
31788
31838
|
dispatchEvent = {
|
|
31789
31839
|
owner: dispatchOwner(frame.event, topic),
|
|
31790
|
-
...frame.event.issue_key === null ? {
|
|
31791
|
-
...topic?.startsWith(DISPATCH_DOCUMENT_TOPIC_PREFIX) === true ? { document: dispatchOwner(frame.event, topic).replace(" / ", "/") } : {},
|
|
31792
|
-
...frame.event.artifact_id === undefined || frame.event.artifact_id === null ? {} : { artifact_id: frame.event.artifact_id }
|
|
31793
|
-
} : { issue_key: frame.event.issue_key },
|
|
31794
31840
|
type: frame.event.type,
|
|
31795
31841
|
actor: frame.event.actor,
|
|
31796
|
-
...
|
|
31797
|
-
...answered === undefined ? {} : { answer: answered.answer },
|
|
31798
|
-
payload: dispatchPayload(frame.event)
|
|
31842
|
+
...compactRecord ?? { payload: dispatchPayload(frame.event) }
|
|
31799
31843
|
};
|
|
31800
31844
|
dispatchActor = frame.event.actor;
|
|
31801
31845
|
} else {
|
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.56.
|
|
16148
|
+
version: "1.56.6",
|
|
16149
16149
|
type: "module",
|
|
16150
16150
|
omp: {
|
|
16151
16151
|
extensions: [
|