mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-30 02:20:38 +00:00
chore: Run pnpm format:fix.
This commit is contained in:
43
docs/pi.md
43
docs/pi.md
@@ -24,12 +24,12 @@ OpenClaw uses the pi SDK to embed an AI coding agent into its messaging gateway
|
||||
}
|
||||
```
|
||||
|
||||
| Package | Purpose |
|
||||
|---------|---------|
|
||||
| `pi-ai` | Core LLM abstractions: `Model`, `streamSimple`, message types, provider APIs |
|
||||
| `pi-agent-core` | Agent loop, tool execution, `AgentMessage` types |
|
||||
| Package | Purpose |
|
||||
| ----------------- | ------------------------------------------------------------------------------------------------------ |
|
||||
| `pi-ai` | Core LLM abstractions: `Model`, `streamSimple`, message types, provider APIs |
|
||||
| `pi-agent-core` | Agent loop, tool execution, `AgentMessage` types |
|
||||
| `pi-coding-agent` | High-level SDK: `createAgentSession`, `SessionManager`, `AuthStorage`, `ModelRegistry`, built-in tools |
|
||||
| `pi-tui` | Terminal UI components (used in OpenClaw's local TUI mode) |
|
||||
| `pi-tui` | Terminal UI components (used in OpenClaw's local TUI mode) |
|
||||
|
||||
## File Structure
|
||||
|
||||
@@ -195,6 +195,7 @@ const subscription = subscribeEmbeddedPiSession({
|
||||
```
|
||||
|
||||
Events handled include:
|
||||
|
||||
- `message_start` / `message_end` / `message_update` (streaming text/thinking)
|
||||
- `tool_execution_start` / `tool_execution_update` / `tool_execution_end`
|
||||
- `turn_start` / `turn_end`
|
||||
@@ -249,7 +250,7 @@ export function toToolDefinitions(tools: AnyAgentTool[]): ToolDefinition[] {
|
||||
```typescript
|
||||
export function splitSdkTools(options: { tools: AnyAgentTool[]; sandboxEnabled: boolean }) {
|
||||
return {
|
||||
builtInTools: [], // Empty. We override everything
|
||||
builtInTools: [], // Empty. We override everything
|
||||
customTools: toToolDefinitions(options.tools),
|
||||
};
|
||||
}
|
||||
@@ -328,7 +329,10 @@ const rotated = await advanceAuthProfile();
|
||||
import { resolveModel } from "./pi-embedded-runner/model.js";
|
||||
|
||||
const { model, error, authStorage, modelRegistry } = resolveModel(
|
||||
provider, modelId, agentDir, config
|
||||
provider,
|
||||
modelId,
|
||||
agentDir,
|
||||
config,
|
||||
);
|
||||
|
||||
// Uses pi's ModelRegistry and AuthStorage
|
||||
@@ -343,7 +347,9 @@ authStorage.setRuntimeApiKey(model.provider, apiKeyInfo.apiKey);
|
||||
if (fallbackConfigured && isFailoverErrorMessage(errorText)) {
|
||||
throw new FailoverError(errorText, {
|
||||
reason: promptFailoverReason ?? "unknown",
|
||||
provider, model: modelId, profileId,
|
||||
provider,
|
||||
model: modelId,
|
||||
profileId,
|
||||
status: resolveFailoverStatus(promptFailoverReason),
|
||||
});
|
||||
}
|
||||
@@ -371,7 +377,10 @@ if (resolveCompactionMode(params.cfg) === "safeguard") {
|
||||
```typescript
|
||||
if (cfg?.agents?.defaults?.contextPruning?.mode === "cache-ttl") {
|
||||
setContextPruningRuntime(params.sessionManager, {
|
||||
settings, contextWindowTokens, isToolPrunable, lastCacheTouchAt,
|
||||
settings,
|
||||
contextWindowTokens,
|
||||
isToolPrunable,
|
||||
lastCacheTouchAt,
|
||||
});
|
||||
paths.push(resolvePiExtensionPath("context-pruning"));
|
||||
}
|
||||
@@ -486,15 +495,15 @@ This provides the interactive terminal experience similar to pi's native mode.
|
||||
|
||||
## Key Differences from Pi CLI
|
||||
|
||||
| Aspect | Pi CLI | OpenClaw Embedded |
|
||||
|--------|--------|-------------------|
|
||||
| Invocation | `pi` command / RPC | SDK via `createAgentSession()` |
|
||||
| Tools | Default coding tools | Custom OpenClaw tool suite |
|
||||
| System prompt | AGENTS.md + prompts | Dynamic per-channel/context |
|
||||
| Aspect | Pi CLI | OpenClaw Embedded |
|
||||
| --------------- | ----------------------- | ---------------------------------------------------------------------------------------------- |
|
||||
| Invocation | `pi` command / RPC | SDK via `createAgentSession()` |
|
||||
| Tools | Default coding tools | Custom OpenClaw tool suite |
|
||||
| System prompt | AGENTS.md + prompts | Dynamic per-channel/context |
|
||||
| Session storage | `~/.pi/agent/sessions/` | `~/.openclaw/agents/<agentId>/sessions/` (or `$OPENCLAW_STATE_DIR/agents/<agentId>/sessions/`) |
|
||||
| Auth | Single credential | Multi-profile with rotation |
|
||||
| Extensions | Loaded from disk | Programmatic + disk paths |
|
||||
| Event handling | TUI rendering | Callback-based (onBlockReply, etc.) |
|
||||
| Auth | Single credential | Multi-profile with rotation |
|
||||
| Extensions | Loaded from disk | Programmatic + disk paths |
|
||||
| Event handling | TUI rendering | Callback-based (onBlockReply, etc.) |
|
||||
|
||||
## Future Considerations
|
||||
|
||||
|
||||
Reference in New Issue
Block a user