Commit graph

4121 commits

Author SHA1 Message Date
Mario Zechner
5609b0d6c0 feat(coding-agent): experimental TUI coding agent on pi-durable
A small local agent in src/experimental/durable: pi's model runtime, settings,
system prompt, theme, and interactive components over a durable Harness with
SQLite storage. Streaming, tools, steer and follow-up, abort, model and
thinking selection, compaction, --continue with recovery of interrupted turns,
a subagent tool with /agents to switch to and talk to subagents, and a live
/tasks panel from the task graph view. The tsconfig path for
@earendil-works/pi-durable/* resolves subpaths to source.
2026-10-01 09:53:21 +02:00
Armin Ronacher
8ce69e9d2b fix(mcp): treat empty and null optional OAuth fields as absent
Empty or null optional fields in OAuth token and registration responses
(scope, refresh_token, id_token, client_secret) failed sign-in, and
expires_in: null marked tokens as expired. Also fall back to the server
origin when resource metadata has invalid URLs, skip empty scopes when
selecting the requested scope, and end pagination at an empty or null
nextCursor.

closes #10266
2026-10-01 02:05:35 +02:00
Armin Ronacher
d850edee9c feat(coding-agent): add MCP oauth.authServerMetadataUrl and check RFC 9207 iss
The configured metadata document replaces discovery and is trusted as
configured. Authorization codes are only exchanged when the response's
iss parameter names the flow's authorization server.

closes #10172
2026-09-30 23:56:10 +02:00
Armin Ronacher
b35af04f46 feat(coding-agent,tui): add a hidden easter egg to the header logo
Adds TuiAltScreen.getScreenLines(), which returns the lines of the last rendered frame.
2026-09-30 22:57:55 +02:00
Armin Ronacher
955cc6665e Add [Unreleased] section for next cycle 2026-09-30 21:12:42 +02:00
Armin Ronacher
005af57d88 Release v0.99.2 2026-09-30 21:12:28 +02:00
Armin Ronacher
002c183e18 docs(ai,coding-agent): audit unreleased changelog entries
Add missing entries, contributor attribution, cross-package duplicates, and a New Features section.
2026-09-30 21:07:03 +02:00
Phil Freo
a9424cd43d
feat(ai): Anthropic workload identity federation (#10242)
Adds Anthropic workload identity federation from the SDK env vars
(ANTHROPIC_FEDERATION_RULE_ID, ANTHROPIC_ORGANIZATION_ID,
ANTHROPIC_IDENTITY_TOKEN_FILE, optional ANTHROPIC_SERVICE_ACCOUNT_ID and
ANTHROPIC_WORKSPACE_ID). Keys and ANTHROPIC_AUTH_TOKEN keep precedence.

The federation client is reused across requests so the SDK's token cache
avoids a token exchange per request, and the SDK's own credential chain is
disabled so pi's auth resolver stays the only source of credentials.

closes #10177
2026-09-30 20:58:37 +02:00
Armin Ronacher
91f9f3b5df feat(coding-agent): let MCP servers authenticate with a provider login
HTTP MCP servers can set "auth": { "provider": "<provider>" } to send the provider's current /login token as the bearer token instead of using MCP OAuth. The token is read on every request, so provider refreshes apply and nothing is copied to mcp-auth.json. Only allowed in the global mcp.json and from extensions, and requires https except on loopback hosts.
2026-09-30 20:41:58 +02:00
Armin Ronacher
b29db895c5 fix(coding-agent): align MCP tool names with codemode identifiers
MCP tool and namespace names now replace - with _ like Codex, so the
pi tool name is also the codemode identifier. Tools of a server whose
names collide all get a hash suffix, and server names that differ only
in - and _ are rejected.

closes #10239
2026-09-30 18:40:06 +02:00
Armin Ronacher
db6cc71dc7 feat(coding-agent): enable tools newly added to defaultTools on reload
When the session's initial tools come from defaultTools, /reload activates
names added to the resolved selection. Removals do not deactivate tools, and
explicit --tools/--no-tools/--no-builtin-tools keep overriding the setting.

closes #10245
2026-09-30 17:55:25 +02:00
Armin Ronacher
028c0ec56e fix(coding-agent): do not list codemode-hidden tools in the system prompt
In codemode.mode "only", tools whose declarations codemode hides were still
listed in the <tools> section. Drop their snippets so the list matches the
declared tools.

closes #10192
2026-09-30 17:46:43 +02:00
Armin Ronacher
0582d9c11d fix(coding-agent): limit codemode and MCP result previews to wrapped lines
Collapsed previews counted logical lines, so one long JSON line filled the
screen. Share a VisualLinePreview component with the bash renderer.
2026-09-30 17:25:07 +02:00
Armin Ronacher
e029c3ed0a feat(coding-agent): stop waiting for MCP servers on the first prompt
The first prompt waits only for servers with direct tools. Other servers
connect in the background; codemode scripts, tool_search, and the
resource tools wait for the servers they need. codemode and tool_search
are activated from the config.

Tool declarations no longer depend on connected servers: the codemode
description leaves out deferred tools, and the tool_search description
no longer lists sources. Servers are listed in an mcp_servers system
prompt section instead, set in before_agent_start from the config and
connected state, so changes are appended to the conversation.

describeNamespace() and searchTools() accept mcp__dev-radius,
mcp__dev_radius, dev-radius, and dev_radius.

closes #10212
2026-09-30 17:21:05 +02:00
David Brailovsky
dc83372f8f fix(coding-agent): validate extension command registration
Reject extension commands without a non-empty string name or a handler
at registration, instead of letting them crash the editor when typing /.

fixes #10054
2026-09-30 15:02:08 +02:00
Armin Ronacher
c34f2d6ad5 fix(coding-agent): merge remote catalog models in linear time
mergeModels ran a findIndex per remote model, so every model lookup for a
provider with a refreshed pi.dev catalog was quadratic in catalog size.
2026-09-30 14:33:58 +02:00
Armin Ronacher
a0660b174e fix(coding-agent): resolve branch model selection with one catalog lookup
getBranchSelection looked up the model catalog once per assistant message,
which made prompt submission scale with session length. Walk the branch
backward instead: only the last model_change can hold against later
responses, so at most that model needs a lookup.

closes #10198
2026-09-30 14:20:03 +02:00
Armin Ronacher
7c9fe66452 feat(coding-agent): allow a custom OAuth client name for MCP servers
Adds oauth.clientName (and pi mcp add --oauth-client-name) to set the
client_name sent during dynamic client registration. Defaults to pi.

closes #10226
2026-09-30 13:59:24 +02:00
Armin Ronacher
1c7e7df765 feat(coding-agent): list MCP servers instead of their tools in codemode
MCP codemode exposure no longer lists tools, tool counts, or server
instructions in the codemode description. Servers are listed by name and
an optional mcp.json description; scripts find tools with searchTools()
and read instructions with describeNamespace(). codemode-deferred is an
alias for codemode.

refs #10212
2026-09-30 13:54:02 +02:00
Armin Ronacher
4a42f8fafa fix(coding-agent): load codemode worker in Windows binary
closes #10204
2026-09-30 13:48:04 +02:00
Armin Ronacher
d2931ad3d5 fix(coding-agent): validate codemode image() base64 and detect image type
image() now rejects malformed base64 and data without a PNG, JPEG, GIF,
or WebP signature, and derives the MIME type from the signature. Invalid
image blocks were persisted and made every later provider request fail.

closes #10215
2026-09-30 12:10:30 +02:00
David Brailovsky
3e94512383 fix(coding-agent): make /mcp sign-in URL clickable like /login
fixes #10186
2026-09-30 10:29:06 +02:00
Christian Klotz
99e85eb7d1
docs(coding-agent): improve MCP server guide (#10220) 2026-09-30 09:28:48 +01:00
Christian Klotz
ee602414c7
fix(coding-agent): preserve renderer example prompt guidance (#10193)
* fix(coding-agent): preserve renderer example prompt guidance

Fixes #10072 by reusing complete built-in tool definitions.

* fix(coding-agent): verify minimal mode shell rendering
2026-09-30 08:56:08 +01:00
David Brailovsky
fddc968b96
fix(coding-agent): mark native providers with stored credentials as configured on registration (#10190)
registerNativeProvider() did not update the auth snapshot, so the provider
stayed unconfigured until an async refresh saved a snapshot that included it.
At startup that refresh can resolve before its result is saved, so initial
model selection saw the provider as unconfigured and fell back to another
provider or warned that no models are available.

Share registerProvider's provisional entry through markProvisionallyConfigured()
so native providers with a stored credential or a models.json apiKey are
configured immediately.

fixes #9962
2026-09-29 22:16:56 +02:00
Armin Ronacher
6a4af07d61 Add [Unreleased] section for next cycle 2026-09-29 20:07:07 +02:00
Armin Ronacher
d86654abb8 Release v0.99.1 2026-09-29 20:06:55 +02:00
Armin Ronacher
a879e23ca7 docs(coding-agent): audit unreleased changelog 2026-09-29 20:01:50 +02:00
Armin Ronacher
72abf01ba9 fix(coding-agent): bundle openai-chatgpt OAuth flow
The lazy OAuth entry list in the bundle build was missing openai-chatgpt,
so /login with OpenAI failed with a missing module error. Also fail the
build if any importOAuthModule() target in load.ts has no lazy entry.
2026-09-29 20:00:11 +02:00
Armin Ronacher
12c416e1a6 feat(ai,coding-agent): add GPT-6.1 Sol and make it the Codex default
Add gpt-6.1-sol to the OpenAI, Azure OpenAI Responses, and OpenAI Codex
providers with official pricing ($2 input, $0.10 cached input, $2.50
cache writes, $10 output, long-context tier above 272k). The model
rejects reasoning.effort "none", so off is unsupported and clamps to
the lowest effort.
2026-09-29 19:43:27 +02:00
Armin Ronacher
312184edb6 Add [Unreleased] section for next cycle 2026-09-29 19:04:43 +02:00
Armin Ronacher
4b060d3a98 Release v0.99.0 2026-09-29 19:04:28 +02:00
Armin Ronacher
f81cf5520d docs: audit changelogs for 0.99.0 2026-09-29 19:01:43 +02:00
Armin Ronacher
8eb2bccf26 fix: bump vitest to 4.1.11 and gondolin's undici to 6.29.0
Addresses GHSA-82fw-gwwq-j7x9 (vitest mocker path traversal) and
GHSA-3wwx-pv8p-q78v (undici 6.x permessage-deflate DoS). Both are
dev/example-only; the shipped coding-agent shrinkwrap is unchanged.
2026-09-29 18:38:07 +02:00
Armin Ronacher
1ff5b6fddf feat(coding-agent): return up to 1 MiB of bash output to codemode scripts
Structured bash results now hold the full output up to 1 MiB instead of the
model-facing 2000 lines or 50KB, keeping the first and last 512 KiB of longer
output, and add truncated and full_output_path.
2026-09-29 18:06:50 +02:00
David Brailovsky
02eed88fd8
feat(ai,coding-agent): add alternative sign in for the openai provider 2026-09-29 17:16:15 +02:00
Cristina Poncela Cubeiro
9d1a650352
fix(extensions): show warning when replaceable builtin replaced (#10174) 2026-09-29 16:37:51 +02:00
Armin Ronacher
9a100c7cc4 feat(coding-agent): report codemode classifier and nested tool usage in session cost
Codemode sums the usage of models.classify() calls into its tool result and shows each call's cost. Usage of tools called through ctx.executeTool() is added to the calling tool's result usage instead of being dropped.
2026-09-29 16:21:39 +02:00
Armin Ronacher
33e2033543 feat(ai): expose Jev on Vercel AI Gateway and OpenCode Zen
Vercel evaluation models are generated from the AI Gateway catalog and
routed through its TypeSafe-compatible /typesafe/v1/systemone endpoint.
OpenCode Zen's jev-1.13 and jev-1.13-free are routed through
/zen/v1/systemone.
2026-09-29 15:32:10 +02:00
Armin Ronacher
5257d0d5f3 feat(coding-agent): show tool call arguments for MCP and fallback-rendered tools
Tools without a custom call renderer now show their arguments as key=value
pairs when collapsed and one key: value line per argument when expanded.
MCP tools get a server/tool title and results that collapse to 5 lines.
2026-09-29 14:10:12 +02:00
Armin Ronacher
30a1d1849d feat(coding-agent): support +name/-name in defaultTools
Entries of only +name/-name modify the inherited tool selection, so
"defaultTools": ["+codemode"] enables codemode without repeating the
defaults. Project entries layer on top of user settings. Document how to
enable codemode without MCP and how to use classifier models from it.
2026-09-29 14:02:57 +02:00
Armin Ronacher
4df1574339 feat(ai,coding-agent): share OAuth callback server and sign-in page
Anthropic, OpenAI Codex, OpenRouter, and Radius now use one loopback callback server in pi-ai. MCP sign-in renders the same browser page through a new renderPage option on the pi-mcp callback server.
2026-09-29 12:10:50 +02:00
Armin Ronacher
4259686d92
refactor(coding-agent): resolve built-in extensions as builtin:<name> paths (#10159)
Built-in extensions (mcp, llama.cpp, codemode, tool-search) are now extension resources like files: the package manager resolves them as builtin:<name>, the extensions setting disables them with -builtin:<name> (per project too), pi config lists them, and --no-extensions turns them off unless loaded with -e builtin:<name>. They load after project trust is resolved and after file and package extensions.

Built-in extensions and tools are named builtin:<name> in errors, diagnostics, RPC source info, and bug reports.
2026-09-29 10:51:01 +02:00
Armin Ronacher
1d74741e17 fix(coding-agent): serialize MCP OAuth refreshes across processes
Refreshes hold a per-server lock file from reading the tokens to saving new ones, and use tokens another process already refreshed. Rotating refresh tokens (Cloudflare) were lost when two pi processes refreshed at once, leaving the server needing sign-in. Closing a connection waits for a running refresh so shutdown does not drop rotated tokens.
2026-09-29 10:19:05 +02:00
Cristina Poncela Cubeiro
da19b63c77
fix(llama): cached context on reload (#10158) 2026-09-29 10:07:27 +02:00
Armin Ronacher
f1927c2d56 feat(tui,coding-agent): configurable fullscreen wheel scrolling with auto acceleration
Adds fullscreenWheelScrollLines ("auto" or 1-100). Auto keeps one line
per event in local macOS terminals and scales with wheel velocity
elsewhere, capped at six lines per event.

closes #9758
2026-09-29 09:57:53 +02:00
Armin Ronacher
8562bcf66a feat(coding-agent): codemode and MCP
This adds codemode and MCP support to pi. Codemode (packages/codemode) runs
model-written JavaScript in a QuickJS wasm VM inside a worker. From there the
script calls pi's tools as async functions, uses a per-session store, and can
read the model catalog and run classifiers. The codemode tool in coding-agent
is compatible with Codex's exec tool, and codemode.mode works like Codex's
tool modes (on or only). Large results are written to a JSON temp file. MCP
(packages/mcp) is a standalone client for stdio and streamable HTTP servers,
with OAuth.

The core only gets general mechanisms; codemode, tool_search and MCP are
built-in extensions that use them. Other extensions can replace these
built-ins. Tools declare an exposure: direct, model-only, codemode, deferred
or hidden. prepareLoadout() lets an orchestrating tool change which tool
declarations the model sees. ctx.executeTool() runs nested calls through
validation and the tool_call/tool_result hooks. Those calls emit events with
parentToolCallId and are recorded as bounded nestedCalls on the parent
result, which compaction and HTML export use. Tools can also return
structuredContent with an outputSchema, and can report errors with isError
instead of throwing. MCP servers come from mcp.json (global, or per project
after the project is trusted) or from pi.registerMcpServer(). They are
managed with /mcp and pi mcp list|login|logout, and their runtimes load on
first use.

Closes #10040
2026-09-29 09:12:50 +02:00
Armin Ronacher
b485fa3128 fix(tui,coding-agent): reduce render cost of theme changes and streaming
Theme previews re-render the whole transcript, and streaming re-renders
every frame, so per-line and per-session work dominated in long sessions.

- visibleWidth: fast path for ANSI-styled ASCII, allocation-free escape scanning
- Box: compare unpadded child lines and skip a second width measurement
- Markdown: reuse parsed tokens across invalidation
- footer: cache usage totals and context usage per session state
- bash results: cache the collapsed preview including the expand hint
- sanitizeBinaryOutput: single regex replace
2026-09-29 08:23:46 +02:00
Armin Ronacher
28fd590868 fix(ai,coding-agent): replace removed Together Kimi K2.6 with Kimi K3
Together no longer lists Kimi K2.6, which broke type checks against the hydrated catalog. Tests use Kimi K3 and the Together default model now points at it.
2026-09-29 08:11:56 +02:00
Armin Ronacher
540e174c72
feat(coding-agent): Virtual models (#10035)
This adds experimental support for virtual models. A virtual model is a catalog entry that an extension registers with pi.registerVirtualModel(). It does not talk to a provider itself; for every request it picks a physical model and thinking level. The motivation is to make routing policies pluggable: plan on a strong model and implement on a cheap one, pick a model with a classifier, or move to a larger window when the context grows. Today this needs model switching by hand or hacks in prepareRequest.

The selection stays virtual: model_change records it, resume restores it, and each response records the physical model and thinking level that produced it. Router state can be stored on the session branch, so it follows /tree and forks and survives compaction. Context limits, compaction and image sizing use the physical model a request was routed to. examples/extensions/jev-router.ts shows a full router that uses the Jev classifier to pick Sol or Terra for planning and hands off to Luna after the first edit. docs/virtual-models.md describes the API.
2026-09-28 23:30:45 +02:00