@akagilnc/pi-workflow-roles 0.1.3565 → 0.1.3572
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 +4 -1
- package/README.zh-CN.md +1 -1
- package/dist/acp-host/production-host.js +755 -60
- package/dist/diarist-contracts.js +72 -0
- package/dist/package-contracts/terminating-tools.js +20 -2
- package/dist/packaged-role-registry.js +20 -0
- package/dist/public-cli/main.js +533 -634
- package/dist/public-cli/registry.js +4 -1
- package/extensions/role-runtime.ts +1 -0
- package/package.json +1 -1
- package/resources/diarist-collect.md +6 -10
- package/souls/diarist.md +9 -0
- package/src/acp-host/production-host.ts +1 -0
- package/src/acp-host/role-envelope.ts +2 -1
- package/src/diarist-contracts.ts +88 -0
- package/src/diarist-role.ts +60 -0
- package/src/diarist.ts +253 -179
- package/src/host-contracts.ts +6 -1
- package/src/package-contracts/terminating-tools.ts +22 -2
- package/src/packaged-role-registry.ts +20 -0
- package/src/pi/role-turn-host.ts +8 -0
- package/src/public-cli/cli.ts +29 -0
- package/src/public-cli/countersign-run.ts +9 -129
- package/src/public-cli/diarist-run.ts +312 -0
- package/src/public-cli/invocation.ts +23 -2
- package/src/public-cli/option-definitions.ts +18 -0
- package/src/public-cli/post-admission.ts +2 -2
- package/src/public-cli/registry.ts +3 -0
- package/src/public-cli/run-lifecycle.ts +31 -3
- package/src/public-cli/settlement.ts +50 -2
- package/src/public-cli/terminal.ts +2 -1
- package/src/role-runtime.ts +117 -6
- package/src/ticket-provenance-contracts.ts +1 -0
- package/src/ticket-provenance.ts +0 -23
- package/src/diarist-llm-collector.ts +0 -324
|
@@ -65,7 +65,10 @@ const STARTUP_CANDIDATES = {
|
|
|
65
65
|
navigator: [
|
|
66
66
|
{ provider: "openai-codex", model: "gpt-5.6-luna", thinking: "medium" },
|
|
67
67
|
{ provider: "xai", model: "grok-4.5", thinking: "high" }
|
|
68
|
-
]
|
|
68
|
+
],
|
|
69
|
+
// #708 `diarist-seat-default`: owner-set initial value; changed in the seat
|
|
70
|
+
// table like any other seat. No engine axis, package-default host.
|
|
71
|
+
diarist: [{ provider: "xai", model: "grok-4.5", thinking: "medium" }]
|
|
69
72
|
};
|
|
70
73
|
function publicStartupCandidates(seat) {
|
|
71
74
|
return STARTUP_CANDIDATES[seat];
|
|
@@ -127,6 +127,7 @@ export default function roleRuntime(pi: ExtensionAPI): void {
|
|
|
127
127
|
loadNotarySoul: () => loadMainRoleSessionMaterials("notary"),
|
|
128
128
|
loadCountersignSoul: () => loadMainRoleSessionMaterials("countersign"),
|
|
129
129
|
loadGleanerLeftSoul: () => loadMainRoleSessionMaterials("gleaner-left"),
|
|
130
|
+
loadDiaristSoul: () => loadMainRoleSessionMaterials("diarist"),
|
|
130
131
|
loadInspectorSoul: () => loadMainRoleSessionMaterials("inspector"),
|
|
131
132
|
loadGatekeeperSoul: () => loadGatekeeperSessionMaterials("gatekeeper"),
|
|
132
133
|
loadNavigatorSoul: () => loadMainRoleSessionMaterials("navigator"),
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# 起居郎收集方法(owner-domain)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
本文件是起居郎语义收集的方法真源(ADR 0075 `diarist-llm-collector` / `transcribe-whole-blocks`)。
|
|
4
4
|
|
|
5
5
|
## 任务
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
从本票已冻结的来源块文件中,选出**与本票决策相关**的整块。文件路径见本轮材料中的路径指针,自行读取;不要等别人把正文贴进对话。
|
|
8
8
|
|
|
9
9
|
## 何谓决策相关
|
|
10
10
|
|
|
@@ -14,16 +14,12 @@
|
|
|
14
14
|
- 命名、工序先后、调用面、闸位、存量是否补档等裁决
|
|
15
15
|
- 对既有 ADR / 法源的采纳、修正或明确不适用
|
|
16
16
|
- 陛下(owner)原话、确认、否决、收口条件
|
|
17
|
-
-
|
|
17
|
+
- 为上述裁决提供必要上下文的紧邻块
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
无关闲聊、纯工具噪声、与本票决策无涉的他票材料不选。
|
|
20
20
|
|
|
21
21
|
## 誊录整块
|
|
22
22
|
|
|
23
|
-
-
|
|
24
|
-
-
|
|
23
|
+
- 入选即整块保留:指向文件中的完整 transcript,不指针化、不摘要替代正文。
|
|
24
|
+
- 引语必须是该块 transcript 内的**连续原文子串**。拼接、改写、跨段拼贴会在机械反验中失败并拒入录。
|
|
25
25
|
- 宁多勿漏:拿不准是否决策相关时入选,由下游反验与人读面承接。
|
|
26
|
-
|
|
27
|
-
## 输出
|
|
28
|
-
|
|
29
|
-
只输出一个 JSON 对象,形状由机器 prompt 给出的 `selections` 约定。不要输出 JSON 以外的文字。
|
package/souls/diarist.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Diarist Soul(起居郎)
|
|
2
|
+
|
|
3
|
+
你为本案找齐并整理决策依据,收进本票已有的起居录。你只记录已经作出的决定,不立法、不批准设计、不指挥施工。
|
|
4
|
+
|
|
5
|
+
- 相关性由你裁决:不把票面已列出的材料当完整候选集合,也不以票号、引语或关键词未命中作为排除依据。
|
|
6
|
+
- 分清身份:陛下(owner)的决定、助手的提议、正式裁决、你自己的整理解释,四者不得混同;建议不得写成授权。
|
|
7
|
+
- 导航而非重写:已有设计与法源以原件指针加简短关系说明引用,不复制成第二份规范。
|
|
8
|
+
- 分清现行与历史:被修订替代的决定保留出处,但不与当前方向并列。
|
|
9
|
+
- 缺录、不可读、引用无法核实时如实说明,不猜成事实,不以缺失充当"没有问题"。
|
|
@@ -64,6 +64,7 @@ export function createAcpRoleRuntimeDependencies(packageRoot: string): RoleRunti
|
|
|
64
64
|
loadNotarySoul: () => loadMainRoleSessionMaterials("notary"),
|
|
65
65
|
loadCountersignSoul: () => loadMainRoleSessionMaterials("countersign"),
|
|
66
66
|
loadGleanerLeftSoul: () => loadMainRoleSessionMaterials("gleaner-left"),
|
|
67
|
+
loadDiaristSoul: () => loadMainRoleSessionMaterials("diarist"),
|
|
67
68
|
loadNotarySourceRun: loadNotarySourceRunLocator,
|
|
68
69
|
loadMergerSoul: () => loadMainRoleSessionMaterials("merger"),
|
|
69
70
|
loadMergerInput: async (path) => JSON.parse(await readFile(path, "utf8")),
|
|
@@ -78,7 +78,8 @@ export function projectAcpActivationFlags(request: RoleTurnRequest): Map<string,
|
|
|
78
78
|
: "packetPath" in activation ? activation.packetPath
|
|
79
79
|
: "casePath" in activation ? activation.casePath
|
|
80
80
|
: "inputPath" in activation ? activation.inputPath
|
|
81
|
-
: "sourceRun" in activation ? activation.sourceRun
|
|
81
|
+
: "sourceRun" in activation ? activation.sourceRun
|
|
82
|
+
: "sourcesPath" in activation ? activation.sourcesPath : undefined;
|
|
82
83
|
if (path !== undefined) flags.set(inputFlag, path);
|
|
83
84
|
}
|
|
84
85
|
if (activation.role === "fixer" && activation.prerequisitesPath !== undefined) flags.set("ak-fixer-prerequisites", activation.prerequisitesPath);
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public 起居郎 (diarist) terminating receipt contracts — ADR 0075 `diarist-is-role`.
|
|
3
|
+
* Lawful explicit release: completed, with empty or nonempty selections.
|
|
4
|
+
* Machine facts about the volume come from the mechanical sitian seam, never
|
|
5
|
+
* from model self-report (锚定宪法); this module owns the receipt shape only.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export const DIARIST_OUTPUT_TOOL_NAME = "ak_diarist_output";
|
|
9
|
+
export const DIARIST_ACCEPTED_TEXT = "起居郎回执已接受";
|
|
10
|
+
|
|
11
|
+
/** Internal transport: frozen candidate-catalog path for this turn's ticket. */
|
|
12
|
+
export const DIARIST_SOURCES_FLAG = {
|
|
13
|
+
name: "ak-diarist-sources",
|
|
14
|
+
definition: {
|
|
15
|
+
description: "Frozen per-ticket source catalog the diarist selects from",
|
|
16
|
+
type: "string" as const,
|
|
17
|
+
},
|
|
18
|
+
} as const;
|
|
19
|
+
|
|
20
|
+
/** One selected block reference into the frozen candidate catalog. */
|
|
21
|
+
export type DiaristSelection = {
|
|
22
|
+
/** Index into the catalog the diarist received. */
|
|
23
|
+
readonly candidateIndex: number;
|
|
24
|
+
/** Quotes claimed verbatim from that block (reverse-verified mechanically). */
|
|
25
|
+
readonly quotes: readonly string[];
|
|
26
|
+
/** Human-facing note (relation to this case). Not a machine gate. */
|
|
27
|
+
readonly note?: string;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type DiaristOutput = {
|
|
31
|
+
readonly status: "completed";
|
|
32
|
+
readonly selections: readonly DiaristSelection[];
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export function validateRecordedDiaristOutput(value: unknown): DiaristOutput {
|
|
36
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
37
|
+
throw new Error("Diarist output has no execution discriminator");
|
|
38
|
+
}
|
|
39
|
+
let status: unknown;
|
|
40
|
+
try {
|
|
41
|
+
status = (value as Record<string, unknown>).status;
|
|
42
|
+
} catch {
|
|
43
|
+
throw new Error("Diarist output has no execution discriminator");
|
|
44
|
+
}
|
|
45
|
+
if (status === "completed") {
|
|
46
|
+
return value as DiaristOutput;
|
|
47
|
+
}
|
|
48
|
+
throw new Error("Diarist output has no execution discriminator");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Lenient projection of submitted selections (第 0 条: shape is not an admission
|
|
53
|
+
* gate). Rows that carry no usable candidateIndex are dropped from the commit,
|
|
54
|
+
* never bounced back at the role.
|
|
55
|
+
*/
|
|
56
|
+
export function projectDiaristSelections(value: unknown): DiaristSelection[] {
|
|
57
|
+
const rows = (value as { selections?: unknown } | null)?.selections;
|
|
58
|
+
if (!Array.isArray(rows)) return [];
|
|
59
|
+
const out: DiaristSelection[] = [];
|
|
60
|
+
for (const row of rows) {
|
|
61
|
+
if (row === null || typeof row !== "object" || Array.isArray(row)) continue;
|
|
62
|
+
const record = row as Record<string, unknown>;
|
|
63
|
+
const index = record.candidateIndex;
|
|
64
|
+
if (typeof index !== "number" || !Number.isInteger(index) || index < 0) continue;
|
|
65
|
+
const quotes = Array.isArray(record.quotes)
|
|
66
|
+
? record.quotes.filter((q): q is string => typeof q === "string" && q.length > 0)
|
|
67
|
+
: [];
|
|
68
|
+
out.push({
|
|
69
|
+
candidateIndex: index,
|
|
70
|
+
quotes,
|
|
71
|
+
...(typeof record.note === "string" ? { note: record.note } : {}),
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return out;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Machine-facing facts from an accepted receipt. Submitted rows retained as-is. */
|
|
78
|
+
export function diaristDecisiveFacts(
|
|
79
|
+
output: DiaristOutput,
|
|
80
|
+
): Record<string, unknown> {
|
|
81
|
+
const facts: Record<string, unknown> = { status: output.status };
|
|
82
|
+
const selections = (output as { selections?: unknown }).selections;
|
|
83
|
+
if (Array.isArray(selections)) facts.selections = selections;
|
|
84
|
+
// Mechanical sitian facts recorded by the envelope at accept time.
|
|
85
|
+
const sitian = (output as { sitian?: unknown }).sitian;
|
|
86
|
+
if (sitian !== undefined) facts.sitian = sitian;
|
|
87
|
+
return facts;
|
|
88
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { Static } from "typebox";
|
|
2
|
+
import { Type } from "typebox";
|
|
3
|
+
|
|
4
|
+
import { openToolObject } from "./open-tool-schema.ts";
|
|
5
|
+
import { withInfrastructureFailureDeclaration } from "./package-contracts/terminating-infrastructure.ts";
|
|
6
|
+
import {
|
|
7
|
+
DIARIST_OUTPUT_TOOL_NAME,
|
|
8
|
+
validateRecordedDiaristOutput,
|
|
9
|
+
type DiaristOutput,
|
|
10
|
+
} from "./diarist-contracts.ts";
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
DIARIST_ACCEPTED_TEXT,
|
|
14
|
+
DIARIST_OUTPUT_TOOL_NAME,
|
|
15
|
+
} from "./diarist-contracts.ts";
|
|
16
|
+
export type { DiaristOutput };
|
|
17
|
+
export { validateRecordedDiaristOutput };
|
|
18
|
+
|
|
19
|
+
/** 起居郎交卷形状;形状指引,非 schema 闸。 */
|
|
20
|
+
export const diaristOutputSchema = withInfrastructureFailureDeclaration(
|
|
21
|
+
openToolObject(
|
|
22
|
+
Type.Object({
|
|
23
|
+
status: Type.Unknown({
|
|
24
|
+
description: "completed — 形状指引,非 schema 闸",
|
|
25
|
+
}),
|
|
26
|
+
selections: Type.Array(
|
|
27
|
+
Type.Object(
|
|
28
|
+
{
|
|
29
|
+
candidateIndex: Type.Number({ description: "候选目录中的整块序号" }),
|
|
30
|
+
quotes: Type.Array(Type.String(), {
|
|
31
|
+
description: "该块 transcript 内的连续原文;机械反验",
|
|
32
|
+
}),
|
|
33
|
+
note: Type.Optional(
|
|
34
|
+
Type.String({ description: "该材料与本案的关系(人读)" }),
|
|
35
|
+
),
|
|
36
|
+
},
|
|
37
|
+
{ additionalProperties: true, description: "一条入录选择" },
|
|
38
|
+
),
|
|
39
|
+
{ description: "入录选择;空列表合法完局" },
|
|
40
|
+
),
|
|
41
|
+
}),
|
|
42
|
+
),
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
export type DiaristOutputParameters = Static<typeof diaristOutputSchema>;
|
|
46
|
+
|
|
47
|
+
export type DiaristRuntimeDependencies = {
|
|
48
|
+
loadSoul(): Promise<string>;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* 决定工具规格。生命周期装配归注册信封 owner——src/role-runtime.ts(ADR 0018)。
|
|
53
|
+
*/
|
|
54
|
+
export const DIARIST_TOOL_SPEC = {
|
|
55
|
+
name: DIARIST_OUTPUT_TOOL_NAME,
|
|
56
|
+
label: "起居郎输出",
|
|
57
|
+
description: "起居郎入录选择。",
|
|
58
|
+
promptSnippet: "起居郎入录选择",
|
|
59
|
+
parameters: diaristOutputSchema,
|
|
60
|
+
} as const;
|