refactor(agent)!: migrate to Pi Durable and embed the agent queue (#525)

* refactor(agent)!: migrate sessions to Pi Durable

Replace patched AgentHarness storage with per-session SQLite and PostgreSQL commit mirroring. Migrate legacy history automatically and run agent queues with the main server.

BREAKING CHANGE: Remove standalone agent workers and return native Pi entry records from chat history APIs.

* fix(agent): constrain session log dialog scrolling

Keep the header visible and wrap long output while log entries and expanded records scroll within the dialog. Cover desktop and narrow viewports through the dashboard Sessions flow.

* fix(agent): hide entry IDs from session log card headers

Retain internal entry IDs in expanded raw records for debugging. Verify that card headers omit the IDs while raw JSON preserves them.

* test(e2e): handle browser wheel limits in session log checks

Verify that a normal wheel event moves the viewport before explicitly scrolling to the final record. Keep the dialog bounds, fixed header, wrapping, and expanded-record assertions.

* fix(agent): select model providers without inheriting unrelated auth

* fix(webui): prevent resize feedback when toggling agent panel

* test(agent): reproduce concurrent comment session races

* fix(agent): serialize comment sessions and deduplicate history

* docs(changelog): consolidate Pi Durable changes into one entry
This commit is contained in:
Yiling-J
2026-11-11 16:05:18 +08:00
committed by GitHub
parent 843a56304c
commit 35a0e82284
120 changed files with 7593 additions and 5972 deletions
+13 -10
View File
@@ -7,12 +7,15 @@
* server(list) > status.
*/
import { Type } from '@sinclair/typebox'
import type { AgentTool, AgentToolResult } from '@earendil-works/pi-agent-core'
import type {
ToolRegistration as AgentTool,
ToolExecutionResult as AgentToolResult,
} from '@earendil-works/pi-durable'
import { Type } from 'typebox'
import type { McpToolRegistry, ToolMetadata } from './mcp-tool-registry'
import { formatSchema } from './mcp-tool-schema'
type ProxyToolResult = AgentToolResult<Record<string, unknown>>
type ProxyToolResult = AgentToolResult
/** Truncated instructions head baked into the proxy tool description (L1). */
const INSTRUCTIONS_SNIPPET_LENGTH = 150
@@ -45,7 +48,7 @@ export type ConnectionOutcome =
export interface CallToolOutcome {
ok: boolean
content: AgentToolResult<Record<string, unknown>>['content']
content: NonNullable<AgentToolResult['output']>
}
export interface McpProxyToolContext {
@@ -167,7 +170,7 @@ function parseArgs(raw: unknown): Record<string, unknown> {
}
function contentText(text: string): ProxyToolResult {
return { content: [{ type: 'text', text }], details: {} }
return { output: [{ type: 'text', text }], details: {} }
}
/** Transform MCP content blocks into model content blocks. */
@@ -181,7 +184,7 @@ export function transformMcpContent(
uri?: string
name?: string
}>,
): AgentToolResult<Record<string, unknown>>['content'] {
): NonNullable<AgentToolResult['output']> {
return content.map((c) => {
if (c.type === 'text') {
return { type: 'text', text: c.text ?? '' }
@@ -331,10 +334,10 @@ function renderServerListing(
export function buildProxyTool(ctx: McpProxyToolContext): AgentTool<typeof proxyToolSchema> {
return {
name: 'mcp',
label: 'MCP Tools',
description: buildProxyDescription(ctx.servers),
parameters: proxyToolSchema,
execute: async (_toolCallId, params): Promise<ProxyToolResult> => {
execute: async (params): Promise<ProxyToolResult> => {
const action = params.action
const server = params.server
const tool = params.tool
@@ -396,10 +399,10 @@ export function buildProxyTool(ctx: McpProxyToolContext): AgentTool<typeof proxy
parseArgs(params.args),
)
if (outcome.ok) {
return { content: outcome.content, details: {} }
return { output: outcome.content, details: {} }
}
return {
content: outcome.content,
output: outcome.content,
details: { error: 'tool_call_failed', tool, server: resolved.serverId },
}
}