feat(backends): add optional pi_embedded backend and config wiring

This commit is contained in:
William Valentin
2026-02-23 21:12:52 -08:00
parent 0af44330b5
commit ac61c9c3fb
9 changed files with 426 additions and 10 deletions
+26 -3
View File
@@ -403,12 +403,18 @@ describe('configSchema — agent_configs', () => {
tool_profile: 'coding',
sandbox: true,
},
pi_canary: {
model_tier: 'default',
backend: 'pi_embedded',
tool_profile: 'messaging',
},
},
});
expect(result.agent_configs.assistant.system_prompt).toBe('You are helpful.');
expect(result.agent_configs.assistant.backend).toBe('codex');
expect(result.agent_configs.assistant.tool_profile).toBe('messaging');
expect(result.agent_configs.coder.sandbox).toBe(true);
expect(result.agent_configs.pi_canary.backend).toBe('pi_embedded');
});
});
@@ -500,20 +506,31 @@ describe('configSchema — backends', () => {
expect(result.backends.opencode.args).toEqual([]);
expect(result.backends.codex.enabled).toBe(false);
expect(result.backends.gemini.enabled).toBe(false);
expect(result.backends.pi_embedded.enabled).toBe(false);
expect(result.backends.pi_embedded.no_tools_mode).toBe(true);
expect(result.backends.pi_embedded.system_prompt_mode).toBe('hybrid');
expect(result.backends.native.enabled).toBe(true);
});
it('accepts explicit codex/gemini backend config', () => {
it('accepts explicit codex/gemini/pi_embedded backend config', () => {
const result = configSchema.parse({
...minimalConfig,
backends: {
default: 'codex',
default: 'pi_embedded',
codex: { enabled: true, path: '/usr/local/bin/codex', args: ['run'], timeout_ms: 300000 },
gemini: { enabled: true, path: '/usr/local/bin/gemini', args: ['chat'], timeout_ms: 60000 },
pi_embedded: {
enabled: true,
timeout_ms: 45000,
no_tools_mode: false,
model: 'openclaw-default',
system_prompt_mode: 'flynn',
module: '@badlogic/pi-agent-core',
},
},
});
expect(result.backends.default).toBe('codex');
expect(result.backends.default).toBe('pi_embedded');
expect(result.backends.codex.enabled).toBe(true);
expect(result.backends.codex.path).toBe('/usr/local/bin/codex');
expect(result.backends.codex.args).toEqual(['run']);
@@ -522,6 +539,12 @@ describe('configSchema — backends', () => {
expect(result.backends.gemini.path).toBe('/usr/local/bin/gemini');
expect(result.backends.gemini.args).toEqual(['chat']);
expect(result.backends.gemini.timeout_ms).toBe(60000);
expect(result.backends.pi_embedded.enabled).toBe(true);
expect(result.backends.pi_embedded.timeout_ms).toBe(45000);
expect(result.backends.pi_embedded.no_tools_mode).toBe(false);
expect(result.backends.pi_embedded.model).toBe('openclaw-default');
expect(result.backends.pi_embedded.system_prompt_mode).toBe('flynn');
expect(result.backends.pi_embedded.module).toBe('@badlogic/pi-agent-core');
});
});
+10 -2
View File
@@ -184,7 +184,7 @@ const modelsSchema = z.object({
});
const backendsSchema = z.object({
default: z.enum(['claude_code', 'opencode', 'codex', 'gemini']).optional(),
default: z.enum(['claude_code', 'opencode', 'codex', 'gemini', 'pi_embedded']).optional(),
claude_code: z.object({
enabled: z.boolean().default(false),
path: z.string().optional(),
@@ -209,6 +209,14 @@ const backendsSchema = z.object({
args: z.array(z.string()).default([]),
timeout_ms: z.number().min(1_000).max(600_000).default(120_000),
}).default({ enabled: false }),
pi_embedded: z.object({
enabled: z.boolean().default(false),
timeout_ms: z.number().min(1_000).max(600_000).default(120_000),
no_tools_mode: z.boolean().default(true),
model: z.string().optional(),
system_prompt_mode: z.enum(['flynn', 'pi_default', 'hybrid']).default('hybrid'),
module: z.string().optional(),
}).default({ enabled: false }),
native: z.object({
enabled: z.boolean().default(true),
}).default({ enabled: true }),
@@ -853,7 +861,7 @@ const sandboxSchema = z.object({
const agentConfigEntrySchema = z.object({
system_prompt: z.string().optional(),
model_tier: modelTierEnum.optional(),
backend: z.enum(['native', 'claude_code', 'opencode', 'codex', 'gemini']).optional(),
backend: z.enum(['native', 'claude_code', 'opencode', 'codex', 'gemini', 'pi_embedded']).optional(),
tool_profile: toolProfileEnum.optional(),
tool_overrides: toolOverrideSchema.optional(),
sandbox: z.boolean().default(false),