refactor(ai): upgrade pi runtime and define execution semantics

This commit is contained in:
digua committed 2026-08-18 17:27:48 +08:00
1 parent dea6eb8f0d
commit cf1aee9e5b
37 files changed
+313 -133

No files matched your search

+3 -3
View File
@@ -15,7 +15,7 @@
"LICENSE"
],
"engines": {
"node": ">=20"
"node": ">=22.19.0"
},
"publishConfig": {
"access": "public"
@@ -48,8 +48,8 @@
"dependencies": {
"@fastify/multipart": "^10.0.0",
"@fastify/static": "^9.1.3",
"@earendil-works/pi-agent-core": "0.74.2",
"@earendil-works/pi-ai": "0.74.2",
"@earendil-works/pi-agent-core": "0.83.0",
"@earendil-works/pi-ai": "0.83.0",
"@modelcontextprotocol/sdk": "^1.12.1",
"better-sqlite3": "^12.4.6",
"commander": "^13.1.0",
+1
View File
@@ -251,6 +251,7 @@ export async function runServerAgent(options: RunAgentOptions): Promise<void> {
userMessage,
maxToolRounds: DEFAULT_MAX_TOOL_ROUNDS,
abortSignal,
providerSessionId: aiChatId,
steerMessage,
thinkingLevel: thinkingLevel as import('@openchatlab/core').ThinkingLevel | undefined,
onConvertToLlm: (filteredMessages) => {
+2
View File
@@ -37,6 +37,7 @@ describe('adaptToolsForAgent', () => {
name: 'render_chart',
description: 'Render a chart',
inputSchema: { type: 'object', properties: {} },
executionMode: 'sequential',
async handler() {
chartCalls += 1
return { content: 'Generated chart.' }
@@ -51,6 +52,7 @@ describe('adaptToolsForAgent', () => {
const result = await agentTool.execute('call-1', {})
assert.equal(agentTool.executionMode, 'sequential')
assert.equal(chartCalls, 0)
assert.deepEqual(result.content, [{ type: 'text', text: CHART_SCHEMA_REQUIRED_MESSAGE }])
assert.equal(result.details, null)
+1
View File
@@ -73,6 +73,7 @@ export function adaptToolsForAgent(
label: tool.name,
description: tool.description,
parameters: toAgentToolParameters(tool.inputSchema) as any,
executionMode: tool.executionMode,
async execute(_toolCallId: string, params: unknown) {
const ctx = getContext()
const execCtx: ToolExecutionContext = {
+1 -1
View File
@@ -15,7 +15,7 @@ export default defineConfig({
splitting: true,
sourcemap: true,
clean: true,
target: 'node20',
target: 'node22',
platform: 'node',
define: {
'process.env.UMAMI_ENDPOINT': JSON.stringify(process.env.UMAMI_ENDPOINT || ''),