@a-t-h-i/bot-lobby 0.6.34 → 0.6.36
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/package.json +1 -1
- package/src/execution/delegation.ts +10 -2
- package/src/lobby/quickfix.ts +2 -1
- package/webui/dist/assets/{index-C8hgfw6m.css → index-4Zm1DbOM.css} +1 -1
- package/webui/dist/assets/{index-B4zpEv7K.js → index-CjhlNym4.js} +2 -2
- package/webui/dist/build.json +5 -5
- package/webui/dist/index.html +2 -2
package/package.json
CHANGED
|
@@ -5,6 +5,7 @@ import { mkdirSync, writeFileSync } from "node:fs";
|
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
import { CONFIG_DIR_NAME } from "@earendil-works/pi-coding-agent";
|
|
7
7
|
import type { AgentRun } from "../schemas/findings.ts";
|
|
8
|
+
import type { Domain, Role } from "../schemas/agent.ts";
|
|
8
9
|
import { agentProfile } from "../schemas/configuration.ts";
|
|
9
10
|
import { dataRoot, detectProjectRoot, loadConfig } from "../state/project.ts";
|
|
10
11
|
import { EditLog } from "../state/changes.ts";
|
|
@@ -18,6 +19,13 @@ export const DELEGATE_TOOL = "delegate_subtasks";
|
|
|
18
19
|
export const AGENT_ENV = "BOT_LOBBY_AGENT_POLICY";
|
|
19
20
|
export const DELEGATION_ENV = "BOT_LOBBY_DELEGATION";
|
|
20
21
|
|
|
22
|
+
/** Only DESIGN/DEV workers and the QA gate may spawn children. */
|
|
23
|
+
export function canDelegate(agent: { role: Role; domain: Domain; depth?: number }, quotaUsed: number): boolean {
|
|
24
|
+
if ((agent.depth ?? 1) !== 1 || quotaUsed >= MAX_CHILDREN) return false;
|
|
25
|
+
if (agent.role === "worker") return agent.domain === "designer" || agent.domain === "backend";
|
|
26
|
+
return agent.role === "reviewer" && agent.domain === "qa";
|
|
27
|
+
}
|
|
28
|
+
|
|
21
29
|
/** One shared child pool per task; parents waiting on children never hold its slots. */
|
|
22
30
|
const pools = new Map<string, { active: number; users: number; waiters: Array<() => void> }>();
|
|
23
31
|
|
|
@@ -63,7 +71,7 @@ export async function delegationHost(options: PiRunOptions, run: ProcessRunner)
|
|
|
63
71
|
const agent = options.agent ?? { runId: id, taskId: id, domain: "backend" as const, role: editable ? "worker" as const : "reviewer" as const };
|
|
64
72
|
const depth = agent.depth ?? 1;
|
|
65
73
|
const quota = options.delegationQuota ?? { used: 0 };
|
|
66
|
-
const tools = [...new Set([...baseTools, ...(options.excalidraw ? toolsOf(options.excalidraw) : []), "codemode", "tool_search", ...(
|
|
74
|
+
const tools = [...new Set([...baseTools, ...(options.excalidraw ? toolsOf(options.excalidraw) : []), "codemode", "tool_search", ...(canDelegate(agent, quota.used) ? [DELEGATE_TOOL] : [])])];
|
|
67
75
|
const mcpTools = options.mcpTools ?? agentProfile(config, agent.domain, agent.role).mcpTools ?? [];
|
|
68
76
|
const policy: AgentPolicy = { tools, mcpTools, readOnly: !editable, depth };
|
|
69
77
|
if (depth > 1) return { tools, env: { ...options.env, [AGENT_ENV]: JSON.stringify(policy), [DELEGATION_ENV]: "" }, note: "You are a child agent. Finish only your assigned brief and report evidence to your parent; you cannot delegate further.", close: async () => {}, onStart: options.onStart, children: [] as AgentRun[] };
|
|
@@ -165,7 +173,7 @@ export async function delegationHost(options: PiRunOptions, run: ProcessRunner)
|
|
|
165
173
|
return {
|
|
166
174
|
tools: desk ? [...new Set([...tools, ...DESK_TOOLS])] : tools,
|
|
167
175
|
env: { ...options.env, ...(desk ? desk.env(parentDeskId) : {}), [AGENT_ENV]: JSON.stringify({ ...policy, tools: desk ? [...new Set([...tools, ...DESK_TOOLS])] : tools }), [DELEGATION_ENV]: JSON.stringify({ address: server.address, token, timeoutMs: options.timeoutMs }) },
|
|
168
|
-
note: `
|
|
176
|
+
note: `${canDelegate(agent, quota.used) ? `Begin every step by delegating your first two sub-briefs via ${DELEGATE_TOOL} — split the work into two disjoint pieces with separate files. If you need more brainpower, delegate more, at most five children total; children cannot delegate further. Integrate and verify their work yourself. ` : ""}Use codemode for concise parallel calls, inspect failures, and return only useful evidence.${desk ? " Before edit/write, claim_file; handover_file when finished. Release files before delegating or waiting." : ""}`,
|
|
169
177
|
onStart: (handle: Parameters<NonNullable<PiRunOptions["onStart"]>>[0]) => {
|
|
170
178
|
desk?.attach(parentDeskId, { runId: id, steer: handle.steer, annotate: () => {} });
|
|
171
179
|
options.onStart?.(handle);
|
package/src/lobby/quickfix.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type { AgentRun } from "../schemas/findings.ts";
|
|
|
8
8
|
*/
|
|
9
9
|
import { loadPrompt } from "../prompts/loader.ts";
|
|
10
10
|
import { runPiAgent, spawnPiProcess, type PiStreamEvent, type ProcessRunner } from "../execution/pi-runner.ts";
|
|
11
|
+
import { MAX_CHILDREN } from "../execution/delegation.ts";
|
|
11
12
|
import { grantOption } from "../excalidraw/sessions.ts";
|
|
12
13
|
import { describeToolCall } from "../pi/activity.ts";
|
|
13
14
|
import { appendMetrics, type MetricRecord } from "../state/metrics.ts";
|
|
@@ -298,7 +299,7 @@ export class QuickFixQueue {
|
|
|
298
299
|
this.edits.set(job.id, new EditLog(this.deps.cwd));
|
|
299
300
|
try {
|
|
300
301
|
const [likely, route] = await Promise.all([this.likely(job.prompt, controller.signal), this.route(job.prompt, profile, controller.signal)]);
|
|
301
|
-
const quota = { used:
|
|
302
|
+
const quota = { used: MAX_CHILDREN };
|
|
302
303
|
const attempt = (model: string | undefined, thinking: string) => runPiAgent(
|
|
303
304
|
{
|
|
304
305
|
cwd: this.deps.cwd,
|