Commit graph

129 commits

Author SHA1 Message Date
Mario Zechner
b3a7b35ec5 Port PDF/Office support, message editor, overlays, key setter 2025-10-01 17:31:13 +02:00
Mario Zechner
b67c10dfb1 feat: add cross-browser extension with AI reading assistant
- Create Pi Reader browser extension for Chrome/Firefox
- Chrome uses Side Panel API, Firefox uses Sidebar Action API
- Supports both browsers with separate manifests and unified codebase
- Built with mini-lit components and Tailwind CSS v4
- Features model selection dialog with Ollama support
- Hot reload development server watches both browser builds
- Add useDefineForClassFields: false to fix LitElement reactivity
2025-10-01 04:33:56 +02:00
Mario Zechner
c1185c7b95 chore: bump version to 0.5.43 2025-09-19 01:49:46 +02:00
Mario Zechner
f55985f633 Fix GPT-5 no-reasoning mode. Somewhat. There's no real off-switch ... 2025-09-19 01:45:00 +02:00
Mario Zechner
0f7ed33ba5 chore: bump version to 0.5.42 2025-09-19 00:14:23 +02:00
Mario Zechner
9e86079386 Fix block indexing in Google provider impl 2025-09-19 00:10:43 +02:00
Mario Zechner
2296dc4052 refactor(ai): improve error handling and stop reason types
- Add 'aborted' as a distinct stop reason separate from 'error'
- Change AssistantMessage.error to errorMessage for clarity
- Update error event to include reason field ('error' | 'aborted')
- Map provider-specific safety/refusal reasons to 'error' stop reason
- Reorganize utility functions into utils/ directory
- Rename agent.ts to agent-loop.ts for better clarity
- Fix error handling in all providers to properly distinguish abort from error
2025-09-18 19:57:13 +02:00
Mario Zechner
293a6e878d chore: bump version to 0.5.41 2025-09-18 11:18:02 +02:00
Mario Zechner
b6af05bbf6 fix(ai): correct streaming event documentation and API methods 2025-09-18 11:17:33 +02:00
Mario Zechner
c9d735bbbd Clean-up 2025-09-16 12:27:30 +02:00
Mario Zechner
9c921049a6 chore: bump version to 0.5.40 2025-09-16 12:24:00 +02:00
Mario Zechner
39c626b6c9 feat(ai): add partial JSON parsing for streaming tool calls
- Added partial-json package for parsing incomplete JSON during streaming
- Tool call arguments now contain partially parsed JSON during toolcall_delta events
- Enables progressive UI updates (e.g., showing file paths before content is complete)
- Arguments are always valid objects (minimum empty {}), never undefined
- Full validation still occurs at toolcall_end when arguments are complete
- Updated all providers (Anthropic, OpenAI Completions/Responses) to use parseStreamingJson
- Added comprehensive documentation and examples in README
- Added test to verify arguments are always defined during streaming
2025-09-16 12:23:34 +02:00
Mario Zechner
197259c88a Fix NodeJS compat 2025-09-16 02:19:47 +02:00
Mario Zechner
e2d23a5abb Update AI models and index exports 2025-09-16 01:29:44 +02:00
Mario Zechner
365b9ec390 chore: bump version to 0.5.36 2025-09-16 01:11:28 +02:00
Mario Zechner
e8370436d7 Replace Zod with TypeBox for schema validation
- Switch from Zod to TypeBox for tool parameter schemas
- TypeBox schemas can be serialized/deserialized as JSON
- Use AJV for runtime validation instead of Zod's parse
- Add StringEnum helper for Google API compatibility (avoids anyOf/const patterns)
- Export Type and Static from main package for convenience
- Update all tests and documentation to reflect TypeBox usage
2025-09-16 01:10:40 +02:00
Mario Zechner
f5ac1ef521 chore: bump version to 0.5.35 2025-09-15 20:32:50 +02:00
Mario Zechner
5f7a50deef Make stream function configurable in agent 2025-09-15 20:31:53 +02:00
Mario Zechner
1c9ab1ca24 chore: bump version to 0.5.34 2025-09-15 00:35:10 +02:00
Mario Zechner
73d2119606 fix: Adjust max tokens for Anthropic and improve Google tools handling
- Reduce default max tokens for Anthropic to 1/3 of model max
- Fix Google provider to properly handle empty tools array
- Ensure toolConfig is undefined when no tools are present
2025-09-15 00:34:52 +02:00
Mario Zechner
433b42ac91 Fix Biome config, don't submit empty assistant messages to completions endpoint. 2025-09-09 21:47:40 +02:00
Mario Zechner
34a7344a7d chore: bump version to 0.5.32 2025-09-09 15:00:32 +02:00
Mario Zechner
35fe8f21e9 feat(ai): Implement Zod-based tool validation and improve Agent API
- Replace JSON Schema with Zod schemas for tool parameter definitions
- Add runtime validation for all tool calls at provider level
- Create shared validation module with detailed error formatting
- Update Agent API with comprehensive event system
- Add agent tests with calculator tool for multi-turn execution
- Add abort test to verify proper handling of aborted requests
- Update documentation with detailed event flow examples
- Rename generate.ts to stream.ts for clarity
2025-09-09 14:58:54 +02:00
Mario Zechner
594b0dac6c Stop GPT-OSS 20b from being dumb .. 2025-09-09 04:31:09 +02:00
Mario Zechner
98a876f3a0 Fix streaming for z-ai in anthropic provider, add preliminary support for tool call streaming. Only reporting argument string deltas, not partial JSON objects 2025-09-09 04:26:56 +02:00
Mario Zechner
2bdb87dfe7 chore: bump version to 0.5.31 2025-09-07 00:09:34 +02:00
Mario Zechner
d073953ef7 feat(ai): Add zAI provider support
- Add 'zai' as a KnownProvider type
- Add ZAI_API_KEY environment variable mapping
- Generate 4 zAI models (glm-4.5-air, glm-4.5v, etc.) using anthropic-messages API
- Add comprehensive test coverage for zAI provider in generate.test.ts and empty.test.ts
- Models support reasoning/thinking capabilities and tool calling
2025-09-07 00:09:15 +02:00
Mario Zechner
9230b83d94 chore: bump version to 0.5.30 2025-09-04 12:42:18 +02:00
Mario Zechner
6c3580828d fix(ai): Ensure unique tool call IDs in Google provider
- Google provider sometimes returns duplicate or missing tool call IDs
- Added counter to ensure unique IDs for each tool call
- Check for duplicates and generate new ID when needed
- Fixes issues with multiple tool calls having the same ID
2025-09-04 12:41:58 +02:00
Mario Zechner
7d1daac39e chore: bump version to 0.5.29 2025-09-04 05:17:48 +02:00
Mario Zechner
6679a83b32 fix(ai): Sanitize tool call IDs for Anthropic API compatibility
- Anthropic API requires tool call IDs to match pattern ^[a-zA-Z0-9_-]+$
- OpenAI Responses API generates IDs with pipe character (|) which breaks Anthropic
- Added sanitizeToolCallId() to replace invalid characters with underscores
- Fixes cross-provider handoffs from OpenAI Responses to Anthropic
- Added test to verify the fix works
2025-09-04 05:17:08 +02:00
Mario Zechner
080bf67306 chore: bump version to 0.5.28 2025-09-03 01:26:12 +02:00
Mario Zechner
4cee070bdd refactor(ai): Simplify API with new streaming interface and model management
- Replace createLLM with getModel/getModels/getProviders functions
- Rename PROVIDERS to MODELS (internal only, not exposed)
- Add streamSimple/completeSimple for unified reasoning interface
- Update README with new API examples and comprehensive documentation
- Remove model registration (models are now fixed from build time)
- Add proper TypeScript typing for provider-specific options
- Document context serialization, cross-provider handoffs, and browser usage
2025-09-03 01:25:19 +02:00
Mario Zechner
21750c230a More clean-up 2025-09-03 00:01:56 +02:00
Mario Zechner
acf0f5aee2 Clean-up 2025-09-03 00:01:32 +02:00
Mario Zechner
66cefb236e Massive refactor of API
- Switch to function based API
- Anthropic SDK style async generator
- Fully typed with escape hatches for custom models
2025-09-02 23:59:36 +02:00
Mario Zechner
004de3c9d0 feat(ai): Add new streaming generate API with AsyncIterable interface
- Implement QueuedGenerateStream class that extends AsyncIterable with finalMessage() method
- Add new types: GenerateStream, GenerateOptions, GenerateOptionsUnified, GenerateFunction
- Create generateAnthropic function-based implementation replacing class-based approach
- Add comprehensive test suite for the new generate API
- Support streaming events with text, thinking, and tool call deltas
- Map ReasoningEffort to provider-specific options
- Include apiKey in options instead of constructor parameter
2025-09-02 18:07:46 +02:00
Mario Zechner
be07c08a75 test(ai): Add empty assistant message tests
- Test providers handling empty assistant messages in conversation flow
- Pattern: user message -> empty assistant -> user message
- All providers handle empty assistant messages gracefully
- Tests ensure providers can continue conversation after empty response
2025-09-02 02:10:07 +02:00
Mario Zechner
0ac05a0676 test(ai): Add empty message tests for all providers
- Test handling of empty content arrays
- Test handling of empty string content
- Test handling of whitespace-only content
- All providers handle these edge cases gracefully
2025-09-02 02:03:06 +02:00
Mario Zechner
0fbb0921bb feat(ai): Add gpt-5-chat-latest model to generated models
- Added hardcoded gpt-5-chat-latest model since it's not in models.dev yet
- Model has image input support and proper pricing configuration
2025-09-02 01:32:26 +02:00
Mario Zechner
efaa5cdb39 feat(ai): Fetch Anthropic, Google, and OpenAI models from models.dev instead of OpenRouter
- Updated generate-models.ts to fetch these providers directly from models.dev API
- OpenRouter now only used for xAI and other third-party providers
- Fixed test model IDs to match new model names from models.dev
- Removed unused import from google.ts
2025-09-02 01:18:59 +02:00
Mario Zechner
f1c3d44602 chore: Bump version to 0.5.25 2025-09-02 00:20:26 +02:00
Mario Zechner
2cfd8ff3c3 fix(ai): Use API type instead of model for message compatibility checks
- Add getApi() method to all providers to identify the API type
- Add api field to AssistantMessage to track which API generated it
- Update transformMessages to check API compatibility instead of model
- Fixes issue where OpenAI Responses API failed when switching models
- Preserves thinking blocks and signatures when staying within same API
2025-09-02 00:20:06 +02:00
Mario Zechner
3007b7a5ac chore: Bump version to 0.5.24 2025-09-01 22:09:47 +02:00
Mario Zechner
32bede3352 docs(ai): Add browser usage section to README
- Document browser support and API key requirements
- Add security warning about exposing keys in frontend
- Keep documentation concise and practical
2025-09-01 22:09:24 +02:00
Mario Zechner
14d93ca8c6 chore: Bump version to 0.5.23 2025-09-01 22:03:09 +02:00
Mario Zechner
a62231987c fix(ai): Add anthropic-dangerous-direct-browser-access header
- Required header for browser-based access to Anthropic API
- Added to both OAuth and regular API key authentication
- Ensures full browser compatibility
2025-09-01 22:02:50 +02:00
Mario Zechner
8324cd4192 chore: Bump version to 0.5.22 2025-09-01 21:56:12 +02:00
Mario Zechner
da43e625f8 fix(ai): Add dangerouslyAllowBrowser flag for Anthropic client
- Enables browser support for Anthropic SDK
- Required for browser-based applications using the AI library
2025-09-01 21:55:52 +02:00
Mario Zechner
3caa3af8fc chore: Bump version to 0.5.21 2025-09-01 21:46:41 +02:00