@sjawhar/pi-legion 19.21.0 → 19.22.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/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.1",
|
|
28787
28851
|
license: "Apache-2.0",
|
|
28788
28852
|
type: "module",
|
|
28789
28853
|
omp: {
|
|
@@ -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. |
|