my-durable 0.0.0-stage → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +7 -0
- package/LICENSE +21 -0
- package/README.md +328 -2
- package/ai_docs/durable_pi/announcement.md +860 -0
- package/ai_docs/durable_pi/changelog.md +51 -0
- package/ai_docs/durable_pi/chord-delta-findings.md +362 -0
- package/ai_docs/durable_pi/coding-agent-integration.md +70 -0
- package/ai_docs/durable_pi/pico-v5-chord-usage.md +391 -0
- package/ai_docs/durable_pi/pico-v5-handoff.md +921 -0
- package/ai_docs/durable_pi/readme.md +617 -0
- package/ai_docs/durable_pi/sources.md +22 -0
- package/ai_docs/durable_pi/spec.md +4696 -0
- package/ai_docs/durable_pi/vacation-planner.md +57 -0
- package/ai_docs/pi/chord.md +268 -0
- package/ai_docs/pi/cli-integration.md +110 -0
- package/ai_docs/pi/cli.md +325 -0
- package/ai_docs/pi/codemode.md +211 -0
- package/ai_docs/pi/compaction.md +467 -0
- package/ai_docs/pi/configuration.md +51 -0
- package/ai_docs/pi/containerization.md +187 -0
- package/ai_docs/pi/custom-provider.md +177 -0
- package/ai_docs/pi/environment-variables.md +102 -0
- package/ai_docs/pi/extensions.md +278 -0
- package/ai_docs/pi/how-pi-works.md +53 -0
- package/ai_docs/pi/index.md +43 -0
- package/ai_docs/pi/json.md +230 -0
- package/ai_docs/pi/keybindings.md +198 -0
- package/ai_docs/pi/llama-cpp.md +118 -0
- package/ai_docs/pi/mcp.md +274 -0
- package/ai_docs/pi/message-types.md +265 -0
- package/ai_docs/pi/models.md +209 -0
- package/ai_docs/pi/overview.md +166 -0
- package/ai_docs/pi/packages.md +133 -0
- package/ai_docs/pi/pi-agent-core.md +568 -0
- package/ai_docs/pi/pi-ai.md +1942 -0
- package/ai_docs/pi/prompt-templates.md +63 -0
- package/ai_docs/pi/providers.md +204 -0
- package/ai_docs/pi/quickstart.md +140 -0
- package/ai_docs/pi/readme.md +99 -0
- package/ai_docs/pi/rpc-commands.md +864 -0
- package/ai_docs/pi/rpc-extension-ui.md +204 -0
- package/ai_docs/pi/rpc.md +197 -0
- package/ai_docs/pi/sdk.md +151 -0
- package/ai_docs/pi/security.md +103 -0
- package/ai_docs/pi/session-format.md +297 -0
- package/ai_docs/pi/sessions.md +70 -0
- package/ai_docs/pi/settings.md +173 -0
- package/ai_docs/pi/shell-aliases.md +97 -0
- package/ai_docs/pi/skills.md +97 -0
- package/ai_docs/pi/slash-commands.md +64 -0
- package/ai_docs/pi/sources.md +57 -0
- package/ai_docs/pi/terminal-setup.md +223 -0
- package/ai_docs/pi/termux.md +121 -0
- package/ai_docs/pi/themes.md +140 -0
- package/ai_docs/pi/tmux.md +59 -0
- package/ai_docs/pi/toolkit.md +168 -0
- package/ai_docs/pi/tui.md +129 -0
- package/ai_docs/pi/usage.md +98 -0
- package/ai_docs/pi/virtual-models.md +118 -0
- package/ai_docs/pi/windows.md +71 -0
- package/apps/dpi-backend/.nvmrc +1 -0
- package/apps/dpi-backend/API.md +99 -0
- package/apps/dpi-backend/README.md +119 -0
- package/apps/dpi-backend/deploy/backend.env.example +9 -0
- package/apps/dpi-backend/deploy/dpi-backend.plist +26 -0
- package/apps/dpi-backend/deploy/dpi-backend.service +22 -0
- package/apps/dpi-backend/package.json +33 -0
- package/apps/dpi-backend/prompts/one_sentence.md +3 -0
- package/apps/dpi-backend/prompts/smart_ass_opus_fix.md +169 -0
- package/apps/dpi-backend/scripts/check-contract.mjs +151 -0
- package/apps/dpi-backend/scripts/migrate-playground.ts +66 -0
- package/apps/dpi-backend/scripts/record-nested-fixture.mts +154 -0
- package/apps/dpi-backend/scripts/token.ts +57 -0
- package/apps/dpi-backend/src/addons.ts +139 -0
- package/apps/dpi-backend/src/auth.ts +20 -0
- package/apps/dpi-backend/src/config.ts +54 -0
- package/apps/dpi-backend/src/contract-check.ts +118 -0
- package/apps/dpi-backend/src/errors.ts +50 -0
- package/apps/dpi-backend/src/extensions.ts +510 -0
- package/apps/dpi-backend/src/faux.ts +80 -0
- package/apps/dpi-backend/src/history.ts +165 -0
- package/apps/dpi-backend/src/idempotency.ts +20 -0
- package/apps/dpi-backend/src/jev.ts +43 -0
- package/apps/dpi-backend/src/jobs.ts +790 -0
- package/apps/dpi-backend/src/main.ts +76 -0
- package/apps/dpi-backend/src/model-catalog.ts +180 -0
- package/apps/dpi-backend/src/pairing-files.ts +142 -0
- package/apps/dpi-backend/src/pairing.ts +459 -0
- package/apps/dpi-backend/src/routes.ts +217 -0
- package/apps/dpi-backend/src/shared-state.ts +85 -0
- package/apps/dpi-backend/src/store.ts +1240 -0
- package/apps/dpi-backend/src/streams.ts +256 -0
- package/apps/dpi-backend/src/tunnel.ts +955 -0
- package/apps/dpi-backend/tsconfig.json +13 -0
- package/apps/dpi-playground/README.md +83 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/assets/index-CFGc7lHT.js +77 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/assets/index-DFdKpwm_.css +1 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/icons/anthropic.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/icons/deepseek.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/icons/durable-pi.svg +14 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/icons/gemini.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/icons/grok.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/icons/kimi.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/icons/lab.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/icons/meta.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/icons/minimax.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/icons/openai.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/icons/qwen.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/icons/xiaomi.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/icons/zai.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/index.html +16 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/index.html +15 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/package.json +5 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/public/icons/anthropic.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/public/icons/deepseek.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/public/icons/durable-pi.svg +14 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/public/icons/gemini.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/public/icons/grok.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/public/icons/kimi.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/public/icons/lab.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/public/icons/meta.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/public/icons/minimax.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/public/icons/openai.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/public/icons/qwen.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/public/icons/xiaomi.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/public/icons/zai.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/App.vue +180 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/commands.ts +119 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/composables.ts +129 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/hub.ts +40 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/icon-path.ts +7 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/ids.ts +2 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/jobs.ts +80 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/link-policy.ts +16 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/markdown-policy.ts +115 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/markdown.ts +60 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/pair-close.ts +23 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/pair-handoff.ts +56 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/pair.ts +166 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/qrcode.ts +323 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/signature.ts +146 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/store.ts +373 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/stream.ts +183 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/AgentView.vue +342 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/Composer.vue +198 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/ContextBar.vue +254 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/DeviceCredentialsDialog.vue +40 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/DeviceIcon.vue +56 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/DirBrowser.vue +95 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/ExtensionsPanel.vue +96 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/HelpDialog.vue +69 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/Inspector.vue +425 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/JobCard.vue +221 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/MobileNav.vue +39 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/ModelPicker.vue +71 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/NetworkSidebar.vue +236 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/NewSessionDialog.vue +114 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/OfflinePanel.vue +128 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/PairDeviceWizard.vue +433 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/PromptDialog.vue +89 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/StateEditor.vue +179 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/TasksPanel.vue +280 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/Toast.vue +11 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/TokenManager.vue +175 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/TopBar.vue +114 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/TranscriptItem.vue +152 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/TreeRow.vue +195 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/TunnelStatusBar.vue +107 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/extensions.css +105 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/jobs.css +655 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/main.ts +22 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/network.css +675 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/style.css +3203 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/tsconfig.json +16 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/vite.config.ts +14 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/package.json +5 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/audit.ts +406 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/client-ip.ts +72 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/credentials.ts +265 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/guard.ts +43 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/http-errors.ts +156 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/identity.ts +60 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/limiter.ts +165 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/main.ts +460 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/monitor.ts +320 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/mux.ts +277 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/pairing.ts +816 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/proxy.ts +128 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/rotation.ts +583 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/seed.ts +11 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/transport.ts +108 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/tunnel-token.ts +11 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/tunnel-transport.ts +560 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/tunnel.ts +873 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/tsconfig.json +13 -0
- package/apps/dpi-playground/package.json +37 -0
- package/apps/dpi-sdk/README.md +74 -0
- package/apps/dpi-sdk/package.json +20 -0
- package/apps/dpi-sdk/scripts/net.ts +73 -0
- package/apps/dpi-sdk/src/api.ts +631 -0
- package/apps/dpi-sdk/src/app-state.ts +111 -0
- package/apps/dpi-sdk/src/client.ts +330 -0
- package/apps/dpi-sdk/src/errors.ts +16 -0
- package/apps/dpi-sdk/src/jobs.ts +99 -0
- package/apps/dpi-sdk/src/models.ts +472 -0
- package/apps/dpi-sdk/src/node/chunk.ts +488 -0
- package/apps/dpi-sdk/src/node/config.ts +175 -0
- package/apps/dpi-sdk/src/node/drivers.ts +402 -0
- package/apps/dpi-sdk/src/node/ops.ts +114 -0
- package/apps/dpi-sdk/src/node/private-dir.ts +48 -0
- package/apps/dpi-sdk/src/node/registry-migration.ts +549 -0
- package/apps/dpi-sdk/src/node/registry.ts +390 -0
- package/apps/dpi-sdk/src/node/sse-writer.ts +151 -0
- package/apps/dpi-sdk/src/protocol/backoff.ts +31 -0
- package/apps/dpi-sdk/src/protocol/limits.ts +199 -0
- package/apps/dpi-sdk/src/protocol/pairing.ts +311 -0
- package/apps/dpi-sdk/src/protocol/rest-routes.ts +105 -0
- package/apps/dpi-sdk/src/protocol/tunnel.ts +331 -0
- package/apps/dpi-sdk/src/sse.ts +117 -0
- package/apps/dpi-sdk/src/transcript.ts +291 -0
- package/apps/dpi-sdk/tsconfig.json +13 -0
- package/apps/dpi-sdk/w +20 -0
- package/apps/dpi-tui/README.md +54 -0
- package/apps/dpi-tui/bin/dpi-tui.mjs +5 -0
- package/apps/dpi-tui/package.json +20 -0
- package/apps/dpi-tui/src/app.ts +433 -0
- package/apps/dpi-tui/src/commands.ts +151 -0
- package/apps/dpi-tui/src/main.ts +122 -0
- package/apps/dpi-tui/src/pairing.ts +287 -0
- package/apps/dpi-tui/src/pickers.ts +238 -0
- package/apps/dpi-tui/src/render.ts +164 -0
- package/apps/dpi-tui/src/theme.ts +57 -0
- package/apps/dpi-tui/tsconfig.json +14 -0
- package/bin/device.mjs +5 -0
- package/bin/hub.mjs +5 -0
- package/bin/tui.mjs +5 -0
- package/deploy/Caddyfile +120 -0
- package/docs/verification.md +102 -0
- package/dpi-network.example.yaml +62 -0
- package/images/01_durable_agent_network.svg +185 -0
- package/images/02_pi_made_durable.svg +204 -0
- package/images/03_restart_mid_tool.svg +168 -0
- package/images/07_one_api_every_client.svg +123 -0
- package/images/08_device_session_agent.svg +123 -0
- package/images/09_compact_keep_history.svg +143 -0
- package/images/10_shared_app_state.svg +177 -0
- package/images/11_durable_jobs_wait.svg +141 -0
- package/images/12_tools_change_mid_run.svg +231 -0
- package/images/13_hook_blocks_tool.svg +122 -0
- package/images/14_fork_at_any_entry.svg +119 -0
- package/images/15_web_client.png +0 -0
- package/images/16_terminal_client.svg +43 -0
- package/images/17_devices_are_data.svg +182 -0
- package/images/18_should_every_agent_be_durable.svg +118 -0
- package/images/19_sqlite_on_every_device.svg +155 -0
- package/images/20_admission_and_effects.svg +134 -0
- package/justfile +33 -0
- package/package.json +41 -4
- package/scripts/verify.mjs +210 -0
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
> Source: [packages/coding-agent/docs/message-types.md](https://github.com/earendil-works/pi/blob/b78e6a9085343ec0f308c3d377da72528b4cf7ee/packages/coding-agent/docs/message-types.md)
|
|
2
|
+
> Retrieved with Firecrawl: 2026-10-05. Repository snapshot: `b78e6a9085343ec0f308c3d377da72528b4cf7ee`.
|
|
3
|
+
> Relative documentation links point to local copies where available, otherwise to the source snapshot.
|
|
4
|
+
|
|
5
|
+
# Message Types
|
|
6
|
+
|
|
7
|
+
Pi uses `AgentMessage` values in SDK state, lifecycle events, RPC responses, and persisted session message entries. This page defines those shared messages and their content blocks.
|
|
8
|
+
|
|
9
|
+
Message timestamps are Unix timestamps in milliseconds. They are different from the ISO 8601 timestamps on [session entries](session-format.md#entry-base).
|
|
10
|
+
|
|
11
|
+
Source definitions:
|
|
12
|
+
|
|
13
|
+
- [`packages/ai/src/types.ts`](https://github.com/earendil-works/pi/blob/main/packages/ai/src/types.ts) defines provider-facing messages and content blocks.
|
|
14
|
+
- [`packages/agent/src/types.ts`](https://github.com/earendil-works/pi/blob/main/packages/agent/src/types.ts) defines the extensible `AgentMessage` union.
|
|
15
|
+
- [`packages/coding-agent/src/core/messages.ts`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/messages.ts) adds coding-agent message roles.
|
|
16
|
+
|
|
17
|
+
## Content blocks
|
|
18
|
+
|
|
19
|
+
### TextContent
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
interface TextContent {
|
|
23
|
+
type: "text";
|
|
24
|
+
text: string;
|
|
25
|
+
textSignature?: string;
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`textSignature` contains provider-specific message metadata. Treat it as opaque.
|
|
30
|
+
|
|
31
|
+
### ImageContent
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
interface ImageContent {
|
|
35
|
+
type: "image";
|
|
36
|
+
data: string;
|
|
37
|
+
mimeType: string;
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
`data` is base64-encoded image data. `mimeType` identifies its media type, such as `image/png` or `image/jpeg`.
|
|
42
|
+
|
|
43
|
+
### ThinkingContent
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
interface ThinkingContent {
|
|
47
|
+
type: "thinking";
|
|
48
|
+
thinking: string;
|
|
49
|
+
thinkingSignature?: string;
|
|
50
|
+
redacted?: boolean;
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Thinking signatures contain provider-specific replay data. Treat them as opaque. A redacted block can have no visible thinking text while retaining an encrypted payload in `thinkingSignature`.
|
|
55
|
+
|
|
56
|
+
### ToolCall
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
interface ToolCall {
|
|
60
|
+
type: "toolCall";
|
|
61
|
+
id: string;
|
|
62
|
+
name: string;
|
|
63
|
+
arguments: Record<string, any>;
|
|
64
|
+
thoughtSignature?: string;
|
|
65
|
+
namespace?: string;
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
`thoughtSignature` is provider-specific. `namespace` identifies an OpenAI Responses namespace for dynamically loaded or namespaced tools.
|
|
70
|
+
|
|
71
|
+
## Usage
|
|
72
|
+
|
|
73
|
+
Assistant messages always contain usage. Tool results can contain usage when the tool performed nested model work.
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
interface Usage {
|
|
77
|
+
input: number;
|
|
78
|
+
output: number;
|
|
79
|
+
cacheRead: number;
|
|
80
|
+
cacheWrite: number;
|
|
81
|
+
cacheWrite1h?: number;
|
|
82
|
+
reasoning?: number;
|
|
83
|
+
totalTokens: number;
|
|
84
|
+
cost: {
|
|
85
|
+
input: number;
|
|
86
|
+
output: number;
|
|
87
|
+
cacheRead: number;
|
|
88
|
+
cacheWrite: number;
|
|
89
|
+
total: number;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
When present, `reasoning` is already included in `output`; do not add it again. `cacheWrite1h` is the subset of `cacheWrite` written with one-hour retention.
|
|
95
|
+
|
|
96
|
+
## Base messages
|
|
97
|
+
|
|
98
|
+
### SystemMessage
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
interface SystemMessage {
|
|
102
|
+
role: "system";
|
|
103
|
+
content: string | TextContent[];
|
|
104
|
+
sections?: Record<string, string | null>;
|
|
105
|
+
toolsAdded?: Tool[];
|
|
106
|
+
toolsRemoved?: ToolReference[];
|
|
107
|
+
replace?: boolean;
|
|
108
|
+
timestamp: number;
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
The leading system message declares the initial prompt and tools. Later system messages can append instructions, replace or remove named prompt sections, and add or remove tools. Replaying them in order yields the current state. A message with `replace: true` discards the earlier state and establishes a complete new baseline.
|
|
113
|
+
|
|
114
|
+
### UserMessage
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
interface UserMessage {
|
|
118
|
+
role: "user";
|
|
119
|
+
content: string | (TextContent | ImageContent)[];
|
|
120
|
+
timestamp: number;
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### AssistantMessage
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
interface AssistantMessage {
|
|
128
|
+
role: "assistant";
|
|
129
|
+
content: (TextContent | ThinkingContent | ToolCall)[];
|
|
130
|
+
api: string;
|
|
131
|
+
provider: string;
|
|
132
|
+
model: string;
|
|
133
|
+
responseModel?: string;
|
|
134
|
+
responseId?: string;
|
|
135
|
+
providerThinkingLevel?: string;
|
|
136
|
+
diagnostics?: AssistantMessageDiagnostic[];
|
|
137
|
+
usage: Usage;
|
|
138
|
+
stopReason: "pending" | "stop" | "length" | "toolUse" | "error" | "aborted" | "deferred";
|
|
139
|
+
deferred?: DeferredHandle;
|
|
140
|
+
errorMessage?: string;
|
|
141
|
+
rawStopReason?: string;
|
|
142
|
+
endTurn?: boolean;
|
|
143
|
+
timestamp: number;
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
`responseModel` records a concrete provider response model when it differs from the requested model. `responseId`, `providerThinkingLevel`, `diagnostics`, and `rawStopReason` preserve provider or runtime details.
|
|
148
|
+
|
|
149
|
+
`"pending"` is used for a partial assistant message while it streams. The completed message in `message_end` has a terminal stop reason, and Pi does not persist `"pending"` assistant messages in session JSONL.
|
|
150
|
+
|
|
151
|
+
A `"deferred"` response has a `DeferredHandle` with the provider data needed to retrieve it:
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
interface DeferredHandle {
|
|
155
|
+
provider: string;
|
|
156
|
+
modelId: string;
|
|
157
|
+
api: string;
|
|
158
|
+
id: string;
|
|
159
|
+
expiresAt?: number;
|
|
160
|
+
pollAfterMs?: number;
|
|
161
|
+
data?: JsonValue;
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### ToolResultMessage
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
interface ToolResultMessage<TDetails = any> {
|
|
169
|
+
role: "toolResult";
|
|
170
|
+
toolCallId: string;
|
|
171
|
+
toolName: string;
|
|
172
|
+
content: (TextContent | ImageContent)[];
|
|
173
|
+
details?: TDetails;
|
|
174
|
+
usage?: Usage;
|
|
175
|
+
isError: boolean;
|
|
176
|
+
timestamp: number;
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
`details` is tool-specific. Optional `usage` reports nested model work performed by the tool and contributes to full-session statistics, but it is not part of the main model-call usage.
|
|
181
|
+
|
|
182
|
+
## Coding-agent messages
|
|
183
|
+
|
|
184
|
+
The coding-agent package extends `AgentMessage` with four roles.
|
|
185
|
+
|
|
186
|
+
### BashExecutionMessage
|
|
187
|
+
|
|
188
|
+
Created by direct shell commands, including the RPC [`bash`](rpc-commands.md#bash) command. It is not an LLM tool result.
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
interface BashExecutionMessage {
|
|
192
|
+
role: "bashExecution";
|
|
193
|
+
command: string;
|
|
194
|
+
output: string;
|
|
195
|
+
exitCode: number | undefined;
|
|
196
|
+
cancelled: boolean;
|
|
197
|
+
truncated: boolean;
|
|
198
|
+
fullOutputPath?: string;
|
|
199
|
+
excludeFromContext?: boolean;
|
|
200
|
+
timestamp: number;
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Unless `excludeFromContext` is true, Pi converts this message to user-role text before the next model request.
|
|
205
|
+
|
|
206
|
+
### CustomMessage
|
|
207
|
+
|
|
208
|
+
Created when an extension sends a context message.
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
interface CustomMessage<T = unknown> {
|
|
212
|
+
role: "custom";
|
|
213
|
+
customType: string;
|
|
214
|
+
content: string | (TextContent | ImageContent)[];
|
|
215
|
+
display: boolean;
|
|
216
|
+
details?: T;
|
|
217
|
+
timestamp: number;
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
Pi converts its content to a user message for model requests. `display` controls terminal rendering; `details` is not sent to the model.
|
|
222
|
+
|
|
223
|
+
### BranchSummaryMessage
|
|
224
|
+
|
|
225
|
+
```typescript
|
|
226
|
+
interface BranchSummaryMessage {
|
|
227
|
+
role: "branchSummary";
|
|
228
|
+
summary: string;
|
|
229
|
+
fromId: string | null;
|
|
230
|
+
timestamp: number;
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Pi creates this context message from a persisted `branch_summary` entry.
|
|
235
|
+
|
|
236
|
+
### CompactionSummaryMessage
|
|
237
|
+
|
|
238
|
+
```typescript
|
|
239
|
+
interface CompactionSummaryMessage {
|
|
240
|
+
role: "compactionSummary";
|
|
241
|
+
summary: string;
|
|
242
|
+
tokensBefore: number;
|
|
243
|
+
timestamp: number;
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Pi creates this context message from a persisted `compaction` entry.
|
|
248
|
+
|
|
249
|
+
## AgentMessage union
|
|
250
|
+
|
|
251
|
+
In the coding agent, the union is equivalent to:
|
|
252
|
+
|
|
253
|
+
```typescript
|
|
254
|
+
type AgentMessage =
|
|
255
|
+
| SystemMessage
|
|
256
|
+
| UserMessage
|
|
257
|
+
| AssistantMessage
|
|
258
|
+
| ToolResultMessage
|
|
259
|
+
| BashExecutionMessage
|
|
260
|
+
| CustomMessage
|
|
261
|
+
| BranchSummaryMessage
|
|
262
|
+
| CompactionSummaryMessage;
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
At the lower-level agent package, `AgentMessage` is `Message | CustomAgentMessages[keyof CustomAgentMessages]`. Applications can add roles through TypeScript declaration merging, so consumers should tolerate unknown custom roles when they accept messages from an augmented host.
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
> Source: [packages/coding-agent/docs/models.md](https://github.com/earendil-works/pi/blob/b78e6a9085343ec0f308c3d377da72528b4cf7ee/packages/coding-agent/docs/models.md)
|
|
2
|
+
> Retrieved with Firecrawl: 2026-10-05. Repository snapshot: `b78e6a9085343ec0f308c3d377da72528b4cf7ee`.
|
|
3
|
+
> Relative documentation links point to local copies where available, otherwise to the source snapshot.
|
|
4
|
+
|
|
5
|
+
# Choose a Model
|
|
6
|
+
|
|
7
|
+
For a built-in provider, start with `/login`, then choose a model with `/model`. Use custom model configuration only when Pi does not already include the provider or endpoint you need.
|
|
8
|
+
|
|
9
|
+
## Choose a connection
|
|
10
|
+
|
|
11
|
+
| What you have | Recommended setup |
|
|
12
|
+
|---|---|
|
|
13
|
+
| A supported subscription | Sign in through `/login` |
|
|
14
|
+
| A provider API key | Store it through `/login` or set its environment variable |
|
|
15
|
+
| A local GGUF model | Connect Pi to the llama.cpp router |
|
|
16
|
+
| An OpenAI-, Anthropic-, or Google-compatible endpoint | Add it to `models.json` |
|
|
17
|
+
| A provider with a custom protocol or authentication flow | Build or install a provider extension |
|
|
18
|
+
|
|
19
|
+
Browse the [model catalog](https://pi.dev/models) for current providers, model IDs, capabilities, context limits, and pricing. Pi starts with its bundled catalog and can overlay newer catalog data from pi.dev. Cached catalog data remains available offline; run `pi update --models` to force a refresh.
|
|
20
|
+
|
|
21
|
+
## Authenticate
|
|
22
|
+
|
|
23
|
+
Run `/login` and select a provider. Pi stores credentials in [`auth.json`](configuration.md#agent-directory). Run `/logout` to remove stored credentials for a provider.
|
|
24
|
+
|
|
25
|
+
You can instead provide an API key through the provider's environment variable. This is useful in CI and other environments where Pi should not write credentials. [Providers](providers.md) lists the variables and provider-specific setup.
|
|
26
|
+
|
|
27
|
+
When several credential sources are configured, Pi uses a runtime `--api-key` first, then a stored `auth.json` credential, an `apiKey` from `models.json`, and finally the provider's environment variables or ambient cloud credentials. Provider extensions can define their own authentication behavior.
|
|
28
|
+
|
|
29
|
+
Keep `auth.json` and any credential commands private. Project settings and extensions can execute inside the Pi process after you trust a project. Review [Security](security.md) before loading configuration from an untrusted directory.
|
|
30
|
+
|
|
31
|
+
## Select a model
|
|
32
|
+
|
|
33
|
+
Run `/model` to search available models. The picker shows models whose providers have usable authentication. Press `Ctrl+S` on a model to save it as the default for new sessions.
|
|
34
|
+
|
|
35
|
+
Run `/thinking` to select the thinking level for the current model. Press `Ctrl+S` there to save the startup level. Pi limits the choices to levels supported by the selected model.
|
|
36
|
+
|
|
37
|
+
`Ctrl+P` cycles through available models. Use `/scoped-models` to control that cycle and save the selection, or configure model patterns through [Settings](settings.md#model-cycling).
|
|
38
|
+
|
|
39
|
+
A session records model and thinking-level changes. Resuming the session restores them without changing defaults for new sessions.
|
|
40
|
+
|
|
41
|
+
## Connect local models
|
|
42
|
+
|
|
43
|
+
Pi integrates directly with the llama.cpp router. The router discovers GGUF files and loads models on demand. Pi's `/llama` command manages the router, while `/model` selects one of its loaded models.
|
|
44
|
+
|
|
45
|
+
Follow [Local Models with llama.cpp](llama-cpp.md) for server startup, model layout, downloads, and connection troubleshooting.
|
|
46
|
+
|
|
47
|
+
For Ollama, LM Studio, vLLM, SGLang, and other compatible servers, [configure a compatible endpoint](#configure-a-compatible-endpoint) in `models.json`.
|
|
48
|
+
|
|
49
|
+
## Configure a compatible endpoint
|
|
50
|
+
|
|
51
|
+
Use [`models.json`](configuration.md#agent-directory) when an endpoint speaks an API Pi already supports. This includes most Ollama, LM Studio, vLLM, SGLang, and proxy deployments.
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"providers": {
|
|
56
|
+
"ollama": {
|
|
57
|
+
"baseUrl": "http://localhost:11434/v1",
|
|
58
|
+
"api": "openai-completions",
|
|
59
|
+
"apiKey": "ollama",
|
|
60
|
+
"models": [
|
|
61
|
+
{ "id": "qwen2.5-coder:7b" }
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The dummy key makes the model available to Pi; Ollama ignores it. For an authenticated endpoint, `apiKey` and header values can use `$NAME` or `${NAME}` environment interpolation, a literal value, or a leading `!command`. Commands in `models.json` run at request time and are not cached by Pi.
|
|
69
|
+
|
|
70
|
+
Opening `/model` reloads the file. A `models` entry adds or replaces a model with the same ID on that provider. Use `modelOverrides` to change metadata for an existing built-in or extension-provided model without replacing the provider's model list. Unknown override IDs are ignored.
|
|
71
|
+
|
|
72
|
+
### Describe model input and caching
|
|
73
|
+
|
|
74
|
+
Use `inputLimits.images.resize` to control how Pi encodes new image attachments, `read` results, and tool-result images before storing them in conversation history:
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
{
|
|
78
|
+
"id": "vision-model",
|
|
79
|
+
"input": ["text", "image"],
|
|
80
|
+
"inputLimits": {
|
|
81
|
+
"images": {
|
|
82
|
+
"resize": {
|
|
83
|
+
"maxWidth": 1568,
|
|
84
|
+
"maxHeight": 1568,
|
|
85
|
+
"maxBytes": 524288,
|
|
86
|
+
"jpegQuality": 75
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
`maxBytes` limits the base64-encoded payload. Omitted resize fields use conservative defaults of 2000 by 2000 pixels, 4.5 MiB encoded, and JPEG quality 80. Images are encoded once; changing models does not rewrite historical images. The catalog can also describe hard request limits with `inputLimits.maxRequestBytes`, `images.maxPerMessage`, and `images.maxPerRequest`, but Pi does not yet rewrite or reject history based on them.
|
|
94
|
+
|
|
95
|
+
<a id="prompt-cache-lifetimes"></a>
|
|
96
|
+
|
|
97
|
+
Use `promptCache` to declare the provider's best-effort cache lifetime in seconds for the `short` or `long` retention tier:
|
|
98
|
+
|
|
99
|
+
```json
|
|
100
|
+
{ "id": "claude-sonnet-5", "promptCache": { "short": 300, "long": 3600 } }
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Choose the conservative end of any published range. A model without a lifetime for the active tier is not eligible for cache warming. A `modelOverrides` entry can set `inputLimits` or `promptCache` for a built-in or extension model, including a model accessed through a validated proxy. See [`cacheWarming`](settings.md#model-and-thinking).
|
|
104
|
+
|
|
105
|
+
### Configure sampling by thinking level
|
|
106
|
+
|
|
107
|
+
OpenAI-compatible APIs support free-form `samplingParams` model defaults and `samplingParamsByThinkingLevel` overrides. The latter uses Pi thinking-level keys (`off`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`), not provider values from `thinkingLevelMap`:
|
|
108
|
+
|
|
109
|
+
```json
|
|
110
|
+
{
|
|
111
|
+
"id": "qwen-thinking-model",
|
|
112
|
+
"reasoning": true,
|
|
113
|
+
"samplingParams": {
|
|
114
|
+
"temperature": 1.0,
|
|
115
|
+
"top_p": 0.95
|
|
116
|
+
},
|
|
117
|
+
"samplingParamsByThinkingLevel": {
|
|
118
|
+
"off": {
|
|
119
|
+
"temperature": 0.7,
|
|
120
|
+
"top_p": 0.8
|
|
121
|
+
},
|
|
122
|
+
"high": {
|
|
123
|
+
"top_k": 20
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Pi first clamps unsupported thinking levels, then merges model `samplingParams`, the effective level's override, and request-level `samplingParams` in that order. Later values win per key. Missing levels inherit the model defaults. `modelOverrides` merges per-level entries per key with the base model. These fields apply only to `openai-completions`, `openai-responses`, and `azure-openai-responses`; other APIs ignore them.
|
|
130
|
+
|
|
131
|
+
Compatibility settings should describe verified differences in the endpoint's request or response behavior. Do not enable them based only on an endpoint advertising OpenAI or Anthropic compatibility.
|
|
132
|
+
|
|
133
|
+
## Use classifier models
|
|
134
|
+
|
|
135
|
+
Classifier models do not chat. They answer typed questions about JSON state: pick one of several choices, answer yes or no, or give a score, each with probabilities. Pi includes TypeSafe's Jev model from these providers, and Cloudflare's Clef and Clef Flash models from Workers AI:
|
|
136
|
+
|
|
137
|
+
| Provider | Model IDs | Authentication |
|
|
138
|
+
|---|---|---|
|
|
139
|
+
| `typesafe` | `jev-latest` | `TYPESAFE_API_KEY` |
|
|
140
|
+
| `openrouter` | `typesafe/jev-1.13`, `~typesafe/jev-latest` | `OPENROUTER_API_KEY` or `/login` |
|
|
141
|
+
| `cloudflare-workers-ai` | `typesafe/jev`, `@cf/cloudflare/clef`, `@cf/cloudflare/clef-flash` | `CLOUDFLARE_API_KEY` and `CLOUDFLARE_ACCOUNT_ID` |
|
|
142
|
+
| `vercel-ai-gateway` | `typesafe-ai/jev` | `AI_GATEWAY_API_KEY` |
|
|
143
|
+
| `opencode` | `jev-1.13`, `jev-1.13-free` | `OPENCODE_API_KEY` |
|
|
144
|
+
|
|
145
|
+
Chat models on a [llama.cpp router](llama-cpp.md#classification) are also listed as classifier models.
|
|
146
|
+
|
|
147
|
+
Classifier models do not appear in `/model`. The model reaches them through the [`codemode`](cli.md#enable-codemode) tool, which is off unless an MCP server turned it on. Enable it with `"defaultTools": ["+codemode"]` in [settings](settings.md#tools). Scripts then list classifier models with `models.getAvailableOfType("classifier")` and call `models.classify(model, { state, questions })`:
|
|
148
|
+
|
|
149
|
+
```js
|
|
150
|
+
const jev = await models.getModelOfType("classifier", "typesafe", "jev-latest");
|
|
151
|
+
const result = await models.classify(jev, {
|
|
152
|
+
state: { message: "The change works, thanks." },
|
|
153
|
+
questions: {
|
|
154
|
+
approved: {
|
|
155
|
+
type: "bool",
|
|
156
|
+
instructions: "Does the user approve of the result?",
|
|
157
|
+
criteria: { true: "Approval", false: "No approval" },
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
return result.answers;
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
[Codemode](codemode.md#classify) describes the question and answer types.
|
|
165
|
+
|
|
166
|
+
When the service reports token counts, as all System One services do, `result.usage` carries them with their cost. Pi adds the usage of a script's classifier calls to the `codemode` tool result, so it counts toward the session cost in the footer and `/session`. The cost uses the model's catalog price; models without one, such as TypeSafe's direct `jev-latest`, report tokens at no cost.
|
|
167
|
+
|
|
168
|
+
Extensions call classifiers through `ctx.modelRegistry.classify()`, without codemode. [Virtual models](virtual-models.md#route-requests) can use them to route requests; see the `jev-router.ts` example.
|
|
169
|
+
|
|
170
|
+
## Use image models
|
|
171
|
+
|
|
172
|
+
Image models generate images from a prompt and optional input images. Pi lists OpenRouter's image models, such as `google/gemini-2.5-flash-image` and `black-forest-labs/flux.2-pro`, under the `openrouter` provider; they use the same `OPENROUTER_API_KEY` or `/login` credential as its chat models.
|
|
173
|
+
|
|
174
|
+
Like classifier models, image models do not appear in `/model`; the model reaches them through the [`codemode`](cli.md#enable-codemode) tool. Scripts list them with `models.getAvailableOfType("image")` and call `models.generateImages(model, { input })`. The result's `output` holds base64 image blocks, which `image()` attaches to the `codemode` result so the model sees them:
|
|
175
|
+
|
|
176
|
+
```js
|
|
177
|
+
const painter = await models.getModelOfType("image", "openrouter", "google/gemini-2.5-flash-image");
|
|
178
|
+
const result = await models.generateImages(painter, {
|
|
179
|
+
input: [{ type: "text", text: "A red fox in the snow, watercolor" }],
|
|
180
|
+
});
|
|
181
|
+
if (result.stopReason !== "stop") return result.errorMessage;
|
|
182
|
+
for (const block of result.output) if (block.type === "image") image(block);
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
`input` can also contain `{ type: "image", data, mimeType }` blocks to edit or use as references. Pi adds the usage of a script's image calls to the `codemode` tool result, like classifier calls. Generated images are not saved to disk. [Codemode](codemode.md#generate-images) describes the full API.
|
|
186
|
+
|
|
187
|
+
Extensions generate images through `ctx.modelRegistry.generateImages()`, without codemode.
|
|
188
|
+
|
|
189
|
+
## Add a custom provider
|
|
190
|
+
|
|
191
|
+
Use an extension when the provider needs custom streaming, model discovery, or authentication behavior. See [Custom Providers](custom-provider.md) for the extension workflow.
|
|
192
|
+
|
|
193
|
+
## Troubleshooting
|
|
194
|
+
|
|
195
|
+
### A model does not appear
|
|
196
|
+
|
|
197
|
+
Confirm that its provider has usable authentication. Custom models can load from `models.json` but remain unavailable in `/model` until Pi can resolve credentials. For llama.cpp, only models currently loaded by the router appear.
|
|
198
|
+
|
|
199
|
+
### Authentication works in one shell only
|
|
200
|
+
|
|
201
|
+
Check whether the key came from an environment variable rather than `auth.json`. Environment variables must be present in the process that starts Pi.
|
|
202
|
+
|
|
203
|
+
### Sign-in opens a browser on a remote machine
|
|
204
|
+
|
|
205
|
+
Complete the provider's headless authentication flow when available. Some providers let you paste the final redirect URL or authorization code back into Pi. See [Authenticate interactively](providers.md#authenticate-interactively).
|
|
206
|
+
|
|
207
|
+
### A compatible endpoint rejects requests
|
|
208
|
+
|
|
209
|
+
Check its API type and compatibility settings in `models.json`. The upstream server must support the corresponding request fields and behavior.
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
> Source: [https://pi.dev/](https://pi.dev/)
|
|
2
|
+
> Retrieved with Firecrawl: 2026-10-05.
|
|
3
|
+
|
|
4
|
+
Click here to add it to your calendar: [add to calendar](https://pi.dev/)
|
|
5
|
+
|
|
6
|
+
Here we ask Pi to build a custom workflow extension with custom TUI to streamline the commit and push process.
|
|
7
|
+
|
|
8
|
+
This is just a small selection of models you can pick from.
|
|
9
|
+
|
|
10
|
+
You can rewind to any prior message, branch from there and share the entire session with others.
|
|
11
|
+
|
|
12
|
+
Pi supports skills, AGENTS.md files and is very token efficient due to its minimal system prompt.
|
|
13
|
+
|
|
14
|
+
Press Enter to steer the current run immediately, or Alt+Enter to queue a follow-up once it finishes.
|
|
15
|
+
|
|
16
|
+
We use the Pi TUI here to build a Pi based shell script that uses print mode.
|
|
17
|
+
|
|
18
|
+
This demonstrates a more heavily customized Pi installation using the third-party extension [@termdraw/pi](https://github.com/benvinegar/termdraw/) by [Ben Vinegar](https://github.com/benvinegar/) that lets you draw.
|
|
19
|
+
|
|
20
|
+
$ scroll to continue
|
|
21
|
+
|
|
22
|
+
Pi - Make it yours
|
|
23
|
+
|
|
24
|
+
## Why Pi?
|
|
25
|
+
|
|
26
|
+
Pi - manipulate the website
|
|
27
|
+
|
|
28
|
+
Pi is a minimal agent harness. Adapt Pi to your workflows, not the other way around. Customize Pi with [extensions](https://github.com/earendil-works/pi/tree/main/packages/coding-agent#extensions), [skills](https://github.com/earendil-works/pi/tree/main/packages/coding-agent#skills), [prompt templates](https://github.com/earendil-works/pi/tree/main/packages/coding-agent#prompt-templates), and [themes](https://github.com/earendil-works/pi/tree/main/packages/coding-agent#themes). Bundle them as [Pi packages](https://pi.dev/packages) and share via npm or git.
|
|
29
|
+
|
|
30
|
+
Pi ships with powerful defaults but skips features like sub-agents and plan mode. Ask Pi to build what you want, or install a package that does it your way.
|
|
31
|
+
|
|
32
|
+
Four modes: interactive, print/JSON, [RPC, and SDK](https://github.com/earendil-works/pi/tree/main/packages/coding-agent#programmatic-usage). See [OpenClaw](https://github.com/OpenClaw/OpenClaw) for a real-world integration.
|
|
33
|
+
|
|
34
|
+
[Read the documentation](https://pi.dev/docs/latest)
|
|
35
|
+
|
|
36
|
+
## Change the harness, not your workflow
|
|
37
|
+
|
|
38
|
+
Pi - Build a custom workflow extension
|
|
39
|
+
|
|
40
|
+
Pi isn't a sealed product. If you need a command, tool, provider, workflow, or UI tweak, just ask Pi to build it. It will customize itself on the fly.
|
|
41
|
+
|
|
42
|
+
Have Pi manipulate itself in place, hit `/reload`, and keep going. If you think others will find what you built useful, share it!
|
|
43
|
+
|
|
44
|
+
## 15+ providers, hundreds of models
|
|
45
|
+
|
|
46
|
+
Pi - Switch models mid-session
|
|
47
|
+
|
|
48
|
+
Anthropic, OpenAI, Google, Azure, Bedrock, Mistral, Groq, Cerebras, xAI, Hugging Face, Kimi For Coding, MiniMax, NVIDIA, OpenRouter, Ollama, and more. Authenticate via API keys or OAuth.
|
|
49
|
+
|
|
50
|
+
Switch models mid-session with `/model` or `Ctrl+L`. Cycle through your favorites with `Ctrl+P`.
|
|
51
|
+
|
|
52
|
+
Add custom providers and models via [models.json](https://github.com/earendil-works/pi/tree/main/packages/coding-agent/docs/models.md) or [extensions](https://github.com/earendil-works/pi/tree/main/packages/coding-agent/docs/custom-provider.md).
|
|
53
|
+
|
|
54
|
+
## Tree-structured, shareable history
|
|
55
|
+
|
|
56
|
+
Pi - Branch and share a session tree
|
|
57
|
+
|
|
58
|
+
Sessions are stored as trees. Use `/tree` to navigate to any previous point and continue from there. All branches live in a single file. Filter by message type, label entries as bookmarks.
|
|
59
|
+
|
|
60
|
+
Export to HTML with `/export`, or upload to a GitHub gist with `/share` and get a shareable URL that renders it. [Example session](https://pi.dev/session/#0ea51497613daf7e1de28ee99950b074).
|
|
61
|
+
|
|
62
|
+
## Context engineering
|
|
63
|
+
|
|
64
|
+
Pi - Load project skills and instructions
|
|
65
|
+
|
|
66
|
+
Pi's [minimal system prompt](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/system-prompt.ts) and extensibility let you do actual context engineering. Control what goes into the context window and how it's managed.
|
|
67
|
+
|
|
68
|
+
**AGENTS.md:** Project instructions loaded at startup from `~/.pi/agent/`, parent directories, and the current directory.
|
|
69
|
+
|
|
70
|
+
**SYSTEM.md:** Replace or append to the default system prompt per-project.
|
|
71
|
+
|
|
72
|
+
**Compaction:** Auto-summarizes older messages when approaching the context limit. Fully customizable via [extensions](https://github.com/earendil-works/pi/tree/main/packages/coding-agent/examples/extensions/custom-compaction.ts): implement topic-based compaction, code-aware summaries, or use different summarization models.
|
|
73
|
+
|
|
74
|
+
**Skills:** Capability packages with instructions and tools, loaded on-demand. Progressive disclosure without busting the prompt cache. See [skills](https://github.com/earendil-works/pi/tree/main/packages/coding-agent#skills).
|
|
75
|
+
|
|
76
|
+
**Prompt templates:** Reusable prompts as Markdown files. Type `/name` to expand. See [prompt templates](https://github.com/earendil-works/pi/tree/main/packages/coding-agent#prompt-templates).
|
|
77
|
+
|
|
78
|
+
**Dynamic context:** [Extensions](https://github.com/earendil-works/pi/tree/main/packages/coding-agent#extensions) can inject messages before each turn, filter the message history, implement RAG, or build long-term memory.
|
|
79
|
+
|
|
80
|
+
## Steer or follow up
|
|
81
|
+
|
|
82
|
+
Pi - Steer a running agent
|
|
83
|
+
|
|
84
|
+
Submit messages while the agent works. `Enter` sends a steering message (delivered after current tool, interrupts remaining tools). `Alt+Enter`sends a follow-up (waits until the agent finishes).
|
|
85
|
+
|
|
86
|
+
## Four modes
|
|
87
|
+
|
|
88
|
+
Pi - Generate a shell script in print mode
|
|
89
|
+
|
|
90
|
+
**Interactive:** The full TUI experience.
|
|
91
|
+
|
|
92
|
+
**Print/JSON:**`pi -p "query"` for scripts, `--mode json` for event streams.
|
|
93
|
+
|
|
94
|
+
**RPC:** JSON protocol over stdin/stdout for non-Node integrations. See [docs/rpc.md](https://github.com/earendil-works/pi/tree/main/packages/coding-agent/docs/rpc.md).
|
|
95
|
+
|
|
96
|
+
**SDK:** Embed Pi in your apps. See [OpenClaw](https://github.com/OpenClaw/OpenClaw) for a real-world example.
|
|
97
|
+
|
|
98
|
+
## Primitives, not features
|
|
99
|
+
|
|
100
|
+
Pi - Install a third-party extension
|
|
101
|
+
|
|
102
|
+
Features that other agents bake in, you can build yourself. Extensions are TypeScript modules with access to tools, commands, keyboard shortcuts, events, and the full TUI.
|
|
103
|
+
|
|
104
|
+
[Sub-agents](https://github.com/earendil-works/pi/tree/main/packages/coding-agent/examples/extensions/subagent/), [plan mode](https://github.com/earendil-works/pi/tree/main/packages/coding-agent/examples/extensions/plan-mode/), [permission gates](https://github.com/earendil-works/pi/tree/main/packages/coding-agent/examples/extensions/permission-gate.ts), [path protection](https://github.com/earendil-works/pi/tree/main/packages/coding-agent/examples/extensions/protected-paths.ts), [SSH execution](https://github.com/earendil-works/pi/tree/main/packages/coding-agent/examples/extensions/ssh.ts), [sandboxing](https://github.com/earendil-works/pi/tree/main/packages/coding-agent/examples/extensions/sandbox/), MCP integrations (still supported alongside built-in MCP), custom editors, status bars, overlays.
|
|
105
|
+
|
|
106
|
+
Don't want to build it? Ask Pi to build it for you. Or install a [package](https://pi.dev/packages) that does it your way. See the [50+ examples](https://github.com/earendil-works/pi/tree/main/packages/coding-agent/examples/extensions/).
|
|
107
|
+
|
|
108
|
+
Bundle extensions, skills, prompts, and themes as packages. Install from npm or git:
|
|
109
|
+
|
|
110
|
+
`$ pi install npm:@foo/pi-tools
|
|
111
|
+
$ pi install git:github.com/badlogic/pi-doom`
|
|
112
|
+
|
|
113
|
+
[Browse packages](https://pi.dev/packages)
|
|
114
|
+
|
|
115
|
+
[and it can play doom](https://pi.dev/#)
|
|
116
|
+
|
|
117
|
+
Fig. 01 \| DOOM EXTENSION
|
|
118
|
+
|
|
119
|
+
- ### ~~No MCP~~ Now with MCP+Codemode
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
MCP is built in, and Codemode lets agents compose tool calls in a JavaScript sandbox. MCP extensions are still supported too. [Why we changed our minds](https://earendil.com/posts/you-said-no-mcp/)
|
|
123
|
+
|
|
124
|
+
- ### No sub-agents
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
Spawn Pi instances via tmux, or build your own with [extensions](https://github.com/earendil-works/pi/tree/main/packages/coding-agent#extensions), or install a package that does it your way.
|
|
128
|
+
|
|
129
|
+
- ### No permission popups
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
Run in a container, or build your own confirmation flow with [extensions](https://github.com/earendil-works/pi/tree/main/packages/coding-agent#extensions) inline with your environment and security requirements.
|
|
133
|
+
|
|
134
|
+
- ### No plan mode
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
Write plans to files, or build it with [extensions](https://github.com/earendil-works/pi/tree/main/packages/coding-agent#extensions), or install a package.
|
|
138
|
+
|
|
139
|
+
- ### No built-in to-dos
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
Use a TODO.md file, or build your own with [extensions](https://github.com/earendil-works/pi/tree/main/packages/coding-agent#extensions).
|
|
143
|
+
|
|
144
|
+
- ### No background bash
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
Use tmux. Full observability, direct interaction.
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
- ### Issues
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
[GitHub](https://github.com/earendil-works/pi/issues) for bugs and features.
|
|
155
|
+
|
|
156
|
+
- ### Discord
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
[Community server](https://discord.com/invite/nKXTsAcmbT) for discussion and sharing.
|
|
161
|
+
|
|
162
|
+
- ### Documentation
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
[Read the documentation](https://pi.dev/docs/latest) or browse the [source on GitHub](https://github.com/earendil-works/pi/tree/main/packages/coding-agent/docs).
|