@sjawhar/claude-envoy 2.35.1 → 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 +245 -35
- package/dist/envoy-channel.js +257 -44
- package/dist/session-hook.js +238 -32
- 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/envoy-client.ts +17 -2
- package/src/subscription-topics.ts +2 -2
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})`;
|
|
@@ -40586,6 +40676,7 @@ var SUBJECT_TOKEN_TYPE_GOOGLE = "urn:envoy:params:oauth:token-type:google-identi
|
|
|
40586
40676
|
var SUBJECT_TOKEN_TYPE_PERSON = "urn:envoy:params:oauth:token-type:person-google-identity";
|
|
40587
40677
|
var ACTOR_TOKEN_TYPE_MACHINE = "urn:envoy:params:oauth:token-type:machine-google-identity";
|
|
40588
40678
|
var TOKEN_TYPE_DPOP = "DPoP";
|
|
40679
|
+
var POD_SESSION_NOT_REGISTERED = "pod_session_not_registered";
|
|
40589
40680
|
|
|
40590
40681
|
// ../broker-client/src/metadata-identity.ts
|
|
40591
40682
|
var METADATA_HOST_VAR = "GCE_METADATA_HOST";
|
|
@@ -42026,6 +42117,26 @@ var DEFAULT_RENEW_BEFORE_MS = 5 * 60000;
|
|
|
42026
42117
|
var TOO_MANY_REQUESTS = 429;
|
|
42027
42118
|
var INVALID_DPOP_PROOF = "invalid_dpop_proof";
|
|
42028
42119
|
var USE_DPOP_NONCE = "use_dpop_nonce";
|
|
42120
|
+
var INVALID_GRANT = "invalid_grant";
|
|
42121
|
+
var UNREGISTERED_FIRST_WAIT_MS = 15000;
|
|
42122
|
+
var UNREGISTERED_MAX_WAIT_MS = 5 * 60000;
|
|
42123
|
+
var UNREGISTERED_LOG_EVERY_MS = 30 * 60000;
|
|
42124
|
+
function sleep2(ms, signal) {
|
|
42125
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
42126
|
+
if (signal?.aborted) {
|
|
42127
|
+
resolve();
|
|
42128
|
+
return promise;
|
|
42129
|
+
}
|
|
42130
|
+
const done = () => {
|
|
42131
|
+
clearTimeout(timer);
|
|
42132
|
+
signal?.removeEventListener("abort", done);
|
|
42133
|
+
resolve();
|
|
42134
|
+
};
|
|
42135
|
+
const timer = setTimeout(done, ms);
|
|
42136
|
+
timer.unref();
|
|
42137
|
+
signal?.addEventListener("abort", done, { once: true });
|
|
42138
|
+
return promise;
|
|
42139
|
+
}
|
|
42029
42140
|
|
|
42030
42141
|
class BrokerRefusedError extends Error {
|
|
42031
42142
|
status;
|
|
@@ -42039,7 +42150,19 @@ class BrokerRefusedError extends Error {
|
|
|
42039
42150
|
this.name = "BrokerRefusedError";
|
|
42040
42151
|
}
|
|
42041
42152
|
get permanent() {
|
|
42042
|
-
return this.status !== TOO_MANY_REQUESTS && this.code !== INVALID_DPOP_PROOF && this.code !== USE_DPOP_NONCE;
|
|
42153
|
+
return this.status !== TOO_MANY_REQUESTS && this.code !== INVALID_DPOP_PROOF && this.code !== USE_DPOP_NONCE && !this.podSessionUnregistered;
|
|
42154
|
+
}
|
|
42155
|
+
get podSessionUnregistered() {
|
|
42156
|
+
return this.code === INVALID_GRANT && this.description.startsWith(`${POD_SESSION_NOT_REGISTERED}:`);
|
|
42157
|
+
}
|
|
42158
|
+
}
|
|
42159
|
+
|
|
42160
|
+
class RegistrationPendingError extends Error {
|
|
42161
|
+
session;
|
|
42162
|
+
constructor(session, refusal) {
|
|
42163
|
+
super(`the secrets broker has no registration for this pod's session ${session} yet, and the trade is being retried in the background until it lands (${refusal.description})`, { cause: refusal });
|
|
42164
|
+
this.session = session;
|
|
42165
|
+
this.name = "RegistrationPendingError";
|
|
42043
42166
|
}
|
|
42044
42167
|
}
|
|
42045
42168
|
|
|
@@ -42088,10 +42211,16 @@ class BrokerTokenClient {
|
|
|
42088
42211
|
#launcherCredential;
|
|
42089
42212
|
#renewBeforeMs;
|
|
42090
42213
|
#now;
|
|
42214
|
+
#sleep;
|
|
42215
|
+
#log;
|
|
42091
42216
|
#fetch;
|
|
42092
42217
|
#nonce = "";
|
|
42093
42218
|
#held = null;
|
|
42094
42219
|
#trading = null;
|
|
42220
|
+
#waiters = new Set;
|
|
42221
|
+
#pending = null;
|
|
42222
|
+
#wake = null;
|
|
42223
|
+
#closed = new AbortController;
|
|
42095
42224
|
constructor(options) {
|
|
42096
42225
|
const brokerUrl = withoutTrailingSlashes(options.brokerUrl.trim());
|
|
42097
42226
|
if (brokerUrl === "")
|
|
@@ -42105,6 +42234,8 @@ class BrokerTokenClient {
|
|
|
42105
42234
|
this.#launcherCredential = options.launcherCredential ?? true;
|
|
42106
42235
|
this.#renewBeforeMs = options.renewBeforeMs ?? DEFAULT_RENEW_BEFORE_MS;
|
|
42107
42236
|
this.#now = options.now ?? Date.now;
|
|
42237
|
+
this.#sleep = options.sleep ?? sleep2;
|
|
42238
|
+
this.#log = options.log ?? console.warn;
|
|
42108
42239
|
this.#fetch = options.fetch ?? fetch;
|
|
42109
42240
|
}
|
|
42110
42241
|
get key() {
|
|
@@ -42117,31 +42248,95 @@ class BrokerTokenClient {
|
|
|
42117
42248
|
const held = this.#held;
|
|
42118
42249
|
if (held !== null && this.#now() < held.expiresAt.getTime() - this.#renewBeforeMs)
|
|
42119
42250
|
return held;
|
|
42120
|
-
if (this.#trading
|
|
42121
|
-
|
|
42122
|
-
|
|
42123
|
-
|
|
42124
|
-
|
|
42125
|
-
|
|
42126
|
-
}
|
|
42251
|
+
if (this.#trading === null) {
|
|
42252
|
+
const started = this.#renew();
|
|
42253
|
+
this.#trading = started;
|
|
42254
|
+
started.then((token) => this.#settled(started, (waiter) => waiter.resolve(token)), (error) => this.#settled(started, (waiter) => waiter.reject(error)));
|
|
42255
|
+
} else {
|
|
42256
|
+
this.#wake?.();
|
|
42257
|
+
}
|
|
42258
|
+
return await this.#joined(signal);
|
|
42259
|
+
}
|
|
42260
|
+
#settled(started, tell) {
|
|
42261
|
+
if (this.#trading === started)
|
|
42127
42262
|
this.#trading = null;
|
|
42263
|
+
const waiters = [...this.#waiters];
|
|
42264
|
+
this.#waiters.clear();
|
|
42265
|
+
for (const waiter of waiters)
|
|
42266
|
+
tell(waiter);
|
|
42267
|
+
}
|
|
42268
|
+
#joined(signal) {
|
|
42269
|
+
const { promise, resolve, reject } = Promise.withResolvers();
|
|
42270
|
+
const stop = () => {
|
|
42271
|
+
this.#waiters.delete(waiter);
|
|
42272
|
+
const pending = this.#pending;
|
|
42273
|
+
reject(pending === null ? signal?.reason : new RegistrationPendingError(this.#session, pending));
|
|
42274
|
+
};
|
|
42275
|
+
const waiter = {
|
|
42276
|
+
resolve: (token) => {
|
|
42277
|
+
signal?.removeEventListener("abort", stop);
|
|
42278
|
+
resolve(token);
|
|
42279
|
+
},
|
|
42280
|
+
reject: (error) => {
|
|
42281
|
+
signal?.removeEventListener("abort", stop);
|
|
42282
|
+
reject(error);
|
|
42283
|
+
}
|
|
42284
|
+
};
|
|
42285
|
+
if (signal?.aborted) {
|
|
42286
|
+
stop();
|
|
42287
|
+
return promise;
|
|
42128
42288
|
}
|
|
42289
|
+
this.#waiters.add(waiter);
|
|
42290
|
+
signal?.addEventListener("abort", stop, { once: true });
|
|
42291
|
+
return promise;
|
|
42292
|
+
}
|
|
42293
|
+
close() {
|
|
42294
|
+
this.#closed.abort();
|
|
42129
42295
|
}
|
|
42130
42296
|
drop() {
|
|
42131
42297
|
this.#held = null;
|
|
42132
42298
|
}
|
|
42133
|
-
async#renew(
|
|
42299
|
+
async#renew() {
|
|
42300
|
+
const closed = this.#closed.signal;
|
|
42301
|
+
let wait = UNREGISTERED_FIRST_WAIT_MS;
|
|
42302
|
+
let since = null;
|
|
42303
|
+
let logged = null;
|
|
42134
42304
|
try {
|
|
42135
|
-
|
|
42136
|
-
|
|
42137
|
-
|
|
42138
|
-
|
|
42139
|
-
|
|
42140
|
-
|
|
42141
|
-
|
|
42305
|
+
while (true) {
|
|
42306
|
+
try {
|
|
42307
|
+
const token = await this.#trade(closed);
|
|
42308
|
+
this.#held = token;
|
|
42309
|
+
return token;
|
|
42310
|
+
} catch (error) {
|
|
42311
|
+
const held = this.#held;
|
|
42312
|
+
if (!isFinalRefusal(error) && held !== null && this.#now() < held.expiresAt.getTime()) {
|
|
42313
|
+
return held;
|
|
42314
|
+
}
|
|
42315
|
+
this.#held = null;
|
|
42316
|
+
const unregistered = error instanceof BrokerRefusedError && error.podSessionUnregistered;
|
|
42317
|
+
if (!unregistered || closed.aborted)
|
|
42318
|
+
throw error;
|
|
42319
|
+
this.#pending = error;
|
|
42320
|
+
const now = this.#now();
|
|
42321
|
+
since ??= now;
|
|
42322
|
+
if (logged === null || now - logged >= UNREGISTERED_LOG_EVERY_MS) {
|
|
42323
|
+
logged = now;
|
|
42324
|
+
this.#log(`the secrets broker has no registration for this pod's session ${this.#session} yet (${Math.round((now - since) / 1000)} s so far); trading ${this.describe()} again until it lands`);
|
|
42325
|
+
}
|
|
42326
|
+
const woken = new AbortController;
|
|
42327
|
+
this.#wake = () => woken.abort();
|
|
42328
|
+
try {
|
|
42329
|
+
await this.#sleep(wait, AbortSignal.any([closed, woken.signal]));
|
|
42330
|
+
} finally {
|
|
42331
|
+
this.#wake = null;
|
|
42332
|
+
}
|
|
42333
|
+
if (closed.aborted)
|
|
42334
|
+
throw error;
|
|
42335
|
+
wait = Math.min(wait * 2, UNREGISTERED_MAX_WAIT_MS);
|
|
42336
|
+
}
|
|
42142
42337
|
}
|
|
42143
|
-
|
|
42144
|
-
|
|
42338
|
+
} finally {
|
|
42339
|
+
this.#pending = null;
|
|
42145
42340
|
}
|
|
42146
42341
|
}
|
|
42147
42342
|
async#trade(signal) {
|
|
@@ -42247,7 +42442,7 @@ class BrokerTokenClient {
|
|
|
42247
42442
|
|
|
42248
42443
|
// ../broker-client/src/person-identity.ts
|
|
42249
42444
|
var ISSUER_TIMEOUT_SECONDS = 30;
|
|
42250
|
-
var
|
|
42445
|
+
var INVALID_GRANT2 = "invalid_grant";
|
|
42251
42446
|
function issuerSaid(error) {
|
|
42252
42447
|
if (error instanceof ResponseBodyError) {
|
|
42253
42448
|
const description = error.error_description ?? "";
|
|
@@ -42304,7 +42499,7 @@ function personIdentity(record, flow, options = {}) {
|
|
|
42304
42499
|
config[customFetch2] = through(signal);
|
|
42305
42500
|
answered = await refreshTokenGrant(config, refreshToken);
|
|
42306
42501
|
} catch (error) {
|
|
42307
|
-
if (error instanceof ResponseBodyError && error.error ===
|
|
42502
|
+
if (error instanceof ResponseBodyError && error.error === INVALID_GRANT2) {
|
|
42308
42503
|
throw new SignInEndedError(flow.issuer, person, { cause: error });
|
|
42309
42504
|
}
|
|
42310
42505
|
throw new Error(`renew ${person}'s sign-in at ${flow.issuer}: ${issuerSaid(error)}`);
|
|
@@ -42586,8 +42781,14 @@ function brokerRouteConfigured(env) {
|
|
|
42586
42781
|
return { traded: true };
|
|
42587
42782
|
}
|
|
42588
42783
|
var CLIENTS = new Map;
|
|
42784
|
+
function closeAll(entries) {
|
|
42785
|
+
for (const held of entries?.values() ?? [])
|
|
42786
|
+
held.made?.client?.close();
|
|
42787
|
+
}
|
|
42589
42788
|
function forgetBrokerSession(session) {
|
|
42590
|
-
|
|
42789
|
+
const key = session.trim();
|
|
42790
|
+
closeAll(CLIENTS.get(key));
|
|
42791
|
+
CLIENTS.delete(key);
|
|
42591
42792
|
}
|
|
42592
42793
|
function signInName(record) {
|
|
42593
42794
|
return `${record.person}\x00${record.thumbprint}`;
|
|
@@ -42649,7 +42850,7 @@ function brokerCredential(env, session) {
|
|
|
42649
42850
|
const own = (acting) => (acting ?? "").trim() || sessionName(session);
|
|
42650
42851
|
return {
|
|
42651
42852
|
scheme: "DPoP",
|
|
42652
|
-
async headers(method, url, acting) {
|
|
42853
|
+
async headers(method, url, acting, signal) {
|
|
42653
42854
|
const { entry, made } = await clientFor(env, own(acting));
|
|
42654
42855
|
const { client } = made;
|
|
42655
42856
|
if (client === undefined) {
|
|
@@ -42657,7 +42858,7 @@ function brokerCredential(env, session) {
|
|
|
42657
42858
|
}
|
|
42658
42859
|
let token;
|
|
42659
42860
|
try {
|
|
42660
|
-
token = await client.token();
|
|
42861
|
+
token = await client.token(signal);
|
|
42661
42862
|
} catch (error) {
|
|
42662
42863
|
if (made.signIn !== "" && isFinalRefusal(error))
|
|
42663
42864
|
entry.refused.set(made.signIn, error);
|
|
@@ -44589,14 +44790,15 @@ class DispatchClient {
|
|
|
44589
44790
|
}
|
|
44590
44791
|
async#sendPresenting(method, url, body, accept, signal, key) {
|
|
44591
44792
|
const headers = { Accept: accept };
|
|
44592
|
-
|
|
44793
|
+
const limit = signal === undefined ? this.#signal : AbortSignal.any([this.#signal, signal]);
|
|
44794
|
+
let presented = await this.#credential.headers(method, url, undefined, limit);
|
|
44593
44795
|
if (body !== undefined)
|
|
44594
44796
|
headers["Content-Type"] = body.type;
|
|
44595
44797
|
if (key === undefined) {
|
|
44596
44798
|
return this.fetchImpl(url, {
|
|
44597
44799
|
method,
|
|
44598
44800
|
headers: { ...headers, ...presented },
|
|
44599
|
-
signal:
|
|
44801
|
+
signal: limit,
|
|
44600
44802
|
...body === undefined ? {} : { body: body.content }
|
|
44601
44803
|
});
|
|
44602
44804
|
}
|
|
@@ -44616,7 +44818,7 @@ class DispatchClient {
|
|
|
44616
44818
|
let thrown;
|
|
44617
44819
|
try {
|
|
44618
44820
|
if (attempt > 1)
|
|
44619
|
-
presented = await this.#credential.headers(method, url);
|
|
44821
|
+
presented = await this.#credential.headers(method, url, undefined, limit);
|
|
44620
44822
|
const sent = { ...headers, ...presented };
|
|
44621
44823
|
answer = await writeAnswer(await this.#attempt(url, method, sent, body, silenceMs), key);
|
|
44622
44824
|
if (answer.echoed)
|
|
@@ -44719,10 +44921,14 @@ class DispatchClient {
|
|
|
44719
44921
|
async#probeKeyedLayer() {
|
|
44720
44922
|
try {
|
|
44721
44923
|
const probe = `${this.#baseUrl}/healthz`;
|
|
44924
|
+
const limit = AbortSignal.any([this.#signal, AbortSignal.timeout(KEY_LAYER_PROBE_MS)]);
|
|
44722
44925
|
const response = await this.fetchImpl(probe, {
|
|
44723
44926
|
method: "GET",
|
|
44724
|
-
headers: {
|
|
44725
|
-
|
|
44927
|
+
headers: {
|
|
44928
|
+
Accept: "application/json",
|
|
44929
|
+
...await this.#credential.headers("GET", probe, undefined, limit)
|
|
44930
|
+
},
|
|
44931
|
+
signal: limit
|
|
44726
44932
|
});
|
|
44727
44933
|
if (!isJson(response))
|
|
44728
44934
|
return false;
|
|
@@ -44810,7 +45016,7 @@ function ownerTitle(owner) {
|
|
|
44810
45016
|
return "";
|
|
44811
45017
|
}
|
|
44812
45018
|
function issueTopic(key) {
|
|
44813
|
-
return { label: key, topic:
|
|
45019
|
+
return { label: key, topic: legacyDispatchIssueSubject(key, ">") };
|
|
44814
45020
|
}
|
|
44815
45021
|
function documentTopicOf(project, slug) {
|
|
44816
45022
|
return {
|
|
@@ -45724,7 +45930,7 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
45724
45930
|
...dispatchIssue === undefined ? [] : [dispatchIssue]
|
|
45725
45931
|
].join(", ") || undefined;
|
|
45726
45932
|
const rendered = {
|
|
45727
|
-
...envelope.topic
|
|
45933
|
+
...envelope.topic !== undefined && topicForms(envelope.topic).includes(legacyAgentSubject(sessionID)) ? { to: `you (${sessionID})` } : {},
|
|
45728
45934
|
from: senderLabel(envelope),
|
|
45729
45935
|
at: inboundTimestamp(envelope.issued_at),
|
|
45730
45936
|
id: envelope.event_id ?? "unknown",
|
|
@@ -46151,7 +46357,8 @@ function reachesPrivateStreamSubject(ownAgentSubject, topic, roles = []) {
|
|
|
46151
46357
|
const role = controllerNoticeRole(topic);
|
|
46152
46358
|
if (role !== undefined)
|
|
46153
46359
|
return !roles.includes(role);
|
|
46154
|
-
|
|
46360
|
+
const own = topic === ownAgentSubject || legacyTwin(topic) === ownAgentSubject;
|
|
46361
|
+
return !own || /[*>]/.test(ownAgentSubject);
|
|
46155
46362
|
}
|
|
46156
46363
|
function registrationTopics(ownAgentSubject, followed, roles = []) {
|
|
46157
46364
|
return [
|
|
@@ -46398,21 +46605,24 @@ function createEnvoyClient(config) {
|
|
|
46398
46605
|
const attemptOnce = async (url, init, deadlineMs, actingSession) => {
|
|
46399
46606
|
let response;
|
|
46400
46607
|
let unminted;
|
|
46608
|
+
const deadline = AbortSignal.timeout(deadlineMs);
|
|
46401
46609
|
try {
|
|
46402
46610
|
const headers = new Headers(init.headers);
|
|
46403
46611
|
let presented;
|
|
46404
46612
|
try {
|
|
46405
|
-
const ready = credential?.headers(init.method ?? "GET", url, actingSession);
|
|
46613
|
+
const ready = credential?.headers(init.method ?? "GET", url, actingSession, deadline);
|
|
46406
46614
|
presented = ready instanceof Promise ? await ready : ready;
|
|
46407
46615
|
} catch (error) {
|
|
46408
46616
|
unminted = error;
|
|
46409
46617
|
}
|
|
46618
|
+
if (unminted !== undefined && deadline.aborted)
|
|
46619
|
+
return { unanswered: unminted };
|
|
46410
46620
|
for (const [name, value] of Object.entries(presented ?? {}))
|
|
46411
46621
|
headers.set(name, value);
|
|
46412
46622
|
response = await config.fetch(url, {
|
|
46413
46623
|
...init,
|
|
46414
46624
|
headers,
|
|
46415
|
-
signal:
|
|
46625
|
+
signal: deadline
|
|
46416
46626
|
});
|
|
46417
46627
|
} catch (error) {
|
|
46418
46628
|
return { unanswered: error };
|
|
@@ -46717,8 +46927,9 @@ function parseIdentity(data) {
|
|
|
46717
46927
|
const { event_id, dedupe_key } = identity.data;
|
|
46718
46928
|
return event_id === undefined && dedupe_key === undefined ? undefined : identity.data;
|
|
46719
46929
|
}
|
|
46720
|
-
function reaches(topic,
|
|
46721
|
-
|
|
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)));
|
|
46722
46933
|
}
|
|
46723
46934
|
function every(ms, callback) {
|
|
46724
46935
|
const timer = setInterval(callback, ms);
|
|
@@ -46729,7 +46940,8 @@ function createConsumerDelivery(options) {
|
|
|
46729
46940
|
const render = options.render ?? renderInbound;
|
|
46730
46941
|
const now = options.now ?? Date.now;
|
|
46731
46942
|
const repeat = options.every ?? every;
|
|
46732
|
-
const ownSubject =
|
|
46943
|
+
const ownSubject = legacyAgentSubject(sessionID);
|
|
46944
|
+
const ownsSubject = (subject) => topicForms(subject).includes(ownSubject);
|
|
46733
46945
|
let currentEpoch = { id: newEpoch(), startedAt: now() };
|
|
46734
46946
|
let follows = new Map;
|
|
46735
46947
|
let streamID;
|
|
@@ -46772,11 +46984,12 @@ function createConsumerDelivery(options) {
|
|
|
46772
46984
|
tellGap("stream_recreated");
|
|
46773
46985
|
};
|
|
46774
46986
|
const followedAt = (subject) => {
|
|
46775
|
-
if (subject
|
|
46987
|
+
if (ownsSubject(subject))
|
|
46776
46988
|
return Number.NEGATIVE_INFINITY;
|
|
46989
|
+
const forms = topicForms(subject);
|
|
46777
46990
|
let earliest;
|
|
46778
46991
|
for (const [topic, at] of follows) {
|
|
46779
|
-
if (!reaches(topic,
|
|
46992
|
+
if (!reaches(topic, forms))
|
|
46780
46993
|
continue;
|
|
46781
46994
|
if (earliest === undefined || at < earliest)
|
|
46782
46995
|
earliest = at;
|
|
@@ -47031,7 +47244,7 @@ function createConsumerDelivery(options) {
|
|
|
47031
47244
|
const at = now();
|
|
47032
47245
|
const next = new Map;
|
|
47033
47246
|
for (const topic of topics) {
|
|
47034
|
-
if (topic
|
|
47247
|
+
if (ownsSubject(topic))
|
|
47035
47248
|
continue;
|
|
47036
47249
|
next.set(topic, follows.get(topic) ?? at);
|
|
47037
47250
|
}
|
|
@@ -57507,7 +57720,7 @@ var import_nats2 = __toESM(require_mod4(), 1);
|
|
|
57507
57720
|
|
|
57508
57721
|
// package.json
|
|
57509
57722
|
var name = "@sjawhar/claude-envoy";
|
|
57510
|
-
var version2 = "2.
|
|
57723
|
+
var version2 = "2.37.0";
|
|
57511
57724
|
var legion = {
|
|
57512
57725
|
daemonApiVersion: 146
|
|
57513
57726
|
};
|
|
@@ -61396,7 +61609,7 @@ function createChannelDelivery(input) {
|
|
|
61396
61609
|
}
|
|
61397
61610
|
async function startChannelSession(options) {
|
|
61398
61611
|
const { identity } = options;
|
|
61399
|
-
let directSubject =
|
|
61612
|
+
let directSubject = legacyAgentSubject(identity.id);
|
|
61400
61613
|
let router;
|
|
61401
61614
|
let turns;
|
|
61402
61615
|
const delivery = createChannelDelivery({
|
|
@@ -61800,7 +62013,7 @@ async function startChannelSession(options) {
|
|
|
61800
62013
|
return;
|
|
61801
62014
|
const previous = identity.id;
|
|
61802
62015
|
const previousSubject = directSubject;
|
|
61803
|
-
const nextSubject =
|
|
62016
|
+
const nextSubject = legacyAgentSubject(next);
|
|
61804
62017
|
followedTopics.follow(nextSubject);
|
|
61805
62018
|
try {
|
|
61806
62019
|
await withTimeout(options.connection.flush(), options.handoffFlushTimeoutMs ?? HANDOFF_FLUSH_TIMEOUT_MS, "flushing NATS");
|