Commit Graph

75 Commits

Author SHA1 Message Date
can1357 e9888367d1 refactor: migrated packages to internal utility modules and removed external dependencies
- Implemented in-house, zero-dependency utility modules in `pi-utils` covering DOM manipulation, markdown parsing, templating, browser automation helpers, and terminal buffers.
- Migrated packages across the repository to consume the new internal utilities and `omptype` schema validators instead of external dependencies.
- Removed multiple external runtime and development dependencies including Zod, Marked, LRU cache, Turndown, and Puppeteer browser packages.
2026-08-05 13:39:09 +02:00
roboomp 8f6ffb3a10 fix(providers): add China (Beijing) region for alibaba-token-plan
The alibaba-token-plan provider hardcoded the international Singapore
endpoint (token-plan.ap-southeast-1.maas.aliyuncs.com) in the login flow,
wire credential, openai-shared resolver, and catalog, so region-locked
China (Beijing) Token Plan sk-sp- keys were rejected with 401
invalid_api_key with no way to reach token-plan.cn-beijing.maas.aliyuncs.com.

Mirror the alibaba-coding-plan pattern: login selects a region
(International / China (Beijing) / Custom), validates against that region's
/models endpoint, and stores the chosen base URL in the credential. The
openai-shared resolver and model discovery both honor the credential's
region, while International logins keep their existing bare-token form.

Fixes #6682
2026-07-26 07:08:27 +00:00
Brent e184fe8f8d feat: add native Alibaba Token Plan provider 2026-07-23 23:04:00 +00:00
can1357 68c3c7ea9d docs(providers): documented novita support 2026-07-10 12:08:44 +02:00
roboomp 41e9bc861b fix(ai): honored NODE_EXTRA_CA_CERTS on every provider fetch
Bun's fetch ignores NODE_EXTRA_CA_CERTS, so private-CA gateways failed
with `unknown certificate verification error` on every OpenAI-compatible,
Codex, Ollama, Azure Responses, and Google call. The env var was only
plumbed through resolveFoundryTlsOptions() on the Anthropic Foundry path.

Added a shared wrapper (wrapFetchForExtraCa / withExtraCaFetch) that
merges the resolved CA bundle into Bun's RequestInit.tls.ca and seeds
the system root store alongside it (Bun's tls.ca replaces the default
trust store when set). The wrapper composes with the existing proxy /
request-debug stack in streamDispatch and streamSimple, so every
provider call now picks up the env var. Path-mtime cache invalidation
mirrors the Foundry helper so rotating bundles are picked up live.

Fixes #3731
2026-06-28 15:57:44 +00:00
oldschoola 13bfc7b9c0 Remove Wafer Pass provider 2026-06-21 02:45:48 +02:00
oldschoola 7d721dc420 Add Umans AI Coding Plan provider 2026-06-15 03:58:20 -07:00
can1357 3a4947ca50 fix(ai): point Token Plan usage doc at dashboard URL, finish rename
Use the usage dashboard URL (user-center/payment/token-plan) instead of
the subscription signup page in the usage provider docstring, rename the
README provider entry to Token Plan, and move the changelog entry back
under [Unreleased] (rebase auto-merge had landed it inside the released
15.10.11 section).

