@sjawhar/pi-legion 19.21.0 → 19.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/legion.js +88 -24
- package/package.json +1 -1
package/dist/legion.js
CHANGED
|
@@ -17681,7 +17681,7 @@ var dispatchToolSpecs = [
|
|
|
17681
17681
|
{
|
|
17682
17682
|
name: "dispatch_read",
|
|
17683
17683
|
example: { issue: "DSP-1" },
|
|
17684
|
-
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), `
|
|
17684
|
+
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,
|
|
17685
17685
|
arguments: (z) => ({
|
|
17686
17686
|
issue: z.string().describe(ISSUE_REFERENCE).optional(),
|
|
17687
17687
|
project: z.string().describe("Project key owning the document.").optional(),
|
|
@@ -18379,6 +18379,45 @@ var MessageAcceptedEventPayloadSchema = strictObject({
|
|
|
18379
18379
|
accepted_as: literal("user_turn"),
|
|
18380
18380
|
target: string2()
|
|
18381
18381
|
}).readonly();
|
|
18382
|
+
// ../contracts/src/dispatch-api-requests.ts
|
|
18383
|
+
var NO_ROUTE_MESSAGE_PREFIX = "no route for ";
|
|
18384
|
+
var NO_ROUTE_RETRY_DELAYS_MS = [1000, 2000, 4000];
|
|
18385
|
+
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.";
|
|
18386
|
+
var sleep = (ms, signal) => {
|
|
18387
|
+
const { promise, resolve, reject } = Promise.withResolvers();
|
|
18388
|
+
if (signal?.aborted) {
|
|
18389
|
+
reject(signal.reason);
|
|
18390
|
+
return promise;
|
|
18391
|
+
}
|
|
18392
|
+
const abort = () => {
|
|
18393
|
+
clearTimeout(timer);
|
|
18394
|
+
reject(signal?.reason);
|
|
18395
|
+
};
|
|
18396
|
+
const timer = setTimeout(() => {
|
|
18397
|
+
signal?.removeEventListener("abort", abort);
|
|
18398
|
+
resolve();
|
|
18399
|
+
}, ms);
|
|
18400
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
18401
|
+
return promise;
|
|
18402
|
+
};
|
|
18403
|
+
function jitteredDelay(ms) {
|
|
18404
|
+
return ms * (0.75 + Math.random() * 0.5);
|
|
18405
|
+
}
|
|
18406
|
+
async function retryNoRoute(attempt, isNoRoute, options) {
|
|
18407
|
+
const wait = options.sleep ?? sleep;
|
|
18408
|
+
for (const delay of [...NO_ROUTE_RETRY_DELAYS_MS, undefined]) {
|
|
18409
|
+
try {
|
|
18410
|
+
return await attempt();
|
|
18411
|
+
} catch (error) {
|
|
18412
|
+
if (!isNoRoute(error))
|
|
18413
|
+
throw error;
|
|
18414
|
+
if (delay === undefined)
|
|
18415
|
+
break;
|
|
18416
|
+
}
|
|
18417
|
+
await wait(jitteredDelay(delay), options.signal);
|
|
18418
|
+
}
|
|
18419
|
+
throw options.exhausted();
|
|
18420
|
+
}
|
|
18382
18421
|
// ../contracts/src/dispatch-api-search.ts
|
|
18383
18422
|
var SEARCH_MEMBERS_EVERY_BUILD_READS = [
|
|
18384
18423
|
"q",
|
|
@@ -20240,7 +20279,13 @@ function isJson(response) {
|
|
|
20240
20279
|
return response.headers.get("content-type")?.includes("application/json") ?? false;
|
|
20241
20280
|
}
|
|
20242
20281
|
function isNoRoute(error) {
|
|
20243
|
-
return error instanceof DispatchServiceError && error.status === 404 && error.code === "NOT_FOUND" && error.message.startsWith(
|
|
20282
|
+
return error instanceof DispatchServiceError && error.status === 404 && error.code === "NOT_FOUND" && error.message.startsWith(NO_ROUTE_MESSAGE_PREFIX);
|
|
20283
|
+
}
|
|
20284
|
+
|
|
20285
|
+
class DispatchNoRouteError extends DispatchServiceError {
|
|
20286
|
+
constructor() {
|
|
20287
|
+
super("NOT_FOUND", 404, NO_ROUTE_ROLLING_RELEASE_MESSAGE);
|
|
20288
|
+
}
|
|
20244
20289
|
}
|
|
20245
20290
|
var ISSUE_EVENTS_PAGE_MAX = 200;
|
|
20246
20291
|
var DISPATCH_TOOL_DEADLINE_MS = 60000;
|
|
@@ -20429,18 +20474,22 @@ function excerpt(text, token) {
|
|
|
20429
20474
|
|
|
20430
20475
|
class DispatchClient {
|
|
20431
20476
|
fetchImpl;
|
|
20432
|
-
writeRetry;
|
|
20433
20477
|
#baseUrl;
|
|
20434
20478
|
#resolvedIssues = new Map;
|
|
20435
20479
|
#signal;
|
|
20436
20480
|
#credential;
|
|
20481
|
+
#sleep;
|
|
20482
|
+
#retryNoRoute;
|
|
20483
|
+
writeRetry;
|
|
20437
20484
|
#madeAt;
|
|
20438
|
-
constructor(baseUrl, credential, fetchImpl = fetch,
|
|
20485
|
+
constructor(baseUrl, credential, fetchImpl = fetch, options = {}) {
|
|
20439
20486
|
this.fetchImpl = fetchImpl;
|
|
20440
|
-
this.writeRetry = writeRetry;
|
|
20441
20487
|
this.#credential = credential;
|
|
20442
20488
|
this.#baseUrl = withoutTrailingSlashes(baseUrl);
|
|
20443
|
-
this.#signal = requestSignal(signal);
|
|
20489
|
+
this.#signal = requestSignal(options.signal);
|
|
20490
|
+
this.writeRetry = options.writeRetry ?? DISPATCH_WRITE_RETRY;
|
|
20491
|
+
this.#sleep = options.sleep ?? sleep;
|
|
20492
|
+
this.#retryNoRoute = options.retryNoRoute ?? true;
|
|
20444
20493
|
this.#madeAt = this.#now();
|
|
20445
20494
|
}
|
|
20446
20495
|
get token() {
|
|
@@ -20595,7 +20644,7 @@ class DispatchClient {
|
|
|
20595
20644
|
try {
|
|
20596
20645
|
return await this.#json("GET", ["api", "v1", "projects", project, "architecture-sources"]);
|
|
20597
20646
|
} catch (error) {
|
|
20598
|
-
if (!
|
|
20647
|
+
if (!(error instanceof DispatchNoRouteError))
|
|
20599
20648
|
throw error;
|
|
20600
20649
|
}
|
|
20601
20650
|
try {
|
|
@@ -20625,7 +20674,7 @@ class DispatchClient {
|
|
|
20625
20674
|
"sync"
|
|
20626
20675
|
]);
|
|
20627
20676
|
} catch (error) {
|
|
20628
|
-
if (!
|
|
20677
|
+
if (!(error instanceof DispatchNoRouteError))
|
|
20629
20678
|
throw error;
|
|
20630
20679
|
}
|
|
20631
20680
|
const source = await this.#json("POST", [
|
|
@@ -20751,13 +20800,15 @@ class DispatchClient {
|
|
|
20751
20800
|
}
|
|
20752
20801
|
async fileVersion(id, version) {
|
|
20753
20802
|
const url = this.#url(["api", "v1", "artifacts", id, "versions", String(version)]);
|
|
20754
|
-
|
|
20755
|
-
|
|
20756
|
-
|
|
20757
|
-
|
|
20758
|
-
|
|
20759
|
-
|
|
20760
|
-
|
|
20803
|
+
return this.#noRoute(async () => {
|
|
20804
|
+
const response = await this.#send("GET", url, undefined, "*/*");
|
|
20805
|
+
if (!response.ok)
|
|
20806
|
+
return this.#response("GET", url, response);
|
|
20807
|
+
return {
|
|
20808
|
+
mime: response.headers.get("Content-Type") ?? "application/octet-stream",
|
|
20809
|
+
bytes: new Uint8Array(await response.arrayBuffer())
|
|
20810
|
+
};
|
|
20811
|
+
});
|
|
20761
20812
|
}
|
|
20762
20813
|
async artifactBlocks(id) {
|
|
20763
20814
|
return this.#json("GET", ["api", "v1", "artifacts", id, "blocks"]);
|
|
@@ -20859,8 +20910,19 @@ class DispatchClient {
|
|
|
20859
20910
|
}
|
|
20860
20911
|
async#jsonAnswer(method, path, body, query, signal, key) {
|
|
20861
20912
|
const url = this.#url(path, query);
|
|
20862
|
-
|
|
20863
|
-
|
|
20913
|
+
return this.#noRoute(async () => {
|
|
20914
|
+
const response = await this.#send(method, url, body === undefined ? undefined : { content: JSON.stringify(body), type: "application/json" }, undefined, signal, key);
|
|
20915
|
+
return { status: response.status, payload: await this.#response(method, url, response) };
|
|
20916
|
+
}, signal);
|
|
20917
|
+
}
|
|
20918
|
+
#noRoute(attempt, signal) {
|
|
20919
|
+
if (!this.#retryNoRoute)
|
|
20920
|
+
return attempt();
|
|
20921
|
+
return retryNoRoute(attempt, isNoRoute, {
|
|
20922
|
+
exhausted: () => new DispatchNoRouteError,
|
|
20923
|
+
signal: signal === undefined ? this.#signal : AbortSignal.any([this.#signal, signal]),
|
|
20924
|
+
sleep: this.#sleep
|
|
20925
|
+
});
|
|
20864
20926
|
}
|
|
20865
20927
|
async#upload(path, input, key) {
|
|
20866
20928
|
if (input.file === undefined) {
|
|
@@ -20877,11 +20939,13 @@ class DispatchClient {
|
|
|
20877
20939
|
}
|
|
20878
20940
|
async#form(method, path, form, key) {
|
|
20879
20941
|
const url = this.#url(path);
|
|
20880
|
-
|
|
20881
|
-
|
|
20882
|
-
|
|
20883
|
-
|
|
20884
|
-
|
|
20942
|
+
return this.#noRoute(async () => {
|
|
20943
|
+
const encoded = new Response(form);
|
|
20944
|
+
const type = encoded.headers.get("Content-Type") ?? "multipart/form-data";
|
|
20945
|
+
const content = new Uint8Array(await encoded.arrayBuffer());
|
|
20946
|
+
const response = await this.#send(method, url, { content, type }, undefined, undefined, key);
|
|
20947
|
+
return this.#response(method, url, response);
|
|
20948
|
+
});
|
|
20885
20949
|
}
|
|
20886
20950
|
async#send(method, url, body, accept = "application/json", signal, callerKey) {
|
|
20887
20951
|
const headers = { Accept: accept };
|
|
@@ -24868,7 +24932,7 @@ function isSessionAnswerRelation(value) {
|
|
|
24868
24932
|
return Object.hasOwn(RELATION_PHRASES, value);
|
|
24869
24933
|
}
|
|
24870
24934
|
function isNoAnswersRoute(error) {
|
|
24871
|
-
return isNoRoute(error);
|
|
24935
|
+
return isNoRoute(error) || error instanceof DispatchNoRouteError;
|
|
24872
24936
|
}
|
|
24873
24937
|
function renderSessionAnswerItem(item) {
|
|
24874
24938
|
const phrase = isSessionAnswerRelation(item.relation) ? RELATION_PHRASES[item.relation] : item.relation;
|
|
@@ -28783,7 +28847,7 @@ import { logger as logger3 } from "@oh-my-pi/pi-utils";
|
|
|
28783
28847
|
// package.json
|
|
28784
28848
|
var package_default = {
|
|
28785
28849
|
name: "@sjawhar/pi-legion",
|
|
28786
|
-
version: "19.
|
|
28850
|
+
version: "19.22.0",
|
|
28787
28851
|
license: "Apache-2.0",
|
|
28788
28852
|
type: "module",
|
|
28789
28853
|
omp: {
|