#18998: fix(llm-task): fall back to dist/ path for runEmbeddedPiAgent import
extensions: llm-task
size: XS
Cluster:
Plugin Fixes and Enhancements
## Summary
Based on #18946 by @arosstale, with fixes for CI failure and review feedback:
- Fixes copy-paste bug where the bundled-install fallback imported from `src/` (same as the dev path) instead of `dist/`, causing `runEmbeddedPiAgent` to fail in packaged installs where `src/` doesn't exist
- **Adds `@ts-expect-error`** to suppress TS2307 for the `dist/` import path that only exists at runtime in packaged installs (this was causing the CI type-check failure)
- **Adds `oxlint-disable` comments** for `as any` casts in the `dist/` block, matching the existing `src/` block style
- **Captures the underlying import error** and attaches it via `Error({ cause })` so callers can see why each import attempt failed, rather than getting a generic "not available" message
## Test plan
- [x] `tsgo --noEmit` passes (no TS2307 error)
- [x] `oxfmt --check` passes
- [x] `oxlint` passes (no `no-explicit-any` errors)
Fixes #18846
Supersedes #18946
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Fixes a copy-paste bug in `loadRunEmbeddedPiAgent()` where the bundled-install fallback path was importing from `src/` (identical to the dev path) instead of `dist/`, causing `runEmbeddedPiAgent` to fail in packaged installs where `src/` doesn't exist.
- Corrects the fallback import path from `../../../src/` to `../../../dist/` for packaged installs
- Wraps the `dist/` import in a `try/catch` block (matching the `src/` block pattern) with `@ts-expect-error` to suppress TS2307 since the path only exists at runtime
- Captures and attaches the underlying import error via `Error({ cause })` for better debugging
- Import reorder is oxfmt auto-sorting (no logic change)
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge — it fixes a clear copy-paste bug with a minimal, well-structured change.
- The change is small and targeted: it fixes an obvious copy-paste bug (both paths importing from src/ instead of src/ then dist/), follows the existing code patterns, and adds proper error handling. The import reorder is purely formatter-driven. No new logic complexity or risk introduced.
- No files require special attention.
<sub>Last reviewed commit: 55437c8</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#19061: fix(llm-task): correct fallback import path from src/ to dist/
by Operative-001 · 2026-02-17
86.9%
#12844: fix(llm-task): use correct import path for built/npm installs
by scout-wolfe · 2026-02-09
83.2%
#13176: fix: resolve llm-task module import for global installs
by striking · 2026-02-10
82.1%
#2541: fix(agents): add error handling to orphaned message cleanup
by Episkey-G · 2026-01-27
76.1%
#6577: fix: add null checks for stdout/stderr when using inherit-stdio fal...
by ncmalan · 2026-02-01
73.9%
#7085: test: skip flaky workspace-paths & safe-bins tests on non-Linux/CI ...
by ThinkIbrokeIt · 2026-02-02
73.8%
#16019: fix(plugins): add postinstall patch for ESM-only package exports
by dashed · 2026-02-14
73.7%
#20851: fix: harden resolveUserPath and compact against undefined workspaceDir
by davidrudduck · 2026-02-19
73.6%
#17237: fix(update): guard post-install imports after npm global update
by tdjackey · 2026-02-15
73.5%
#17393: fix(ci): resolve TS2742 type error blocking all PRs
by miloudbelarebia · 2026-02-15
73.4%