picocode-core 0.9.210 → 0.9.212
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/README.md +1 -1
- package/package.json +1 -1
- package/src/agents.js +64 -1
- package/src/catalog-snapshot.json +1 -1
- package/src/claude-code/README.md +43 -0
- package/src/claude-code/bridge.js +104 -0
- package/src/claude-code/cli.js +127 -0
- package/src/claude-code/engine.js +387 -0
- package/src/claude-code/mcp-server.js +48 -0
- package/src/claude-code/models.js +71 -0
- package/src/claude-code/translate.js +220 -0
- package/src/controller.js +32 -5
- package/src/engines.js +29 -0
package/README.md
CHANGED
|
@@ -12,4 +12,4 @@ import { deriveState } from 'picocode-core/derive.js'
|
|
|
12
12
|
import { createToolset } from 'picocode-core/tools/index.js'
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
Model access goes through [@prsm/ai](https://github.com/prsmjs/ai). The package is plain ESM and requires Node 24 or newer.
|
|
15
|
+
Model access goes through [@prsm/ai](https://github.com/prsmjs/ai), except for models whose provider has a turn engine (`engines.js`): Claude Code models (`claude-code/*`) run through the local `claude` command on the user's Claude subscription; see `src/claude-code/README.md`. The package is plain ESM and requires Node 24 or newer.
|
package/package.json
CHANGED
package/src/agents.js
CHANGED
|
@@ -31,6 +31,7 @@ function restoredAgent(data, at) {
|
|
|
31
31
|
error: null,
|
|
32
32
|
usage: null,
|
|
33
33
|
options: data,
|
|
34
|
+
external: !!data.external,
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
|
|
@@ -156,6 +157,66 @@ export function createAgentManager({ run, concurrency = 8, onChange = () => {},
|
|
|
156
157
|
return agent
|
|
157
158
|
}
|
|
158
159
|
|
|
160
|
+
// an agent another runtime runs, such as a Claude Code subagent: listed,
|
|
161
|
+
// recorded and shown like pico's own, but fed and finished from outside
|
|
162
|
+
function track(options) {
|
|
163
|
+
const id = String(nextId++)
|
|
164
|
+
let resolve
|
|
165
|
+
const done = new Promise((r) => { resolve = r })
|
|
166
|
+
const at = Date.now()
|
|
167
|
+
const agent = {
|
|
168
|
+
id,
|
|
169
|
+
description: options.description || options.prompt?.slice(0, 80) || `agent ${id}`,
|
|
170
|
+
prompt: options.prompt || '',
|
|
171
|
+
model: options.model || null,
|
|
172
|
+
role: 'worker',
|
|
173
|
+
parentId: null,
|
|
174
|
+
sessionId: options.sessionId || null,
|
|
175
|
+
sessionFile: options.sessionFile || null,
|
|
176
|
+
tools: [],
|
|
177
|
+
status: 'running',
|
|
178
|
+
createdAt: at,
|
|
179
|
+
updatedAt: at,
|
|
180
|
+
startedAt: at,
|
|
181
|
+
endedAt: null,
|
|
182
|
+
events: [],
|
|
183
|
+
result: '',
|
|
184
|
+
error: null,
|
|
185
|
+
usage: null,
|
|
186
|
+
controller: new AbortController(),
|
|
187
|
+
resolve,
|
|
188
|
+
done,
|
|
189
|
+
options,
|
|
190
|
+
external: true,
|
|
191
|
+
generation,
|
|
192
|
+
}
|
|
193
|
+
agents.set(id, agent)
|
|
194
|
+
onCreate(agent)
|
|
195
|
+
changed()
|
|
196
|
+
const live = () => agent.generation === generation && agent.status === 'running'
|
|
197
|
+
return {
|
|
198
|
+
id,
|
|
199
|
+
event(event) {
|
|
200
|
+
if (!live()) return
|
|
201
|
+
agent.events.push(event)
|
|
202
|
+
if (event.type === 'usage') agent.usage = event.usage
|
|
203
|
+
agent.updatedAt = Date.now()
|
|
204
|
+
onEvent(agent, event)
|
|
205
|
+
changed()
|
|
206
|
+
},
|
|
207
|
+
finish({ result = '', error = null, interrupted = false } = {}) {
|
|
208
|
+
if (!live()) return
|
|
209
|
+
agent.result = result
|
|
210
|
+
agent.error = error
|
|
211
|
+
agent.status = error ? 'failed' : interrupted ? 'cancelled' : 'completed'
|
|
212
|
+
agent.endedAt = Date.now()
|
|
213
|
+
onFinish(agent)
|
|
214
|
+
changed()
|
|
215
|
+
resolve(agent)
|
|
216
|
+
},
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
159
220
|
function restore(events) {
|
|
160
221
|
generation++
|
|
161
222
|
for (const agent of agents.values()) {
|
|
@@ -176,6 +237,7 @@ export function createAgentManager({ run, concurrency = 8, onChange = () => {},
|
|
|
176
237
|
|
|
177
238
|
return {
|
|
178
239
|
start,
|
|
240
|
+
track,
|
|
179
241
|
restore,
|
|
180
242
|
clear: () => restore([]),
|
|
181
243
|
get: (id) => agents.get(String(id)) || null,
|
|
@@ -196,7 +258,8 @@ export function createAgentManager({ run, concurrency = 8, onChange = () => {},
|
|
|
196
258
|
},
|
|
197
259
|
cancel(id) {
|
|
198
260
|
const agent = agents.get(String(id))
|
|
199
|
-
|
|
261
|
+
// an external agent stops only with whatever runs it
|
|
262
|
+
if (!agent || agent.external || ['completed', 'failed', 'cancelled'].includes(agent.status)) return false
|
|
200
263
|
if (agent.status === 'queued') {
|
|
201
264
|
agent.status = 'cancelled'
|
|
202
265
|
agent.endedAt = Date.now()
|