From 86d064e10cd064f42bc38a206e6dec892320cc9f Mon Sep 17 00:00:00 2001 From: seekskyworld Date: Fri, 4 Sep 2026 16:20:45 +0800 Subject: [PATCH] feat(web): expose Pi thinking state Signed-off-by: seekskyworld --- web/host/web-host.ts | 5 +++++ web/runtime/pi-runtime.ts | 5 +++++ web/runtime/types.ts | 1 + 3 files changed, 11 insertions(+) diff --git a/web/host/web-host.ts b/web/host/web-host.ts index 6203e647..11a5f6f4 100644 --- a/web/host/web-host.ts +++ b/web/host/web-host.ts @@ -557,6 +557,11 @@ export class WebHost { } if (url.pathname === "/api/models") return this.json(response, 200, { models: this.runtime.listModels() }); + if (url.pathname === "/api/thinking") + return this.json(response, 200, { + sessionId: this.runtime.sessionManager.getSessionId(), + ...(this.runtime.getThinkingState?.() ?? { level: "unknown", available: [] }), + }); if (url.pathname === "/api/snapshot") { const cursor = this.sequence; const projection = await this.adapter.getSnapshot( diff --git a/web/runtime/pi-runtime.ts b/web/runtime/pi-runtime.ts index cf792d39..c29d0cdc 100644 --- a/web/runtime/pi-runtime.ts +++ b/web/runtime/pi-runtime.ts @@ -265,6 +265,11 @@ export class PiWebRuntime implements WebRuntimeController { return () => this.listeners.delete(listener); } + getThinkingState() { + const session = this.runtime.session; + return { level: session.thinkingLevel, available: session.getAvailableThinkingLevels() }; + } + async sendPrompt(content: string, options?: WebPromptOptions) { this.assertActive(); this.assertWorkspaceSelected(); diff --git a/web/runtime/types.ts b/web/runtime/types.ts index 2b66c3f0..f464e178 100644 --- a/web/runtime/types.ts +++ b/web/runtime/types.ts @@ -61,6 +61,7 @@ export interface WebRuntimeController { ): Promise; switchSession(sessionPath: string): Promise<{ cancelled: boolean }>; listModels(): WebModelSummary[]; + getThinkingState?(): { level: string; available: readonly string[] }; setModel( provider: string, modelId: string,