Migrate to Pi Coding Agent SDK for multi-provider LLM support

Replace the custom Pi API fetch client with the @earendil-works/pi-coding-agent
SDK, enabling support for multiple LLM providers (Anthropic, OpenAI, DeepSeek,
Google Gemini, xAI/ZAI) while maintaining backward compatibility.

Key changes:
- Add piSdk.ts with SDK session management and provider auto-detection
- Refactor client.ts to delegate to SDK adapter, keeping public API surface
- Update documentation to reflect multi-provider environment variables
- Add RPC contracts for LLM model selection and provider configuration
- Update agent runner to support provider-specific tools and parameters

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-15 00:17:26 -04:00
parent 506d092b2b
commit 0624026af3
30 changed files with 4326 additions and 354 deletions

View File

@@ -204,6 +204,8 @@ export type RpcRequestMap = {
"earnings.getSchedule": { companyId: string };
"filing.list": { companyId: string; since?: string };
"model.get": { companyId: string; tab: string };
"model.list": undefined;
"model.set": { provider: string; modelId: string; thinkingLevel?: "off" | "minimal" | "low" | "medium" | "high" };
"model.updateCell": { companyId: string; tab: string; row: number; col: number; value: string };
"model.createRow": { companyId: string; tab: string; label: string; kind: "actual" | "forecast" | "total"; values?: string[] };
"model.deleteRow": { companyId: string; tab: string; row: number };
@@ -267,6 +269,8 @@ export type RpcResponseMap = {
"earnings.getSchedule": { schedule: EarningsSchedule[] };
"filing.list": { filings: Filing[] };
"model.get": { headers: string[]; rows: ModelRow[] };
"model.list": { models: Array<{ provider: string; modelId: string; name: string; available: boolean }> };
"model.set": { ok: boolean; provider: string; modelId: string };
"model.updateCell": { ok: boolean; affectedCells: string[] };
"model.createRow": { row: ModelRow; position: number };
"model.deleteRow": { ok: boolean };

View File

@@ -40,6 +40,11 @@ export const ServerSettingsSchema = z.object({
agentConfigs: z.record(z.unknown()),
dataSources: z.record(z.boolean()),
exportPipelines: z.record(z.unknown()),
llm: z.object({
provider: z.string().optional(),
modelId: z.string().optional(),
thinkingLevel: z.enum(["off", "minimal", "low", "medium", "high"]).optional(),
}).optional(),
});
const RiskInputSchema = RiskSchema.omit({ id: true, companyId: true });
@@ -65,6 +70,8 @@ export const RpcRequestSchemas = {
"earnings.getSchedule": z.object({ companyId: idString }),
"filing.list": z.object({ companyId: idString, since: z.string().optional() }),
"model.get": z.object({ companyId: idString, tab: nonEmptyString }),
"model.list": z.undefined(),
"model.set": z.object({ provider: nonEmptyString, modelId: nonEmptyString, thinkingLevel: z.enum(["off", "minimal", "low", "medium", "high"]).optional() }),
"model.updateCell": z.object({
companyId: idString,
tab: nonEmptyString,
@@ -158,6 +165,8 @@ export const RpcResponseSchemas = {
"earnings.getSchedule": z.object({ schedule: z.array(EarningsScheduleSchema) }),
"filing.list": z.object({ filings: z.array(FilingSchema) }),
"model.get": z.object({ headers: z.array(z.string()), rows: z.array(ModelRowSchema) }),
"model.list": z.object({ models: z.array(z.object({ provider: z.string(), modelId: z.string(), name: z.string(), available: z.boolean() })) }),
"model.set": z.object({ ok: z.boolean(), provider: z.string(), modelId: z.string() }),
"model.updateCell": z.object({ ok: z.boolean(), affectedCells: z.array(z.string()) }),
"model.createRow": z.object({ row: ModelRowSchema, position: z.number().int().min(0) }),
"model.deleteRow": z.object({ ok: z.boolean() }),