@akagilnc/pi-workflow-roles 0.1.5382 → 0.1.5406
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 +2 -0
- package/README.zh-CN.md +2 -0
- package/dist/acp-host/production-host.js +2523 -1880
- package/dist/archivist-record-pointer.js +38 -0
- package/dist/compliance-transport.js +5 -0
- package/dist/doctor-auditor.js +1 -0
- package/dist/engine-detour-usage.js +6 -6
- package/dist/headless-host/production-host.js +1097 -454
- package/dist/judge-role.js +14 -1
- package/dist/migrate-book-topology.js +190 -74
- package/dist/navigator-attendance.js +10 -9
- package/dist/navigator-invocation-identity.js +18 -0
- package/dist/pi/role-turn-host.js +9 -0
- package/dist/public-cli/cli.js +1 -0
- package/dist/public-cli/instruction-seat-run.js +250 -44
- package/dist/public-cli/main.js +929 -323
- package/dist/public-cli/post-admission.js +427 -244
- package/dist/public-cli/settlement.js +111 -48
- package/dist/public-cli/terminal.js +12 -1
- package/dist/public-cli/turn-request.js +3 -0
- package/dist/receipt-delivery-policy.js +152 -17
- package/dist/submission-errors.js +11 -1
- package/dist/submission-gate.js +27 -4
- package/package.json +1 -1
- package/src/archivist-record-pointer.ts +48 -0
- package/src/compliance-transport.ts +10 -2
- package/src/doctor-auditor.ts +3 -0
- package/src/engine-detour-usage.ts +7 -6
- package/src/external-host-turn-loop.ts +24 -12
- package/src/gatekeeper-role.ts +2 -2
- package/src/host-contracts.ts +7 -0
- package/src/judge-role.ts +24 -5
- package/src/navigator-attendance.ts +17 -12
- package/src/navigator-invocation-identity.ts +31 -0
- package/src/pi/adapter.ts +33 -8
- package/src/pi/role-turn-host.ts +7 -0
- package/src/public-cli/cli.ts +1 -0
- package/src/public-cli/instruction-seat-run.ts +283 -49
- package/src/public-cli/post-admission.ts +556 -324
- package/src/public-cli/settlement.ts +112 -50
- package/src/public-cli/terminal.ts +16 -4
- package/src/public-cli/turn-request.ts +10 -1
- package/src/receipt-delivery-policy.ts +209 -17
- package/src/role-envelope.ts +5 -1
- package/src/role-runtime-dependencies.ts +1 -0
- package/src/role-runtime.ts +65 -21
- package/src/submission-correctable-error.ts +5 -2
- package/src/submission-errors.ts +12 -1
- package/src/submission-gate.ts +34 -4
- package/src/worker-role.ts +19 -7
- package/src/worker-submission-gates.ts +29 -7
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
2
3
|
import { dirname, join } from "node:path";
|
|
4
|
+
import { isRecord } from "./unknown-value.js";
|
|
3
5
|
/** Typed parent-side pointer to an independent officer run 正本 (ADR 0079 / #675). */
|
|
4
6
|
export const DIRECT_OFFICER_RUN_POINTER_KIND = "direct-officer-run-pointer";
|
|
5
7
|
/**
|
|
@@ -14,6 +16,7 @@ export const DIRECT_OFFICER_RUN_POINTER_KIND = "direct-officer-run-pointer";
|
|
|
14
16
|
export function bookDirectOfficerRunPointer(options) {
|
|
15
17
|
const nest = join(dirname(options.parentSessionFile), "auditor-roles");
|
|
16
18
|
mkdirSync(nest, { recursive: true });
|
|
19
|
+
const submissionToolCallId = options.submissionToolCallId?.trim() ?? "";
|
|
17
20
|
const pointer = {
|
|
18
21
|
version: 1,
|
|
19
22
|
kind: DIRECT_OFFICER_RUN_POINTER_KIND,
|
|
@@ -22,7 +25,42 @@ export function bookDirectOfficerRunPointer(options) {
|
|
|
22
25
|
...(options.runDirectory !== undefined && options.runDirectory.trim() !== ""
|
|
23
26
|
? { runDirectory: options.runDirectory }
|
|
24
27
|
: {}),
|
|
28
|
+
...(submissionToolCallId === "" ? {} : { submissionToolCallId }),
|
|
25
29
|
};
|
|
26
30
|
writeFileSync(join(nest, `${options.officer}.pointer.json`), `${JSON.stringify(pointer)}\n`, "utf8");
|
|
27
31
|
return pointer;
|
|
28
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Read the one officer pointer. Missing or unreadable is not a pass:
|
|
35
|
+
* the caller re-runs the gate.
|
|
36
|
+
*/
|
|
37
|
+
export async function readDirectOfficerRunPointer(parentSessionFile, officer) {
|
|
38
|
+
try {
|
|
39
|
+
const raw = JSON.parse(await readFile(join(dirname(parentSessionFile), "auditor-roles", `${officer}.pointer.json`), "utf8"));
|
|
40
|
+
if (!isRecord(raw) || raw.kind !== DIRECT_OFFICER_RUN_POINTER_KIND || raw.version !== 1) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
if (raw.officer !== officer)
|
|
44
|
+
return undefined;
|
|
45
|
+
if (typeof raw.sessionFile !== "string" || raw.sessionFile.trim() === "")
|
|
46
|
+
return undefined;
|
|
47
|
+
const runDirectory = typeof raw.runDirectory === "string" && raw.runDirectory.trim() !== ""
|
|
48
|
+
? raw.runDirectory
|
|
49
|
+
: undefined;
|
|
50
|
+
const submissionToolCallId = typeof raw.submissionToolCallId === "string"
|
|
51
|
+
&& raw.submissionToolCallId.trim() !== ""
|
|
52
|
+
? raw.submissionToolCallId
|
|
53
|
+
: undefined;
|
|
54
|
+
return {
|
|
55
|
+
version: 1,
|
|
56
|
+
kind: DIRECT_OFFICER_RUN_POINTER_KIND,
|
|
57
|
+
officer,
|
|
58
|
+
sessionFile: raw.sessionFile,
|
|
59
|
+
...(runDirectory === undefined ? {} : { runDirectory }),
|
|
60
|
+
...(submissionToolCallId === undefined ? {} : { submissionToolCallId }),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -3,6 +3,7 @@ import { officerConclusionReask } from "./gatekeeper-role.js";
|
|
|
3
3
|
import { receivedDiscriminator } from "./submission-errors.js";
|
|
4
4
|
import { coalesceSubmissionRows } from "./public-cli/terminal.js";
|
|
5
5
|
import { readableGateItem } from "./readable-gate-item.js";
|
|
6
|
+
import { deliveryLimitFromConfig } from "./receipt-delivery-policy.js";
|
|
6
7
|
import { isRecord } from "./unknown-value.js";
|
|
7
8
|
const AUDITOR_DOSSIER_PROMPT = "\u5377\u5B97\u6307\u9488\uFF1A";
|
|
8
9
|
const COMPLIANCE_RESPONSE_ENTRY_TYPE = "ak_compliance_response";
|
|
@@ -120,10 +121,14 @@ async function runComplianceAudit(options) {
|
|
|
120
121
|
});
|
|
121
122
|
});
|
|
122
123
|
let reask;
|
|
124
|
+
let reasksSpent = 0;
|
|
125
|
+
const reaskLimit = deliveryLimitFromConfig(options.autoResumeLimit);
|
|
123
126
|
for (; ; ) {
|
|
124
127
|
const summoned = await summon(subject, runDirectory, options.signal, reask, submission);
|
|
125
128
|
const decision = await projectAuditorTerminal(summoned);
|
|
126
129
|
if (decision.status === "received") {
|
|
130
|
+
if (reasksSpent >= reaskLimit) return decision;
|
|
131
|
+
reasksSpent += 1;
|
|
127
132
|
reask = officerConclusionReask(receivedDiscriminator(decision.reply, "status"));
|
|
128
133
|
continue;
|
|
129
134
|
}
|
package/dist/doctor-auditor.js
CHANGED
|
@@ -20,6 +20,7 @@ export function createPiDoctorAuditor() {
|
|
|
20
20
|
? {}
|
|
21
21
|
: { runDirectory: auditorRunDirectory(options.context) }),
|
|
22
22
|
...(options.signal === undefined ? {} : { signal: options.signal }),
|
|
23
|
+
...(options.autoResumeLimit === undefined ? {} : { autoResumeLimit: options.autoResumeLimit }),
|
|
23
24
|
...(options.summonAuditor === undefined ? {} : { summonAuditor: options.summonAuditor }),
|
|
24
25
|
});
|
|
25
26
|
};
|
|
@@ -248,14 +248,14 @@ export function sessionFileFromSessionDirectory(sessionDirectory) {
|
|
|
248
248
|
return join(sessionDirectory, "session.jsonl");
|
|
249
249
|
}
|
|
250
250
|
/**
|
|
251
|
-
* Mint one public-invocation scope id
|
|
251
|
+
* Mint one public-invocation scope id.
|
|
252
252
|
* Call once at the public-entry boundary — never inside the auto-resume loop.
|
|
253
|
-
*
|
|
253
|
+
* Auto-resume reuses it; an explicit new public call, including manual resume,
|
|
254
|
+
* mints another. The id lives on RoleTurnRequest / HostContext only.
|
|
255
|
+
* Receipt facts and detour rows both use this id, including calls with no
|
|
256
|
+
* engine mounted — a missing engine must not merge two public calls.
|
|
254
257
|
*/
|
|
255
|
-
export function mintEngineDetourInvocationScope(
|
|
256
|
-
const engine = input.effectiveEngine?.trim();
|
|
257
|
-
if (engine === undefined || engine.length === 0)
|
|
258
|
-
return undefined;
|
|
258
|
+
export function mintEngineDetourInvocationScope(_input) {
|
|
259
259
|
return randomUUID();
|
|
260
260
|
}
|
|
261
261
|
/** Attach a minted scope onto a turn request (shared Host envelope field). */
|