Commit Graph
43 Commits
Author SHA1 Message Date
Patrick Wozniak 0700d9b61d fix(core): register the custom api in the pi-ai compat registry
pi routes the main chat through the registered provider, but sibling
extensions that call streamSimple from @earendil-works/pi-ai/compat with
the active Command Code model resolve model.api through the compat
api-registry, which only knows built-in APIs. On plain pi that failed
with "No API provider registered for api: commandcode-custom".

Register commandcode-custom there and delegate to the transport router.
The registry resolves no credentials for extension providers, so fall
back to the configured Command Code key when the caller passes none.

Closes #68

(cherry picked from commit 7e9659e672771c6a9223b95938e50fb2a051a0a7)
2026-09-01 23:29:30 +02:00
Patrick Wozniak c51a790530 fix(stream): match Command Code CLI transport behavior 2026-08-25 15:54:18 +02:00
Patrick Wozniak 96356698fa fix(quota): harden dashboard integration 2026-08-25 13:34:54 +02:00
Patrick Wozniak 63dd92da09 Merge remote-tracking branch 'origin/main' into review/pr-52
# Conflicts:
#	CHANGELOG.md
2026-08-25 13:33:55 +02:00
José Galliano 307714b051 feat(quota): add live commandcode-quota dashboard and OMP auth fix
Fetches live account quota from Command Code alpha usage endpoints
(whoami, billing/credits, billing/subscriptions, usage/summary) and
renders a plain-text dashboard via ui.notify.

- Graceful degradation: optional endpoint transport/timeout/parse
  failures degrade to null sections instead of aborting; only 401/403
  are hard failures. 429 is transient, not fatal.
- Overall deadline bounds the whole command to QUOTA_TIMEOUT_MS
  (per-request controllers are chained; post-deadline phases fail fast).
- OMP auth: filter unresolved $COMMANDCODE_API_KEY placeholder and fall
  back to the host resolver via pickCommandCodeApiKey.
- ZDR privacy header respected on quota requests.
- Redaction reuses redactCommandCodeErrorText plus JSON-quoted
  credential fields; outer-catch errors are redacted too.
