@oyasmi/pipiclaw 0.9.0-beta.1 → 0.9.0-beta.3
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/agent/channel-runner.d.ts +9 -0
- package/dist/agent/channel-runner.js +58 -4
- package/dist/agent/commands.js +11 -3
- package/dist/agent/job-manager.d.ts +6 -0
- package/dist/agent/job-manager.js +55 -1
- package/dist/agent/progress-formatter.js +3 -3
- package/dist/agent/run-queue.d.ts +10 -1
- package/dist/agent/run-queue.js +19 -2
- package/dist/agent/session-resource-gate.d.ts +17 -0
- package/dist/agent/session-resource-gate.js +33 -2
- package/dist/agent/status-render.js +1 -3
- package/dist/agent/types.d.ts +8 -0
- package/dist/runtime/bootstrap.d.ts +52 -0
- package/dist/runtime/bootstrap.js +192 -25
- package/dist/runtime/delivery.js +5 -5
- package/dist/runtime/dingtalk.d.ts +8 -0
- package/dist/runtime/durable-dispatch.d.ts +4 -0
- package/dist/runtime/durable-dispatch.js +16 -0
- package/dist/runtime/subagent-commands.d.ts +8 -6
- package/dist/runtime/subagent-commands.js +264 -64
- package/dist/security/logger.js +7 -0
- package/dist/shared/host-process.d.ts +7 -1
- package/dist/shared/host-process.js +7 -3
- package/dist/shared/jsonl-appender.d.ts +2 -0
- package/dist/shared/jsonl-appender.js +25 -13
- package/dist/shared/with-timeout.d.ts +14 -0
- package/dist/shared/with-timeout.js +38 -0
- package/dist/subagents/detached-discovery.d.ts +13 -0
- package/dist/subagents/detached-discovery.js +17 -0
- package/dist/subagents/external/run.d.ts +10 -0
- package/dist/subagents/external/run.js +47 -1
- package/dist/subagents/format.d.ts +12 -0
- package/dist/subagents/format.js +24 -0
- package/dist/subagents/runs.d.ts +38 -0
- package/dist/subagents/runs.js +171 -24
- package/dist/subagents/tool.d.ts +18 -0
- package/dist/subagents/tool.js +147 -89
- package/dist/tasks/control.d.ts +12 -0
- package/dist/tasks/control.js +20 -0
- package/dist/tasks/store.d.ts +21 -0
- package/dist/tasks/store.js +80 -0
- package/dist/tools/index.js +2 -0
- package/dist/tools/subagent-manage.d.ts +5 -0
- package/dist/tools/subagent-manage.js +68 -51
- package/dist/usage/ledger.d.ts +7 -0
- package/dist/usage/ledger.js +15 -2
- package/dist/usage/render.js +22 -0
- package/examples/sub-agents/README.md +12 -7
- package/examples/sub-agents/documenter.md +3 -3
- package/examples/sub-agents/git-committer.md +1 -1
- package/examples/sub-agents/reviewer.md +12 -6
- package/examples/sub-agents/verifier.md +5 -2
- package/examples/sub-agents/worker.md +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
|
+
import { DEFAULT_SECURITY_CONFIG } from "../security/config.js";
|
|
2
3
|
import { RecoverableToolError } from "../shared/recoverable-error.js";
|
|
3
4
|
import { launchExternalRun } from "../subagents/external/run.js";
|
|
5
|
+
import { elapsedMs, formatCost, formatDuration, harnessLabel } from "../subagents/format.js";
|
|
4
6
|
import { getSubAgentRunManager } from "../subagents/runs.js";
|
|
5
|
-
import { acquireWorkspaceLease, formatWorkspaceLeaseConflict } from "../subagents/workspace-lease.js";
|
|
7
|
+
import { acquireWorkspaceLease, formatWorkspaceLeaseConflict, releaseWorkspaceLease, } from "../subagents/workspace-lease.js";
|
|
6
8
|
const subagentManageSchema = Type.Object({
|
|
7
9
|
label: Type.String({ description: "Brief description of what you're checking (shown to user)" }),
|
|
8
10
|
op: Type.Union([Type.Literal("list"), Type.Literal("cancel"), Type.Literal("follow_up")], {
|
|
@@ -12,18 +14,16 @@ const subagentManageSchema = Type.Object({
|
|
|
12
14
|
runId: Type.Optional(Type.String({ description: "Required for cancel and follow_up." })),
|
|
13
15
|
task: Type.Optional(Type.String({ description: "Follow-up instruction. Required for op=follow_up." })),
|
|
14
16
|
});
|
|
15
|
-
function formatDuration(ms) {
|
|
16
|
-
const seconds = Math.round(ms / 1000);
|
|
17
|
-
if (seconds < 60)
|
|
18
|
-
return `${seconds}s`;
|
|
19
|
-
return `${Math.floor(seconds / 60)}m${seconds % 60}s`;
|
|
20
|
-
}
|
|
21
17
|
function formatRunLine(record) {
|
|
22
|
-
const harness = record.harness ? `${record.runtime}/${record.harness}` : record.runtime;
|
|
23
|
-
const elapsed = (record.finishedAt ?? Date.now()) - record.startedAt;
|
|
24
18
|
const task = record.taskId ? `, task ${record.taskId}` : "";
|
|
25
19
|
const lease = record.leaseKey ? ", lease held" : "";
|
|
26
|
-
|
|
20
|
+
const cost = formatCost(record);
|
|
21
|
+
const costPart = cost ? `, ${cost}` : "";
|
|
22
|
+
const header = `- [${record.runId}] ${record.agent} (${harnessLabel(record)}) — "${record.label}" — ${record.status} (${formatDuration(elapsedMs(record))}${task}${lease}${costPart})`;
|
|
23
|
+
if (record.status === "failed" && record.failureReason) {
|
|
24
|
+
return `${header}\n failed: ${record.failureReason}`;
|
|
25
|
+
}
|
|
26
|
+
return header;
|
|
27
27
|
}
|
|
28
28
|
/** Resumable harnesses only: `claude-code`/`codex-cli`. `exec` has no session concept, and internal
|
|
29
29
|
* runs have no persisted transcript by design (spec 040, non-goals). */
|
|
@@ -43,7 +43,7 @@ export function createSubAgentManageTool(options) {
|
|
|
43
43
|
"run with a new instruction, producing a new runId. A run finishing wakes this channel by itself, " +
|
|
44
44
|
"so never poll here waiting for one — end the turn instead.",
|
|
45
45
|
parameters: subagentManageSchema,
|
|
46
|
-
execute: async (
|
|
46
|
+
execute: async (_toolCallId, { op, runId, task }) => {
|
|
47
47
|
if (op === "list") {
|
|
48
48
|
const runs = manager().list();
|
|
49
49
|
const text = runs.length === 0 ? "No delegation runs." : runs.map(formatRunLine).join("\n");
|
|
@@ -52,50 +52,55 @@ export function createSubAgentManageTool(options) {
|
|
|
52
52
|
if (!runId) {
|
|
53
53
|
throw new RecoverableToolError(`${op} requires runId.`);
|
|
54
54
|
}
|
|
55
|
+
const resolution = manager().resolveRef(runId);
|
|
56
|
+
if (resolution.kind === "ambiguous") {
|
|
57
|
+
throw new RecoverableToolError(`"${runId}" matches multiple runs on this channel: ${resolution.candidates.map((candidate) => candidate.runId).join(", ")}. Use the full runId.`);
|
|
58
|
+
}
|
|
59
|
+
if (resolution.kind === "not_found") {
|
|
60
|
+
throw new RecoverableToolError(`Run "${runId}" was not found on this channel.`);
|
|
61
|
+
}
|
|
62
|
+
const resolvedRunId = resolution.record.runId;
|
|
55
63
|
if (op === "cancel") {
|
|
56
|
-
const status = await manager().cancel(
|
|
57
|
-
if (status === "not_found") {
|
|
58
|
-
throw new RecoverableToolError(`Run "${runId}" was not found on this channel.`);
|
|
59
|
-
}
|
|
64
|
+
const status = await manager().cancel(resolvedRunId);
|
|
60
65
|
return {
|
|
61
|
-
content: [{ type: "text", text: `Cancel requested for run ${
|
|
62
|
-
details: { kind: "subagent_manage", op, runId, status },
|
|
66
|
+
content: [{ type: "text", text: `Cancel requested for run ${resolvedRunId}: ${status}` }],
|
|
67
|
+
details: { kind: "subagent_manage", op, runId: resolvedRunId, status },
|
|
63
68
|
};
|
|
64
69
|
}
|
|
65
70
|
// follow_up
|
|
66
71
|
if (!task || !task.trim()) {
|
|
67
72
|
throw new RecoverableToolError("follow_up requires task.");
|
|
68
73
|
}
|
|
69
|
-
const record =
|
|
70
|
-
if (!record) {
|
|
71
|
-
throw new RecoverableToolError(`Run "${runId}" was not found on this channel.`);
|
|
72
|
-
}
|
|
74
|
+
const record = resolution.record;
|
|
73
75
|
const harness = resumableHarnessOf(record);
|
|
74
76
|
if (!harness) {
|
|
75
77
|
// Internal runs have no persisted transcript to resume — the isolated-context design
|
|
76
78
|
// is the point, not a gap. `exec` has no session concept at all. Directing the model
|
|
77
79
|
// at a fresh delegation, not a fallback to "just use internal", keeps this honest (P2).
|
|
78
|
-
throw new RecoverableToolError(`Run "${
|
|
80
|
+
throw new RecoverableToolError(`Run "${resolvedRunId}" (${record.runtime}${record.harness ? `/${record.harness}` : ""}) does not support ` +
|
|
79
81
|
"follow_up yet. Delegate a new run instead, carrying forward whatever context or prior output it needs.");
|
|
80
82
|
}
|
|
81
83
|
if (record.status === "running") {
|
|
82
|
-
throw new RecoverableToolError(`Run "${
|
|
84
|
+
throw new RecoverableToolError(`Run "${resolvedRunId}" is still running; wait for it to finish before following up.`);
|
|
83
85
|
}
|
|
84
86
|
if (!record.sessionId) {
|
|
85
|
-
throw new RecoverableToolError(`Run "${
|
|
87
|
+
throw new RecoverableToolError(`Run "${resolvedRunId}" never reported a session id (it likely failed before producing one); it cannot be resumed. Delegate a new run instead.`);
|
|
86
88
|
}
|
|
87
89
|
const discovery = options.getSubAgentDiscovery?.();
|
|
88
90
|
const role = discovery?.agents.find((agent) => agent.name === record.agent && agent.runtime === "external");
|
|
89
91
|
if (!role) {
|
|
90
|
-
throw new RecoverableToolError(`Role "${record.agent}" is no longer configured as an external role; cannot follow up run "${
|
|
92
|
+
throw new RecoverableToolError(`Role "${record.agent}" is no longer configured as an external role; cannot follow up run "${resolvedRunId}".`);
|
|
91
93
|
}
|
|
92
94
|
if (role.unavailable) {
|
|
93
95
|
throw new RecoverableToolError(`Role "${record.agent}" is currently unavailable: ${role.unavailable}`);
|
|
94
96
|
}
|
|
97
|
+
// A short, human-typeable id (spec 041) — the follow-up gets a fresh identity, not the
|
|
98
|
+
// dispatching tool call's own id.
|
|
99
|
+
const newRunId = manager().mintRunId();
|
|
95
100
|
let leaseKey;
|
|
96
101
|
if (role.mutates === "write") {
|
|
97
102
|
const lease = acquireWorkspaceLease({
|
|
98
|
-
runId:
|
|
103
|
+
runId: newRunId,
|
|
99
104
|
channelId: options.channelId,
|
|
100
105
|
workingDirectory: record.workingDirectory,
|
|
101
106
|
});
|
|
@@ -104,37 +109,49 @@ export function createSubAgentManageTool(options) {
|
|
|
104
109
|
}
|
|
105
110
|
leaseKey = lease.leaseKey;
|
|
106
111
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
112
|
+
try {
|
|
113
|
+
await launchExternalRun({
|
|
114
|
+
runId: newRunId,
|
|
115
|
+
channelId: options.channelId,
|
|
116
|
+
channelDir: options.channelDir,
|
|
117
|
+
label: `follow-up: ${task.slice(0, 80)}`,
|
|
118
|
+
agent: role.name,
|
|
119
|
+
source: role.source,
|
|
120
|
+
harness,
|
|
121
|
+
command: role.command ?? "",
|
|
122
|
+
shell: role.shell,
|
|
123
|
+
env: role.env,
|
|
124
|
+
externalModelRef: role.externalModelRef,
|
|
125
|
+
thinkingLevel: role.thinkingLevel,
|
|
126
|
+
maxWallTimeSec: role.maxWallTimeSec,
|
|
127
|
+
systemPrompt: role.systemPrompt,
|
|
128
|
+
task,
|
|
129
|
+
workingDirectory: record.workingDirectory,
|
|
130
|
+
artifactDir: record.artifactDir.replace(/[^/\\]+$/, newRunId),
|
|
131
|
+
purpose: record.purpose,
|
|
132
|
+
taskId: record.taskId,
|
|
133
|
+
leaseKey,
|
|
134
|
+
resumeSessionId: record.sessionId,
|
|
135
|
+
mutates: role.mutates,
|
|
136
|
+
workspaceDir: options.workspaceDir ?? "",
|
|
137
|
+
securityConfig: options.securityConfig ?? DEFAULT_SECURITY_CONFIG,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
// Until launchExternalRun has durably registered the run, no settlement authority owns
|
|
142
|
+
// this lease. Releasing here mirrors the initial subagent dispatch path and covers prompt,
|
|
143
|
+
// artifact, audit, invocation, and pre-spawn failures in follow_up.
|
|
144
|
+
releaseWorkspaceLease(leaseKey);
|
|
145
|
+
throw error;
|
|
146
|
+
}
|
|
130
147
|
return {
|
|
131
148
|
content: [
|
|
132
149
|
{
|
|
133
150
|
type: "text",
|
|
134
|
-
text: `Follow-up dispatched as runId=${
|
|
151
|
+
text: `Follow-up dispatched as runId=${newRunId} (resuming ${resolvedRunId}). This channel will be woken when it finishes.`,
|
|
135
152
|
},
|
|
136
153
|
],
|
|
137
|
-
details: { kind: "subagent_manage", op, runId:
|
|
154
|
+
details: { kind: "subagent_manage", op, runId: newRunId, resumedFrom: resolvedRunId },
|
|
138
155
|
};
|
|
139
156
|
},
|
|
140
157
|
};
|
package/dist/usage/ledger.d.ts
CHANGED
|
@@ -38,6 +38,13 @@ export interface UsageSummary {
|
|
|
38
38
|
byKind: Record<string, number>;
|
|
39
39
|
byModel: Record<string, number>;
|
|
40
40
|
byChannel: Record<string, number>;
|
|
41
|
+
/** Entries with `usageKnown === false` (e.g. the `exec` harness never reports tokens at all).
|
|
42
|
+
* Their `usage.total` is always 0 and never contributes to `totalTokens` — display this count
|
|
43
|
+
* rather than let those runs silently read as "0 tokens used". */
|
|
44
|
+
unknownUsageCount: number;
|
|
45
|
+
/** Entries with `costKnown === false` (e.g. `codex-cli`/`exec`, which report no cost field).
|
|
46
|
+
* Their `cost.total` is always 0 and never contributes to `totalCost` — same rationale. */
|
|
47
|
+
unknownCostCount: number;
|
|
41
48
|
}
|
|
42
49
|
export interface UsageSummaryQuery {
|
|
43
50
|
since: Date;
|
package/dist/usage/ledger.js
CHANGED
|
@@ -71,8 +71,13 @@ export function createUsageLedger(options = {}) {
|
|
|
71
71
|
// Record anything that consumed tokens, even at zero cost: a local model, or one whose
|
|
72
72
|
// pricing metadata is missing, still has to show up somewhere or `/usage` reports nothing
|
|
73
73
|
// at all and any spend guard built on this ledger fails open. Only a genuinely empty
|
|
74
|
-
// entry (no tokens, no cost) is dropped as noise
|
|
75
|
-
|
|
74
|
+
// entry (no tokens, no cost, and nothing unknown either) is dropped as noise — an entry
|
|
75
|
+
// with `usageKnown`/`costKnown` false always has zero numeric totals by construction (the
|
|
76
|
+
// harness has nothing to report), so without this exemption every such run would be
|
|
77
|
+
// silently dropped instead of showing up as "unknown" (spec 040, T7).
|
|
78
|
+
const hasKnownSignal = entry.cost.total > 0 || entry.usage.total > 0;
|
|
79
|
+
const hasUnknownSignal = entry.usageKnown === false || entry.costKnown === false;
|
|
80
|
+
if (!hasKnownSignal && !hasUnknownSignal)
|
|
76
81
|
return;
|
|
77
82
|
if (!entry.channelId) {
|
|
78
83
|
log.logWarning("Usage ledger entry missing channelId; recording as untracked", `kind=${entry.kind}`);
|
|
@@ -97,6 +102,8 @@ export function createUsageLedger(options = {}) {
|
|
|
97
102
|
byKind: {},
|
|
98
103
|
byModel: {},
|
|
99
104
|
byChannel: {},
|
|
105
|
+
unknownUsageCount: 0,
|
|
106
|
+
unknownCostCount: 0,
|
|
100
107
|
};
|
|
101
108
|
for (const key of monthKeysBetween(query.since, until)) {
|
|
102
109
|
for (const entry of await loadMonth(join(baseDir, `usage-${key}.jsonl`))) {
|
|
@@ -112,6 +119,12 @@ export function createUsageLedger(options = {}) {
|
|
|
112
119
|
summary.byKind[entry.kind] = (summary.byKind[entry.kind] ?? 0) + cost;
|
|
113
120
|
summary.byModel[entry.model] = (summary.byModel[entry.model] ?? 0) + cost;
|
|
114
121
|
summary.byChannel[entry.channelId] = (summary.byChannel[entry.channelId] ?? 0) + cost;
|
|
122
|
+
// `undefined` (every entry recorded before this field existed) counts as known —
|
|
123
|
+
// backward compatibility for a ledger that predates this distinction.
|
|
124
|
+
if (entry.usageKnown === false)
|
|
125
|
+
summary.unknownUsageCount += 1;
|
|
126
|
+
if (entry.costKnown === false)
|
|
127
|
+
summary.unknownCostCount += 1;
|
|
115
128
|
}
|
|
116
129
|
}
|
|
117
130
|
return summary;
|
package/dist/usage/render.js
CHANGED
|
@@ -46,6 +46,20 @@ function renderKindBreakdown(summary) {
|
|
|
46
46
|
const parts = topEntries(summary.byKind, 3).map(([kind, cost]) => `${kind} ${money(cost)}`);
|
|
47
47
|
return parts.length > 0 ? parts.join(" · ") : null;
|
|
48
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Some harnesses cannot report tokens or cost at all (`exec` reports neither; `codex-cli` reports
|
|
51
|
+
* no cost). Those runs are never dropped from the ledger (spec 040, T7) but their totals are
|
|
52
|
+
* always 0 by construction, so the aggregate total must say so explicitly — otherwise "$0.0000"
|
|
53
|
+
* reads as "these runs cost nothing" instead of "cost unknown for some of these runs".
|
|
54
|
+
*/
|
|
55
|
+
function unknownNote(summary) {
|
|
56
|
+
const parts = [];
|
|
57
|
+
if (summary.unknownCostCount > 0)
|
|
58
|
+
parts.push(`${summary.unknownCostCount} 次成本未知`);
|
|
59
|
+
if (summary.unknownUsageCount > 0)
|
|
60
|
+
parts.push(`${summary.unknownUsageCount} 次用量未知`);
|
|
61
|
+
return parts.length > 0 ? `(另有 ${parts.join(",")},未计入以上合计)` : null;
|
|
62
|
+
}
|
|
49
63
|
async function renderWindow(window, ledger, channelId) {
|
|
50
64
|
const [global, channel] = await Promise.all([
|
|
51
65
|
ledger.summarize({ since: window.since, until: window.until }),
|
|
@@ -63,12 +77,20 @@ async function renderWindow(window, ledger, channelId) {
|
|
|
63
77
|
if (channelKinds) {
|
|
64
78
|
lines.push(` ${channelKinds}`);
|
|
65
79
|
}
|
|
80
|
+
const channelUnknown = unknownNote(channel);
|
|
81
|
+
if (channelUnknown) {
|
|
82
|
+
lines.push(` ${channelUnknown}`);
|
|
83
|
+
}
|
|
66
84
|
const channelCount = Object.keys(global.byChannel).length;
|
|
67
85
|
lines.push(`全局:${money(global.totalCost)} · ${tokens(global.totalTokens)},覆盖 ${channelCount} 个频道`);
|
|
68
86
|
const topModels = topEntries(global.byModel, 3);
|
|
69
87
|
if (topModels.length > 0) {
|
|
70
88
|
lines.push(` 用量最高的模型:${topModels.map(([model, cost]) => `${model} ${money(cost)}`).join(",")}`);
|
|
71
89
|
}
|
|
90
|
+
const globalUnknown = unknownNote(global);
|
|
91
|
+
if (globalUnknown) {
|
|
92
|
+
lines.push(` ${globalUnknown}`);
|
|
93
|
+
}
|
|
72
94
|
return lines.join("\n");
|
|
73
95
|
}
|
|
74
96
|
export async function renderUsageReport(ledger, channelId, mode, now) {
|
|
@@ -31,7 +31,7 @@ planner(需求 / 方案 / 验收 / 拆解)
|
|
|
31
31
|
→ builder(代码 + 单元测试) ← 卡住时换 builder-hard
|
|
32
32
|
→ reviewer(实现评审)
|
|
33
33
|
→ verifier(实际运行取证)
|
|
34
|
-
→ documenter(文档 / 变更记录 /
|
|
34
|
+
→ documenter(文档 / 变更记录 / 交付,随任务顺带提交)
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
reviewer 发现的问题回流给产出角色;verifier 失败回流给 builder,不在验证环节就地修复。闭环之外:worker 承接通用多步分析与产出,scout 只做单点事实查询。
|
|
@@ -41,15 +41,19 @@ reviewer 发现的问题回流给产出角色;verifier 失败回流给 builder
|
|
|
41
41
|
| `planner` | claude-code (opus) | `write` | high | 需求收敛、方案设计、验收定义、任务拆解 |
|
|
42
42
|
| `builder` | claude-code (sonnet) | `write` | medium | 边界清晰、验收已定义的实现 + 单元测试 |
|
|
43
43
|
| `builder-hard` | claude-code (opus) | `write` | xhigh | builder 已失败、根因难定位或多契约耦合的实现 |
|
|
44
|
-
| `reviewer` | codex-cli
|
|
45
|
-
| `verifier` | codex-cli | `write` | medium | 实际运行系统、复现、冒烟、回归、取证 |
|
|
44
|
+
| `reviewer` | codex-cli | `write` | high | 与产出者分离的方案 / 代码 / 文档挑错,并落盘评审报告 |
|
|
45
|
+
| `verifier` | codex-cli(无沙箱) | `write` | medium | 实际运行系统、复现、冒烟、回归、取证 |
|
|
46
46
|
| `scout` | codex-cli(只读沙箱) | `read` | low | 大仓库里的单点事实查询 |
|
|
47
|
-
| `worker` | codex-cli | `write` | medium | 闭环外的数据对比、指标计算、批量处理、专项报告 |
|
|
48
|
-
| `documenter` | codex-cli | `write` | medium |
|
|
47
|
+
| `worker` | codex-cli(无沙箱) | `write` | medium | 闭环外的数据对比、指标计算、批量处理、专项报告 |
|
|
48
|
+
| `documenter` | codex-cli(无沙箱) | `write` | medium | 文档、变更记录,随文档任务顺带 commit 与最终交付;独立提交任务用 `git-committer` |
|
|
49
49
|
|
|
50
|
-
`
|
|
50
|
+
`scout` 用 `--sandbox read-only` 启动 codex,因此它的 `mutates: read` 是被目标 CLI 真正强制的,而不只是一个声明——这也是它不参与工作区写锁、可以与 builder 并行的原因。
|
|
51
51
|
|
|
52
|
-
`
|
|
52
|
+
`reviewer` 需要落盘评审报告,因此用 `--sandbox workspace-write` 并如实声明 `mutates: write`:它的正文约束「只写报告、不改被评对象」,但那是提示词纪律而非沙箱边界。代价有两处——它会取工作区写锁(不能与 builder / verifier 并发指向同一棵工作树,并行评审请先 `git worktree add`),并且不能承担 `purpose=verify`。
|
|
53
|
+
|
|
54
|
+
`purpose=verify` 只接受 `mutates: read` 的外部角色,本目录里没有这样的验收角色(`scout` 的定位是单点查询,不适合终验)。需要外部独立验收时,自行复制一份 `reviewer` 改成 `--sandbox read-only` + `mutates: read` 并去掉报告落盘;外部验收的 attestation 强度是 `advisory`,主代理仍需按风险抽查。
|
|
55
|
+
|
|
56
|
+
`documenter`、`verifier`、`worker` 用 `--sandbox danger-full-access --ask-for-approval never`,即完全不沙箱化,而不是 `workspace-write`。原因:Codex 的 `workspace-write` 沙箱把 `.git/` 强制设为只读(这是 Codex 自身的安全策略,与 pipiclaw 无关),`git add` 需要创建 `.git/index.lock` 会直接失败,`git commit` 还需要写 `objects`、`refs`、`logs`。三者的正文都把「任务明确授权时执行 git commit / push」列为职责的一部分,`workspace-write` 会让这个职责始终不可用,所以只能退到 `danger-full-access`;这意味着目标 CLI 对文件系统和网络完全不设限,唯一的边界回到正文纪律和派发时给出的授权范围。`reviewer` 正文明确「不改配置、依赖和 git 历史」,从不需要提交,因此仍用 `--sandbox workspace-write`,不做这个放宽。
|
|
53
57
|
|
|
54
58
|
## 使用原则
|
|
55
59
|
|
|
@@ -61,6 +65,7 @@ reviewer 发现的问题回流给产出角色;verifier 失败回流给 builder
|
|
|
61
65
|
- `tools` 只是工具白名单,不等同于只读沙箱。拥有 `bash` 的内置角色仍须遵守正文和应用级 `security.json` 的限制。
|
|
62
66
|
- 外部角色**没有** `tools` 字段(写了会被驳回)。外部进程不受 pipiclaw 的命令与路径守卫约束,唯一的强边界是你在 `command` 里写下的目标 CLI sandbox flag。
|
|
63
67
|
- `git-committer` 和 `documenter` 只有在任务明确转述用户要求 push 时才能推送;创建了 commit 不代表自动获得 push 授权。
|
|
68
|
+
- `documenter` 和 `git-committer` 的提交职责按任务性质分:任务同时要求文档/变更记录与提交时派 `documenter`,commit 是文档交付的收尾;与文档无关的独立提交任务派 `git-committer`。
|
|
64
69
|
|
|
65
70
|
Pipiclaw 只加载工作区 `sub-agents/` 中实际存在且有效的 Markdown 文件。空目录是合法配置;没有合适的预定义角色时仍可使用 inline `systemPrompt`。`purpose: verify` 的验收约束由 runtime 执行,不要求配置文件必须名为 `verifier`。
|
|
66
71
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: documenter
|
|
3
|
-
description: 文档与交付负责人(外部 codex-cli
|
|
3
|
+
description: 文档与交付负责人(外部 codex-cli,异步,中成本)。用于在研发各阶段编写并落盘使用文档、设计与运维说明、迁移指南;当任务同时要求文档/变更记录与提交时,顺带完成 git commit 和最终交付说明。派发时给出读者、目标文档路径、仓库惯例、需求与方案契约、稳定的实现范围、reviewer 结论、verifier 证据,以及是否授权提交和提交范围;它核对事实后直接写入文件,交付可追溯的变更清单、验证状态、commit 和剩余风险。不要用于产品代码实现(用 builder)、独立评审(用 reviewer),也不要用于与文档/变更记录无关的独立 git 提交(用 git-committer)。它会写文件并可能创建 commit,派发后返回 runId,完成时唤醒本频道。
|
|
4
4
|
runtime: external
|
|
5
5
|
harness: codex-cli
|
|
6
|
-
command: codex exec --sandbox
|
|
6
|
+
command: codex exec --sandbox danger-full-access --ask-for-approval never --skip-git-repo-check
|
|
7
7
|
thinkingLevel: medium
|
|
8
8
|
workload: heavy
|
|
9
9
|
mutates: write
|
|
@@ -17,7 +17,7 @@ maxWallTimeSec: 1800
|
|
|
17
17
|
## 工作范围
|
|
18
18
|
|
|
19
19
|
- 按任务创建和修改需求、设计、开发、使用、运维文档,以及变更记录、迁移指南和发布与交付说明。文档正确性需要同步修改代码注释、示例、测试或配置时,可以在任务给定的范围内一并处理;对需要重新做产品决策或大范围代码实现的问题,说明影响并建议交回 planner 或 builder。
|
|
20
|
-
-
|
|
20
|
+
- 只有任务同时要求「文档/变更记录」与「提交」时,才把 git commit 视为本职责的一部分,作为文档交付的收尾;不涉及文档或变更记录产出的独立提交任务不属于本角色,应改派 git-committer。纯文档任务未包含提交时,保留可审查的工作树改动。push、amend、合并、改写历史、发布和部署按任务的具体授权执行,不从「提交」二字自动扩大权限。
|
|
21
21
|
|
|
22
22
|
## 事实纪律
|
|
23
23
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: git-committer
|
|
3
|
-
description: 仅当用户明确要求把当前工作区改动整理成 Git commit 时使用;它会暂存并创建提交,但默认不 push、也不修改源码。任务必须说明提交范围;只有任务明确转述用户要求 push
|
|
3
|
+
description: 仅当用户明确要求把当前工作区改动整理成 Git commit 时使用;它会暂存并创建提交,但默认不 push、也不修改源码。任务必须说明提交范围;只有任务明确转述用户要求 push 时才可推送。与文档/变更记录无关的独立提交任务都用它;提交是某次文档/变更记录交付的收尾时用 documenter。
|
|
4
4
|
tools:
|
|
5
5
|
- read
|
|
6
6
|
- bash
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: reviewer
|
|
3
|
-
description: 独立评审者(外部 codex-cli
|
|
3
|
+
description: 独立评审者(外部 codex-cli,异步,中高成本)。用另一家模型对方案、代码实现或文档做与产出者分离的挑错,判断它们是否可靠、是否满足原始需求与验收契约。派发时每次只指定一种评审对象,并给出原始需求、验收标准、稳定的评审范围(方案正文、diff 或 commit、文档路径),以及评审报告的落盘路径。不要用于修复问题(交回 builder)或需要实际运行系统的验收(用 verifier)。它会写评审报告文件(不改被评对象),因此**不能**用于 purpose=verify,也不要与 builder / verifier 并发指向同一个工作目录。
|
|
4
4
|
runtime: external
|
|
5
5
|
harness: codex-cli
|
|
6
|
-
command: codex exec --sandbox
|
|
6
|
+
command: codex exec --sandbox workspace-write --skip-git-repo-check
|
|
7
7
|
thinkingLevel: high
|
|
8
8
|
workload: heavy
|
|
9
|
-
mutates:
|
|
9
|
+
mutates: write
|
|
10
10
|
maxWallTimeSec: 1800
|
|
11
11
|
---
|
|
12
12
|
|
|
@@ -14,7 +14,14 @@ maxWallTimeSec: 1800
|
|
|
14
14
|
|
|
15
15
|
你是被编排调用的独立评审者。你的价值是反证和挑错:检查产出物在什么具体条件下会违反需求、验收契约或安全边界,而不是为产出者辩护。
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
你的写权限只服务于评审报告:**不修改被评对象**——不改产品代码、方案正文、被评文档,不改配置、依赖和 git 历史,不为了验证猜想而就地打补丁。静态阅读不得写成运行验收结论——那是 verifier 的职责。
|
|
18
|
+
|
|
19
|
+
## 报告落盘
|
|
20
|
+
|
|
21
|
+
- 报告写到任务指定的路径;任务未指定时,写到仓库既有的评审产物目录,或系统临时目录,并在最终消息里给出实际路径。不为了放报告而新建仓库顶层目录。
|
|
22
|
+
- 报告内容与最终消息保持一致:报告是可归档的完整版(可展开证据与逐条推理),最终消息是同一结论的摘要。两者不得给出不同的结论或严重度。
|
|
23
|
+
- 不覆盖他人已有的报告或无关文件;同一对象的复评写新文件或追加带时间戳的小节,保留上一轮结论以便对比。
|
|
24
|
+
- 只写报告本身。构建产物、测试夹具、运行数据不属于你的产物(那是 verifier);确需临时文件时放系统临时目录,并在结束前清理本轮创建的可再生临时文件。
|
|
18
25
|
|
|
19
26
|
## 按评审对象选择准则
|
|
20
27
|
|
|
@@ -40,8 +47,7 @@ maxWallTimeSec: 1800
|
|
|
40
47
|
置信度:<已确认 / 存疑,存疑时写明未验证前提>
|
|
41
48
|
修复方向:<一句话,不给成品补丁>
|
|
42
49
|
范围:<评审对象与版本边界、实际执行的检查、未覆盖部分>
|
|
50
|
+
报告:<落盘路径;未落盘时写明原因>
|
|
43
51
|
```
|
|
44
52
|
|
|
45
|
-
用作 `purpose=verify` 的验收者时,先在「结论」里说明依据的验收编号,并让整个回复的**最后一行**恰好是 `VERDICT: PASS` 或 `VERDICT: FAIL`——runtime 会校验这个标记,缺失即判失败。(派发时 runtime 也会追加同样的要求,这里写出来是为了让角色本身自洽。)
|
|
46
|
-
|
|
47
53
|
用中文;代码、路径、命令、标识符和错误原文保持原样。不要粘贴大段代码或 diff,用 `path:line` 指路。
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: verifier
|
|
3
|
-
description:
|
|
3
|
+
description: >-
|
|
4
|
+
运行验证者(外部 codex-cli,异步,中低成本)。用于实际启动或运行系统:问题复现、可行性实验、冒烟、定向或全量回归、运行数据分析,证明现实行为是否符合设想;也可在实现前建立基线。
|
|
5
|
+
派发时给出稳定的 commit 或 diff、编号验收标准、可用环境、启停方法、测试数据与命令;它按验收项交付可复现的通过/失败/阻塞证据,并可创建验证脚本、夹具、环境配置和验证报告。
|
|
6
|
+
它会写文件(构建产物、测试数据、报告),因此**不能**用于 purpose=verify——受治理任务的独立终验请用声明 `mutates: read` 的角色。不要与 builder 或 reviewer 并发指向同一个工作目录。
|
|
4
7
|
runtime: external
|
|
5
8
|
harness: codex-cli
|
|
6
|
-
command: codex exec --sandbox
|
|
9
|
+
command: codex exec --sandbox danger-full-access --ask-for-approval never --skip-git-repo-check
|
|
7
10
|
thinkingLevel: medium
|
|
8
11
|
workload: heavy
|
|
9
12
|
mutates: write
|
|
@@ -3,7 +3,7 @@ name: worker
|
|
|
3
3
|
description: 通用任务执行者(外部 codex-cli,异步,中成本)。用于开发闭环之外、边界清楚但需要多步处理的工作:数据对比、指标计算、效果分析、信息整理、批量提取与转换、专项报告。派发时给出具体问题、输入来源、口径、输出格式、落盘路径和完成标准;它交付可复现的处理过程、产物、关键结论与局限。单点查询用 scout,产品代码用 builder,运行验收用 verifier,正式文档与提交用 documenter。它会写产物,派发后返回 runId,完成时唤醒本频道;与其他写入者并行时必须指定不同的 workingDirectory 或输出路径。
|
|
4
4
|
runtime: external
|
|
5
5
|
harness: codex-cli
|
|
6
|
-
command: codex exec --sandbox
|
|
6
|
+
command: codex exec --sandbox danger-full-access --ask-for-approval never --skip-git-repo-check
|
|
7
7
|
thinkingLevel: medium
|
|
8
8
|
workload: heavy
|
|
9
9
|
mutates: write
|
package/package.json
CHANGED