Commit graph

59 commits

Author SHA1 Message Date
Mario Zechner
7472cda0d6 feat(coding-agent): remove the experimental server stack and the client, protocol, and server packages
Deletes packages/client, packages/protocol (CBOR codec), packages/server, coding-agent's
src/experimental (except source-resolver.ts, which source runs still preload), src/cli/experimental,
src/client, the example plugin, and their tests. coding-agent no longer depends on @earendil-works/chord.
The installer lock drops esbuild, so its platform-package sanity check goes too.
2026-10-12 10:41:59 +00:00
Armin Ronacher
748b351fe2 feat(codemode): run sandboxes on Cloudflare Workers via a remote Durable Object
Split the host into transport-independent execution logic and a VM driver, so the VM can run in a worker thread (CodemodeSandbox, unchanged), on the calling thread (InlineCodemodeSandbox), or in another isolate over RPC (RemoteCodemodeSandbox).

Add the /portable entry without Node imports and the /cloudflare entry with CodemodeSandboxDurableObject, meant to be deployed as its own Worker so scripts never block the caller's thread. Scripts that compute without awaiting a tool are bounded by an interrupt budget, now also polled while draining promise jobs. examples/cloudflare shows the setup.
2026-10-10 14:41:36 +02:00
Mario Zechner
ba03e03f2d feat(env): add @earendil-works/pi-env, remote execution environments over SSH
- RemoteExecutionEnv: a Durable ExecutionEnv on another machine whose
  results match NodeExecutionEnv there; Connection to the pi-env daemon
- packages/env/daemon: the Rust daemon for Linux, macOS, Android and
  Windows, following Node and libuv semantics
- env.yml runs Durable's env tests, the daemon's checks and pi-env's
  conformance and differential tests on Linux, macOS and Windows
