Repository navigation
Use published Pi version and clean up the PiHarness options - #2423
Merged
Merged
Conversation
The vendor existed because npm 0.99.1 predated pi's events API. 0.99.2 ships it -- watchEvents, AgentEvent, AgentEventStream, SnapshotEvent, MessageChange -- so the reason is gone. Checked before switching: the exported surface of the vendored build is a strict subset of published 0.99.2. Nothing is in the vendor that is not on npm, and 0.99.2 adds the ten compaction types. pi-ai's surface is identical. Every pi symbol src/harness imports compiles against 0.99.2 under --strict. Two of the four features the vendor was justified by -- the inbox and ownership -- were already in published 0.99.1, and subagents are absent from the vendored build too. Deletes 1.5 MB of tarballs, pack.mjs and SHA256SUMS. Two consequences worth knowing: - The repo sets minimumReleaseAge: 1440, so a pi release under 24h old will not install. 0.99.2 needed @earendil-works/* added to minimumReleaseAgeExclude. That list is a supply-chain control, so the entry is deliberate rather than incidental -- the alternative is waiting for each release to age out. - Published chord depends on esbuild (~12 MB), which the vendored archive stripped. It is only used by chord's Node bundler and never reached from a Worker; worth an upstream ask to make it an optional peer.
PiHarnessOptions becomes a discriminated union. The declarative form is
unchanged in spirit -- give models and the harness opens pi itself -- and
a harness factory form lets a caller own the Harness.open call.
type PiHarnessOptions = PiHarnessCommon & (
| { models: Models; env?; onReport?; harness?: never }
| { harness: PiHarnessFactory; models?: never; env?: never; onReport?: never }
);
The factory receives the already-open store, the registry the harness
built from tools/systemPrompt/skills/configure, and a context, so it only
decides how pi is opened. Use it for a HarnessOptions field the
declarative form does not forward, to wrap the Harness, or for a custom
registry.
A union rather than replacing the declarative fields, because models, env
and onReport are Harness.open arguments: if a factory owns the open they
must move with it, or two places could set them and a precedence rule is
needed. The never branches make that a type error instead. The
registry-building fields are not Harness.open arguments -- they run before
it -- so they stay shared and a factory caller still gets
tools/systemPrompt/skills.
Two groupings come with it. defaults{model,thinkingLevel,retry} replaces
three top-level fields whose 'new sessions only' semantics were invisible
at the call site. timing{sleepThresholdMs,waitBudgetMs,heartbeatMs}
replaces module constants a test could not shorten; the fixture now sets
heartbeatMs 1s so the suite does not sit on the real 30s heartbeat. The
constructor rejects a non-positive timing.
Tests: adds options.test.ts and a PiFactoryTestObject so both
construction paths are covered at runtime, not just in the types -- a
prompt answered through a caller-supplied Harness, a tool round proving
the registry handed to the factory is the one in force, and the wake
still parking with no alarm. Mutation-checked rather than trusted green:
forcing #doOpen down the declarative branch fails two of the three. The
third passes either way by design and says so.
Typecheck clean, 41/41 tests pass.
PiHarnessOptions drops the declarative/factory union. The harness factory
is the one required option and owns Harness.open, so models, env and
onReport live there:
type PiHarnessOptions = {
harness: PiHarnessFactory; // ({ storage, context }) => Harness
defaults?: PiSessionDefaults;
store?: PiSessionStoreOptions;
timing?: PiWakeTiming;
};
The registry moves to the caller too. systemPrompt, tools, skills and
configure only wrote into a registry the harness never read, so the host
now composes pi's own Registry and passes it to Harness.open. Skills
become an addSkills(registry, sources) helper the factory awaits.
PiSessionSockets takes the registry as a RegistryReader for its tool
list, since pi's Harness does not expose the one it was opened with.
defaults, and defaults.model, are optional. A session without a model
ends its prompts unanswered with pi's no_model reason until setModel.
The factory test fixture, now identical to the main one, becomes a
no-defaults fixture covering that.
Local types that pi already publishes are replaced with pi's: PiJson
with JsonValue, PiMessageInput and PiImage with UserInput, PiToolContent
and the text/image message parts with TextContent | ImageContent. The
asJson cast, userInput() and toolContent() conversions go with them.
🦋 Changeset detectedLatest commit: 048df07 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
🟡 agents import sizes: 2 entry points grew
Changed exports (9)
How this worksEach runtime export is bundled on its own, minified, and gzipped. Changes smaller than 100 B, or smaller than 1% and 1 KiB, are ignored. Growth over 10% or 5 KiB is marked 🔴. This report is informational and does not fail CI. The workflow artifact contains every measurement. Compared |
Contributor
Author
|
@agent-think can you bump the pi-recovery dependency to the same pi version as used by this branch to avoid the serif issue. |
sherif rejects the workspace for declaring @earendil-works/pi-ai at two ranges: ^0.99.2 in the pi harness example and ^0.80.2 in experimental/pi-recovery. Move pi-recovery to ^0.99.2. pi-recovery also uses @earendil-works/pi-agent-core, whose last release is 0.84.1 and which depends on its own pi-ai. With two pi-ai copies its AgentMessage and pi-ai's Message no longer type-check against each other, so a scoped pnpm override points pi-agent-core at the workspace's pi-ai. pi-recovery type-checks, its codec tests pass, and its SIGKILL recovery e2e passes against the single 0.99.2 copy. The pi harness README introduction still described an unreleased pinned pi build; it now points at the published npm packages.
| - "@typescript/*" | ||
| - "@earendil-works/*" | ||
| overrides: | ||
| "@earendil-works/pi-agent-core>@earendil-works/pi-ai": "^0.99.2" |
Contributor
The Python installer dropped every .dist-info/ file from installed wheels, so importlib.metadata.version() found no distribution for any package installed from PyPI. FastAPI 0.142 imports OpenTelemetry at startup, and opentelemetry.context calls uuid4() at import time, outside a request. The Workers Python SDK permits that entropy call for known packages after checking the package version with importlib.metadata, which raised PackageNotFoundError for fastapi and stopped the Worker from starting. The e2e tests that import fastapi failed on every attempt. Keep each distribution's METADATA file and continue to skip the rest of .dist-info/ and .data/.
agents
@cloudflare/ai-chat
@cloudflare/codemode
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR now pins the
@earendil-works/pi-durablepackage rather than vendoring it and cleans up thePiHarnessoptions.Only
harnessis required:defaultssets the model, thinking level and retry policy for new sessions. If no model is set, a session's prompts end unanswered with reasonno_modeluntil you callsetModel.storechanges the table prefix, which defaults topi_.timingchanges how long the wake job waits.