Skip to content

fix(omp): avoid unsupported calculateCost import#25

Merged
patlux merged 2 commits into
mainfrom
fix/issue-24-omp-calculatecost
Jul 5, 2026
Merged

fix(omp): avoid unsupported calculateCost import#25
patlux merged 2 commits into
mainfrom
fix/issue-24-omp-calculatecost

Conversation

@patlux

@patlux patlux commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Why

Fixes #24. Oh My Pi validates extensions through its legacy pi-ai shim, which does not export calculateCost. Importing it at module load time makes installation fail before the provider can register.

What

  • Remove the calculateCost import from @earendil-works/pi-ai.
  • Add a local cost calculator with the same per-million-token arithmetic.
  • Keep the existing custom stream implementation unchanged.

Testing

  • npm run typecheck
  • npm run format:check
  • git diff --check
  • gitleaks dir . --no-banner --redact --verbose
  • node --input-type=module -e 'import("./index.ts").then(()=>console.log("index import ok"))'\n\nNote: full npm test currently fails locally in tests/test-pi-local.mjs due local pi model-list configuration not showing the mocked Command Code provider output; unrelated to this import-only OMP fix.

@patlux patlux self-assigned this Jul 5, 2026
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Move the local cost function into src/cost.ts so it is covered by
typecheck, add cost to ModelLike to match the runtime model shape, and
compare the implementation field-by-field against pi-ai's calculateCost
so the OMP compatibility copy cannot drift.

@piparo-agent piparo-agent left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved for hotfix release.

@patlux patlux merged commit e123e84 into main Jul 5, 2026
10 checks passed
@patlux patlux deleted the fix/issue-24-omp-calculatecost branch July 5, 2026 01:10
@patlux

patlux commented Jul 5, 2026

Copy link
Copy Markdown
Owner Author

Shipped in pi-commandcode-provider@0.4.2 / GitHub release v0.4.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fail to install on Oh-my-pi

2 participants