@sjawhar/claude-envoy 2.22.0 → 2.23.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 +95 -25
- package/dist/envoy-channel.js +99 -27
- package/dist/session-hook.js +98 -26
- package/hooks/session-hook.ts +3 -6
- package/legion/skills/legion-architect/references/wake-routing.md +1 -1
- package/package.json +1 -1
- package/src/envoy-channel-server.ts +3 -1
package/.omp-plugin/plugin.json
CHANGED
package/dist/dispatch.js
CHANGED
|
@@ -15662,7 +15662,7 @@ var dispatchToolSpecs = [
|
|
|
15662
15662
|
{
|
|
15663
15663
|
name: "dispatch_read",
|
|
15664
15664
|
example: { issue: "DSP-1" },
|
|
15665
|
-
description: "Read an issue or document summary, targeted ask, or targeted comment reply chain, or the conversation " + "a message belongs to. Do not use it for document contents; use dispatch doc-read instead. Supply ref, issue, " + "issue plus artifact (one of its documents), project plus artifact, or project alone, which lists the project's documents on no issue and nothing more; or message alone, which reads a human's direct message to this session and every " + "reply to it (they belong to no issue). A document summary names its issue, reference, versions and approval. " + "An issue read lists every document, picture and file the issue holds under `Documents:`, each by slug, filename and kind. " + "An anchored comment or ask also says where its quote sits, as `Position:`: the block's path from the top, " + "and in a table the row (0 is the header), the cells before the anchored one, and the column's header; " + "`Position: unavailable (<code>)` when Dispatch could not read the document: `DOC_SERVICE_UNAVAILABLE` " + "(try again shortly), `DOC_SCHEMA` (the document needs repair), `
|
|
15665
|
+
description: "Read an issue or document summary, targeted ask, or targeted comment reply chain, or the conversation " + "a message belongs to. Do not use it for document contents; use dispatch doc-read instead. Supply ref, issue, " + "issue plus artifact (one of its documents), project plus artifact, or project alone, which lists the project's documents on no issue and nothing more; or message alone, which reads a human's direct message to this session and every " + "reply to it (they belong to no issue). A document summary names its issue, reference, versions and approval. " + "An issue read lists every document, picture and file the issue holds under `Documents:`, each by slug, filename and kind. " + "An anchored comment or ask also says where its quote sits, as `Position:`: the block's path from the top, " + "and in a table the row (0 is the header), the cells before the anchored one, and the column's header; " + "`Position: unavailable (<code>)` when Dispatch could not read the document: `DOC_SERVICE_UNAVAILABLE` " + "(try again shortly), `DOC_SCHEMA` (the document needs repair), `DOC_NEWER_CONTENT` (this Dispatch " + "build cannot read an element of the document; try again in one minute), `DOCUMENT_UNLOADABLE` (the " + "document's stored history cannot load; a person decides whether to rebuild it) or `INTERNAL`. " + "An issue read carries a `Progress:` line, `tasks 3/7, children 2/5`: its spec's task-list items " + "(`- [ ]` / `- [x]`, nested lists included) and its direct children, each done of total and each only " + "when it has any (`Progress: none` otherwise). " + "An issue whose spec marks requirements carries one `Coverage:` line per gap, `Coverage: R3 has no check` or " + "`Coverage: R3 has no plan task` (the second only once the issue has a plan document), counting the `check` and " + "`plan_task` blocks of every document of the issue and of its descendants; a spec that marks none reads " + "`Coverage: the spec marks no requirements`. Nothing is refused for a gap. " + `An issue read, and its dispatch://KEY/log, lists the issue's last ${DEFAULT_ISSUE_READ_EVENTS} events, oldest first; ` + "--events N lists the last N, and --all-events every one. " + "A comment reply chain names the comment each nested reply answers as `Answers: <comment id>`. " + "Every read ends with `Referenced by:` (what cites or hangs off this node, each with its dispatch:// address, " + "an excerpt, and when) and `Links:` (what it cites), so tracing provenance is one call. " + "A block read prints `Block:`, `Type:` for a block of a document, `Document:`, every attribute a typed block carries " + "(a `check`'s serves, surface, run, when, negative_control and ci_check; a `plan_task`'s serves and needs), `Changed in version:` " + "and `Text:`, then those two sections; a pinned one adds " + "the block's text at that version and whether it is unchanged, changed or removed since, and an absent block, unpinned, " + "reads `No block <id> in <document>.` " + "The pictures the shown messages, asks and comments embed come back as images you see, newest first, at most 8 " + "and 10 MiB of them per read, each a PNG, JPEG, GIF or WebP of at most 3,750,000 bytes (5 MB of base64); a `Pictures:` section names each " + "one shown, in order, and the rest by reference, for dispatch doc-read. A picture this session was already shown is named, not sent again " + "(every request carries the session's history, and the provider refuses one over 32 MB); dispatch doc-read shows it again. " + OWNER_REFERENCE,
|
|
15666
15666
|
arguments: (z) => ({
|
|
15667
15667
|
issue: z.string().describe(ISSUE_REFERENCE).optional(),
|
|
15668
15668
|
project: z.string().describe("Project key owning the document.").optional(),
|
|
@@ -16361,6 +16361,45 @@ var MessageAcceptedEventPayloadSchema = strictObject({
|
|
|
16361
16361
|
accepted_as: literal("user_turn"),
|
|
16362
16362
|
target: string2()
|
|
16363
16363
|
}).readonly();
|
|
16364
|
+
// ../contracts/src/dispatch-api-requests.ts
|
|
16365
|
+
var NO_ROUTE_MESSAGE_PREFIX = "no route for ";
|
|
16366
|
+
var NO_ROUTE_RETRY_DELAYS_MS = [1000, 2000, 4000];
|
|
16367
|
+
var NO_ROUTE_ROLLING_RELEASE_MESSAGE = "The Dispatch process that answered does not offer this action yet, because a new release of " + "Dispatch is in progress. Try again in one minute.";
|
|
16368
|
+
var sleep = (ms, signal) => {
|
|
16369
|
+
const { promise, resolve, reject } = Promise.withResolvers();
|
|
16370
|
+
if (signal?.aborted) {
|
|
16371
|
+
reject(signal.reason);
|
|
16372
|
+
return promise;
|
|
16373
|
+
}
|
|
16374
|
+
const abort = () => {
|
|
16375
|
+
clearTimeout(timer);
|
|
16376
|
+
reject(signal?.reason);
|
|
16377
|
+
};
|
|
16378
|
+
const timer = setTimeout(() => {
|
|
16379
|
+
signal?.removeEventListener("abort", abort);
|
|
16380
|
+
resolve();
|
|
16381
|
+
}, ms);
|
|
16382
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
16383
|
+
return promise;
|
|
16384
|
+
};
|
|
16385
|
+
function jitteredDelay(ms) {
|
|
16386
|
+
return ms * (0.75 + Math.random() * 0.5);
|
|
16387
|
+
}
|
|
16388
|
+
async function retryNoRoute(attempt, isNoRoute, options) {
|
|
16389
|
+
const wait = options.sleep ?? sleep;
|
|
16390
|
+
for (const delay of [...NO_ROUTE_RETRY_DELAYS_MS, undefined]) {
|
|
16391
|
+
try {
|
|
16392
|
+
return await attempt();
|
|
16393
|
+
} catch (error) {
|
|
16394
|
+
if (!isNoRoute(error))
|
|
16395
|
+
throw error;
|
|
16396
|
+
if (delay === undefined)
|
|
16397
|
+
break;
|
|
16398
|
+
}
|
|
16399
|
+
await wait(jitteredDelay(delay), options.signal);
|
|
16400
|
+
}
|
|
16401
|
+
throw options.exhausted();
|
|
16402
|
+
}
|
|
16364
16403
|
// ../contracts/src/dispatch-api-search.ts
|
|
16365
16404
|
var SEARCH_MEMBERS_EVERY_BUILD_READS = [
|
|
16366
16405
|
"q",
|
|
@@ -18392,7 +18431,13 @@ function isJson(response) {
|
|
|
18392
18431
|
return response.headers.get("content-type")?.includes("application/json") ?? false;
|
|
18393
18432
|
}
|
|
18394
18433
|
function isNoRoute(error) {
|
|
18395
|
-
return error instanceof DispatchServiceError && error.status === 404 && error.code === "NOT_FOUND" && error.message.startsWith(
|
|
18434
|
+
return error instanceof DispatchServiceError && error.status === 404 && error.code === "NOT_FOUND" && error.message.startsWith(NO_ROUTE_MESSAGE_PREFIX);
|
|
18435
|
+
}
|
|
18436
|
+
|
|
18437
|
+
class DispatchNoRouteError extends DispatchServiceError {
|
|
18438
|
+
constructor() {
|
|
18439
|
+
super("NOT_FOUND", 404, NO_ROUTE_ROLLING_RELEASE_MESSAGE);
|
|
18440
|
+
}
|
|
18396
18441
|
}
|
|
18397
18442
|
var ISSUE_EVENTS_PAGE_MAX = 200;
|
|
18398
18443
|
var DISPATCH_TOOL_DEADLINE_MS = 60000;
|
|
@@ -18610,18 +18655,22 @@ function excerpt(text, token) {
|
|
|
18610
18655
|
|
|
18611
18656
|
class DispatchClient {
|
|
18612
18657
|
fetchImpl;
|
|
18613
|
-
writeRetry;
|
|
18614
18658
|
#baseUrl;
|
|
18615
18659
|
#resolvedIssues = new Map;
|
|
18616
18660
|
#signal;
|
|
18617
18661
|
#credential;
|
|
18662
|
+
#sleep;
|
|
18663
|
+
#retryNoRoute;
|
|
18664
|
+
writeRetry;
|
|
18618
18665
|
#madeAt;
|
|
18619
|
-
constructor(baseUrl, credential, fetchImpl = fetch,
|
|
18666
|
+
constructor(baseUrl, credential, fetchImpl = fetch, options = {}) {
|
|
18620
18667
|
this.fetchImpl = fetchImpl;
|
|
18621
|
-
this.writeRetry = writeRetry;
|
|
18622
18668
|
this.#credential = credential;
|
|
18623
18669
|
this.#baseUrl = withoutTrailingSlashes(baseUrl);
|
|
18624
|
-
this.#signal = requestSignal(signal);
|
|
18670
|
+
this.#signal = requestSignal(options.signal);
|
|
18671
|
+
this.writeRetry = options.writeRetry ?? DISPATCH_WRITE_RETRY;
|
|
18672
|
+
this.#sleep = options.sleep ?? sleep;
|
|
18673
|
+
this.#retryNoRoute = options.retryNoRoute ?? true;
|
|
18625
18674
|
this.#madeAt = this.#now();
|
|
18626
18675
|
}
|
|
18627
18676
|
get token() {
|
|
@@ -18776,7 +18825,7 @@ class DispatchClient {
|
|
|
18776
18825
|
try {
|
|
18777
18826
|
return await this.#json("GET", ["api", "v1", "projects", project, "architecture-sources"]);
|
|
18778
18827
|
} catch (error) {
|
|
18779
|
-
if (!
|
|
18828
|
+
if (!(error instanceof DispatchNoRouteError))
|
|
18780
18829
|
throw error;
|
|
18781
18830
|
}
|
|
18782
18831
|
try {
|
|
@@ -18806,7 +18855,7 @@ class DispatchClient {
|
|
|
18806
18855
|
"sync"
|
|
18807
18856
|
]);
|
|
18808
18857
|
} catch (error) {
|
|
18809
|
-
if (!
|
|
18858
|
+
if (!(error instanceof DispatchNoRouteError))
|
|
18810
18859
|
throw error;
|
|
18811
18860
|
}
|
|
18812
18861
|
const source = await this.#json("POST", [
|
|
@@ -18932,13 +18981,15 @@ class DispatchClient {
|
|
|
18932
18981
|
}
|
|
18933
18982
|
async fileVersion(id, version) {
|
|
18934
18983
|
const url = this.#url(["api", "v1", "artifacts", id, "versions", String(version)]);
|
|
18935
|
-
|
|
18936
|
-
|
|
18937
|
-
|
|
18938
|
-
|
|
18939
|
-
|
|
18940
|
-
|
|
18941
|
-
|
|
18984
|
+
return this.#noRoute(async () => {
|
|
18985
|
+
const response = await this.#send("GET", url, undefined, "*/*");
|
|
18986
|
+
if (!response.ok)
|
|
18987
|
+
return this.#response("GET", url, response);
|
|
18988
|
+
return {
|
|
18989
|
+
mime: response.headers.get("Content-Type") ?? "application/octet-stream",
|
|
18990
|
+
bytes: new Uint8Array(await response.arrayBuffer())
|
|
18991
|
+
};
|
|
18992
|
+
});
|
|
18942
18993
|
}
|
|
18943
18994
|
async artifactBlocks(id) {
|
|
18944
18995
|
return this.#json("GET", ["api", "v1", "artifacts", id, "blocks"]);
|
|
@@ -19040,8 +19091,19 @@ class DispatchClient {
|
|
|
19040
19091
|
}
|
|
19041
19092
|
async#jsonAnswer(method, path, body, query, signal, key) {
|
|
19042
19093
|
const url = this.#url(path, query);
|
|
19043
|
-
|
|
19044
|
-
|
|
19094
|
+
return this.#noRoute(async () => {
|
|
19095
|
+
const response = await this.#send(method, url, body === undefined ? undefined : { content: JSON.stringify(body), type: "application/json" }, undefined, signal, key);
|
|
19096
|
+
return { status: response.status, payload: await this.#response(method, url, response) };
|
|
19097
|
+
}, signal);
|
|
19098
|
+
}
|
|
19099
|
+
#noRoute(attempt, signal) {
|
|
19100
|
+
if (!this.#retryNoRoute)
|
|
19101
|
+
return attempt();
|
|
19102
|
+
return retryNoRoute(attempt, isNoRoute, {
|
|
19103
|
+
exhausted: () => new DispatchNoRouteError,
|
|
19104
|
+
signal: signal === undefined ? this.#signal : AbortSignal.any([this.#signal, signal]),
|
|
19105
|
+
sleep: this.#sleep
|
|
19106
|
+
});
|
|
19045
19107
|
}
|
|
19046
19108
|
async#upload(path, input, key) {
|
|
19047
19109
|
if (input.file === undefined) {
|
|
@@ -19058,11 +19120,13 @@ class DispatchClient {
|
|
|
19058
19120
|
}
|
|
19059
19121
|
async#form(method, path, form, key) {
|
|
19060
19122
|
const url = this.#url(path);
|
|
19061
|
-
|
|
19062
|
-
|
|
19063
|
-
|
|
19064
|
-
|
|
19065
|
-
|
|
19123
|
+
return this.#noRoute(async () => {
|
|
19124
|
+
const encoded = new Response(form);
|
|
19125
|
+
const type = encoded.headers.get("Content-Type") ?? "multipart/form-data";
|
|
19126
|
+
const content = new Uint8Array(await encoded.arrayBuffer());
|
|
19127
|
+
const response = await this.#send(method, url, { content, type }, undefined, undefined, key);
|
|
19128
|
+
return this.#response(method, url, response);
|
|
19129
|
+
});
|
|
19066
19130
|
}
|
|
19067
19131
|
async#send(method, url, body, accept = "application/json", signal, callerKey) {
|
|
19068
19132
|
const headers = { Accept: accept };
|
|
@@ -19357,7 +19421,11 @@ function sessionContext(input, checked) {
|
|
|
19357
19421
|
configUrl,
|
|
19358
19422
|
linkBase: input.config.publicUrl ?? configUrl,
|
|
19359
19423
|
hostSession: input.sessionId?.trim(),
|
|
19360
|
-
newClient: () => new DispatchClient(configUrl, credential, fetchImpl,
|
|
19424
|
+
newClient: () => new DispatchClient(configUrl, credential, fetchImpl, {
|
|
19425
|
+
signal: input.signal,
|
|
19426
|
+
writeRetry: input.writeRetry,
|
|
19427
|
+
sleep: input.sleep
|
|
19428
|
+
})
|
|
19361
19429
|
};
|
|
19362
19430
|
}
|
|
19363
19431
|
|
|
@@ -25317,7 +25385,7 @@ function isSessionAnswerRelation(value) {
|
|
|
25317
25385
|
return Object.hasOwn(RELATION_PHRASES, value);
|
|
25318
25386
|
}
|
|
25319
25387
|
function isNoAnswersRoute(error) {
|
|
25320
|
-
return isNoRoute(error);
|
|
25388
|
+
return isNoRoute(error) || error instanceof DispatchNoRouteError;
|
|
25321
25389
|
}
|
|
25322
25390
|
function renderSessionAnswerItem(item) {
|
|
25323
25391
|
const phrase = isSessionAnswerRelation(item.relation) ? RELATION_PHRASES[item.relation] : item.relation;
|
|
@@ -25518,7 +25586,9 @@ async function readSessionAnswers(options) {
|
|
|
25518
25586
|
}
|
|
25519
25587
|
let read = current.inFlight;
|
|
25520
25588
|
if (read === undefined) {
|
|
25521
|
-
const client = new DispatchClient(url, dispatch.credential, options.fetchImpl ?? fetch
|
|
25589
|
+
const client = new DispatchClient(url, dispatch.credential, options.fetchImpl ?? fetch, {
|
|
25590
|
+
retryNoRoute: false
|
|
25591
|
+
});
|
|
25522
25592
|
const started = client.sessionAnswers(session, {
|
|
25523
25593
|
maxChars: SESSION_ANSWERS_MAX_CHARS,
|
|
25524
25594
|
signal: AbortSignal.timeout(READ_TIMEOUT_MS)
|
package/dist/envoy-channel.js
CHANGED
|
@@ -37302,7 +37302,7 @@ var dispatchToolSpecs = [
|
|
|
37302
37302
|
{
|
|
37303
37303
|
name: "dispatch_read",
|
|
37304
37304
|
example: { issue: "DSP-1" },
|
|
37305
|
-
description: "Read an issue or document summary, targeted ask, or targeted comment reply chain, or the conversation " + "a message belongs to. Do not use it for document contents; use dispatch doc-read instead. Supply ref, issue, " + "issue plus artifact (one of its documents), project plus artifact, or project alone, which lists the project's documents on no issue and nothing more; or message alone, which reads a human's direct message to this session and every " + "reply to it (they belong to no issue). A document summary names its issue, reference, versions and approval. " + "An issue read lists every document, picture and file the issue holds under `Documents:`, each by slug, filename and kind. " + "An anchored comment or ask also says where its quote sits, as `Position:`: the block's path from the top, " + "and in a table the row (0 is the header), the cells before the anchored one, and the column's header; " + "`Position: unavailable (<code>)` when Dispatch could not read the document: `DOC_SERVICE_UNAVAILABLE` " + "(try again shortly), `DOC_SCHEMA` (the document needs repair), `
|
|
37305
|
+
description: "Read an issue or document summary, targeted ask, or targeted comment reply chain, or the conversation " + "a message belongs to. Do not use it for document contents; use dispatch doc-read instead. Supply ref, issue, " + "issue plus artifact (one of its documents), project plus artifact, or project alone, which lists the project's documents on no issue and nothing more; or message alone, which reads a human's direct message to this session and every " + "reply to it (they belong to no issue). A document summary names its issue, reference, versions and approval. " + "An issue read lists every document, picture and file the issue holds under `Documents:`, each by slug, filename and kind. " + "An anchored comment or ask also says where its quote sits, as `Position:`: the block's path from the top, " + "and in a table the row (0 is the header), the cells before the anchored one, and the column's header; " + "`Position: unavailable (<code>)` when Dispatch could not read the document: `DOC_SERVICE_UNAVAILABLE` " + "(try again shortly), `DOC_SCHEMA` (the document needs repair), `DOC_NEWER_CONTENT` (this Dispatch " + "build cannot read an element of the document; try again in one minute), `DOCUMENT_UNLOADABLE` (the " + "document's stored history cannot load; a person decides whether to rebuild it) or `INTERNAL`. " + "An issue read carries a `Progress:` line, `tasks 3/7, children 2/5`: its spec's task-list items " + "(`- [ ]` / `- [x]`, nested lists included) and its direct children, each done of total and each only " + "when it has any (`Progress: none` otherwise). " + "An issue whose spec marks requirements carries one `Coverage:` line per gap, `Coverage: R3 has no check` or " + "`Coverage: R3 has no plan task` (the second only once the issue has a plan document), counting the `check` and " + "`plan_task` blocks of every document of the issue and of its descendants; a spec that marks none reads " + "`Coverage: the spec marks no requirements`. Nothing is refused for a gap. " + `An issue read, and its dispatch://KEY/log, lists the issue's last ${DEFAULT_ISSUE_READ_EVENTS} events, oldest first; ` + "--events N lists the last N, and --all-events every one. " + "A comment reply chain names the comment each nested reply answers as `Answers: <comment id>`. " + "Every read ends with `Referenced by:` (what cites or hangs off this node, each with its dispatch:// address, " + "an excerpt, and when) and `Links:` (what it cites), so tracing provenance is one call. " + "A block read prints `Block:`, `Type:` for a block of a document, `Document:`, every attribute a typed block carries " + "(a `check`'s serves, surface, run, when, negative_control and ci_check; a `plan_task`'s serves and needs), `Changed in version:` " + "and `Text:`, then those two sections; a pinned one adds " + "the block's text at that version and whether it is unchanged, changed or removed since, and an absent block, unpinned, " + "reads `No block <id> in <document>.` " + "The pictures the shown messages, asks and comments embed come back as images you see, newest first, at most 8 " + "and 10 MiB of them per read, each a PNG, JPEG, GIF or WebP of at most 3,750,000 bytes (5 MB of base64); a `Pictures:` section names each " + "one shown, in order, and the rest by reference, for dispatch doc-read. A picture this session was already shown is named, not sent again " + "(every request carries the session's history, and the provider refuses one over 32 MB); dispatch doc-read shows it again. " + OWNER_REFERENCE,
|
|
37306
37306
|
arguments: (z) => ({
|
|
37307
37307
|
issue: z.string().describe(ISSUE_REFERENCE).optional(),
|
|
37308
37308
|
project: z.string().describe("Project key owning the document.").optional(),
|
|
@@ -38001,6 +38001,45 @@ var MessageAcceptedEventPayloadSchema = strictObject({
|
|
|
38001
38001
|
accepted_as: literal("user_turn"),
|
|
38002
38002
|
target: string2()
|
|
38003
38003
|
}).readonly();
|
|
38004
|
+
// ../contracts/src/dispatch-api-requests.ts
|
|
38005
|
+
var NO_ROUTE_MESSAGE_PREFIX = "no route for ";
|
|
38006
|
+
var NO_ROUTE_RETRY_DELAYS_MS = [1000, 2000, 4000];
|
|
38007
|
+
var NO_ROUTE_ROLLING_RELEASE_MESSAGE = "The Dispatch process that answered does not offer this action yet, because a new release of " + "Dispatch is in progress. Try again in one minute.";
|
|
38008
|
+
var sleep = (ms, signal) => {
|
|
38009
|
+
const { promise, resolve, reject } = Promise.withResolvers();
|
|
38010
|
+
if (signal?.aborted) {
|
|
38011
|
+
reject(signal.reason);
|
|
38012
|
+
return promise;
|
|
38013
|
+
}
|
|
38014
|
+
const abort = () => {
|
|
38015
|
+
clearTimeout(timer);
|
|
38016
|
+
reject(signal?.reason);
|
|
38017
|
+
};
|
|
38018
|
+
const timer = setTimeout(() => {
|
|
38019
|
+
signal?.removeEventListener("abort", abort);
|
|
38020
|
+
resolve();
|
|
38021
|
+
}, ms);
|
|
38022
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
38023
|
+
return promise;
|
|
38024
|
+
};
|
|
38025
|
+
function jitteredDelay(ms) {
|
|
38026
|
+
return ms * (0.75 + Math.random() * 0.5);
|
|
38027
|
+
}
|
|
38028
|
+
async function retryNoRoute(attempt, isNoRoute, options) {
|
|
38029
|
+
const wait = options.sleep ?? sleep;
|
|
38030
|
+
for (const delay of [...NO_ROUTE_RETRY_DELAYS_MS, undefined]) {
|
|
38031
|
+
try {
|
|
38032
|
+
return await attempt();
|
|
38033
|
+
} catch (error) {
|
|
38034
|
+
if (!isNoRoute(error))
|
|
38035
|
+
throw error;
|
|
38036
|
+
if (delay === undefined)
|
|
38037
|
+
break;
|
|
38038
|
+
}
|
|
38039
|
+
await wait(jitteredDelay(delay), options.signal);
|
|
38040
|
+
}
|
|
38041
|
+
throw options.exhausted();
|
|
38042
|
+
}
|
|
38004
38043
|
// ../contracts/src/dispatch-api-search.ts
|
|
38005
38044
|
var SEARCH_MEMBERS_EVERY_BUILD_READS = [
|
|
38006
38045
|
"q",
|
|
@@ -42992,7 +43031,13 @@ function isJson(response) {
|
|
|
42992
43031
|
return response.headers.get("content-type")?.includes("application/json") ?? false;
|
|
42993
43032
|
}
|
|
42994
43033
|
function isNoRoute(error) {
|
|
42995
|
-
return error instanceof DispatchServiceError && error.status === 404 && error.code === "NOT_FOUND" && error.message.startsWith(
|
|
43034
|
+
return error instanceof DispatchServiceError && error.status === 404 && error.code === "NOT_FOUND" && error.message.startsWith(NO_ROUTE_MESSAGE_PREFIX);
|
|
43035
|
+
}
|
|
43036
|
+
|
|
43037
|
+
class DispatchNoRouteError extends DispatchServiceError {
|
|
43038
|
+
constructor() {
|
|
43039
|
+
super("NOT_FOUND", 404, NO_ROUTE_ROLLING_RELEASE_MESSAGE);
|
|
43040
|
+
}
|
|
42996
43041
|
}
|
|
42997
43042
|
var ISSUE_EVENTS_PAGE_MAX = 200;
|
|
42998
43043
|
var DISPATCH_TOOL_DEADLINE_MS = 60000;
|
|
@@ -43210,18 +43255,22 @@ function excerpt(text, token) {
|
|
|
43210
43255
|
|
|
43211
43256
|
class DispatchClient {
|
|
43212
43257
|
fetchImpl;
|
|
43213
|
-
writeRetry;
|
|
43214
43258
|
#baseUrl;
|
|
43215
43259
|
#resolvedIssues = new Map;
|
|
43216
43260
|
#signal;
|
|
43217
43261
|
#credential;
|
|
43262
|
+
#sleep;
|
|
43263
|
+
#retryNoRoute;
|
|
43264
|
+
writeRetry;
|
|
43218
43265
|
#madeAt;
|
|
43219
|
-
constructor(baseUrl, credential, fetchImpl = fetch,
|
|
43266
|
+
constructor(baseUrl, credential, fetchImpl = fetch, options = {}) {
|
|
43220
43267
|
this.fetchImpl = fetchImpl;
|
|
43221
|
-
this.writeRetry = writeRetry;
|
|
43222
43268
|
this.#credential = credential;
|
|
43223
43269
|
this.#baseUrl = withoutTrailingSlashes(baseUrl);
|
|
43224
|
-
this.#signal = requestSignal(signal);
|
|
43270
|
+
this.#signal = requestSignal(options.signal);
|
|
43271
|
+
this.writeRetry = options.writeRetry ?? DISPATCH_WRITE_RETRY;
|
|
43272
|
+
this.#sleep = options.sleep ?? sleep;
|
|
43273
|
+
this.#retryNoRoute = options.retryNoRoute ?? true;
|
|
43225
43274
|
this.#madeAt = this.#now();
|
|
43226
43275
|
}
|
|
43227
43276
|
get token() {
|
|
@@ -43376,7 +43425,7 @@ class DispatchClient {
|
|
|
43376
43425
|
try {
|
|
43377
43426
|
return await this.#json("GET", ["api", "v1", "projects", project, "architecture-sources"]);
|
|
43378
43427
|
} catch (error) {
|
|
43379
|
-
if (!
|
|
43428
|
+
if (!(error instanceof DispatchNoRouteError))
|
|
43380
43429
|
throw error;
|
|
43381
43430
|
}
|
|
43382
43431
|
try {
|
|
@@ -43406,7 +43455,7 @@ class DispatchClient {
|
|
|
43406
43455
|
"sync"
|
|
43407
43456
|
]);
|
|
43408
43457
|
} catch (error) {
|
|
43409
|
-
if (!
|
|
43458
|
+
if (!(error instanceof DispatchNoRouteError))
|
|
43410
43459
|
throw error;
|
|
43411
43460
|
}
|
|
43412
43461
|
const source = await this.#json("POST", [
|
|
@@ -43532,13 +43581,15 @@ class DispatchClient {
|
|
|
43532
43581
|
}
|
|
43533
43582
|
async fileVersion(id, version) {
|
|
43534
43583
|
const url = this.#url(["api", "v1", "artifacts", id, "versions", String(version)]);
|
|
43535
|
-
|
|
43536
|
-
|
|
43537
|
-
|
|
43538
|
-
|
|
43539
|
-
|
|
43540
|
-
|
|
43541
|
-
|
|
43584
|
+
return this.#noRoute(async () => {
|
|
43585
|
+
const response = await this.#send("GET", url, undefined, "*/*");
|
|
43586
|
+
if (!response.ok)
|
|
43587
|
+
return this.#response("GET", url, response);
|
|
43588
|
+
return {
|
|
43589
|
+
mime: response.headers.get("Content-Type") ?? "application/octet-stream",
|
|
43590
|
+
bytes: new Uint8Array(await response.arrayBuffer())
|
|
43591
|
+
};
|
|
43592
|
+
});
|
|
43542
43593
|
}
|
|
43543
43594
|
async artifactBlocks(id) {
|
|
43544
43595
|
return this.#json("GET", ["api", "v1", "artifacts", id, "blocks"]);
|
|
@@ -43640,8 +43691,19 @@ class DispatchClient {
|
|
|
43640
43691
|
}
|
|
43641
43692
|
async#jsonAnswer(method, path, body, query, signal, key) {
|
|
43642
43693
|
const url = this.#url(path, query);
|
|
43643
|
-
|
|
43644
|
-
|
|
43694
|
+
return this.#noRoute(async () => {
|
|
43695
|
+
const response = await this.#send(method, url, body === undefined ? undefined : { content: JSON.stringify(body), type: "application/json" }, undefined, signal, key);
|
|
43696
|
+
return { status: response.status, payload: await this.#response(method, url, response) };
|
|
43697
|
+
}, signal);
|
|
43698
|
+
}
|
|
43699
|
+
#noRoute(attempt, signal) {
|
|
43700
|
+
if (!this.#retryNoRoute)
|
|
43701
|
+
return attempt();
|
|
43702
|
+
return retryNoRoute(attempt, isNoRoute, {
|
|
43703
|
+
exhausted: () => new DispatchNoRouteError,
|
|
43704
|
+
signal: signal === undefined ? this.#signal : AbortSignal.any([this.#signal, signal]),
|
|
43705
|
+
sleep: this.#sleep
|
|
43706
|
+
});
|
|
43645
43707
|
}
|
|
43646
43708
|
async#upload(path, input, key) {
|
|
43647
43709
|
if (input.file === undefined) {
|
|
@@ -43658,11 +43720,13 @@ class DispatchClient {
|
|
|
43658
43720
|
}
|
|
43659
43721
|
async#form(method, path, form, key) {
|
|
43660
43722
|
const url = this.#url(path);
|
|
43661
|
-
|
|
43662
|
-
|
|
43663
|
-
|
|
43664
|
-
|
|
43665
|
-
|
|
43723
|
+
return this.#noRoute(async () => {
|
|
43724
|
+
const encoded = new Response(form);
|
|
43725
|
+
const type = encoded.headers.get("Content-Type") ?? "multipart/form-data";
|
|
43726
|
+
const content = new Uint8Array(await encoded.arrayBuffer());
|
|
43727
|
+
const response = await this.#send(method, url, { content, type }, undefined, undefined, key);
|
|
43728
|
+
return this.#response(method, url, response);
|
|
43729
|
+
});
|
|
43666
43730
|
}
|
|
43667
43731
|
async#send(method, url, body, accept = "application/json", signal, callerKey) {
|
|
43668
43732
|
const headers = { Accept: accept };
|
|
@@ -47748,7 +47812,11 @@ function sessionContext(input, checked) {
|
|
|
47748
47812
|
configUrl,
|
|
47749
47813
|
linkBase: input.config.publicUrl ?? configUrl,
|
|
47750
47814
|
hostSession: input.sessionId?.trim(),
|
|
47751
|
-
newClient: () => new DispatchClient(configUrl, credential, fetchImpl,
|
|
47815
|
+
newClient: () => new DispatchClient(configUrl, credential, fetchImpl, {
|
|
47816
|
+
signal: input.signal,
|
|
47817
|
+
writeRetry: input.writeRetry,
|
|
47818
|
+
sleep: input.sleep
|
|
47819
|
+
})
|
|
47752
47820
|
};
|
|
47753
47821
|
}
|
|
47754
47822
|
|
|
@@ -51622,7 +51690,7 @@ function isSessionAnswerRelation(value) {
|
|
|
51622
51690
|
return Object.hasOwn(RELATION_PHRASES, value);
|
|
51623
51691
|
}
|
|
51624
51692
|
function isNoAnswersRoute(error) {
|
|
51625
|
-
return isNoRoute(error);
|
|
51693
|
+
return isNoRoute(error) || error instanceof DispatchNoRouteError;
|
|
51626
51694
|
}
|
|
51627
51695
|
function renderSessionAnswerItem(item) {
|
|
51628
51696
|
const phrase = isSessionAnswerRelation(item.relation) ? RELATION_PHRASES[item.relation] : item.relation;
|
|
@@ -51823,7 +51891,9 @@ async function readSessionAnswers(options) {
|
|
|
51823
51891
|
}
|
|
51824
51892
|
let read = current.inFlight;
|
|
51825
51893
|
if (read === undefined) {
|
|
51826
|
-
const client = new DispatchClient(url, dispatch.credential, options.fetchImpl ?? fetch
|
|
51894
|
+
const client = new DispatchClient(url, dispatch.credential, options.fetchImpl ?? fetch, {
|
|
51895
|
+
retryNoRoute: false
|
|
51896
|
+
});
|
|
51827
51897
|
const started = client.sessionAnswers(session, {
|
|
51828
51898
|
maxChars: SESSION_ANSWERS_MAX_CHARS,
|
|
51829
51899
|
signal: AbortSignal.timeout(READ_TIMEOUT_MS)
|
|
@@ -56426,7 +56496,7 @@ var import_nats2 = __toESM(require_mod4(), 1);
|
|
|
56426
56496
|
|
|
56427
56497
|
// package.json
|
|
56428
56498
|
var name = "@sjawhar/claude-envoy";
|
|
56429
|
-
var version2 = "2.
|
|
56499
|
+
var version2 = "2.23.1";
|
|
56430
56500
|
var legion = {
|
|
56431
56501
|
daemonApiVersion: 133
|
|
56432
56502
|
};
|
|
@@ -61287,7 +61357,9 @@ async function runEnvoyChannelServer() {
|
|
|
61287
61357
|
const options = {
|
|
61288
61358
|
dispatch: (ms) => {
|
|
61289
61359
|
const active = activeDispatchSettings(sessionDispatchSettings(configFile, process.env, { cwd: directory }).dispatch);
|
|
61290
|
-
return active === null ? undefined : new DispatchClient(active.url, active.credential, fetch,
|
|
61360
|
+
return active === null ? undefined : new DispatchClient(active.url, active.credential, fetch, {
|
|
61361
|
+
signal: AbortSignal.timeout(ms)
|
|
61362
|
+
});
|
|
61291
61363
|
},
|
|
61292
61364
|
effortPicked: (effort) => agentStream?.pickedEffort(effort),
|
|
61293
61365
|
refreshSettings: () => agentStream?.refresh(),
|
package/dist/session-hook.js
CHANGED
|
@@ -14649,7 +14649,7 @@ var dispatchToolSpecs = [
|
|
|
14649
14649
|
{
|
|
14650
14650
|
name: "dispatch_read",
|
|
14651
14651
|
example: { issue: "DSP-1" },
|
|
14652
|
-
description: "Read an issue or document summary, targeted ask, or targeted comment reply chain, or the conversation " + "a message belongs to. Do not use it for document contents; use dispatch doc-read instead. Supply ref, issue, " + "issue plus artifact (one of its documents), project plus artifact, or project alone, which lists the project's documents on no issue and nothing more; or message alone, which reads a human's direct message to this session and every " + "reply to it (they belong to no issue). A document summary names its issue, reference, versions and approval. " + "An issue read lists every document, picture and file the issue holds under `Documents:`, each by slug, filename and kind. " + "An anchored comment or ask also says where its quote sits, as `Position:`: the block's path from the top, " + "and in a table the row (0 is the header), the cells before the anchored one, and the column's header; " + "`Position: unavailable (<code>)` when Dispatch could not read the document: `DOC_SERVICE_UNAVAILABLE` " + "(try again shortly), `DOC_SCHEMA` (the document needs repair), `
|
|
14652
|
+
description: "Read an issue or document summary, targeted ask, or targeted comment reply chain, or the conversation " + "a message belongs to. Do not use it for document contents; use dispatch doc-read instead. Supply ref, issue, " + "issue plus artifact (one of its documents), project plus artifact, or project alone, which lists the project's documents on no issue and nothing more; or message alone, which reads a human's direct message to this session and every " + "reply to it (they belong to no issue). A document summary names its issue, reference, versions and approval. " + "An issue read lists every document, picture and file the issue holds under `Documents:`, each by slug, filename and kind. " + "An anchored comment or ask also says where its quote sits, as `Position:`: the block's path from the top, " + "and in a table the row (0 is the header), the cells before the anchored one, and the column's header; " + "`Position: unavailable (<code>)` when Dispatch could not read the document: `DOC_SERVICE_UNAVAILABLE` " + "(try again shortly), `DOC_SCHEMA` (the document needs repair), `DOC_NEWER_CONTENT` (this Dispatch " + "build cannot read an element of the document; try again in one minute), `DOCUMENT_UNLOADABLE` (the " + "document's stored history cannot load; a person decides whether to rebuild it) or `INTERNAL`. " + "An issue read carries a `Progress:` line, `tasks 3/7, children 2/5`: its spec's task-list items " + "(`- [ ]` / `- [x]`, nested lists included) and its direct children, each done of total and each only " + "when it has any (`Progress: none` otherwise). " + "An issue whose spec marks requirements carries one `Coverage:` line per gap, `Coverage: R3 has no check` or " + "`Coverage: R3 has no plan task` (the second only once the issue has a plan document), counting the `check` and " + "`plan_task` blocks of every document of the issue and of its descendants; a spec that marks none reads " + "`Coverage: the spec marks no requirements`. Nothing is refused for a gap. " + `An issue read, and its dispatch://KEY/log, lists the issue's last ${DEFAULT_ISSUE_READ_EVENTS} events, oldest first; ` + "--events N lists the last N, and --all-events every one. " + "A comment reply chain names the comment each nested reply answers as `Answers: <comment id>`. " + "Every read ends with `Referenced by:` (what cites or hangs off this node, each with its dispatch:// address, " + "an excerpt, and when) and `Links:` (what it cites), so tracing provenance is one call. " + "A block read prints `Block:`, `Type:` for a block of a document, `Document:`, every attribute a typed block carries " + "(a `check`'s serves, surface, run, when, negative_control and ci_check; a `plan_task`'s serves and needs), `Changed in version:` " + "and `Text:`, then those two sections; a pinned one adds " + "the block's text at that version and whether it is unchanged, changed or removed since, and an absent block, unpinned, " + "reads `No block <id> in <document>.` " + "The pictures the shown messages, asks and comments embed come back as images you see, newest first, at most 8 " + "and 10 MiB of them per read, each a PNG, JPEG, GIF or WebP of at most 3,750,000 bytes (5 MB of base64); a `Pictures:` section names each " + "one shown, in order, and the rest by reference, for dispatch doc-read. A picture this session was already shown is named, not sent again " + "(every request carries the session's history, and the provider refuses one over 32 MB); dispatch doc-read shows it again. " + OWNER_REFERENCE,
|
|
14653
14653
|
arguments: (z) => ({
|
|
14654
14654
|
issue: z.string().describe(ISSUE_REFERENCE).optional(),
|
|
14655
14655
|
project: z.string().describe("Project key owning the document.").optional(),
|
|
@@ -15348,6 +15348,45 @@ var MessageAcceptedEventPayloadSchema = strictObject({
|
|
|
15348
15348
|
accepted_as: literal("user_turn"),
|
|
15349
15349
|
target: string2()
|
|
15350
15350
|
}).readonly();
|
|
15351
|
+
// ../contracts/src/dispatch-api-requests.ts
|
|
15352
|
+
var NO_ROUTE_MESSAGE_PREFIX = "no route for ";
|
|
15353
|
+
var NO_ROUTE_RETRY_DELAYS_MS = [1000, 2000, 4000];
|
|
15354
|
+
var NO_ROUTE_ROLLING_RELEASE_MESSAGE = "The Dispatch process that answered does not offer this action yet, because a new release of " + "Dispatch is in progress. Try again in one minute.";
|
|
15355
|
+
var sleep = (ms, signal) => {
|
|
15356
|
+
const { promise, resolve, reject } = Promise.withResolvers();
|
|
15357
|
+
if (signal?.aborted) {
|
|
15358
|
+
reject(signal.reason);
|
|
15359
|
+
return promise;
|
|
15360
|
+
}
|
|
15361
|
+
const abort = () => {
|
|
15362
|
+
clearTimeout(timer);
|
|
15363
|
+
reject(signal?.reason);
|
|
15364
|
+
};
|
|
15365
|
+
const timer = setTimeout(() => {
|
|
15366
|
+
signal?.removeEventListener("abort", abort);
|
|
15367
|
+
resolve();
|
|
15368
|
+
}, ms);
|
|
15369
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
15370
|
+
return promise;
|
|
15371
|
+
};
|
|
15372
|
+
function jitteredDelay(ms) {
|
|
15373
|
+
return ms * (0.75 + Math.random() * 0.5);
|
|
15374
|
+
}
|
|
15375
|
+
async function retryNoRoute(attempt, isNoRoute, options) {
|
|
15376
|
+
const wait = options.sleep ?? sleep;
|
|
15377
|
+
for (const delay of [...NO_ROUTE_RETRY_DELAYS_MS, undefined]) {
|
|
15378
|
+
try {
|
|
15379
|
+
return await attempt();
|
|
15380
|
+
} catch (error) {
|
|
15381
|
+
if (!isNoRoute(error))
|
|
15382
|
+
throw error;
|
|
15383
|
+
if (delay === undefined)
|
|
15384
|
+
break;
|
|
15385
|
+
}
|
|
15386
|
+
await wait(jitteredDelay(delay), options.signal);
|
|
15387
|
+
}
|
|
15388
|
+
throw options.exhausted();
|
|
15389
|
+
}
|
|
15351
15390
|
// ../contracts/src/dispatch-api-search.ts
|
|
15352
15391
|
var SEARCH_MEMBERS_EVERY_BUILD_READS = [
|
|
15353
15392
|
"q",
|
|
@@ -18151,7 +18190,13 @@ function isJson(response) {
|
|
|
18151
18190
|
return response.headers.get("content-type")?.includes("application/json") ?? false;
|
|
18152
18191
|
}
|
|
18153
18192
|
function isNoRoute(error) {
|
|
18154
|
-
return error instanceof DispatchServiceError && error.status === 404 && error.code === "NOT_FOUND" && error.message.startsWith(
|
|
18193
|
+
return error instanceof DispatchServiceError && error.status === 404 && error.code === "NOT_FOUND" && error.message.startsWith(NO_ROUTE_MESSAGE_PREFIX);
|
|
18194
|
+
}
|
|
18195
|
+
|
|
18196
|
+
class DispatchNoRouteError extends DispatchServiceError {
|
|
18197
|
+
constructor() {
|
|
18198
|
+
super("NOT_FOUND", 404, NO_ROUTE_ROLLING_RELEASE_MESSAGE);
|
|
18199
|
+
}
|
|
18155
18200
|
}
|
|
18156
18201
|
var ISSUE_EVENTS_PAGE_MAX = 200;
|
|
18157
18202
|
var DISPATCH_TOOL_DEADLINE_MS = 60000;
|
|
@@ -18369,18 +18414,22 @@ function excerpt(text, token) {
|
|
|
18369
18414
|
|
|
18370
18415
|
class DispatchClient {
|
|
18371
18416
|
fetchImpl;
|
|
18372
|
-
writeRetry;
|
|
18373
18417
|
#baseUrl;
|
|
18374
18418
|
#resolvedIssues = new Map;
|
|
18375
18419
|
#signal;
|
|
18376
18420
|
#credential;
|
|
18421
|
+
#sleep;
|
|
18422
|
+
#retryNoRoute;
|
|
18423
|
+
writeRetry;
|
|
18377
18424
|
#madeAt;
|
|
18378
|
-
constructor(baseUrl, credential, fetchImpl = fetch,
|
|
18425
|
+
constructor(baseUrl, credential, fetchImpl = fetch, options = {}) {
|
|
18379
18426
|
this.fetchImpl = fetchImpl;
|
|
18380
|
-
this.writeRetry = writeRetry;
|
|
18381
18427
|
this.#credential = credential;
|
|
18382
18428
|
this.#baseUrl = withoutTrailingSlashes(baseUrl);
|
|
18383
|
-
this.#signal = requestSignal(signal);
|
|
18429
|
+
this.#signal = requestSignal(options.signal);
|
|
18430
|
+
this.writeRetry = options.writeRetry ?? DISPATCH_WRITE_RETRY;
|
|
18431
|
+
this.#sleep = options.sleep ?? sleep;
|
|
18432
|
+
this.#retryNoRoute = options.retryNoRoute ?? true;
|
|
18384
18433
|
this.#madeAt = this.#now();
|
|
18385
18434
|
}
|
|
18386
18435
|
get token() {
|
|
@@ -18535,7 +18584,7 @@ class DispatchClient {
|
|
|
18535
18584
|
try {
|
|
18536
18585
|
return await this.#json("GET", ["api", "v1", "projects", project, "architecture-sources"]);
|
|
18537
18586
|
} catch (error) {
|
|
18538
|
-
if (!
|
|
18587
|
+
if (!(error instanceof DispatchNoRouteError))
|
|
18539
18588
|
throw error;
|
|
18540
18589
|
}
|
|
18541
18590
|
try {
|
|
@@ -18565,7 +18614,7 @@ class DispatchClient {
|
|
|
18565
18614
|
"sync"
|
|
18566
18615
|
]);
|
|
18567
18616
|
} catch (error) {
|
|
18568
|
-
if (!
|
|
18617
|
+
if (!(error instanceof DispatchNoRouteError))
|
|
18569
18618
|
throw error;
|
|
18570
18619
|
}
|
|
18571
18620
|
const source = await this.#json("POST", [
|
|
@@ -18691,13 +18740,15 @@ class DispatchClient {
|
|
|
18691
18740
|
}
|
|
18692
18741
|
async fileVersion(id, version) {
|
|
18693
18742
|
const url = this.#url(["api", "v1", "artifacts", id, "versions", String(version)]);
|
|
18694
|
-
|
|
18695
|
-
|
|
18696
|
-
|
|
18697
|
-
|
|
18698
|
-
|
|
18699
|
-
|
|
18700
|
-
|
|
18743
|
+
return this.#noRoute(async () => {
|
|
18744
|
+
const response = await this.#send("GET", url, undefined, "*/*");
|
|
18745
|
+
if (!response.ok)
|
|
18746
|
+
return this.#response("GET", url, response);
|
|
18747
|
+
return {
|
|
18748
|
+
mime: response.headers.get("Content-Type") ?? "application/octet-stream",
|
|
18749
|
+
bytes: new Uint8Array(await response.arrayBuffer())
|
|
18750
|
+
};
|
|
18751
|
+
});
|
|
18701
18752
|
}
|
|
18702
18753
|
async artifactBlocks(id) {
|
|
18703
18754
|
return this.#json("GET", ["api", "v1", "artifacts", id, "blocks"]);
|
|
@@ -18799,8 +18850,19 @@ class DispatchClient {
|
|
|
18799
18850
|
}
|
|
18800
18851
|
async#jsonAnswer(method, path, body, query, signal, key) {
|
|
18801
18852
|
const url = this.#url(path, query);
|
|
18802
|
-
|
|
18803
|
-
|
|
18853
|
+
return this.#noRoute(async () => {
|
|
18854
|
+
const response = await this.#send(method, url, body === undefined ? undefined : { content: JSON.stringify(body), type: "application/json" }, undefined, signal, key);
|
|
18855
|
+
return { status: response.status, payload: await this.#response(method, url, response) };
|
|
18856
|
+
}, signal);
|
|
18857
|
+
}
|
|
18858
|
+
#noRoute(attempt, signal) {
|
|
18859
|
+
if (!this.#retryNoRoute)
|
|
18860
|
+
return attempt();
|
|
18861
|
+
return retryNoRoute(attempt, isNoRoute, {
|
|
18862
|
+
exhausted: () => new DispatchNoRouteError,
|
|
18863
|
+
signal: signal === undefined ? this.#signal : AbortSignal.any([this.#signal, signal]),
|
|
18864
|
+
sleep: this.#sleep
|
|
18865
|
+
});
|
|
18804
18866
|
}
|
|
18805
18867
|
async#upload(path, input, key) {
|
|
18806
18868
|
if (input.file === undefined) {
|
|
@@ -18817,11 +18879,13 @@ class DispatchClient {
|
|
|
18817
18879
|
}
|
|
18818
18880
|
async#form(method, path, form, key) {
|
|
18819
18881
|
const url = this.#url(path);
|
|
18820
|
-
|
|
18821
|
-
|
|
18822
|
-
|
|
18823
|
-
|
|
18824
|
-
|
|
18882
|
+
return this.#noRoute(async () => {
|
|
18883
|
+
const encoded = new Response(form);
|
|
18884
|
+
const type = encoded.headers.get("Content-Type") ?? "multipart/form-data";
|
|
18885
|
+
const content = new Uint8Array(await encoded.arrayBuffer());
|
|
18886
|
+
const response = await this.#send(method, url, { content, type }, undefined, undefined, key);
|
|
18887
|
+
return this.#response(method, url, response);
|
|
18888
|
+
});
|
|
18825
18889
|
}
|
|
18826
18890
|
async#send(method, url, body, accept = "application/json", signal, callerKey) {
|
|
18827
18891
|
const headers = { Accept: accept };
|
|
@@ -20350,7 +20414,11 @@ function sessionContext(input, checked) {
|
|
|
20350
20414
|
configUrl,
|
|
20351
20415
|
linkBase: input.config.publicUrl ?? configUrl,
|
|
20352
20416
|
hostSession: input.sessionId?.trim(),
|
|
20353
|
-
newClient: () => new DispatchClient(configUrl, credential, fetchImpl,
|
|
20417
|
+
newClient: () => new DispatchClient(configUrl, credential, fetchImpl, {
|
|
20418
|
+
signal: input.signal,
|
|
20419
|
+
writeRetry: input.writeRetry,
|
|
20420
|
+
sleep: input.sleep
|
|
20421
|
+
})
|
|
20354
20422
|
};
|
|
20355
20423
|
}
|
|
20356
20424
|
|
|
@@ -24321,7 +24389,7 @@ function isSessionAnswerRelation(value) {
|
|
|
24321
24389
|
return Object.hasOwn(RELATION_PHRASES, value);
|
|
24322
24390
|
}
|
|
24323
24391
|
function isNoAnswersRoute(error) {
|
|
24324
|
-
return isNoRoute(error);
|
|
24392
|
+
return isNoRoute(error) || error instanceof DispatchNoRouteError;
|
|
24325
24393
|
}
|
|
24326
24394
|
function renderSessionAnswerItem(item) {
|
|
24327
24395
|
const phrase = isSessionAnswerRelation(item.relation) ? RELATION_PHRASES[item.relation] : item.relation;
|
|
@@ -24522,7 +24590,9 @@ async function readSessionAnswers(options) {
|
|
|
24522
24590
|
}
|
|
24523
24591
|
let read = current.inFlight;
|
|
24524
24592
|
if (read === undefined) {
|
|
24525
|
-
const client = new DispatchClient(url, dispatch.credential, options.fetchImpl ?? fetch
|
|
24593
|
+
const client = new DispatchClient(url, dispatch.credential, options.fetchImpl ?? fetch, {
|
|
24594
|
+
retryNoRoute: false
|
|
24595
|
+
});
|
|
24526
24596
|
const started = client.sessionAnswers(session, {
|
|
24527
24597
|
maxChars: SESSION_ANSWERS_MAX_CHARS,
|
|
24528
24598
|
signal: AbortSignal.timeout(READ_TIMEOUT_MS)
|
|
@@ -28603,7 +28673,9 @@ async function openAsks(raw) {
|
|
|
28603
28673
|
`);
|
|
28604
28674
|
if (dispatch.enabled) {
|
|
28605
28675
|
try {
|
|
28606
|
-
const snapshot = await new DispatchClient(dispatch.url, dispatch.credential, fetch,
|
|
28676
|
+
const snapshot = await new DispatchClient(dispatch.url, dispatch.credential, fetch, {
|
|
28677
|
+
signal: AbortSignal.timeout(OPEN_ASKS_TIMEOUT_MS)
|
|
28678
|
+
}).openAsks(input.session_id);
|
|
28607
28679
|
process.stdout.write(`Dispatch authored-ask summary:
|
|
28608
28680
|
${formatOpenAsksSummary(snapshot, dispatch.publicUrl ?? dispatch.url)}
|
|
28609
28681
|
`);
|
package/hooks/session-hook.ts
CHANGED
|
@@ -307,12 +307,9 @@ async function openAsks(raw: unknown): Promise<void> {
|
|
|
307
307
|
for (const warning of warnings) process.stdout.write(`envoy: ${warning}\n`)
|
|
308
308
|
if (dispatch.enabled) {
|
|
309
309
|
try {
|
|
310
|
-
const snapshot = await new DispatchClient(
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
fetch,
|
|
314
|
-
AbortSignal.timeout(OPEN_ASKS_TIMEOUT_MS),
|
|
315
|
-
).openAsks(input.session_id)
|
|
310
|
+
const snapshot = await new DispatchClient(dispatch.url, dispatch.credential, fetch, {
|
|
311
|
+
signal: AbortSignal.timeout(OPEN_ASKS_TIMEOUT_MS),
|
|
312
|
+
}).openAsks(input.session_id)
|
|
316
313
|
process.stdout.write(
|
|
317
314
|
`Dispatch authored-ask summary:\n${formatOpenAsksSummary(snapshot, dispatch.publicUrl ?? dispatch.url)}\n`,
|
|
318
315
|
)
|
|
@@ -17,7 +17,7 @@ and 7 (a conflict, the hand-over, the close) is in
|
|
|
17
17
|
| `carried-gate-opened` | Only a root whose catch-up said `carried` gets it. Its `version` and `reason`: a human approved the old root's spec document at `version`, which opened the gate this root carried; the daemon has started any child waiting on it. It names no step: the carry brings the old root's gate records, and the catch-up reports every gated step the carry did not bring as unregistered, so register each of those on this issue's own document for that step (`skill://legion-architect/references/design-gate.md`). It is not `design-approved`: do not proceed to section 2 or release a wave because of it, and start nothing. |
|
|
18
18
|
| `child-status` | A child of your tree left the workflow or re-entered it, or joined your tree from the admission queue or from a closed tree; the reason names the child and its new status, or reads `<KEY> joined the tree of <ROOT> from the admission queue`, or, for a member of a closed tree your release took, `<KEY> joined the tree of <ROOT> from the closed tree of <OLD ROOT>`. `todo` (a human's move, your `release_children`, or your `rerun_child`) means it runs again under your tree from planning, and the daemon starts it; you start nothing. A child held for a blocker starts the same way once nothing holds it, and the reason, naming it and its root, says what cleared the hold: its last blocker's close, naming the issues it waited on, now done, or a person or you taking its blocked-by links off; you start nothing for it either. `backlog`, `icebox` or `triage` (a human's move, or your `park_child`) means the daemon has suspended its workers, and it advances no further until it is set back to `todo`. A `park_child` and then a `rerun_child` is that child's restart and not a park, because the daemon refuses `rerun_child` on a child whose phase is not `done` (`CHILD_RUNNING`, `packages/daemon/internal/api/architect.go`). Joined from the admission queue means a root that waited for a slot and never ran, which a person made a child of your tree or your `release_children` adopted, now runs in your tree with no architect of its own and takes an admission slot of its own when its work starts, from planning when it is `todo` and parked otherwise; one that waits on an unfinished blocked-by issue is held for that blocker like any other child, and starts when nothing holds it; you start nothing. A reason saying an issue is beneath an ancestor whose reviewed head the daemon has already accepted is a person's `todo` the daemon recorded and holds at `admitted`: nothing starts it until that ancestor closes, and a `request_backward_move` of the ancestor is what runs it under the ancestor now. What the rest of the tree does is your decision. When a park leaves no child that an issue in `accepting` waits on, run that issue's last round (`skill://legion-architect/references/acceptance.md`). |
|
|
19
19
|
| `child-closed` | Read the child completion and remaining open children. Re-scope open work, and take out with `park_child` each child the result makes unneeded (first take its link off each sibling that waits on it, or park that sibling too when its work ends with the parked child, under the same rule, as section 2 says) and say why with `dispatch comment`. Park a child only when a person asked for that move, or when the work is done, folded into another issue or no longer needed. Then file any new child the result calls for, after the red-team check in `skill://legion-architect/references/decomposition.md`, and release it at once with `release_children`, blocked by what it builds on (section 2). When a worker waits on this child for a missing surface (see `phase-finished`), tell it to continue with `envoy_publish` to its role topic. The last child's close is not the end-game (section 3). When it was the last child an issue in `accepting` waits on, run that issue's last round (`skill://legion-architect/references/acceptance.md`). |
|
|
20
|
-
| `child-release-stalled` | Its `reason` names a child your `release_children` released that your tree has not recorded, its parent, and why, one of three: the parent's release has not reached the daemon after three tries; or GitHub did not answer the App installation read of a repository on the child's parent chain, and the release left the child unrecorded because a parent on that chain is not `todo`, or did not write the child `todo` because its parent is not recorded; or the daemon's recovery of such a repository, once GitHub answered, still left children unrecorded (one notice per tree lists them all, each with its parent). Read the parent's record with the `legion` tool's `read_record` (`issue` the parent); release the parent first when the `reason` says to, then run `release_children` for the child again once the parent is recorded in your tree, and tell the controller if it never is. |
|
|
20
|
+
| `child-release-stalled` | Its `reason` names a child your `release_children` released that your tree has not recorded, its parent, and why, one of three: the parent's release has not reached the daemon after three tries; or GitHub did not answer the App installation read, or the default-branch read past GitHub's rate limit, of a repository on the child's parent chain, and the release left the child unrecorded because a parent on that chain is not `todo`, or did not write the child `todo` because its parent is not recorded; or the daemon's recovery of such a repository, once GitHub answered, still left children unrecorded (one notice per tree lists them all, each with its parent). Read the parent's record with the `legion` tool's `read_record` (`issue` the parent); release the parent first when the `reason` says to, then run `release_children` for the child again once the parent is recorded in your tree, and tell the controller if it never is. |
|
|
21
21
|
| `child-not-recorded` | Its `reason` names a child your tree did not record and why: its repository resolves to none (neither it nor an ancestor names one, and the project has no default), or to one not mapped to the project, or to one the daemon leaves out for a missing GitHub App. The daemon said why on the child too. Set the child's repository to one of the project's (`dispatch issue-update --repo owner/name`), then release it again with `release_children`; tell the controller when the repository it needs is not served. |
|
|
22
22
|
| `children-first` | An issue of your tree starts no phase of its own while Dispatch shows an open child under it, a child you filed and have not released included. The reason names the parent and each open child with the Dispatch status that holds it, and each cycle it found (a child `blocked_by` an issue above it on its own parent chain, which only a person taking that link off ends: open a `dispatch ask`). It comes once per issue and run of its tree. Release every child that should run. Park a child only when a person asked for that move, or when the work is done, folded into another issue or no longer needed, and cite that reason in a comment on the child. A released child, a held one included, stays under the parent, because the parent's wait ends when that child leaves the workflow. Move out from under the parent only a child you have not released and that should not run now. Move it under another issue of the same tree that has started a phase and has not reached `accepting`, and never under an issue it waits on: that move ends this wait and leaves the child in the tree (section 3). After the move, ask the person on the root (`dispatch ask`) when that child's work should run or stop: release it when they say to run it; when they say to stop it, close it, or move it to `icebox` under the rule when they say its work should wait, citing their answer. Hold the acceptance of the issue you moved it under, and of the root, until they answer. Never give such a child the `legion` label, and never clear its parent while the tree is live, because such a child would then run nowhere (section 3). Where the tree holds no issue to move the child under, ask the person. The parent's first phase can start once the last open child has left the workflow; a parent the daemon has already started gives its admission slot back while it waits for its children, and takes one again by itself; nothing of its work stops meanwhile, and you do nothing for it (https://cybermonklabs.github.io/legion/legion/concepts/#admission-and-the-legion-label, which also names the three roots that keep their slot through a wait); a parent the daemon has not started waits in the line for a slot. You start nothing. |
|
|
23
23
|
| `design-approved` | Its `version` is the approved one, and it names no step: under more than one gated step, read `gatedSteps` in your own record (the `legion` tool's `read_record`) to see which step that version opened and whether another still holds the tree. A human approved the document of one gated step at its current version; that step is open. Proceed to section 2 once every gated step is `approved` — except on a root whose catch-up said `handed_over`: its workers already run their phases, so start nothing. One whose `version` is the version a human's own answer to a decision block wrote, after an earlier approval (Dispatch carried that approval to it, "After approval" in `skill://legion-architect/references/design-gate.md`), opens nothing new: carry on, and release no wave because of it. A root that was waiting on a question in `awaiting_person` gets no such notice: the task that resumes it says "Your spec is approved at version N and the design gate is open: this resume is your design-approved wake", and that resume is this wake — proceed to section 2 on it. |
|
package/package.json
CHANGED
|
@@ -2261,7 +2261,9 @@ export async function runEnvoyChannelServer(): Promise<void> {
|
|
|
2261
2261
|
)
|
|
2262
2262
|
return active === null
|
|
2263
2263
|
? undefined
|
|
2264
|
-
: new DispatchClient(active.url, active.credential, fetch,
|
|
2264
|
+
: new DispatchClient(active.url, active.credential, fetch, {
|
|
2265
|
+
signal: AbortSignal.timeout(ms),
|
|
2266
|
+
})
|
|
2265
2267
|
},
|
|
2266
2268
|
effortPicked: (effort) => agentStream?.pickedEffort(effort),
|
|
2267
2269
|
refreshSettings: () => agentStream?.refresh(),
|