@sjawhar/claude-envoy 1.39.1 → 1.40.1
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/dispatch.js +1 -1
- package/dist/envoy-channel.js +70 -16
- package/dist/session-hook.js +1 -1
- package/legion/skills/legion-architect/references/merge-notices.md +6 -0
- package/package.json +1 -1
- package/skills/dispatch/SKILL.md +3 -2
- package/skills/dispatch-first/SKILL.md +1 -1
- package/src/envoy-channel-server.ts +4 -2
package/.omp-plugin/plugin.json
CHANGED
package/dist/dispatch.js
CHANGED
|
@@ -15226,7 +15226,7 @@ function imagesArgument(z, owner) {
|
|
|
15226
15226
|
var ASK_URGENCIES = ["low", "med", "high", "blocking"];
|
|
15227
15227
|
var DISPATCH_BLOCK_UNITS = 32000;
|
|
15228
15228
|
var DISPATCH_ITEM_BLOCKS = 32768;
|
|
15229
|
-
var BODY_BLOCK_RULE = `Each block (a paragraph, list, quote, table or code block) holds at most ${DISPATCH_BLOCK_UNITS} ` + `characters and a body at most ${DISPATCH_ITEM_BLOCKS} blocks; Dispatch refuses a longer one and ` + "names it, and `dispatch limits` prints the bounds.";
|
|
15229
|
+
var BODY_BLOCK_RULE = `Each block (a paragraph, list, quote, table or code block) holds at most ${DISPATCH_BLOCK_UNITS} ` + `characters and a body at most ${DISPATCH_ITEM_BLOCKS} blocks; Dispatch refuses a longer one and ` + "names it, and `dispatch limits` prints the bounds. A body holding a decision block (`:::ask`) " + "is refused however short it is, since nobody can answer a question put in a comment or a " + "message: ask the question in the issue's own document, as a decision block there, or open an " + "ask with `dispatch ask`.";
|
|
15230
15230
|
var ASK_BOUND_RULE = "Dispatch bounds an ask's question and its options together, refuses a longer one and names " + "the bound, and `dispatch limits` prints it. An ask is short and asks one thing; its reasoning " + "goes in the document, not in the question.";
|
|
15231
15231
|
var DISPATCH_HANDOFF_BODY_MAX = 262144;
|
|
15232
15232
|
var HANDOFF_PHASE_PATTERN = /^[a-z][a-z0-9-]{0,31}$/;
|
package/dist/envoy-channel.js
CHANGED
|
@@ -36875,7 +36875,7 @@ function imagesArgument(z, owner) {
|
|
|
36875
36875
|
var ASK_URGENCIES = ["low", "med", "high", "blocking"];
|
|
36876
36876
|
var DISPATCH_BLOCK_UNITS = 32000;
|
|
36877
36877
|
var DISPATCH_ITEM_BLOCKS = 32768;
|
|
36878
|
-
var BODY_BLOCK_RULE = `Each block (a paragraph, list, quote, table or code block) holds at most ${DISPATCH_BLOCK_UNITS} ` + `characters and a body at most ${DISPATCH_ITEM_BLOCKS} blocks; Dispatch refuses a longer one and ` + "names it, and `dispatch limits` prints the bounds.";
|
|
36878
|
+
var BODY_BLOCK_RULE = `Each block (a paragraph, list, quote, table or code block) holds at most ${DISPATCH_BLOCK_UNITS} ` + `characters and a body at most ${DISPATCH_ITEM_BLOCKS} blocks; Dispatch refuses a longer one and ` + "names it, and `dispatch limits` prints the bounds. A body holding a decision block (`:::ask`) " + "is refused however short it is, since nobody can answer a question put in a comment or a " + "message: ask the question in the issue's own document, as a decision block there, or open an " + "ask with `dispatch ask`.";
|
|
36879
36879
|
var ASK_BOUND_RULE = "Dispatch bounds an ask's question and its options together, refuses a longer one and names " + "the bound, and `dispatch limits` prints it. An ask is short and asks one thing; its reasoning " + "goes in the document, not in the question.";
|
|
36880
36880
|
var DISPATCH_HANDOFF_BODY_MAX = 262144;
|
|
36881
36881
|
var HANDOFF_PHASE_PATTERN = /^[a-z][a-z0-9-]{0,31}$/;
|
|
@@ -44858,16 +44858,16 @@ function createReplayEngine(options) {
|
|
|
44858
44858
|
unwritten.push(entry);
|
|
44859
44859
|
};
|
|
44860
44860
|
const flush = (alive, atOnce = false) => {
|
|
44861
|
-
|
|
44861
|
+
const written = writes.then(async () => {
|
|
44862
44862
|
if (!alive())
|
|
44863
|
-
return;
|
|
44863
|
+
return false;
|
|
44864
44864
|
const json = stateJSON();
|
|
44865
44865
|
const delivered = unwritten;
|
|
44866
44866
|
if (json === writtenState && delivered.length === 0)
|
|
44867
|
-
return;
|
|
44867
|
+
return true;
|
|
44868
44868
|
const shape = stateJSON(false);
|
|
44869
44869
|
if (delivered.length === 0 && !atOnce && shape === writtenShape && writtenAt !== undefined && now() - writtenAt < REPLAY_STATE_REFRESH_MS) {
|
|
44870
|
-
return;
|
|
44870
|
+
return true;
|
|
44871
44871
|
}
|
|
44872
44872
|
unwritten = [];
|
|
44873
44873
|
const state = json === writtenState ? undefined : JSON.parse(json);
|
|
@@ -44882,12 +44882,17 @@ function createReplayEngine(options) {
|
|
|
44882
44882
|
writtenShape = shape;
|
|
44883
44883
|
writtenAt = now();
|
|
44884
44884
|
}
|
|
44885
|
+
return true;
|
|
44885
44886
|
} catch (error) {
|
|
44886
44887
|
unwritten = [...delivered, ...unwritten];
|
|
44887
44888
|
log("replay: could not persist the replay state; the next write carries it", error);
|
|
44889
|
+
return false;
|
|
44888
44890
|
}
|
|
44889
44891
|
});
|
|
44890
|
-
|
|
44892
|
+
writes = written.then(() => {
|
|
44893
|
+
return;
|
|
44894
|
+
});
|
|
44895
|
+
return written;
|
|
44891
44896
|
};
|
|
44892
44897
|
const syncFollowed = () => {
|
|
44893
44898
|
const followed = new Set(host.followedSubjects());
|
|
@@ -45353,18 +45358,20 @@ function createReplayEngine(options) {
|
|
|
45353
45358
|
async recordDeliveredFor(sessionID, frame) {
|
|
45354
45359
|
const alive = bindTo(sessionID, writeSession)?.alive;
|
|
45355
45360
|
if (alive === undefined)
|
|
45356
|
-
return;
|
|
45361
|
+
return false;
|
|
45357
45362
|
record2(replayLedgerIdentity(frame));
|
|
45358
|
-
await flush(alive);
|
|
45363
|
+
return await flush(alive);
|
|
45359
45364
|
},
|
|
45360
|
-
async liveFailed(followed, envelope, error, receivedAt) {
|
|
45365
|
+
async liveFailed(sessionID, followed, envelope, error, receivedAt) {
|
|
45361
45366
|
const started = cursorStarts.get(followed);
|
|
45362
45367
|
if (!isRoleForward(envelope) && answered.has(followed) && cursors.get(followed)?.after !== undefined && (started === undefined || started <= receivedAt)) {
|
|
45363
45368
|
return;
|
|
45364
45369
|
}
|
|
45365
|
-
const alive =
|
|
45366
|
-
if (alive === undefined)
|
|
45370
|
+
const alive = bindTo(sessionID, currentSession)?.alive;
|
|
45371
|
+
if (alive === undefined) {
|
|
45372
|
+
log("replay: a failed frame was not reported here; the session it names is closed");
|
|
45367
45373
|
return;
|
|
45374
|
+
}
|
|
45368
45375
|
try {
|
|
45369
45376
|
await showFailureNotice(failureNotice(envelope, inboundTimestamp(envelope.issued_at), messageFor(error)), alive);
|
|
45370
45377
|
} catch (thrown) {
|
|
@@ -45767,11 +45774,12 @@ function createConsumerDelivery(options) {
|
|
|
45767
45774
|
settle(entry, "nak");
|
|
45768
45775
|
return;
|
|
45769
45776
|
}
|
|
45777
|
+
log(`frame ${entry.frame.streamSeq} failed and does not come again; its session gets the notice`, error);
|
|
45770
45778
|
safely("failure notice", () => {
|
|
45771
45779
|
const { subject, data } = entry.frame;
|
|
45772
45780
|
const { envelope } = renderInbound(data, sessionID, subject);
|
|
45773
45781
|
if (envelope !== undefined)
|
|
45774
|
-
ledger.liveFailed(subject, envelope, error, now());
|
|
45782
|
+
ledger.liveFailed(sessionID, subject, envelope, error, now());
|
|
45775
45783
|
});
|
|
45776
45784
|
settle(entry, "done");
|
|
45777
45785
|
};
|
|
@@ -55490,7 +55498,7 @@ var import_nats2 = __toESM(require_mod4(), 1);
|
|
|
55490
55498
|
|
|
55491
55499
|
// package.json
|
|
55492
55500
|
var name = "@sjawhar/claude-envoy";
|
|
55493
|
-
var version2 = "1.
|
|
55501
|
+
var version2 = "1.40.1";
|
|
55494
55502
|
var legion = {
|
|
55495
55503
|
daemonApiVersion: 68
|
|
55496
55504
|
};
|
|
@@ -55641,9 +55649,15 @@ class AgentStreamPublisher {
|
|
|
55641
55649
|
#listedCommands;
|
|
55642
55650
|
#commands;
|
|
55643
55651
|
#commandsSeq = 0;
|
|
55652
|
+
#fitListed;
|
|
55653
|
+
#fitLimit = 0;
|
|
55654
|
+
#fitEmptyBytes = 0;
|
|
55644
55655
|
#settings;
|
|
55645
55656
|
#settingsSeq = 0;
|
|
55646
55657
|
#settingsJson;
|
|
55658
|
+
#context;
|
|
55659
|
+
#contextSeq = 0;
|
|
55660
|
+
#contextJson;
|
|
55647
55661
|
constructor(deps) {
|
|
55648
55662
|
this.#deps = deps;
|
|
55649
55663
|
this.#seq = Math.trunc(deps.now()) * SEQ_PER_MS;
|
|
@@ -55657,6 +55671,9 @@ class AgentStreamPublisher {
|
|
|
55657
55671
|
if (this.#settings !== undefined) {
|
|
55658
55672
|
this.#deps.publish(subject, JSON.stringify(this.#settingsFrame(this.#settings)));
|
|
55659
55673
|
}
|
|
55674
|
+
if (this.#context !== undefined) {
|
|
55675
|
+
this.#deps.publish(subject, JSON.stringify(this.#contextFrame(this.#context)));
|
|
55676
|
+
}
|
|
55660
55677
|
if (this.#commands !== undefined) {
|
|
55661
55678
|
this.#deps.publish(subject, JSON.stringify(this.#commandsFrame(this.#commands)));
|
|
55662
55679
|
}
|
|
@@ -55673,6 +55690,8 @@ class AgentStreamPublisher {
|
|
|
55673
55690
|
this.#commands = undefined;
|
|
55674
55691
|
this.#settings = undefined;
|
|
55675
55692
|
this.#settingsJson = undefined;
|
|
55693
|
+
this.#context = undefined;
|
|
55694
|
+
this.#contextJson = undefined;
|
|
55676
55695
|
}
|
|
55677
55696
|
setCommands(subject, commands) {
|
|
55678
55697
|
const seen = new Set;
|
|
@@ -55716,13 +55735,43 @@ class AgentStreamPublisher {
|
|
|
55716
55735
|
this.#deps.publish(subject, JSON.stringify(this.#settingsFrame(kept)));
|
|
55717
55736
|
this.#fitCommands(subject);
|
|
55718
55737
|
}
|
|
55738
|
+
setContext(subject, usage) {
|
|
55739
|
+
if (usage === undefined)
|
|
55740
|
+
return;
|
|
55741
|
+
if (!(usage.contextWindow > 0))
|
|
55742
|
+
return;
|
|
55743
|
+
if (typeof usage.percent !== "number" && !(usage.tokens > 0))
|
|
55744
|
+
return;
|
|
55745
|
+
const kept = {
|
|
55746
|
+
contextWindow: usage.contextWindow,
|
|
55747
|
+
tokens: usage.tokens
|
|
55748
|
+
};
|
|
55749
|
+
const json = JSON.stringify(kept);
|
|
55750
|
+
if (json === this.#contextJson)
|
|
55751
|
+
return;
|
|
55752
|
+
this.#context = kept;
|
|
55753
|
+
this.#contextJson = json;
|
|
55754
|
+
this.#seq += 1;
|
|
55755
|
+
this.#contextSeq = this.#seq;
|
|
55756
|
+
if (this.watched)
|
|
55757
|
+
this.#deps.publish(subject, JSON.stringify(this.#contextFrame(kept)));
|
|
55758
|
+
this.#fitCommands(subject);
|
|
55759
|
+
}
|
|
55719
55760
|
#fitCommands(subject) {
|
|
55720
55761
|
const listed = this.#listedCommands;
|
|
55721
55762
|
if (listed === undefined)
|
|
55722
55763
|
return;
|
|
55723
55764
|
const settings = this.#settings === undefined ? 0 : jsonBytes(this.#settingsFrame(this.#settings)) + 1;
|
|
55724
|
-
const
|
|
55725
|
-
|
|
55765
|
+
const context = this.#context === undefined ? 0 : jsonBytes(this.#contextFrame(this.#context)) + 1;
|
|
55766
|
+
const limit = AGENT_STREAM_LIMITS.historyBytes - REPLAY_ARRAY_BYTES - settings - context;
|
|
55767
|
+
const emptyBytes = jsonBytes(this.#commandsFrame([], this.#seq + 1));
|
|
55768
|
+
const unchanged = listed === this.#fitListed && limit === this.#fitLimit && emptyBytes === this.#fitEmptyBytes;
|
|
55769
|
+
if (unchanged)
|
|
55770
|
+
return;
|
|
55771
|
+
this.#fitListed = listed;
|
|
55772
|
+
this.#fitLimit = limit;
|
|
55773
|
+
this.#fitEmptyBytes = emptyBytes;
|
|
55774
|
+
let bytes = emptyBytes;
|
|
55726
55775
|
const kept = [];
|
|
55727
55776
|
for (const command of listed) {
|
|
55728
55777
|
const cost = jsonBytes(command) + (kept.length === 0 ? 0 : 1);
|
|
@@ -55745,6 +55794,9 @@ class AgentStreamPublisher {
|
|
|
55745
55794
|
#settingsFrame(settings) {
|
|
55746
55795
|
return { ...settings, kind: "settings", seq: this.#settingsSeq, v: AGENT_STREAM_PROTOCOL };
|
|
55747
55796
|
}
|
|
55797
|
+
#contextFrame(context) {
|
|
55798
|
+
return { ...context, kind: "context", seq: this.#contextSeq, v: AGENT_STREAM_PROTOCOL };
|
|
55799
|
+
}
|
|
55748
55800
|
record(subject, raw, streaming, dispatchMessageId) {
|
|
55749
55801
|
const message = readMessage(raw);
|
|
55750
55802
|
if (message === null)
|
|
@@ -55793,6 +55845,8 @@ class AgentStreamPublisher {
|
|
|
55793
55845
|
const tail = [];
|
|
55794
55846
|
if (this.#settings !== undefined)
|
|
55795
55847
|
tail.push(this.#settingsFrame(this.#settings));
|
|
55848
|
+
if (this.#context !== undefined)
|
|
55849
|
+
tail.push(this.#contextFrame(this.#context));
|
|
55796
55850
|
if (this.#commands !== undefined)
|
|
55797
55851
|
tail.push(this.#commandsFrame(this.#commands));
|
|
55798
55852
|
let used = REPLAY_ARRAY_BYTES + tail.reduce((bytes, frame, index) => bytes + jsonBytes(frame) + (index === 0 ? 0 : 1), 0);
|
|
@@ -59636,7 +59690,7 @@ async function startChannelSession(options) {
|
|
|
59636
59690
|
failed: (message, topic, error, receivedAt) => {
|
|
59637
59691
|
const envelope = renderInbound(message.raw, identity.id, message.subject).envelope;
|
|
59638
59692
|
if (envelope !== undefined)
|
|
59639
|
-
replay.liveFailed(topic, envelope, error, receivedAt);
|
|
59693
|
+
replay.liveFailed(identity.id, topic, envelope, error, receivedAt);
|
|
59640
59694
|
},
|
|
59641
59695
|
deliver: async (message) => {
|
|
59642
59696
|
takeRemovals(message.raw);
|
package/dist/session-hook.js
CHANGED
|
@@ -14225,7 +14225,7 @@ function imagesArgument(z, owner) {
|
|
|
14225
14225
|
var ASK_URGENCIES = ["low", "med", "high", "blocking"];
|
|
14226
14226
|
var DISPATCH_BLOCK_UNITS = 32000;
|
|
14227
14227
|
var DISPATCH_ITEM_BLOCKS = 32768;
|
|
14228
|
-
var BODY_BLOCK_RULE = `Each block (a paragraph, list, quote, table or code block) holds at most ${DISPATCH_BLOCK_UNITS} ` + `characters and a body at most ${DISPATCH_ITEM_BLOCKS} blocks; Dispatch refuses a longer one and ` + "names it, and `dispatch limits` prints the bounds.";
|
|
14228
|
+
var BODY_BLOCK_RULE = `Each block (a paragraph, list, quote, table or code block) holds at most ${DISPATCH_BLOCK_UNITS} ` + `characters and a body at most ${DISPATCH_ITEM_BLOCKS} blocks; Dispatch refuses a longer one and ` + "names it, and `dispatch limits` prints the bounds. A body holding a decision block (`:::ask`) " + "is refused however short it is, since nobody can answer a question put in a comment or a " + "message: ask the question in the issue's own document, as a decision block there, or open an " + "ask with `dispatch ask`.";
|
|
14229
14229
|
var ASK_BOUND_RULE = "Dispatch bounds an ask's question and its options together, refuses a longer one and names " + "the bound, and `dispatch limits` prints it. An ask is short and asks one thing; its reasoning " + "goes in the document, not in the question.";
|
|
14230
14230
|
var DISPATCH_HANDOFF_BODY_MAX = 262144;
|
|
14231
14231
|
var HANDOFF_PHASE_PATTERN = /^[a-z][a-z0-9-]{0,31}$/;
|
|
@@ -81,6 +81,12 @@ carries them — `close_root` answers `CLOSE_REASON_TOO_LONG` and `handoff_compl
|
|
|
81
81
|
`READY_PACKET_TOO_LONG`, each naming the bound and how far over the text is — so this notice is a
|
|
82
82
|
refusal those checks did not predict.
|
|
83
83
|
|
|
84
|
+
Those two calls also answer `CLOSE_REASON_DECISION_BLOCK` and `READY_PACKET_DECISION_BLOCK` for a
|
|
85
|
+
text holding a decision block (`:::ask{…}`). Such a text is refused however short it is, because
|
|
86
|
+
a question put in a message is one nobody can answer where it stands. The question belongs in the
|
|
87
|
+
issue's own document, as a decision block there, or in an ask opened with `dispatch ask`; the
|
|
88
|
+
close reason or the packet then goes again with the decision stated.
|
|
89
|
+
|
|
84
90
|
On a status write the daemon writes the status all the same, retrying it on the row's backoff
|
|
85
91
|
until Dispatch takes it, so the status is set unless Dispatch refused the status itself — the
|
|
86
92
|
reason says which. With the status set, only the reason beside it is on no issue: the issue's
|
package/package.json
CHANGED
package/skills/dispatch/SKILL.md
CHANGED
|
@@ -10,13 +10,13 @@ Dispatch is a record for the people who decide, never a log of your work.
|
|
|
10
10
|
- Use the `dispatch` command; the HTTP API only for what no command does. `dispatch <command> --help` gives its rules and an example.
|
|
11
11
|
- Put long text on stdin: `--<field>-file -` with a quoted here-document (`<<'EOF'`); give object and list fields as JSON.
|
|
12
12
|
- Exit 1 is a refusal, 2 a usage error. A refusal lists every problem: fix all, call once.
|
|
13
|
-
- A
|
|
13
|
+
- A command hard to use, or storing or losing something wrongly, is a defect to report, not work around: open an issue in the owning project's code and tell its controller; a Legion role tells its architect (`skill://legion-worker/references/findings.md`).
|
|
14
14
|
|
|
15
15
|
## Asks and ask blocks
|
|
16
16
|
|
|
17
17
|
- An ask is a question for a person, never a request to another agent. Ask an agent by envoy_send or a comment on the issue.
|
|
18
18
|
- An ask waits on the issue's assignee until a person hands it on. No agent can hand one on.
|
|
19
|
-
- A design question a document records is an ask block
|
|
19
|
+
- A design question a document records is an ask block ending its section:
|
|
20
20
|
|
|
21
21
|
```md
|
|
22
22
|
:::ask{urgency="med"}
|
|
@@ -27,6 +27,7 @@ The question and the recommendation (`skill://dispatch-writing-specs`).
|
|
|
27
27
|
:::
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
+
- A decision block in a comment, message or close reason is refused: ask in the issue's document, or `dispatch ask`.
|
|
30
31
|
- Never repeat an open ask in a message.
|
|
31
32
|
- Change an open ask's block with `dispatch edit-ask` (its ask id), or `doc-edit`'s `replace` or `move` (its block id). An answered ask is fixed: ask anew. `dispatch read --ref` takes either id.
|
|
32
33
|
- Reply on an open ask with `dispatch comment --reply-to-ask`; `--turn agent` (a progress note) needs it. An approval request a newer version moved needs `request-approval` again.
|
|
@@ -28,7 +28,7 @@ dispatch search --query 'reviewer threads OR review comments'
|
|
|
28
28
|
|
|
29
29
|
## Research before you ask
|
|
30
30
|
|
|
31
|
-
- Research when a file, command or document can show the answer
|
|
31
|
+
- Research when a file, command or document can show the answer.
|
|
32
32
|
- Ask a person only for what their authority, taste or risk appetite settles, because no file holds that. Where a file records the decision, cite it (`file:line`) and follow it; ask again only when the facts it rested on changed.
|
|
33
33
|
- Say what you searched: each part you found with its source, and each part you did not, with the queries you ran. Ask only the part no search answered.
|
|
34
34
|
|
|
@@ -1087,9 +1087,11 @@ export async function startChannelSession(options: ChannelSessionOptions): Promi
|
|
|
1087
1087
|
// A frame no sweep will show again gets its notice at once: a role forward, already
|
|
1088
1088
|
// acknowledged, one on a subscription the replay does not read (refused, not started, or
|
|
1089
1089
|
// the listener's replay failing), or one received before its subject's cursor started.
|
|
1090
|
-
// The stream's copy of any other waits for a sweep.
|
|
1090
|
+
// The stream's copy of any other waits for a sweep. The notice is asked for this
|
|
1091
|
+
// process's one session by name, read when the failure lands.
|
|
1091
1092
|
const envelope = renderInbound(message.raw, identity.id, message.subject).envelope
|
|
1092
|
-
if (envelope !== undefined)
|
|
1093
|
+
if (envelope !== undefined)
|
|
1094
|
+
void replay.liveFailed(identity.id, topic, envelope, error, receivedAt)
|
|
1093
1095
|
},
|
|
1094
1096
|
deliver: async (message) => {
|
|
1095
1097
|
takeRemovals(message.raw)
|