Commit graph

627 commits

Author SHA1 Message Date
Armin Ronacher
c2b8f5c050 feat(tui): add switchable terminal renderers
Allow coding-agent UI modes to switch at runtime while preserving terminal, focus, input, and renderer state.
2026-08-01 20:38:26 +02:00
Armin Ronacher
b3ed27b3fe feat(coding-agent): add scrollbar thumb theme color 2026-07-31 17:41:40 +02:00
Armin Ronacher
6129a353b1 feat(tui): add configurable fullscreen scrollbars 2026-07-31 17:17:02 +02:00
Armin Ronacher
3c717842e8 feat(tui): add fullscreen transcript navigation 2026-07-31 16:23:58 +02:00
Vegard Stikbakke
f074efd921 feat(coding-agent): add ui mode setting 2026-07-31 15:33:52 +02:00
Mario Zechner
ea1e77e2db feat(tui): add alternate-screen viewport layouts 2026-07-31 09:22:10 +02:00
Alexey Zaytsev
714978bf51
Markdown api (#7231)
* feat(tui): export bundled Marked parser

* feat(coding-agent): add width-aware Markdown transformers

---------

Co-authored-by: Mario Zechner <badlogicgames@gmail.com>
2026-07-30 22:39:04 +02:00
Mario Zechner
2c30412420 fix(ai): support streams without finish reasons 2026-07-30 22:23:46 +02:00
Mario Zechner
c13ffe1877 feat(tui): add alternate-screen renderer
Closes #7304
2026-07-30 12:59:48 +02:00
pungggi
04b15259b2
feat(extensions): expose ctx.scopedModels to extensions (#7191)
Extensions have no way to read the session's scoped model set (the models
resolved from --models / enabledModels against the available catalogue --
the same list /scoped-models shows). The only model surfaces on
ExtensionContext are ctx.model (active) and ctx.modelRegistry.getAvailable()
(the whole catalogue, unfiltered), so an extension that wants a scoped
model picker must either enumerate everything or re-implement pi's scope
resolution (minimatch on provider/modelId / bare modelId + enabledModels +
--models) from disk -- duplicating core logic.

Add ctx.scopedModels: readonly ScopedModel[] to ExtensionContext, mirroring
how ctx.model is exposed (field -> bindCore -> lazy getter in createContext()).
Empty when no scoping is configured (all available models usable). Each entry
is { model, thinkingLevel? }.

- types.ts: ExtensionContext.scopedModels + ExtensionContextActions.getScopedModels
- runner.ts: field, bindCore wiring, lazy scopedModels getter
- agent-session.ts: provide getScopedModels: () => this._scopedModels
- test: assert ctx.scopedModels reflects the action (default [] + live ref)
- docs/extensions.md: document the new field

Co-authored-by: ngSoftware <alessandro@pungitore.ch>
2026-07-28 08:31:01 +02:00
Rafael
61da9e2f37
feat(ai): add manual redirect URL fallback to OpenRouter OAuth login (#7114)
The OpenRouter PKCE flow only completed through the loopback callback
server, so remote/headless sessions (e.g. pi over SSH) could never
finish login: the browser runs on another machine and cannot reach
127.0.0.1 on the host running pi.

Race the callback server against a manual_code prompt, matching the
existing Anthropic and OpenAI Codex flows. Users can paste the final
redirect URL (or the bare authorization code) and the flow exchanges
it with the same PKCE verifier. A claimed callback keeps priority so
a pasted code cannot interrupt an in-flight exchange.

The callback server object follows the OAuthServerInfo shape from the
OpenAI Codex flow: waitForCredential() resolves null when cancelWait()
hands the login over to manual entry, and close() is pure cleanup that
never settles the wait.

Refs #7078
2026-07-27 11:58:04 +02:00
Lucas Meijer
f9a49869c2
feat(ai): expose pending stop reason while streaming (#7151)
* feat(ai): expose pending streaming stop reason

Closes #7142

* manual tidy up of human facing copy
2026-07-27 11:56:15 +02:00
Alexey Zaytsev
518855dd50
feat(coding-agent): expose output padding to custom renderers (#7045)
Co-authored-by: Mario Zechner <badlogicgames@gmail.com>
2026-07-25 08:29:34 +02:00
Armin Ronacher
24bace27cf
feat(ai): support constrained sampling (#6341)
Add the constrained sampling API and provider plumbing for OpenAI and Anthropic tool calls, including grammar sampling variants and model capability metadata.
2026-07-23 23:48:40 +02:00
Thomas Mustier
241431c69b
fix(agent,ai): don't cache write compaction or branch summaries (#6618)
avoid cache writes for compaction and branch summaries

Co-authored-by: Armin Ronacher <armin.ronacher@active-4.com>
2026-07-23 23:03:23 +02:00
Anantha Kumaran
fc85bdd88b
feat(coding-agent): emit bash_execution_update events (#6971) 2026-07-23 12:28:12 +02:00
Petr Houška
7af8533c6f
fix(ai): make provider retries abortable (#6980)
Replace OpenAI and Anthropic SDK retries with local request retries that
preserve configured retry counts, enforce maxRetryDelayMs, and make retry
backoff interruptible through AbortSignal.

Alternatives considered: Racing SDK requests against AbortSignal would make
cancellation observable but would not let Pi enforce maxRetryDelayMs before
the SDK enters its retry sleep. Patching private SDK internals would be brittle,
while disabling provider retries entirely would ignore explicitly configured
maxRetries.

Also, align the custom OpenAI Codex retry loop with the documented
maxRetryDelayMs behavior. Oversized server-requested delays now fail immediately
instead of being clamped, allowing the visible, abortable agent-level retry
policy to handle the failure.

Fixes #6911
2026-07-23 12:25:37 +02:00
Armin Ronacher
bb3d7d399c
feat(coding-agent): expose session metadata to bash tools (#6967) 2026-07-22 20:15:02 +02:00
Saryev Rustam
7b52cef2e6
feat(ai): add OpenRouter OAuth support (#6927)
Closes #6814
2026-07-22 15:48:39 +02:00
Mario Zechner
6f95a33888 fix(ai): enable cache control for OpenRouter aliases
closes #6940
2026-07-22 11:46:21 +02:00
David Brailovsky
7540da4016 add docs for new event types 2026-07-21 15:40:11 +00:00
Cristina Poncela Cubeiro
9e7582aa03
feat: sqlite session storage (#6594)
This PR:

- Adds retainedTail to compaction entries in the new agent harness so we don't have to walk up the tree for the 2000 tokens before compaction,
- Changes getPathToRoot to getPathToRootOrCompaction to only load until last compaction, as unnecessary to access all nodes where it is called,
- Adds a SQLite storage backend, in a separate packages/session-backend-sqlite, with a migration system and schemas as per on-site discussions: sessions to match session header messages (except for metadata, which I couldn't understand what it's used for or where it gets written, so I omitted it), session_entries for shared entry types as columns plus payload as a json for what remains, session_sequences to represent the append-only, serialized nature of the jsonl files, branch_entries to attribute nodes to branches (relationship one-to-many), and session_materialized with the session info (see /session in TUI) to act as a "cache" or quick-access for costs, message count, token info, labels, session name, and model-thinking-level config (e.g. for fast resume).
- This is compatible with the new agent harness Session abstraction.
2026-07-21 11:36:31 +02:00
Mario Zechner
f8b74a4507 fix: complete extension usage accounting
closes #6509
2026-07-20 17:06:22 +02:00
Cristina Poncela Cubeiro
c179395218
feat: get_available_thinking_levels rpc (#6865) 2026-07-20 16:29:10 +02:00
QuintinShaw
bbb91fa8ae
feat(ai): add Qwen Token Plan as built-in provider (#6858)
Add Alibaba Cloud Model Studio Token Plan subscription service as two
built-in API-key providers: qwen-token-plan (international, Singapore)
and qwen-token-plan-cn (China, Beijing).

Each provider exposes 15 text-generation models (Qwen, DeepSeek, GLM,
Kimi, MiniMax) via the OpenAI-compatible endpoint with DashScope
enable_thinking support. Model metadata is sourced from models.dev;
qwen3.8-max-preview is hardcoded until models.dev includes it.

Also fixes kimi-coding test references (k2p7 -> kimi-for-coding) after
models.dev catalog update picked up by generate-models.

Closes #6850
2026-07-20 13:53:30 +02:00
Mario Zechner
3da591ab74 feat(coding-agent): add Hugging Face llama search
Some checks failed
CI / build-check-test (push) Has been cancelled
2026-07-17 17:13:39 +02:00
Mario Zechner
f1a466b19d feat(coding-agent): add llama.cpp router integration 2026-07-17 16:25:00 +02:00
David Brailovsky
64f83c85d9 fix(coding-agent): support all-argument prompt defaults closes #6695
Some checks are pending
CI / build-check-test (push) Waiting to run
2026-07-17 13:52:32 +02:00
Mario Zechner
019e4ad687 feat(coding-agent): accept native extension providers
Allow extensions to register complete pi-ai Provider objects while preserving models.json composition and resolved provider auth access.

Refs #4823 and #4824.
2026-07-17 10:58:48 +02:00
Mario Zechner
58575888f5 docs(coding-agent): fix obsolete extension UI examples closes #6735 2026-07-17 09:36:59 +02:00
David Brailovsky
3524cd4c85 Merge remote-tracking branch 'origin/main' into add-kimi-deferred-tools 2026-07-16 17:30:50 +02:00
David Brailovsky
f16b4e0cda add deferred tools support for kimi in openai-completions api 2026-07-16 12:26:56 +00:00
Armin Ronacher
97f9978fa6 feat(coding-agent): add model catalog refresh flag 2026-07-16 12:46:49 +02:00
Milosz Jankiewicz
5220aba619
feat(ai): add xAI device OAuth and route grok-4.5 through Responses (#6651)
* feat(ai): add xAI device OAuth and route grok-4.5 through Responses

Add xAI device-code OAuth alongside XAI_API_KEY. Route only grok-4.5
through Responses with low/medium/high reasoning; other xAI models stay
on Completions.

* fix(ai): tolerate xAI device-code interval 0 and correct token poll error label

---------

Co-authored-by: Jaaneek <Jaaneek@users.noreply.github.com>
2026-07-16 09:58:24 +02:00
Mario Zechner
bd9e09db44 feat(coding-agent): expose dynamic provider refresh 2026-07-15 12:56:50 +02:00
Mario Zechner
cd7cad4ee2 feat(coding-agent): merge origin/main into model runtime facade 2026-07-15 12:25:36 +02:00
Mario Zechner
9993c96907 feat(coding-agent): replace model registry with model runtime
Move provider auth and OAuth flows onto pi-ai Models, compose models.json and extension overlays through ModelRuntime, and retain ModelRegistry as an extension compatibility facade.
2026-07-14 17:48:45 +02:00
Petr Houška
298665cfb9
fix(ai): support OpenRouter session affinity (#6496)
Fixes #6366
2026-07-13 09:57:53 +02:00
Armin Ronacher
3d8f74357c
feat(ai): support message-anchored tool loading (#6474)
This adds cache-friendly dynamic tool loading anchored to tool results. Purely additive active-tool changes are recorded with `addedToolNames`, allowing supported Anthropic and OpenAI Responses models to load tool definitions at the point they become available instead of placing them in the cached prompt prefix.

It retains safe fallback behavior for unsupported models and non-additive changes but it will wipe caches.
2026-07-10 23:52:54 +02:00
Armin Ronacher
d7a48d30a0 fix(coding-agent): fall back to text clipboard paste 2026-07-10 21:46:15 +02:00
Armin Ronacher
3b686ac224 feat(coding-agent): add message copy shortcut 2026-07-10 21:35:53 +02:00
Armin Ronacher
3ea064ea2a fix: support Bedrock API key login 2026-07-10 19:34:11 +02:00
Aaron Ky-Riesenbach
1a2542b11b
feat(coding-agent): expand ~ in shellPath setting (#6470)
getShellPath() now runs the configured shellPath through the existing
normalizePath() helper, mirroring getSessionDir(). This lets shellPath
point at a home-directory-relative shell wrapper (e.g.
~/.local/bin/agent-shell-sandbox) and resolves consistently across
machines and OSes with different home directories.

refs #6458
2026-07-09 23:23:06 +02:00
Armin Ronacher
a9ecf301fb feat(ai): add input-based pricing tiers 2026-07-09 22:44:29 +02:00
Mario Zechner
fbdd46389c feat(ai): add max thinking level 2026-07-09 22:30:53 +02:00
Armin Ronacher
3f9aa5d10b
feat(coding-agent): add prompt cache miss tracking (#6427)
Detect prompt cache misses per turn by comparing each assistant message's
cache reads against the previous request's prompt tokens (core/cache-stats.ts).
Significant misses emit a warning-colored transcript notice at the turn they
occur, noting idle gaps past the cache TTL and model switches when relevant.

/session gained cache statistics: a compact token/cache breakdown with hit
rate, a $-prefixed cost section with per-model cost breakdown, and the
cumulative cost re-billed due to cache misses.
2026-07-09 14:12:57 +02:00
Mario Zechner
e9fa5a68a1 fix(coding-agent): add settled agent lifecycle event
closes #6363
2026-07-09 12:42:08 +02:00
Mario Zechner
1ffca0f2aa fix(coding-agent): align reload descriptions
closes #6395
2026-07-09 11:47:44 +02:00
Mario Zechner
c6251a866b fix(coding-agent): apply modelOverrides to extension providers
closes #6367
2026-07-09 11:22:35 +02:00
Mat
244f1deaf1
feat(coding-agent): add before_provider_headers extension hook (#6350)
* feat(coding-agent): add before_provider_headers extension hook

Extensions can already rewrite the request payload through before_provider_request, but there is no way to adjust the outgoing HTTP
headers of a provider call. This hook fills that gap for cases like request tracing, session correlation, or tenant routing.

Handlers mutate the headers map in place - a null value deletes a header - and the return value is ignored, so a handler cannot accidentally drop auth or attribution headers by
forgetting to spread.

* docs(coding-agent): document before_provider_headers extension hook

Add the before_provider_headers section and lifecycle-diagram entry to
extensions.md; drop the now-superseded proposal file.
2026-07-06 22:35:56 +02:00