Commit graph

209 commits

Author SHA1 Message Date
Christian Klotz
9171697c0d
feat(mcp,coding-agent): publish a JSON schema for mcp.json (#12706)
Publishes a JSON schema for `mcp.json` at
`https://pi.dev/schemas/mcp.schema.json`, like the existing
models/settings/keybindings/theme schemas. Closes #12563.

## What

**pi-mcp** (owner of the shared `mcpServers` shape):
- New `./config-schema` export: the shared fields as a JSON Schema built
with pi-schema, following the pi-ai compat/model-schema pattern.
Field-level constraints (loopback `callbackUrl`, non-blank `clientName`,
port bounds, URL patterns, `protocol`) live here, next to the validator
they mirror.
- `McpStdioServerConfig`, `McpHttpServerConfig`, and `McpOAuthConfig`
now derive from the schema (`Static`), so schema and types cannot drift.
`McpHttpServerConfig.type` now includes `"streamable-http"`, which the
validator always accepted. The validator itself is unchanged, and the
root export does not load pi-schema (type-only imports).

**coding-agent**:
- `src/core/mcp-config-schema.ts` composes pi's fields (`exposure`,
`toolExposure`, `auth`, `autoEnableCodemode`, project override entries)
on top of pi-mcp's property maps, re-annotated with pi's behavior, and
`generate-schemas.ts` emits the committed `schemas/mcp.schema.json`.
- Entries, oauth, and the document root are closed objects: the loader
deliberately keeps unknown fields, so a mistyped key (`exposur`,
`mcpSevers`) changes behavior silently today; the schema flags it in the
editor.
- Docs: `$schema` line in `docs/mcp.md`, plus a section for the
previously undocumented `auth` field (separate commit).

## Intentional schema/runtime differences

Documented in the `mcp-config-schema.ts` header and asserted in the
tests: cross-field rules stay prose (override/`auth` file scoping, cimd
restrictions, port agreement), URL schemes must be lowercase, and
entries mixing `url` with `command` are flagged although the runtime
picks HTTP.

## Tests

- `packages/mcp/test/config-schema.test.ts`: schema/validator agreement
for the shared fields.
- `packages/coding-agent/test/config-schemas.test.ts`: fifth artifact
pinned, representative documents, a runtime-validator agreement test
(accept and reject lists plus the documented asymmetries), and a
compile-time key-parity guard against the runtime config types.
- `npm run check` clean; pi-mcp suite 199/199; coding-agent
config-schemas/documentation/references pass.

This PR is AI-generated.
2026-12-01 15:59:26 +00:00
Vegard Stikbakke
c80b089fb2 feat(ai): add openrouter-images API for POST /images 2026-12-01 14:07:21 +01:00
Mario Zechner
6a9fdb6ba0 fix(durable): one idle clock for an image thread (its pi-images instance lives as long as the thread), a new thread starts idle so a failed first send still lets it exit; the processor in processor.ts, the installed-wasm loader in installed.ts; docs on animated PNG and JPEG-LS (ERNDL-1340) 2026-11-30 23:01:18 +00:00
Mario Zechner
b8cbb65028 fix(durable): the image thread copies the caller's bytes and forgets only itself on exit, one fallback per host, the thread keeps pi-images' instance for its life; any error drops the burst's job; images go back unchanged only under the type their bytes are; ImageEncoder.shrink, the job as encoder; a 12 MP case in a Durable Object (ERNDL-1340) 2026-11-30 23:01:18 +00:00
Mario Zechner
3f71ce6e96 chore: /images/fit loads neither processor, pi-images included (ERNDL-1340) 2026-11-30 23:01:18 +00:00
Vegard Stikbakke
484da3a869 feat(coding-agent): remove telemetry
Remove telemetry reporting from pi for new installs or updates.
2026-11-26 14:51:47 +01:00
David Brailovsky
001ffff32b fix(ai): support xhigh thinking on Gemini 4 Hydrogen and Neon
Upgrade @google/genai from 2.32.0 to 3.6.1, which adds ThinkingLevel.XHIGH.
The Google adapters now send xhigh as thinkingLevel "XHIGH" instead of
failing before the request; models that use token budgets use the high
budget for it.

- Map the finish reasons added in 3.x (MISSING_THOUGHT_SIGNATURE,
  MALFORMED_RESPONSE, ESCALATION, PUP_LIMITED_DISABLED, MODEL_ARMOR)
  to error instead of throwing "Unhandled stop reason"
- Share one Gemini 2.5 thinking budget table between both adapters,
  which fixes Vertex Gemini 2.5 Flash-Lite getting Flash budgets
- Drop @google/genai from the install-script allowlist; 3.6.1 has no
  install script

