picocode-core 0.9.142 → 0.9.144
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/agent-transcript.js +8 -0
- package/src/controller.js +28 -4
- package/src/wakeups.js +4 -3
package/package.json
CHANGED
package/src/agent-transcript.js
CHANGED
|
@@ -65,8 +65,16 @@ function deliberationTranscript(agent) {
|
|
|
65
65
|
}
|
|
66
66
|
if (event.type === 'tool_complete' || event.type === 'tool_error') settleTool(tools, event)
|
|
67
67
|
}
|
|
68
|
+
// whoever is speaking right now shows their words as they arrive
|
|
69
|
+
const live = agent.live
|
|
70
|
+
if (live?.text && live.role !== 'synthesis') {
|
|
71
|
+
const turn = turnFor(live.role, live.round)
|
|
72
|
+
if (turn.text == null) turn.text = live.text
|
|
73
|
+
}
|
|
68
74
|
if (agent.result) {
|
|
69
75
|
items.push({ kind: 'deliberation-turn', role: 'synthesis', text: agent.result, tools: [], interrupted: agent.status === 'cancelled' })
|
|
76
|
+
} else if (live?.text && live.role === 'synthesis') {
|
|
77
|
+
items.push({ kind: 'deliberation-turn', role: 'synthesis', text: live.text, tools: [], active: true })
|
|
70
78
|
} else if (agent.error) {
|
|
71
79
|
items.push({ kind: 'assistant', text: agent.error, interrupted: true })
|
|
72
80
|
}
|
package/src/controller.js
CHANGED
|
@@ -225,6 +225,10 @@ export function createController({ boot }) {
|
|
|
225
225
|
},
|
|
226
226
|
})
|
|
227
227
|
|
|
228
|
+
// a running deliberation's current speaker streams into this buffer; it
|
|
229
|
+
// is never persisted, the turn event carries the settled text
|
|
230
|
+
const liveDeliberations = new Map()
|
|
231
|
+
|
|
228
232
|
const deliberations = {
|
|
229
233
|
run: async ({ brief, rounds, signal }) => {
|
|
230
234
|
const options = validateDeliberation({ brief, rounds })
|
|
@@ -240,6 +244,18 @@ export function createController({ boot }) {
|
|
|
240
244
|
if (!sessionId) throw new Error('deliberation requires an active session')
|
|
241
245
|
persist(makeEvent('deliberation_start', { deliberationId: id, brief, rounds, model: modelName }))
|
|
242
246
|
bumpActivity()
|
|
247
|
+
const live = { role: null, round: null, text: '' }
|
|
248
|
+
liveDeliberations.set(id, live)
|
|
249
|
+
const speak = (role, round) => (event) => {
|
|
250
|
+
if (event.type === 'content') {
|
|
251
|
+
if (live.role !== role || live.round !== round) Object.assign(live, { role, round, text: '' })
|
|
252
|
+
live.text += event.content
|
|
253
|
+
bumpActivity()
|
|
254
|
+
} else if (event.type === 'tool_calls_ready' && live.text) {
|
|
255
|
+
live.text = ''
|
|
256
|
+
bumpActivity()
|
|
257
|
+
}
|
|
258
|
+
}
|
|
243
259
|
|
|
244
260
|
const persistDeliberation = (event) => {
|
|
245
261
|
persist(event)
|
|
@@ -281,14 +297,18 @@ export function createController({ boot }) {
|
|
|
281
297
|
history,
|
|
282
298
|
role,
|
|
283
299
|
onStream: (event) => {
|
|
300
|
+
speak(role, round)(event)
|
|
284
301
|
if (['tool_executing', 'tool_complete', 'tool_error'].includes(event.type)) {
|
|
285
302
|
persistDeliberation(makeEvent('deliberation_event', { deliberationId: id, role, round, event }))
|
|
286
303
|
}
|
|
287
304
|
},
|
|
288
305
|
}),
|
|
289
|
-
runSynthesis: ({ history }) => runWorker({ history, role: 'synthesizer', tools: false }),
|
|
290
|
-
onEvent: (event) =>
|
|
291
|
-
|
|
306
|
+
runSynthesis: ({ history }) => runWorker({ history, role: 'synthesizer', tools: false, onStream: speak('synthesis', null) }),
|
|
307
|
+
onEvent: (event) => {
|
|
308
|
+
Object.assign(live, { role: null, round: null, text: '' })
|
|
309
|
+
persistDeliberation(makeEvent('deliberation_turn', { deliberationId: id, ...event }))
|
|
310
|
+
},
|
|
311
|
+
}).finally(() => liveDeliberations.delete(id))
|
|
292
312
|
persistDeliberation(makeEvent('deliberation_result', { deliberationId: id, result: result.result, usage: result.usage, interrupted: result.interrupted, error: result.error }))
|
|
293
313
|
if (result.error) throw new Error(result.error)
|
|
294
314
|
return {
|
|
@@ -1218,7 +1238,11 @@ export function createController({ boot }) {
|
|
|
1218
1238
|
}
|
|
1219
1239
|
|
|
1220
1240
|
function activity() {
|
|
1221
|
-
const
|
|
1241
|
+
const withLive = (item) => {
|
|
1242
|
+
const live = liveDeliberations.get(item.deliberationId)
|
|
1243
|
+
return live?.role ? { ...item, live: { ...live } } : item
|
|
1244
|
+
}
|
|
1245
|
+
const rows = [...agents.list(), ...deliberationsFromEvents(state.events).map(withLive)]
|
|
1222
1246
|
return rows.sort((a, b) => (b.startedAt || 0) - (a.startedAt || 0))
|
|
1223
1247
|
}
|
|
1224
1248
|
|
package/src/wakeups.js
CHANGED
|
@@ -6,13 +6,14 @@ export function createWakeupManager({ onFire = () => {}, onChange = () => {} } =
|
|
|
6
6
|
schedule(delaySeconds, note) {
|
|
7
7
|
const seconds = Math.max(5, Math.round(delaySeconds))
|
|
8
8
|
const id = String(nextId++)
|
|
9
|
-
const
|
|
9
|
+
const scheduledAt = Date.now()
|
|
10
|
+
const at = scheduledAt + seconds * 1000
|
|
10
11
|
const timer = setTimeout(() => {
|
|
11
12
|
wakeups.delete(id)
|
|
12
13
|
onChange()
|
|
13
14
|
onFire({ id, note, at })
|
|
14
15
|
}, seconds * 1000)
|
|
15
|
-
wakeups.set(id, { id, note, at, timer })
|
|
16
|
+
wakeups.set(id, { id, note, at, scheduledAt, timer })
|
|
16
17
|
onChange()
|
|
17
18
|
return { id, at, seconds }
|
|
18
19
|
},
|
|
@@ -26,7 +27,7 @@ export function createWakeupManager({ onFire = () => {}, onChange = () => {} } =
|
|
|
26
27
|
},
|
|
27
28
|
list() {
|
|
28
29
|
return [...wakeups.values()]
|
|
29
|
-
.map(({ id, note, at }) => ({ id, note, at }))
|
|
30
|
+
.map(({ id, note, at, scheduledAt }) => ({ id, note, at, scheduledAt }))
|
|
30
31
|
.sort((a, b) => a.at - b.at)
|
|
31
32
|
},
|
|
32
33
|
pending() {
|