@akagilnc/pi-workflow-roles 0.1.3932 → 0.1.3975
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/CLAUDE.md +1 -1
- package/dist/acp-host/production-host.js +2389 -6018
- package/dist/analyst-gate-cycles-read.js +15 -19
- package/dist/audit-escalation.js +16 -46
- package/dist/auditor-dossier-tool.js +7 -62
- package/dist/collector-identity.js +0 -157
- package/dist/collector-ledger.js +2 -42
- package/dist/compliance-transport.js +40 -14
- package/dist/diarist-contracts.js +2 -40
- package/dist/doctor-contracts.js +39 -108
- package/dist/doctor-evidence.js +1 -5
- package/dist/engine-detour-tool.js +1 -1
- package/dist/gatekeeper-role.js +49 -38
- package/dist/headless-host/production-host.js +4814 -8450
- package/dist/host-contracts.js +0 -5
- package/dist/merger-contracts.js +4 -6
- package/dist/navigator-attendance.js +30 -52
- package/dist/navigator-invocation-identity.js +0 -1
- package/dist/navigator-public-session.js +2 -1
- package/dist/notary-contracts.js +4 -10
- package/dist/package-contracts/auditor-output.js +5 -23
- package/dist/package-contracts/fixer-output.js +25 -49
- package/dist/package-contracts/gatekeeper-output.js +3 -13
- package/dist/package-contracts/navigator-output.js +4 -7
- package/dist/package-contracts/reviewer-output.js +1 -95
- package/dist/package-contracts/terminating-tools.js +33 -144
- package/dist/package-contracts/worker-output.js +1 -3
- package/dist/public-cli/auto-resume.js +30 -68
- package/dist/public-cli/case-dossier-delivery.js +5 -17
- package/dist/public-cli/diarist-run.js +9 -4
- package/dist/public-cli/inspector-run.js +2 -8
- package/dist/public-cli/instruction-seat-run.js +3 -7
- package/dist/public-cli/invocation.js +5 -2
- package/dist/public-cli/main.js +6068 -6964
- package/dist/public-cli/notary-run.js +1 -8
- package/dist/public-cli/post-admission.js +314 -113
- package/dist/public-cli/run-lifecycle.js +14 -38
- package/dist/public-cli/settlement.js +209 -390
- package/dist/public-cli/terminal.js +51 -45
- package/dist/public-role-summons.js +1 -12
- package/dist/reviewer-dispatch.js +12 -258
- package/dist/submission-correctable-error.js +0 -12
- package/dist/submission-errors.js +6 -1
- package/dist/submission-ledger.js +125 -168
- package/dist/ticket-provenance-contracts.js +2 -49
- package/dist/ticket-provenance.js +82 -31
- package/extensions/role-runtime.ts +1 -6
- package/package.json +1 -1
- package/resources/836-deleted-machine-instruction-inventory.md +18 -0
- package/src/acp-host/role-turn-host.ts +8 -3
- package/src/analyst-gate-cycles-read.ts +17 -29
- package/src/audit-escalation.ts +20 -50
- package/src/auditor-dossier-tool.ts +5 -103
- package/src/canonical-skill-binding.ts +3 -2
- package/src/collector-identity.ts +0 -179
- package/src/collector-ledger.ts +3 -46
- package/src/collector-role.ts +32 -61
- package/src/collector-tool-schemas.ts +20 -14
- package/src/compliance-transport.ts +55 -17
- package/src/countersign-role.ts +17 -8
- package/src/diarist-contracts.ts +3 -36
- package/src/diarist-role.ts +13 -7
- package/src/diarist.ts +4 -16
- package/src/doctor-contracts.ts +73 -94
- package/src/doctor-evidence.ts +1 -1
- package/src/doctor-role.ts +3 -3
- package/src/engine-detour-tool.ts +4 -1
- package/src/external-host-turn-loop.ts +9 -3
- package/src/gatekeeper-pass-envelope.ts +7 -12
- package/src/gatekeeper-role.ts +56 -50
- package/src/gleaner-left-role.ts +4 -2
- package/src/headless-host/role-turn-host.ts +4 -5
- package/src/host-contracts.ts +3 -8
- package/src/judge-role.ts +19 -13
- package/src/merger-contracts.ts +10 -6
- package/src/merger-role.ts +1 -5
- package/src/navigator-attendance.ts +37 -74
- package/src/navigator-invocation-identity.ts +0 -6
- package/src/navigator-public-session.ts +2 -1
- package/src/notary-contracts.ts +7 -10
- package/src/package-contracts/auditor-output.ts +4 -21
- package/src/package-contracts/fixer-output.ts +34 -52
- package/src/package-contracts/gatekeeper-output.ts +5 -22
- package/src/package-contracts/navigator-output.ts +7 -7
- package/src/package-contracts/reviewer-output.ts +2 -150
- package/src/package-contracts/terminating-tools.ts +32 -147
- package/src/package-contracts/worker-output.ts +0 -1
- package/src/pi/adapter.ts +3 -8
- package/src/public-cli/auto-resume.ts +41 -94
- package/src/public-cli/case-dossier-delivery.ts +5 -15
- package/src/public-cli/countersign-run.ts +14 -6
- package/src/public-cli/diarist-run.ts +11 -9
- package/src/public-cli/inspector-run.ts +2 -18
- package/src/public-cli/instruction-seat-run.ts +3 -17
- package/src/public-cli/invocation.ts +5 -2
- package/src/public-cli/merger-run.ts +1 -1
- package/src/public-cli/notary-run.ts +1 -18
- package/src/public-cli/post-admission.ts +385 -115
- package/src/public-cli/run-lifecycle.ts +13 -44
- package/src/public-cli/settlement.ts +314 -562
- package/src/public-cli/terminal.ts +66 -72
- package/src/public-role-summons.ts +5 -30
- package/src/reviewer-dispatch.ts +29 -331
- package/src/reviewer-role.ts +16 -83
- package/src/role-envelope.ts +16 -24
- package/src/role-runtime-dependencies.ts +1 -6
- package/src/role-runtime.ts +65 -201
- package/src/submission-correctable-error.ts +0 -14
- package/src/submission-errors.ts +6 -1
- package/src/submission-ledger.ts +187 -187
- package/src/ticket-provenance-contracts.ts +4 -60
- package/src/ticket-provenance.ts +98 -32
- package/src/worker-role.ts +35 -36
- package/dist/activation-ledger-session.js +0 -105
- package/dist/activation-ledger.js +0 -139
- package/dist/activation-trace.js +0 -33
- package/dist/atomic-write.js +0 -23
- package/dist/auditor-role.js +0 -12
- package/dist/canonical-skill-binding.js +0 -61
- package/dist/collector-handbook.js +0 -142
- package/dist/collector-receipt.js +0 -107
- package/dist/collector-role.js +0 -566
- package/dist/collector-tool-schemas.js +0 -107
- package/dist/countersign-role.js +0 -28
- package/dist/diarist-role.js +0 -44
- package/dist/diarist.js +0 -66
- package/dist/doctor-role.js +0 -75
- package/dist/fixer-bash-seatbelt.js +0 -13
- package/dist/gatekeeper-pass-envelope.js +0 -77
- package/dist/gleaner-left-role.js +0 -26
- package/dist/inspector-role.js +0 -29
- package/dist/judge-role.js +0 -104
- package/dist/merger-role.js +0 -55
- package/dist/navigator-role.js +0 -12
- package/dist/notary-role.js +0 -134
- package/dist/oauth-keepalive.js +0 -158
- package/dist/pi/adapter.js +0 -223
- package/dist/reviewer-agent.js +0 -122
- package/dist/reviewer-child-executor.js +0 -194
- package/dist/reviewer-construction.js +0 -103
- package/dist/reviewer-execution-ledger.js +0 -166
- package/dist/reviewer-failure-diagnostic.js +0 -17
- package/dist/reviewer-role.js +0 -159
- package/dist/reviewer-scope-prompt.js +0 -21
- package/dist/reviewer-settlement.js +0 -66
- package/dist/reviewer-workspace.js +0 -132
- package/dist/role-runtime.js +0 -1604
- package/dist/stderr-jsonl.js +0 -26
- package/dist/tool-execution-observation.js +0 -141
- package/dist/worker-role.js +0 -345
- package/dist/worker-submission-gates.js +0 -305
- package/src/collector-receipt.ts +0 -140
- package/src/diagnostic-tail.ts +0 -18
- package/src/reviewer-agent.ts +0 -135
- package/src/reviewer-child-executor.ts +0 -252
- package/src/reviewer-construction.ts +0 -195
- package/src/reviewer-execution-ledger.ts +0 -212
- package/src/reviewer-failure-diagnostic.ts +0 -18
- package/src/reviewer-scope-prompt.ts +0 -24
- package/src/reviewer-settlement.ts +0 -74
- package/src/reviewer-workspace.ts +0 -105
- package/src/shape-unreadable-failure.ts +0 -49
package/dist/collector-role.js
DELETED
|
@@ -1,566 +0,0 @@
|
|
|
1
|
-
import { emptyCollectorManifest, loadCollectorManifest, parseCollectorPrNumber, parseCollectorRepository, } from "./collector-config.js";
|
|
2
|
-
import { COLLECTOR_DEFAULT_WAIT_WINDOW_MS, createSystemCollectorClock, } from "./collector-evidence.js";
|
|
3
|
-
import { createGhApiRunner, listPullRequestNumbersByTicket, } from "./collector-github.js";
|
|
4
|
-
import { createCollectorHandbookStore, resolveCollectorHandbookRoot, } from "./collector-handbook.js";
|
|
5
|
-
import { COLLECTOR_BIND_TARGET_TOOL, COLLECTOR_HANDBOOK_WRITE_TOOL, COLLECTOR_OBSERVE_TOOL, COLLECTOR_OPEN_WAIT_WINDOW_TOOL, COLLECTOR_OUTPUT_TOOL, COLLECTOR_READ_TOOL, COLLECTOR_REQUEST_TOOL, COLLECTOR_WAIT_TOOL, projectEvidenceEntryView, } from "./collector-ledger.js";
|
|
6
|
-
import { buildCollectorReceipt, } from "./collector-receipt.js";
|
|
7
|
-
import { collectorBindTargetArgsSchema, collectorHandbookWriteArgsSchema, collectorObserveArgsSchema, collectorOpenWaitWindowArgsSchema, collectorOutputArgsSchema, collectorReadArgsSchema, collectorRequestArgsSchema, collectorWaitArgsSchema, } from "./collector-tool-schemas.js";
|
|
8
|
-
import { COLLECTOR_ACCEPTED_TEXT } from "./package-contracts/collector-output.js";
|
|
9
|
-
import { CorrectableSubmissionError, isCorrectableExecuteError } from "./submission-correctable-error.js";
|
|
10
|
-
import { CollectorUnknownEvidenceError } from "./collector-identity.js";
|
|
11
|
-
export { CollectorUnknownEvidenceError } from "./collector-identity.js";
|
|
12
|
-
/**
|
|
13
|
-
* #641 chain②: normal completion must never declare `infrastructureFailure`.
|
|
14
|
-
* When the runtime can machine-verify a lawful receipt assembly, a declaration
|
|
15
|
-
* is model misuse — bounce it as correctable guidance instead of host failure.
|
|
16
|
-
*/
|
|
17
|
-
export class CollectorNormalCompletionDeclarationError extends CorrectableSubmissionError {
|
|
18
|
-
constructor() {
|
|
19
|
-
super("runtime 已按机器状态核验本局为正常完工(回执可合法组装):正常完工的交件不得填 infrastructureFailure,请省略该字段后重新提交。");
|
|
20
|
-
this.name = "CollectorNormalCompletionDeclarationError";
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
/** #676 A: role-chosen target could not bind uniquely — correctable, not host failure. */
|
|
24
|
-
export class CollectorTargetBindError extends CorrectableSubmissionError {
|
|
25
|
-
constructor(message) {
|
|
26
|
-
super(message);
|
|
27
|
-
this.name = "CollectorTargetBindError";
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
export { COLLECTOR_BIND_TARGET_TOOL, COLLECTOR_HANDBOOK_WRITE_TOOL, COLLECTOR_OBSERVE_TOOL, COLLECTOR_OPEN_WAIT_WINDOW_TOOL, COLLECTOR_OUTPUT_TOOL, COLLECTOR_READ_TOOL, COLLECTOR_REQUEST_TOOL, COLLECTOR_WAIT_TOOL, };
|
|
31
|
-
export const COLLECTOR_REQUIRED_TOOLS = [
|
|
32
|
-
COLLECTOR_BIND_TARGET_TOOL,
|
|
33
|
-
COLLECTOR_OBSERVE_TOOL,
|
|
34
|
-
COLLECTOR_READ_TOOL,
|
|
35
|
-
COLLECTOR_REQUEST_TOOL,
|
|
36
|
-
COLLECTOR_OPEN_WAIT_WINDOW_TOOL,
|
|
37
|
-
COLLECTOR_WAIT_TOOL,
|
|
38
|
-
COLLECTOR_HANDBOOK_WRITE_TOOL,
|
|
39
|
-
COLLECTOR_OUTPUT_TOOL,
|
|
40
|
-
];
|
|
41
|
-
/** Envelope-owned transport flags (ADR 0018 / #676 E). */
|
|
42
|
-
export const COLLECTOR_TRANSPORT_FLAGS = Object.freeze([
|
|
43
|
-
Object.freeze({
|
|
44
|
-
name: "ak-collector-repo",
|
|
45
|
-
definition: Object.freeze({
|
|
46
|
-
description: "GitHub owner/repo target for Collector (github.com only; conservative ASCII grammar).",
|
|
47
|
-
type: "string",
|
|
48
|
-
}),
|
|
49
|
-
}),
|
|
50
|
-
Object.freeze({
|
|
51
|
-
name: "ak-collector-pr",
|
|
52
|
-
definition: Object.freeze({
|
|
53
|
-
description: "Optional positive safe-integer pull request number for Collector. Omit when the role will bind from task materials.",
|
|
54
|
-
type: "string",
|
|
55
|
-
}),
|
|
56
|
-
}),
|
|
57
|
-
Object.freeze({
|
|
58
|
-
name: "ak-collector-request-manifest",
|
|
59
|
-
definition: Object.freeze({
|
|
60
|
-
description: "Path to the Collector v1 request manifest JSON file.",
|
|
61
|
-
type: "string",
|
|
62
|
-
}),
|
|
63
|
-
}),
|
|
64
|
-
Object.freeze({
|
|
65
|
-
name: "ak-collector-wait-ms",
|
|
66
|
-
definition: Object.freeze({
|
|
67
|
-
description: `Collector wait-window duration in milliseconds (default ${COLLECTOR_DEFAULT_WAIT_WINDOW_MS}). Caller-configurable; opens at a work step, not session start (#678 D4).`,
|
|
68
|
-
type: "string",
|
|
69
|
-
}),
|
|
70
|
-
}),
|
|
71
|
-
]);
|
|
72
|
-
const observeSchema = collectorObserveArgsSchema;
|
|
73
|
-
const readSchema = collectorReadArgsSchema;
|
|
74
|
-
const requestSchema = collectorRequestArgsSchema;
|
|
75
|
-
const openWaitWindowSchema = collectorOpenWaitWindowArgsSchema;
|
|
76
|
-
const waitSchema = collectorWaitArgsSchema;
|
|
77
|
-
const bindSchema = collectorBindTargetArgsSchema;
|
|
78
|
-
const handbookWriteSchema = collectorHandbookWriteArgsSchema;
|
|
79
|
-
const outputSchema = collectorOutputArgsSchema;
|
|
80
|
-
function parseWaitWindowMsFlag(raw) {
|
|
81
|
-
if (raw === undefined || raw === null || raw === "")
|
|
82
|
-
return COLLECTOR_DEFAULT_WAIT_WINDOW_MS;
|
|
83
|
-
if (typeof raw === "number" && Number.isSafeInteger(raw) && raw >= 1)
|
|
84
|
-
return raw;
|
|
85
|
-
if (typeof raw === "string" && /^[1-9]\d*$/.test(raw.trim())) {
|
|
86
|
-
const value = Number(raw.trim());
|
|
87
|
-
if (Number.isSafeInteger(value) && value >= 1)
|
|
88
|
-
return value;
|
|
89
|
-
}
|
|
90
|
-
throw new Error("Collector --ak-collector-wait-ms must be a positive safe-integer millisecond string");
|
|
91
|
-
}
|
|
92
|
-
function buildMethodContext(activation) {
|
|
93
|
-
const pr = activation.ledger.config.prNumber;
|
|
94
|
-
const handbook = activation.handbookView;
|
|
95
|
-
const lines = [
|
|
96
|
-
"<collector_method>",
|
|
97
|
-
`host: github.com`,
|
|
98
|
-
`repository: ${activation.repository.canonical}`,
|
|
99
|
-
`prNumber: ${pr === undefined ? "未绑定" : String(pr)}`,
|
|
100
|
-
`waitWindowMs: ${String(activation.ledger.config.waitWindowMs)}`,
|
|
101
|
-
`requests: ${JSON.stringify(activation.manifest.requests.map((request) => ({ id: request.id })))}`,
|
|
102
|
-
`handbookGeneralSource: ${handbook.generalSource}`,
|
|
103
|
-
`handbookRepoSource: ${handbook.repoSource}`,
|
|
104
|
-
"</collector_method>",
|
|
105
|
-
];
|
|
106
|
-
// Opaque working memory only — no directional instructions (ADR 0073).
|
|
107
|
-
// JSON + `<` → \u003c keeps bodies from forging the delivery close tag (#677).
|
|
108
|
-
if (handbook.general.length > 0 || handbook.repo.length > 0) {
|
|
109
|
-
const payload = JSON.stringify({
|
|
110
|
-
general: handbook.general,
|
|
111
|
-
repo: handbook.repo,
|
|
112
|
-
generalSource: handbook.generalSource,
|
|
113
|
-
repoSource: handbook.repoSource,
|
|
114
|
-
repository: activation.repository.canonical,
|
|
115
|
-
}).replaceAll("<", "\\u003c");
|
|
116
|
-
lines.push("", "<collector_handbook>", payload, "</collector_handbook>");
|
|
117
|
-
}
|
|
118
|
-
return lines.join("\n");
|
|
119
|
-
}
|
|
120
|
-
function parsePositiveTicket(raw, label) {
|
|
121
|
-
if (raw === undefined || raw === null)
|
|
122
|
-
return undefined;
|
|
123
|
-
if (typeof raw === "number" && Number.isSafeInteger(raw) && raw >= 1)
|
|
124
|
-
return raw;
|
|
125
|
-
if (typeof raw === "string" && /^[1-9]\d*$/.test(raw.trim()))
|
|
126
|
-
return Number(raw.trim());
|
|
127
|
-
throw new CollectorTargetBindError(`通进司绑定 ${label} 须为正安全整数`);
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Shared envelope installs business tools and material callback after lifecycle gates.
|
|
131
|
-
* Role module does not self-hook events, setActiveTools, or mode/fork checks (ADR 0018 / #676 E).
|
|
132
|
-
*/
|
|
133
|
-
export function createCollectorRoleRuntime(pi, dependencies, hostActions) {
|
|
134
|
-
let toolsRegistered = false;
|
|
135
|
-
return {
|
|
136
|
-
async activate(ctx) {
|
|
137
|
-
const soul = (await dependencies.loadSoul()).trim();
|
|
138
|
-
if (soul.length === 0)
|
|
139
|
-
throw new Error("Collector soul is empty");
|
|
140
|
-
// Flags registered by the shared envelope (COLLECTOR_TRANSPORT_FLAGS).
|
|
141
|
-
const repoFlag = pi.getFlag("ak-collector-repo");
|
|
142
|
-
const prFlag = pi.getFlag("ak-collector-pr");
|
|
143
|
-
const requestManifestFlag = pi.getFlag("ak-collector-request-manifest");
|
|
144
|
-
const waitMsFlag = pi.getFlag("ak-collector-wait-ms");
|
|
145
|
-
if (typeof repoFlag !== "string" || repoFlag.trim().length === 0) {
|
|
146
|
-
throw new Error("Collector requires --ak-collector-repo");
|
|
147
|
-
}
|
|
148
|
-
const repository = parseCollectorRepository(repoFlag);
|
|
149
|
-
// #676 A: PR may be unbound — role binds via ak_collector_bind_target from materials.
|
|
150
|
-
let prNumber;
|
|
151
|
-
if (typeof prFlag === "string" && prFlag.trim().length > 0) {
|
|
152
|
-
prNumber = parseCollectorPrNumber(prFlag);
|
|
153
|
-
}
|
|
154
|
-
else if (typeof prFlag === "number") {
|
|
155
|
-
prNumber = parseCollectorPrNumber(prFlag);
|
|
156
|
-
}
|
|
157
|
-
const manifest = typeof requestManifestFlag === "string" && requestManifestFlag.trim().length > 0
|
|
158
|
-
? await loadCollectorManifest(requestManifestFlag)
|
|
159
|
-
: emptyCollectorManifest();
|
|
160
|
-
const waitWindowMs = parseWaitWindowMsFlag(waitMsFlag);
|
|
161
|
-
const clock = dependencies.createClock?.() ?? createSystemCollectorClock();
|
|
162
|
-
const transport = dependencies.createTransport();
|
|
163
|
-
const ledger = dependencies.createLedger({ repository, prNumber, manifest, waitWindowMs }, clock, ctx);
|
|
164
|
-
// #677: handbook under admitted book topology (session path → books/<key>/collector-handbook).
|
|
165
|
-
const sessionPath = ctx.sessionManager?.getSessionFile?.()
|
|
166
|
-
?? ctx.sessionManager?.getSessionDir?.();
|
|
167
|
-
if (typeof sessionPath !== "string" || sessionPath.length === 0) {
|
|
168
|
-
throw new Error("通进司手册要求 session 路径位于 books/<bookKey>/");
|
|
169
|
-
}
|
|
170
|
-
const placement = resolveCollectorHandbookRoot(sessionPath);
|
|
171
|
-
const seedGeneral = dependencies.loadHandbookSeed === undefined
|
|
172
|
-
? undefined
|
|
173
|
-
: (await dependencies.loadHandbookSeed()).trim();
|
|
174
|
-
const handbook = createCollectorHandbookStore({
|
|
175
|
-
ledgerHome: placement.ledgerHome,
|
|
176
|
-
handbookRoot: placement.root,
|
|
177
|
-
repositoryCanonical: repository.canonical,
|
|
178
|
-
...(seedGeneral === undefined || seedGeneral.length === 0
|
|
179
|
-
? {}
|
|
180
|
-
: { seedGeneral }),
|
|
181
|
-
});
|
|
182
|
-
const handbookView = await handbook.read();
|
|
183
|
-
return {
|
|
184
|
-
soul,
|
|
185
|
-
repository,
|
|
186
|
-
manifest,
|
|
187
|
-
ledger,
|
|
188
|
-
transport,
|
|
189
|
-
clock,
|
|
190
|
-
handbook,
|
|
191
|
-
handbookView,
|
|
192
|
-
};
|
|
193
|
-
},
|
|
194
|
-
assembleMaterials(activation, baseSystemPrompt) {
|
|
195
|
-
return [
|
|
196
|
-
baseSystemPrompt,
|
|
197
|
-
"",
|
|
198
|
-
"<collector_soul>",
|
|
199
|
-
activation.soul,
|
|
200
|
-
"</collector_soul>",
|
|
201
|
-
"",
|
|
202
|
-
buildMethodContext(activation),
|
|
203
|
-
].join("\n");
|
|
204
|
-
},
|
|
205
|
-
onToolCall(activation, event) {
|
|
206
|
-
// Business ledger facts only — allowed-tool / mode gates live on the envelope.
|
|
207
|
-
if (activation.ledger.fatal) {
|
|
208
|
-
return {
|
|
209
|
-
block: true,
|
|
210
|
-
reason: activation.ledger.fatalReason ?? "通进司致命状态",
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
if (event.toolName === COLLECTOR_OUTPUT_TOOL) {
|
|
214
|
-
activation.ledger.beginOperational(COLLECTOR_OUTPUT_TOOL, event.toolCallId);
|
|
215
|
-
}
|
|
216
|
-
if (activation.ledger.outputCandidate &&
|
|
217
|
-
event.toolName !== COLLECTOR_OUTPUT_TOOL) {
|
|
218
|
-
return {
|
|
219
|
-
block: true,
|
|
220
|
-
reason: "通进司已产出输出候选,本局不再受理操作",
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
return undefined;
|
|
224
|
-
},
|
|
225
|
-
onToolResult(activation, event) {
|
|
226
|
-
activation.ledger.completeOperational(event.toolCallId);
|
|
227
|
-
},
|
|
228
|
-
registerBusinessTools(getActivation) {
|
|
229
|
-
if (toolsRegistered)
|
|
230
|
-
return;
|
|
231
|
-
toolsRegistered = true;
|
|
232
|
-
pi.registerTool({
|
|
233
|
-
name: COLLECTOR_BIND_TARGET_TOOL,
|
|
234
|
-
label: "通进司认票绑定",
|
|
235
|
-
description: "角色判定任务材料后绑定本仓唯一 PR 目标。可提交 prNumber 或 issueNumber(线上关联唯一 PR);显式 --pr 已绑定时无需再调。多义或无法确定时会正确驳回,要求调用方明确 --pr。",
|
|
236
|
-
promptSnippet: "绑定角色判定的 issue/PR 目标",
|
|
237
|
-
parameters: bindSchema,
|
|
238
|
-
async execute(toolCallId, params, _signal, _onUpdate, ctx) {
|
|
239
|
-
const activation = getActivation();
|
|
240
|
-
if (activation === undefined)
|
|
241
|
-
throw new Error("通进司未激活");
|
|
242
|
-
try {
|
|
243
|
-
activation.ledger.beginOperational(COLLECTOR_BIND_TARGET_TOOL, toolCallId);
|
|
244
|
-
const prNumber = parsePositiveTicket(params.prNumber, "prNumber");
|
|
245
|
-
const issueNumber = parsePositiveTicket(params.issueNumber, "issueNumber");
|
|
246
|
-
if (prNumber === undefined && issueNumber === undefined) {
|
|
247
|
-
throw new CollectorTargetBindError("通进司绑定须由角色判定 prNumber 与/或 issueNumber");
|
|
248
|
-
}
|
|
249
|
-
let bound = prNumber;
|
|
250
|
-
if (issueNumber !== undefined) {
|
|
251
|
-
const associated = await listPullRequestNumbersByTicket(createGhApiRunner(), {
|
|
252
|
-
owner: activation.repository.owner,
|
|
253
|
-
repo: activation.repository.repo,
|
|
254
|
-
ticketNumber: issueNumber,
|
|
255
|
-
});
|
|
256
|
-
if (associated.length === 0) {
|
|
257
|
-
throw new CollectorTargetBindError(`${activation.repository.canonical} 的 issue #${issueNumber} 无关联 PR;请改用明确 --pr 或其他 issueNumber`);
|
|
258
|
-
}
|
|
259
|
-
if (associated.length > 1) {
|
|
260
|
-
throw new CollectorTargetBindError(`issue #${issueNumber} 关联多个 PR:${associated.join("、")};请改用明确 prNumber 或 --pr`);
|
|
261
|
-
}
|
|
262
|
-
const fromIssue = associated[0];
|
|
263
|
-
if (prNumber !== undefined && prNumber !== fromIssue) {
|
|
264
|
-
throw new CollectorTargetBindError(`prNumber ${prNumber} 与 issue #${issueNumber} 关联 PR ${fromIssue} 冲突`);
|
|
265
|
-
}
|
|
266
|
-
bound = fromIssue;
|
|
267
|
-
}
|
|
268
|
-
activation.ledger.bindTarget(bound);
|
|
269
|
-
activation.ledger.completeOperational(toolCallId);
|
|
270
|
-
return {
|
|
271
|
-
content: [{
|
|
272
|
-
type: "text",
|
|
273
|
-
text: `目标已绑定:${activation.repository.canonical}#${bound}`,
|
|
274
|
-
}],
|
|
275
|
-
details: {
|
|
276
|
-
repository: activation.repository.canonical,
|
|
277
|
-
prNumber: bound,
|
|
278
|
-
...(issueNumber === undefined ? {} : { issueNumber }),
|
|
279
|
-
},
|
|
280
|
-
};
|
|
281
|
-
}
|
|
282
|
-
catch (error) {
|
|
283
|
-
if (isCorrectableExecuteError(error))
|
|
284
|
-
throw error;
|
|
285
|
-
hostActions.failInfrastructure(error, ctx, toolCallId);
|
|
286
|
-
}
|
|
287
|
-
finally {
|
|
288
|
-
try {
|
|
289
|
-
activation.ledger.completeOperational(toolCallId);
|
|
290
|
-
}
|
|
291
|
-
catch {
|
|
292
|
-
// already completed or not begun
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
},
|
|
296
|
-
});
|
|
297
|
-
pi.registerTool({
|
|
298
|
-
name: COLLECTOR_OBSERVE_TOOL,
|
|
299
|
-
label: "通进司观察",
|
|
300
|
-
description: "抓取配置目标的完整 GitHub PR 证据,存不可变快照入卷。正文在上下文中只给头部摘录加指针;需要头部之外的正文时,用 ak_collector_read 按 evidenceId 开卷;findings 的拆分与归类由你在交件时完成。目标未绑定前须先 ak_collector_bind_target。",
|
|
301
|
-
promptSnippet: "抓取配置目标 PR 证据",
|
|
302
|
-
parameters: observeSchema,
|
|
303
|
-
async execute(toolCallId, _params, signal, _onUpdate, ctx) {
|
|
304
|
-
const activation = getActivation();
|
|
305
|
-
if (activation === undefined)
|
|
306
|
-
throw new Error("通进司未激活");
|
|
307
|
-
try {
|
|
308
|
-
activation.ledger.beginOperational(COLLECTOR_OBSERVE_TOOL, toolCallId);
|
|
309
|
-
const { snapshot, contextView } = await activation.ledger.observe(activation.transport, activation.clock, signal);
|
|
310
|
-
activation.ledger.completeOperational(toolCallId);
|
|
311
|
-
return {
|
|
312
|
-
content: [{
|
|
313
|
-
type: "text",
|
|
314
|
-
text: JSON.stringify(contextView),
|
|
315
|
-
}],
|
|
316
|
-
details: contextView,
|
|
317
|
-
};
|
|
318
|
-
}
|
|
319
|
-
catch (error) {
|
|
320
|
-
if (isCorrectableExecuteError(error))
|
|
321
|
-
throw error;
|
|
322
|
-
hostActions.failInfrastructure(error, ctx, toolCallId);
|
|
323
|
-
}
|
|
324
|
-
},
|
|
325
|
-
});
|
|
326
|
-
pi.registerTool({
|
|
327
|
-
name: COLLECTOR_READ_TOOL,
|
|
328
|
-
label: "通进司开卷",
|
|
329
|
-
description: "按 evidenceId 开卷读取一条已观测材料的全量正文与指针;只在观察头部摘录不足以判读时调用。",
|
|
330
|
-
promptSnippet: "按指针开卷读材料",
|
|
331
|
-
parameters: readSchema,
|
|
332
|
-
async execute(toolCallId, params, _signal, _onUpdate, ctx) {
|
|
333
|
-
const activation = getActivation();
|
|
334
|
-
if (activation === undefined)
|
|
335
|
-
throw new Error("通进司未激活");
|
|
336
|
-
try {
|
|
337
|
-
activation.ledger.beginOperational(COLLECTOR_READ_TOOL, toolCallId);
|
|
338
|
-
const record = activation.ledger.getEvidence(params.evidenceId);
|
|
339
|
-
if (record === undefined ||
|
|
340
|
-
(record.kind !== "review" && record.kind !== "issue_comment" && record.kind !== "review_comment" && record.kind !== "reaction") ||
|
|
341
|
-
typeof record.body !== "string") {
|
|
342
|
-
throw new CollectorUnknownEvidenceError(params.evidenceId);
|
|
343
|
-
}
|
|
344
|
-
const material = projectEvidenceEntryView(record);
|
|
345
|
-
activation.ledger.completeOperational(toolCallId);
|
|
346
|
-
return {
|
|
347
|
-
content: [{
|
|
348
|
-
type: "text",
|
|
349
|
-
text: JSON.stringify(material),
|
|
350
|
-
}],
|
|
351
|
-
details: material,
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
|
-
catch (error) {
|
|
355
|
-
if (isCorrectableExecuteError(error))
|
|
356
|
-
throw error;
|
|
357
|
-
hostActions.failInfrastructure(error, ctx, toolCallId);
|
|
358
|
-
}
|
|
359
|
-
},
|
|
360
|
-
});
|
|
361
|
-
pi.registerTool({
|
|
362
|
-
name: COLLECTOR_REQUEST_TOOL,
|
|
363
|
-
label: "通进司请求",
|
|
364
|
-
description: "在所引最新快照 HEAD 发一次请求。requestId 可取配置清单,或角色依手册/现场判定的稳定 id;后者须同时提供 body。",
|
|
365
|
-
promptSnippet: "发一次评审请求",
|
|
366
|
-
parameters: requestSchema,
|
|
367
|
-
async execute(toolCallId, params, signal, _onUpdate, ctx) {
|
|
368
|
-
const activation = getActivation();
|
|
369
|
-
if (activation === undefined)
|
|
370
|
-
throw new Error("通进司未激活");
|
|
371
|
-
try {
|
|
372
|
-
activation.ledger.beginOperational(COLLECTOR_REQUEST_TOOL, toolCallId);
|
|
373
|
-
const details = await activation.ledger.request({
|
|
374
|
-
requestId: params.requestId,
|
|
375
|
-
snapshotId: params.snapshotId,
|
|
376
|
-
...(typeof params.body === "string" ? { body: params.body } : {}),
|
|
377
|
-
}, activation.transport, activation.clock, signal);
|
|
378
|
-
activation.ledger.completeOperational(toolCallId);
|
|
379
|
-
return {
|
|
380
|
-
content: [{
|
|
381
|
-
type: "text",
|
|
382
|
-
text: `请求尝试已记录:request ${params.requestId}`,
|
|
383
|
-
}],
|
|
384
|
-
details,
|
|
385
|
-
};
|
|
386
|
-
}
|
|
387
|
-
catch (error) {
|
|
388
|
-
if (isCorrectableExecuteError(error))
|
|
389
|
-
throw error;
|
|
390
|
-
hostActions.failInfrastructure(error, ctx, toolCallId);
|
|
391
|
-
}
|
|
392
|
-
},
|
|
393
|
-
});
|
|
394
|
-
pi.registerTool({
|
|
395
|
-
name: COLLECTOR_HANDBOOK_WRITE_TOOL,
|
|
396
|
-
label: "通进司手册写入",
|
|
397
|
-
description: "写入通用手册或当前仓库差异全文(整份替换)。",
|
|
398
|
-
promptSnippet: "更新 bot 手册",
|
|
399
|
-
parameters: handbookWriteSchema,
|
|
400
|
-
async execute(toolCallId, params, _signal, _onUpdate, ctx) {
|
|
401
|
-
const activation = getActivation();
|
|
402
|
-
if (activation === undefined)
|
|
403
|
-
throw new Error("通进司未激活");
|
|
404
|
-
try {
|
|
405
|
-
activation.ledger.beginOperational(COLLECTOR_HANDBOOK_WRITE_TOOL, toolCallId);
|
|
406
|
-
// scope/body shape authority = collectorHandbookWriteArgsSchema (host parameters).
|
|
407
|
-
const details = await activation.handbook.write(params.scope, params.body);
|
|
408
|
-
activation.handbookView = await activation.handbook.read();
|
|
409
|
-
activation.ledger.completeOperational(toolCallId);
|
|
410
|
-
return {
|
|
411
|
-
content: [{
|
|
412
|
-
type: "text",
|
|
413
|
-
text: `手册已写入:${details.scope}`,
|
|
414
|
-
}],
|
|
415
|
-
details: {
|
|
416
|
-
scope: details.scope,
|
|
417
|
-
path: details.path,
|
|
418
|
-
byteLength: details.byteLength,
|
|
419
|
-
generalSource: activation.handbookView.generalSource,
|
|
420
|
-
repoSource: activation.handbookView.repoSource,
|
|
421
|
-
},
|
|
422
|
-
};
|
|
423
|
-
}
|
|
424
|
-
catch (error) {
|
|
425
|
-
if (isCorrectableExecuteError(error))
|
|
426
|
-
throw error;
|
|
427
|
-
hostActions.failInfrastructure(error, ctx, toolCallId);
|
|
428
|
-
}
|
|
429
|
-
finally {
|
|
430
|
-
try {
|
|
431
|
-
activation.ledger.completeOperational(toolCallId);
|
|
432
|
-
}
|
|
433
|
-
catch {
|
|
434
|
-
// already completed or not begun
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
},
|
|
438
|
-
});
|
|
439
|
-
pi.registerTool({
|
|
440
|
-
name: COLLECTOR_OPEN_WAIT_WINDOW_TOOL,
|
|
441
|
-
label: "通进司开启等待窗",
|
|
442
|
-
description: "在工作步骤上开启等待窗:新建并自动触发的 PR 传创建成功时刻;已有 PR 在触发阶段结束后省略 startedAt(=现在)。窗长由使用方配置,默认十分钟;开启后不因 PR 更新重置。",
|
|
443
|
-
promptSnippet: "按工作步骤开启等待窗",
|
|
444
|
-
parameters: openWaitWindowSchema,
|
|
445
|
-
async execute(toolCallId, params, _signal, _onUpdate, ctx) {
|
|
446
|
-
const activation = getActivation();
|
|
447
|
-
if (activation === undefined)
|
|
448
|
-
throw new Error("通进司未激活");
|
|
449
|
-
try {
|
|
450
|
-
activation.ledger.beginOperational(COLLECTOR_OPEN_WAIT_WINDOW_TOOL, toolCallId);
|
|
451
|
-
let startedAt;
|
|
452
|
-
if (typeof params.startedAt === "string" && params.startedAt.trim().length > 0) {
|
|
453
|
-
const parsed = new Date(params.startedAt);
|
|
454
|
-
if (Number.isNaN(parsed.getTime())) {
|
|
455
|
-
throw new Error("通进司等待窗 startedAt 须为有效 ISO 时间");
|
|
456
|
-
}
|
|
457
|
-
startedAt = parsed;
|
|
458
|
-
}
|
|
459
|
-
activation.ledger.openWaitWindow(activation.clock, startedAt === undefined ? undefined : { startedAt });
|
|
460
|
-
activation.ledger.completeOperational(toolCallId);
|
|
461
|
-
return {
|
|
462
|
-
content: [{
|
|
463
|
-
type: "text",
|
|
464
|
-
text: "等待窗已开启",
|
|
465
|
-
}],
|
|
466
|
-
details: {
|
|
467
|
-
activationTime: activation.ledger.activationTime?.toISOString(),
|
|
468
|
-
deadlineTime: activation.ledger.deadlineTime?.toISOString(),
|
|
469
|
-
waitWindowMs: activation.ledger.config.waitWindowMs,
|
|
470
|
-
},
|
|
471
|
-
};
|
|
472
|
-
}
|
|
473
|
-
catch (error) {
|
|
474
|
-
if (isCorrectableExecuteError(error))
|
|
475
|
-
throw error;
|
|
476
|
-
hostActions.failInfrastructure(error, ctx, toolCallId);
|
|
477
|
-
}
|
|
478
|
-
finally {
|
|
479
|
-
try {
|
|
480
|
-
activation.ledger.completeOperational(toolCallId);
|
|
481
|
-
}
|
|
482
|
-
catch {
|
|
483
|
-
// already completed or not begun
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
},
|
|
487
|
-
});
|
|
488
|
-
pi.registerTool({
|
|
489
|
-
name: COLLECTOR_WAIT_TOOL,
|
|
490
|
-
label: "通进司等待",
|
|
491
|
-
description: "再观察前等待;实际睡眠不超过剩余等待窗。",
|
|
492
|
-
promptSnippet: "等待窗内等待",
|
|
493
|
-
parameters: waitSchema,
|
|
494
|
-
async execute(toolCallId, params, signal, _onUpdate, ctx) {
|
|
495
|
-
const activation = getActivation();
|
|
496
|
-
if (activation === undefined)
|
|
497
|
-
throw new Error("通进司未激活");
|
|
498
|
-
try {
|
|
499
|
-
activation.ledger.beginOperational(COLLECTOR_WAIT_TOOL, toolCallId);
|
|
500
|
-
const details = await activation.ledger.wait(params, activation.clock, signal);
|
|
501
|
-
activation.ledger.completeOperational(toolCallId);
|
|
502
|
-
return {
|
|
503
|
-
content: [{
|
|
504
|
-
type: "text",
|
|
505
|
-
text: `已等待 ${String(details.effectiveMs)}ms`,
|
|
506
|
-
}],
|
|
507
|
-
details,
|
|
508
|
-
};
|
|
509
|
-
}
|
|
510
|
-
catch (error) {
|
|
511
|
-
if (isCorrectableExecuteError(error))
|
|
512
|
-
throw error;
|
|
513
|
-
hostActions.failInfrastructure(error, ctx, toolCallId);
|
|
514
|
-
}
|
|
515
|
-
},
|
|
516
|
-
});
|
|
517
|
-
pi.registerTool({
|
|
518
|
-
name: COLLECTOR_OUTPUT_TOOL,
|
|
519
|
-
label: "通进司输出",
|
|
520
|
-
description: "观察完成后提交;回执由 runtime 组装。正常完工提交空对象 {}(如需报 finding,填 findings 指针数组);仅在基础设施真实失败时才可填 infrastructureFailure,无失败时必须省略该字段。",
|
|
521
|
-
promptSnippet: "提交通进司回执",
|
|
522
|
-
bounceInfrastructureDeclaration(params) {
|
|
523
|
-
const activation = getActivation();
|
|
524
|
-
if (activation === undefined)
|
|
525
|
-
return undefined;
|
|
526
|
-
try {
|
|
527
|
-
buildCollectorReceipt(activation.ledger, params, activation.clock);
|
|
528
|
-
}
|
|
529
|
-
catch {
|
|
530
|
-
return undefined;
|
|
531
|
-
}
|
|
532
|
-
return new CollectorNormalCompletionDeclarationError();
|
|
533
|
-
},
|
|
534
|
-
parameters: outputSchema,
|
|
535
|
-
async execute(toolCallId, params, _signal, _onUpdate, ctx) {
|
|
536
|
-
const activation = getActivation();
|
|
537
|
-
if (activation === undefined)
|
|
538
|
-
throw new Error("通进司未激活");
|
|
539
|
-
try {
|
|
540
|
-
activation.ledger.beginOperational(COLLECTOR_OUTPUT_TOOL, toolCallId);
|
|
541
|
-
const receipt = buildCollectorReceipt(activation.ledger, params, activation.clock);
|
|
542
|
-
activation.ledger.recordOutputCandidate();
|
|
543
|
-
return {
|
|
544
|
-
content: [{
|
|
545
|
-
type: "text",
|
|
546
|
-
text: COLLECTOR_ACCEPTED_TEXT,
|
|
547
|
-
}],
|
|
548
|
-
details: receipt,
|
|
549
|
-
terminate: true,
|
|
550
|
-
};
|
|
551
|
-
}
|
|
552
|
-
catch (error) {
|
|
553
|
-
if (error instanceof Error &&
|
|
554
|
-
error.collectorFatal === true) {
|
|
555
|
-
hostActions.failInfrastructure(error, ctx, toolCallId);
|
|
556
|
-
}
|
|
557
|
-
throw error;
|
|
558
|
-
}
|
|
559
|
-
finally {
|
|
560
|
-
activation.ledger.completeOperational(toolCallId);
|
|
561
|
-
}
|
|
562
|
-
},
|
|
563
|
-
});
|
|
564
|
-
},
|
|
565
|
-
};
|
|
566
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { Type } from "typebox";
|
|
2
|
-
import { openToolObject } from "./open-tool-schema.js";
|
|
3
|
-
import { withInfrastructureFailureDeclaration } from "./package-contracts/terminating-infrastructure.js";
|
|
4
|
-
export const collectorObserveArgsSchema = Type.Object({}, { additionalProperties: false });
|
|
5
|
-
/**
|
|
6
|
-
* Stable request identity: non-empty after trim, no leading/trailing whitespace.
|
|
7
|
-
* Host schema + ledger identity seam share this contract (#677 / D2 dedup).
|
|
8
|
-
*/
|
|
9
|
-
export const COLLECTOR_REQUEST_ID_PATTERN = /^\S(?:.*\S)?$/;
|
|
10
|
-
export const collectorRequestArgsSchema = Type.Object({
|
|
11
|
-
requestId: Type.String({
|
|
12
|
-
minLength: 1,
|
|
13
|
-
pattern: COLLECTOR_REQUEST_ID_PATTERN.source,
|
|
14
|
-
description: "请求身份(配置 id 或角色判定的稳定 id;首尾无空白)",
|
|
15
|
-
}),
|
|
16
|
-
snapshotId: Type.String({ minLength: 1, description: "最新留存观察快照" }),
|
|
17
|
-
body: Type.Optional(Type.String({
|
|
18
|
-
minLength: 1,
|
|
19
|
-
description: "角色判定的请求正文;request-manifest 未收录该 requestId 时必填",
|
|
20
|
-
})),
|
|
21
|
-
}, { additionalProperties: false });
|
|
22
|
-
/** UTF-8 byte ceiling per handbook body — keeps next activation materials inside context budget. */
|
|
23
|
-
export const COLLECTOR_HANDBOOK_MAX_BYTES = 64 * 1024;
|
|
24
|
-
export const collectorHandbookWriteArgsSchema = Type.Object({
|
|
25
|
-
scope: Type.Union([
|
|
26
|
-
Type.Literal("general"),
|
|
27
|
-
Type.Literal("repo"),
|
|
28
|
-
], { description: "general=通用手册;repo=当前仓库差异" }),
|
|
29
|
-
body: Type.String({
|
|
30
|
-
description: `手册全文(opaque 工作记忆;整份替换;UTF-8 至多 ${COLLECTOR_HANDBOOK_MAX_BYTES} 字节)`,
|
|
31
|
-
}),
|
|
32
|
-
}, { additionalProperties: false });
|
|
33
|
-
export const collectorReadArgsSchema = Type.Object({
|
|
34
|
-
evidenceId: Type.String({ minLength: 1, description: "observe 返回的材料证据 id(evidenceId)" }),
|
|
35
|
-
}, { additionalProperties: false });
|
|
36
|
-
export const collectorWaitArgsSchema = Type.Object({
|
|
37
|
-
durationMs: Type.Integer({
|
|
38
|
-
minimum: 1,
|
|
39
|
-
description: "等待毫秒;实际睡眠不超过剩余等待窗(#678;无包内单次任意上限)",
|
|
40
|
-
}),
|
|
41
|
-
}, { additionalProperties: false });
|
|
42
|
-
/**
|
|
43
|
-
* #678 D4: open the wait window at a work step.
|
|
44
|
-
* Omit startedAt for existing-PR trigger-phase end (= now).
|
|
45
|
-
* Pass PR creation success time for new-PR auto-trigger rounds.
|
|
46
|
-
*/
|
|
47
|
-
export const collectorOpenWaitWindowArgsSchema = Type.Object({
|
|
48
|
-
startedAt: Type.Optional(Type.String({
|
|
49
|
-
minLength: 1,
|
|
50
|
-
description: "等待窗起点 ISO 时间;新建 PR 用创建成功时刻;省略=现在(触发阶段结束)",
|
|
51
|
-
})),
|
|
52
|
-
}, { additionalProperties: false });
|
|
53
|
-
/**
|
|
54
|
-
* #676 A: role-decided target bind. The model judges task materials and submits
|
|
55
|
-
* the chosen PR and/or issue identity; runtime only performs online association
|
|
56
|
-
* for the role-chosen ticket — never scrapes task text to lock a target.
|
|
57
|
-
*/
|
|
58
|
-
export const collectorBindTargetArgsSchema = Type.Object({
|
|
59
|
-
prNumber: Type.Optional(Type.Unknown({
|
|
60
|
-
description: "角色判定的本仓 PR 号(正整数)。与 issueNumber 二选一或同指唯一目标。形状指引,非 schema 闸。",
|
|
61
|
-
})),
|
|
62
|
-
issueNumber: Type.Optional(Type.Unknown({
|
|
63
|
-
description: "角色判定的本仓 issue 号(正整数);runtime 经线上关联解析唯一 PR。形状指引,非 schema 闸。",
|
|
64
|
-
})),
|
|
65
|
-
}, { additionalProperties: true });
|
|
66
|
-
/**
|
|
67
|
-
* #641 chain① / #676 C / ADR 0057: nested finding item declarations for model
|
|
68
|
-
* guidance. Host must not pure-shape-reject the envelope (第 0 条). Runtime binds
|
|
69
|
-
* resolvable evidence pointers only; unprojected content stays distinguishable.
|
|
70
|
-
*/
|
|
71
|
-
const collectorFindingItemDeclaration = (() => {
|
|
72
|
-
// Nested declarations for model guidance only — open required so host cannot
|
|
73
|
-
// pure-shape-reject missing optional fields (第 0 条 / ADR 0057 / #676 C).
|
|
74
|
-
const item = Type.Object({
|
|
75
|
-
evidenceId: Type.Unknown({
|
|
76
|
-
description: "observe 返回的材料指针(必填语义)",
|
|
77
|
-
}),
|
|
78
|
-
category: Type.Unknown({
|
|
79
|
-
description: "简短归类标签,不是摘要",
|
|
80
|
-
}),
|
|
81
|
-
summary: Type.Unknown({
|
|
82
|
-
description: "哪个 bot、什么问题的摘要;不誊抄正文",
|
|
83
|
-
}),
|
|
84
|
-
}, {
|
|
85
|
-
additionalProperties: true,
|
|
86
|
-
description: "单条 finding 指针:evidenceId + 可选 category/summary。形状指引,非 schema 闸。",
|
|
87
|
-
});
|
|
88
|
-
item.required = [];
|
|
89
|
-
return item;
|
|
90
|
-
})();
|
|
91
|
-
/**
|
|
92
|
-
* Field declarations + descriptions are guidance for the model — host must not
|
|
93
|
-
* pure-shape-reject the envelope (第 0 条 / ADR 0057).
|
|
94
|
-
*/
|
|
95
|
-
export const collectorOutputBaseSchema = openToolObject(Type.Object({
|
|
96
|
-
// No root type:array — host must not shape-reject non-array findings (#676 C).
|
|
97
|
-
// Nested item declarations ride `items` for registration preservation (ADR 0057).
|
|
98
|
-
findings: Type.Unsafe({
|
|
99
|
-
description: "本次收集到的逐条 findings(指针数组为规范形)。零 finding 的模板通知不得进入;正常完工无 finding 时省略。形状指引,非 schema 闸。",
|
|
100
|
-
items: collectorFindingItemDeclaration,
|
|
101
|
-
}),
|
|
102
|
-
unfinishedReasons: Type.Unknown({
|
|
103
|
-
description: "未完成原因字符串数组(额度/故障/等待届满等现场依据);不得把未完成表述为无问题。无可报告时省略。形状指引,非 schema 闸。",
|
|
104
|
-
}),
|
|
105
|
-
}));
|
|
106
|
-
/** Runtime owns the observed evidence; the model submits findings and signals sole-final submission. */
|
|
107
|
-
export const collectorOutputArgsSchema = withInfrastructureFailureDeclaration(collectorOutputBaseSchema);
|