closes #12184
2026-11-24 11:13:55 +01:00
David Brailovsky
b82477b7bb
fix(ai,coding-agent): make system the default instruction role in openai-completions (#12134)
TLDR:
On chat-completions api, change the default instruction role from
developer to system.

Inspired by: #12101 by @qoli

---
The trigger was #10741: Groq's qwen/qwen3.8-27b failed on the first
message:
`400: minijinja: rendering failed: raise_exception: Unexpected message
role.`

Problem: openai-completions sent the system messages of every reasoning
model with the `developer` role unless the catalog turned it off.
`developer` is OpenAI's role; many other hosts' chat templates reject
it, as Groq's Qwen template does.

Every new OpenAI-compatible provider or reasoning model hit the same bug
until someone added `supportsDeveloperRole: false` to the catalog; about
20 provider files carried that line. Nothing in models.dev says which
role a model accepts, so the catalog could not get this right on its
own.

Solution: detectCompat() now defaults supportsDeveloperRole to true only
for api.openai.com. Every other host gets `system`. This applies to the
initial system prompt and to mid-conversation system messages.

Built-in models whose role changes from developer to system:
- groq: 5 (gpt-oss and Qwen)
- xiaomi, xiaomi-token-plan-*: 9 MiMo models
- openrouter: 89 openai/* and anthropic/* models; 12 of them (newer GPT
models) also support mid-conversation system messages
(supportsMidConvoSystemMessages), which change role too All other
built-in Chat Completions models already sent `system`.

Why the default is only api.openai.com:
- api.openai.com keeps `developer` because OpenAI documents it as the
role for its reasoning models. In practice this rarely matters: the
built-in OpenAI models all use the Responses API, so it only affects
custom models that call OpenAI through openai-completions.
- Azure is excluded. Its built-in OpenAI models also use the Responses
API; its only built-in Chat Completions model is DeepSeek, which needs
`system`.
- OpenRouter is excluded: its Chat Completions reference accepts
`system` ("System message for setting behavior") and `developer` with
the same fields, and gives no reason to prefer `developer` for any model
(https://openrouter.ai/docs/api/api-reference/chat/create-a-chat-completion).
The openai/* and anthropic/* exception came in with #5309 without a
reported need.
- compat.supportsDeveloperRole still overrides the default.
- The Responses API has its own setting and is unchanged.

The now-redundant `supportsDeveloperRole: false` lines are removed from
the catalog and the llama extension.

How we checked it is safe: live requests to the affected hosts, each
model given the same instruction once as `developer` and once as
`system`:
- Groq qwen/qwen3.8-27b: developer 400, system OK. Groq gpt-oss-20b:
both OK.
- Xiaomi mimo-v2.6-pro and mimo-v2.6-flash: both roles OK.
- OpenRouter openai/gpt-5-mini, openai/gpt-oss-20b,
anthropic/claude-haiku-4.5, moonshotai/kimi-k2.6, qwen/qwen3.6-plus,
deepseek/deepseek-v4-pro: both roles OK.
- OpenRouter openai/gpt-5.4-mini and openai/gpt-5.5 with an instruction
added mid-conversation: both roles OK.

Released clients: they fetch new catalogs from pi.dev and still default
supportsDeveloperRole to true, so the removed `false` lines would make
them send `developer` to hosts that reject it. MINIMUM_PI_VERSION is
raised to 1.5.3 so they keep the last catalog published for them.

closes #10741 #12101
2026-11-20 09:32:28 +01:00
Armin Ronacher
76c79d8bbe fix(p2): fit images to the model's limits before they enter the transcript
p2 sent uploaded images at full size, so a phone photo failed the request
with a provider 400 and every later one in the conversation.

pi-durable gains @earendil-works/pi-durable/images/fit, a kit that works
with any ImageProcessor and does not load Photon: fitImage/fitImages for a
host's input, and the fit-images extension, an afterTool hook that fits the
images of every tool result before it is committed. Images are fitted once,
before they are stored, so the transcript and prompt caches stay stable.
Every image is decoded, as in the coding agent; one that cannot be prepared
is left out with a note. imageLimits(model) is shared with read.

p2 creates one Photon processor per worker (WorkerParts.images) and uses it
for read, for attachments (resizes noted next to the file) and in the new
fit-images plugin.
2026-11-14 19:28:29 +01:00
rometi
f72f799a4c
fix(ai): pass custom fetch to the Google GenAI SDK adapters (#12103)
## Problem

Both `google-generative-ai` and `google-vertex` reject a custom `fetch`
option.

I need this to route model requests through my own HTTP proxy, mainly to
control request URLs and inspect HTTP status codes and `Retry-After`
headers.

Without it, I have to use Google's OpenAI-compatible endpoint. However,
pi's `openai-completions` adapter does not read Gemini's thought
signatures from `extra_content`, so they are lost between tool calls.

## Changes

- Updated `@google/genai` from 2.21.0 to 2.32.0, which supports
`httpOptions.fetch`.
- Both Google adapters now pass `options.fetch` to the SDK through
`httpOptions.fetch`.
- Added handling for the CONTINUATION finish reason (enum and raw
string) as MAX_TOKENS, since the new SDK version introduces it.
- Replaced the test that expected the custom fetch rejection with one
that verifies it is used.
- Added a test for `FinishReason.CONTINUATION`.

## Tests

- `npm run check`: passed.
- Targeted tests: 7/7 passed.
- `./test.sh`: same failures as `main` without this change.

## Dependencies

- Lockfile changes are expected from the SDK version update.
- Updated `scripts/generate-coding-agent-install-lock.mjs` to move the
allowlist entry from `@google/genai@2.21.0` to `@google/genai@2.32.0`.
Its `preinstall` script is still a no-op.

Closes #12097

---------

Co-authored-by: Petr Houška <houskape@gmail.com>
2026-11-12 22:09:35 +01:00
robopipi[bot]
4cfea97861
Fix standalone binary not resolving extension dependencies via package.json main/exports (#12046)
The standalone binary is built with `bun build --compile`, and that
defaults `--compile-autoload-package-json` to off. With it off, the
compiled executable never reads `package.json` at runtime. So when an
extension or one of its dependencies imports a package whose entry point
is declared only in `main` or `exports` (`shiki`, `yaml`, `graceful-fs`,
…), it fails with `Cannot find package 'shiki' from '…'`. Packages with
a root `index.*` still resolve. jiti's fallback resolver hides part of
this while extensions load, but imports made later from inside an
already-loaded dependency have no fallback. Shiki's lazy loaders are one
such case, which is why pi-fabric's highlighting fails. Node, plain Bun,
and the same binary run with `BUN_BE_BUN=1` all resolve these packages.

This change adds `--compile-autoload-package-json` to:
- both `bun build --compile` lines in `scripts/build-binaries.sh`
(Windows and others);
- the `build:binary` script in `packages/coding-agent/package.json`.

No other `bun build --compile` call exists in the repo; CI goes through
`build-binaries.sh`.

The bunfig and `.env` autoloads stay disabled (#7684, #10473). A
`package.json` in the working directory did not change pi's behavior in
testing. I tried malformed JSON, `type: module`/`commonjs`, `imports`,
and `browser` fields: no output, no crash, and extensions loaded the
same.

Testing:
- I built the real binary with Bun 1.4.4 (the version CI uses), with the
old flags and with the new ones. My test extension `require`s a
`main`-only package, and imports a package that itself does
`import("dep")` lazily.
- Old flags: `dep: FAIL Cannot find module 'dep'` and `lazy import: FAIL
Cannot find package 'dep' imported from …/node_modules/lazy/lib/x.js`.
  - New flags: `dep: resolved | control: resolved | lazy import: ok`.
- A minimal compiled Bun script shows the same difference for packages
that use only `main` and only `exports`.
- `npm run check` passes.
- I added no automated test. It would need Bun and a compile step, and
nothing in the test suite builds the binary.

Fixes #12012

Requested by @badlogic

Co-authored-by: triagent <triagent@localhost>
Co-authored-by: Mario Zechner <contact@badlogicgames.com>
2026-11-11 13:14:18 +01:00
David Brailovsky
b0ebcafc78 fix: CI checks that released changelog sections match their tag
Entries merged after a release land under its heading: the diff anchors on
lines the release left under ## [x.y.z] (PR #11975 after v1.5.1). CI fetches
the newest release tag and compares each changelog's released sections.
2026-11-10 16:55:20 +01:00
David Brailovsky
2930f5220c fix: release scripts find published packages only in packages/*
getPublicWorkspacePackages walked every folder under packages/, so leftover
build output (packages/coding-agent/binaries/<platform>, with copies of the
coding-agent's package.json and CHANGELOG.md) was packed as duplicate
packages. It now reads only the direct subfolders. The release's changelog
updates and sync-versions' lockstep check and version table use the same
list; with the copies counted, sync-versions failed the next version bump.
2026-11-10 15:42:52 +01:00
David Brailovsky
681d3a4de9 fix: release requires npm 11 or newer
npm 10 (bundled with Node 22) drops the libc fields of native packages
from package-lock.json when the release rewrites it.
2026-11-10 15:42:52 +01:00
David Brailovsky
058496badc fix: release version bumps only the top-level packages
npm version --workspaces also bumped private workspaces (Chord's tutorial app,
the extension examples, p2), which broke the tutorial book's quote check at
every release. --workspace packages selects packages/* only; sync-versions
still updates every package's dependencies.
2026-11-10 14:48:41 +01:00
David Brailovsky
4657d5428b fix: sync-versions only pins dependencies on published packages
The version table included private packages, so release bumps rewrote
Chord's example fixtures (file: and git+file: references) to registry versions.
2026-11-10 14:48:40 +01:00
Mario Zechner
8a19e8c4a2 fix(scripts): biome-check skips files Biome does not support, as the CLI does
The WASM workspace throws "The file does not exist in the workspace" for a file it has no language for (a
Dockerfile, a shell script) instead of skipping it, so npm run check crashed on platforms without the native Biome
(Android). Ask the workspace's file features first and skip unsupported files.
2026-11-06 07:47:14 +01:00
Christian Klotz
7a52c2108d
feat: release version tags on pkg.earendil.com (#11686)
## Problem

`scripts/release.mjs` pushes `Release vX.Y.Z` and `Add [Unreleased]
section…` to main in one push, then pushes the tag. CI builds only the
pushed head, so the tagged release commit is never built and
pkg.earendil.com has no build of a release. Example: for v1.4.0, v1.3.0
and v1.2.0 the tagged commits have Build Binaries and Nix runs, but no
CI run.

Internal users want to install a release from pkg.earendil.com as soon
as it is tagged, without waiting for the npm release.

## Change

- `ci.yml` also runs for `v*.*.*` tags (the pattern `nix.yml` uses), so
the tagged commit is built and packed.
- `preview-packages.yml` also publishes passing CI runs of release tags:
`POST /_/releases` keeps the packages for good under the tag (it never
moves), then the `latest` ref moves to it. Pre-releases (`v1.2.3-rc.1`)
are released without moving `latest`.
- `scripts/preview-packages.mjs publish` decides what a push run
publishes (the workflow passes the run's branch and conclusion), reading
the GitHub API with `fetch` before anything is uploaded. A tag push's
`head_branch` is the tag's name, and a branch or tag can carry its own
copy of CI, so:
- every push run must be for a commit on main, comparing against main's
resolved SHA (a bare `main` in compare would resolve to a tag named
`main`);
- a release tag must match `^v\d+\.\d+\.\d+(-[0-9A-Za-z.]+)?$`, have
passing CI (CI packs before its tests run), and point at the commit,
dereferencing annotated tags, also nested;
  - other names publish nothing.

This also closes an existing hole: a tag named `main` on an unreviewed
commit could move the `main` ref.
- A release happens after the uploads and before moving refs, so
`latest` never points at a failed release. The job summary lists the
release's install commands.
- A passing push run whose CI artifact expired (3 days) fails with
"re-run CI" instead of passing silently, so a release tag cannot go
unreleased unnoticed.

## Before / after for a release

| | Before | After |
|---|---|---|
| CI of the tagged commit | none | build, test, pack |
| `pkg.earendil.com/<package>@vX.Y.Z` | 404 | kept for good |
| `…@<release sha>` | 404 | kept for good |
| `…@latest` | none | moves to each release |
| npm, binaries, pi.dev, Nix `stable` | unchanged | unchanged |
| main and PR previews | unchanged | unchanged |

Tag CI runs trigger Publish Model Catalog and Nix, which skip them
(`head_branch != main`).

## Before merging

- [x] Deploy pkg.earendil.com with `POST /_/releases` (earendil-pkg
`7955990`); until then a tag run fails at the release call and `latest`
does not move.

## Recommended (not required by this PR)

Add a ruleset restricting creation, update and deletion of `v*` tags to
maintainers / the release process. The checks above already keep
unreviewed code out (every push run must be for a commit on main), but
anyone with write access can push a `v*` tag on any main commit. On
pkg.earendil.com that release is kept for good, takes the version number
(the real release then gets `409` there) and moves `latest`, with no
approval gate like npm's `npm-publish` environment. Build Binaries (npm)
and Nix (`stable`) also act on `v*` tags today.

## Checks

`npm run check`; `node --test scripts/preview-packages.test.mjs` (10
tests, under 2s, against a fake server for pkg.earendil.com and the
GitHub API with raw API responses). Each of these mutations fails a
test: bare `main` in compare, wrong API field names, no on-main check,
no tag target check, one-level tag dereference, `latest` for
pre-releases, unanchored or loose tag pattern, no CI conclusion check,
dropping `identical`. actionlint reports only the existing `queue:`
complaint.
2026-11-05 10:01:01 +00:00
David Brailovsky
5f6198c397 remove temp issue triage scripts 2026-11-05 08:32:50 +00:00
Mario Zechner
05dc8d239d feat: add apps/p2 (imported from pi-private at 7dadff697)
p2 (Pi Mobile on Chord v2) moves from pi-private into pi as one commit. Root scripts that loop all workspaces
use --if-present; npm test, ./test.sh and the release script cover packages/* only (p2: cd apps/p2 && npm test);
sync-versions also updates apps' workspace pins.
2026-11-03 13:39:06 +00:00
Mario Zechner
ed4f488401 feat(chord): remove Chord v1 (/old, /old/node), its tests and docs
p2 runs on Chord v2; apps still on v1 pin @earendil-works/chord@1.5.0.
2026-11-03 12:11:22 +00:00
David Brailovsky
00967748dc feat: issue triage UI shows untriaged issues and agent conversations 2026-11-02 23:25:24 +00:00
Mario Zechner
e9c0ff4d84 feat(chord): Chord v2 is the package's root
src/next is src (the main export), src/next-node is src/node with short subpaths (/http, /workers, /plugins,
/plugins/runtime, /app, /surfaces, /web, /react, /tui, /tui/launcher); the foundations get /json and /watch;
Chord v1 moves to src/old (/old, /old/node) until p2 runs on v2; tests and docs move likewise (test/, docs/,
test/old, docs/old). Durable and env import the foundations from their subpaths.
2026-11-02 22:36:55 +00:00
Vegard Stikbakke
62752fd4c3
fix(coding-agent): serve catalogs without version redirect (#11690)
Update the model catalog protocol to pi.dev after a change to stop
pi.dev redirecting released clients to `?pi-version=` URLs and serve
their catalog directly. The released CLI is unaffected.
2026-11-02 14:42:17 +01:00
Mario Zechner
6536f80129 feat(ai,agent,coding-agent): validate tool arguments with pi-schema, drop TypeBox
pi-schema: opt-in coercion, compile(schema, { coerce: true }) with coerce() and
parse(), the superset of TypeBox's Value.Convert rules and pi-ai's old coercion;
unresolvedRefs option; url and json-pointer-uri-fragment formats.
pi-ai: Tool takes any JSON Schema; validation through pi-schema; Type, Static
and TSchema are no longer exported (breaking). pi-agent-core and pi-durable:
tools on pi-schema, no TypeBox dependency. Coding agent: extensions keep Type,
Static, TSchema and StringEnum through an extension view of pi-ai; built-in
tools stay on TypeBox.
2026-11-01 10:08:42 +00:00
Mario Zechner
fab2c5353e feat(schema): add pi-schema, JSON Schema builders and validation without eval
@earendil-works/pi-schema compiles JSON Schema (drafts 2020-12 and 7) once into
plain closures: no eval or new Function, so it runs under a strict CSP. It
passes 2,222 of the 2,223 core tests of the official JSON-Schema-Test-Suite,
checks Chord-style argument schemas within 1.2x of TypeBox's JIT, and keeps
3,200 compiled schemas in 7.9 MB (TypeBox: 54.7 MB).

- compile(schema, options) returns a Validator: check() is the boolean check
  (a type guard for builder schemas), errors() reports each failure with a
  JSON Pointer path, missing and unknown fields at the field.
- Builders (str, int, obj, opt, union, ...) return plain JSON Schema typed with
  the values it accepts (Static<typeof schema>).
- Formats are an optional entry point (./formats), adapted from TypeBox (MIT).
- Tests run the vendored suite (drafts 2020-12 and 7, with optional and format
  tests); npm run bench compares conformance, speed, setup cost, memory and
  bundle size with TypeBox, @cfworker/json-schema and omptype.
2026-10-31 21:39:34 +00:00
Armin Ronacher
b4c2e92acb fix: remove vulnerable dependency chains
Replace build-time shell utilities with Node filesystem operations and retire the native sandbox example in favor of existing isolation options. Upgrade glob matching and worker-test dependencies and refresh the lockfiles.
2026-10-31 17:54:29 +01:00
Mario Zechner
e5c6182bab feat(durable): group commit and batch Storage.commit
A Session no longer holds its line while a commit is stored. Commits that
arrive while one storage call is in flight go out together in the next call,
each with its own seq and outcome; a job runs until it touches a key an
unpublished commit wrote, then waits for that commit's publication. Outcomes
are delivered in line order; publication is in line order, one commit per
macrotask. The scheduler's decisions run as regions that record the keys they
read and rerun after a wait, with side effects only after a clean check.

Storage.commit(batches, receive, context) replaces commit(writes, adopt,
context): prefix semantics (Durable's own checks refuse a batch and keep the
ones before it; any other failure rejects the call), receipts per stored
batch, optional publishing() scope. Memory, SQLite, JSONL, IndexedDB and
StoreStorage implement it natively; StoreStorage through the new
ChordStore.commitSeries (one store transaction per call), replacing
commitInBatch.

A normal run makes no storage reads: bounded record cache, conversation
tails, task-document index, kept context ranges. A tool slot's running status
and a generation's attempt are stored with the next commit (12 instead of 14
commits per run).

One Harness with 128 conversations over storage with a 4 ms round trip: about
5 -> 440 agent runs per second. Design: packages/durable/docs/group-commit.md.
2026-10-30 10:41:11 +00:00
Mario Zechner
6eb99ad65b feat(chord): Chord v2 slice 8, registries and host.root
Registries: shared tokens (defineRegistry), one provider per host (host.serve(R, { compose, accepts })),
contributions from facets and host-lifetime objects, plain values or followed Chord watchables, a table
sorted by plugin, lazy compose in the batch that changed the table, failures left out and reported with
the last good value kept; self.registry as a declared dependency, host.registry outside objects, older
readers mapped by accepts[old].value; keyedEntries and orderedEntries. Native sources: self.writable,
registry values and ref.state. self.retryOn wakes failed objects on registry values. host.root gives code
outside objects a call scope sealed at settle, abort and host.close.

Durable: registryReader(value, context); a Session close ends synchronous observers failed
("session closed"), watches still end ended.
2026-10-28 21:34:56 +00:00
Armin Ronacher
2e0f175bd5
feat(ai): refactor provider definitions (#11368)
This builds the model catalog from per-provider definitions and
models.dev v2 data.

It eplacer `generate-models.ts` with one `defineProvider()` file per
built-in provider, shared model-family rules (Claude, GPT, DeepSeek,
Kimi, Google), and source adapters. models.dev is read through its v2
API. Outputs and CLI flags are unchanged.
2026-10-28 11:06:10 +01:00
robopipi[bot]
0eea54f11c
fix: normalize path separators in check-entry-graphs on Windows (#11399)
`scripts/check-entry-graphs.mjs` built the list of files each export
reaches with `path.relative()`, which returns paths with `\` separators
on Windows. The allow and forbid patterns are written with `/`, which
caused two problems on Windows:

- The allow entry `packages/telemetry/src/index.ts` never matched, so
the bare `index.ts` forbid pattern flagged it and the check failed even
though nothing was wrong.
- Forbid patterns that contain a `/` (`providers/`, `runtime/host.ts`,
...) never matched, so real violations went unreported.

The fix converts the relative paths to `/` before any comparison. On
Linux and macOS nothing changes.

Testing:
- The scripts have no unit tests, so no test was added.
- `node scripts/check-entry-graphs.mjs` and `npm run check` pass on
Linux.
- I simulated Windows path handling with `path.win32`, without running
Windows itself:
- Before the fix: `relative(...)` gives
`packages\telemetry\src\index.ts`, and
`endsWith("packages/telemetry/src/index.ts")` is false.
- After the fix: the path becomes `packages/telemetry/src/index.ts`, and
the suffix check is true.

Fixes #11333

Requested by @badlogic

Co-authored-by: triagent <triagent@localhost>
2026-10-25 08:54:24 +01:00
Mario Zechner
d8d99950ac feat(chord,durable): PendingOps folds pending ops for slow consumers; Watch delivers one call per busy period
- chord/delta: PendingOps (push, size, take -> PendingTake): raw pending ops, r drops everything
  before it, a leaf index merges appends and primitive sets per path (cleared by any other op),
  past 10,000 ops only "replace with the current value"; one batch is kept by reference and
  received ops are never mutated
- chord: Watch queues frames in PendingOps while its listener is busy or not started and delivers
  one call with the newest value, the folded ops (or [["r", newest]] after an overflow) and the
  newest frame's context; replaces the 100-frame collapse. NativeWatch is unchanged and takes an
  optional replace()
- durable: watchEvents keeps every event batch in order (NativeWatch with a snapshot replace);
  document, view and task-graph watches fold; spec, README, example 04 and tests updated
- tests: fold fuzzers (tracker, appendText, splices/reorders, root arrays, diffRevisions) with
  codec round trips, adversarial cases, cap, ownership, cost and GC guards
2026-10-24 09:37:12 +00:00
Mario Zechner
da412b0392 feat(chord,durable): appendText for cheap string appends; Durable partial commits append instead of reassigning
Follow-up to #9265.

- chord: Delta appendText(draft, key, text) / StringKeys<T> record an append op without the
  O(length) prefix compare that a plain `draft[key] += text` costs in prepare()
- durable: partial commits append text and thinking deltas with appendText (assignJson plan,
  checked by length), and apply tool-call argument changes from their own StreamingJsonParser
  of the raw toolcall_delta text instead of reassigning the arguments snapshot
- durable "." entry-graph budget 73 -> 76 for the parser it now imports
2026-10-24 08:21:41 +00:00
David Brailovsky
a1836b06c3 fix: handle npm 12 pack --json output in preview-packages 2026-10-23 11:20:01 +02:00
Christian Klotz
db774055e3
Set up preview packages (#11260)
* feat: publish preview packages to pkg.earendil.com

CI packs every public package after the build, with internal dependencies
pointing at the same commit's builds. A workflow_run job publishes them to
the earendil-pkg worker with the job's GitHub OIDC token, moves main or
pr-<n>, and comments install commands on the PR. Closing a PR deletes its
ref. pi-env is left out because its daemons are only built for releases.

* feat: publish preview packages only for main and same-repo PRs

pkg.earendil.com requires a consumer token, so fork authors could not
install their previews anyway. Fork PRs are no longer packed or
published, which keeps fork code out of the registry and removes the PR
lookup: the PR number now comes from the workflow_run event. The PR
comment is dropped; the job summary lists the install commands.

* fix: pick the PR into main and describe only the workflow in preview-packages.yml

- Read the PR number from the workflow_run pull request list with jq,
  selecting the PR into main; a branch can also have PRs into other
  branches, and the index expression tripped workflow linters.
- Comments describe what the workflow does and what it needs from
  pkg.earendil.com, not how the service works.

* fix: gate preview publishing to main pushes and open PRs into main

- Publish only CI runs for pushes to main and for pull requests. A branch
  can make its own copy of CI run on push; those runs are unreviewed and
  were uploaded as push builds.
- Move pr-<number> only while the PR is open into main with this commit
  as its head, checked live, so a late publish cannot recreate the ref of
  a closed PR; otherwise publish without a ref and print a notice.
- Set concurrency per job, so skipped fork runs never wait in a group.

* docs: drop the service rule from the preview-packages.yml header

* docs: name the earendil-works/pkg worker in the preview script
2026-10-22 11:43:08 +02:00
Armin Ronacher
cae9fd28a2 Revert "feat(durable): replicate storages as a commit log"
Some checks are pending
CI / build-check-test (push) Waiting to run
CI / mcp-conformance (push) Waiting to run
This reverts commit 4c25119f54. The work continues on the replication branch.
2026-10-21 14:39:26 +02:00
Armin Ronacher
4c25119f54 feat(durable): replicate storages as a commit log
Every built-in storage implements ReplayableStorage: head(), replay() at an explicit sequence, and export() of the current state as a log that replays to the same reads. SQLite schema version 3 adds sequence indexes so export streams. @earendil-works/pi-durable/sync adds ReplicatingStorage, which appends each committed batch to an outbox with fork copies resolved, compactRecords(), and versioned JSON log lines.
2026-10-21 14:26:19 +02:00
Armin Ronacher
adc5fa9f80 feat(ai,agent,coding-agent): move client identity and provider attribution into pi-ai
pi-ai gets a ClientIdentity request option and createModels() default that choose the User-Agent (detailed with version, short, or custom) and provider attribution headers for OpenRouter, NVIDIA NIM, and OpenCode. Attribution is off by default in pi-ai and on by default in pi-agent-core and pi-durable (HarnessOptions.identity). pi-coding-agent sets its identity from the telemetry setting instead of adding headers itself.
2026-10-21 11:17:02 +00:00
Mario Zechner
5c1736f82d feat: checkpointWhen is required on Durable document definitions
Breaking change: defineDoc and defineDocFamily now require an explicit checkpointWhen predicate; no default is supplied. Set policies on built-in documents, examples, tests, and triage state, and document the required API.
2026-10-19 18:17:42 +00:00
Mario Zechner
2ec55d808d feat: Durable and pi-ai telemetry; Context.telemetry is always a span
Some checks are pending
CI / build-check-test (push) Waiting to run
CI / mcp-conformance (push) Waiting to run
- pi-ai: AI_TELEMETRY_SCHEMA; pi.ai.request and pi.ai.poll spans around Models requests via a lazyStream observer
  (no provider changes), first_chunk and block events (never per delta), usage/cost end attributes, provider_error
  status with a bounded message, aborted stays ok; duration, first-chunk, token and cost metrics; option renamed
  telemetryContext -> telemetry (a parent span)
- pi-telemetry: TelemetryContext carries readonly metrics and propagation capabilities on every span
- chord/context: Context.telemetry is always a TelemetrySpan (NOOP default); withTelemetry takes spans
- durable: DURABLE_TELEMETRY_SCHEMA; pi.durable.submit (inputs start their own trace linked to the caller) and
  pi.durable.phase spans for every task phase; stored carriers on submissions and tasks (TaskOptions.trace, links);
  entry, submission, checkpoint, replay and report events after commit; resumed tasks stay in their trace; phase
  duration, active task and report metrics; failed phases carry fixed categories with bounded messages
2026-10-19 06:26:02 +00:00
Mario Zechner
48909d987a feat: telemetry propagation, span links and metrics; telemetry member in chord/context
- pi-telemetry: TelemetryPropagation (inject/extract, opaque carriers), span links (SpanOptions.links, addLink),
  TelemetryMetrics (counter, up-down counter, histogram), typed metric schemas (createTypedMetrics), in-memory
  measurement log, conformance tests for propagation and metrics
- chord/context: fixed Context.telemetry member (NOOP default), withTelemetry, traceIn
- durable: HarnessOptions.telemetry option type (no instrumentation yet)
2026-10-18 20:36:08 +00:00
David Brailovsky
4954d76050
feat: check the model catalog against the latest release before publishing (#11007)
pi.dev serves each published catalog to released pi >= MINIMUM_PI_VERSION.
Compile the latest release's pi-ai against its built-in models overlaid by
the new catalog, so a catalog it cannot handle (e.g. kimi-coding moving to
openai-completions) fails in CI instead of breaking released clients.
MINIMUM_PI_VERSION moves to scripts/model-catalog-minimum-version.mjs.
2026-10-15 21:21:57 +02:00
Armin Ronacher
d05a73fb31 fix: keep the Nix model catalog pin buildable
The pin script discovered the catalog with the checkout's version, which on
main is the last release, so pi.dev answered with the catalog for released
clients after MINIMUM_PI_VERSION was raised. It now pins the newest
published catalog and treats the pin as stale when its provider/type/API
model groups differ. The release script pins the newest catalog and runs
the Nix build steps before tagging.

closes #10985
2026-10-15 20:16:03 +02:00
David Brailovsky
a3f265b1c6 feat(ai): use Chat Completions for the kimi-coding provider
Some checks are pending
CI / build-check-test (push) Waiting to run
CI / mcp-conformance (push) Waiting to run
Environments / daemons (push) Waiting to run
Environments / check (push) Blocked by required conditions
Environments / release-daemons (darwin-arm64, macos-latest) (push) Blocked by required conditions
Environments / release-daemons (darwin-x64, macos-latest) (push) Blocked by required conditions
Environments / release-daemons (linux-arm64, ubuntu-24.04-arm) (push) Blocked by required conditions
Environments / release-daemons (linux-x64, ubuntu-latest) (push) Blocked by required conditions
Environments / release-daemons (windows-arm64, windows-11-arm) (push) Blocked by required conditions
Environments / release-daemons (windows-x64, windows-latest) (push) Blocked by required conditions
Environments / tests (macos-latest) (push) Waiting to run
Environments / tests (ubuntu-24.04-arm) (push) Waiting to run
Environments / tests (ubuntu-latest) (push) Waiting to run
Environments / tests (windows-11-arm) (push) Waiting to run
Environments / tests (windows-latest) (push) Waiting to run
Switch kimi-coding to OpenAI Chat Completions at api.kimi.com/coding/v1,
the protocol the official Kimi Code client uses. K3, K3-256K, and Kimi For
Coding accept tools declared in later system messages, so tools loaded
mid-conversation (e.g. by tool_search) keep the prompt cache. Highspeed
rejects tool-bearing system messages and keeps added tools top-level.

Re-lands b06c1f2 (reverted in 6a1f799b6) with MINIMUM_PI_VERSION bumped
to 1.2.1. Released clients implement only Anthropic Messages for
kimi-coding and ignore a model's api, so they must keep receiving the
last catalog published under 0.80.7.

closes #10720
2026-10-15 15:29:11 +02:00
Armin Ronacher
f13c00fb3a fix: pin internal dependencies to exact versions
Some checks failed
CI / build-check-test (push) Waiting to run
CI / mcp-conformance (push) Waiting to run
Environments / tests (windows-latest) (push) Has been cancelled
Environments / daemons (push) Has been cancelled
Environments / tests (macos-latest) (push) Has been cancelled
Environments / tests (ubuntu-24.04-arm) (push) Has been cancelled
Environments / tests (ubuntu-latest) (push) Has been cancelled
Environments / tests (windows-11-arm) (push) Has been cancelled
Environments / check (push) Has been cancelled
Environments / release-daemons (darwin-arm64, macos-latest) (push) Has been cancelled
Environments / release-daemons (darwin-x64, macos-latest) (push) Has been cancelled
Environments / release-daemons (linux-arm64, ubuntu-24.04-arm) (push) Has been cancelled
Environments / release-daemons (linux-x64, ubuntu-latest) (push) Has been cancelled
Environments / release-daemons (windows-arm64, windows-11-arm) (push) Has been cancelled
Environments / release-daemons (windows-x64, windows-latest) (push) Has been cancelled
Update release synchronization and dependency checks to enforce exact versions. Refresh both lockfiles and add regression coverage.

closes #10865
2026-10-13 14:28:15 +02:00
Mario Zechner
6db4070f17 docs: describe only the current Chord, Durable, and coding-agent code
Chord: README rewritten for the new runtime; notes.md and requests.md removed, their open limits and
decisions folded into spec.md section 12; guide and spec status lines updated. Durable: drops the
pico-v5 handoff and delta findings, renames the Pico spec, and uses current Chord terms. Delta README,
issue categories, and PI_RADIUS_GATEWAY updated.
2026-10-12 10:47:09 +00:00
Mario Zechner
0104fef1e9 feat(chord): replace the facet and service runtime with the chord2 host runtime
Moves chord2 (contracts, objects, cells, roots, plugins, hot reload, memory/IPC/WebSocket links)
from p2 into packages/chord, with its tests (now on vitest) and docs. The root export is the new
runtime plus the shared base (Context, JsonValue, JsonRepresentation, Draft, copyJson, isJsonValue,
replicatedState and its types). ./node now holds the host manager, child control, process locks,
and nodeLoader. ./context and ./delta are unchanged; ./bundler is removed.

replicatedState stays a standalone module with the same exports. It no longer exposes the exact-op
subscription the removed service provider used, so listener failures of mutable states are always
reported asynchronously. The package depends on typebox instead of esbuild. The wire format stays JSON.
2026-10-12 10:41:59 +00:00
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
Mario Zechner
97195ec3c4 build: share root config with pi-private
Some checks failed
CI / build-check-test (push) Waiting to run
CI / mcp-conformance (push) Waiting to run
Environments / tests (macos-latest) (push) Has been cancelled
Environments / tests (ubuntu-24.04-arm) (push) Has been cancelled
Environments / tests (ubuntu-latest) (push) Has been cancelled
Environments / tests (windows-11-arm) (push) Has been cancelled
Environments / tests (windows-latest) (push) Has been cancelled
Environments / daemons (push) Has been cancelled
Environments / check (push) Has been cancelled
Environments / release-daemons (darwin-arm64, macos-latest) (push) Has been cancelled
Environments / release-daemons (darwin-x64, macos-latest) (push) Has been cancelled
Environments / release-daemons (linux-x64, ubuntu-latest) (push) Has been cancelled
Environments / release-daemons (linux-arm64, ubuntu-24.04-arm) (push) Has been cancelled
Environments / release-daemons (windows-arm64, windows-11-arm) (push) Has been cancelled
Environments / release-daemons (windows-x64, windows-latest) (push) Has been cancelled
Everything outside apps/ is the same in pi and pi-private; apps/ exists only
in pi-private, and these files now tolerate its absence:
- workspaces include apps/*
- biome.json leaves apps/ to its own config
- the pre-commit hook runs the apps/mobile check only when it exists
- the Android APK workflow runs only in earendil-works/pi-private
- scripts/biome-check.mjs runs native Biome, or Biome WASM on Android
  (@biomejs/wasm-nodejs 2.3.5), for npm run check
From pi-private bac58de97, c2a8629da, 106714ebc.
2026-10-11 16:36:26 +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