feat(agent): update pi packages to 0.82.1 and implement new SessionStorage interface methods

This commit is contained in:
yiling
2026-08-03 10:25:10 +08:00
parent 16d136b45a
commit dbe3420b6c
10 changed files with 116 additions and 40 deletions
+8 -14
View File
@@ -95,8 +95,8 @@
"version": "0.3.2",
"dependencies": {
"@anthropic-ai/sandbox-runtime": "0.0.66",
"@earendil-works/pi-agent-core": "0.78.0",
"@earendil-works/pi-ai": "0.80.7",
"@earendil-works/pi-agent-core": "0.82.1",
"@earendil-works/pi-ai": "0.82.1",
"@google/genai": "1.52.0",
"@shumai/core": "workspace:*",
"@shumai/db": "workspace:*",
@@ -133,7 +133,7 @@
"name": "@shumai/core",
"version": "0.3.2",
"dependencies": {
"@earendil-works/pi-agent-core": "0.78.0",
"@earendil-works/pi-agent-core": "0.82.1",
"@earendil-works/pi-ai": "0.82.1",
"@shumai/db": "workspace:*",
"@shumai/dtos": "workspace:*",
@@ -165,7 +165,7 @@
"name": "@shumai/db",
"version": "0.3.2",
"dependencies": {
"@earendil-works/pi-agent-core": "0.78.0",
"@earendil-works/pi-agent-core": "0.82.1",
"@prisma/adapter-pg": "7.8.0",
"@prisma/client": "7.8.0",
"pg": "8.21.0",
@@ -181,7 +181,7 @@
"name": "@shumai/dtos",
"version": "0.3.2",
"dependencies": {
"@earendil-works/pi-agent-core": "0.78.0",
"@earendil-works/pi-agent-core": "0.82.1",
"zod": "4.4.3",
},
},
@@ -189,7 +189,7 @@
"name": "@shumai/e2e",
"version": "0.3.2",
"dependencies": {
"@earendil-works/pi-agent-core": "0.78.0",
"@earendil-works/pi-agent-core": "0.82.1",
"@google/genai": "1.52.0",
"@shumai/agent": "workspace:*",
"@shumai/core": "workspace:*",
@@ -465,9 +465,9 @@
"@dnd-kit/state": ["@dnd-kit/state@0.4.0", "", { "dependencies": { "@preact/signals-core": "^1.10.0", "tslib": "^2.6.2" } }, "sha512-vVdwOY9VsYdMNa7Z0xQhTXlzHqCcCugGuoM1kzvZhnZ0tYVPRdmIhWfeO6Y2ZoN92JwYAyJRRNl4ICkEe2mneg=="],
"@earendil-works/pi-agent-core": ["@earendil-works/pi-agent-core@0.78.0", "", { "dependencies": { "@earendil-works/pi-ai": "^0.78.0", "ignore": "7.0.5", "typebox": "1.1.38", "yaml": "2.9.0" } }, "sha512-xhWd59Qzd8yO88gYQw2S4dEQstJJEiUtxRP01//YzVJ61jCtUASMfcyAmYhgGYR4Onp7GmwEAbBBGOiV6Iwk9g=="],
"@earendil-works/pi-agent-core": ["@earendil-works/pi-agent-core@0.82.1", "", { "dependencies": { "@earendil-works/pi-ai": "^0.82.1", "diff": "8.0.4", "ignore": "7.0.5", "typebox": "1.1.38", "yaml": "2.9.0" } }, "sha512-Z3kloziJIE2dmrisRckZX8zDca/gIv9/YdFAzeoqpHiLV2wsni6bL4hInNSjVKLbqT+4kqLIkph2JQLKvSepjg=="],
"@earendil-works/pi-ai": ["@earendil-works/pi-ai@0.80.7", "", { "dependencies": { "@anthropic-ai/sdk": "0.91.1", "@aws-sdk/client-bedrock-runtime": "3.1048.0", "@google/genai": "1.52.0", "@mistralai/mistralai": "2.2.6", "@opentelemetry/api": "1.9.0", "@smithy/node-http-handler": "4.7.3", "http-proxy-agent": "7.0.2", "https-proxy-agent": "7.0.6", "openai": "6.26.0", "partial-json": "0.1.7", "typebox": "1.1.38" }, "bin": { "pi-ai": "dist/cli.js" } }, "sha512-8RLKLwe5TFM9kKFMNu/lTzveduq4GxZbnlG6ba8FAhLeb5wJP4zbj1eBumKBRvggpFQnW5R/Vo2a8zTlHsV9SQ=="],
"@earendil-works/pi-ai": ["@earendil-works/pi-ai@0.82.1", "", { "dependencies": { "@anthropic-ai/sdk": "0.91.1", "@aws-sdk/client-bedrock-runtime": "3.1048.0", "@google/genai": "1.52.0", "@mistralai/mistralai": "2.2.6", "@opentelemetry/api": "1.9.0", "@smithy/node-http-handler": "4.7.3", "http-proxy-agent": "7.0.2", "https-proxy-agent": "7.0.6", "openai": "6.26.0", "partial-json": "0.1.7", "typebox": "1.1.38" }, "bin": { "pi-ai": "dist/cli.js" } }, "sha512-3WFYRhEp3lQB3444EhPMBcM7zSaEUE3eJgHOR7s4081NLqbw/FsWilIKWXSua0Gv3sRr7m9xMidR3pPDE7jI/A=="],
"@electric-sql/pglite": ["@electric-sql/pglite@0.4.1", "", {}, "sha512-mZ9NzzUSYPOCnxHH1oAHPRzoMFJHY472raDKwXl/+6oPbpdJ7g8LsCN4FSaIIfkiCKHhb3iF/Zqo3NYxaIhU7Q=="],
@@ -2821,8 +2821,6 @@
"@aws-sdk/nested-clients/@smithy/node-http-handler": ["@smithy/node-http-handler@4.7.6", "", { "dependencies": { "@smithy/core": "^3.24.6", "@smithy/types": "^4.14.3", "tslib": "^2.6.2" } }, "sha512-3fya8i7GrJilQouk4cZJKdy5k8MWQBpjfXrRNaXDedH8r779tr0jcxyH3+yoTmsluc2+vF4S343yFbnvu8ExDQ=="],
"@earendil-works/pi-agent-core/@earendil-works/pi-ai": ["@earendil-works/pi-ai@0.78.0", "", { "dependencies": { "@anthropic-ai/sdk": "0.91.1", "@aws-sdk/client-bedrock-runtime": "3.1048.0", "@google/genai": "1.52.0", "@mistralai/mistralai": "2.2.1", "@smithy/node-http-handler": "4.7.3", "http-proxy-agent": "7.0.2", "https-proxy-agent": "7.0.6", "openai": "6.26.0", "partial-json": "0.1.7", "typebox": "1.1.38" }, "bin": { "pi-ai": "dist/cli.js" } }, "sha512-q0hUrvT6ngT6cgBX0oIbzfQfmzztgdkZobP8OTL+sCOOBlnG6+1YRt8g7zO9CC/4NdeYEqa7uGqWdQhH0fjCLA=="],
"@earendil-works/pi-agent-core/ignore": ["ignore@7.0.5", "", {}, "sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg=="],
"@eslint-community/eslint-utils/eslint-visitor-keys": ["eslint-visitor-keys@3.4.3", "", {}, "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag=="],
@@ -3039,8 +3037,6 @@
"@reduxjs/toolkit/immer": ["immer@11.1.8", "", {}, "sha512-/tbkHMW7y10Lx6i1crLjD4/OhNkRG+Fo7byZHtah0547nIeXYcpIXaUh0IAQY6gO5459qpGGYapcEOHtFXkIuA=="],
"@shumai/core/@earendil-works/pi-ai": ["@earendil-works/pi-ai@0.82.1", "", { "dependencies": { "@anthropic-ai/sdk": "0.91.1", "@aws-sdk/client-bedrock-runtime": "3.1048.0", "@google/genai": "1.52.0", "@mistralai/mistralai": "2.2.6", "@opentelemetry/api": "1.9.0", "@smithy/node-http-handler": "4.7.3", "http-proxy-agent": "7.0.2", "https-proxy-agent": "7.0.6", "openai": "6.26.0", "partial-json": "0.1.7", "typebox": "1.1.38" }, "bin": { "pi-ai": "dist/cli.js" } }, "sha512-3WFYRhEp3lQB3444EhPMBcM7zSaEUE3eJgHOR7s4081NLqbw/FsWilIKWXSua0Gv3sRr7m9xMidR3pPDE7jI/A=="],
"@tailwindcss/oxide-wasm32-wasi/@emnapi/core": ["@emnapi/core@1.10.0", "", { "dependencies": { "@emnapi/wasi-threads": "1.2.1", "tslib": "^2.4.0" }, "bundled": true }, "sha512-yq6OkJ4p82CAfPl0u9mQebQHKPJkY7WrIuk205cTYnYe+k2Z8YBh11FrbRG/H6ihirqcacOgl2BIO8oyMQLeXw=="],
"@tailwindcss/oxide-wasm32-wasi/@emnapi/runtime": ["@emnapi/runtime@1.10.0", "", { "dependencies": { "tslib": "^2.4.0" }, "bundled": true }, "sha512-ewvYlk86xUoGI0zQRNq/mC+16R1QeDlKQy21Ki3oSYXNgLb45GV1P6A0M+/s6nyCuNDqe5VpaY84BzXGwVbwFA=="],
@@ -3249,8 +3245,6 @@
"yauzl/buffer-crc32": ["buffer-crc32@0.2.13", "", {}, "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ=="],
"@earendil-works/pi-agent-core/@earendil-works/pi-ai/@mistralai/mistralai": ["@mistralai/mistralai@2.2.1", "", { "dependencies": { "ws": "^8.18.0", "zod": "^3.25.0 || ^4.0.0", "zod-to-json-schema": "^3.25.0" } }, "sha512-uKU8CZmL2RzYKmplsU01hii4p3pe4HqJefpWNRWXm1Tcm0Sm4xXfwSLIy4k7ZCPlbETCGcp69E7hZs+WOJ5itQ=="],
"@isaacs/cliui/string-width/emoji-regex": ["emoji-regex@9.2.2", "", {}, "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg=="],
"@isaacs/cliui/strip-ansi/ansi-regex": ["ansi-regex@6.2.2", "", {}, "sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg=="],
+2 -2
View File
@@ -7,8 +7,8 @@
"types": "./src/index.ts",
"dependencies": {
"@anthropic-ai/sandbox-runtime": "0.0.66",
"@earendil-works/pi-agent-core": "0.78.0",
"@earendil-works/pi-ai": "0.80.7",
"@earendil-works/pi-agent-core": "0.82.1",
"@earendil-works/pi-ai": "0.82.1",
"@google/genai": "1.52.0",
"@shumai/core": "workspace:*",
"@shumai/db": "workspace:*",
+48 -8
View File
@@ -70,7 +70,12 @@ describe('Agent Activities', () => {
vi.mocked(piAgent.createAgentSession).mockResolvedValue({
session: mockSession as unknown as Session<DatabaseSessionMetadata>,
harness: mockHarness as unknown as AgentHarness,
harness: mockHarness as unknown as AgentHarness<
undefined,
Skill,
PromptTemplate,
AgentHarnessTool<undefined>
>,
})
const context = {
@@ -137,7 +142,12 @@ describe('Agent Activities', () => {
vi.mocked(piAgent.createAgentSession).mockResolvedValue({
session: mockSession as unknown as Session<DatabaseSessionMetadata>,
harness: mockHarness as unknown as AgentHarness,
harness: mockHarness as unknown as AgentHarness<
undefined,
Skill,
PromptTemplate,
AgentHarnessTool<undefined>
>,
})
const context = {
@@ -198,7 +208,12 @@ describe('Agent Activities', () => {
vi.mocked(piAgent.createAgentSession).mockResolvedValue({
session: mockSession as unknown as Session<DatabaseSessionMetadata>,
harness: mockHarness as unknown as AgentHarness,
harness: mockHarness as unknown as AgentHarness<
undefined,
Skill,
PromptTemplate,
AgentHarnessTool<undefined>
>,
})
const context = {
@@ -266,7 +281,12 @@ describe('Agent Activities', () => {
vi.mocked(piAgent.createAgentSession).mockResolvedValue({
session: mockSession as unknown as Session<DatabaseSessionMetadata>,
harness: mockHarness as unknown as AgentHarness,
harness: mockHarness as unknown as AgentHarness<
undefined,
Skill,
PromptTemplate,
AgentHarnessTool<undefined>
>,
})
const context = {
@@ -331,7 +351,12 @@ describe('Agent Activities', () => {
vi.mocked(piAgent.createAgentSession).mockResolvedValue({
session: mockSession as unknown as Session<DatabaseSessionMetadata>,
harness: mockHarness as unknown as AgentHarness,
harness: mockHarness as unknown as AgentHarness<
undefined,
Skill,
PromptTemplate,
AgentHarnessTool<undefined>
>,
})
const context = {
@@ -371,7 +396,12 @@ describe('Agent Activities', () => {
vi.mocked(piAgent.createAgentSession).mockResolvedValue({
session: mockSession as unknown as Session<DatabaseSessionMetadata>,
harness: mockHarness as unknown as AgentHarness,
harness: mockHarness as unknown as AgentHarness<
undefined,
Skill,
PromptTemplate,
AgentHarnessTool<undefined>
>,
})
const context = {
@@ -430,7 +460,12 @@ describe('Agent Activities', () => {
}
return {
session: mockSession as unknown as Session<DatabaseSessionMetadata>,
harness: mockHarness as unknown as AgentHarness,
harness: mockHarness as unknown as AgentHarness<
undefined,
Skill,
PromptTemplate,
AgentHarnessTool<undefined>
>,
}
})
@@ -1420,7 +1455,12 @@ describe('Agent Database Activities Integration', () => {
}
vi.mocked(piAgent.createAgentSession).mockResolvedValue({
session: {} as unknown as Session<DatabaseSessionMetadata>,
harness: mockHarness as unknown as AgentHarness,
harness: mockHarness as unknown as AgentHarness<
undefined,
Skill,
PromptTemplate,
AgentHarnessTool<undefined>
>,
})
await generateSessionNameActivity({
@@ -212,6 +212,30 @@ export class DatabaseSessionStorage implements SessionStorage<DatabaseSessionMet
return (entry as { label?: string } | undefined)?.label
}
async getSessionName(): Promise<string | undefined> {
return undefined
}
async getSessionStats(): Promise<{
messageCount: number
cachedTokens: number
uncachedTokens: number
totalTokens: number
costTotal: number
}> {
return {
messageCount: 0,
cachedTokens: 0,
uncachedTokens: 0,
totalTokens: 0,
costTotal: 0,
}
}
async getPathToRootOrCompaction(leafId: string | null): Promise<SessionTreeEntry[]> {
return this.getPathToRoot(leafId)
}
async getPathToRoot(leafId: string | null): Promise<SessionTreeEntry[]> {
if (!leafId) return []
+16 -5
View File
@@ -5,8 +5,9 @@ import {
type AgentTool,
type ThinkingLevel,
} from '@earendil-works/pi-agent-core'
import { NodeExecutionEnv } from '@earendil-works/pi-agent-core/node'
import type { Api, Model } from '@earendil-works/pi-ai'
import { createModels, InMemoryCredentialStore } from '@earendil-works/pi-ai'
import { builtinProviders } from '@earendil-works/pi-ai/providers/all'
import { agentService } from '@shumai/core/src/agent/agent'
import { prisma } from '@shumai/db'
import { Type, type TSchema } from '@sinclair/typebox'
@@ -279,9 +280,22 @@ export async function createAgentSession(params: CreateAgentSessionParams) {
? []
: allTools.filter((tool) => !deniedTools.includes(tool.name))
const credentials = new InMemoryCredentialStore()
const resolveKey = (key: string | undefined) => (key ? process.env[key] || key : undefined)
for (const p of params.providers) {
const apiKey = resolveKey(p.config?.apiKey)
if (apiKey) {
await credentials.modify(p.name, async () => ({ type: 'api_key' as const, key: apiKey }))
}
}
const modelsStore = createModels({ credentials })
for (const provider of builtinProviders()) {
modelsStore.setProvider(provider)
}
const harness = new AgentHarness({
env: new NodeExecutionEnv({ cwd: process.cwd() }),
session,
models: modelsStore,
model,
thinkingLevel: (thinkingLevel || 'off') as ThinkingLevel,
streamOptions: {
@@ -312,9 +326,6 @@ export async function createAgentSession(params: CreateAgentSessionParams) {
}
return prompt
},
getApiKeyAndHeaders: async (targetModel) => {
return getApiKeyAndHeadersFromDb(params.providers, targetModel.provider)
},
tools: enabledTools,
})
+1 -1
View File
@@ -6,7 +6,7 @@
"main": "./src/index.ts",
"types": "./src/index.ts",
"dependencies": {
"@earendil-works/pi-agent-core": "0.78.0",
"@earendil-works/pi-agent-core": "0.82.1",
"@earendil-works/pi-ai": "0.82.1",
"@shumai/db": "workspace:*",
"@shumai/dtos": "workspace:*",
+1 -1
View File
@@ -16,7 +16,7 @@
"@prisma/adapter-pg": "7.8.0",
"@prisma/client": "7.8.0",
"pg": "8.21.0",
"@earendil-works/pi-agent-core": "0.78.0",
"@earendil-works/pi-agent-core": "0.82.1",
"zod": "4.4.3"
},
"devDependencies": {
+1 -1
View File
@@ -6,7 +6,7 @@
"main": "./src/index.ts",
"types": "./src/index.ts",
"dependencies": {
"@earendil-works/pi-agent-core": "0.78.0",
"@earendil-works/pi-agent-core": "0.82.1",
"zod": "4.4.3"
}
}
+1 -1
View File
@@ -4,7 +4,7 @@
"private": true,
"type": "module",
"dependencies": {
"@earendil-works/pi-agent-core": "0.78.0",
"@earendil-works/pi-agent-core": "0.82.1",
"@google/genai": "1.52.0",
"@shumai/agent": "workspace:*",
"@shumai/core": "workspace:*",
+14 -7
View File
@@ -5,7 +5,7 @@ import { workflowService, TaskQueueAgent, TaskQueueTranscode } from '@shumai/wor
import { initAgentWorkflows } from '@shumai/agent'
import { initTranscodeWorkflows } from '@shumai/transcode'
import { s3Service } from '@shumai/core/src/s3/s3'
import { AgentHarness, type AgentTool } from '@earendil-works/pi-agent-core'
import { AgentHarness } from '@earendil-works/pi-agent-core'
import { fileURLToPath } from 'url'
import * as path from 'path'
@@ -38,15 +38,22 @@ describe.each(['local', 'temporal'] as const)(
) {
// Find the real autofill_metadata tool configured on the harness
const tools = this.getTools()
const autofillTool = tools.find((t: AgentTool) => t.name === 'autofill_metadata')
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Tool execution mock for E2E harness test
const autofillTool = tools.find((t) => t.name === 'autofill_metadata') as any
if (autofillTool) {
// Execute the real tool callback to perform the actual DB updates
await autofillTool.execute('call-123', {
title: 'E2E Title Extracted',
confidence: 0.95,
completed: true,
})
await autofillTool.execute(
'call-123',
{
title: 'E2E Title Extracted',
confidence: 0.95,
completed: true,
},
undefined,
undefined,
undefined,
)
}
// Return a successful assistant response mock