@sjawhar/claude-envoy 2.36.0 → 2.37.0
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/README.md +2 -1
- package/dist/dispatch.js +96 -5
- package/dist/envoy-channel.js +108 -14
- package/dist/session-hook.js +94 -4
- package/package.json +1 -1
- package/scripts/smoke-session-title.sh +11 -2
- package/skills/agent-secrets/SKILL.md +6 -4
- package/src/envoy-channel-server.ts +3 -3
- package/src/subscription-topics.ts +2 -2
package/.omp-plugin/plugin.json
CHANGED
package/README.md
CHANGED
|
@@ -538,7 +538,8 @@ in the session's Dispatch state directory carries the same name. Its negative co
|
|
|
538
538
|
first case again against the committed `dist/envoy-channel.js` of `BASE_REV` (default
|
|
539
539
|
`0306bcbe16df-`, the last revision without the fallback), which registers the folder name instead.
|
|
540
540
|
It needs `bun`, `curl`, `jq`, `go` and `nats-server`
|
|
541
|
-
(`go install github.com/nats-io/nats-server/v2@v2.
|
|
541
|
+
(`go install github.com/nats-io/nats-server/v2@v2.15.1`, the hub's version: the listener refuses a
|
|
542
|
+
nats-server below v2.11.12, v2.12.4 or v2.14.0), and no Claude authentication: the two
|
|
542
543
|
hook payloads are written by the script, and that the field arrives at all rests on Claude Code's
|
|
543
544
|
documentation. Claude Code is not installed in an issue pod's image, though it runs there from
|
|
544
545
|
`bunx --package @anthropic-ai/claude-code@<version> claude`, as
|
package/dist/dispatch.js
CHANGED
|
@@ -14696,17 +14696,18 @@ function isPictureType(mime) {
|
|
|
14696
14696
|
// ../contracts/src/subject.ts
|
|
14697
14697
|
var AGENT_TOPIC_PREFIX = "notifications.agent.";
|
|
14698
14698
|
var ROLE_TOPIC_PREFIX = "notifications.role.";
|
|
14699
|
+
var NO_PROJECT = "_";
|
|
14699
14700
|
var LEGION_NOTICE_TOPIC_PREFIX = "notifications.legion.";
|
|
14700
14701
|
var DISPATCH_TOPIC_PREFIX = "notifications.dispatch.";
|
|
14701
14702
|
var DISPATCH_ISSUE_TOPIC_PREFIX = `${DISPATCH_TOPIC_PREFIX}issue.`;
|
|
14702
14703
|
var DISPATCH_DOCUMENT_TOPIC_PREFIX = `${DISPATCH_TOPIC_PREFIX}document.`;
|
|
14703
|
-
function
|
|
14704
|
+
function legacyDispatchIssueSubject(issueKey, type) {
|
|
14704
14705
|
return `${DISPATCH_ISSUE_TOPIC_PREFIX}${issueKey}.${type}`;
|
|
14705
14706
|
}
|
|
14706
14707
|
function dispatchDocumentSubject(project, slug, type) {
|
|
14707
14708
|
return `${DISPATCH_DOCUMENT_TOPIC_PREFIX}${project}.${slug}.${type}`;
|
|
14708
14709
|
}
|
|
14709
|
-
function
|
|
14710
|
+
function legacyAgentSubject(session) {
|
|
14710
14711
|
return `${AGENT_TOPIC_PREFIX}${session}`;
|
|
14711
14712
|
}
|
|
14712
14713
|
var GHOSTWISPR_TOPIC_PREFIX = "notifications.ghostwispr.";
|
|
@@ -17819,6 +17820,95 @@ function canonicalRepo(owner, repo) {
|
|
|
17819
17820
|
}
|
|
17820
17821
|
// ../contracts/src/slack.ts
|
|
17821
17822
|
var SLACK_POST_TEXT_MAX = 4000;
|
|
17823
|
+
// ../contracts/src/subject-project.ts
|
|
17824
|
+
var EXCEPTION_PREFIX = "notifications.envoy.exceptions.";
|
|
17825
|
+
var KEPT_PREFIX = "notifications.envoy.kept.";
|
|
17826
|
+
function isLiteral(token) {
|
|
17827
|
+
return token !== undefined && token !== "" && token !== "*" && token !== ">";
|
|
17828
|
+
}
|
|
17829
|
+
function projectOfToken(token) {
|
|
17830
|
+
return token !== undefined && PROJECT_KEY_PATTERN.test(token) ? token : NO_PROJECT;
|
|
17831
|
+
}
|
|
17832
|
+
function issueProject(key) {
|
|
17833
|
+
const project = DISPATCH_KEY_PATTERN.exec(key)?.[1];
|
|
17834
|
+
return project !== undefined && PROJECT_KEY_PATTERN.test(project) ? project : undefined;
|
|
17835
|
+
}
|
|
17836
|
+
var LEGION_ROLE_TOKEN = /^legion-([a-z0-9]+)-[\s\S]/;
|
|
17837
|
+
function legionTokenProject(token) {
|
|
17838
|
+
return token !== undefined && isLegionProjectToken(token) ? projectOfToken(token.toUpperCase()) : NO_PROJECT;
|
|
17839
|
+
}
|
|
17840
|
+
function roleProject(role) {
|
|
17841
|
+
return legionTokenProject(LEGION_ROLE_TOKEN.exec(role)?.[1]);
|
|
17842
|
+
}
|
|
17843
|
+
function keptLane(topic) {
|
|
17844
|
+
if (!topic.startsWith(KEPT_PREFIX))
|
|
17845
|
+
return;
|
|
17846
|
+
const [kind, ...rest] = topic.slice(KEPT_PREFIX.length).split(".");
|
|
17847
|
+
return kind === "role" || kind === "cursor" ? { kind, rest } : undefined;
|
|
17848
|
+
}
|
|
17849
|
+
function canonicalTopic(topic) {
|
|
17850
|
+
const unchanged = { canonical: topic, legacy: false };
|
|
17851
|
+
if (topic.startsWith(DISPATCH_ISSUE_TOPIC_PREFIX)) {
|
|
17852
|
+
const rest = topic.slice(DISPATCH_ISSUE_TOPIC_PREFIX.length);
|
|
17853
|
+
const project = issueProject(rest.split(".")[0] ?? "");
|
|
17854
|
+
return project === undefined ? unchanged : { canonical: `${DISPATCH_ISSUE_TOPIC_PREFIX}${project}.${rest}`, legacy: true };
|
|
17855
|
+
}
|
|
17856
|
+
if (topic.startsWith(AGENT_TOPIC_PREFIX)) {
|
|
17857
|
+
const rest = topic.slice(AGENT_TOPIC_PREFIX.length).split(".");
|
|
17858
|
+
return rest.length === 1 && isLiteral(rest[0]) ? { canonical: `${AGENT_TOPIC_PREFIX}*.${rest[0]}`, legacy: true } : unchanged;
|
|
17859
|
+
}
|
|
17860
|
+
if (topic.startsWith(ROLE_TOPIC_PREFIX)) {
|
|
17861
|
+
const rest = topic.slice(ROLE_TOPIC_PREFIX.length).split(".");
|
|
17862
|
+
return rest.length === 1 && isLiteral(rest[0]) ? { canonical: `${ROLE_TOPIC_PREFIX}${roleProject(rest[0])}.${rest[0]}`, legacy: true } : unchanged;
|
|
17863
|
+
}
|
|
17864
|
+
if (topic.startsWith(EXCEPTION_PREFIX)) {
|
|
17865
|
+
const wrapped = canonicalTopic(topic.slice(EXCEPTION_PREFIX.length));
|
|
17866
|
+
return wrapped.legacy ? { canonical: `${EXCEPTION_PREFIX}${wrapped.canonical}`, legacy: true } : unchanged;
|
|
17867
|
+
}
|
|
17868
|
+
const kept = keptLane(topic);
|
|
17869
|
+
if (kept !== undefined && kept.rest.length === 1 && isLiteral(kept.rest[0])) {
|
|
17870
|
+
const role = kept.rest[0];
|
|
17871
|
+
return { canonical: `${KEPT_PREFIX}${kept.kind}.${roleProject(role)}.${role}`, legacy: true };
|
|
17872
|
+
}
|
|
17873
|
+
return unchanged;
|
|
17874
|
+
}
|
|
17875
|
+
function isProjectPosition(token) {
|
|
17876
|
+
return token !== undefined && (PROJECT_KEY_PATTERN.test(token) || token === NO_PROJECT || token === "*");
|
|
17877
|
+
}
|
|
17878
|
+
function legacyTwin(canonical) {
|
|
17879
|
+
if (canonical.startsWith(DISPATCH_ISSUE_TOPIC_PREFIX)) {
|
|
17880
|
+
const [project, key, ...rest] = canonical.slice(DISPATCH_ISSUE_TOPIC_PREFIX.length).split(".");
|
|
17881
|
+
if (key === undefined || project === undefined)
|
|
17882
|
+
return;
|
|
17883
|
+
const keyProject = issueProject(key);
|
|
17884
|
+
if (keyProject === undefined || project !== keyProject)
|
|
17885
|
+
return;
|
|
17886
|
+
return [`${DISPATCH_ISSUE_TOPIC_PREFIX}${key}`, ...rest].join(".");
|
|
17887
|
+
}
|
|
17888
|
+
for (const prefix of [AGENT_TOPIC_PREFIX, ROLE_TOPIC_PREFIX]) {
|
|
17889
|
+
if (canonical.startsWith(prefix)) {
|
|
17890
|
+
const rest = canonical.slice(prefix.length).split(".");
|
|
17891
|
+
return rest.length === 2 && isProjectPosition(rest[0]) && isLiteral(rest[1]) ? `${prefix}${rest[1]}` : undefined;
|
|
17892
|
+
}
|
|
17893
|
+
}
|
|
17894
|
+
if (canonical.startsWith(EXCEPTION_PREFIX)) {
|
|
17895
|
+
const twin = legacyTwin(canonical.slice(EXCEPTION_PREFIX.length));
|
|
17896
|
+
return twin === undefined ? undefined : `${EXCEPTION_PREFIX}${twin}`;
|
|
17897
|
+
}
|
|
17898
|
+
const kept = keptLane(canonical);
|
|
17899
|
+
if (kept !== undefined && kept.rest.length === 2 && isProjectPosition(kept.rest[0])) {
|
|
17900
|
+
const role = kept.rest[1];
|
|
17901
|
+
return isLiteral(role) ? `${KEPT_PREFIX}${kept.kind}.${role}` : undefined;
|
|
17902
|
+
}
|
|
17903
|
+
return;
|
|
17904
|
+
}
|
|
17905
|
+
function topicForms(topic) {
|
|
17906
|
+
const { canonical, legacy } = canonicalTopic(topic);
|
|
17907
|
+
if (legacy)
|
|
17908
|
+
return [topic, canonical];
|
|
17909
|
+
const twin = legacyTwin(topic);
|
|
17910
|
+
return twin === undefined ? [topic] : [topic, twin];
|
|
17911
|
+
}
|
|
17822
17912
|
// ../contracts/src/tool-schema.ts
|
|
17823
17913
|
function overCapMessage(length, max) {
|
|
17824
17914
|
return `is ${length - max} characters over the ${max}-character limit (${length}/${max})`;
|
|
@@ -19671,7 +19761,7 @@ function ownerTitle(owner) {
|
|
|
19671
19761
|
return "";
|
|
19672
19762
|
}
|
|
19673
19763
|
function issueTopic(key) {
|
|
19674
|
-
return { label: key, topic:
|
|
19764
|
+
return { label: key, topic: legacyDispatchIssueSubject(key, ">") };
|
|
19675
19765
|
}
|
|
19676
19766
|
function documentTopicOf(project, slug) {
|
|
19677
19767
|
return {
|
|
@@ -21111,7 +21201,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
21111
21201
|
...dispatchIssue === undefined ? [] : [dispatchIssue]
|
|
21112
21202
|
].join(", ") || undefined;
|
|
21113
21203
|
const rendered = {
|
|
21114
|
-
...envelope.topic
|
|
21204
|
+
...envelope.topic !== undefined && topicForms(envelope.topic).includes(legacyAgentSubject(sessionID)) ? { to: `you (${sessionID})` } : {},
|
|
21115
21205
|
from: senderLabel(envelope),
|
|
21116
21206
|
at: inboundTimestamp(envelope.issued_at),
|
|
21117
21207
|
id: envelope.event_id ?? "unknown",
|
|
@@ -30484,7 +30574,8 @@ function reachesPrivateStreamSubject(ownAgentSubject, topic, roles = []) {
|
|
|
30484
30574
|
const role = controllerNoticeRole(topic);
|
|
30485
30575
|
if (role !== undefined)
|
|
30486
30576
|
return !roles.includes(role);
|
|
30487
|
-
|
|
30577
|
+
const own = topic === ownAgentSubject || legacyTwin(topic) === ownAgentSubject;
|
|
30578
|
+
return !own || /[*>]/.test(ownAgentSubject);
|
|
30488
30579
|
}
|
|
30489
30580
|
function registrationTopics(ownAgentSubject, followed, roles = []) {
|
|
30490
30581
|
return [
|
package/dist/envoy-channel.js
CHANGED
|
@@ -36286,17 +36286,18 @@ function isPictureType(mime) {
|
|
|
36286
36286
|
// ../contracts/src/subject.ts
|
|
36287
36287
|
var AGENT_TOPIC_PREFIX = "notifications.agent.";
|
|
36288
36288
|
var ROLE_TOPIC_PREFIX = "notifications.role.";
|
|
36289
|
+
var NO_PROJECT = "_";
|
|
36289
36290
|
var LEGION_NOTICE_TOPIC_PREFIX = "notifications.legion.";
|
|
36290
36291
|
var DISPATCH_TOPIC_PREFIX = "notifications.dispatch.";
|
|
36291
36292
|
var DISPATCH_ISSUE_TOPIC_PREFIX = `${DISPATCH_TOPIC_PREFIX}issue.`;
|
|
36292
36293
|
var DISPATCH_DOCUMENT_TOPIC_PREFIX = `${DISPATCH_TOPIC_PREFIX}document.`;
|
|
36293
|
-
function
|
|
36294
|
+
function legacyDispatchIssueSubject(issueKey, type) {
|
|
36294
36295
|
return `${DISPATCH_ISSUE_TOPIC_PREFIX}${issueKey}.${type}`;
|
|
36295
36296
|
}
|
|
36296
36297
|
function dispatchDocumentSubject(project, slug, type) {
|
|
36297
36298
|
return `${DISPATCH_DOCUMENT_TOPIC_PREFIX}${project}.${slug}.${type}`;
|
|
36298
36299
|
}
|
|
36299
|
-
function
|
|
36300
|
+
function legacyAgentSubject(session) {
|
|
36300
36301
|
return `${AGENT_TOPIC_PREFIX}${session}`;
|
|
36301
36302
|
}
|
|
36302
36303
|
var GHOSTWISPR_TOPIC_PREFIX = "notifications.ghostwispr.";
|
|
@@ -39409,6 +39410,95 @@ function canonicalRepo(owner, repo) {
|
|
|
39409
39410
|
}
|
|
39410
39411
|
// ../contracts/src/slack.ts
|
|
39411
39412
|
var SLACK_POST_TEXT_MAX = 4000;
|
|
39413
|
+
// ../contracts/src/subject-project.ts
|
|
39414
|
+
var EXCEPTION_PREFIX = "notifications.envoy.exceptions.";
|
|
39415
|
+
var KEPT_PREFIX = "notifications.envoy.kept.";
|
|
39416
|
+
function isLiteral(token) {
|
|
39417
|
+
return token !== undefined && token !== "" && token !== "*" && token !== ">";
|
|
39418
|
+
}
|
|
39419
|
+
function projectOfToken(token) {
|
|
39420
|
+
return token !== undefined && PROJECT_KEY_PATTERN.test(token) ? token : NO_PROJECT;
|
|
39421
|
+
}
|
|
39422
|
+
function issueProject(key) {
|
|
39423
|
+
const project = DISPATCH_KEY_PATTERN.exec(key)?.[1];
|
|
39424
|
+
return project !== undefined && PROJECT_KEY_PATTERN.test(project) ? project : undefined;
|
|
39425
|
+
}
|
|
39426
|
+
var LEGION_ROLE_TOKEN = /^legion-([a-z0-9]+)-[\s\S]/;
|
|
39427
|
+
function legionTokenProject(token) {
|
|
39428
|
+
return token !== undefined && isLegionProjectToken(token) ? projectOfToken(token.toUpperCase()) : NO_PROJECT;
|
|
39429
|
+
}
|
|
39430
|
+
function roleProject(role) {
|
|
39431
|
+
return legionTokenProject(LEGION_ROLE_TOKEN.exec(role)?.[1]);
|
|
39432
|
+
}
|
|
39433
|
+
function keptLane(topic) {
|
|
39434
|
+
if (!topic.startsWith(KEPT_PREFIX))
|
|
39435
|
+
return;
|
|
39436
|
+
const [kind, ...rest] = topic.slice(KEPT_PREFIX.length).split(".");
|
|
39437
|
+
return kind === "role" || kind === "cursor" ? { kind, rest } : undefined;
|
|
39438
|
+
}
|
|
39439
|
+
function canonicalTopic(topic) {
|
|
39440
|
+
const unchanged = { canonical: topic, legacy: false };
|
|
39441
|
+
if (topic.startsWith(DISPATCH_ISSUE_TOPIC_PREFIX)) {
|
|
39442
|
+
const rest = topic.slice(DISPATCH_ISSUE_TOPIC_PREFIX.length);
|
|
39443
|
+
const project = issueProject(rest.split(".")[0] ?? "");
|
|
39444
|
+
return project === undefined ? unchanged : { canonical: `${DISPATCH_ISSUE_TOPIC_PREFIX}${project}.${rest}`, legacy: true };
|
|
39445
|
+
}
|
|
39446
|
+
if (topic.startsWith(AGENT_TOPIC_PREFIX)) {
|
|
39447
|
+
const rest = topic.slice(AGENT_TOPIC_PREFIX.length).split(".");
|
|
39448
|
+
return rest.length === 1 && isLiteral(rest[0]) ? { canonical: `${AGENT_TOPIC_PREFIX}*.${rest[0]}`, legacy: true } : unchanged;
|
|
39449
|
+
}
|
|
39450
|
+
if (topic.startsWith(ROLE_TOPIC_PREFIX)) {
|
|
39451
|
+
const rest = topic.slice(ROLE_TOPIC_PREFIX.length).split(".");
|
|
39452
|
+
return rest.length === 1 && isLiteral(rest[0]) ? { canonical: `${ROLE_TOPIC_PREFIX}${roleProject(rest[0])}.${rest[0]}`, legacy: true } : unchanged;
|
|
39453
|
+
}
|
|
39454
|
+
if (topic.startsWith(EXCEPTION_PREFIX)) {
|
|
39455
|
+
const wrapped = canonicalTopic(topic.slice(EXCEPTION_PREFIX.length));
|
|
39456
|
+
return wrapped.legacy ? { canonical: `${EXCEPTION_PREFIX}${wrapped.canonical}`, legacy: true } : unchanged;
|
|
39457
|
+
}
|
|
39458
|
+
const kept = keptLane(topic);
|
|
39459
|
+
if (kept !== undefined && kept.rest.length === 1 && isLiteral(kept.rest[0])) {
|
|
39460
|
+
const role = kept.rest[0];
|
|
39461
|
+
return { canonical: `${KEPT_PREFIX}${kept.kind}.${roleProject(role)}.${role}`, legacy: true };
|
|
39462
|
+
}
|
|
39463
|
+
return unchanged;
|
|
39464
|
+
}
|
|
39465
|
+
function isProjectPosition(token) {
|
|
39466
|
+
return token !== undefined && (PROJECT_KEY_PATTERN.test(token) || token === NO_PROJECT || token === "*");
|
|
39467
|
+
}
|
|
39468
|
+
function legacyTwin(canonical) {
|
|
39469
|
+
if (canonical.startsWith(DISPATCH_ISSUE_TOPIC_PREFIX)) {
|
|
39470
|
+
const [project, key, ...rest] = canonical.slice(DISPATCH_ISSUE_TOPIC_PREFIX.length).split(".");
|
|
39471
|
+
if (key === undefined || project === undefined)
|
|
39472
|
+
return;
|
|
39473
|
+
const keyProject = issueProject(key);
|
|
39474
|
+
if (keyProject === undefined || project !== keyProject)
|
|
39475
|
+
return;
|
|
39476
|
+
return [`${DISPATCH_ISSUE_TOPIC_PREFIX}${key}`, ...rest].join(".");
|
|
39477
|
+
}
|
|
39478
|
+
for (const prefix of [AGENT_TOPIC_PREFIX, ROLE_TOPIC_PREFIX]) {
|
|
39479
|
+
if (canonical.startsWith(prefix)) {
|
|
39480
|
+
const rest = canonical.slice(prefix.length).split(".");
|
|
39481
|
+
return rest.length === 2 && isProjectPosition(rest[0]) && isLiteral(rest[1]) ? `${prefix}${rest[1]}` : undefined;
|
|
39482
|
+
}
|
|
39483
|
+
}
|
|
39484
|
+
if (canonical.startsWith(EXCEPTION_PREFIX)) {
|
|
39485
|
+
const twin = legacyTwin(canonical.slice(EXCEPTION_PREFIX.length));
|
|
39486
|
+
return twin === undefined ? undefined : `${EXCEPTION_PREFIX}${twin}`;
|
|
39487
|
+
}
|
|
39488
|
+
const kept = keptLane(canonical);
|
|
39489
|
+
if (kept !== undefined && kept.rest.length === 2 && isProjectPosition(kept.rest[0])) {
|
|
39490
|
+
const role = kept.rest[1];
|
|
39491
|
+
return isLiteral(role) ? `${KEPT_PREFIX}${kept.kind}.${role}` : undefined;
|
|
39492
|
+
}
|
|
39493
|
+
return;
|
|
39494
|
+
}
|
|
39495
|
+
function topicForms(topic) {
|
|
39496
|
+
const { canonical, legacy } = canonicalTopic(topic);
|
|
39497
|
+
if (legacy)
|
|
39498
|
+
return [topic, canonical];
|
|
39499
|
+
const twin = legacyTwin(topic);
|
|
39500
|
+
return twin === undefined ? [topic] : [topic, twin];
|
|
39501
|
+
}
|
|
39412
39502
|
// ../contracts/src/tool-schema.ts
|
|
39413
39503
|
function overCapMessage(length, max) {
|
|
39414
39504
|
return `is ${length - max} characters over the ${max}-character limit (${length}/${max})`;
|
|
@@ -44926,7 +45016,7 @@ function ownerTitle(owner) {
|
|
|
44926
45016
|
return "";
|
|
44927
45017
|
}
|
|
44928
45018
|
function issueTopic(key) {
|
|
44929
|
-
return { label: key, topic:
|
|
45019
|
+
return { label: key, topic: legacyDispatchIssueSubject(key, ">") };
|
|
44930
45020
|
}
|
|
44931
45021
|
function documentTopicOf(project, slug) {
|
|
44932
45022
|
return {
|
|
@@ -45840,7 +45930,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
45840
45930
|
...dispatchIssue === undefined ? [] : [dispatchIssue]
|
|
45841
45931
|
].join(", ") || undefined;
|
|
45842
45932
|
const rendered = {
|
|
45843
|
-
...envelope.topic
|
|
45933
|
+
...envelope.topic !== undefined && topicForms(envelope.topic).includes(legacyAgentSubject(sessionID)) ? { to: `you (${sessionID})` } : {},
|
|
45844
45934
|
from: senderLabel(envelope),
|
|
45845
45935
|
at: inboundTimestamp(envelope.issued_at),
|
|
45846
45936
|
id: envelope.event_id ?? "unknown",
|
|
@@ -46267,7 +46357,8 @@ function reachesPrivateStreamSubject(ownAgentSubject, topic, roles = []) {
|
|
|
46267
46357
|
const role = controllerNoticeRole(topic);
|
|
46268
46358
|
if (role !== undefined)
|
|
46269
46359
|
return !roles.includes(role);
|
|
46270
|
-
|
|
46360
|
+
const own = topic === ownAgentSubject || legacyTwin(topic) === ownAgentSubject;
|
|
46361
|
+
return !own || /[*>]/.test(ownAgentSubject);
|
|
46271
46362
|
}
|
|
46272
46363
|
function registrationTopics(ownAgentSubject, followed, roles = []) {
|
|
46273
46364
|
return [
|
|
@@ -46836,8 +46927,9 @@ function parseIdentity(data) {
|
|
|
46836
46927
|
const { event_id, dedupe_key } = identity.data;
|
|
46837
46928
|
return event_id === undefined && dedupe_key === undefined ? undefined : identity.data;
|
|
46838
46929
|
}
|
|
46839
|
-
function reaches(topic,
|
|
46840
|
-
|
|
46930
|
+
function reaches(topic, forms) {
|
|
46931
|
+
const patterns = topicForms(topic).flatMap((form) => expandSubscriptionTopics([form]));
|
|
46932
|
+
return forms.some((form) => patterns.some((pattern) => subjectsOverlap(pattern, form)));
|
|
46841
46933
|
}
|
|
46842
46934
|
function every(ms, callback) {
|
|
46843
46935
|
const timer = setInterval(callback, ms);
|
|
@@ -46848,7 +46940,8 @@ function createConsumerDelivery(options) {
|
|
|
46848
46940
|
const render = options.render ?? renderInbound;
|
|
46849
46941
|
const now = options.now ?? Date.now;
|
|
46850
46942
|
const repeat = options.every ?? every;
|
|
46851
|
-
const ownSubject =
|
|
46943
|
+
const ownSubject = legacyAgentSubject(sessionID);
|
|
46944
|
+
const ownsSubject = (subject) => topicForms(subject).includes(ownSubject);
|
|
46852
46945
|
let currentEpoch = { id: newEpoch(), startedAt: now() };
|
|
46853
46946
|
let follows = new Map;
|
|
46854
46947
|
let streamID;
|
|
@@ -46891,11 +46984,12 @@ function createConsumerDelivery(options) {
|
|
|
46891
46984
|
tellGap("stream_recreated");
|
|
46892
46985
|
};
|
|
46893
46986
|
const followedAt = (subject) => {
|
|
46894
|
-
if (subject
|
|
46987
|
+
if (ownsSubject(subject))
|
|
46895
46988
|
return Number.NEGATIVE_INFINITY;
|
|
46989
|
+
const forms = topicForms(subject);
|
|
46896
46990
|
let earliest;
|
|
46897
46991
|
for (const [topic, at] of follows) {
|
|
46898
|
-
if (!reaches(topic,
|
|
46992
|
+
if (!reaches(topic, forms))
|
|
46899
46993
|
continue;
|
|
46900
46994
|
if (earliest === undefined || at < earliest)
|
|
46901
46995
|
earliest = at;
|
|
@@ -47150,7 +47244,7 @@ function createConsumerDelivery(options) {
|
|
|
47150
47244
|
const at = now();
|
|
47151
47245
|
const next = new Map;
|
|
47152
47246
|
for (const topic of topics) {
|
|
47153
|
-
if (topic
|
|
47247
|
+
if (ownsSubject(topic))
|
|
47154
47248
|
continue;
|
|
47155
47249
|
next.set(topic, follows.get(topic) ?? at);
|
|
47156
47250
|
}
|
|
@@ -57626,7 +57720,7 @@ var import_nats2 = __toESM(require_mod4(), 1);
|
|
|
57626
57720
|
|
|
57627
57721
|
// package.json
|
|
57628
57722
|
var name = "@sjawhar/claude-envoy";
|
|
57629
|
-
var version2 = "2.
|
|
57723
|
+
var version2 = "2.37.0";
|
|
57630
57724
|
var legion = {
|
|
57631
57725
|
daemonApiVersion: 146
|
|
57632
57726
|
};
|
|
@@ -61515,7 +61609,7 @@ function createChannelDelivery(input) {
|
|
|
61515
61609
|
}
|
|
61516
61610
|
async function startChannelSession(options) {
|
|
61517
61611
|
const { identity } = options;
|
|
61518
|
-
let directSubject =
|
|
61612
|
+
let directSubject = legacyAgentSubject(identity.id);
|
|
61519
61613
|
let router;
|
|
61520
61614
|
let turns;
|
|
61521
61615
|
const delivery = createChannelDelivery({
|
|
@@ -61919,7 +62013,7 @@ async function startChannelSession(options) {
|
|
|
61919
62013
|
return;
|
|
61920
62014
|
const previous = identity.id;
|
|
61921
62015
|
const previousSubject = directSubject;
|
|
61922
|
-
const nextSubject =
|
|
62016
|
+
const nextSubject = legacyAgentSubject(next);
|
|
61923
62017
|
followedTopics.follow(nextSubject);
|
|
61924
62018
|
try {
|
|
61925
62019
|
await withTimeout(options.connection.flush(), options.handoffFlushTimeoutMs ?? HANDOFF_FLUSH_TIMEOUT_MS, "flushing NATS");
|
package/dist/session-hook.js
CHANGED
|
@@ -13633,17 +13633,18 @@ function isPictureType(mime) {
|
|
|
13633
13633
|
// ../contracts/src/subject.ts
|
|
13634
13634
|
var AGENT_TOPIC_PREFIX = "notifications.agent.";
|
|
13635
13635
|
var ROLE_TOPIC_PREFIX = "notifications.role.";
|
|
13636
|
+
var NO_PROJECT = "_";
|
|
13636
13637
|
var LEGION_NOTICE_TOPIC_PREFIX = "notifications.legion.";
|
|
13637
13638
|
var DISPATCH_TOPIC_PREFIX = "notifications.dispatch.";
|
|
13638
13639
|
var DISPATCH_ISSUE_TOPIC_PREFIX = `${DISPATCH_TOPIC_PREFIX}issue.`;
|
|
13639
13640
|
var DISPATCH_DOCUMENT_TOPIC_PREFIX = `${DISPATCH_TOPIC_PREFIX}document.`;
|
|
13640
|
-
function
|
|
13641
|
+
function legacyDispatchIssueSubject(issueKey, type) {
|
|
13641
13642
|
return `${DISPATCH_ISSUE_TOPIC_PREFIX}${issueKey}.${type}`;
|
|
13642
13643
|
}
|
|
13643
13644
|
function dispatchDocumentSubject(project, slug, type) {
|
|
13644
13645
|
return `${DISPATCH_DOCUMENT_TOPIC_PREFIX}${project}.${slug}.${type}`;
|
|
13645
13646
|
}
|
|
13646
|
-
function
|
|
13647
|
+
function legacyAgentSubject(session) {
|
|
13647
13648
|
return `${AGENT_TOPIC_PREFIX}${session}`;
|
|
13648
13649
|
}
|
|
13649
13650
|
var GHOSTWISPR_TOPIC_PREFIX = "notifications.ghostwispr.";
|
|
@@ -16756,6 +16757,95 @@ function canonicalRepo(owner, repo) {
|
|
|
16756
16757
|
}
|
|
16757
16758
|
// ../contracts/src/slack.ts
|
|
16758
16759
|
var SLACK_POST_TEXT_MAX = 4000;
|
|
16760
|
+
// ../contracts/src/subject-project.ts
|
|
16761
|
+
var EXCEPTION_PREFIX = "notifications.envoy.exceptions.";
|
|
16762
|
+
var KEPT_PREFIX = "notifications.envoy.kept.";
|
|
16763
|
+
function isLiteral(token) {
|
|
16764
|
+
return token !== undefined && token !== "" && token !== "*" && token !== ">";
|
|
16765
|
+
}
|
|
16766
|
+
function projectOfToken(token) {
|
|
16767
|
+
return token !== undefined && PROJECT_KEY_PATTERN.test(token) ? token : NO_PROJECT;
|
|
16768
|
+
}
|
|
16769
|
+
function issueProject(key) {
|
|
16770
|
+
const project = DISPATCH_KEY_PATTERN.exec(key)?.[1];
|
|
16771
|
+
return project !== undefined && PROJECT_KEY_PATTERN.test(project) ? project : undefined;
|
|
16772
|
+
}
|
|
16773
|
+
var LEGION_ROLE_TOKEN = /^legion-([a-z0-9]+)-[\s\S]/;
|
|
16774
|
+
function legionTokenProject(token) {
|
|
16775
|
+
return token !== undefined && isLegionProjectToken(token) ? projectOfToken(token.toUpperCase()) : NO_PROJECT;
|
|
16776
|
+
}
|
|
16777
|
+
function roleProject(role) {
|
|
16778
|
+
return legionTokenProject(LEGION_ROLE_TOKEN.exec(role)?.[1]);
|
|
16779
|
+
}
|
|
16780
|
+
function keptLane(topic) {
|
|
16781
|
+
if (!topic.startsWith(KEPT_PREFIX))
|
|
16782
|
+
return;
|
|
16783
|
+
const [kind, ...rest] = topic.slice(KEPT_PREFIX.length).split(".");
|
|
16784
|
+
return kind === "role" || kind === "cursor" ? { kind, rest } : undefined;
|
|
16785
|
+
}
|
|
16786
|
+
function canonicalTopic(topic) {
|
|
16787
|
+
const unchanged = { canonical: topic, legacy: false };
|
|
16788
|
+
if (topic.startsWith(DISPATCH_ISSUE_TOPIC_PREFIX)) {
|
|
16789
|
+
const rest = topic.slice(DISPATCH_ISSUE_TOPIC_PREFIX.length);
|
|
16790
|
+
const project = issueProject(rest.split(".")[0] ?? "");
|
|
16791
|
+
return project === undefined ? unchanged : { canonical: `${DISPATCH_ISSUE_TOPIC_PREFIX}${project}.${rest}`, legacy: true };
|
|
16792
|
+
}
|
|
16793
|
+
if (topic.startsWith(AGENT_TOPIC_PREFIX)) {
|
|
16794
|
+
const rest = topic.slice(AGENT_TOPIC_PREFIX.length).split(".");
|
|
16795
|
+
return rest.length === 1 && isLiteral(rest[0]) ? { canonical: `${AGENT_TOPIC_PREFIX}*.${rest[0]}`, legacy: true } : unchanged;
|
|
16796
|
+
}
|
|
16797
|
+
if (topic.startsWith(ROLE_TOPIC_PREFIX)) {
|
|
16798
|
+
const rest = topic.slice(ROLE_TOPIC_PREFIX.length).split(".");
|
|
16799
|
+
return rest.length === 1 && isLiteral(rest[0]) ? { canonical: `${ROLE_TOPIC_PREFIX}${roleProject(rest[0])}.${rest[0]}`, legacy: true } : unchanged;
|
|
16800
|
+
}
|
|
16801
|
+
if (topic.startsWith(EXCEPTION_PREFIX)) {
|
|
16802
|
+
const wrapped = canonicalTopic(topic.slice(EXCEPTION_PREFIX.length));
|
|
16803
|
+
return wrapped.legacy ? { canonical: `${EXCEPTION_PREFIX}${wrapped.canonical}`, legacy: true } : unchanged;
|
|
16804
|
+
}
|
|
16805
|
+
const kept = keptLane(topic);
|
|
16806
|
+
if (kept !== undefined && kept.rest.length === 1 && isLiteral(kept.rest[0])) {
|
|
16807
|
+
const role = kept.rest[0];
|
|
16808
|
+
return { canonical: `${KEPT_PREFIX}${kept.kind}.${roleProject(role)}.${role}`, legacy: true };
|
|
16809
|
+
}
|
|
16810
|
+
return unchanged;
|
|
16811
|
+
}
|
|
16812
|
+
function isProjectPosition(token) {
|
|
16813
|
+
return token !== undefined && (PROJECT_KEY_PATTERN.test(token) || token === NO_PROJECT || token === "*");
|
|
16814
|
+
}
|
|
16815
|
+
function legacyTwin(canonical) {
|
|
16816
|
+
if (canonical.startsWith(DISPATCH_ISSUE_TOPIC_PREFIX)) {
|
|
16817
|
+
const [project, key, ...rest] = canonical.slice(DISPATCH_ISSUE_TOPIC_PREFIX.length).split(".");
|
|
16818
|
+
if (key === undefined || project === undefined)
|
|
16819
|
+
return;
|
|
16820
|
+
const keyProject = issueProject(key);
|
|
16821
|
+
if (keyProject === undefined || project !== keyProject)
|
|
16822
|
+
return;
|
|
16823
|
+
return [`${DISPATCH_ISSUE_TOPIC_PREFIX}${key}`, ...rest].join(".");
|
|
16824
|
+
}
|
|
16825
|
+
for (const prefix of [AGENT_TOPIC_PREFIX, ROLE_TOPIC_PREFIX]) {
|
|
16826
|
+
if (canonical.startsWith(prefix)) {
|
|
16827
|
+
const rest = canonical.slice(prefix.length).split(".");
|
|
16828
|
+
return rest.length === 2 && isProjectPosition(rest[0]) && isLiteral(rest[1]) ? `${prefix}${rest[1]}` : undefined;
|
|
16829
|
+
}
|
|
16830
|
+
}
|
|
16831
|
+
if (canonical.startsWith(EXCEPTION_PREFIX)) {
|
|
16832
|
+
const twin = legacyTwin(canonical.slice(EXCEPTION_PREFIX.length));
|
|
16833
|
+
return twin === undefined ? undefined : `${EXCEPTION_PREFIX}${twin}`;
|
|
16834
|
+
}
|
|
16835
|
+
const kept = keptLane(canonical);
|
|
16836
|
+
if (kept !== undefined && kept.rest.length === 2 && isProjectPosition(kept.rest[0])) {
|
|
16837
|
+
const role = kept.rest[1];
|
|
16838
|
+
return isLiteral(role) ? `${KEPT_PREFIX}${kept.kind}.${role}` : undefined;
|
|
16839
|
+
}
|
|
16840
|
+
return;
|
|
16841
|
+
}
|
|
16842
|
+
function topicForms(topic) {
|
|
16843
|
+
const { canonical, legacy } = canonicalTopic(topic);
|
|
16844
|
+
if (legacy)
|
|
16845
|
+
return [topic, canonical];
|
|
16846
|
+
const twin = legacyTwin(topic);
|
|
16847
|
+
return twin === undefined ? [topic] : [topic, twin];
|
|
16848
|
+
}
|
|
16759
16849
|
// ../contracts/src/tool-schema.ts
|
|
16760
16850
|
function overCapMessage(length, max) {
|
|
16761
16851
|
return `is ${length - max} characters over the ${max}-character limit (${length}/${max})`;
|
|
@@ -17485,7 +17575,7 @@ function ownerTitle(owner) {
|
|
|
17485
17575
|
return "";
|
|
17486
17576
|
}
|
|
17487
17577
|
function issueTopic(key) {
|
|
17488
|
-
return { label: key, topic:
|
|
17578
|
+
return { label: key, topic: legacyDispatchIssueSubject(key, ">") };
|
|
17489
17579
|
}
|
|
17490
17580
|
function documentTopicOf(project, slug) {
|
|
17491
17581
|
return {
|
|
@@ -19987,7 +20077,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
19987
20077
|
...dispatchIssue === undefined ? [] : [dispatchIssue]
|
|
19988
20078
|
].join(", ") || undefined;
|
|
19989
20079
|
const rendered = {
|
|
19990
|
-
...envelope.topic
|
|
20080
|
+
...envelope.topic !== undefined && topicForms(envelope.topic).includes(legacyAgentSubject(sessionID)) ? { to: `you (${sessionID})` } : {},
|
|
19991
20081
|
from: senderLabel(envelope),
|
|
19992
20082
|
at: inboundTimestamp(envelope.issued_at),
|
|
19993
20083
|
id: envelope.event_id ?? "unknown",
|
package/package.json
CHANGED
|
@@ -46,15 +46,24 @@ fail() {
|
|
|
46
46
|
exit 1
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
# nats-server is a `go install` away and lands in GOPATH's bin, which is often off PATH.
|
|
49
|
+
# nats-server is a `go install` away and lands in GOPATH's bin, which is often off PATH. The
|
|
50
|
+
# listener refuses a nats-server below natsversion's floor, so install the hub's v2.15.1.
|
|
50
51
|
if ! command -v nats-server >/dev/null 2>&1; then
|
|
51
52
|
PATH="$(go env GOPATH 2>/dev/null)/bin:${PATH}"
|
|
52
53
|
export PATH
|
|
53
54
|
fi
|
|
54
55
|
for tool in bun curl jq go nats-server; do
|
|
55
56
|
command -v "$tool" >/dev/null 2>&1 ||
|
|
56
|
-
fail "$tool is required (nats-server: go install github.com/nats-io/nats-server/v2@v2.
|
|
57
|
+
fail "$tool is required (nats-server: go install github.com/nats-io/nats-server/v2@v2.15.1)"
|
|
57
58
|
done
|
|
59
|
+
# Whether the listener takes this nats-server is natsversion's own rule, which natsfloor answers
|
|
60
|
+
# (packages/envoy/natsversion/cmd/natsfloor), so this smoke holds no copy of it.
|
|
61
|
+
nats_version=$(nats-server --version 2>/dev/null | sed -n 's/^nats-server: \(v\{0,1\}[0-9][^[:space:]]*\).*$/\1/p')
|
|
62
|
+
[[ -n "$nats_version" ]] || fail "could not read nats-server's version from '$(nats-server --version 2>&1)'"
|
|
63
|
+
floor_verdict=$(go run -C "${repo_root}/packages/envoy" ./natsversion/cmd/natsfloor "$nats_version") ||
|
|
64
|
+
fail "could not ask natsversion whether the listener takes nats-server ${nats_version}"
|
|
65
|
+
[[ "$floor_verdict" == taken$'\t'* ]] ||
|
|
66
|
+
fail "$(command -v nats-server): ${floor_verdict##*$'\t'}: go install github.com/nats-io/nats-server/v2@v2.15.1"
|
|
58
67
|
|
|
59
68
|
workdir="$(mktemp -d /tmp/claude-session-title.XXXXXX)"
|
|
60
69
|
readonly workdir
|
|
@@ -100,11 +100,13 @@ A refusal comes from the proxy, not from the service:
|
|
|
100
100
|
- An HTTP error naming the rule that refused it: a TLS name or `Host` that is not the host the
|
|
101
101
|
command asked for, a method or a path outside the entry's `allow`, a path with a `.` or `..`
|
|
102
102
|
segment, an `X-HTTP-Method-Override`, `X-HTTP-Method` or `X-Method-Override` header where the
|
|
103
|
-
entry lists methods,
|
|
103
|
+
entry lists methods, a `CONNECT` or an `h2c` upgrade inside the proxied connection, plain
|
|
104
|
+
`http://` to a host an entry binds, or a private address. gRPC clients work through the proxy,
|
|
105
|
+
and a gRPC refusal shows the same text in its error message.
|
|
104
106
|
|
|
105
|
-
- `407` once the grant ends, on every call to any host. A
|
|
106
|
-
|
|
107
|
-
idle limit instead.
|
|
107
|
+
- `407` once the grant ends, on every call to any host. A call still running at that moment (a
|
|
108
|
+
WebSocket, a gRPC stream, a long poll) is ended with the grant. A tunnel to a host no entry binds
|
|
109
|
+
carries no value, so it runs to its idle limit instead.
|
|
108
110
|
|
|
109
111
|
- `503` when the broker could not read the grant at all. The grant has not ended and the call
|
|
110
112
|
can be made again.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type Stats, unwatchFile, watchFile } from "node:fs"
|
|
2
2
|
import { rm } from "node:fs/promises"
|
|
3
3
|
import {
|
|
4
|
-
agentSubject,
|
|
5
4
|
DELIVERY_CAPABILITIES,
|
|
6
5
|
type DeliveryCapability,
|
|
6
|
+
legacyAgentSubject,
|
|
7
7
|
ROLE_TOPIC_PREFIX,
|
|
8
8
|
zodSchemaApi,
|
|
9
9
|
} from "@legion/contracts"
|
|
@@ -624,7 +624,7 @@ export function createChannelDelivery(input: {
|
|
|
624
624
|
*/
|
|
625
625
|
export async function startChannelSession(options: ChannelSessionOptions): Promise<ChannelSession> {
|
|
626
626
|
const { identity } = options
|
|
627
|
-
let directSubject =
|
|
627
|
+
let directSubject = legacyAgentSubject(identity.id)
|
|
628
628
|
/**
|
|
629
629
|
* What this session does with a person's direct messages, for the id now bound: the record is
|
|
630
630
|
* kept per session id (`./user-turn-state`), so a `/clear` builds another one. Undefined until
|
|
@@ -1359,7 +1359,7 @@ export async function startChannelSession(options: ChannelSessionOptions): Promi
|
|
|
1359
1359
|
if (next === undefined || next === identity.id) return
|
|
1360
1360
|
const previous = identity.id
|
|
1361
1361
|
const previousSubject = directSubject
|
|
1362
|
-
const nextSubject =
|
|
1362
|
+
const nextSubject = legacyAgentSubject(next)
|
|
1363
1363
|
followedTopics.follow(nextSubject)
|
|
1364
1364
|
try {
|
|
1365
1365
|
// Bounded: this runs inside the registry chain, and a flush on a stalled NATS
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { legacyAgentSubject } from "@legion/contracts"
|
|
2
2
|
import { expandSubscriptionTopics } from "@legion/envoy-client/transport"
|
|
3
3
|
|
|
4
4
|
export type SubscriptionTopicsOptions = {
|
|
@@ -12,5 +12,5 @@ export function subscriptionTopics(options: SubscriptionTopicsOptions): readonly
|
|
|
12
12
|
.map((topic) => topic.trim())
|
|
13
13
|
.filter((topic) => topic.length > 0)
|
|
14
14
|
|
|
15
|
-
return expandSubscriptionTopics([
|
|
15
|
+
return expandSubscriptionTopics([legacyAgentSubject(options.sessionId), ...(additional ?? [])])
|
|
16
16
|
}
|