2026-10-05 12:50:48 +02:00
Mario Zechner
7fd478a2e8 feat(agent): remove the experimental harness from pi-agent-core
pi-agent-core now contains only Agent, the agent loop, the proxy stream, and
their types. Removed the harness, sessions and session storage, pico3, harness
tools, compaction, skills, prompt templates, telemetry schemas, search types,
and the uuidv7 and pi-telemetry re-exports, plus the ./node, ./harness/* and
./experimental/pico3 subpath exports. Durable sessions live in
@earendil-works/pi-durable.

Also removed packages/session-backends and the experimental mini and micro
coding-agent frontends, with their scripts and build configuration.
2026-10-01 14:45:01 +02:00
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
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
ca7460d16b feat: build with TypeScript 7 and run sources with plain node
Replace the tsgo native preview with typescript@7.0.2 and port the check scripts to the TS 7 API. Target ES2024, drop useDefineForClassFields: false and unused decorator options, and enable verbatimModuleSyntax. Replace tsx with node plus the source resolver hook, passed to --import as a file URL.

closes #9965
2026-09-25 13:14:33 +02:00
Christian Klotz
b45597504e
feat(durable): export scoped storage conformance suite (#9977)
* feat(durable): export scoped storage conformance suite

* docs(durable): clarify storage conformance example
2026-09-23 23:21:15 +02:00
Armin Ronacher
7fd564cbb7 feat: share model catalog protocol with pi.dev (#9763)
Move catalog layout, index validation, version selection, and request
negotiation into scripts/model-catalog-protocol.ts. pi.dev keeps an
identical copy, so the publisher and a test running the current client
exercise the same selection pi.dev performs. Replaces the cross-repository
compatibility dispatch.

Related to #9099.
2026-09-23 20:08:05 +02:00
Mario Zechner
0801601621 feat(durable): move Pico into dedicated package 2026-09-18 13:39:09 +02:00
Mario Zechner
7e19507681 feat(coding-agent): add experimental micro agent 2026-09-17 16:33:03 +02:00
Armin Ronacher
86bac52f94 feat: add delta-backed replicated state
Track mutable provider state and publish immutable operation batches. Keep path codecs isolated per client subscription and state member.
2026-08-31 14:04:42 +02:00
Armin Ronacher
429f4e756c feat: add package-based facet plugins
Bundle declarative plugin packages with Chord and load fresh generations. Scope client selections to persisted Session and TUI branches, and replace stale local server generations after protocol changes.
2026-08-30 22:05:12 +02:00
Armin Ronacher
0252dff886 feat: add bundled facet distribution and reload
Bundle content-addressed Chord facet entries, distribute server-selected presentation artifacts during the handshake, and reload Session and TUI generations through /reload.
2026-08-30 12:52:58 +02:00
Armin Ronacher
e6dc574d1b feat: isolate Chord context API 2026-08-29 20:01:32 +02:00
Armin Ronacher
6ec57e6e5f feat: consolidate Chord public API 2026-08-29 18:56:26 +02:00
Armin Ronacher
34dc9d055a feat: move facet services into Chord
Move service, replicated-state, facet host, and loader ownership into the standalone Chord package. Migrate consumers and leave runtime JSON enforcement to serializers.
2026-08-29 14:55:51 +02:00
Armin Ronacher
28b49a6b3b feat: add Chord runtime foundation 2026-08-29 14:54:19 +02:00
Mario Zechner
5507d76ee8 feat(agent,ai): add narrow subpath exports so clients skip the barrel
A barrel forces Node to evaluate its whole graph: importing reduceLaneSnapshot
(1 file, 6 KB) through pi-agent-core's index evaluated 106 files, and mini's
server loaded 112 files to enumerate JSONL headers. Types are free, so this only
ever affected value imports.

pi-ai gains ./utils/* alongside the existing ./providers/* and ./api/*
wildcards. pi-agent-core gains ./harness/context, ./harness/env/nodejs,
./harness/runtime/reducer and ./harness/session, and ./session/testing becomes
./harness/session/testing so every export mirrors its source path. The barrel
and ./node keep their batteries-included semantics.

The session layer takes uuidv7 from @earendil-works/pi-ai/utils/uuid rather than
the pi-ai barrel, which is what let ./harness/session drop from 42 files to 19.
Two imports there were written `import { type Usage } from` - not a type-only
statement, so it emitted a runtime import of the barrel.

scripts/check-entry-graphs.mjs walks each declared entry's value-import graph and
enforces per-entry budgets and forbidden paths, so a stray `export *` cannot
silently undo this. It caught the two `import { type ... }` regressions above.

Measured with mini: server 112 files and 98 MB to 28 files and 69 MB, presentation
204 files and 125 MB to 99 files and 110 MB. The worker still loads the provider
graph, correctly.
2026-08-26 22:02:31 +02:00
Armin Ronacher
8dce5da769 feat(coding-agent): coordinate replaceable servers and workers
Keep the stable socket in an opaque detached coordinator while server processes own detached worker discovery and lifecycle. Remove the public drain RPC in favor of server replacement through coordinator routing.
2026-08-15 11:49:53 +02:00
Christian Klotz
6b3fb49dd9
feat: add fail-fast server generation replacement 2026-08-14 13:40:55 +03:00
Christian Klotz
e2888c4a93
feat(coding-agent): add local list and attach demo 2026-08-14 00:36:33 +03:00
Christian Klotz
b3bf0a2a81
feat(agent): add storage backend conformance suite 2026-08-12 00:22:30 +03:00
Mario Zechner
5aeb06bb11 feat(agent): establish durable harness type contracts 2026-08-11 17:43:26 +02:00
Mario Zechner
35f5c265d3 feat: add telemetry reference adapter and span composition 2026-08-06 11:44:58 +02:00
Mario Zechner
6b461b75b3 feat: extract telemetry package 2026-08-05 23:23:12 +02:00
Cristina Poncela Cubeiro
a80008b96c chore: rename storage package to session-backends 2026-08-05 09:28:44 +02:00
Christian Klotz
79cc1ef00a
fix(agent): own SQLite backend tests in storage package (#7626)
* fix(agent): own SQLite backend tests in storage package

* fix(agent): use lexical disposal for SQLite tests
2026-08-04 22:54:15 +03:00
Mario Zechner
44289550aa feat(agent): promote durable harness API 2026-08-04 17:01:43 +02:00
Cristina Poncela Cubeiro
f119b01cb1
refactor: update sqlite for lanes (#7591)
* feat: align sqlite storage with session lanes

* fix: delete lane from entry, action

* fix: errors and types

* fix: tests

* fix: usage records instead of session materialized

* chore: 1 mig

* fix

* refactor(agent): move harness experimental changes to split branch

* refactor and cleanup

* fix: use assertJsonSerializable for session metadata

* fix(sqlite): reject corrupt lane leafs on open

* fix: rebuild cache

* refactor: branch cache

* feat: session stats

* fix: enforce leases

* feat(agent): enforce fenced SQLite writer leases

* fix(agent): keep SQLite transactions synchronous

* fix(agent): align SQLite storage with conformance suite

---------

Co-authored-by: Christian Klotz <hello@christianklotz.co.uk>
2026-08-04 15:56:56 +02:00
Christian Klotz
33bc0a7b83
feat(client): add runtime-neutral session client
Split harness shutdown initiation from settlement so callbacks can request shutdown without deadlocking active work.
2026-07-31 12:19:19 +03:00
Christian Klotz
56eb685b69
feat(protocol): add remote session wire protocol 2026-07-30 21:45:58 +03:00
Cristina Poncela Cubeiro
8495f9d0d6
chore: rename orchestrator to server (#6898) 2026-07-21 13:32:42 +02: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
Armin Ronacher
a9f6a3159a
feat(ai): separate generated model data (#6765) 2026-07-17 11:08:48 +02:00
Cristina Poncela Cubeiro
7ece19b0e8 chore: package structure 2026-06-18 12:16:55 +02:00
Mario Zechner
4f7d756df8 Exclude optional Gondolin example from root check 2026-06-04 18:27:18 +02:00
Mario Zechner
b141e1fa24 chore: remove web-ui workspace 2026-05-20 02:26:09 +02:00
Mario Zechner
3e5ad67e0f chore: migrate pi packages to earendil works scope 2026-05-07 15:59:42 +02:00
Mario Zechner
0ed0d43439 remove mom and pods packages
People should check out pi-chat (earendil-works/pi-chat on GitHub), or use an older commit for mom and fork.
2026-04-30 23:01:19 +02:00
Armin Ronacher
35ff2689ee
fix(typebox): migrate to v1 with extension compat (#3474)
* fix(typebox): migrate to v1 with extension compat

Replace AJV-based validation with TypeBox-native validation, keep legacy extension imports working (including @sinclair/typebox/compiler), and restore coercion for serialized/plain JSON schemas.

This change closes #3112.

* fix(typebox): use canonical imports and harden coercion

Switch first-party code to canonical typebox imports while retaining legacy extension aliases in the loader.

Remove obsolete runtime codegen guards, expand serialized JSON-schema coercion coverage, and update related tests and fixtures.

Fixes #3112.

---------

Co-authored-by: Mario Zechner <badlogicgames@gmail.com>
2026-04-22 19:59:33 +02:00
Fero
170c66072d
fix(monorepo): resolve pi-ai subpaths to source files (#2625) 2026-03-29 17:27:27 +02:00
Mario Zechner
392fbc73cd fix(dev): map pi-ai oauth subpath in tsconfig paths 2026-03-04 20:30:10 +01:00
Mario Zechner
0f98decf65 Remove proxy package
The proxy functionality is now handled by web-ui's createStreamFn
with external proxy servers.
2025-12-30 22:42:21 +01:00
Mario Zechner
54018b6cc0 Refactor OAuth/API key handling: AuthStorage and ModelRegistry
- Add AuthStorage class for credential storage (auth.json)
- Add ModelRegistry class for model management with API key resolution
- Add discoverAuthStorage() and discoverModels() discovery functions
- Add migration from legacy oauth.json and settings.json apiKeys to auth.json
- Remove configureOAuthStorage, defaultGetApiKey, findModel, discoverAvailableModels
- Remove apiKeys from Settings type and SettingsManager methods
- Rename getOAuthPath to getAuthPath
- Update SDK, examples, docs, tests, and mom package

Fixes #296
2025-12-25 03:48:36 +01:00
Mario Zechner
030788140a WIP: Remove global state from pi-ai OAuth/API key handling
- Remove setApiKey, resolveApiKey, and global apiKeys Map from stream.ts
- Rename getApiKey to getApiKeyFromEnv (only checks env vars)
- Remove OAuth storage layer (storage.ts deleted)
- OAuth login/refresh functions now return credentials instead of saving
- getOAuthApiKey/refreshOAuthToken now take credentials as params
- Add test/oauth.ts helper for ai package tests
- Simplify root npm run check (single biome + tsgo pass)
- Remove redundant check scripts from most packages
- Add web-ui and coding-agent examples to biome/tsgo includes

coding-agent still has compile errors - needs refactoring for new API
2025-12-25 01:01:03 +01:00
Mario Zechner
909989066a Fix TUI performance regression: add caching to Box, use Text directly for built-in tools 2025-12-17 16:39:23 +01:00
Mario Zechner
0ef73ad1dc Add file-trigger hook example 2025-12-17 16:06:30 +01:00
Mario Zechner
e7097d911a Custom tools with session lifecycle, examples for hooks and tools
- Custom tools: TypeScript modules that extend pi with new tools
  - Custom TUI rendering via renderCall/renderResult
  - User interaction via pi.ui (select, confirm, input, notify)
  - Session lifecycle via onSession callback for state reconstruction
  - Examples: todo.ts, question.ts, hello.ts

- Hook examples: permission-gate, git-checkpoint, protected-paths

- Session lifecycle centralized in AgentSession
  - Works across all modes (interactive, print, RPC)
  - Unified session event for hooks (replaces session_start/session_switch)

- Box component added to pi-tui

- Examples bundled in npm and binary releases

Fixes #190
2025-12-17 16:03:23 +01:00
Peter Steinberger
c43f1d307c Add CI workflow and fix workspace tests 2025-12-02 12:53:53 +00:00