@earendil-works/pi-coding-agent 0.99.2 → 1.0.1
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/CHANGELOG.md +90 -0
- package/README.md +32 -7
- package/dist/bundle/chunks/{anthropic-messages-UID2PALB.js → anthropic-messages-GXHZP2HL.js} +3 -3
- package/dist/bundle/chunks/anthropic.js +2 -2
- package/dist/bundle/chunks/{azure-openai-responses-TLHNIYZK.js → azure-openai-responses-AFMVM6NP.js} +1 -1
- package/dist/bundle/chunks/bedrock-converse-stream.js +1 -1
- package/dist/bundle/chunks/chunk-2KAZSACP.js +2 -0
- package/dist/bundle/chunks/{chunk-R5J3MOBF.js → chunk-2VNGUWBO.js} +1 -1
- package/dist/bundle/chunks/chunk-5OEJBNHG.js +1203 -0
- package/dist/bundle/chunks/{chunk-7QSPBJKW.js → chunk-6FX7UEPL.js} +16 -30
- package/dist/bundle/chunks/chunk-F5ZABL6Z.js +20 -0
- package/dist/bundle/chunks/chunk-FDW3AYMM.js +2 -0
- package/dist/bundle/chunks/chunk-OYBSLV7Y.js +16 -0
- package/dist/bundle/chunks/{chunk-45SXDISG.js → chunk-PDFMCAOZ.js} +5 -5
- package/dist/bundle/chunks/{chunk-G3UZ5FWD.js → chunk-SYF2TF6W.js} +11 -60
- package/dist/bundle/chunks/chunk-WCQZGZ6I.js +82 -0
- package/dist/bundle/chunks/chunk-ZSI3BL5Q.js +4 -0
- package/dist/bundle/chunks/{cli-ALNBTL3U.js → cli-KILDDGW3.js} +4 -4
- package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-NPQN263E.js → cloudflare-workers-ai-system-one-X5PVWWYJ.js} +1 -1
- package/dist/bundle/chunks/codemode-worker.js +68 -8
- package/dist/bundle/chunks/easter-egg-3d-T5FFWIBR.js +2 -0
- package/dist/bundle/chunks/execute-RYVK27GT.js +388 -0
- package/dist/bundle/chunks/node-N5BSDOA5.js +16 -0
- package/dist/bundle/chunks/openai-chatgpt.js +2 -2
- package/dist/bundle/chunks/{openai-codex-responses-3GKGNXC4.js → openai-codex-responses-GK67DQQJ.js} +1 -1
- package/dist/bundle/chunks/openai-codex.js +1 -1
- package/dist/bundle/chunks/{openai-responses-S7GKCCDG.js → openai-responses-CQDDLDQF.js} +1 -1
- package/dist/bundle/chunks/openrouter.js +1 -1
- package/dist/bundle/chunks/radius.js +1 -1
- package/dist/bundle/chunks/runtime-D5I2NTIF.js +2 -0
- package/dist/bundle/chunks/virtual-modules-OO3V5ZPE.js +2 -0
- package/dist/bundle/cli-runtime.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +6 -3
- package/dist/cli/args.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +3 -0
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts +8 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +38 -9
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/export-html/tool-renderer.d.ts +3 -3
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
- package/dist/core/export-html/tool-renderer.js +3 -3
- package/dist/core/export-html/tool-renderer.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +5 -0
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +3 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +6 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +9 -0
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/mcp-servers.d.ts +12 -0
- package/dist/core/mcp-servers.d.ts.map +1 -1
- package/dist/core/mcp-servers.js +18 -0
- package/dist/core/mcp-servers.js.map +1 -1
- package/dist/core/model-registry.d.ts +3 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +4 -0
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.js +1 -1
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/radius.d.ts +2 -0
- package/dist/core/radius.d.ts.map +1 -1
- package/dist/core/radius.js +2 -0
- package/dist/core/radius.js.map +1 -1
- package/dist/core/settings-manager.d.ts +7 -5
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +3 -2
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/system-prompt.js +1 -1
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +3 -5
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/renderers/index.d.ts +2 -2
- package/dist/core/tools/renderers/index.d.ts.map +1 -1
- package/dist/core/tools/renderers/index.js.map +1 -1
- package/dist/extensions/codemode/execute.d.ts.map +1 -1
- package/dist/extensions/codemode/execute.js +154 -47
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/codemode/tool.d.ts +7 -7
- package/dist/extensions/codemode/tool.d.ts.map +1 -1
- package/dist/extensions/codemode/tool.js +55 -102
- package/dist/extensions/codemode/tool.js.map +1 -1
- package/dist/extensions/mcp/cli.d.ts.map +1 -1
- package/dist/extensions/mcp/cli.js +5 -2
- package/dist/extensions/mcp/cli.js.map +1 -1
- package/dist/extensions/mcp/config.d.ts +15 -3
- package/dist/extensions/mcp/config.d.ts.map +1 -1
- package/dist/extensions/mcp/config.js +46 -10
- package/dist/extensions/mcp/config.js.map +1 -1
- package/dist/extensions/mcp/index.d.ts +4 -1
- package/dist/extensions/mcp/index.d.ts.map +1 -1
- package/dist/extensions/mcp/index.js +97 -51
- package/dist/extensions/mcp/index.js.map +1 -1
- package/dist/extensions/mcp/oauth.d.ts +12 -8
- package/dist/extensions/mcp/oauth.d.ts.map +1 -1
- package/dist/extensions/mcp/oauth.js +104 -35
- package/dist/extensions/mcp/oauth.js.map +1 -1
- package/dist/extensions/mcp/runtime.d.ts.map +1 -1
- package/dist/extensions/mcp/runtime.js +3 -1
- package/dist/extensions/mcp/runtime.js.map +1 -1
- package/dist/extensions/mcp/tools.d.ts +3 -1
- package/dist/extensions/mcp/tools.d.ts.map +1 -1
- package/dist/extensions/mcp/tools.js +19 -13
- package/dist/extensions/mcp/tools.js.map +1 -1
- package/dist/extensions/mcp/ui.d.ts.map +1 -1
- package/dist/extensions/mcp/ui.js +8 -4
- package/dist/extensions/mcp/ui.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +6 -0
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/armin.d.ts +3 -0
- package/dist/modes/interactive/components/armin.d.ts.map +1 -1
- package/dist/modes/interactive/components/armin.js +7 -5
- package/dist/modes/interactive/components/armin.js.map +1 -1
- package/dist/modes/interactive/components/auth-url.d.ts +14 -0
- package/dist/modes/interactive/components/auth-url.d.ts.map +1 -0
- package/dist/modes/interactive/components/auth-url.js +37 -0
- package/dist/modes/interactive/components/auth-url.js.map +1 -0
- package/dist/modes/interactive/components/easter-egg-3d.d.ts +104 -0
- package/dist/modes/interactive/components/easter-egg-3d.d.ts.map +1 -0
- package/dist/modes/interactive/components/easter-egg-3d.js +1139 -0
- package/dist/modes/interactive/components/easter-egg-3d.js.map +1 -0
- package/dist/modes/interactive/components/easter-egg-3d.lazy.d.ts +6 -0
- package/dist/modes/interactive/components/easter-egg-3d.lazy.d.ts.map +1 -0
- package/dist/modes/interactive/components/easter-egg-3d.lazy.js +23 -0
- package/dist/modes/interactive/components/easter-egg-3d.lazy.js.map +1 -0
- package/dist/modes/interactive/components/index.d.ts +0 -1
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js +0 -1
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +2 -0
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +11 -5
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +8 -2
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +24 -21
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/pi-logo.d.ts +7 -0
- package/dist/modes/interactive/components/pi-logo.d.ts.map +1 -1
- package/dist/modes/interactive/components/pi-logo.js +13 -1
- package/dist/modes/interactive/components/pi-logo.js.map +1 -1
- package/dist/modes/interactive/components/radius-login-selector.d.ts +15 -0
- package/dist/modes/interactive/components/radius-login-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/radius-login-selector.js +85 -0
- package/dist/modes/interactive/components/radius-login-selector.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +3 -3
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +5 -5
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +6 -18
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +22 -45
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +5 -4
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +12 -2
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +166 -55
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/system-theme.d.ts +2 -1
- package/dist/modes/interactive/theme/system-theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/system-theme.js +16 -5
- package/dist/modes/interactive/theme/system-theme.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +12 -0
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/image-convert.d.ts +12 -0
- package/dist/utils/image-convert.d.ts.map +1 -1
- package/dist/utils/image-convert.js +45 -6
- package/dist/utils/image-convert.js.map +1 -1
- package/docs/cli.md +8 -16
- package/docs/codemode.md +207 -0
- package/docs/docs.json +5 -1
- package/docs/environment-variables.md +2 -2
- package/docs/extensions.md +4 -0
- package/docs/index.md +1 -1
- package/docs/keybindings.md +1 -1
- package/docs/mcp.md +40 -1
- package/docs/models.md +24 -3
- package/docs/providers.md +16 -6
- package/docs/quickstart.md +16 -2
- package/docs/sdk.md +1 -1
- package/docs/settings.md +3 -3
- package/docs/usage.md +1 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/package.json +13 -14
- package/dist/bundle/chunks/chunk-3KYEVQKX.js +0 -82
- package/dist/bundle/chunks/chunk-3NVH2HQH.js +0 -4
- package/dist/bundle/chunks/chunk-3YAHQSW6.js +0 -1438
- package/dist/bundle/chunks/chunk-DTD7JQ7Y.js +0 -42
- package/dist/bundle/chunks/chunk-ECRK44UV.js +0 -2
- package/dist/bundle/chunks/execute-RC7W4ML3.js +0 -328
- package/dist/bundle/chunks/node-O3RIBJRH.js +0 -16
- package/dist/bundle/chunks/runtime-NJPX4ID2.js +0 -2
- package/dist/bundle/chunks/virtual-modules-5UGH4HRZ.js +0 -2
- package/dist/modes/interactive/components/daxnuts.d.ts +0 -23
- package/dist/modes/interactive/components/daxnuts.d.ts.map +0 -1
- package/dist/modes/interactive/components/daxnuts.js +0 -140
- package/dist/modes/interactive/components/daxnuts.js.map +0 -1
- package/npm-shrinkwrap.json +0 -1957
package/docs/codemode.md
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# Codemode
|
|
2
|
+
|
|
3
|
+
The `codemode` tool lets the model write a JavaScript script that calls pi's other tools and runs non-LLM models, such as classifiers and image models. Only the script's output reaches the model, so a script can run calls in parallel and filter large results before the model sees them. To turn it on, see [Enable codemode](cli.md#enable-codemode).
|
|
4
|
+
|
|
5
|
+
## Scripts
|
|
6
|
+
|
|
7
|
+
The tool input is raw JavaScript source, not JSON and not a markdown code fence. It runs as the body of an async function in a QuickJS sandbox, so top-level `await` and `return` work. The sandbox has no Node APIs, file system, network, or timers; scripts reach the outside world only through tools and `models`.
|
|
8
|
+
|
|
9
|
+
A script may start with an options line:
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
// @options: {"max_output_tokens": 2000, "timeout_ms": 60000}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
- `max_output_tokens` (default 10000) limits the output. Longer output keeps its start and end, and the full text is written to a temp file whose path is included in the result. A script fails when its output passes 16777216 characters of text and base64 image data or 100000 `text()`, `image()`, and `console` calls; write large data to a file with a tool instead.
|
|
16
|
+
- `timeout_ms` is a hard deadline for the whole script. It is unset by default. Image generation can take minutes, so do not set a short deadline for scripts that generate images.
|
|
17
|
+
|
|
18
|
+
The result starts with `Script completed` or `Script failed`, the wall time, and the output. A failed script keeps its partial output, followed by `Script error:` and the error. Tool calls are real: calls made before a failure are not undone. Calls still running when the script ends are cancelled, and unawaited promises are discarded.
|
|
19
|
+
|
|
20
|
+
## Globals
|
|
21
|
+
|
|
22
|
+
| Global | Purpose |
|
|
23
|
+
|---|---|
|
|
24
|
+
| `tools.<name>(args)` | Call a tool. See [Call tools](#call-tools). |
|
|
25
|
+
| `text(value)` | Add a text item to the output. Strings are added as is, other values as JSON. |
|
|
26
|
+
| `image(value)` | Add an image to the output: a base64 `data:` URL, an `{ image_url }` object, or an image block `{ type: "image", data, mimeType }` such as those returned by MCP tools and `models.generateImages()`. Remote URLs are not supported. PNG, JPEG, GIF, and WebP are accepted. |
|
|
27
|
+
| `console.log(...)` | Like `text()`; `info`, `warn`, `error`, and `debug` do the same. |
|
|
28
|
+
| `return value` | A top-level `return` adds the value like `text()`. |
|
|
29
|
+
| `exit()` | End the script successfully. |
|
|
30
|
+
| `store(key, value)` / `load(key)` | Keep small JSON values across `codemode` calls. See [Store values](#store-values). |
|
|
31
|
+
| `ALL_TOOLS` | Every callable tool as `{ name, description }`, including tools the description does not list. |
|
|
32
|
+
| `searchTools(query, { limit?, namespace? })` | Rank callable tools by relevance (BM25, default limit 8). Resolves to `{ name, description }[]`. |
|
|
33
|
+
| `describeTool(name)` | Resolves to a tool's description and TypeScript declaration, or `undefined`. |
|
|
34
|
+
| `describeNamespace(name)` | Resolves to `{ name, description?, instructions?, tools }` for a namespace such as an MCP server, or `undefined`. |
|
|
35
|
+
| `models` | List and run non-LLM models. See [Models](#models). |
|
|
36
|
+
|
|
37
|
+
## Call tools
|
|
38
|
+
|
|
39
|
+
Every tool the session can call is a method of `tools`, named by its identifier: characters that are not valid in a JavaScript identifier become `_`, so the MCP tool `mcp__dev-radius__search` is `tools.mcp__dev_radius__search`. Each method takes one object with the tool's arguments.
|
|
40
|
+
|
|
41
|
+
What a call resolves to depends on the tool:
|
|
42
|
+
|
|
43
|
+
- Tools with an output schema resolve to a structured value. `bash` resolves to `{ output, truncated, full_output_path?, exit_code, wall_time_seconds }`, also for non-zero exit codes. Its `output` is not limited to the 2000 lines or 50KB the model sees: it holds up to 1 MiB, and longer output keeps its first and last 512 KiB around an omission marker, with `truncated` set and the full output in `full_output_path`.
|
|
44
|
+
- MCP tools resolve to their `CallToolResult`, including `isError` and `structuredContent`.
|
|
45
|
+
- Other tools, such as `read`, `edit`, and `write`, resolve to their text output.
|
|
46
|
+
|
|
47
|
+
A call that fails, is blocked, or gets invalid arguments rejects with an `Error` that carries the tool's error text. Use `Promise.allSettled()` to keep the results of the calls that succeed.
|
|
48
|
+
|
|
49
|
+
The `codemode` description lists tools with their TypeScript declarations, grouped by namespace (for example one MCP server). Tools with `deferred` exposure, which includes MCP tools with the default `codemode` exposure, are not listed, so the description stays the same while MCP servers connect. Listed declarations share a budget of 3000 estimated tokens (`codemode.inlineBudget` in [settings](settings.md#tools)). Scripts find the other tools with `searchTools()`, `describeTool()`, `describeNamespace()`, or by filtering `ALL_TOOLS`.
|
|
50
|
+
|
|
51
|
+
While `codemode` is active, `codemode.mode` in [settings](settings.md#tools) decides how the other tools are presented. With `on` (default) declared tools stay declared, and their descriptions say how to call them from scripts. With `only` they are hidden from the model and listed in the `codemode` description instead, so the model calls them through scripts.
|
|
52
|
+
|
|
53
|
+
## Store values
|
|
54
|
+
|
|
55
|
+
`store(key, value)` keeps a JSON value under a string key for later `codemode` calls; storing `undefined` deletes the key. `load(key)` returns the value, or `undefined`. Writes are kept only when the script succeeds: each successful script that stores values appends a `codemode-store` custom entry to the session, so resumed sessions keep the values and each branch sees only the values written on its path.
|
|
56
|
+
|
|
57
|
+
The store is for small state such as IDs, cursors, or summaries. One value may have at most 262144 characters of JSON and all values together at most 1048576. Do not store image data; show images with `image()` or write them to a file with a tool.
|
|
58
|
+
|
|
59
|
+
## Models
|
|
60
|
+
|
|
61
|
+
`models` reaches the model catalog and runs non-LLM models with the session's credentials: classifiers, which answer typed questions about JSON state, and image models, which generate images. Chat models are listed but cannot be run from scripts. Which classifier and image models exist is described in [Use classifier models](models.md#use-classifier-models) and [Use image models](models.md#use-image-models).
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
type ModelType = "chat" | "image" | "classifier";
|
|
65
|
+
|
|
66
|
+
/** A catalog entry. `provider` and `id` identify it; other fields depend on the type. */
|
|
67
|
+
interface ModelInfo {
|
|
68
|
+
type?: ModelType;
|
|
69
|
+
provider: string;
|
|
70
|
+
id: string;
|
|
71
|
+
name: string;
|
|
72
|
+
api: string;
|
|
73
|
+
input: ("text" | "image")[];
|
|
74
|
+
contextWindow?: number;
|
|
75
|
+
[key: string]: unknown;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
declare const models: {
|
|
79
|
+
/** Every known model of a type, optionally for one provider. */
|
|
80
|
+
getModelsOfType(type: ModelType, provider?: string): Promise<ModelInfo[]>;
|
|
81
|
+
/** Models of a type whose provider has working credentials. */
|
|
82
|
+
getAvailableOfType(type: ModelType, provider?: string): Promise<ModelInfo[]>;
|
|
83
|
+
/** One catalog entry, or undefined. */
|
|
84
|
+
getModelOfType(type: ModelType, provider: string, id: string): Promise<ModelInfo | undefined>;
|
|
85
|
+
/** Answer `context.questions` about `context.state`; answers are in `result.answers` by question ID. */
|
|
86
|
+
classify(model: ModelInfo, context: ClassifierContext): Promise<ClassifierResult>;
|
|
87
|
+
/** Generate images from `context.input` text and image blocks; show `result.output` blocks with image(). Can take minutes. */
|
|
88
|
+
generateImages(model: ModelInfo, context: ImagesContext): Promise<ImagesResult>;
|
|
89
|
+
};
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
`classify()` and `generateImages()` use only the `provider` and `id` of `model`, so `{ provider, id }` works as well. They do not throw on provider errors: check `stopReason` and `errorMessage`. At most four such calls run at once per script; more calls wait for a free slot, so `Promise.all()` over many items is fine. Their usage is added to the `codemode` tool result and counts toward the session cost.
|
|
93
|
+
|
|
94
|
+
Model IDs differ between providers, for example `typesafe/jev-latest` and `openrouter/typesafe/jev-1.13`. Use `models.getAvailableOfType(type)` to find the IDs that work with the current credentials.
|
|
95
|
+
|
|
96
|
+
### Classify
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
interface ClassifierContext {
|
|
100
|
+
/** The data to classify. */
|
|
101
|
+
state: Record<string, unknown>;
|
|
102
|
+
/** Questions by ID. One call answers all of them. */
|
|
103
|
+
questions: Record<string, ClassifierQuestion>;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
type ClassifierQuestion =
|
|
107
|
+
/** Pick one label. `criteria` maps each label to what it means. */
|
|
108
|
+
| { type: "choice"; instructions: string; criteria: Record<string, string> }
|
|
109
|
+
/** Score on an ordered scale. `criteria` describes each level, lowest first. */
|
|
110
|
+
| { type: "score"; instructions: string; criteria: string[] }
|
|
111
|
+
/** Yes or no. */
|
|
112
|
+
| { type: "bool"; instructions: string; criteria: { true: string; false: string } };
|
|
113
|
+
|
|
114
|
+
interface ClassifierResult {
|
|
115
|
+
provider: string;
|
|
116
|
+
model: string;
|
|
117
|
+
/** Answers by question ID. */
|
|
118
|
+
answers: Record<string, ClassifierAnswer>;
|
|
119
|
+
usage?: ModelUsage;
|
|
120
|
+
stopReason: "stop" | "error" | "aborted";
|
|
121
|
+
errorMessage?: string;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
type ClassifierAnswer =
|
|
125
|
+
| { type: "choice"; choice: string; probabilities: Record<string, number>; confidence: number }
|
|
126
|
+
/** `score` is the expected level index, from 0 to `criteria.length - 1`. */
|
|
127
|
+
| { type: "score"; score: number; confidence: number }
|
|
128
|
+
/** Probability of `true`. */
|
|
129
|
+
| { type: "bool"; probability: number };
|
|
130
|
+
|
|
131
|
+
/** Token counts and cost in USD, when the service reports them. */
|
|
132
|
+
type ModelUsage = { input: number; output: number; totalTokens: number; cost: { total: number } };
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Classify several items by calling `classify()` once per item. This script sorts feedback messages, for example ones a tool returned earlier in the script:
|
|
136
|
+
|
|
137
|
+
```js
|
|
138
|
+
const jev = await models.getModelOfType("classifier", "typesafe", "jev-latest");
|
|
139
|
+
const results = await Promise.all(
|
|
140
|
+
messages.map((message) =>
|
|
141
|
+
models.classify(jev, {
|
|
142
|
+
state: { message },
|
|
143
|
+
questions: {
|
|
144
|
+
sentiment: {
|
|
145
|
+
type: "choice",
|
|
146
|
+
instructions: "How does the user feel about the product?",
|
|
147
|
+
criteria: { positive: "Satisfied or happy", negative: "Unhappy or frustrated", neutral: "Neither" },
|
|
148
|
+
},
|
|
149
|
+
urgency: {
|
|
150
|
+
type: "score",
|
|
151
|
+
instructions: "How urgently does this need a reply?",
|
|
152
|
+
criteria: ["no reply needed", "reply this week", "reply today"],
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
}),
|
|
156
|
+
),
|
|
157
|
+
);
|
|
158
|
+
return results.map((result, i) =>
|
|
159
|
+
result.stopReason === "stop"
|
|
160
|
+
? { message: messages[i], sentiment: result.answers.sentiment.choice, urgency: result.answers.urgency.score }
|
|
161
|
+
: { message: messages[i], error: result.errorMessage },
|
|
162
|
+
);
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Generate images
|
|
166
|
+
|
|
167
|
+
```ts
|
|
168
|
+
interface ImagesContext {
|
|
169
|
+
/** The prompt as text blocks, plus image blocks to edit or use as references. */
|
|
170
|
+
input: (TextBlock | ImageBlock)[];
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
interface ImagesResult {
|
|
174
|
+
provider: string;
|
|
175
|
+
model: string;
|
|
176
|
+
/** Generated images, and text blocks for models that also return text. */
|
|
177
|
+
output: (TextBlock | ImageBlock)[];
|
|
178
|
+
usage?: ModelUsage;
|
|
179
|
+
stopReason: "stop" | "error" | "aborted";
|
|
180
|
+
errorMessage?: string;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
type TextBlock = { type: "text"; text: string };
|
|
184
|
+
/** `data` is base64. */
|
|
185
|
+
type ImageBlock = { type: "image"; data: string; mimeType: string };
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Show generated images with `image(block)`. Do not print `data` with `text()`, `console`, or `return`: it is large and the model cannot read it as text. Generated images are not saved to disk; to keep one, write it to a file with a tool.
|
|
189
|
+
|
|
190
|
+
```js
|
|
191
|
+
// @options: {"timeout_ms": 300000}
|
|
192
|
+
const painter = await models.getModelOfType("image", "openrouter", "google/gemini-2.5-flash-image");
|
|
193
|
+
const result = await models.generateImages(painter, {
|
|
194
|
+
input: [{ type: "text", text: "A red fox in the snow, watercolor" }],
|
|
195
|
+
});
|
|
196
|
+
if (result.stopReason !== "stop") return result.errorMessage;
|
|
197
|
+
for (const block of result.output) {
|
|
198
|
+
if (block.type === "image") image(block);
|
|
199
|
+
else text(block.text);
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Limits
|
|
204
|
+
|
|
205
|
+
- A script's VM has 256 MB of memory. Running out throws `InternalError: out of memory`; filter or aggregate large data instead of accumulating it.
|
|
206
|
+
- A script that waits on a promise that can never settle (no tool call pending) fails immediately, since there are no timers.
|
|
207
|
+
- Scripts cannot start other `codemode` scripts.
|
package/docs/docs.json
CHANGED
|
@@ -136,6 +136,10 @@
|
|
|
136
136
|
"title": "CLI",
|
|
137
137
|
"path": "cli.md"
|
|
138
138
|
},
|
|
139
|
+
{
|
|
140
|
+
"title": "Codemode",
|
|
141
|
+
"path": "codemode.md"
|
|
142
|
+
},
|
|
139
143
|
{
|
|
140
144
|
"title": "Slash Commands",
|
|
141
145
|
"path": "slash-commands.md"
|
|
@@ -153,7 +157,7 @@
|
|
|
153
157
|
"path": "keybindings.md"
|
|
154
158
|
},
|
|
155
159
|
{
|
|
156
|
-
"title": "
|
|
160
|
+
"title": "Providers",
|
|
157
161
|
"path": "providers.md"
|
|
158
162
|
},
|
|
159
163
|
{
|
|
@@ -6,7 +6,7 @@ Pi uses environment variables in three ways:
|
|
|
6
6
|
- Pi sets process markers so child processes can identify Pi as the launching agent.
|
|
7
7
|
- Commands run by the LLM-callable shell tools receive `PI_*` variables describing the current session.
|
|
8
8
|
|
|
9
|
-
Provider API-key variables are documented separately in [
|
|
9
|
+
Provider API-key variables are documented separately in [Providers](providers.md#use-an-api-key-from-the-environment).
|
|
10
10
|
|
|
11
11
|
## Process Marker
|
|
12
12
|
|
|
@@ -95,4 +95,4 @@ These variables are read by Pi itself:
|
|
|
95
95
|
| `VISUAL`, `EDITOR` | External editor fallback when `externalEditor` is unset |
|
|
96
96
|
| `HTTP_PROXY`, `HTTPS_PROXY` | Proxy outbound HTTP requests |
|
|
97
97
|
|
|
98
|
-
Provider credentials such as `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, and
|
|
98
|
+
Provider credentials such as `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, and provider-specific configuration are listed in [Providers](providers.md#use-an-api-key-from-the-environment).
|
package/docs/extensions.md
CHANGED
|
@@ -185,6 +185,10 @@ Register every tool first, keep optional tools inactive, and use `pi.setActiveTo
|
|
|
185
185
|
|
|
186
186
|
Pi records the initial prompt and tool set in the transcript's first system message, then appends tool and prompt changes before the next model request. Providers that cannot represent the transition receive a complete transcript checkpoint, which can invalidate the cached prefix.
|
|
187
187
|
|
|
188
|
+
### Tool rendering
|
|
189
|
+
|
|
190
|
+
A tool's `renderCall` and `renderResult` draw its calls in the interactive transcript and in HTML exports. `pi.registerToolRenderer((toolName, next) => renderers)` chooses renderers for calls to any tool, including tools that are not registered yet, such as MCP tools in a resumed session before their server connected. `next()` returns what the remaining resolvers (in extension load order), then the registered tool, would use, so `next() ?? mine` only fills in.
|
|
191
|
+
|
|
188
192
|
### MCP servers
|
|
189
193
|
|
|
190
194
|
`pi.registerMcpServer(name, config)` adds an MCP server for the current session. `config` has the shape of an `mcpServers` entry in [`mcp.json`](mcp.md): `command`, `args`, `env`, and `cwd` for stdio servers, `url`, `headers`, and `oauth` for HTTP servers, plus `exposure`, `toolExposure`, `description`, `enabled`, and `timeout`.
|
package/docs/index.md
CHANGED
|
@@ -30,7 +30,7 @@ Use the [Quickstart customization chooser](quickstart.md#choose-how-to-customize
|
|
|
30
30
|
|
|
31
31
|
## Find reference and setup information
|
|
32
32
|
|
|
33
|
-
Use the reference pages to look up [CLI options](cli.md), [settings](settings.md), [
|
|
33
|
+
Use the reference pages to look up [CLI options](cli.md), [settings](settings.md), [providers](providers.md), [keybindings](keybindings.md), and [environment variables](environment-variables.md).
|
|
34
34
|
|
|
35
35
|
For platform-specific help, see [Terminal Setup](terminal-setup.md), [Windows](windows.md), [tmux](tmux.md), [Termux on Android](termux.md), or [Containerization](containerization.md).
|
|
36
36
|
|
package/docs/keybindings.md
CHANGED
|
@@ -161,7 +161,7 @@ On native Windows, `app.suspend` has no default because Windows terminals do not
|
|
|
161
161
|
| Keybinding id | Default | Description |
|
|
162
162
|
|--------|---------|-------------|
|
|
163
163
|
| `app.tools.expand` | `ctrl+o` | Collapse or expand tool output |
|
|
164
|
-
| `app.message.copy` | `ctrl+x` | Copy the selected message in `/tree`; in fullscreen mode, copy the active selection when `fullscreenCopyOnSelect` is `false`; otherwise copy the last assistant message |
|
|
164
|
+
| `app.message.copy` | `ctrl+x` | Copy the selected message in `/tree`; in fullscreen mode, copy the active selection when `fullscreenCopyOnSelect` is `false`; otherwise copy the last assistant message. On OAuth sign-in screens, copy the sign-in URL |
|
|
165
165
|
| `app.message.followUp` | `alt+enter` (`ctrl+q` on Windows and WSL) | Queue follow-up message |
|
|
166
166
|
| `app.message.dequeue` | `alt+up` (`alt+q` on Windows and WSL) | Restore queued messages to editor |
|
|
167
167
|
|
package/docs/mcp.md
CHANGED
|
@@ -31,6 +31,16 @@ Use `/mcp` inside an interactive session to inspect connections, sign in, reconn
|
|
|
31
31
|
|
|
32
32
|
Pi reads user-level servers from `~/.pi/agent/mcp.json` and project servers from `.pi/mcp.json`. Project configuration is read only after [project trust](security.md#understand-project-trust) is granted. A project entry replaces a user-level entry with the same name.
|
|
33
33
|
|
|
34
|
+
A project entry without `command`, `url`, or `type` overrides only `enabled`, `exposure`, and `toolExposure` of the user-level server with the same name and keeps the rest, including `env`, `headers`, and `auth`. For example, this turns off a user-level server in one project:
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"mcpServers": {
|
|
39
|
+
"internal-tools": { "enabled": false }
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
34
44
|
The format matches other MCP clients:
|
|
35
45
|
|
|
36
46
|
```json
|
|
@@ -77,7 +87,7 @@ Keep personal servers and servers with credentials in the user-level file. Use t
|
|
|
77
87
|
|
|
78
88
|
`/mcp` lists configured servers with their state, tool count, exposure, and configuration source. Servers that need attention appear first. Select a server to inspect its tools and connection details, reconnect, sign in or out, change exposure, or enable and disable it.
|
|
79
89
|
|
|
80
|
-
Exposure and enabled-state changes are saved to the file that defines the server without replacing unrelated content. Disabled servers remain listed. Outside the interactive TUI, `/mcp` prints server status; `/mcp login <server>`, `/mcp logout <server>`, and `/mcp reconnect <server>` perform those actions directly.
|
|
90
|
+
Exposure and enabled-state changes are saved to the file that defines the server without replacing unrelated content. In a trusted project, "Enable in this project" and "Disable in this project" add a project override for a user-level server; later changes to that server are saved to the override. Disabled servers remain listed. Outside the interactive TUI, `/mcp` prints server status; `/mcp login <server>`, `/mcp logout <server>`, and `/mcp reconnect <server>` perform those actions directly.
|
|
81
91
|
|
|
82
92
|
Shell commands work without a session: `pi mcp add`, `pi mcp remove`, `pi mcp list`, `pi mcp login`, and `pi mcp logout`. Shell commands do not load extensions.
|
|
83
93
|
|
|
@@ -118,6 +128,8 @@ When the server rejects an unauthenticated connection, `/mcp` shows that it need
|
|
|
118
128
|
|
|
119
129
|
Pi registers itself with the authorization server, stores tokens in `~/.pi/agent/mcp-auth.json`, and refreshes access tokens when they expire or the server rejects them. If a server later requests additional scope, Pi asks for sign-in again. Signing out deletes the stored credentials.
|
|
120
130
|
|
|
131
|
+
Credentials belong to a server name and URL. Servers with the same URL under different names, such as one per account, sign in separately; servers with the same name and URL in different `mcp.json` files share one sign-in.
|
|
132
|
+
|
|
121
133
|
OAuth applies to HTTP servers without an `Authorization` header. For a server that does not support dynamic client registration, configure a registered client:
|
|
122
134
|
|
|
123
135
|
```json
|
|
@@ -147,6 +159,33 @@ Pi registers as `pi`. Some servers only accept registrations from known clients.
|
|
|
147
159
|
|
|
148
160
|
The name is only sent when Pi registers a client. To register again under a new name, sign out first.
|
|
149
161
|
|
|
162
|
+
Some authorization servers allow clients by their Client ID Metadata Document URL instead of registering them. Set `clientRegistration` to `cimd` to identify as Pi's document on pi.dev instead of registering:
|
|
163
|
+
|
|
164
|
+
```json
|
|
165
|
+
{
|
|
166
|
+
"mcpServers": {
|
|
167
|
+
"example": { "url": "https://mcp.example.com/mcp", "oauth": { "clientRegistration": "cimd" } }
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
The client ID is `https://pi.dev/oauth/client.json` with the redirect URI `http://127.0.0.1:<port>/callback`. If the authorization server does not send the `iss` parameter in authorization responses (RFC 9207), Pi uses a document and redirect path specific to the MCP server instead: `https://pi.dev/oauth/<id>/client.json` with `http://127.0.0.1:<port>/callback/<id>`. The authorization server must advertise Client ID Metadata Document support and public clients, or sign-in fails. `cimd` cannot be combined with `clientId` or `clientName`, and a `callbackUrl` must use `localhost` or `127.0.0.1` with the path `/callback`.
|
|
173
|
+
|
|
174
|
+
Pi finds the authorization server through the server's protected resource metadata (RFC 9728) and checks that the authorization server's metadata names the expected issuer (RFC 8414). Some servers advertise the wrong authorization server or none, so sign-in opens a page that does not exist. Set `authServerMetadataUrl` to the metadata document of the right authorization server:
|
|
175
|
+
|
|
176
|
+
```json
|
|
177
|
+
{
|
|
178
|
+
"mcpServers": {
|
|
179
|
+
"example": {
|
|
180
|
+
"url": "https://mcp.example.com/mcp",
|
|
181
|
+
"oauth": { "authServerMetadataUrl": "https://example.okta.com/.well-known/openid-configuration" }
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Pi uses that document instead of discovery and trusts it as configured, so only point it at a document you trust. The URL must use HTTPS, except on `localhost`, `127.0.0.1`, or `[::1]`.
|
|
188
|
+
|
|
150
189
|
## Control tool exposure
|
|
151
190
|
|
|
152
191
|
Each server tool is registered as `mcp__<server>__<tool>`. The server's `exposure` determines how the model reaches it:
|
package/docs/models.md
CHANGED
|
@@ -18,7 +18,7 @@ Browse the [model catalog](https://pi.dev/models) for current providers, model I
|
|
|
18
18
|
|
|
19
19
|
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.
|
|
20
20
|
|
|
21
|
-
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. [
|
|
21
|
+
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.
|
|
22
22
|
|
|
23
23
|
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.
|
|
24
24
|
|
|
@@ -102,13 +102,13 @@ Compatibility settings should describe verified differences in the endpoint's re
|
|
|
102
102
|
|
|
103
103
|
## Use classifier models
|
|
104
104
|
|
|
105
|
-
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:
|
|
105
|
+
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:
|
|
106
106
|
|
|
107
107
|
| Provider | Model IDs | Authentication |
|
|
108
108
|
|---|---|---|
|
|
109
109
|
| `typesafe` | `jev-latest` | `TYPESAFE_API_KEY` |
|
|
110
110
|
| `openrouter` | `typesafe/jev-1.13`, `~typesafe/jev-latest` | `OPENROUTER_API_KEY` or `/login` |
|
|
111
|
-
| `cloudflare-workers-ai` | `typesafe/jev` | `CLOUDFLARE_API_KEY` and `CLOUDFLARE_ACCOUNT_ID` |
|
|
111
|
+
| `cloudflare-workers-ai` | `typesafe/jev`, `@cf/cloudflare/clef`, `@cf/cloudflare/clef-flash` | `CLOUDFLARE_API_KEY` and `CLOUDFLARE_ACCOUNT_ID` |
|
|
112
112
|
| `vercel-ai-gateway` | `typesafe-ai/jev` | `AI_GATEWAY_API_KEY` |
|
|
113
113
|
| `opencode` | `jev-1.13`, `jev-1.13-free` | `OPENCODE_API_KEY` |
|
|
114
114
|
|
|
@@ -131,10 +131,31 @@ const result = await models.classify(jev, {
|
|
|
131
131
|
return result.answers;
|
|
132
132
|
```
|
|
133
133
|
|
|
134
|
+
[Codemode](codemode.md#classify) describes the question and answer types.
|
|
135
|
+
|
|
134
136
|
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.
|
|
135
137
|
|
|
136
138
|
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.
|
|
137
139
|
|
|
140
|
+
## Use image models
|
|
141
|
+
|
|
142
|
+
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.
|
|
143
|
+
|
|
144
|
+
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:
|
|
145
|
+
|
|
146
|
+
```js
|
|
147
|
+
const painter = await models.getModelOfType("image", "openrouter", "google/gemini-2.5-flash-image");
|
|
148
|
+
const result = await models.generateImages(painter, {
|
|
149
|
+
input: [{ type: "text", text: "A red fox in the snow, watercolor" }],
|
|
150
|
+
});
|
|
151
|
+
if (result.stopReason !== "stop") return result.errorMessage;
|
|
152
|
+
for (const block of result.output) if (block.type === "image") image(block);
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
`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.
|
|
156
|
+
|
|
157
|
+
Extensions generate images through `ctx.modelRegistry.generateImages()`, without codemode.
|
|
158
|
+
|
|
138
159
|
## Add a custom provider
|
|
139
160
|
|
|
140
161
|
Use an extension when the provider needs custom streaming, model discovery, or authentication behavior. See [Custom Providers](custom-provider.md) for the extension workflow.
|
package/docs/providers.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Providers
|
|
2
2
|
|
|
3
3
|
Most hosted providers support one or both of these authentication methods:
|
|
4
4
|
|
|
@@ -17,8 +17,6 @@ Run `/logout` and select a provider to remove its stored credential. This does n
|
|
|
17
17
|
|
|
18
18
|
`auth.json` can contain API keys and OAuth tokens. Keep it private and do not commit it.
|
|
19
19
|
|
|
20
|
-
Radius authentication uses its gateway catalog and caches refreshed model metadata for later offline startup. A custom Radius gateway configured in `models.json` uses its own catalog rather than inheriting the public `radius.pi.dev` catalog.
|
|
21
|
-
|
|
22
20
|
## Use an API key from the environment
|
|
23
21
|
|
|
24
22
|
Environment variables are useful in CI and anywhere Pi should not store the key. Set the variable before starting Pi:
|
|
@@ -28,7 +26,7 @@ export ANTHROPIC_API_KEY=sk-ant-...
|
|
|
28
26
|
pi
|
|
29
27
|
```
|
|
30
28
|
|
|
31
|
-
This table covers providers with a single primary API-key variable. Providers that need additional configuration or support ambient credentials are covered under [
|
|
29
|
+
This table covers providers with a single primary API-key variable. Providers that need additional configuration or support ambient credentials are covered under [Provider Specific Config](#provider-specific-config).
|
|
32
30
|
|
|
33
31
|
| Provider | Environment variable |
|
|
34
32
|
|---|---|
|
|
@@ -85,9 +83,9 @@ To use a secret manager without writing the resolved key to disk, set a provider
|
|
|
85
83
|
|
|
86
84
|
Pi runs the command when the key is first needed and caches its standard output for the process lifetime. Empty output, a timeout, or a nonzero exit leaves the key unresolved until Pi restarts.
|
|
87
85
|
|
|
88
|
-
##
|
|
86
|
+
## Provider Specific Config
|
|
89
87
|
|
|
90
|
-
The providers below need additional settings or can use credentials supplied by their
|
|
88
|
+
The providers below have additional setup, need additional settings, or can use credentials supplied by their platform.
|
|
91
89
|
|
|
92
90
|
A stored API-key credential can include an `env` object. Its values take priority over the process environment for that provider:
|
|
93
91
|
|
|
@@ -103,6 +101,18 @@ A stored API-key credential can include an `env` object. Its values take priorit
|
|
|
103
101
|
}
|
|
104
102
|
```
|
|
105
103
|
|
|
104
|
+
### Radius
|
|
105
|
+
|
|
106
|
+
Radius is a service crafted for Pi by the builders of Pi, Earendil Works. It provides a customizable AI gateway with organization-level controls and analytics built in, and artifacts for sharing what you create with Pi.
|
|
107
|
+
|
|
108
|
+
To get started, run `/login radius` in Pi. This adds Radius as a provider, and its models appear in `/model` like any other provider's.
|
|
109
|
+
|
|
110
|
+
Radius also has an MCP server, so Pi can manage Radius for you.
|
|
111
|
+
|
|
112
|
+
Radius is currently in early alpha and evolving quickly. See [radius.earendil.com](https://radius.earendil.com) for more.
|
|
113
|
+
|
|
114
|
+
Radius authentication uses its gateway catalog and caches refreshed model metadata for later offline startup. A custom Radius gateway configured in `models.json` uses its own catalog rather than inheriting the public `radius.pi.dev` catalog.
|
|
115
|
+
|
|
106
116
|
### Azure OpenAI
|
|
107
117
|
|
|
108
118
|
Set an API key plus either a base URL or resource name:
|
package/docs/quickstart.md
CHANGED
|
@@ -12,7 +12,7 @@ On macOS or Linux, you can use the installer:
|
|
|
12
12
|
curl -fsSL https://pi.dev/install.sh | sh
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
Alternatively, install Pi from npm. This requires Node.js 22.19 or newer:
|
|
15
|
+
The installer pins all dependencies and updates Pi with `pi update`. Alternatively, install Pi from npm, which does not pin transitive dependencies. This requires Node.js 22.19 or newer:
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
18
|
npm install -g --ignore-scripts @earendil-works/pi-coding-agent
|
|
@@ -20,6 +20,14 @@ npm install -g --ignore-scripts @earendil-works/pi-coding-agent
|
|
|
20
20
|
|
|
21
21
|
Pi does not require dependency lifecycle scripts for a normal npm installation.
|
|
22
22
|
|
|
23
|
+
With Nix on macOS or Linux, install the latest release from Pi's flake. Nix builds Pi from source:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
nix profile add github:earendil-works/pi/stable
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Older Nix versions use `nix profile install` instead. Update with `nix profile upgrade pi`; `pi update` cannot update a Nix installation. To pin a release, use a tag such as `github:earendil-works/pi/v1.0.0`.
|
|
30
|
+
|
|
23
31
|
Verify the installation:
|
|
24
32
|
|
|
25
33
|
```bash
|
|
@@ -119,4 +127,10 @@ If you used the installer, run it again and choose **Uninstall Pi**:
|
|
|
119
127
|
curl -fsSL https://pi.dev/install.sh | sh
|
|
120
128
|
```
|
|
121
129
|
|
|
122
|
-
|
|
130
|
+
If you installed Pi with Nix, run:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
nix profile remove pi
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
None of these methods removes configuration, credentials, sessions, or installed Pi packages from `~/.pi/agent/`.
|
package/docs/sdk.md
CHANGED
|
@@ -140,7 +140,7 @@ See the focused examples for [models](../examples/sdk/02-custom-model.ts), [tool
|
|
|
140
140
|
|
|
141
141
|
## Resources
|
|
142
142
|
|
|
143
|
-
- [Choose a Model](models.md) covers model selection and compatible endpoints; [
|
|
143
|
+
- [Choose a Model](models.md) covers model selection and compatible endpoints; [Providers](providers.md) covers credentials and provider-specific setup.
|
|
144
144
|
- [Configuration](configuration.md) explains normal discovery and settings; [Settings](settings.md) lists every setting.
|
|
145
145
|
- [Sessions and Context](sessions.md) explains session behavior; [Session Format](session-format.md) defines persisted entries; [Message Types](message-types.md) defines shared transcript values.
|
|
146
146
|
- [Extensions](extensions.md), [Skills](skills.md), and [Prompt Templates](prompt-templates.md) document resources supplied through a `ResourceLoader`.
|
package/docs/settings.md
CHANGED
|
@@ -38,7 +38,7 @@ See [Choose a Model](models.md) for model selection and thinking controls.
|
|
|
38
38
|
| Setting | Type | Default | Description |
|
|
39
39
|
|---|---|---|---|
|
|
40
40
|
| `defaultTools` | `string[]` | `read`, `bash`, `edit`, `write` | Tools enabled at startup. Plain names replace the defaults; `+name` adds a tool and `-name` removes one. An empty array disables all built-in tools but not extension or SDK tools. |
|
|
41
|
-
| `codemode.mode` | `"on"` \| `"only"` | `"on"` | How the `codemode` tool presents tools while it is active. `on`: declared tools get
|
|
41
|
+
| `codemode.mode` | `"on"` \| `"only"` | `"on"` | How the `codemode` tool presents tools while it is active. `on`: declared tools get a note on calling them from scripts appended to their description, and `codemode` lists only tools that are not declared. `only`: `codemode` lists every tool scripts can call, and active built-in and extension tools are hidden from the model, so it reaches them through `codemode`. |
|
|
42
42
|
| `codemode.inlineBudget` | number | `3000` | Estimated tokens (characters / 4) the `codemode` tool's description may spend on tool declarations. Tools that do not fit are left out and found with `searchTools()`. `0` lists only namespaces. |
|
|
43
43
|
|
|
44
44
|
Available built-in tools are `read`, `bash`, `powershell`, `edit`, `write`, `grep`, `find`, and `ls`. `defaultTools` can also name `codemode` and `tool_search`, which built-in extensions register inactive, and other extension tools registered inactive.
|
|
@@ -90,8 +90,8 @@ See [Compaction Reference](compaction.md) for trigger, summarization, and valida
|
|
|
90
90
|
| Setting | Type | Default | Description |
|
|
91
91
|
|---|---|---|---|
|
|
92
92
|
| `theme` | string | `"system"` | Built-in or custom theme name. `system` derives colors from the terminal theme. |
|
|
93
|
-
| `quietStartup` | boolean | `false` |
|
|
94
|
-
| `tuiMode` | `"regular" \| "fullscreen"` | `"
|
|
93
|
+
| `quietStartup` | boolean \| `"header"` | `false` | `true` hides the startup header and loaded-resource listing. `"header"` keeps the header (version and key hints) but hides the model scope line and loaded-resource listing. |
|
|
94
|
+
| `tuiMode` | `"regular" \| "fullscreen"` | `"fullscreen"` | Interactive terminal UI mode. |
|
|
95
95
|
| `fullscreenExitOutput` | `"transcript" \| "resume-hint"` | `"transcript"` | Output printed when fullscreen mode exits. |
|
|
96
96
|
| `fullscreenScrollbar` | `"auto" \| "always" \| "hidden"` | `"auto"` | Fullscreen transcript scrollbar behavior. |
|
|
97
97
|
| `fullscreenCopyOnSelect` | boolean | `true` | Copy selected text automatically in fullscreen mode. |
|
package/docs/usage.md
CHANGED
|
@@ -83,7 +83,7 @@ Use `/share` to upload the session and get a viewer link. With Radius authentica
|
|
|
83
83
|
|
|
84
84
|
## Adjust the terminal
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
Fullscreen mode, the default, keeps the editor and status area fixed while the transcript scrolls within the terminal window. Regular mode uses the terminal's normal scrollback. Choose a mode through `/settings` or `--tui-mode`.
|
|
87
87
|
|
|
88
88
|
Terminal support for mouse input, keyboard shortcuts, and inline images varies. See [Terminal Setup](terminal-setup.md) for platform-specific configuration and [Keybindings](keybindings.md) for every configurable shortcut. Run `/hotkeys` to inspect the shortcuts active in your current session.
|
|
89
89
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-custom-provider",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-custom-provider",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "1.0.1",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sdk": "^0.52.0"
|
|
12
12
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-gondolin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-gondolin",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "1.0.1",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@earendil-works/gondolin": "0.12.0"
|
|
12
12
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-sandbox",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-sandbox",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "1.0.1",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sandbox-runtime": "^0.0.26"
|
|
12
12
|
}
|