|
@@ -3,6 +3,7 @@ import type { DatabaseSync } from 'node:sqlite'
|
|
|
import {
|
|
import {
|
|
|
CHAT_TRANSCRIPT_FEATURE,
|
|
CHAT_TRANSCRIPT_FEATURE,
|
|
|
type TranscriptEvent,
|
|
type TranscriptEvent,
|
|
|
|
|
+ type TranscriptControlState,
|
|
|
type TranscriptMessage,
|
|
type TranscriptMessage,
|
|
|
type TranscriptSnapshot,
|
|
type TranscriptSnapshot,
|
|
|
} from '../shared/chatTranscript.js'
|
|
} from '../shared/chatTranscript.js'
|
|
@@ -32,7 +33,7 @@ interface TurnHead {
|
|
|
}
|
|
}
|
|
|
const emptyHead = (): TurnHead => ({ running: false, queued: false, queue: [], tools: {}, pending: {} })
|
|
const emptyHead = (): TurnHead => ({ running: false, queued: false, queue: [], tools: {}, pending: {} })
|
|
|
const text = (p: Data): string => String(p.output ?? p.text ?? p.content ?? '')
|
|
const text = (p: Data): string => String(p.output ?? p.text ?? p.content ?? '')
|
|
|
-const controlState = (head: TurnHead) => ({
|
|
|
|
|
|
|
+const controlState = (head: TurnHead): TranscriptControlState => ({
|
|
|
running: head.running,
|
|
running: head.running,
|
|
|
queued: head.queued,
|
|
queued: head.queued,
|
|
|
pendingApproval: head.pendingApproval ?? null,
|
|
pendingApproval: head.pendingApproval ?? null,
|
|
@@ -309,6 +310,9 @@ export class ChatTranscriptStore {
|
|
|
.get(...scope)
|
|
.get(...scope)
|
|
|
return row ? JSON.parse(String(row.data)) : emptyHead()
|
|
return row ? JSON.parse(String(row.data)) : emptyHead()
|
|
|
}
|
|
}
|
|
|
|
|
+ control(...scope: Scope): TranscriptControlState {
|
|
|
|
|
+ return controlState(this.head(...scope))
|
|
|
|
|
+ }
|
|
|
message(owner: string, profile: string, sessionId: string, id: string): TranscriptMessage | undefined {
|
|
message(owner: string, profile: string, sessionId: string, id: string): TranscriptMessage | undefined {
|
|
|
const row = this.db
|
|
const row = this.db
|
|
|
.prepare(
|
|
.prepare(
|
|
@@ -1051,7 +1055,7 @@ export class ChatTranscriptStore {
|
|
|
before = Number.MAX_SAFE_INTEGER,
|
|
before = Number.MAX_SAFE_INTEGER,
|
|
|
limit = 150,
|
|
limit = 150,
|
|
|
): TranscriptSnapshot {
|
|
): TranscriptSnapshot {
|
|
|
- const run = this.head(owner, profile, sessionId)
|
|
|
|
|
|
|
+ const run = this.control(owner, profile, sessionId)
|
|
|
const coverage = this.db
|
|
const coverage = this.db
|
|
|
.prepare(
|
|
.prepare(
|
|
|
'SELECT complete,message_total FROM chat_sessions WHERE owner=? AND profile=? AND session_id=?',
|
|
'SELECT complete,message_total FROM chat_sessions WHERE owner=? AND profile=? AND session_id=?',
|