Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
feat(agent): add reasoning mode types and thinking extraction
yushen77d5702f80e9
diff --git a/src/agent/extract-text.ts b/src/agent/extract-text.tsindex 145a2c971a..8075e61ffd 100644--- a/src/agent/extract-text.ts+++ b/src/agent/extract-text.ts@@ -10,3 +10,14 @@ export function extractText(message: AgentMessage | undefined): string {.map((c) => c.text ?? "").join("");}++/** Extract thinking/reasoning content from an AgentMessage */+export function extractThinking(message: AgentMessage | undefined): string {+ if (!message || typeof message !== "object" || !("content" in message)) return "";+ const content = (message as { content?: Array<{ type: string; thinking?: string }> }).content;+ if (!Array.isArray(content)) return "";+ return content+ .filter((c) => c.type === "thinking")+ .map((c) => c.thinking ?? "")+ .join("");+}diff --git a/src/agent/profile/types.ts b/src/agent/profile/types.tsindex f1de243d4d..f03f7d11e2 100644--- a/src/agent/profile/types.ts+++ b/src/agent/profile/types.ts@@ -37,6 +37,8 @@ export interface ProfileConfig {model?: string;/** Default thinking level */thinkingLevel?: string;+ /** Reasoning mode: off, on, stream */+ reasoningMode?: "off" | "on" | "stream" | undefined;}/** Agent Profile configuration */diff --git a/src/agent/session/types.ts b/src/agent/session/types.tsindex c9086b74ee..72c810ab9e 100644--- a/src/agent/session/types.ts+++ b/src/agent/session/types.ts@@ -4,6 +4,8 @@ export type SessionMeta = {provider?: string;model?: string;thinkingLevel?: string;+ /** Reasoning mode: off, on, stream */+ reasoningMode?: string;/** Context window token 数 */contextWindowTokens?: number;};diff --git a/src/agent/types.ts b/src/agent/types.tsindex c7e3765811..6f7b7806d6 100644--- a/src/agent/types.ts+++ b/src/agent/types.ts@@ -2,8 +2,13 @@ import type { ThinkingLevel } from "@mariozechner/pi-agent-core";import type { SkillsConfig } from "./skills/types.js";import type { ToolsConfig } from "./tools/policy.js";+/** Controls how reasoning/thinking content blocks are handled */+export type ReasoningMode = "off" | "on" | "stream";+export type AgentRunResult = {text: string;+ /** Extracted thinking/reasoning content (when reasoningMode !== "off") */+ thinking?: string | undefined;error?: string | undefined;};@@ -28,6 +33,8 @@ export type AgentOptions = {/** System prompt, if profileId is set will auto-construct from profile */systemPrompt?: string | undefined;thinkingLevel?: ThinkingLevel | undefined;+ /** Controls how reasoning/thinking content is displayed: off, on, stream (default: stream) */+ reasoningMode?: ReasoningMode | undefined;/** Command execution directory */cwd?: string | undefined;sessionId?: string | undefined;