#11446

A lightweight entry point for defining extensions for pi-durable

Openchrisgoddardopened 13d ago

What do you want to change?

Add a subpath export, such as @earendil-works/pi-durable/extension, that exports the extension-authoring helpers (defineDoc, defineExtension, hook, ToolTask) and their types. It should not load the session runtime, storage or model code.

Why?

These helpers are only on the root export, and importing the root loads the whole runtime. In 1.4.0, a module that only defines an extension pays about 180 ms and 742 modules for that one import. On Cloudflare Workers this cost hits every cold start. The package already has narrow subpaths (./codemode, ./env, ./tools, ./storage/*, ...), so this fits the existing pattern.

Repro (Node 24, pi-durable 1.4.0):

npm i @earendil-works/pi-durable@1.4.0
node --input-type=module -e "const t=performance.now(); await import('@earendil-works/pi-durable'); console.log(performance.now()-t)"

# 513.1185280000001 (no disk cache)
# 165.471654
# 214.493499
# 185.04169

How? (optional)

A new entry module that re-exports only the authoring helpers, plus an exports entry for it. Type-only imports stay as they are.

I’d be happy to implement this myself and open a PR if the subpath name and export set work for you.

Activity

0

No activity yet.