picocode-core 0.9.194 → 0.9.195
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/controller.js +4 -10
- package/src/derive.js +10 -2
- package/src/stream-transcript.js +0 -9
package/package.json
CHANGED
package/src/controller.js
CHANGED
|
@@ -11,7 +11,6 @@ import { appendPrompt } from './history.js'
|
|
|
11
11
|
import { runTurn, summarizeText, compactHistory, compactProgress } from './agent.js'
|
|
12
12
|
import { createAgentManager } from './agents.js'
|
|
13
13
|
import { createPeers } from './peers.js'
|
|
14
|
-
import { streamTranscript } from './stream-transcript.js'
|
|
15
14
|
import { runDeliberation, validateDeliberation } from './deliberation.js'
|
|
16
15
|
import { deliberationsFromEvents } from './deliberation-history.js'
|
|
17
16
|
import { compactionPrompt, formatCompactSummary, summarySections, compactionKeepFrom } from './compaction.js'
|
|
@@ -205,11 +204,11 @@ export function createController({ boot, run = runTurn, peerDirectory } = {}) {
|
|
|
205
204
|
state.events.push(event)
|
|
206
205
|
state.persisted = state.events.length
|
|
207
206
|
reDerive()
|
|
208
|
-
if (state.busy && !state.compacting) {
|
|
207
|
+
if (state.busy && !state.compacting && direction === 'outgoing') {
|
|
209
208
|
const items = [...state.overlay]
|
|
210
|
-
|
|
209
|
+
flushStream(items)
|
|
211
210
|
const item = state.derived.transcript.findLast((item) => item.kind === 'peer' && item.messageId === message.id)
|
|
212
|
-
items.push(
|
|
211
|
+
items.push(item)
|
|
213
212
|
set({ overlay: items })
|
|
214
213
|
}
|
|
215
214
|
})()
|
|
@@ -302,10 +301,6 @@ export function createController({ boot, run = runTurn, peerDirectory } = {}) {
|
|
|
302
301
|
|
|
303
302
|
function reDerive() {
|
|
304
303
|
state.derived = deriveState(state.events)
|
|
305
|
-
const peerItems = new Map(state.derived.transcript.filter(item => item.kind === 'peer').map(item => [item.messageId, item]))
|
|
306
|
-
state.overlay = state.overlay.map(item => item.kind === 'peer' && item.direction === 'incoming'
|
|
307
|
-
? { ...item, read: peerItems.get(item.messageId)?.read ?? item.read }
|
|
308
|
-
: item)
|
|
309
304
|
emit('derived', state.derived)
|
|
310
305
|
changed()
|
|
311
306
|
}
|
|
@@ -545,8 +540,7 @@ export function createController({ boot, run = runTurn, peerDirectory } = {}) {
|
|
|
545
540
|
}
|
|
546
541
|
|
|
547
542
|
function flushStream(items) {
|
|
548
|
-
|
|
549
|
-
items.splice(0, items.length, ...flushed)
|
|
543
|
+
if (state.streaming) items.push({ kind: 'assistant', text: state.streaming })
|
|
550
544
|
state.streaming = null
|
|
551
545
|
}
|
|
552
546
|
|
package/src/derive.js
CHANGED
|
@@ -150,7 +150,11 @@ function flushConsumedPeers(state) {
|
|
|
150
150
|
if (state.openToolCalls.size) return
|
|
151
151
|
for (const { peer, eventId } of state.deferredConsumedPeers.splice(0)) {
|
|
152
152
|
const entry = state.peerMessages.get(peer.id)
|
|
153
|
-
if (entry?.item)
|
|
153
|
+
if (entry?.item) {
|
|
154
|
+
entry.item.read = true
|
|
155
|
+
state.transcript = state.transcript.filter(item => item !== entry.item)
|
|
156
|
+
state.transcript.push(entry.item)
|
|
157
|
+
}
|
|
154
158
|
pushHistory(state, peerInputMessage(peer), eventId)
|
|
155
159
|
}
|
|
156
160
|
}
|
|
@@ -281,9 +285,10 @@ export function deriveState(events) {
|
|
|
281
285
|
const restored = { ...item, eventId: event.id, at: item.at ?? event.at ?? null }
|
|
282
286
|
if (restored.kind === 'peer') {
|
|
283
287
|
const entry = state.peerMessages.get(restored.messageId)
|
|
288
|
+
if (entry?.peer.direction === 'incoming') continue
|
|
284
289
|
if (entry?.item) {
|
|
285
290
|
state.transcript = state.transcript.filter((candidate) => candidate !== entry.item)
|
|
286
|
-
Object.assign(restored, { status: entry.item.status, error: entry.item.error
|
|
291
|
+
Object.assign(restored, { status: entry.item.status, error: entry.item.error })
|
|
287
292
|
entry.item = restored
|
|
288
293
|
}
|
|
289
294
|
}
|
|
@@ -399,6 +404,9 @@ export function deriveState(events) {
|
|
|
399
404
|
state.pendingPeerMessages = [...state.peerMessages.values()]
|
|
400
405
|
.filter(({ peer }) => peer.direction === 'incoming' && !consumedPeerIds.has(peer.id))
|
|
401
406
|
.map(({ peer }) => peer)
|
|
407
|
+
const unread = state.transcript.filter(item => item.kind === 'peer' && item.direction === 'incoming' && !item.read)
|
|
408
|
+
const unreadItems = new Set(unread)
|
|
409
|
+
state.transcript = [...state.transcript.filter(item => !unreadItems.has(item)), ...unread]
|
|
402
410
|
state.estimatedPromptTokens = contextEdited && measuredBaseline
|
|
403
411
|
? Math.max(0, measuredBaseline.tokens + historyTokens() - measuredBaseline.history)
|
|
404
412
|
: null
|
package/src/stream-transcript.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export function streamTranscript(items, text) {
|
|
2
|
-
const boundary = items.findIndex(item => item.streamPending)
|
|
3
|
-
const index = boundary < 0 ? items.length : boundary
|
|
4
|
-
return [
|
|
5
|
-
...items.slice(0, index),
|
|
6
|
-
...(text ? [{ kind: 'assistant', text }] : []),
|
|
7
|
-
...items.slice(index).map(({ streamPending, ...item }) => item),
|
|
8
|
-
]
|
|
9
|
-
}
|