@oyasmi/pipiclaw 0.9.0-beta.1 → 0.9.0-beta.2
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/job-manager.d.ts +6 -0
- package/dist/agent/job-manager.js +55 -1
- package/dist/runtime/bootstrap.d.ts +38 -0
- package/dist/runtime/bootstrap.js +134 -25
- 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/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/subagents/external/run.d.ts +10 -0
- package/dist/subagents/external/run.js +47 -1
- package/dist/subagents/runs.d.ts +14 -0
- package/dist/subagents/runs.js +117 -24
- package/dist/subagents/tool.d.ts +18 -0
- package/dist/subagents/tool.js +144 -88
- 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 +37 -24
- 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 +5 -3
- package/examples/sub-agents/reviewer.md +12 -6
- package/examples/sub-agents/verifier.md +4 -1
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ import { createWriteStream } from "node:fs";
|
|
|
4
4
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
import * as log from "../../log.js";
|
|
7
|
+
import { logSecurityEvent } from "../../security/logger.js";
|
|
7
8
|
import { killProcessGroup } from "../../shared/host-process.js";
|
|
8
9
|
import { formatLocalTime } from "../../shared/local-time.js";
|
|
9
10
|
import { splitShellWords } from "../../shared/shell-words.js";
|
|
@@ -54,6 +55,22 @@ export async function launchExternalRun(input) {
|
|
|
54
55
|
systemPromptFile,
|
|
55
56
|
resumeSessionId: input.resumeSessionId,
|
|
56
57
|
});
|
|
58
|
+
const spawnedArgv = [invocation.executable, ...invocation.args];
|
|
59
|
+
// Security gate: the final executable/argv/cwd/capability record must be durable before a
|
|
60
|
+
// process can exist. `external-agent` uses the strict appender path and rejects on queue or I/O
|
|
61
|
+
// failure; callers then release any admission lease without an unaudited child ever starting.
|
|
62
|
+
await logSecurityEvent(input.workspaceDir, input.securityConfig, {
|
|
63
|
+
type: "external-agent",
|
|
64
|
+
tool: "subagent",
|
|
65
|
+
channelId: input.channelId,
|
|
66
|
+
runId: input.runId,
|
|
67
|
+
agent: input.agent,
|
|
68
|
+
harness: harness.id,
|
|
69
|
+
argv: spawnedArgv,
|
|
70
|
+
workingDirectory: input.workingDirectory,
|
|
71
|
+
mutates: input.mutates ?? "read",
|
|
72
|
+
model: input.externalModelRef,
|
|
73
|
+
});
|
|
57
74
|
const runManager = getSubAgentRunManager(input.channelId);
|
|
58
75
|
await runManager.register({
|
|
59
76
|
runId: input.runId,
|
|
@@ -71,6 +88,14 @@ export async function launchExternalRun(input) {
|
|
|
71
88
|
artifactDir: input.artifactDir,
|
|
72
89
|
leaseKey: input.leaseKey,
|
|
73
90
|
});
|
|
91
|
+
let cancelledBeforeSpawn = false;
|
|
92
|
+
const launchClaimed = await runManager.claimExternalLaunch(input.runId, () => {
|
|
93
|
+
cancelledBeforeSpawn = true;
|
|
94
|
+
});
|
|
95
|
+
if (!launchClaimed) {
|
|
96
|
+
await runManager.settle(input.runId, { ...failedSettleInput("Cancelled before the external process was spawned."), status: "cancelled" }, { announce: false });
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
74
99
|
const eventsPath = join(input.artifactDir, "events.jsonl");
|
|
75
100
|
const stderrPath = join(input.artifactDir, "stderr.log");
|
|
76
101
|
const eventsStream = createWriteStream(eventsPath);
|
|
@@ -108,11 +133,18 @@ export async function launchExternalRun(input) {
|
|
|
108
133
|
return;
|
|
109
134
|
}
|
|
110
135
|
const pid = child.pid;
|
|
136
|
+
if (cancelledBeforeSpawn) {
|
|
137
|
+
void killProcessGroup(pid);
|
|
138
|
+
eventsStream.close();
|
|
139
|
+
stderrStream.close();
|
|
140
|
+
await runManager.settle(input.runId, { ...failedSettleInput("Cancelled while the external process was spawning."), status: "cancelled" }, { announce: false });
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
111
143
|
const fingerprint = randomBytes(6).toString("hex");
|
|
112
144
|
await runManager.setLaunched(input.runId, {
|
|
113
145
|
pid,
|
|
114
146
|
fingerprint,
|
|
115
|
-
argv:
|
|
147
|
+
argv: spawnedArgv,
|
|
116
148
|
sessionId: invocation.presetSessionId,
|
|
117
149
|
});
|
|
118
150
|
child.stdout?.on("data", (chunk) => eventsStream.write(chunk));
|
|
@@ -121,7 +153,9 @@ export async function launchExternalRun(input) {
|
|
|
121
153
|
child.stdin.on("error", () => { }); // EPIPE if the process already exited; harmless.
|
|
122
154
|
child.stdin.end(stdinContent);
|
|
123
155
|
}
|
|
156
|
+
let cancelled = false;
|
|
124
157
|
runManager.registerCancelHandle(input.runId, () => {
|
|
158
|
+
cancelled = true;
|
|
125
159
|
void killProcessGroup(pid);
|
|
126
160
|
});
|
|
127
161
|
const wallClockTimer = setTimeout(() => {
|
|
@@ -135,8 +169,20 @@ export async function launchExternalRun(input) {
|
|
|
135
169
|
}).then(async (exitCode) => {
|
|
136
170
|
clearTimeout(wallClockTimer);
|
|
137
171
|
runManager.clearCancelHandle(input.runId);
|
|
172
|
+
// The leader can exit before a detached descendant it spawned (e.g. a shell that forked and
|
|
173
|
+
// returned); `-pid` still reaches the whole group as long as the group itself is still
|
|
174
|
+
// around, so reap it unconditionally rather than only on an explicit cancel/timeout.
|
|
175
|
+
await killProcessGroup(pid);
|
|
138
176
|
await new Promise((resolve) => eventsStream.end(resolve));
|
|
139
177
|
await new Promise((resolve) => stderrStream.end(resolve));
|
|
178
|
+
if (cancelled) {
|
|
179
|
+
await runManager
|
|
180
|
+
.settle(input.runId, { ...failedSettleInput("Cancelled by request."), status: "cancelled" }, { announce: false })
|
|
181
|
+
.catch((error) => {
|
|
182
|
+
log.logWarning(`Failed to settle external run ${input.runId}`, errorMessage(error));
|
|
183
|
+
});
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
140
186
|
const eventsText = await readFile(eventsPath, "utf-8").catch(() => "");
|
|
141
187
|
const stderrTail = (await readFile(stderrPath, "utf-8").catch(() => "")).slice(-WAKE_OUTPUT_TAIL_CHARS);
|
|
142
188
|
const outcome = harness.parseOutcome({ eventsText, exitCode, stderrTail });
|
package/dist/subagents/runs.d.ts
CHANGED
|
@@ -66,6 +66,9 @@ export interface RunRecord extends RunUsage {
|
|
|
66
66
|
usageRecorded?: boolean;
|
|
67
67
|
/** Set once the completion wake has been hallmarked for delivery; guards against a duplicate wake. */
|
|
68
68
|
wakeEnqueued?: boolean;
|
|
69
|
+
/** Durable one-time relationship between the internally produced wake and task activation (T9). */
|
|
70
|
+
wakeClaimDispatchId?: string;
|
|
71
|
+
wakeConsumedAt?: number;
|
|
69
72
|
pid?: number;
|
|
70
73
|
fingerprint?: string;
|
|
71
74
|
argv?: string[];
|
|
@@ -127,6 +130,9 @@ export declare class SubAgentRunManager {
|
|
|
127
130
|
* kill goes through pid, not this map, once phase 2/3 lands). Never persisted: a restart loses
|
|
128
131
|
* the only thing that could reach an in-process worker anyway (D10.3). */
|
|
129
132
|
private readonly cancelHandles;
|
|
133
|
+
/** External launch intents exist before a safe live child handle does. A cancel in that window
|
|
134
|
+
* is remembered here and consumed before spawn, rather than spawning a process nothing can cancel. */
|
|
135
|
+
private readonly externalLaunches;
|
|
130
136
|
private readonly queue;
|
|
131
137
|
constructor(channelId: string, options: RunManagerOptions);
|
|
132
138
|
private recordPath;
|
|
@@ -147,6 +153,10 @@ export declare class SubAgentRunManager {
|
|
|
147
153
|
runningCount(): number;
|
|
148
154
|
/** Register the run's lifecycle before any work starts, and persist it immediately (D1). */
|
|
149
155
|
register(input: RegisterRunInput): Promise<RunRecord>;
|
|
156
|
+
/** Atomically crosses the external launch cancel window. The supplied live-handle callback is
|
|
157
|
+
* installed before this method resolves; a cancel queued during register is observed first and
|
|
158
|
+
* makes this return false, so the caller must not spawn. */
|
|
159
|
+
claimExternalLaunch(runId: string, cancel: () => void): Promise<boolean>;
|
|
150
160
|
/**
|
|
151
161
|
* Persist the pid once a spawn actually succeeds — the second half of D1's launch ordering.
|
|
152
162
|
* `register()` already durably recorded the intent (argv, working directory, artifact dir)
|
|
@@ -159,6 +169,10 @@ export declare class SubAgentRunManager {
|
|
|
159
169
|
argv: string[];
|
|
160
170
|
sessionId?: string;
|
|
161
171
|
}): Promise<void>;
|
|
172
|
+
/** Reserve a task wake exactly once. A replay of the same durable dispatch may resume an
|
|
173
|
+
* interrupted activation, while copied text or a different dispatch id can never claim it. */
|
|
174
|
+
beginWakeConsumption(runId: string, taskId: string, dispatchId: string): Promise<boolean>;
|
|
175
|
+
finishWakeConsumption(runId: string, dispatchId: string): Promise<void>;
|
|
162
176
|
/** Let a caller (subagent tool) register a way to abort this run's in-process worker. */
|
|
163
177
|
registerCancelHandle(runId: string, cancel: () => void): void;
|
|
164
178
|
clearCancelHandle(runId: string): void;
|
package/dist/subagents/runs.js
CHANGED
|
@@ -20,6 +20,10 @@ export const MAX_RUNNING_SUBAGENT_RUNS_PER_CHANNEL = 5;
|
|
|
20
20
|
/** D10.2: host-wide cap across every channel. Bounds unbounded process/worker growth only —
|
|
21
21
|
* not the full cross-subsystem (task/job/sidecar) admission scheme the design doc leaves open. */
|
|
22
22
|
export const MAX_RUNNING_SUBAGENT_RUNS_PER_HOST = 20;
|
|
23
|
+
/** Registration is serialized across channel managers so the host-wide count and insertion are
|
|
24
|
+
* one admission transaction. The per-run manager queue alone cannot protect the 19 -> 20 edge
|
|
25
|
+
* when two different channels register concurrently. */
|
|
26
|
+
const hostAdmissionQueue = createSerialQueue();
|
|
23
27
|
/** Bytes of the reply text carried inline in the completion wake, matching job-manager's tail budget. */
|
|
24
28
|
const WAKE_OUTPUT_TAIL_CHARS = 2_000;
|
|
25
29
|
function isTerminal(status) {
|
|
@@ -61,12 +65,15 @@ export class SubAgentRunManager {
|
|
|
61
65
|
* kill goes through pid, not this map, once phase 2/3 lands). Never persisted: a restart loses
|
|
62
66
|
* the only thing that could reach an in-process worker anyway (D10.3). */
|
|
63
67
|
this.cancelHandles = new Map();
|
|
68
|
+
/** External launch intents exist before a safe live child handle does. A cancel in that window
|
|
69
|
+
* is remembered here and consumed before spawn, rather than spawning a process nothing can cancel. */
|
|
70
|
+
this.externalLaunches = new Map();
|
|
64
71
|
this.queue = createSerialQueue();
|
|
65
72
|
}
|
|
66
73
|
recordPath(runId) {
|
|
67
74
|
return this.options.stateDir ? join(this.options.stateDir, this.channelId, `${runId}.json`) : undefined;
|
|
68
75
|
}
|
|
69
|
-
async persist(record) {
|
|
76
|
+
async persist(record, required = false) {
|
|
70
77
|
const path = this.recordPath(record.runId);
|
|
71
78
|
if (!path)
|
|
72
79
|
return;
|
|
@@ -74,6 +81,8 @@ export class SubAgentRunManager {
|
|
|
74
81
|
await writeFileAtomically(path, `${JSON.stringify(record)}\n`);
|
|
75
82
|
}
|
|
76
83
|
catch (error) {
|
|
84
|
+
if (required)
|
|
85
|
+
throw error;
|
|
77
86
|
log.logWarning(`Failed to persist sub-agent run ${record.runId}`, errorMessage(error));
|
|
78
87
|
}
|
|
79
88
|
}
|
|
@@ -99,6 +108,7 @@ export class SubAgentRunManager {
|
|
|
99
108
|
async forget(record) {
|
|
100
109
|
this.runs.delete(record.runId);
|
|
101
110
|
this.cancelHandles.delete(record.runId);
|
|
111
|
+
this.externalLaunches.delete(record.runId);
|
|
102
112
|
const path = this.recordPath(record.runId);
|
|
103
113
|
if (path)
|
|
104
114
|
await unlink(path).catch(() => undefined);
|
|
@@ -124,28 +134,55 @@ export class SubAgentRunManager {
|
|
|
124
134
|
}
|
|
125
135
|
/** Register the run's lifecycle before any work starts, and persist it immediately (D1). */
|
|
126
136
|
async register(input) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
137
|
+
return hostAdmissionQueue.run("host", () => this.queue.run(input.runId, async () => {
|
|
138
|
+
// D10.2: a per-channel and a host-wide cap, both code constants (a local response to a
|
|
139
|
+
// runaway model, not a global cross-subsystem admission scheme — see the design doc's
|
|
140
|
+
// non-goals). Checked before anything is persisted, so a rejected run costs nothing.
|
|
141
|
+
if (this.runningCount() >= MAX_RUNNING_SUBAGENT_RUNS_PER_CHANNEL) {
|
|
142
|
+
throw new Error(`Too many delegation runs already running on this channel (>= ${MAX_RUNNING_SUBAGENT_RUNS_PER_CHANNEL}). ` +
|
|
143
|
+
"Wait for one to finish, or cancel one with subagent_manage first.");
|
|
144
|
+
}
|
|
145
|
+
if (totalRunningSubAgentRuns() >= MAX_RUNNING_SUBAGENT_RUNS_PER_HOST) {
|
|
146
|
+
throw new Error(`Too many delegation runs already running host-wide (>= ${MAX_RUNNING_SUBAGENT_RUNS_PER_HOST}). ` +
|
|
147
|
+
"Wait for one to finish before dispatching another.");
|
|
148
|
+
}
|
|
149
|
+
const record = {
|
|
150
|
+
...input,
|
|
151
|
+
status: "running",
|
|
152
|
+
startedAt: Date.now(),
|
|
153
|
+
usage: emptyUsage(),
|
|
154
|
+
usageKnown: true,
|
|
155
|
+
costKnown: true,
|
|
156
|
+
};
|
|
157
|
+
this.runs.set(record.runId, record);
|
|
158
|
+
if (record.runtime === "external")
|
|
159
|
+
this.externalLaunches.set(record.runId, { cancelRequested: false });
|
|
160
|
+
try {
|
|
161
|
+
await this.persist(record, true);
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
this.runs.delete(record.runId);
|
|
165
|
+
this.externalLaunches.delete(record.runId);
|
|
166
|
+
throw error;
|
|
167
|
+
}
|
|
168
|
+
return record;
|
|
169
|
+
}));
|
|
170
|
+
}
|
|
171
|
+
/** Atomically crosses the external launch cancel window. The supplied live-handle callback is
|
|
172
|
+
* installed before this method resolves; a cancel queued during register is observed first and
|
|
173
|
+
* makes this return false, so the caller must not spawn. */
|
|
174
|
+
async claimExternalLaunch(runId, cancel) {
|
|
175
|
+
return this.queue.run(runId, async () => {
|
|
176
|
+
const record = this.runs.get(runId);
|
|
177
|
+
const launch = this.externalLaunches.get(runId);
|
|
178
|
+
if (!record || record.status !== "running" || !launch || launch.cancelRequested) {
|
|
179
|
+
this.externalLaunches.delete(runId);
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
this.cancelHandles.set(runId, cancel);
|
|
183
|
+
this.externalLaunches.delete(runId);
|
|
184
|
+
return true;
|
|
185
|
+
});
|
|
149
186
|
}
|
|
150
187
|
/**
|
|
151
188
|
* Persist the pid once a spawn actually succeeds — the second half of D1's launch ordering.
|
|
@@ -164,7 +201,47 @@ export class SubAgentRunManager {
|
|
|
164
201
|
// at settle(), means a run that crashes before any output is still resumable.
|
|
165
202
|
if (info.sessionId)
|
|
166
203
|
record.sessionId = info.sessionId;
|
|
167
|
-
await this.persist(record);
|
|
204
|
+
await this.persist(record, true);
|
|
205
|
+
}
|
|
206
|
+
/** Reserve a task wake exactly once. A replay of the same durable dispatch may resume an
|
|
207
|
+
* interrupted activation, while copied text or a different dispatch id can never claim it. */
|
|
208
|
+
async beginWakeConsumption(runId, taskId, dispatchId) {
|
|
209
|
+
return this.queue.run(runId, async () => {
|
|
210
|
+
const record = this.runs.get(runId);
|
|
211
|
+
const expected = `subagent:${record?.channelId}:${runId}:done`;
|
|
212
|
+
if (!record?.settledAt ||
|
|
213
|
+
record.taskId !== taskId ||
|
|
214
|
+
dispatchId !== expected ||
|
|
215
|
+
record.wakeConsumedAt ||
|
|
216
|
+
(record.wakeClaimDispatchId && record.wakeClaimDispatchId !== dispatchId)) {
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
const previousClaim = record.wakeClaimDispatchId;
|
|
220
|
+
record.wakeClaimDispatchId = dispatchId;
|
|
221
|
+
try {
|
|
222
|
+
await this.persist(record, true);
|
|
223
|
+
}
|
|
224
|
+
catch (error) {
|
|
225
|
+
record.wakeClaimDispatchId = previousClaim;
|
|
226
|
+
throw error;
|
|
227
|
+
}
|
|
228
|
+
return true;
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
async finishWakeConsumption(runId, dispatchId) {
|
|
232
|
+
await this.queue.run(runId, async () => {
|
|
233
|
+
const record = this.runs.get(runId);
|
|
234
|
+
if (!record || record.wakeClaimDispatchId !== dispatchId || record.wakeConsumedAt)
|
|
235
|
+
return;
|
|
236
|
+
record.wakeConsumedAt = Date.now();
|
|
237
|
+
try {
|
|
238
|
+
await this.persist(record, true);
|
|
239
|
+
}
|
|
240
|
+
catch (error) {
|
|
241
|
+
record.wakeConsumedAt = undefined;
|
|
242
|
+
throw error;
|
|
243
|
+
}
|
|
244
|
+
});
|
|
168
245
|
}
|
|
169
246
|
/** Let a caller (subagent tool) register a way to abort this run's in-process worker. */
|
|
170
247
|
registerCancelHandle(runId, cancel) {
|
|
@@ -202,6 +279,7 @@ export class SubAgentRunManager {
|
|
|
202
279
|
releaseWorkspaceLease(record.leaseKey);
|
|
203
280
|
await this.persist(record);
|
|
204
281
|
this.cancelHandles.delete(runId);
|
|
282
|
+
this.externalLaunches.delete(runId);
|
|
205
283
|
if (!record.usageRecorded) {
|
|
206
284
|
record.usageRecorded = true;
|
|
207
285
|
this.options.ledger?.record({
|
|
@@ -290,6 +368,16 @@ export class SubAgentRunManager {
|
|
|
290
368
|
conversationId: "",
|
|
291
369
|
conversationType: record.channelId.startsWith("group_") ? "2" : "1",
|
|
292
370
|
dispatchId: `subagent:${record.channelId}:${record.runId}:done`,
|
|
371
|
+
...(record.taskId
|
|
372
|
+
? {
|
|
373
|
+
internalWake: {
|
|
374
|
+
kind: "subagent",
|
|
375
|
+
resourceId: record.runId,
|
|
376
|
+
taskId: record.taskId,
|
|
377
|
+
dispatchId: `subagent:${record.channelId}:${record.runId}:done`,
|
|
378
|
+
},
|
|
379
|
+
}
|
|
380
|
+
: {}),
|
|
293
381
|
};
|
|
294
382
|
try {
|
|
295
383
|
await this.options.dispatch(event);
|
|
@@ -314,6 +402,11 @@ export class SubAgentRunManager {
|
|
|
314
402
|
if (cancelHandle) {
|
|
315
403
|
cancelHandle();
|
|
316
404
|
}
|
|
405
|
+
else if (record.runtime === "external" && this.externalLaunches.has(runId)) {
|
|
406
|
+
// The process has not spawned yet; claimExternalLaunch() will observe this request
|
|
407
|
+
// and refuse to spawn instead of starting an uncancellable child.
|
|
408
|
+
this.externalLaunches.get(runId).cancelRequested = true;
|
|
409
|
+
}
|
|
317
410
|
else {
|
|
318
411
|
// No in-process handle (external runtime, not yet wired, or a run this process did
|
|
319
412
|
// not launch): mark it lost rather than pretend a cancel we could not perform happened.
|
package/dist/subagents/tool.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type { PipiclawMemoryRecallSettings } from "../settings.js";
|
|
|
8
8
|
import type { UsageTotals } from "../shared/types.js";
|
|
9
9
|
import type { PipiclawWebToolsConfig } from "../tools/config.js";
|
|
10
10
|
import { type ResolvedSubAgentConfig, type SubAgentDiscoveryResult } from "./discovery.js";
|
|
11
|
+
import { getSubAgentRunManager } from "./runs.js";
|
|
11
12
|
declare const subagentSchema: Type.TObject<{
|
|
12
13
|
label: Type.TString;
|
|
13
14
|
agent: Type.TOptional<Type.TString>;
|
|
@@ -80,10 +81,14 @@ export interface SubAgentToolOptions {
|
|
|
80
81
|
apiKey: string;
|
|
81
82
|
tools: AgentTool<any>[];
|
|
82
83
|
}) => SubAgentWorker;
|
|
84
|
+
/** Test seam for failures while constructing the scoped tool set after durable registration. */
|
|
85
|
+
buildTools?: typeof buildSubagentTools;
|
|
83
86
|
/** Test-only override for the D6 convergence-turn wall clock; defaults to CONVERGENCE_WALL_CLOCK_MS. */
|
|
84
87
|
convergenceWallClockMs?: number;
|
|
85
88
|
/** Test-only override for the D2 sync grace window; defaults to SYNC_GRACE_MS. */
|
|
86
89
|
syncGraceMs?: number;
|
|
90
|
+
/** Test seam for setup/admission failures. Production uses the process-wide channel manager. */
|
|
91
|
+
getRunManager?: typeof getSubAgentRunManager;
|
|
87
92
|
}
|
|
88
93
|
interface SubAgentWorker {
|
|
89
94
|
state: {
|
|
@@ -102,5 +107,18 @@ interface SubAgentWorker {
|
|
|
102
107
|
* only caps what gets echoed into the parent's context.
|
|
103
108
|
*/
|
|
104
109
|
export declare const MAX_SUBAGENT_RESULT_UNITS = 1200;
|
|
110
|
+
interface SubAgentRunContext {
|
|
111
|
+
runId: string;
|
|
112
|
+
purpose: "work" | "verify";
|
|
113
|
+
taskId?: string;
|
|
114
|
+
workingDirectory: string;
|
|
115
|
+
artifactDir: string;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Build a sub-agent's tool set from the shared tool registry, filtered to tools flagged
|
|
119
|
+
* available to sub-agents (files + web). Sub-agents run with their own security context
|
|
120
|
+
* (rooted at the sub-agent workspace) and their own per-invocation bash timeout.
|
|
121
|
+
*/
|
|
122
|
+
declare function buildSubagentTools(executor: Executor, bashTimeoutSec: number, options: SubAgentToolOptions, runContext: SubAgentRunContext): AgentTool<any>[];
|
|
105
123
|
export declare function createSubAgentTool(options: SubAgentToolOptions): AgentTool<typeof subagentSchema, SubAgentToolDetails>;
|
|
106
124
|
export {};
|