picocode-core 0.9.229 → 0.9.231

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.231",
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() })
@@ -208,7 +210,8 @@ export function createClaudeCodeEngine({ command = claudeCommand(), idleMs = IDL
208
210
  // call through the bridge lands on the tool_use Claude announced for
209
211
  // it (same name, same arguments, oldest first), once every message
210
212
  // before it has been handled, since it reaches pico by another channel
211
- entry.bridge.setTurn(tools.filter((tool) => !COVERED_TOOLS.has(tool.name)), async (name, args) => {
213
+ const covered = host.ownTools ? new Set(host.ownTools) : COVERED_TOOLS
214
+ entry.bridge.setTurn(tools.filter((tool) => !covered.has(tool.name)), async (name, args) => {
212
215
  await chain
213
216
  const at = unclaimed.findIndex((use) => use.name === name && JSON.stringify(use.args) === JSON.stringify(args ?? {}))
214
217
  const use = at >= 0 ? unclaimed.splice(at, 1)[0] : null
@@ -18,10 +18,12 @@ const BRIDGE_PREFIX = `mcp__${BRIDGE_SERVER}__`
18
18
  // pico tools Claude Code already has its own version of; offering both
19
19
  // would only make the model choose between equivalent tools. Memory is
20
20
  // not among them: Claude Code's own is switched off, so every model in a
21
- // project keeps one store, pico's
21
+ // project keeps one store, pico's. Deliberation is not either: Claude
22
+ // Code has nothing like it. A host that decides this itself passes its
23
+ // own list (boot.engineOwnTools)
22
24
  export const COVERED_TOOLS = new Set([
23
25
  'read', 'write', 'edit', 'bash', 'glob', 'grep', 'view', 'shell_output', 'shell_kill', 'tool_result',
24
- 'agent_start', 'agent_list', 'agent_collect', 'agent_cancel', 'deliberate',
26
+ 'agent_start', 'agent_list', 'agent_collect', 'agent_cancel',
25
27
  'skill',
26
28
  ])
27
29
 
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) => {
@@ -799,6 +799,8 @@ export function createController({ boot, run = runTurn, compactRun = compactHist
799
799
  env: boot.env,
800
800
  contextFiles: boot.startupContext?.files ?? [],
801
801
  engineState: savedEngineState(engine),
802
+ // the pico tools this engine's model is not offered, when the host decides that in place of the engine
803
+ ownTools: boot.engineOwnTools?.[engine.name] ?? null,
802
804
  // subagents the engine runs itself, shown in the activity list
803
805
  subagents: { start: (options) => agents.track({ ...options, sessionId: state.session?.id, sessionFile: state.session?.file }) },
804
806
  }