picocode-core 0.9.229 → 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.229",
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() })
package/src/controller.js CHANGED
@@ -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) => {