picocode-core 0.9.228 → 0.9.230

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "picocode-core",
3
- "version": "0.9.228",
3
+ "version": "0.9.230",
4
4
  "description": "The agent runtime behind pico: sessions, tools, subagents, MCP, memory, and model access",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/agents.js CHANGED
@@ -20,6 +20,7 @@ function restoredAgent(data, at) {
20
20
  parentId: data.parentId || null,
21
21
  sessionId: data.sessionId || null,
22
22
  sessionFile: data.sessionFile || null,
23
+ callId: data.callId || null,
23
24
  tools: data.tools || [],
24
25
  status: 'cancelled',
25
26
  createdAt: at,
@@ -173,6 +174,8 @@ export function createAgentManager({ run, concurrency = 8, onChange = () => {},
173
174
  parentId: null,
174
175
  sessionId: options.sessionId || null,
175
176
  sessionFile: options.sessionFile || null,
177
+ // the tool call that started it, when another engine started it
178
+ callId: options.callId || null,
176
179
  tools: [],
177
180
  status: 'running',
178
181
  createdAt: at,
@@ -171,8 +171,9 @@ export function createClaudeCodeEngine({ command = claudeCommand(), idleMs = IDL
171
171
  const startSubagent = (block) => {
172
172
  if (!host.subagents || !SUBAGENT_TOOLS.has(block.name)) return
173
173
  // a subagent runs on the session's model unless its call names another
174
- const handle = host.subagents.start({ description: block.input?.description, prompt: block.input?.prompt ?? '', model: `${CLAUDE_CODE_PROVIDER}/${block.input?.model ?? model}` })
175
- subagents.set(block.id, { handle })
174
+ // the Task call that started it goes with it, so a host can show the subagent where the call is
175
+ const handle = host.subagents.start({ description: block.input?.description, prompt: block.input?.prompt ?? '', model: `${CLAUDE_CODE_PROVIDER}/${block.input?.model ?? model}`, callId: block.id })
176
+ subagents.set(block.id, { handle, said: '' })
176
177
  }
177
178
  // `extra` is the structured result, whose report is free of the frame
178
179
  // Claude Code wraps it in for the model
@@ -181,14 +182,15 @@ export function createClaudeCodeEngine({ command = claudeCommand(), idleMs = IDL
181
182
  if (!sub) return
182
183
  subagents.delete(block.tool_use_id)
183
184
  const text = Array.isArray(extra?.content) ? toolResultText(extra.content) : toolResultText(block.content)
184
- sub.handle.finish(block.is_error ? { error: text || 'failed', interrupted } : { result: text })
185
+ // what it found is its own last message, as it wrote it; the call's result only when it wrote none
186
+ sub.handle.finish(block.is_error ? { error: text || 'failed', interrupted } : { result: sub.said.trim() ? sub.said : text })
185
187
  }
186
188
  const onSubagent = (message) => {
187
189
  const sub = subagents.get(message.parent_tool_use_id)
188
190
  if (!sub) return
189
191
  if (message.type === 'assistant') {
190
192
  for (const block of message.message?.content ?? []) {
191
- if (block.type === 'text' && block.text) sub.handle.event({ type: 'content', content: block.text })
193
+ if (block.type === 'text' && block.text) { sub.said = block.text; sub.handle.event({ type: 'content', content: block.text }) }
192
194
  if (block.type !== 'tool_use') continue
193
195
  const { name, args } = picoTool(block.name, block.input, host.cwd)
194
196
  sub.handle.event({ type: 'tool_executing', call: { id: block.id, type: 'function', function: { name, arguments: JSON.stringify(args) } }, at: Date.now() })
@@ -21,7 +21,7 @@ const BRIDGE_PREFIX = `mcp__${BRIDGE_SERVER}__`
21
21
  // project keeps one store, pico's
22
22
  export const COVERED_TOOLS = new Set([
23
23
  'read', 'write', 'edit', 'bash', 'glob', 'grep', 'view', 'shell_output', 'shell_kill', 'tool_result',
24
- 'agent_plan', 'agent_start', 'agent_list', 'agent_collect', 'agent_cancel', 'deliberate',
24
+ 'agent_start', 'agent_list', 'agent_collect', 'agent_cancel', 'deliberate',
25
25
  'skill',
26
26
  ])
27
27
 
package/src/controller.js CHANGED
@@ -66,7 +66,7 @@ export const SESSION_COLORS = {
66
66
  gray: '#9ca3af',
67
67
  }
68
68
 
69
- const AGENT_TOOLS = ['agent_plan', 'agent_start', 'agent_list', 'agent_collect', 'agent_cancel']
69
+ const AGENT_TOOLS = ['agent_start', 'agent_list', 'agent_collect', 'agent_cancel']
70
70
  const CONTEXT_COLORS = ['#67b7ff', '#c792ea', '#f7c66a', '#f78c6c', '#6be795']
71
71
 
72
72
  function createEmitter() {
@@ -84,9 +84,9 @@ function createEmitter() {
84
84
  }
85
85
 
86
86
  // each of these takes the host's own wording when it gives one (boot.prompts), with {{placeholders}} filled in
87
- function parallelPrompt(task, agentLimit, template) {
88
- if (template) return fillPrompt(template, { task, agents: agentLimit })
89
- return `Use parallel agents for the following task: ${task}\n\nFirst call agent_plan. Interpret any agent-count instruction in the user's task semantically and declare that count; if the user gave no count, declare the configured default budget of ${agentLimit}. Then use agent_start within that enforced budget to delegate distinct, focused parts of the task to the configured worker model. Collect workers with agent_collect, critically evaluate their results, and synthesize the final response. When useful and the budget permits, use independent workers to check important disputed or weak conclusions. Do not delegate final synthesis. Do not emit progress updates while agents run; Pico displays agent activity automatically.`
87
+ function parallelPrompt(task, template) {
88
+ if (template) return fillPrompt(template, { task })
89
+ return `Use parallel agents for the following task: ${task}\n\nUse agent_start to delegate distinct, focused parts of the task to the configured worker model, as many as the task needs. Collect workers with agent_collect, critically evaluate their results, and synthesize the final response. When useful, use independent workers to check important disputed or weak conclusions. Do not delegate final synthesis. Do not emit progress updates while agents run; Pico displays agent activity automatically.`
90
90
  }
91
91
 
92
92
  function deliberatePrompt(decision, rounds, template) {
@@ -158,7 +158,7 @@ export function createController({ boot, run = runTurn, compactRun = compactHist
158
158
 
159
159
  let abort = null
160
160
  let sendAfterToolTriggered = false
161
- let nextResearchAgentLimit = null
161
+ let nextParallelTurn = false
162
162
  let pendingSystemNotes = []
163
163
  const warnedTools = new Set()
164
164
 
@@ -398,7 +398,7 @@ export function createController({ boot, run = runTurn, compactRun = compactHist
398
398
  concurrency: 8,
399
399
  defaults: () => ({ model: boot.researchModel }),
400
400
  onChange: bumpActivity,
401
- onCreate: (agent) => persist(makeEvent('agent_start', { agentId: agent.id, description: agent.description, prompt: agent.prompt, model: agent.model, role: agent.role, sessionId: agent.sessionId, sessionFile: agent.sessionFile, tools: agent.tools, ...(agent.external ? { external: true } : {}) })),
401
+ onCreate: (agent) => persist(makeEvent('agent_start', { agentId: agent.id, description: agent.description, prompt: agent.prompt, model: agent.model, role: agent.role, sessionId: agent.sessionId, sessionFile: agent.sessionFile, tools: agent.tools, ...(agent.callId ? { callId: agent.callId } : {}), ...(agent.external ? { external: true } : {}) })),
402
402
  // what an agent wrote between its steps is saved as one message each time a step begins or it finishes, so a
403
403
  // restored agent reads in the order it happened: a message, its steps, the next message
404
404
  onEvent: (agent, event) => {
@@ -923,8 +923,9 @@ export function createController({ boot, run = runTurn, compactRun = compactHist
923
923
 
924
924
  async function performAgentTurn() {
925
925
  if (state.busy || peerTransition || shuttingDown) return
926
- const researchAgentLimit = nextResearchAgentLimit || null
927
- nextResearchAgentLimit = null
926
+ // a /parallel turn: the main agent only delegates
927
+ const parallelTurn = nextParallelTurn
928
+ nextParallelTurn = false
928
929
  const controller = new AbortController()
929
930
  abort = controller
930
931
  emit('turn', 'start')
@@ -959,9 +960,7 @@ export function createController({ boot, run = runTurn, compactRun = compactHist
959
960
  onAgentsCollected: discardCollectedAgentNotes,
960
961
  askUser,
961
962
  signal: controller.signal,
962
- maxAgentStarts: researchAgentLimit ? 100 : undefined,
963
- requireAgentPlan: !!researchAgentLimit,
964
- allowNames: researchAgentLimit ? AGENT_TOOLS : undefined,
963
+ allowNames: parallelTurn ? AGENT_TOOLS : undefined,
965
964
  // the tools the host turned off for this model, read at every turn
966
965
  denyNames: typeof boot.disabledTools === 'function' ? boot.disabledTools(state.model) : boot.disabledTools,
967
966
  onToolUpdate,
@@ -1554,8 +1553,8 @@ export function createController({ boot, run = runTurn, compactRun = compactHist
1554
1553
  return true
1555
1554
  }
1556
1555
  if (!modelAvailable(boot.researchModel)) return false
1557
- nextResearchAgentLimit = boot.researchAgentLimit
1558
- send(parallelPrompt(task, boot.researchAgentLimit, boot.prompts?.parallel?.request))
1556
+ nextParallelTurn = true
1557
+ send(parallelPrompt(task, boot.prompts?.parallel?.request))
1559
1558
  return true
1560
1559
  }
1561
1560
 
@@ -194,7 +194,7 @@ export function createDaemonRuntime({ createSession, onEmpty = () => {}, batchMs
194
194
  return { result, incremental: true }
195
195
  }
196
196
  if (op === 'configure') {
197
- const allowed = ['researchModel', 'shellModel', 'deliberationModel', 'participantAModel', 'participantBModel', 'researchAgentLimit', 'clouds', 'compactToolHistory', 'gitFooter', 'wideSidebar']
197
+ const allowed = ['researchModel', 'shellModel', 'deliberationModel', 'participantAModel', 'participantBModel', 'clouds', 'compactToolHistory', 'gitFooter', 'wideSidebar']
198
198
  for (const [key, value] of Object.entries(args[0])) { if (!allowed.includes(key)) throw new Error('unsupported session setting'); record.ctl.boot[key] = value }
199
199
  publish(record, 'change')
200
200
  return
package/src/init.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export const INIT_PROMPT = `Initialize or improve this repository's AGENTS.md guidance for future pico sessions.
2
2
 
3
- Do this discovery yourself as the main agent. Do not call agent_plan, agent_start, agent_list, agent_collect, or delegate any part of this task to another agent.
3
+ Do this discovery yourself as the main agent. Do not call agent_start, agent_list, agent_collect, or delegate any part of this task to another agent.
4
4
 
5
5
  Inspect the repository directly and then create or update its AGENTS.md files. Read enough of the actual project to understand its structure and workflows, including the relevant manifests, documentation, configuration, source layout, tests, scripts, and existing instruction files. Use targeted searches and representative files rather than exhaustively reading every file. If an AGENTS.md already exists, preserve useful human-authored guidance and improve it conservatively instead of replacing it blindly. Check CLAUDE.md files for useful repository guidance when relevant, but write canonical guidance to AGENTS.md.
6
6
 
@@ -7,10 +7,8 @@ import { createGlob } from './glob.js'
7
7
  import { createGrep } from './grep.js'
8
8
  import { createView } from './view.js'
9
9
 
10
- export function createToolset({ toolResult, cwd, env, tracker, skills, shells, sessionId, sessionFile, wakeups, memory, agents, peers, deliberations, onAgentsCollected, askUser, mcpTools = [], userTools = [], hostTools = [], signal, maxToolCalls, maxAgentStarts, requireAgentPlan = false, allowNames, denyNames, onToolUpdate, viewer }) {
10
+ export function createToolset({ toolResult, cwd, env, tracker, skills, shells, sessionId, sessionFile, wakeups, memory, agents, peers, deliberations, onAgentsCollected, askUser, mcpTools = [], userTools = [], hostTools = [], signal, maxToolCalls, allowNames, denyNames, onToolUpdate, viewer }) {
11
11
  const recorder = createRecorder(onToolUpdate)
12
- let agentStarts = 0
13
- let plannedAgentStarts = requireAgentPlan ? null : maxAgentStarts
14
12
  const deps = { cwd, env, recorder, tracker, signal, shells, sessionId, sessionFile }
15
13
 
16
14
  const local = [
@@ -173,35 +171,16 @@ export function createToolset({ toolResult, cwd, env, tracker, skills, shells, s
173
171
 
174
172
  if (agents) {
175
173
  local.push(
176
- {
177
- name: 'agent_plan',
178
- description: 'Declare the background worker budget for the current assistant turn before starting any workers. The main agent is excluded. Set count to the number of workers you intend to start this turn; collecting a worker does not restore budget. Interpret any user-requested count semantically; otherwise use the configured default.',
179
- schema: {
180
- description: describeParam,
181
- count: { type: 'integer', description: `background workers permitted this turn, excluding the main agent (1-${maxAgentStarts || 100})` },
182
- reason: { type: 'string', description: 'brief explanation of how the count follows the user request or research scope' },
183
- },
184
- execute: ({ count, reason }) => {
185
- const ceiling = maxAgentStarts || 100
186
- if (!Number.isInteger(count) || count < 1 || count > ceiling) throw new Error(`agent budget must be between 1 and ${ceiling}`)
187
- if (agentStarts > 0) throw new Error('agent budget must be declared before starting agents')
188
- plannedAgentStarts = count
189
- return { agentLimit: count, reason }
190
- },
191
- },
192
174
  {
193
175
  name: 'agent_start',
194
- description: 'Start one background worker, consuming one unit of the current turn\'s agent_plan budget. Workers do not receive the parent conversation, only the supplied prompt and their available project context and tools. Make the prompt self-contained by including all conversation-specific terms, goals, constraints, and decisions the worker cannot discover itself. Collected or completed workers do not restore budget within that turn. Continue only independent work until you collect its result with agent_collect.',
176
+ description: 'Start one background worker, as many as the task needs. Workers do not receive the parent conversation, only the supplied prompt and their available project context and tools. Make the prompt self-contained by including all conversation-specific terms, goals, constraints, and decisions the worker cannot discover itself. Continue only independent work until you collect its result with agent_collect.',
195
177
  schema: {
196
178
  prompt: { type: 'string', description: 'complete, self-contained task and desired output, including necessary context from the parent conversation' },
197
179
  description: describeParam,
198
180
  tools: { type: 'array', items: { type: 'string' }, description: 'tool names to allow; omit for the configured worker tools', optional: true },
199
181
  },
200
182
  execute: ({ prompt, description, tools }) => {
201
- if (plannedAgentStarts == null) throw new Error('call agent_plan before starting research agents')
202
- if (agentStarts >= plannedAgentStarts) throw new Error(`agent limit reached for this turn (${plannedAgentStarts}); completed or collected workers do not restore budget within the turn`)
203
183
  const agent = agents.start({ prompt, description, tools, sessionId, sessionFile })
204
- agentStarts++
205
184
  return { agentId: agent.id, status: agent.status, model: agent.model }
206
185
  },
207
186
  },