- resetAt parsed from seconds, ms, numeric string, or ISO string.
- 21 hermetic unit tests wired into npm test (test:quota).
2026-08-21 11:21:25 -06:00
Omar Iqbal Naru 1e0dd1189c fix(core): register custom api under non-reserved name for omp 17.4.0
omp 17.4.0's host registry rejects registerCustomApi calls under
built-in api names ("Cannot register custom API '<name>': built-in
API names are reserved"). The provider and its models registered
under "openai-completions", so the extension failed to load.

Register under "commandcode-custom" instead (matches the published
npm build) and restore the real wire api via apiForModelId before
dispatching to the native compat stream inside the transport router.

The host's model registry also stores provider-supplied compat under
model.compatConfig internally, only copying it back to model.compat
inside its own dispatch-time patches. Since the transport router calls
the native compat stream directly, it must read compatConfig itself or
requests crash with 'baseCompat is undefined' before any network call.

Verified against a local mock Provider API server with the extension
linked into omp 17.4.0: model discovery lists all Command Code models,
and a streamed chat completion sends the resolved x-cmd-zdr header and
Authorization header end to end.
2026-08-21 19:41:54 +05:00
Patrick Wozniak ed29c59f31 fix(models): use adaptive thinking for Claude 2026-08-20 00:13:56 +02:00
Patrick Wozniak 75552ef4b9 test(e2e): add live account profiles 2026-08-18 17:20:44 +02:00
Patrick Wozniak 89dc21bed2 feat(api): fall back for go plan accounts 2026-08-18 12:11:47 +02:00
Patrick Wozniak 864538e146 fix(ci): satisfy provider audit checks 2026-08-18 11:01:12 +02:00
Patrick Wozniak 84a802d91d feat(api): use official provider endpoints 2026-08-18 10:56:06 +02:00
Patrick WozniakandGitHub a367aed63c feat(models): add vision input capabilities (#43) 2026-08-11 00:28:03 +02:00
Patrick Wozniak 7efca20d16 fix(core): preserve request fidelity and provider errors 2026-08-07 14:05:03 +02:00
Patrick Wozniak 7e9ecc563a feat(models): add model-aware runtime metadata 2026-08-07 14:03:24 +02:00
Patrick Wozniak 62e51ee9f5 Merge main into feat/isolated-pi-launcher 2026-08-07 10:02:22 +02:00
Patrick Wozniak b100d553c1 feat(tests): add isolated pi launchers 2026-08-07 09:55:02 +02:00
Patrick Wozniak 947915df55 fix(models): refresh model pricing 2026-08-04 13:46:26 +02:00
Patrick Wozniak b1a60da6b4 fix(models): store cache in agent directory
Resolve the Command Code model cache through the host's getAgentDir helper so pi, OMP, and PI_CODING_AGENT_DIR use their own agent state directory instead of the official Command Code client directory.
2026-08-02 01:37:34 +02:00
Patrick Wozniak 070ef3c07a fix(models): cache catalog for offline startup
Persist the last valid Command Code model catalog and use it when live model discovery fails. Keep first-time offline startup non-fatal, surface clear warnings, and cover cached model selection with unit and pi integration regression tests.
2026-08-02 01:16:39 +02:00
K2 811f908918 fix: allow extension to load when offline
The model fetch at startup throws and blocks pi from starting when
there's no network. Catch the error and register the provider with
an empty model list instead.
2026-07-23 11:19:04 +01:00
Patrick WozniakandGitHub e123e84116 fix(omp): avoid unsupported calculateCost import
Fix OMP installation by removing the unsupported calculateCost runtime import from pi-ai.
2026-07-05 03:10:02 +02:00
PlumJamandGitHub 88d8706234 fix: resolve deprecation warning for apiKey value
Use the explicit $COMMANDCODE_API_KEY environment variable reference expected by newer pi versions while keeping compatibility with the legacy placeholder handling.
2026-06-16 14:08:11 +02:00
Patrick Wozniak fe49146892 Merge remote-tracking branch 'origin/main' into fix/pr-7-review
# Conflicts:
#	index.ts
#	package.json
#	tests/test-pi-local.mjs
2026-05-28 22:07:51 +02:00
Patrick Wozniak 5a62f60049 fix(models): correct DeepSeek V4 Flash cache rate, add xiaomi models
DeepSeek V4 Flash cache-read rate was /bin/bash.01/1M but docs list ~/bin/bash.028.
Added xiaomi/mimo-v2.5-pro and xiaomi/mimo-v2.5 to MODEL_COSTS so they
don't display as zero-cost models (pricing TBD, currently set to 0).
2026-05-28 22:05:20 +02:00
Patrick Wozniak 3caa4111e1 fix(models): correct DeepSeek V4 Pro discount as permanent
The Command Code docs state the 4x usage deal for DeepSeek V4 Pro is
permanent with no expiry date, not time-limited through May 31, 2026.
2026-05-28 22:05:08 +02:00
wh.huajieyu e78875f532 refactor: clean up code formatting and update package dependencies
- Removed unnecessary blank lines and improved formatting for better readability in index.ts and converters.ts.
- Updated package-lock.json to downgrade several dependencies for compatibility, including @protobufjs/eventemitter, @protobufjs/fetch, and others.
- Enhanced error message in core.ts to clarify configuration options for the Command Code API key.
- Added a test to ensure the correct handling of environment variable values in test-stream.ts.
2026-05-28 06:23:28 -04:00
AlexVagrantandwh.huajieyu c2497ed098 feat: add OMP (Oh My Pi) provider compatibility
Support OMP as a host alongside pi:
- Convert OMP's array-format system prompts to string via systemPromptToText
- Guard against OMP passing the literal env-var name as the API key value
- Add ~/.omp/agent/auth.json to default auth path lookup
- Fix --list-models output to check both stdout and stderr
- Add OMP compatibility smoke test with isolated temp HOME and mock server
- Deduplicate usage section in README, add OMP install and usage docs
2026-05-28 04:12:35 -04:00
Fei Yan 96c452eefd chore: upgrade pi dependencies from @mariozechner 0.72.0 to @earendil-works 0.75.5
pi 0.75.5 renamed the npm namespace from @mariozechner/ to @earendil-works/.
Importing from the old namespace causes 'fetch failed' errors at startup.

Changes:
- index.ts: @mariozechner/pi-ai → @earendil-works/pi-ai
- index.ts: @mariozechner/pi-coding-agent → @earendil-works/pi-coding-agent
- package.json: bump deps from 0.72.0 to 0.75.5
- package-lock.json: regenerated with new packages (242 deps)
- tsc --noEmit: zero errors
2026-05-27 19:48:55 +08:00
Fei Yan 567e1e28a4 feat(models): add live display pricing for known Command Code models
The Provider API does not expose pricing yet. Overlay a static MODEL_COSTS
map on top of the dynamically fetched model list so pi can display per-model
costs. Models not in the table fall back to zero cost. When the Provider API
adds a cost field, the static table can be removed.
2026-05-27 07:32:50 +08:00
Patrick Wozniak cc05faa526 Release 0.1.1 2026-05-26 23:05:21 +02:00
Patrick Wozniak 418f4c925b Fetch Command Code models at startup 2026-05-26 21:51:41 +02:00
Tao Yang 960d0d1f23 feat: extract models from command-code dist, load via models.json
- Add scripts/extract-models.ts to parse command-code npm dist file
- Generate models.json (21 models, 15 pricing entries) with contextWindow
  and maxOutputTokens pre-filled; no nulls or hardcoded fallbacks in index.ts
- Rewrite index.ts to load model list and costs from models.json
- Cap gateway model maxOutputTokens at 65536 (API limit for Baseten/Vercel)
- Add 'Update models' section to README documenting the generation flow
- Add npm run extract-models script
2026-05-25 16:37:08 +08:00
Patrick Wozniak b8853ab0d6 Add Command Code browser login fallback 2026-05-05 14:48:06 +02:00
Patrick Wozniak af2b316d84 style: configure prettier (no semicolons, trailing commas) 2026-05-05 14:02:41 +02:00
Patrick Wozniak e9853eb4a4 chore: add CI workflow (typecheck + prettier format check), tsconfig, and prettier formatting 2026-05-05 13:56:41 +02:00
Patrick Wozniak ebf638e9fb Extract Command Code stream core 2026-05-05 13:22:00 +02:00
Patrick Wozniak 4407ab5b37 fix: add onResponse hook for response metadata inspection before streaming 2025-05-05 11:20:00 +02:00
Patrick Wozniak 29f4565a53 fix: flush remaining thinking blocks after stream ends 2025-05-05 10:45:00 +02:00
Patrick Wozniak 103b6e6fff feat: add abort handling with raceAbort helper 2025-05-04 18:40:00 +02:00
Patrick Wozniak 0cb34f54d7 feat: add API key resolution from env var + auth.json files 2025-05-04 18:15:00 +02:00
Patrick Wozniak 28ccca9a0c feat: implement streamCommandCode with SSE parsing 2025-05-04 17:50:00 +02:00
Patrick Wozniak ad3479f68c feat: add model definitions and helpers (toJsonSchema, toolsToJson, messagesToCC) 2025-05-04 17:22:00 +02:00
Patrick Wozniak d18dd3e77b feat: scaffold pi package with provider skeleton 2025-05-04 17:05:00 +02:00