| 41 | let sdkPromise: Promise<PiSdk> | undefined |
| 42 | |
| 43 | function loadPiSdk(): Promise<PiSdk> { |
| 44 | if (!sdkPromise) { |
| 45 | // A static specifier (not a variable) is required so Next's dependency tracer |
| 46 | // copies the package + its transitive deps into the standalone Docker output, |
| 47 | // the same way `@e2b/code-interpreter` is handled. Clear the cache on failure |
| 48 | // so a transient import error doesn't permanently break later local runs. |
| 49 | sdkPromise = import('@earendil-works/pi-coding-agent').catch((error) => { |
| 50 | sdkPromise = undefined |
| 51 | throw error |
| 52 | }) |
| 53 | } |
| 54 | return sdkPromise |
| 55 | } |
| 56 | |
| 57 | function toPiTool(sdk: PiSdk, spec: PiToolSpec): ToolDefinition { |
| 58 | return sdk.defineTool({ |