Commit Graph

15 Commits

Author SHA1 Message Date
can1357 eb1a46baf5 feat: added injectable fetch transport across AI and coding network flows
- Added optional FetchImpl fields to compaction, proxy, AI, coding-agent, and mnemopi options.
- Threaded injected fetch implementations through OAuth, discovery, and search/LLM request flows.
- Removed exported hookFetch utility and its package entrypoint from utils.
- Replaced global-fetch test monkeypatching with per-test FetchImpl mocks across test suites.
2026-06-09 04:51:17 +02:00
can1357 9d457f73d9 test: migrated test imports to package subpath exports
- Replaced relative `../src` imports with `@oh-my-pi/pi-ai` and `@oh-my-pi/pi-agent-core` subpaths.
2026-06-08 19:03:55 +02:00
can1357 ba6cc67f38 refactor(packages/ai): migrated effort types to dependency-free module
- Added dependency-free `@oh-my-pi/pi-ai/effort` module and re-exported `Effort`/`THINKING_EFFORTS`.
- Moved `Effort` and `THINKING_EFFORTS` from `model-thinking.ts` to `effort.ts`, then migrated runtime/tests imports.
2026-06-06 22:58:33 +02:00
roboomp 25b68332e6 fix(ai): used copilot context window limit
Mapped GitHub Copilot OAuth discovery context windows from max_context_window_tokens before prompt budgets.

Kept output token mapping on max_output_tokens and covered the fallback order in Copilot model limit tests.

Fixes #1539
2026-05-30 09:09:26 +00:00
can1357 c4ea6c920f fix: restore Copilot prompt budgets and align task/model-registry expectations with opus 4.7
Three fixes to make CI green after the opus 4.7 and auto-bump landed:

1. github-copilot model mapper: prefer capabilities.limits.max_prompt_tokens
   over the root-level context_length field (which mirrors max_context_window_tokens, i.e.
   total window). Copilot's real /models response returns both for the gpt-5.x family, and
   context_length inflates contextWindow with the output budget. Also restore the bundled
   Copilot limits (claude-opus-4.6, gpt-5.2, gpt-5.4, gpt-5.4-mini, grok-code-fast-1) to
   the values the fixed mapper produces so tests that depend on truthful offline fallbacks
   pass. Update the two Copilot discovery tests whose payloads conflated context_length
   with prompt capacity.

2. coding-agent task schema: make the per-task assignment description context-mode-aware.
   The previous description unconditionally told agents that 'shared background belongs
   in context', which is wrong for independent mode where shared context is disabled.

3. coding-agent model-registry test: update the anthropic-latest canonical collapse case
   to claude-opus-4-7 since opus 4.7 is now the newest official opus in models.json.
2026-04-17 19:24:03 +02:00
Adrian Glapiński 31c95c9ed2 fix(ai): refresh stale Copilot bundled limits 2026-04-11 22:44:12 +02:00
Adrian Glapiński 977059bb8e fix(ai): resolve Copilot context window from max_prompt_tokens, not max_context_window_tokens
Copilot's /models endpoint exposes token limits under capabilities.limits.
max_prompt_tokens is the actual prompt capacity (what OMP calls contextWindow),
while max_context_window_tokens is the total window (prompt + output budget).
Using the latter inflates contextWindow, which breaks compaction thresholds,
overflow detection, and context promotion.

Three changes:

1. mapModel reference selection: always prefer the Copilot-specific bundled
   reference over the global cross-provider reference. Copilot imposes its
   own limits that are strictly lower than native provider limits.

2. mapModel contextWindow chain: remove max_context_window_tokens from the
   fallback. New chain: context_length -> max_prompt_tokens -> reference.

3. generate-models: stop overwriting contextWindow/maxTokens in
   applyGlobalModelsDevFallback. These are provider-specific and should not
   be replaced with cross-provider models.dev global references.

Also fixes bundled values: github-copilot/gpt-5.4 (400k -> 272k) and
github-copilot/gpt-5.2 (264k -> 128k) to match live API max_prompt_tokens.

Refs: #225, #226
2026-04-11 22:44:12 +02:00
Abir Biswas a7423f2604 fix: unwrap structured Copilot OAuth key for model discovery 2026-04-09 18:47:09 +02:00
Abir Biswas 31e4b91019 feat(ai): replace GitHub Copilot auth with opencode OAuth flow
Replace VSCode extension impersonation (client ID Iv1.b507a08c87ecfe98,
User-Agent GitHubCopilotChat/0.35.0) with the opencode OAuth app
(Ov23li8tweQw6odWQebz, User-Agent opencode/1.3.15).

Key changes:
- OAuth device flow now uses JSON body encoding and opencode headers
- GitHub OAuth token is used directly for all API requests; no JWT
  exchange or refresh cycle needed
- Base URL changed from api.individual.githubcopilot.com to
  api.githubcopilot.com across models.json, openai-compat.ts, and
  the oauth module
- Removed proxy-ep JWT base URL extraction from github-copilot-headers.ts
  and openai-compat.ts (resolveGitHubCopilotBaseUrl now passes through
  the model baseUrl unchanged)
- refreshGitHubCopilotToken is now a synchronous identity return
- All 25 bundled Copilot model definitions updated to new headers/baseUrl
- Tests updated to reflect plain GitHub token format and new base URL

Existing users will need to re-authenticate once with /login github-copilot.
2026-04-09 18:47:08 +02:00
can1357 efbfa60517 fix(ci): restore Copilot 1M context and stabilize plan-role tests 2026-04-05 18:05:09 +02:00
can1357 3d29a48e7a fix(coding-agent): fixed memory leak by cancelling idle compaction
- Fixed memory leak by cancelling idle compaction timer on event controller disposal.
- Fixed session resumption to preserve last non-empty session when starting fresh.
- Fixed stash detection to use git ref resolution instead of output parsing for reliability.
- Fixed secret obfuscation to deobfuscate restored session messages locally while keeping LLM messages obfuscated.
- Fixed stash pop operation to preserve staged changes with --index flag after task branch merges.
- Changed idle compaction settings from enum to numeric type for flexible configuration.
2026-04-05 03:50:52 +02:00
can1357 61c4c1d0c5 feat(ai): added 40+ AI models and updated context windows across providers
- Added 40+ new AI model entries across multiple providers including Alibaba, Google, ByteDance, NVIDIA, OpenRouter, and others.
- Updated context window and token limits for existing models including GitHub Copilot Opus 4.6 (1M tokens) and Gemini 2.5 Pro (1M tokens).
- Fixed GitHub Copilot and Gemini 2.5 Pro model detection logic in context window calculation.
- Enhanced model configurations with reasoning capabilities, thinking modes, and updated pricing across providers.
2026-04-05 01:11:23 +02:00
maximhar ab37a18225 feat: add GPT-5.4 mini and nano models (#476)
* feat: add GPT-5.4 mini and nano models

* fix: address GPT-5.4 review feedback
2026-03-20 23:15:11 +01:00
can1357 0611e97dbc fix(ai,coding-agent): resolve copilot endpoint at provider layer
Fixes #260
2026-03-03 05:33:56 +01:00
maximhar 3e51168616 Use Copilot live limits for context/max token mapping (#226) 2026-03-01 03:48:17 +01:00