@akagilnc/pi-workflow-roles 0.1.5483 → 0.1.5571
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/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/dist/acp-host/production-host.js +6312 -6376
- package/dist/analyst-gate-cycles-read.js +28 -78
- package/dist/analyst-ledger.js +26 -42
- package/dist/analyst-metric-families/acceptance-success-rework.js +25 -1
- package/dist/analyst-metric-families/round-timeline.js +2 -5
- package/dist/archivist-record-entry.js +4 -3
- package/dist/archivist-record-pointer.js +71 -36
- package/dist/atomic-write.js +2 -2
- package/dist/auditor-dossier-tool.js +11 -6
- package/dist/auditor-soul.js +5 -12
- package/dist/collector-config.js +6 -5
- package/dist/doctor-evidence.js +8 -4
- package/dist/engine-detour-usage.js +8 -22
- package/dist/headless-host/production-host.js +5969 -6011
- package/dist/host-descriptions.js +0 -4
- package/dist/host-session-record.js +266 -267
- package/dist/ledger-session-read.js +5 -0
- package/dist/migrate-book-topology.js +1369 -722
- package/dist/navigator-public-session.js +13 -17
- package/dist/notary-source-run.js +8 -16
- package/dist/packaged-role-registry.js +5 -56
- package/dist/pi/durable-principal.js +2 -3
- package/dist/pi/role-turn-host.js +79 -15
- package/dist/public-cli/auto-resume.js +8 -47
- package/dist/public-cli/instruction-seat-run.js +9 -7
- package/dist/public-cli/invocation.js +67 -100
- package/dist/public-cli/main.js +2689 -2532
- package/dist/public-cli/post-admission.js +96 -55
- package/dist/public-cli/run-lifecycle.js +44 -100
- package/dist/public-cli/settlement.js +184 -429
- package/dist/public-cli/terminal.js +0 -12
- package/dist/role-run-placement.js +53 -16
- package/dist/role-run-relocation.js +111 -52
- package/dist/run-dossier-files.js +30 -0
- package/dist/run-dossier.js +322 -0
- package/dist/run-terminal-artifacts.js +69 -202
- package/dist/run-ticket-number.js +49 -7
- package/dist/session-assistant-usage.js +9 -18
- package/dist/session-identity.js +49 -19
- package/dist/sitian-appender.js +29 -18
- package/dist/sitian-facade.js +11 -0
- package/dist/sitian-reader.js +44 -29
- package/dist/submission-gate.js +1 -1
- package/dist/submission-ledger.js +4 -4
- package/dist/ticket-provenance-contracts.js +2 -8
- package/dist/ticket-provenance.js +25 -9
- package/package.json +1 -1
- package/scripts/build-package.mjs +2 -0
- package/src/acp-host/production-host.ts +1 -1
- package/src/acp-host/role-turn-host.ts +11 -4
- package/src/analyst-gate-cycles-read.ts +31 -88
- package/src/analyst-ledger.ts +36 -51
- package/src/analyst-metric-families/acceptance-success-rework.ts +24 -1
- package/src/analyst-metric-families/gate-cycles.ts +1 -1
- package/src/analyst-metric-families/round-timeline.ts +2 -5
- package/src/analyst-page.ts +3 -3
- package/src/archivist-record-entry.ts +6 -5
- package/src/archivist-record-pointer.ts +92 -42
- package/src/atomic-write.ts +3 -1
- package/src/auditor-dossier-tool.ts +14 -8
- package/src/auditor-soul.ts +5 -10
- package/src/book-topology-migration-placement.ts +16 -3
- package/src/book-topology-record-class-migrators.ts +4 -2
- package/src/book-topology-runs-migrator.ts +6 -3
- package/src/collector-config.ts +5 -3
- package/src/doctor-contracts.ts +1 -1
- package/src/doctor-evidence.ts +7 -3
- package/src/engine-detour-tool.ts +1 -1
- package/src/engine-detour-usage.ts +12 -25
- package/src/external-host-turn-loop.ts +25 -0
- package/src/factory-board.ts +16 -81
- package/src/headless-host/production-host.ts +1 -4
- package/src/headless-host/role-turn-host.ts +56 -21
- package/src/host-descriptions.ts +0 -6
- package/src/host-session-record.ts +224 -140
- package/src/ledger-session-read.ts +6 -0
- package/src/navigator-public-session.ts +13 -18
- package/src/navigator-work-context.ts +3 -1
- package/src/notary-role.ts +2 -1
- package/src/notary-source-run.ts +8 -18
- package/src/packaged-role-registry.ts +1 -65
- package/src/pi/adapter.ts +50 -7
- package/src/pi/durable-principal.ts +2 -4
- package/src/pi/role-turn-host.ts +85 -14
- package/src/public-cli/auto-resume.ts +7 -43
- package/src/public-cli/instruction-seat-run.ts +13 -6
- package/src/public-cli/invocation.ts +90 -144
- package/src/public-cli/post-admission.ts +111 -72
- package/src/public-cli/run-lifecycle.ts +47 -115
- package/src/public-cli/settlement.ts +221 -589
- package/src/public-cli/terminal.ts +1 -61
- package/src/role-envelope.ts +4 -2
- package/src/role-run-placement.ts +65 -17
- package/src/role-run-relocation.ts +110 -70
- package/src/role-runtime.ts +46 -69
- package/src/run-dossier-files.ts +33 -0
- package/src/run-dossier.ts +357 -0
- package/src/run-terminal-artifacts.ts +84 -240
- package/src/run-ticket-number.ts +82 -14
- package/src/session-assistant-usage.ts +8 -20
- package/src/session-identity.ts +52 -21
- package/src/sitian-appender.ts +33 -26
- package/src/sitian-facade.ts +22 -0
- package/src/sitian-reader.ts +62 -32
- package/src/submission-gate.ts +1 -1
- package/src/submission-ledger.ts +4 -4
- package/src/ticket-provenance-contracts.ts +3 -6
- package/src/ticket-provenance.ts +23 -11
- package/src/ticket-snapshot.ts +3 -2
- package/src/ticket-trajectory.ts +95 -109
package/dist/doctor-evidence.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readdir, readFile, realpath, stat } from "node:fs/promises";
|
|
2
2
|
import { dirname, relative, resolve, sep } from "node:path";
|
|
3
3
|
import { sha256Hex } from "./sha256.js";
|
|
4
|
+
import { physicallyContainedIn } from "./activation-ledger-topology.js";
|
|
4
5
|
import { AcceptedDetailsContractError, acceptedFacts, isTerminatingToolName, validateAcceptedDetails } from "./package-contracts/terminating-tools.js";
|
|
5
6
|
import { isRecord, isMissingPathError } from "./unknown-value.js";
|
|
6
7
|
async function discoverCaseFiles(root) { const found = []; async function walk(dir, depth) { for (const item of await readdir(dir, { withFileTypes: true })) {
|
|
@@ -8,7 +9,7 @@ async function discoverCaseFiles(root) { const found = []; async function walk(d
|
|
|
8
9
|
if (item.isDirectory()) {
|
|
9
10
|
await walk(path, depth + 1);
|
|
10
11
|
}
|
|
11
|
-
else if (item.isFile() && (item.name.endsWith(".jsonl") || (item.name === "
|
|
12
|
+
else if (item.isFile() && ((item.name.endsWith(".jsonl") && item.name !== "state.jsonl" && !(item.name === "log.jsonl" && depth === 1)) || (item.name === "log.jsonl" && depth === 1)))
|
|
12
13
|
found.push(path);
|
|
13
14
|
} } await walk(root, 0); return found.sort(); }
|
|
14
15
|
function sourceList(count, sources) { return { count, sources: [...new Set(sources)].sort() }; }
|
|
@@ -106,8 +107,11 @@ function deriveSession(content, id) {
|
|
|
106
107
|
return { session, turns, calls, tokens, statuses, commits };
|
|
107
108
|
}
|
|
108
109
|
/** Read Pi's retained session directory as the sole raw material for one case. */
|
|
109
|
-
export async function loadDoctorCase(runsPath) {
|
|
110
|
+
export async function loadDoctorCase(runsPath, projectRoot) {
|
|
110
111
|
const root = await realpath(runsPath);
|
|
112
|
+
if (projectRoot !== undefined && !physicallyContainedIn(projectRoot, root)) {
|
|
113
|
+
throw new Error("doctor --runs escapes the project root");
|
|
114
|
+
}
|
|
111
115
|
// Canonical <book>/<ticket>/runs; legacy issues/<n>/runs remains read-only compatible.
|
|
112
116
|
const match = root.split(sep).join("/").match(/\/\.ak-roles\/books\/[^/]+\/(?:issues\/)?([1-9]\d*)\/runs$/);
|
|
113
117
|
if (!match)
|
|
@@ -118,9 +122,9 @@ export async function loadDoctorCase(runsPath) {
|
|
|
118
122
|
const id = relative(root, path).split(sep).join("/");
|
|
119
123
|
const bytes = await readFile(path);
|
|
120
124
|
const content = bytes.toString("utf8");
|
|
121
|
-
const kind = id.endsWith(".jsonl") ? "
|
|
125
|
+
const kind = id.split("/").length === 2 && id.endsWith("/log.jsonl") ? "log" : "session";
|
|
122
126
|
evidence.push({ id, kind, byteLength: bytes.byteLength, contentLength: content.length, sha256: sha256Hex(bytes), content });
|
|
123
|
-
if (kind === "
|
|
127
|
+
if (kind === "log")
|
|
124
128
|
continue;
|
|
125
129
|
const result = deriveSession(content, id);
|
|
126
130
|
sessions.push(result.session);
|
|
@@ -15,9 +15,11 @@
|
|
|
15
15
|
* `ak-role resume`) mints a new one. Never courtAttemptId, never Pi session
|
|
16
16
|
* toolResult join keys, and never a detour-owned sidecar file.
|
|
17
17
|
*/
|
|
18
|
+
import { readPageSync, RUN_LOG_FILE } from "./run-dossier.js";
|
|
18
19
|
import { randomUUID } from "node:crypto";
|
|
19
20
|
import { readFileSync } from "node:fs";
|
|
20
|
-
import {
|
|
21
|
+
import { join } from "node:path";
|
|
22
|
+
export { runDirectoryFromSessionDirectory, sessionFileIn as sessionFileFromSessionDirectory, } from "./role-run-placement.js";
|
|
21
23
|
import { ENGINE_DETOUR_TOOL_NAME } from "./engine-detour.js";
|
|
22
24
|
import { readSitianRecords, resolveSitianRecordPath, sitianReport, } from "./sitian-facade.js";
|
|
23
25
|
import { isRecord } from "./unknown-value.js";
|
|
@@ -26,11 +28,11 @@ export const ENGINE_DETOUR_CALL_KIND = "engine-detour-call";
|
|
|
26
28
|
/** decisiveFacts key — name states detour-tool scope, not full engine usage. */
|
|
27
29
|
export const ENGINE_DETOUR_TOOL_USAGE_FACT_KEY = "engineDetourToolUsage";
|
|
28
30
|
/**
|
|
29
|
-
* Run-relative
|
|
31
|
+
* Run-relative path of the log that holds one detour call's record.
|
|
30
32
|
* Openable once the run directory is known from the terminal's run id.
|
|
31
33
|
* Contains no runId bytes itself (#108 + #537).
|
|
32
34
|
*/
|
|
33
|
-
export const ENGINE_DETOUR_CALL_RECORD_FILE_RELATIVE =
|
|
35
|
+
export const ENGINE_DETOUR_CALL_RECORD_FILE_RELATIVE = RUN_LOG_FILE;
|
|
34
36
|
/** stdout UTF-8 byte length (ticket-frozen metric; empty stdout is real 0). */
|
|
35
37
|
export function engineDetourStdoutByteLength(stdout) {
|
|
36
38
|
return Buffer.byteLength(stdout, "utf8");
|
|
@@ -180,19 +182,11 @@ export async function readEngineDetourToolUsage(input) {
|
|
|
180
182
|
const calls = Array.from(callsByToolCallId.values());
|
|
181
183
|
return { callCount: calls.length, calls };
|
|
182
184
|
}
|
|
183
|
-
/** One shared
|
|
185
|
+
/** One shared state.jsonl invocation-row reader (absent → undefined; other errors propagate). */
|
|
184
186
|
function readInvocationRecord(runDirectory) {
|
|
185
|
-
|
|
186
|
-
const raw = JSON.parse(readFileSync(join(runDirectory, "invocation.json"), "utf8"));
|
|
187
|
-
return isRecord(raw) ? raw : undefined;
|
|
188
|
-
}
|
|
189
|
-
catch (error) {
|
|
190
|
-
if (error?.code === "ENOENT")
|
|
191
|
-
return undefined;
|
|
192
|
-
throw error;
|
|
193
|
-
}
|
|
187
|
+
return readPageSync(runDirectory, "invocation");
|
|
194
188
|
}
|
|
195
|
-
/** True when invocation
|
|
189
|
+
/** True when the invocation section carries a non-empty engine axis. */
|
|
196
190
|
export async function readInvocationEngineMounted(runDirectory) {
|
|
197
191
|
const raw = readInvocationRecord(runDirectory);
|
|
198
192
|
if (raw === undefined)
|
|
@@ -212,14 +206,6 @@ export function withEngineDetourToolUsageFact(outcome, usage) {
|
|
|
212
206
|
},
|
|
213
207
|
};
|
|
214
208
|
}
|
|
215
|
-
/** runDirectory owning a session directory (.../runs/<id>@role/session). */
|
|
216
|
-
export function runDirectoryFromSessionDirectory(sessionDirectory) {
|
|
217
|
-
return dirname(sessionDirectory);
|
|
218
|
-
}
|
|
219
|
-
/** session.jsonl under a session directory. */
|
|
220
|
-
export function sessionFileFromSessionDirectory(sessionDirectory) {
|
|
221
|
-
return join(sessionDirectory, "session.jsonl");
|
|
222
|
-
}
|
|
223
209
|
/**
|
|
224
210
|
* Mint one public-invocation scope id.
|
|
225
211
|
* Call once at the public-entry boundary — never inside the auto-resume loop.
|