@sjawhar/pi-envoy 17.20.0 → 17.22.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/dist/dispatch.js +92 -24
- package/dist/envoy.js +92 -26
- package/package.json +1 -1
package/dist/dispatch.js
CHANGED
|
@@ -15568,7 +15568,7 @@ var dispatchToolSpecs = [
|
|
|
15568
15568
|
{
|
|
15569
15569
|
name: "dispatch_read",
|
|
15570
15570
|
example: { issue: "DSP-1" },
|
|
15571
|
-
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), `
|
|
15571
|
+
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,
|
|
15572
15572
|
arguments: (z) => ({
|
|
15573
15573
|
issue: z.string().describe(ISSUE_REFERENCE).optional(),
|
|
15574
15574
|
project: z.string().describe("Project key owning the document.").optional(),
|
|
@@ -16266,6 +16266,45 @@ var MessageAcceptedEventPayloadSchema = strictObject({
|
|
|
16266
16266
|
accepted_as: literal("user_turn"),
|
|
16267
16267
|
target: string2()
|
|
16268
16268
|
}).readonly();
|
|
16269
|
+
// ../contracts/src/dispatch-api-requests.ts
|
|
16270
|
+
var NO_ROUTE_MESSAGE_PREFIX = "no route for ";
|
|
16271
|
+
var NO_ROUTE_RETRY_DELAYS_MS = [1000, 2000, 4000];
|
|
16272
|
+
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.";
|
|
16273
|
+
var sleep = (ms, signal) => {
|
|
16274
|
+
const { promise, resolve, reject } = Promise.withResolvers();
|
|
16275
|
+
if (signal?.aborted) {
|
|
16276
|
+
reject(signal.reason);
|
|
16277
|
+
return promise;
|
|
16278
|
+
}
|
|
16279
|
+
const abort = () => {
|
|
16280
|
+
clearTimeout(timer);
|
|
16281
|
+
reject(signal?.reason);
|
|
16282
|
+
};
|
|
16283
|
+
const timer = setTimeout(() => {
|
|
16284
|
+
signal?.removeEventListener("abort", abort);
|
|
16285
|
+
resolve();
|
|
16286
|
+
}, ms);
|
|
16287
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
16288
|
+
return promise;
|
|
16289
|
+
};
|
|
16290
|
+
function jitteredDelay(ms) {
|
|
16291
|
+
return ms * (0.75 + Math.random() * 0.5);
|
|
16292
|
+
}
|
|
16293
|
+
async function retryNoRoute(attempt, isNoRoute, options) {
|
|
16294
|
+
const wait = options.sleep ?? sleep;
|
|
16295
|
+
for (const delay of [...NO_ROUTE_RETRY_DELAYS_MS, undefined]) {
|
|
16296
|
+
try {
|
|
16297
|
+
return await attempt();
|
|
16298
|
+
} catch (error) {
|
|
16299
|
+
if (!isNoRoute(error))
|
|
16300
|
+
throw error;
|
|
16301
|
+
if (delay === undefined)
|
|
16302
|
+
break;
|
|
16303
|
+
}
|
|
16304
|
+
await wait(jitteredDelay(delay), options.signal);
|
|
16305
|
+
}
|
|
16306
|
+
throw options.exhausted();
|
|
16307
|
+
}
|
|
16269
16308
|
// ../contracts/src/dispatch-api-search.ts
|
|
16270
16309
|
var SEARCH_MEMBERS_EVERY_BUILD_READS = [
|
|
16271
16310
|
"q",
|
|
@@ -18259,7 +18298,13 @@ function isJson(response) {
|
|
|
18259
18298
|
return response.headers.get("content-type")?.includes("application/json") ?? false;
|
|
18260
18299
|
}
|
|
18261
18300
|
function isNoRoute(error) {
|
|
18262
|
-
return error instanceof DispatchServiceError && error.status === 404 && error.code === "NOT_FOUND" && error.message.startsWith(
|
|
18301
|
+
return error instanceof DispatchServiceError && error.status === 404 && error.code === "NOT_FOUND" && error.message.startsWith(NO_ROUTE_MESSAGE_PREFIX);
|
|
18302
|
+
}
|
|
18303
|
+
|
|
18304
|
+
class DispatchNoRouteError extends DispatchServiceError {
|
|
18305
|
+
constructor() {
|
|
18306
|
+
super("NOT_FOUND", 404, NO_ROUTE_ROLLING_RELEASE_MESSAGE);
|
|
18307
|
+
}
|
|
18263
18308
|
}
|
|
18264
18309
|
var ISSUE_EVENTS_PAGE_MAX = 200;
|
|
18265
18310
|
var DISPATCH_TOOL_DEADLINE_MS = 60000;
|
|
@@ -18477,18 +18522,22 @@ function excerpt(text, token) {
|
|
|
18477
18522
|
|
|
18478
18523
|
class DispatchClient {
|
|
18479
18524
|
fetchImpl;
|
|
18480
|
-
writeRetry;
|
|
18481
18525
|
#baseUrl;
|
|
18482
18526
|
#resolvedIssues = new Map;
|
|
18483
18527
|
#signal;
|
|
18484
18528
|
#credential;
|
|
18529
|
+
#sleep;
|
|
18530
|
+
#retryNoRoute;
|
|
18531
|
+
writeRetry;
|
|
18485
18532
|
#madeAt;
|
|
18486
|
-
constructor(baseUrl, credential, fetchImpl = fetch,
|
|
18533
|
+
constructor(baseUrl, credential, fetchImpl = fetch, options = {}) {
|
|
18487
18534
|
this.fetchImpl = fetchImpl;
|
|
18488
|
-
this.writeRetry = writeRetry;
|
|
18489
18535
|
this.#credential = credential;
|
|
18490
18536
|
this.#baseUrl = withoutTrailingSlashes(baseUrl);
|
|
18491
|
-
this.#signal = requestSignal(signal);
|
|
18537
|
+
this.#signal = requestSignal(options.signal);
|
|
18538
|
+
this.writeRetry = options.writeRetry ?? DISPATCH_WRITE_RETRY;
|
|
18539
|
+
this.#sleep = options.sleep ?? sleep;
|
|
18540
|
+
this.#retryNoRoute = options.retryNoRoute ?? true;
|
|
18492
18541
|
this.#madeAt = this.#now();
|
|
18493
18542
|
}
|
|
18494
18543
|
get token() {
|
|
@@ -18643,7 +18692,7 @@ class DispatchClient {
|
|
|
18643
18692
|
try {
|
|
18644
18693
|
return await this.#json("GET", ["api", "v1", "projects", project, "architecture-sources"]);
|
|
18645
18694
|
} catch (error) {
|
|
18646
|
-
if (!
|
|
18695
|
+
if (!(error instanceof DispatchNoRouteError))
|
|
18647
18696
|
throw error;
|
|
18648
18697
|
}
|
|
18649
18698
|
try {
|
|
@@ -18673,7 +18722,7 @@ class DispatchClient {
|
|
|
18673
18722
|
"sync"
|
|
18674
18723
|
]);
|
|
18675
18724
|
} catch (error) {
|
|
18676
|
-
if (!
|
|
18725
|
+
if (!(error instanceof DispatchNoRouteError))
|
|
18677
18726
|
throw error;
|
|
18678
18727
|
}
|
|
18679
18728
|
const source = await this.#json("POST", [
|
|
@@ -18799,13 +18848,15 @@ class DispatchClient {
|
|
|
18799
18848
|
}
|
|
18800
18849
|
async fileVersion(id, version) {
|
|
18801
18850
|
const url = this.#url(["api", "v1", "artifacts", id, "versions", String(version)]);
|
|
18802
|
-
|
|
18803
|
-
|
|
18804
|
-
|
|
18805
|
-
|
|
18806
|
-
|
|
18807
|
-
|
|
18808
|
-
|
|
18851
|
+
return this.#noRoute(async () => {
|
|
18852
|
+
const response = await this.#send("GET", url, undefined, "*/*");
|
|
18853
|
+
if (!response.ok)
|
|
18854
|
+
return this.#response("GET", url, response);
|
|
18855
|
+
return {
|
|
18856
|
+
mime: response.headers.get("Content-Type") ?? "application/octet-stream",
|
|
18857
|
+
bytes: new Uint8Array(await response.arrayBuffer())
|
|
18858
|
+
};
|
|
18859
|
+
});
|
|
18809
18860
|
}
|
|
18810
18861
|
async artifactBlocks(id) {
|
|
18811
18862
|
return this.#json("GET", ["api", "v1", "artifacts", id, "blocks"]);
|
|
@@ -18907,8 +18958,19 @@ class DispatchClient {
|
|
|
18907
18958
|
}
|
|
18908
18959
|
async#jsonAnswer(method, path, body, query, signal, key) {
|
|
18909
18960
|
const url = this.#url(path, query);
|
|
18910
|
-
|
|
18911
|
-
|
|
18961
|
+
return this.#noRoute(async () => {
|
|
18962
|
+
const response = await this.#send(method, url, body === undefined ? undefined : { content: JSON.stringify(body), type: "application/json" }, undefined, signal, key);
|
|
18963
|
+
return { status: response.status, payload: await this.#response(method, url, response) };
|
|
18964
|
+
}, signal);
|
|
18965
|
+
}
|
|
18966
|
+
#noRoute(attempt, signal) {
|
|
18967
|
+
if (!this.#retryNoRoute)
|
|
18968
|
+
return attempt();
|
|
18969
|
+
return retryNoRoute(attempt, isNoRoute, {
|
|
18970
|
+
exhausted: () => new DispatchNoRouteError,
|
|
18971
|
+
signal: signal === undefined ? this.#signal : AbortSignal.any([this.#signal, signal]),
|
|
18972
|
+
sleep: this.#sleep
|
|
18973
|
+
});
|
|
18912
18974
|
}
|
|
18913
18975
|
async#upload(path, input, key) {
|
|
18914
18976
|
if (input.file === undefined) {
|
|
@@ -18925,11 +18987,13 @@ class DispatchClient {
|
|
|
18925
18987
|
}
|
|
18926
18988
|
async#form(method, path, form, key) {
|
|
18927
18989
|
const url = this.#url(path);
|
|
18928
|
-
|
|
18929
|
-
|
|
18930
|
-
|
|
18931
|
-
|
|
18932
|
-
|
|
18990
|
+
return this.#noRoute(async () => {
|
|
18991
|
+
const encoded = new Response(form);
|
|
18992
|
+
const type = encoded.headers.get("Content-Type") ?? "multipart/form-data";
|
|
18993
|
+
const content = new Uint8Array(await encoded.arrayBuffer());
|
|
18994
|
+
const response = await this.#send(method, url, { content, type }, undefined, undefined, key);
|
|
18995
|
+
return this.#response(method, url, response);
|
|
18996
|
+
});
|
|
18933
18997
|
}
|
|
18934
18998
|
async#send(method, url, body, accept = "application/json", signal, callerKey) {
|
|
18935
18999
|
const headers = { Accept: accept };
|
|
@@ -19224,7 +19288,11 @@ function sessionContext(input, checked) {
|
|
|
19224
19288
|
configUrl,
|
|
19225
19289
|
linkBase: input.config.publicUrl ?? configUrl,
|
|
19226
19290
|
hostSession: input.sessionId?.trim(),
|
|
19227
|
-
newClient: () => new DispatchClient(configUrl, credential, fetchImpl,
|
|
19291
|
+
newClient: () => new DispatchClient(configUrl, credential, fetchImpl, {
|
|
19292
|
+
signal: input.signal,
|
|
19293
|
+
writeRetry: input.writeRetry,
|
|
19294
|
+
sleep: input.sleep
|
|
19295
|
+
})
|
|
19228
19296
|
};
|
|
19229
19297
|
}
|
|
19230
19298
|
|
|
@@ -23939,7 +24007,7 @@ function isSessionAnswerRelation(value) {
|
|
|
23939
24007
|
return Object.hasOwn(RELATION_PHRASES, value);
|
|
23940
24008
|
}
|
|
23941
24009
|
function isNoAnswersRoute(error) {
|
|
23942
|
-
return isNoRoute(error);
|
|
24010
|
+
return isNoRoute(error) || error instanceof DispatchNoRouteError;
|
|
23943
24011
|
}
|
|
23944
24012
|
function renderSessionAnswerItem(item) {
|
|
23945
24013
|
const phrase = isSessionAnswerRelation(item.relation) ? RELATION_PHRASES[item.relation] : item.relation;
|
package/dist/envoy.js
CHANGED
|
@@ -30661,7 +30661,7 @@ var dispatchToolSpecs = [
|
|
|
30661
30661
|
{
|
|
30662
30662
|
name: "dispatch_read",
|
|
30663
30663
|
example: { issue: "DSP-1" },
|
|
30664
|
-
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), `
|
|
30664
|
+
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,
|
|
30665
30665
|
arguments: (z) => ({
|
|
30666
30666
|
issue: z.string().describe(ISSUE_REFERENCE).optional(),
|
|
30667
30667
|
project: z.string().describe("Project key owning the document.").optional(),
|
|
@@ -31360,6 +31360,45 @@ var MessageAcceptedEventPayloadSchema = strictObject({
|
|
|
31360
31360
|
accepted_as: literal("user_turn"),
|
|
31361
31361
|
target: string2()
|
|
31362
31362
|
}).readonly();
|
|
31363
|
+
// ../contracts/src/dispatch-api-requests.ts
|
|
31364
|
+
var NO_ROUTE_MESSAGE_PREFIX = "no route for ";
|
|
31365
|
+
var NO_ROUTE_RETRY_DELAYS_MS = [1000, 2000, 4000];
|
|
31366
|
+
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.";
|
|
31367
|
+
var sleep = (ms, signal) => {
|
|
31368
|
+
const { promise, resolve, reject } = Promise.withResolvers();
|
|
31369
|
+
if (signal?.aborted) {
|
|
31370
|
+
reject(signal.reason);
|
|
31371
|
+
return promise;
|
|
31372
|
+
}
|
|
31373
|
+
const abort = () => {
|
|
31374
|
+
clearTimeout(timer);
|
|
31375
|
+
reject(signal?.reason);
|
|
31376
|
+
};
|
|
31377
|
+
const timer = setTimeout(() => {
|
|
31378
|
+
signal?.removeEventListener("abort", abort);
|
|
31379
|
+
resolve();
|
|
31380
|
+
}, ms);
|
|
31381
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
31382
|
+
return promise;
|
|
31383
|
+
};
|
|
31384
|
+
function jitteredDelay(ms) {
|
|
31385
|
+
return ms * (0.75 + Math.random() * 0.5);
|
|
31386
|
+
}
|
|
31387
|
+
async function retryNoRoute(attempt, isNoRoute, options) {
|
|
31388
|
+
const wait = options.sleep ?? sleep;
|
|
31389
|
+
for (const delay of [...NO_ROUTE_RETRY_DELAYS_MS, undefined]) {
|
|
31390
|
+
try {
|
|
31391
|
+
return await attempt();
|
|
31392
|
+
} catch (error) {
|
|
31393
|
+
if (!isNoRoute(error))
|
|
31394
|
+
throw error;
|
|
31395
|
+
if (delay === undefined)
|
|
31396
|
+
break;
|
|
31397
|
+
}
|
|
31398
|
+
await wait(jitteredDelay(delay), options.signal);
|
|
31399
|
+
}
|
|
31400
|
+
throw options.exhausted();
|
|
31401
|
+
}
|
|
31363
31402
|
// ../contracts/src/dispatch-api-search.ts
|
|
31364
31403
|
var SEARCH_MEMBERS_EVERY_BUILD_READS = [
|
|
31365
31404
|
"q",
|
|
@@ -36382,7 +36421,13 @@ function isJson(response) {
|
|
|
36382
36421
|
return response.headers.get("content-type")?.includes("application/json") ?? false;
|
|
36383
36422
|
}
|
|
36384
36423
|
function isNoRoute(error) {
|
|
36385
|
-
return error instanceof DispatchServiceError && error.status === 404 && error.code === "NOT_FOUND" && error.message.startsWith(
|
|
36424
|
+
return error instanceof DispatchServiceError && error.status === 404 && error.code === "NOT_FOUND" && error.message.startsWith(NO_ROUTE_MESSAGE_PREFIX);
|
|
36425
|
+
}
|
|
36426
|
+
|
|
36427
|
+
class DispatchNoRouteError extends DispatchServiceError {
|
|
36428
|
+
constructor() {
|
|
36429
|
+
super("NOT_FOUND", 404, NO_ROUTE_ROLLING_RELEASE_MESSAGE);
|
|
36430
|
+
}
|
|
36386
36431
|
}
|
|
36387
36432
|
var ISSUE_EVENTS_PAGE_MAX = 200;
|
|
36388
36433
|
var DISPATCH_TOOL_DEADLINE_MS = 60000;
|
|
@@ -36571,18 +36616,22 @@ function excerpt(text, token) {
|
|
|
36571
36616
|
|
|
36572
36617
|
class DispatchClient {
|
|
36573
36618
|
fetchImpl;
|
|
36574
|
-
writeRetry;
|
|
36575
36619
|
#baseUrl;
|
|
36576
36620
|
#resolvedIssues = new Map;
|
|
36577
36621
|
#signal;
|
|
36578
36622
|
#credential;
|
|
36623
|
+
#sleep;
|
|
36624
|
+
#retryNoRoute;
|
|
36625
|
+
writeRetry;
|
|
36579
36626
|
#madeAt;
|
|
36580
|
-
constructor(baseUrl, credential, fetchImpl = fetch,
|
|
36627
|
+
constructor(baseUrl, credential, fetchImpl = fetch, options = {}) {
|
|
36581
36628
|
this.fetchImpl = fetchImpl;
|
|
36582
|
-
this.writeRetry = writeRetry;
|
|
36583
36629
|
this.#credential = credential;
|
|
36584
36630
|
this.#baseUrl = withoutTrailingSlashes(baseUrl);
|
|
36585
|
-
this.#signal = requestSignal(signal);
|
|
36631
|
+
this.#signal = requestSignal(options.signal);
|
|
36632
|
+
this.writeRetry = options.writeRetry ?? DISPATCH_WRITE_RETRY;
|
|
36633
|
+
this.#sleep = options.sleep ?? sleep;
|
|
36634
|
+
this.#retryNoRoute = options.retryNoRoute ?? true;
|
|
36586
36635
|
this.#madeAt = this.#now();
|
|
36587
36636
|
}
|
|
36588
36637
|
get token() {
|
|
@@ -36737,7 +36786,7 @@ class DispatchClient {
|
|
|
36737
36786
|
try {
|
|
36738
36787
|
return await this.#json("GET", ["api", "v1", "projects", project, "architecture-sources"]);
|
|
36739
36788
|
} catch (error) {
|
|
36740
|
-
if (!
|
|
36789
|
+
if (!(error instanceof DispatchNoRouteError))
|
|
36741
36790
|
throw error;
|
|
36742
36791
|
}
|
|
36743
36792
|
try {
|
|
@@ -36767,7 +36816,7 @@ class DispatchClient {
|
|
|
36767
36816
|
"sync"
|
|
36768
36817
|
]);
|
|
36769
36818
|
} catch (error) {
|
|
36770
|
-
if (!
|
|
36819
|
+
if (!(error instanceof DispatchNoRouteError))
|
|
36771
36820
|
throw error;
|
|
36772
36821
|
}
|
|
36773
36822
|
const source = await this.#json("POST", [
|
|
@@ -36893,13 +36942,15 @@ class DispatchClient {
|
|
|
36893
36942
|
}
|
|
36894
36943
|
async fileVersion(id, version) {
|
|
36895
36944
|
const url = this.#url(["api", "v1", "artifacts", id, "versions", String(version)]);
|
|
36896
|
-
|
|
36897
|
-
|
|
36898
|
-
|
|
36899
|
-
|
|
36900
|
-
|
|
36901
|
-
|
|
36902
|
-
|
|
36945
|
+
return this.#noRoute(async () => {
|
|
36946
|
+
const response = await this.#send("GET", url, undefined, "*/*");
|
|
36947
|
+
if (!response.ok)
|
|
36948
|
+
return this.#response("GET", url, response);
|
|
36949
|
+
return {
|
|
36950
|
+
mime: response.headers.get("Content-Type") ?? "application/octet-stream",
|
|
36951
|
+
bytes: new Uint8Array(await response.arrayBuffer())
|
|
36952
|
+
};
|
|
36953
|
+
});
|
|
36903
36954
|
}
|
|
36904
36955
|
async artifactBlocks(id) {
|
|
36905
36956
|
return this.#json("GET", ["api", "v1", "artifacts", id, "blocks"]);
|
|
@@ -37001,8 +37052,19 @@ class DispatchClient {
|
|
|
37001
37052
|
}
|
|
37002
37053
|
async#jsonAnswer(method, path, body, query, signal, key) {
|
|
37003
37054
|
const url = this.#url(path, query);
|
|
37004
|
-
|
|
37005
|
-
|
|
37055
|
+
return this.#noRoute(async () => {
|
|
37056
|
+
const response = await this.#send(method, url, body === undefined ? undefined : { content: JSON.stringify(body), type: "application/json" }, undefined, signal, key);
|
|
37057
|
+
return { status: response.status, payload: await this.#response(method, url, response) };
|
|
37058
|
+
}, signal);
|
|
37059
|
+
}
|
|
37060
|
+
#noRoute(attempt, signal) {
|
|
37061
|
+
if (!this.#retryNoRoute)
|
|
37062
|
+
return attempt();
|
|
37063
|
+
return retryNoRoute(attempt, isNoRoute, {
|
|
37064
|
+
exhausted: () => new DispatchNoRouteError,
|
|
37065
|
+
signal: signal === undefined ? this.#signal : AbortSignal.any([this.#signal, signal]),
|
|
37066
|
+
sleep: this.#sleep
|
|
37067
|
+
});
|
|
37006
37068
|
}
|
|
37007
37069
|
async#upload(path, input, key) {
|
|
37008
37070
|
if (input.file === undefined) {
|
|
@@ -37019,11 +37081,13 @@ class DispatchClient {
|
|
|
37019
37081
|
}
|
|
37020
37082
|
async#form(method, path, form, key) {
|
|
37021
37083
|
const url = this.#url(path);
|
|
37022
|
-
|
|
37023
|
-
|
|
37024
|
-
|
|
37025
|
-
|
|
37026
|
-
|
|
37084
|
+
return this.#noRoute(async () => {
|
|
37085
|
+
const encoded = new Response(form);
|
|
37086
|
+
const type = encoded.headers.get("Content-Type") ?? "multipart/form-data";
|
|
37087
|
+
const content = new Uint8Array(await encoded.arrayBuffer());
|
|
37088
|
+
const response = await this.#send(method, url, { content, type }, undefined, undefined, key);
|
|
37089
|
+
return this.#response(method, url, response);
|
|
37090
|
+
});
|
|
37027
37091
|
}
|
|
37028
37092
|
async#send(method, url, body, accept = "application/json", signal, callerKey) {
|
|
37029
37093
|
const headers = { Accept: accept };
|
|
@@ -44387,7 +44451,7 @@ function isSessionAnswersText(text) {
|
|
|
44387
44451
|
return text.startsWith(SESSION_ANSWERS_MARKER) || text.startsWith(FAILURE_MARKER);
|
|
44388
44452
|
}
|
|
44389
44453
|
function isNoAnswersRoute(error) {
|
|
44390
|
-
return isNoRoute(error);
|
|
44454
|
+
return isNoRoute(error) || error instanceof DispatchNoRouteError;
|
|
44391
44455
|
}
|
|
44392
44456
|
function renderSessionAnswerItem(item) {
|
|
44393
44457
|
const phrase = isSessionAnswerRelation(item.relation) ? RELATION_PHRASES[item.relation] : item.relation;
|
|
@@ -44588,7 +44652,9 @@ async function readSessionAnswers(options) {
|
|
|
44588
44652
|
}
|
|
44589
44653
|
let read = current.inFlight;
|
|
44590
44654
|
if (read === undefined) {
|
|
44591
|
-
const client = new DispatchClient(url, dispatch.credential, options.fetchImpl ?? fetch
|
|
44655
|
+
const client = new DispatchClient(url, dispatch.credential, options.fetchImpl ?? fetch, {
|
|
44656
|
+
retryNoRoute: false
|
|
44657
|
+
});
|
|
44592
44658
|
const started = client.sessionAnswers(session, {
|
|
44593
44659
|
maxChars: SESSION_ANSWERS_MAX_CHARS,
|
|
44594
44660
|
signal: AbortSignal.timeout(READ_TIMEOUT_MS)
|
|
@@ -46663,7 +46729,7 @@ var import_nats2 = __toESM(require_mod4(), 1);
|
|
|
46663
46729
|
|
|
46664
46730
|
// package.json
|
|
46665
46731
|
var name = "@sjawhar/pi-envoy";
|
|
46666
|
-
var version2 = "17.
|
|
46732
|
+
var version2 = "17.22.0";
|
|
46667
46733
|
var package_default = {
|
|
46668
46734
|
name,
|
|
46669
46735
|
version: version2,
|
|
@@ -47340,7 +47406,7 @@ function withDispatchFirst(messages, context) {
|
|
|
47340
47406
|
function sessionDispatchClient(file, cwd, signal, session) {
|
|
47341
47407
|
const config = activeDispatchSettings(sessionDispatchSettings(file, process.env, { cwd, session }).dispatch);
|
|
47342
47408
|
return config === null ? undefined : {
|
|
47343
|
-
client: new DispatchClient(config.url, config.credential, fetch, signal),
|
|
47409
|
+
client: new DispatchClient(config.url, config.credential, fetch, { signal }),
|
|
47344
47410
|
serverUrls: dispatchServerUrls(config)
|
|
47345
47411
|
};
|
|
47346
47412
|
}
|