Addresses review feedback on #2203.
2026-06-10 08:31:30 +02:00
bench-local f6ca76728b feat(ai): add Wafer Pass and Wafer Serverless providers
Wafer (https://wafer.ai) exposes a single OpenAI-compatible endpoint
(`https://pass.wafer.ai/v1`) for two SKUs whose entitlement differs
server-side, so we model them as two parallel providers — mirroring the
firepass/fireworks split so a user with both subscriptions can switch
without re-pasting:

- `wafer-pass` — flat-rate. `/v1/models` is filtered to entries whose
  `wafer.tier === "pass_included"`.
- `wafer-serverless` — pay-as-you-go superset of Pass.

Both issue `wfr_…` keys. `/login wafer-pass` and `/login wafer-serverless`
paste-and-validate via `/v1/models`. `WAFER_PASS_API_KEY` and
`WAFER_SERVERLESS_API_KEY` are wired through `getEnvApiKey`.

Bundled catalog:
- `wafer-pass`: GLM-5.1, Qwen3.5-397B-A17B.
- `wafer-serverless`: GLM-5.1, Qwen3.5-397B-A17B, Kimi-K2.6, Qwen3.6-35B-A3B.

Dynamic discovery via `/v1/models` overlays additional models at runtime
and folds the `wafer` envelope (tier, capabilities, cents/M pricing) into
the canonical `Model<"openai-completions">` shape. GLM-family entries
carry the zai-style thinking compat (`thinkingFormat: "zai"`,
`reasoningContentField: "reasoning_content"`) so reasoning tokens land in
the right field. Cents-per-million → dollars-per-million via /100.

Tests (`packages/ai/test/wafer.test.ts`, 5 cases): bundled catalog
contract for both providers and wire-id pass-through (case-sensitive,
no rewrite — `GLM-5.1` must round-trip verbatim or upstream 404s).
Optional `packages/ai/test/wafer.live.ts` exercises a real round-trip
against `pass.wafer.ai` when `WAFER_PASS_API_KEY` is set.
2026-05-27 20:45:33 -07:00
can1357 07d13ba15e refactor(auth-broker): migrated OAuth flow from pi-ai CLI to AuthStorage
- Migrated OAuth provider authentication from standalone `pi-ai` CLI to in-process `AuthStorage.login()` flow in coding-agent.
- Made provider argument optional for `login` and `logout` commands with interactive provider picker when omitted.
- Added `list` command to enumerate registered OAuth providers with optional `--json` output format.
- Removed `pi-ai` CLI binary and `bin` entry from @oh-my-pi/ai package; library API remains unchanged.
- Updated documentation and examples to reflect new `omp auth-broker` command interface and in-process OAuth flow.
2026-05-26 19:56:43 +02:00
can1357 64fcdc308f refactor(coding-agent)!: removed StringEnum helper and shortened tool schema descriptions
- Replaced all StringEnum(...) usages with z.enum([...]) across tools, examples, and tests.
- Removed StringEnum re-export from @oh-my-pi/pi-coding-agent public API.
- Condensed verbose tool parameter descriptions to minimal lowercase phrases.
- Renamed AuthCredentialStore to SqliteAuthCredentialStore at usage sites.
2026-05-16 19:26:32 +02:00
can1357 2867e1f4e3 feat(deps): added pi.zod exports and removed TypeBox package exports
- Added canonical `pi.zod` schema API exports and removed TypeBox package exports/imports.
- Migrated Tool schema typing from TypeBox to shared `TSchema`/Zod flow with legacy TypeBox compatibility.
- Updated AI provider adapters and MCP/agent builders to convert tool params through `toolWireSchema()`.
- Reworked schema validation from AJV to Zod-safe parsing with `fromTypeBox`, `toolWireSchema`, and meta schema checks.
2026-05-15 14:46:54 +02:00
can1357 8c323666be feat: added ordered systemPrompt arrays and normalized context prompts
- Converted systemPrompt APIs and state types to ordered `string[]` across agent, AI, and coding-agent surfaces.
- Added `normalizeSystemPrompts` and applied it to context normalization before building provider request payloads.
- Updated AI providers to emit separate normalized prompt blocks/messages instead of a single merged system prompt.
- Removed dedicated `projectPrompt` state and remapped that context into system-context buckets in session, dump, and token accounting.
- Aligned tests and changelogs to pass and assert `systemPrompt` as arrays with ordered prompt semantics.
2026-05-04 15:20:26 +02:00
Ronny Unger 03aad88db7 feat(ai): add Ollama Cloud provider with streaming, thinking, and tool support
Add ollama-chat API provider supporting:
- Streaming chat completions via Ollama Cloud (ollama.com) API
- API key authentication via OLLAMA_API_KEY env var
- Thinking/reasoning model support with configurable effort levels
- Tool calling with streaming JSON argument assembly
- Dynamic model discovery via /api/tags and /api/show metadata
- Context window detection from model info
- Login flow via pi login ollama-cloud
2026-04-15 07:43:14 +02:00
can1357 2a20bd302e feat(ai): support extra body fields in openai-completions requests
Fixes #363
2026-03-14 13:52:12 +01:00
Gregor 15c7429ad0 add llama.cpp as local provider (#370)
* add llama.cpp as local provider

* use responses api instead of messages

* use api-keys correctly for llama.cpp provider

---------

Co-authored-by: Can Bölük <can1357@users.noreply.github.com>
2026-03-13 15:16:53 +01:00
D.Yang c1b39ea6c6 feat(ai): add ZenMux provider and /login flow
- add built-in zenmux provider discovery with Anthropic/OpenAI route split

- add interactive loginZenMux API-key flow and wire AuthStorage/CLI

- document ZENMUX_API_KEY usage and add provider/login tests
2026-03-05 00:24:26 +08:00
AK 4b651a95e9 add azure foundry support for claude code (#257) 2026-03-03 03:25:07 +01:00
can1357 9b22401bdd feat(ai): add Kilo Gateway provider and OAuth device login
Fixes #193
2026-02-27 12:43:46 +01:00
can1357 8c73c45ccc docs: document NanoGPT env var and login flow 2026-02-19 13:55:26 +01:00
can1357 e6f8001d9e feat: added 11 AI providers with OAuth and $pickenv() fallback support
- Added support for 11 new AI providers (Hugging Face, NVIDIA, Together, Ollama, LiteLLM, Xiaomi, Moonshot, Venice, Qwen Portal, vLLM, Cloudflare AI Gateway) with API key authentication and login flows.
- Implemented $pickenv() utility for environment variable fallback chains, enabling multi-key resolution for providers with alternative credential names.
- Extended KnownProvider and OAuthProvider types to include all 11 new providers with corresponding model manager functions and OAuth handlers.
- Expanded models.json with thousands of new model entries across all new providers and replaced deprecated opencode provider with cloudflare-ai-gateway.
- Refactored model generation script to use unified fetchProviderModelsFromCatalog() and centralized API key resolution for all providers.
2026-02-18 17:47:59 +01:00
can1357 bad4db1365 fix(models): aligned synthetic/cerebras auth and discovery 2026-02-18 15:43:46 +01:00
can1357 412ab9ea00 fix(coding-agent,ai): resolve issues #33, #34, #35, #37
- show help instead of crashing on `omp setup` with no args
- show runtime-discovered MCP servers in `/mcp list`
- remove deprecated Anthropic model entries from models.json
- sort models by recency in model selector
2026-02-12 20:29:06 +01:00
Chris Watson cf97ef0650 feat(ai): add MiniMax Coding Plan provider
Add support for MiniMax Coding Plan with OpenAI-compatible API:
- New providers: minimax-code (international) and minimax-code-cn (China)
- Environment variables: MINIMAX_CODE_API_KEY and MINIMAX_CODE_CN_API_KEY
- Uses thinkingFormat: 'zai' for reasoning compatibility
- Models: MiniMax-M2, MiniMax-M2.1, MiniMax-M2.1-lightning
- Base URLs: https://api.minimax.io/v1 (intl), https://api.minimaxi.com/v1 (CN)

The Coding Plan is a subscription-based service separate from regular MiniMax API.
2026-02-12 00:19:33 +01:00
Chris Watson 1793b155cd docs(ai): add Z-AI to supported providers list in README 2026-02-12 00:19:00 +01:00
can1357 f8950c22b4 refactor(auth-storage): cleanup auth.json mentions
- Migrated authentication storage from JSON-based (auth.json) to database-based (agent.db) format across test files and configuration.
- Simplified auth storage discovery in sdk.ts by removing manual path construction and fallback logic in favor of centralized getAgentDbPath() function.
- Removed dbPath instance property from AuthStorage class as database path is now managed centrally.
- Updated environment variable precedence documentation to reflect agent.db instead of auth.json as the lowest priority source.
- Removed OAuth provider section header comments from multiple test files for cleaner test organization.
- Added support for JSON and JSONC configuration file formats without requiring migration to YAML.
2026-02-05 14:30:22 +01:00
can1357 1f7c4f6f90 refactor(stream-parsing): restructured stream utilities to use Web standard APIs and generic SSE parsing
- Refactored SSE stream parsing to use generic `readSseJson` utility instead of domain-specific handlers across multiple packages.
- Migrated from Node.js Buffer API to Web standard APIs (Uint8Array, TextDecoder, DataView) for cross-platform compatibility.
- Simplified stream transformation pipeline by consolidating multiple stream operations into unified `createTextLineSplitter` utility.
- Refactored `ptree.ts` to remove complex stream pumping infrastructure and simplify stderr handling with direct async iteration.
- Rewrote stream utilities to operate at binary level with byte-level parsing for improved efficiency and reduced string allocations.
- Updated TypeScript configuration to include DOM.AsyncIterable type definitions for async iterable DOM API support.
2026-02-05 10:59:47 +01:00
can1357 51d39e7eea refactor(imports): migrated node module imports to namespace imports
- Converted named imports from node modules (fs, path, os) to namespace imports across all packages.
- Extended extension loader error handling with isEacces and hasFsCode type guards.
2026-01-24 03:37:59 +01:00
can1357 e22d123009 refactor(fs): migrated remaining sync file operations to async
- Converted readdirSync, readFileSync, and statSync to async readdir, readFile, stat across skills and agent discovery.
- Made scanDirectoryForSkills async and refactored custom directory scanning to use Promise.all for concurrent processing.
- Updated agent discovery to use fs/promises for async file reading and refactored helper patterns.
- Added AgentParsingError exception class for better error handling during agent parsing.
- Added filesystem error type guards (isEnoent, isEacces, isPerm, etc.) to pi-utils for safe error checking.
- Added color manipulation utilities to pi-utils for accessibility features.
- Added color-blind mode setting to settings manager.
- Migrated plugins, settings, and config modules from sync to async file operations.
- Updated error handling to use new pi-utils type guards for type-safe checking.
2026-01-24 03:18:03 +01:00
can1357 1e79ba6cdc feat(ai): added custom headers and payload hooks to AI providers
- Added headers option to all providers for custom request headers.
- Added onPayload hook to observe provider request payloads before sending.
- Added strictResponsesPairing option for Azure OpenAI Responses API compatibility.
- Added originator option to loginOpenAICodex for custom OAuth flow identification.
- Enhanced AWS credential detection to support ECS task roles and IRSA web identity tokens.
2026-01-21 04:44:24 +01:00
can1357 030b812624 feat(ai): implemented OAuth authentication with SQLite storage and callback server
- Added OAuth callback server with automatic port fallback and CSRF protection.
- Added persistent SQLite-based credential storage replacing auth.json file system.
- Added logout and status CLI commands for OAuth provider management.
- Refactored all OAuth flows to use common OAuthCallbackFlow base class.
- Added automatic regex pattern validation with fallback to literal mode in grep tool.
2026-01-19 20:25:43 +01:00
can1357 100061accb chore: merged in upstream changes
- Added ExtensionRuntime shared state with async extension factory support
- Introduced pluggable tool operations (BashOperations, FileOperations, etc.) for remote execution
- Added new CLI flags: --no-tools, --no-extensions, --no-skills
- Added login dialog, countdown timer, and component barrel export
- Added blockImages and thinkingBudgets settings
- Refactored stdin handling with StdinBuffer for improved key parsing
- Updated DEVELOPMENT.md with new architecture documentation
2026-01-10 06:32:51 +01:00
can1357 5a63120dd3 feat(ai): add @oh-my-pi/pi-ai package with tool name prefixing
- Port pi-ai from upstream with Bun-first approach (source files, no dist)
- Add cli_ prefix to tool names in OAuth mode to avoid collisions
- Improve beta header handling with proper deduplication
- Convert codex-instructions.md to Bun text embed
- Strip .js extensions from all imports
2026-01-09 12:10:03 +01:00
can1357 5919b0df94 refactor: switched to upstream @mariozechner/pi-ai and removed unused packages
- Replaced local @oh-my-pi/pi-ai with upstream @mariozechner/pi-ai@0.37.4
- Added sessionId support to agent for provider caching (OpenAI Codex)
- Deleted packages/ai (now using upstream)
- Deleted packages/mom (unused)
- Deleted packages/web-ui (unused)
2026-01-06 22:25:24 +00:00
can1357 21192e2056 refactor: consolidated tool execution params into details object
- Changed isError property from required to optional across ToolResultMessage and tool event interfaces.
- Added SpinnerType variants with distinct animation frames per symbol preset.
- Fixed spinner animation crash when frames array is empty by adding guard clause.
- Refactored agent-loop tool execution to consolidate toolCallId, toolName, and isError into details object.
2026-01-05 04:44:43 +01:00
can1357 2be354322d chore: renamed package scope to @oh-my-pi for consistent branding
- Renamed npm package scope from @mariozechner to @oh-my-pi across all packages for consistent branding.
- Removed packages/pods directory and all related pod management functionality.
- Updated import paths and module declarations throughout codebase to reflect new package names.
- Reformatted code with consistent trailing comma removal and ternary operator alignment.
2026-01-02 18:08:23 +01:00
Mario Zechner 0ac8e459fe Update READMEs: remove agent section from pi-ai, rewrite pi-agent-core
- Removed Agent API section from pi-ai README (moved to agent package)
- Rewrote agent package README for new architecture:
  - No more transports (ProviderTransport, AppTransport removed)
  - Uses streamFn directly with streamProxy for proxy usage
  - Documents convertToLlm and transformContext
  - Documents low-level agentLoop/agentLoopContinue API
  - Updated custom message types documentation
2025-12-30 22:42:20 +01:00
Mario Zechner 1d089cd803 getApiKeyFromEnv -> getEnvApiKey 2025-12-25 02:38:10 +01:00
Mario Zechner 37d302cc6d WIP: Add CLI for OAuth login, update README
- Add src/cli.ts with login command for OAuth providers
- Add bin entry to package.json for 'npx @mariozechner/pi-ai'
- Update README: remove setApiKey docs, rewrite OAuth section
- OAuth storage is caller's responsibility, not library's
- Use getOAuthProviders() instead of duplicating provider list
2025-12-25 01:09:27 +01:00
Mario Zechner 0384923bea Add configurable OAuth storage backend and respect --models in model selector
- Add setOAuthStorage() and resetOAuthStorage() to pi-ai for custom storage backends
- Configure coding-agent to use its own configurable OAuth path via getOAuthPath()
- Model selector (/model command) now only shows models from --models scope when set
- Rewrite OAuth documentation in pi-ai README with examples

Fixes #255
2025-12-20 22:00:53 +01:00
Peter Steinberger 362b50a151 feat(ai): interrupt tool batch on queued messages 2025-12-20 21:34:53 +01:00
Mario Zechner 75aaa9b4fa Add tool result streaming
- Add AgentToolUpdateCallback type and optional onUpdate callback to AgentTool.execute()
- Add tool_execution_update event with toolCallId, toolName, args, partialResult
- Normalize tool_execution_end to always use AgentToolResult (no more string fallback)
- Bash tool streams truncated rolling buffer output during execution
- ToolExecutionComponent shows last N lines when collapsed (not first N)
- Interactive mode handles tool_execution_update events
- Update RPC docs and ai/agent READMEs

fixes #44
2025-12-16 14:53:17 +01:00
Mario Zechner 540b831716 Update docs and changelogs for GitHub Copilot changes 2025-12-15 20:08:06 +01:00
Mario Zechner 6a2e3b1d88 Fix GitHub Copilot model enablement instructions (VS Code, not web) 2025-12-15 19:18:07 +01:00
Mario Zechner fb8938972d Add GitHub Copilot documentation to packages/ai README 2025-12-15 19:16:56 +01:00
Mario Zechner 56ced9ae83 Add Mistral as AI provider
- Add Mistral to KnownProvider type and model generation
- Implement Mistral-specific compat handling in openai-completions:
  - requiresToolResultName: tool results need name field
  - requiresAssistantAfterToolResult: synthetic assistant message between tool/user
  - requiresThinkingAsText: thinking blocks as <thinking> text
  - requiresMistralToolIds: tool IDs must be exactly 9 alphanumeric chars
- Add MISTRAL_API_KEY environment variable support
- Add Mistral tests across all test files
- Update documentation (README, CHANGELOG) for both ai and coding-agent packages
- Remove client IDs from gemini.md, reference upstream source instead

Closes #165
2025-12-10 20:36:19 +01:00
Mario Zechner 62a606744c Simplify compaction: remove proactive abort, use Agent.continue() for retry
- Add agentLoopContinue() to pi-ai for resuming from existing context
- Add Agent.continue() method and transport.continue() interface
- Simplify AgentSession compaction to two cases: overflow (auto-retry) and threshold (no retry)
- Remove proactive mid-turn compaction abort
- Merge turn prefix summary into main summary
- Add isCompacting property to AgentSession and RPC state
- Block input during compaction in interactive mode
- Show compaction count on session resume
- Rename RPC.md to rpc.md for consistency

Related to #128
2025-12-09 21:43:49 +01:00
Mario Zechner 18df11d10e Add xhigh thinking level for OpenAI codex-max models
- Add 'xhigh' to ThinkingLevel type in ai and agent packages
- Map xhigh to reasoning_effort: 'max' for OpenAI providers
- Add thinkingXhigh color token to theme schema and built-in themes
- Show xhigh option only when using codex-max models
- Update CHANGELOG for both ai and coding-agent packages

closes #143
2025-12-08 21:12:54 +01:00
Mario Zechner ed22731d93 Add OpenAICompat for openai-completions provider quirks
Fixes #133
2025-12-08 19:02:03 +01:00
Mario Zechner 83f099f282 Remove provider-level tool validation, add validateToolCall helper 2025-12-08 18:04:33 +01:00