mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
dea06c391c
* Improve the web launcher and gateway integration across backend and frontend. - add runtime model availability checks for local and OAuth-backed models - support launcher-driven gateway host overrides and websocket URL resolution - add gateway log clearing and keep incremental log sync consistent after resets - migrate session history APIs to JSONL metadata-backed storage with legacy fallback - expose session titles and improve chat history loading and error handling - move shared backend runtime helpers into the web utils package - avoid blocking web startup when automatic onboard initialization fails - add backend tests covering gateway readiness, host resolution, models, logs, and sessions * feat(agent): add skills and tools management APIs and UI - add backend APIs to list, view, import, and delete skills - add tool status and toggle endpoints with dependency-aware config updates - add agent skills/tools pages, routes, sidebar entries, and i18n strings - add backend tests for the new skills and tools flows * chore(frontend): upgrade shadcn to 4.0.5 and refresh lockfile * chore(web): keep backend dist placeholder tracked
52 lines
1.2 KiB
TypeScript
52 lines
1.2 KiB
TypeScript
// Sessions API — list and retrieve chat session history
|
|
|
|
export interface SessionSummary {
|
|
id: string
|
|
title: string
|
|
preview: string
|
|
message_count: number
|
|
created: string
|
|
updated: string
|
|
}
|
|
|
|
export interface SessionDetail {
|
|
id: string
|
|
messages: { role: "user" | "assistant"; content: string }[]
|
|
summary: string
|
|
created: string
|
|
updated: string
|
|
}
|
|
|
|
export async function getSessions(
|
|
offset: number = 0,
|
|
limit: number = 20,
|
|
): Promise<SessionSummary[]> {
|
|
const params = new URLSearchParams({
|
|
offset: offset.toString(),
|
|
limit: limit.toString(),
|
|
})
|
|
|
|
const res = await fetch(`/api/sessions?${params.toString()}`)
|
|
if (!res.ok) {
|
|
throw new Error(`Failed to fetch sessions: ${res.status}`)
|
|
}
|
|
return res.json()
|
|
}
|
|
|
|
export async function getSessionHistory(id: string): Promise<SessionDetail> {
|
|
const res = await fetch(`/api/sessions/${encodeURIComponent(id)}`)
|
|
if (!res.ok) {
|
|
throw new Error(`Failed to fetch session ${id}: ${res.status}`)
|
|
}
|
|
return res.json()
|
|
}
|
|
|
|
export async function deleteSession(id: string): Promise<void> {
|
|
const res = await fetch(`/api/sessions/${encodeURIComponent(id)}`, {
|
|
method: "DELETE",
|
|
})
|
|
if (!res.ok) {
|
|
throw new Error(`Failed to delete session ${id}: ${res.status}`)
|
|
}
|
|
}
|