@sjawhar/claude-envoy 6.0.0 → 6.0.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/.claude-plugin/plugin.json +1 -1
- package/.omp-plugin/plugin.json +1 -1
- package/dist/codex-hook.js +97 -12
- package/dist/dispatch.js +97 -12
- package/dist/envoy-channel.js +98 -13
- package/dist/session-hook.js +97 -12
- package/legion/skills/legion-controller/SKILL.md +1 -1
- package/legion/skills/legion-controller/references/admission.md +6 -3
- package/legion/skills/legion-controller/references/wakes.md +1 -1
- package/package.json +1 -1
package/.omp-plugin/plugin.json
CHANGED
package/dist/codex-hook.js
CHANGED
|
@@ -20253,6 +20253,9 @@ function parseDispatchRef(ref) {
|
|
|
20253
20253
|
// ../envoy-client/src/dispatch-picture-tools.ts
|
|
20254
20254
|
import { basename, resolve as resolvePath } from "path";
|
|
20255
20255
|
|
|
20256
|
+
// ../envoy-client/src/delivery.ts
|
|
20257
|
+
import { isDeepStrictEqual } from "util";
|
|
20258
|
+
|
|
20256
20259
|
// ../../node_modules/.bun/@toon-format+toon@4.1.1/node_modules/@toon-format/toon/dist/index.mjs
|
|
20257
20260
|
var NULL_LITERAL = "null";
|
|
20258
20261
|
var DELIMITERS = {
|
|
@@ -26760,21 +26763,95 @@ function dispatchCompact(event, comment, ownsAsk) {
|
|
|
26760
26763
|
return { askId: ask.data.id, record };
|
|
26761
26764
|
}
|
|
26762
26765
|
function dispatchPayload(event) {
|
|
26763
|
-
const schema = DISPATCH_PAYLOAD_SCHEMAS[event.type];
|
|
26766
|
+
const schema = Object.hasOwn(DISPATCH_PAYLOAD_SCHEMAS, event.type) ? DISPATCH_PAYLOAD_SCHEMAS[event.type] : undefined;
|
|
26764
26767
|
if (schema === undefined)
|
|
26765
26768
|
return event.payload;
|
|
26766
26769
|
const parsed = schema.safeParse(event.payload);
|
|
26767
26770
|
return parsed.success ? parsed.data : event.payload;
|
|
26768
26771
|
}
|
|
26769
|
-
|
|
26770
|
-
|
|
26771
|
-
|
|
26772
|
-
|
|
26773
|
-
|
|
26774
|
-
|
|
26772
|
+
var DISPATCH_BOOKKEEPING = new Set([
|
|
26773
|
+
"deliveries",
|
|
26774
|
+
"mentions_decide_routes",
|
|
26775
|
+
"suppress_route",
|
|
26776
|
+
"suppressed_route",
|
|
26777
|
+
"suppressed_route_session_id",
|
|
26778
|
+
"suppressed_authors",
|
|
26779
|
+
"thread_logins",
|
|
26780
|
+
"references_changed",
|
|
26781
|
+
"references_changed_truncated",
|
|
26782
|
+
"references_changed_truncated_kinds",
|
|
26783
|
+
"rank"
|
|
26784
|
+
]);
|
|
26785
|
+
function dispatchPayloadForReader(event, sessionID, issuedAt) {
|
|
26786
|
+
const whole = dispatchPayload(event);
|
|
26787
|
+
const changed = event.type !== "issue.created" && isObject3(whole) && Array.isArray(whole["changed"]) ? whole["changed"] : [];
|
|
26788
|
+
const payload = withoutEmptyFields(whole, (key, item) => changed.includes(key) || (key === "suggestion" || key === "forced") && item !== null && item !== undefined);
|
|
26789
|
+
if (!isObject3(payload) || Array.isArray(payload))
|
|
26775
26790
|
return payload;
|
|
26776
|
-
const
|
|
26777
|
-
|
|
26791
|
+
const { reply_to: replyTo } = payload;
|
|
26792
|
+
const actor = event.actor;
|
|
26793
|
+
const repeatsTheCard = (key, value) => {
|
|
26794
|
+
switch (key) {
|
|
26795
|
+
case "issue_key":
|
|
26796
|
+
return value === event.issue_key;
|
|
26797
|
+
case "author":
|
|
26798
|
+
return isObject3(value) && Object.entries(value).every(([field, held]) => isDeepStrictEqual(held, actor[field]));
|
|
26799
|
+
case "created_at": {
|
|
26800
|
+
if (typeof value !== "string")
|
|
26801
|
+
return false;
|
|
26802
|
+
const timestamp = Date.parse(value);
|
|
26803
|
+
return issuedAt !== undefined && Math.abs(timestamp - issuedAt) < 1000;
|
|
26804
|
+
}
|
|
26805
|
+
case "thread_root_id":
|
|
26806
|
+
case "answers":
|
|
26807
|
+
return typeof replyTo === "string" && value === replyTo;
|
|
26808
|
+
default:
|
|
26809
|
+
return DISPATCH_BOOKKEEPING.has(key);
|
|
26810
|
+
}
|
|
26811
|
+
};
|
|
26812
|
+
const shown = {};
|
|
26813
|
+
for (const [key, value] of Object.entries(payload)) {
|
|
26814
|
+
if (!changed.includes(key) && repeatsTheCard(key, value))
|
|
26815
|
+
continue;
|
|
26816
|
+
shown[key] = key === "target" && value === `session:${sessionID}` ? `you (${value})` : value;
|
|
26817
|
+
}
|
|
26818
|
+
return shown;
|
|
26819
|
+
}
|
|
26820
|
+
function withoutEmptyFields(value, keptWhole) {
|
|
26821
|
+
if (!isObject3(value))
|
|
26822
|
+
return value;
|
|
26823
|
+
const root = Array.isArray(value) ? [] : {};
|
|
26824
|
+
const pending = [
|
|
26825
|
+
[value, root]
|
|
26826
|
+
];
|
|
26827
|
+
const placed = [];
|
|
26828
|
+
for (let next = pending.pop();next !== undefined; next = pending.pop()) {
|
|
26829
|
+
const [from, to] = next;
|
|
26830
|
+
const inList = Array.isArray(from);
|
|
26831
|
+
for (const [key, item] of Object.entries(from)) {
|
|
26832
|
+
if (from === value && !inList && keptWhole(key, item)) {
|
|
26833
|
+
to[key] = item;
|
|
26834
|
+
continue;
|
|
26835
|
+
}
|
|
26836
|
+
const statesNothing = item === null || item === undefined || item === "" || item === false || Array.isArray(item) && item.length === 0;
|
|
26837
|
+
if (!inList && statesNothing)
|
|
26838
|
+
continue;
|
|
26839
|
+
if (!isObject3(item)) {
|
|
26840
|
+
to[key] = item;
|
|
26841
|
+
continue;
|
|
26842
|
+
}
|
|
26843
|
+
const copy = Array.isArray(item) ? [] : {};
|
|
26844
|
+
pending.push([item, copy]);
|
|
26845
|
+
if (!inList && !Array.isArray(item))
|
|
26846
|
+
placed.push([to, key, copy]);
|
|
26847
|
+
to[key] = copy;
|
|
26848
|
+
}
|
|
26849
|
+
}
|
|
26850
|
+
for (const [holder, key, held] of placed.reverse()) {
|
|
26851
|
+
if (Object.keys(held).length === 0)
|
|
26852
|
+
delete holder[key];
|
|
26853
|
+
}
|
|
26854
|
+
return root;
|
|
26778
26855
|
}
|
|
26779
26856
|
function dispatchAskQuestion(comment) {
|
|
26780
26857
|
return comment?.ask_question !== undefined && comment.ask_question !== "" ? textHead(comment.ask_question) : undefined;
|
|
@@ -26926,6 +27003,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
26926
27003
|
let inReplyTo = envelope.in_reply_to;
|
|
26927
27004
|
let payloadSessions = [];
|
|
26928
27005
|
let trailer = "";
|
|
27006
|
+
const at = inboundTimestamp(envelope.issued_at);
|
|
26929
27007
|
const dispatchRendered = envelope.source === "dispatch" && envelope.payload !== undefined;
|
|
26930
27008
|
if (envelope.source === "dispatch") {
|
|
26931
27009
|
const topic = subject ?? envelope.topic;
|
|
@@ -27031,12 +27109,19 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
27031
27109
|
ask: dispatchReplyRef(frame.event, topic, compact.askId, commentPayload),
|
|
27032
27110
|
...compact.record
|
|
27033
27111
|
};
|
|
27112
|
+
const payload = compactRecord === undefined ? dispatchPayloadForReader(frame.event, sessionID, envelope.issued_at) : undefined;
|
|
27113
|
+
let actor = frame.event.actor;
|
|
27114
|
+
if ("origin" in frame.event.actor) {
|
|
27115
|
+
const { origin, ...rest } = frame.event.actor;
|
|
27116
|
+
const title = isObject3(origin) ? origin["session_title"] : undefined;
|
|
27117
|
+
actor = typeof title === "string" && title !== "" ? { ...rest, origin: { session_title: title } } : rest;
|
|
27118
|
+
}
|
|
27034
27119
|
dispatchEvent = {
|
|
27035
27120
|
owner: dispatchOwner(frame.event, topic),
|
|
27036
27121
|
type: frame.event.type,
|
|
27037
|
-
actor
|
|
27122
|
+
actor,
|
|
27038
27123
|
...relation === undefined ? {} : { relation },
|
|
27039
|
-
...compactRecord ??
|
|
27124
|
+
...compactRecord ?? (isObject3(payload) && Object.keys(payload).length === 0 ? {} : { payload })
|
|
27040
27125
|
};
|
|
27041
27126
|
dispatchActor = frame.event.actor;
|
|
27042
27127
|
bodyNote = carriedBodyNote(frame.event);
|
|
@@ -27089,7 +27174,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
27089
27174
|
const rendered = {
|
|
27090
27175
|
...envelope.topic !== undefined && topicForms(envelope.topic).includes(legacyAgentSubject(sessionID)) ? { to: `you (${sessionID})` } : {},
|
|
27091
27176
|
from: senderLabel(envelope),
|
|
27092
|
-
at
|
|
27177
|
+
at,
|
|
27093
27178
|
id: envelope.event_id ?? "unknown",
|
|
27094
27179
|
...envelope.kept_at === undefined ? {} : { kept_at: inboundTimestamp(envelope.kept_at) },
|
|
27095
27180
|
...envelope.expires_at === undefined ? {} : { by: inboundTimestamp(envelope.expires_at) },
|
package/dist/dispatch.js
CHANGED
|
@@ -26390,6 +26390,9 @@ function formatZodIssues(issues, schema, tool) {
|
|
|
26390
26390
|
// ../envoy-client/src/dispatch-picture-tools.ts
|
|
26391
26391
|
import { basename, resolve as resolvePath } from "path";
|
|
26392
26392
|
|
|
26393
|
+
// ../envoy-client/src/delivery.ts
|
|
26394
|
+
import { isDeepStrictEqual } from "util";
|
|
26395
|
+
|
|
26393
26396
|
// ../../node_modules/.bun/@toon-format+toon@4.1.1/node_modules/@toon-format/toon/dist/index.mjs
|
|
26394
26397
|
var NULL_LITERAL = "null";
|
|
26395
26398
|
var DELIMITERS = {
|
|
@@ -28700,21 +28703,95 @@ function dispatchCompact(event, comment, ownsAsk) {
|
|
|
28700
28703
|
return { askId: ask.data.id, record };
|
|
28701
28704
|
}
|
|
28702
28705
|
function dispatchPayload(event) {
|
|
28703
|
-
const schema = DISPATCH_PAYLOAD_SCHEMAS[event.type];
|
|
28706
|
+
const schema = Object.hasOwn(DISPATCH_PAYLOAD_SCHEMAS, event.type) ? DISPATCH_PAYLOAD_SCHEMAS[event.type] : undefined;
|
|
28704
28707
|
if (schema === undefined)
|
|
28705
28708
|
return event.payload;
|
|
28706
28709
|
const parsed = schema.safeParse(event.payload);
|
|
28707
28710
|
return parsed.success ? parsed.data : event.payload;
|
|
28708
28711
|
}
|
|
28709
|
-
|
|
28710
|
-
|
|
28711
|
-
|
|
28712
|
-
|
|
28713
|
-
|
|
28714
|
-
|
|
28712
|
+
var DISPATCH_BOOKKEEPING = new Set([
|
|
28713
|
+
"deliveries",
|
|
28714
|
+
"mentions_decide_routes",
|
|
28715
|
+
"suppress_route",
|
|
28716
|
+
"suppressed_route",
|
|
28717
|
+
"suppressed_route_session_id",
|
|
28718
|
+
"suppressed_authors",
|
|
28719
|
+
"thread_logins",
|
|
28720
|
+
"references_changed",
|
|
28721
|
+
"references_changed_truncated",
|
|
28722
|
+
"references_changed_truncated_kinds",
|
|
28723
|
+
"rank"
|
|
28724
|
+
]);
|
|
28725
|
+
function dispatchPayloadForReader(event, sessionID, issuedAt) {
|
|
28726
|
+
const whole = dispatchPayload(event);
|
|
28727
|
+
const changed = event.type !== "issue.created" && isObject3(whole) && Array.isArray(whole["changed"]) ? whole["changed"] : [];
|
|
28728
|
+
const payload = withoutEmptyFields(whole, (key, item) => changed.includes(key) || (key === "suggestion" || key === "forced") && item !== null && item !== undefined);
|
|
28729
|
+
if (!isObject3(payload) || Array.isArray(payload))
|
|
28715
28730
|
return payload;
|
|
28716
|
-
const
|
|
28717
|
-
|
|
28731
|
+
const { reply_to: replyTo } = payload;
|
|
28732
|
+
const actor = event.actor;
|
|
28733
|
+
const repeatsTheCard = (key, value) => {
|
|
28734
|
+
switch (key) {
|
|
28735
|
+
case "issue_key":
|
|
28736
|
+
return value === event.issue_key;
|
|
28737
|
+
case "author":
|
|
28738
|
+
return isObject3(value) && Object.entries(value).every(([field, held]) => isDeepStrictEqual(held, actor[field]));
|
|
28739
|
+
case "created_at": {
|
|
28740
|
+
if (typeof value !== "string")
|
|
28741
|
+
return false;
|
|
28742
|
+
const timestamp = Date.parse(value);
|
|
28743
|
+
return issuedAt !== undefined && Math.abs(timestamp - issuedAt) < 1000;
|
|
28744
|
+
}
|
|
28745
|
+
case "thread_root_id":
|
|
28746
|
+
case "answers":
|
|
28747
|
+
return typeof replyTo === "string" && value === replyTo;
|
|
28748
|
+
default:
|
|
28749
|
+
return DISPATCH_BOOKKEEPING.has(key);
|
|
28750
|
+
}
|
|
28751
|
+
};
|
|
28752
|
+
const shown = {};
|
|
28753
|
+
for (const [key, value] of Object.entries(payload)) {
|
|
28754
|
+
if (!changed.includes(key) && repeatsTheCard(key, value))
|
|
28755
|
+
continue;
|
|
28756
|
+
shown[key] = key === "target" && value === `session:${sessionID}` ? `you (${value})` : value;
|
|
28757
|
+
}
|
|
28758
|
+
return shown;
|
|
28759
|
+
}
|
|
28760
|
+
function withoutEmptyFields(value, keptWhole) {
|
|
28761
|
+
if (!isObject3(value))
|
|
28762
|
+
return value;
|
|
28763
|
+
const root = Array.isArray(value) ? [] : {};
|
|
28764
|
+
const pending = [
|
|
28765
|
+
[value, root]
|
|
28766
|
+
];
|
|
28767
|
+
const placed = [];
|
|
28768
|
+
for (let next = pending.pop();next !== undefined; next = pending.pop()) {
|
|
28769
|
+
const [from, to] = next;
|
|
28770
|
+
const inList = Array.isArray(from);
|
|
28771
|
+
for (const [key, item] of Object.entries(from)) {
|
|
28772
|
+
if (from === value && !inList && keptWhole(key, item)) {
|
|
28773
|
+
to[key] = item;
|
|
28774
|
+
continue;
|
|
28775
|
+
}
|
|
28776
|
+
const statesNothing = item === null || item === undefined || item === "" || item === false || Array.isArray(item) && item.length === 0;
|
|
28777
|
+
if (!inList && statesNothing)
|
|
28778
|
+
continue;
|
|
28779
|
+
if (!isObject3(item)) {
|
|
28780
|
+
to[key] = item;
|
|
28781
|
+
continue;
|
|
28782
|
+
}
|
|
28783
|
+
const copy = Array.isArray(item) ? [] : {};
|
|
28784
|
+
pending.push([item, copy]);
|
|
28785
|
+
if (!inList && !Array.isArray(item))
|
|
28786
|
+
placed.push([to, key, copy]);
|
|
28787
|
+
to[key] = copy;
|
|
28788
|
+
}
|
|
28789
|
+
}
|
|
28790
|
+
for (const [holder, key, held] of placed.reverse()) {
|
|
28791
|
+
if (Object.keys(held).length === 0)
|
|
28792
|
+
delete holder[key];
|
|
28793
|
+
}
|
|
28794
|
+
return root;
|
|
28718
28795
|
}
|
|
28719
28796
|
function dispatchAskQuestion(comment) {
|
|
28720
28797
|
return comment?.ask_question !== undefined && comment.ask_question !== "" ? textHead(comment.ask_question) : undefined;
|
|
@@ -28866,6 +28943,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
28866
28943
|
let inReplyTo = envelope.in_reply_to;
|
|
28867
28944
|
let payloadSessions = [];
|
|
28868
28945
|
let trailer = "";
|
|
28946
|
+
const at = inboundTimestamp(envelope.issued_at);
|
|
28869
28947
|
const dispatchRendered = envelope.source === "dispatch" && envelope.payload !== undefined;
|
|
28870
28948
|
if (envelope.source === "dispatch") {
|
|
28871
28949
|
const topic = subject ?? envelope.topic;
|
|
@@ -28971,12 +29049,19 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
28971
29049
|
ask: dispatchReplyRef(frame.event, topic, compact.askId, commentPayload),
|
|
28972
29050
|
...compact.record
|
|
28973
29051
|
};
|
|
29052
|
+
const payload = compactRecord === undefined ? dispatchPayloadForReader(frame.event, sessionID, envelope.issued_at) : undefined;
|
|
29053
|
+
let actor = frame.event.actor;
|
|
29054
|
+
if ("origin" in frame.event.actor) {
|
|
29055
|
+
const { origin, ...rest } = frame.event.actor;
|
|
29056
|
+
const title = isObject3(origin) ? origin["session_title"] : undefined;
|
|
29057
|
+
actor = typeof title === "string" && title !== "" ? { ...rest, origin: { session_title: title } } : rest;
|
|
29058
|
+
}
|
|
28974
29059
|
dispatchEvent = {
|
|
28975
29060
|
owner: dispatchOwner(frame.event, topic),
|
|
28976
29061
|
type: frame.event.type,
|
|
28977
|
-
actor
|
|
29062
|
+
actor,
|
|
28978
29063
|
...relation === undefined ? {} : { relation },
|
|
28979
|
-
...compactRecord ??
|
|
29064
|
+
...compactRecord ?? (isObject3(payload) && Object.keys(payload).length === 0 ? {} : { payload })
|
|
28980
29065
|
};
|
|
28981
29066
|
dispatchActor = frame.event.actor;
|
|
28982
29067
|
bodyNote = carriedBodyNote(frame.event);
|
|
@@ -29029,7 +29114,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
29029
29114
|
const rendered = {
|
|
29030
29115
|
...envelope.topic !== undefined && topicForms(envelope.topic).includes(legacyAgentSubject(sessionID)) ? { to: `you (${sessionID})` } : {},
|
|
29031
29116
|
from: senderLabel(envelope),
|
|
29032
|
-
at
|
|
29117
|
+
at,
|
|
29033
29118
|
id: envelope.event_id ?? "unknown",
|
|
29034
29119
|
...envelope.kept_at === undefined ? {} : { kept_at: inboundTimestamp(envelope.kept_at) },
|
|
29035
29120
|
...envelope.expires_at === undefined ? {} : { by: inboundTimestamp(envelope.expires_at) },
|
package/dist/envoy-channel.js
CHANGED
|
@@ -50278,6 +50278,9 @@ function parseDispatchRef(ref) {
|
|
|
50278
50278
|
// ../envoy-client/src/dispatch-picture-tools.ts
|
|
50279
50279
|
import { basename as basename2, resolve as resolvePath } from "path";
|
|
50280
50280
|
|
|
50281
|
+
// ../envoy-client/src/delivery.ts
|
|
50282
|
+
import { isDeepStrictEqual } from "util";
|
|
50283
|
+
|
|
50281
50284
|
// ../../node_modules/.bun/@toon-format+toon@4.1.1/node_modules/@toon-format/toon/dist/index.mjs
|
|
50282
50285
|
var NULL_LITERAL = "null";
|
|
50283
50286
|
var DELIMITERS = {
|
|
@@ -52650,21 +52653,95 @@ function dispatchCompact(event, comment, ownsAsk) {
|
|
|
52650
52653
|
return { askId: ask.data.id, record };
|
|
52651
52654
|
}
|
|
52652
52655
|
function dispatchPayload(event) {
|
|
52653
|
-
const schema = DISPATCH_PAYLOAD_SCHEMAS[event.type];
|
|
52656
|
+
const schema = Object.hasOwn(DISPATCH_PAYLOAD_SCHEMAS, event.type) ? DISPATCH_PAYLOAD_SCHEMAS[event.type] : undefined;
|
|
52654
52657
|
if (schema === undefined)
|
|
52655
52658
|
return event.payload;
|
|
52656
52659
|
const parsed = schema.safeParse(event.payload);
|
|
52657
52660
|
return parsed.success ? parsed.data : event.payload;
|
|
52658
52661
|
}
|
|
52659
|
-
|
|
52660
|
-
|
|
52661
|
-
|
|
52662
|
-
|
|
52663
|
-
|
|
52664
|
-
|
|
52662
|
+
var DISPATCH_BOOKKEEPING = new Set([
|
|
52663
|
+
"deliveries",
|
|
52664
|
+
"mentions_decide_routes",
|
|
52665
|
+
"suppress_route",
|
|
52666
|
+
"suppressed_route",
|
|
52667
|
+
"suppressed_route_session_id",
|
|
52668
|
+
"suppressed_authors",
|
|
52669
|
+
"thread_logins",
|
|
52670
|
+
"references_changed",
|
|
52671
|
+
"references_changed_truncated",
|
|
52672
|
+
"references_changed_truncated_kinds",
|
|
52673
|
+
"rank"
|
|
52674
|
+
]);
|
|
52675
|
+
function dispatchPayloadForReader(event, sessionID, issuedAt) {
|
|
52676
|
+
const whole = dispatchPayload(event);
|
|
52677
|
+
const changed = event.type !== "issue.created" && isObject3(whole) && Array.isArray(whole["changed"]) ? whole["changed"] : [];
|
|
52678
|
+
const payload = withoutEmptyFields(whole, (key, item) => changed.includes(key) || (key === "suggestion" || key === "forced") && item !== null && item !== undefined);
|
|
52679
|
+
if (!isObject3(payload) || Array.isArray(payload))
|
|
52665
52680
|
return payload;
|
|
52666
|
-
const
|
|
52667
|
-
|
|
52681
|
+
const { reply_to: replyTo } = payload;
|
|
52682
|
+
const actor = event.actor;
|
|
52683
|
+
const repeatsTheCard = (key, value) => {
|
|
52684
|
+
switch (key) {
|
|
52685
|
+
case "issue_key":
|
|
52686
|
+
return value === event.issue_key;
|
|
52687
|
+
case "author":
|
|
52688
|
+
return isObject3(value) && Object.entries(value).every(([field, held]) => isDeepStrictEqual(held, actor[field]));
|
|
52689
|
+
case "created_at": {
|
|
52690
|
+
if (typeof value !== "string")
|
|
52691
|
+
return false;
|
|
52692
|
+
const timestamp = Date.parse(value);
|
|
52693
|
+
return issuedAt !== undefined && Math.abs(timestamp - issuedAt) < 1000;
|
|
52694
|
+
}
|
|
52695
|
+
case "thread_root_id":
|
|
52696
|
+
case "answers":
|
|
52697
|
+
return typeof replyTo === "string" && value === replyTo;
|
|
52698
|
+
default:
|
|
52699
|
+
return DISPATCH_BOOKKEEPING.has(key);
|
|
52700
|
+
}
|
|
52701
|
+
};
|
|
52702
|
+
const shown = {};
|
|
52703
|
+
for (const [key, value] of Object.entries(payload)) {
|
|
52704
|
+
if (!changed.includes(key) && repeatsTheCard(key, value))
|
|
52705
|
+
continue;
|
|
52706
|
+
shown[key] = key === "target" && value === `session:${sessionID}` ? `you (${value})` : value;
|
|
52707
|
+
}
|
|
52708
|
+
return shown;
|
|
52709
|
+
}
|
|
52710
|
+
function withoutEmptyFields(value, keptWhole) {
|
|
52711
|
+
if (!isObject3(value))
|
|
52712
|
+
return value;
|
|
52713
|
+
const root = Array.isArray(value) ? [] : {};
|
|
52714
|
+
const pending = [
|
|
52715
|
+
[value, root]
|
|
52716
|
+
];
|
|
52717
|
+
const placed = [];
|
|
52718
|
+
for (let next = pending.pop();next !== undefined; next = pending.pop()) {
|
|
52719
|
+
const [from, to] = next;
|
|
52720
|
+
const inList = Array.isArray(from);
|
|
52721
|
+
for (const [key, item] of Object.entries(from)) {
|
|
52722
|
+
if (from === value && !inList && keptWhole(key, item)) {
|
|
52723
|
+
to[key] = item;
|
|
52724
|
+
continue;
|
|
52725
|
+
}
|
|
52726
|
+
const statesNothing = item === null || item === undefined || item === "" || item === false || Array.isArray(item) && item.length === 0;
|
|
52727
|
+
if (!inList && statesNothing)
|
|
52728
|
+
continue;
|
|
52729
|
+
if (!isObject3(item)) {
|
|
52730
|
+
to[key] = item;
|
|
52731
|
+
continue;
|
|
52732
|
+
}
|
|
52733
|
+
const copy = Array.isArray(item) ? [] : {};
|
|
52734
|
+
pending.push([item, copy]);
|
|
52735
|
+
if (!inList && !Array.isArray(item))
|
|
52736
|
+
placed.push([to, key, copy]);
|
|
52737
|
+
to[key] = copy;
|
|
52738
|
+
}
|
|
52739
|
+
}
|
|
52740
|
+
for (const [holder, key, held] of placed.reverse()) {
|
|
52741
|
+
if (Object.keys(held).length === 0)
|
|
52742
|
+
delete holder[key];
|
|
52743
|
+
}
|
|
52744
|
+
return root;
|
|
52668
52745
|
}
|
|
52669
52746
|
function dispatchAskQuestion(comment) {
|
|
52670
52747
|
return comment?.ask_question !== undefined && comment.ask_question !== "" ? textHead(comment.ask_question) : undefined;
|
|
@@ -52816,6 +52893,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
52816
52893
|
let inReplyTo = envelope.in_reply_to;
|
|
52817
52894
|
let payloadSessions = [];
|
|
52818
52895
|
let trailer = "";
|
|
52896
|
+
const at = inboundTimestamp(envelope.issued_at);
|
|
52819
52897
|
const dispatchRendered = envelope.source === "dispatch" && envelope.payload !== undefined;
|
|
52820
52898
|
if (envelope.source === "dispatch") {
|
|
52821
52899
|
const topic = subject ?? envelope.topic;
|
|
@@ -52921,12 +52999,19 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
52921
52999
|
ask: dispatchReplyRef(frame.event, topic, compact.askId, commentPayload),
|
|
52922
53000
|
...compact.record
|
|
52923
53001
|
};
|
|
53002
|
+
const payload = compactRecord === undefined ? dispatchPayloadForReader(frame.event, sessionID, envelope.issued_at) : undefined;
|
|
53003
|
+
let actor = frame.event.actor;
|
|
53004
|
+
if ("origin" in frame.event.actor) {
|
|
53005
|
+
const { origin, ...rest } = frame.event.actor;
|
|
53006
|
+
const title = isObject3(origin) ? origin["session_title"] : undefined;
|
|
53007
|
+
actor = typeof title === "string" && title !== "" ? { ...rest, origin: { session_title: title } } : rest;
|
|
53008
|
+
}
|
|
52924
53009
|
dispatchEvent = {
|
|
52925
53010
|
owner: dispatchOwner(frame.event, topic),
|
|
52926
53011
|
type: frame.event.type,
|
|
52927
|
-
actor
|
|
53012
|
+
actor,
|
|
52928
53013
|
...relation === undefined ? {} : { relation },
|
|
52929
|
-
...compactRecord ??
|
|
53014
|
+
...compactRecord ?? (isObject3(payload) && Object.keys(payload).length === 0 ? {} : { payload })
|
|
52930
53015
|
};
|
|
52931
53016
|
dispatchActor = frame.event.actor;
|
|
52932
53017
|
bodyNote = carriedBodyNote(frame.event);
|
|
@@ -52979,7 +53064,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
52979
53064
|
const rendered = {
|
|
52980
53065
|
...envelope.topic !== undefined && topicForms(envelope.topic).includes(legacyAgentSubject(sessionID)) ? { to: `you (${sessionID})` } : {},
|
|
52981
53066
|
from: senderLabel(envelope),
|
|
52982
|
-
at
|
|
53067
|
+
at,
|
|
52983
53068
|
id: envelope.event_id ?? "unknown",
|
|
52984
53069
|
...envelope.kept_at === undefined ? {} : { kept_at: inboundTimestamp(envelope.kept_at) },
|
|
52985
53070
|
...envelope.expires_at === undefined ? {} : { by: inboundTimestamp(envelope.expires_at) },
|
|
@@ -65509,7 +65594,7 @@ var import_nats5 = __toESM(require_mod4(), 1);
|
|
|
65509
65594
|
|
|
65510
65595
|
// package.json
|
|
65511
65596
|
var name2 = "@sjawhar/claude-envoy";
|
|
65512
|
-
var version2 = "6.0.
|
|
65597
|
+
var version2 = "6.0.2";
|
|
65513
65598
|
var package_default = {
|
|
65514
65599
|
name: name2,
|
|
65515
65600
|
version: version2,
|
package/dist/session-hook.js
CHANGED
|
@@ -23571,6 +23571,9 @@ function parseDispatchRef(ref) {
|
|
|
23571
23571
|
// ../envoy-client/src/dispatch-picture-tools.ts
|
|
23572
23572
|
import { basename as basename2, resolve as resolvePath } from "path";
|
|
23573
23573
|
|
|
23574
|
+
// ../envoy-client/src/delivery.ts
|
|
23575
|
+
import { isDeepStrictEqual } from "util";
|
|
23576
|
+
|
|
23574
23577
|
// ../../node_modules/.bun/@toon-format+toon@4.1.1/node_modules/@toon-format/toon/dist/index.mjs
|
|
23575
23578
|
var NULL_LITERAL = "null";
|
|
23576
23579
|
var DELIMITERS = {
|
|
@@ -27908,21 +27911,95 @@ function dispatchCompact(event, comment, ownsAsk) {
|
|
|
27908
27911
|
return { askId: ask.data.id, record };
|
|
27909
27912
|
}
|
|
27910
27913
|
function dispatchPayload(event) {
|
|
27911
|
-
const schema = DISPATCH_PAYLOAD_SCHEMAS[event.type];
|
|
27914
|
+
const schema = Object.hasOwn(DISPATCH_PAYLOAD_SCHEMAS, event.type) ? DISPATCH_PAYLOAD_SCHEMAS[event.type] : undefined;
|
|
27912
27915
|
if (schema === undefined)
|
|
27913
27916
|
return event.payload;
|
|
27914
27917
|
const parsed = schema.safeParse(event.payload);
|
|
27915
27918
|
return parsed.success ? parsed.data : event.payload;
|
|
27916
27919
|
}
|
|
27917
|
-
|
|
27918
|
-
|
|
27919
|
-
|
|
27920
|
-
|
|
27921
|
-
|
|
27922
|
-
|
|
27920
|
+
var DISPATCH_BOOKKEEPING = new Set([
|
|
27921
|
+
"deliveries",
|
|
27922
|
+
"mentions_decide_routes",
|
|
27923
|
+
"suppress_route",
|
|
27924
|
+
"suppressed_route",
|
|
27925
|
+
"suppressed_route_session_id",
|
|
27926
|
+
"suppressed_authors",
|
|
27927
|
+
"thread_logins",
|
|
27928
|
+
"references_changed",
|
|
27929
|
+
"references_changed_truncated",
|
|
27930
|
+
"references_changed_truncated_kinds",
|
|
27931
|
+
"rank"
|
|
27932
|
+
]);
|
|
27933
|
+
function dispatchPayloadForReader(event, sessionID, issuedAt) {
|
|
27934
|
+
const whole = dispatchPayload(event);
|
|
27935
|
+
const changed = event.type !== "issue.created" && isObject3(whole) && Array.isArray(whole["changed"]) ? whole["changed"] : [];
|
|
27936
|
+
const payload = withoutEmptyFields(whole, (key, item) => changed.includes(key) || (key === "suggestion" || key === "forced") && item !== null && item !== undefined);
|
|
27937
|
+
if (!isObject3(payload) || Array.isArray(payload))
|
|
27923
27938
|
return payload;
|
|
27924
|
-
const
|
|
27925
|
-
|
|
27939
|
+
const { reply_to: replyTo } = payload;
|
|
27940
|
+
const actor = event.actor;
|
|
27941
|
+
const repeatsTheCard = (key, value) => {
|
|
27942
|
+
switch (key) {
|
|
27943
|
+
case "issue_key":
|
|
27944
|
+
return value === event.issue_key;
|
|
27945
|
+
case "author":
|
|
27946
|
+
return isObject3(value) && Object.entries(value).every(([field, held]) => isDeepStrictEqual(held, actor[field]));
|
|
27947
|
+
case "created_at": {
|
|
27948
|
+
if (typeof value !== "string")
|
|
27949
|
+
return false;
|
|
27950
|
+
const timestamp = Date.parse(value);
|
|
27951
|
+
return issuedAt !== undefined && Math.abs(timestamp - issuedAt) < 1000;
|
|
27952
|
+
}
|
|
27953
|
+
case "thread_root_id":
|
|
27954
|
+
case "answers":
|
|
27955
|
+
return typeof replyTo === "string" && value === replyTo;
|
|
27956
|
+
default:
|
|
27957
|
+
return DISPATCH_BOOKKEEPING.has(key);
|
|
27958
|
+
}
|
|
27959
|
+
};
|
|
27960
|
+
const shown = {};
|
|
27961
|
+
for (const [key, value] of Object.entries(payload)) {
|
|
27962
|
+
if (!changed.includes(key) && repeatsTheCard(key, value))
|
|
27963
|
+
continue;
|
|
27964
|
+
shown[key] = key === "target" && value === `session:${sessionID}` ? `you (${value})` : value;
|
|
27965
|
+
}
|
|
27966
|
+
return shown;
|
|
27967
|
+
}
|
|
27968
|
+
function withoutEmptyFields(value, keptWhole) {
|
|
27969
|
+
if (!isObject3(value))
|
|
27970
|
+
return value;
|
|
27971
|
+
const root = Array.isArray(value) ? [] : {};
|
|
27972
|
+
const pending = [
|
|
27973
|
+
[value, root]
|
|
27974
|
+
];
|
|
27975
|
+
const placed = [];
|
|
27976
|
+
for (let next = pending.pop();next !== undefined; next = pending.pop()) {
|
|
27977
|
+
const [from, to] = next;
|
|
27978
|
+
const inList = Array.isArray(from);
|
|
27979
|
+
for (const [key, item] of Object.entries(from)) {
|
|
27980
|
+
if (from === value && !inList && keptWhole(key, item)) {
|
|
27981
|
+
to[key] = item;
|
|
27982
|
+
continue;
|
|
27983
|
+
}
|
|
27984
|
+
const statesNothing = item === null || item === undefined || item === "" || item === false || Array.isArray(item) && item.length === 0;
|
|
27985
|
+
if (!inList && statesNothing)
|
|
27986
|
+
continue;
|
|
27987
|
+
if (!isObject3(item)) {
|
|
27988
|
+
to[key] = item;
|
|
27989
|
+
continue;
|
|
27990
|
+
}
|
|
27991
|
+
const copy = Array.isArray(item) ? [] : {};
|
|
27992
|
+
pending.push([item, copy]);
|
|
27993
|
+
if (!inList && !Array.isArray(item))
|
|
27994
|
+
placed.push([to, key, copy]);
|
|
27995
|
+
to[key] = copy;
|
|
27996
|
+
}
|
|
27997
|
+
}
|
|
27998
|
+
for (const [holder, key, held] of placed.reverse()) {
|
|
27999
|
+
if (Object.keys(held).length === 0)
|
|
28000
|
+
delete holder[key];
|
|
28001
|
+
}
|
|
28002
|
+
return root;
|
|
27926
28003
|
}
|
|
27927
28004
|
function dispatchAskQuestion(comment) {
|
|
27928
28005
|
return comment?.ask_question !== undefined && comment.ask_question !== "" ? textHead(comment.ask_question) : undefined;
|
|
@@ -28074,6 +28151,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
28074
28151
|
let inReplyTo = envelope.in_reply_to;
|
|
28075
28152
|
let payloadSessions = [];
|
|
28076
28153
|
let trailer = "";
|
|
28154
|
+
const at = inboundTimestamp(envelope.issued_at);
|
|
28077
28155
|
const dispatchRendered = envelope.source === "dispatch" && envelope.payload !== undefined;
|
|
28078
28156
|
if (envelope.source === "dispatch") {
|
|
28079
28157
|
const topic = subject ?? envelope.topic;
|
|
@@ -28179,12 +28257,19 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
28179
28257
|
ask: dispatchReplyRef(frame.event, topic, compact.askId, commentPayload),
|
|
28180
28258
|
...compact.record
|
|
28181
28259
|
};
|
|
28260
|
+
const payload = compactRecord === undefined ? dispatchPayloadForReader(frame.event, sessionID, envelope.issued_at) : undefined;
|
|
28261
|
+
let actor = frame.event.actor;
|
|
28262
|
+
if ("origin" in frame.event.actor) {
|
|
28263
|
+
const { origin, ...rest } = frame.event.actor;
|
|
28264
|
+
const title = isObject3(origin) ? origin["session_title"] : undefined;
|
|
28265
|
+
actor = typeof title === "string" && title !== "" ? { ...rest, origin: { session_title: title } } : rest;
|
|
28266
|
+
}
|
|
28182
28267
|
dispatchEvent = {
|
|
28183
28268
|
owner: dispatchOwner(frame.event, topic),
|
|
28184
28269
|
type: frame.event.type,
|
|
28185
|
-
actor
|
|
28270
|
+
actor,
|
|
28186
28271
|
...relation === undefined ? {} : { relation },
|
|
28187
|
-
...compactRecord ??
|
|
28272
|
+
...compactRecord ?? (isObject3(payload) && Object.keys(payload).length === 0 ? {} : { payload })
|
|
28188
28273
|
};
|
|
28189
28274
|
dispatchActor = frame.event.actor;
|
|
28190
28275
|
bodyNote = carriedBodyNote(frame.event);
|
|
@@ -28237,7 +28322,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
28237
28322
|
const rendered = {
|
|
28238
28323
|
...envelope.topic !== undefined && topicForms(envelope.topic).includes(legacyAgentSubject(sessionID)) ? { to: `you (${sessionID})` } : {},
|
|
28239
28324
|
from: senderLabel(envelope),
|
|
28240
|
-
at
|
|
28325
|
+
at,
|
|
28241
28326
|
id: envelope.event_id ?? "unknown",
|
|
28242
28327
|
...envelope.kept_at === undefined ? {} : { kept_at: inboundTimestamp(envelope.kept_at) },
|
|
28243
28328
|
...envelope.expires_at === undefined ? {} : { by: inboundTimestamp(envelope.expires_at) },
|
|
@@ -68,7 +68,7 @@ The daemon works only issues labelled `legion` (any case), and a labelled root i
|
|
|
68
68
|
|
|
69
69
|
A free slot or a full cap is no reason to take, label, admit or park an issue: a labelled root in `todo` takes the next slot by itself.
|
|
70
70
|
|
|
71
|
-
A slot is one issue the daemon started, a root or a child. Free slots are `admission.cap`, less every issue in `admission.active`, less each issue of `admission.waiting` in neither `admission.active` nor `admission.blocked`.
|
|
71
|
+
A slot is one issue the daemon started, a root or a child. Free slots are `admission.cap`, less every issue in `admission.active`, less each issue of `admission.waiting` in neither `admission.active` nor `admission.blocked`. The line is ordered by Dispatch priority first; within one priority a returned issue goes before an unstarted one whatever their ranks, by design ([Admission and the `legion` label](https://cybermonklabs.github.io/legion/legion/concepts/#admission-and-the-legion-label)). The lists and `admission.held` words: `skill://legion-controller/references/admission.md`.
|
|
72
72
|
|
|
73
73
|
Every move to `todo` you make is one of these:
|
|
74
74
|
|
|
@@ -15,14 +15,17 @@ The rules behind them: [Admission and the `legion` label](https://cybermonklabs.
|
|
|
15
15
|
Use it, not `admission.active`, for which trees run.
|
|
16
16
|
|
|
17
17
|
- `admission.waiting`: the line, in order.
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
It is ordered by Dispatch priority first: P0, P1, P2, P3, then the issues with no priority, each issue at its own priority, else at its tree root's.
|
|
19
|
+
Within one priority, first the issues whose work came back, oldest first; then the issues whose first phase can start, by their root's Dispatch rank and then their own.
|
|
20
|
+
A priority changed in Dispatch moves the issue at the next admission pass; priority takes no slot back from work that runs.
|
|
21
|
+
`issues.<KEY>.priority` is the issue's own priority (0 for P0 to 3 for P3, null for none), and `waitingLine.priority` the one it waits at (null for one that waits after P3).
|
|
22
|
+
`issues.<KEY>.waitingLine` says where one stands (`priority`, `part`, `kind`, `holdsSlot`, `reason`): quote its `reason` before you call an order wrong.
|
|
20
23
|
|
|
21
24
|
- `admission.blocked`: issues waiting on an unfinished `blocked_by` issue, or a parent waiting for its open children.
|
|
22
25
|
A started issue here gave its slot back and takes one again by itself; nothing of its work stops.
|
|
23
26
|
|
|
24
27
|
- `phase: awaiting_person` with `waitingOn`: a root waiting on a person's answer or review keeps its slot and is in no line.
|
|
25
|
-
`waitingOn.answeredAt` means the daemon has put it in `admission.waiting` as well, among the issues whose work came back, oldest first, where it stands until the pass that resumes it.
|
|
28
|
+
`waitingOn.answeredAt` means the daemon has put it in `admission.waiting` as well, within its priority, among the issues whose work came back, oldest first, where it stands until the pass that resumes it.
|
|
26
29
|
|
|
27
30
|
- `phase: admitted`, in no list, with a `child_of` parent: a child that has not started.
|
|
28
31
|
Leave it to its tree.
|
|
@@ -10,7 +10,7 @@ A `silent` entry is a phase worker nothing will prompt: the daemon sends its tas
|
|
|
10
10
|
|
|
11
11
|
## `awaiting-person`
|
|
12
12
|
|
|
13
|
-
A root that waits only on a person keeps its slot: do not park it or take anything for its wait. The person's answer puts it in `admission.waiting` by itself, among the issues whose work came back, oldest first, and its promotion gives its architect the answer task.
|
|
13
|
+
A root that waits only on a person keeps its slot: do not park it or take anything for its wait. The person's answer puts it in `admission.waiting` by itself, within its priority, among the issues whose work came back, oldest first, and its promotion gives its architect the answer task.
|
|
14
14
|
|
|
15
15
|
## `tree-stalled`
|
|
16
16
|
|