feat(agent): add profile system and improve tools

- Add Agent Profile module for managing agent identity, soul, tools,
  memory, and bootstrap configuration
- Add profile CLI (pnpm agent:profile) for creating/listing/showing profiles
- Default sessionId to UUIDv7 instead of "default"
- Expose Agent.sessionId as public readonly property
- Improve exec/process tools error handling (no more crashes on spawn errors)
- Add 'output' action to process tool for reading stdout/stderr
- Better tool descriptions to guide agent in choosing exec vs process

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Jiayuan 2026-01-30 02:47:30 +08:00
parent 46a6cb3061
commit 200b2cefda
15 changed files with 740 additions and 58 deletions

View file

@ -1,5 +1,5 @@
import type { AgentOptions } from "./types.js";
import { getModel } from "@mariozechner/pi-ai";
import { getModel, type KnownProvider } from "@mariozechner/pi-ai";
import { createCodingTools } from "@mariozechner/pi-coding-agent";
import type { AgentTool } from "@mariozechner/pi-agent-core";
import { createExecTool } from "./tools/exec.js";
@ -7,14 +7,18 @@ import { createProcessTool } from "./tools/process.js";
export function resolveModel(options: AgentOptions) {
if (options.provider && options.model) {
return getModel(options.provider, options.model);
// Type assertion needed because provider/model come from dynamic user config
return (getModel as (p: string, m: string) => ReturnType<typeof getModel>)(
options.provider,
options.model,
);
}
return getModel("kimi-coding", "kimi-k2-thinking");
}
export function resolveTools(options: AgentOptions) {
export function resolveTools(options: AgentOptions): AgentTool<any>[] {
const cwd = options.cwd ?? process.cwd();
const baseTools = createCodingTools(cwd).filter((tool) => tool.name !== "bash");
const baseTools = createCodingTools(cwd).filter((tool) => tool.name !== "bash") as AgentTool<any>[];
const execTool = createExecTool(cwd);
const processTool = createProcessTool(cwd);
return [...baseTools, execTool as AgentTool<any>, processTool as AgentTool<any>];