You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constresourceLoader=newDefaultResourceLoader({cwd: sessionWorkDir,agentDir: hostAgentDir,// per-session tmp dir, not `input.agentDir`
...
// Pi runs in the host process, so its default resource discovery reaches// the host developer's personal config ...noExtensions: true,
The reasoning is right for the default case: pi runs in the host process, so loading a developer's ~/.pi/agent/extensions or a checked-out repo's .pi/extensions would execute untrusted code in the server. But it leaves no opt-in for deployments where the harness process is the sandbox.
Use case
We run harness-pi inside a Firecracker microVM (one VM per session, disposable HOME, the VM is the trust boundary). We want the guest image to ship pi extensions as files, the way pi itself is configured:
/opt/pi/agent/extensions/rtk.ts # from `rtk init --agent pi`
/opt/pi/agent/extensions/context-mode -> node_modules/context-mode # pi manifest package
Today the only route is extensionFactories, which means hand-porting every extension into TypeScript inside our package: an inline copy of rtk's rtk.ts, a loader that resolves context-mode's adapter path and imports it, plus tests for both. Each new extension is another port. Tools that already publish a pi extension (rtk, context-mode, anything with a pi manifest in package.json) cannot be used as published.
Also, agentDir: hostAgentDir means that even if noExtensions were lifted, <agentDir>/extensions would resolve to an empty tmp dir; the caller's agentDir setting is only used for auth.json/models.json/settings, not discovery.
Proposal
A PiHarnessSettings.extensions?: boolean, default false, that:
sets noExtensions: !extensions on the DefaultResourceLoader;
when enabled, passes the caller's agentDir (falling back to hostAgentDir) to the loader so <agentDir>/extensions is discovered;
Default behavior is unchanged. The docstring should state the trust implication plainly: enabling this runs whatever is under <agentDir>/extensions and the working directory's .pi/extensions, so only enable it where the harness process is already isolated.
Verified: with extensions: true and agentDir set, a plain .ts under <agentDir>/extensions and a symlinked package directory with a pi manifest both load at session start, and their registered tools are listed by the model. With the setting unset nothing changes.
Happy to open a PR against packages/harness-pi if the shape is acceptable.
Description
@ai-sdk/harness-pi1.0.101.createPiSessionhardcodes filesystem extension discovery off:The reasoning is right for the default case: pi runs in the host process, so loading a developer's
~/.pi/agent/extensionsor a checked-out repo's.pi/extensionswould execute untrusted code in the server. But it leaves no opt-in for deployments where the harness process is the sandbox.Use case
We run harness-pi inside a Firecracker microVM (one VM per session, disposable HOME, the VM is the trust boundary). We want the guest image to ship pi extensions as files, the way pi itself is configured:
Today the only route is
extensionFactories, which means hand-porting every extension into TypeScript inside our package: an inline copy of rtk'srtk.ts, a loader that resolves context-mode's adapter path and imports it, plus tests for both. Each new extension is another port. Tools that already publish a pi extension (rtk, context-mode, anything with apimanifest in package.json) cannot be used as published.Also,
agentDir: hostAgentDirmeans that even ifnoExtensionswere lifted,<agentDir>/extensionswould resolve to an empty tmp dir; the caller'sagentDirsetting is only used forauth.json/models.json/settings, not discovery.Proposal
A
PiHarnessSettings.extensions?: boolean, defaultfalse, that:noExtensions: !extensionson theDefaultResourceLoader;agentDir(falling back tohostAgentDir) to the loader so<agentDir>/extensionsis discovered;noTools: "builtin"path so extension-registered tools reach the model (same gap as harness-pi: tools registered by extensionFactories extensions never reach the model (dropped bytoolsallowlist) #20402).Default behavior is unchanged. The docstring should state the trust implication plainly: enabling this runs whatever is under
<agentDir>/extensionsand the working directory's.pi/extensions, so only enable it where the harness process is already isolated.Patch we run
Verified: with
extensions: trueandagentDirset, a plain.tsunder<agentDir>/extensionsand a symlinked package directory with apimanifest both load at session start, and their registered tools are listed by the model. With the setting unset nothing changes.Happy to open a PR against
packages/harness-piif the shape is acceptable.