Conversation
29987b9 to
4f114b9
Compare
…ponsibilities - Extract runAssistantLoop as a pure async generator (assistant-loop.ts) that yields events instead of calling session callbacks - Extract tool execution logic into tool-execution.ts - Introduce ChatRequestContext class to encapsulate per-request state (transcript staging + streaming turn buffer) - Reduce useAIChat hook to thin React orchestrator with single applyEvent dispatch point for all state transitions - Remove the 12-method AIChatSessionRequest god-interface
e38d1d2 to
e03b3e1
Compare
Code Metrics Report
Details | | main (bad3569) | #363 (2f0f180) | +/- |
|---------------------|----------------|----------------|-------|
- | Coverage | 87.5% | 87.4% | -0.1% |
| Files | 206 | 209 | +3 |
| Lines | 6084 | 6218 | +134 |
+ | Covered | 5325 | 5438 | +113 |
- | Test Execution Time | 1m25s | 2m6s | +41s |Code coverage of files in pull request scope (88.3% → 86.4%, patch 85.8%)
Reported by octocov |
commit: |
|
@copilot resolve the merge conflicts in this pull request |
…l-calling # Conflicts: # pnpm-lock.yaml Co-authored-by: IzumiSy <982850+IzumiSy@users.noreply.github.com>
Merged the latest |
|
@copilot resolve the merge conflicts in this pull request |
…l-calling # Conflicts: # decisions/documentation-management-overhaul.md Co-authored-by: IzumiSy <982850+IzumiSy@users.noreply.github.com>
Merged the latest |
|
@copilot fix CI errors |
Co-authored-by: IzumiSy <982850+IzumiSy@users.noreply.github.com>
Fixed the CI formatting failure in |
|
@copilot resolve the merge conflicts in this pull request |
…l-calling # Conflicts: # pnpm-lock.yaml
Merged the latest |
|
@copilot "decisions/documentation-management-overhaul.md"の差分はこのPRとは関係なさそうなので、diffから抜いてください。 |
Co-authored-by: IzumiSy <982850+IzumiSy@users.noreply.github.com>
Restored |
Motivation
useAIChat()previously covered only text request/response flows even though the AI Gateway transport can receive function calls. Applications need models to call local functions and use provider-managed tools.The API should keep provider SDK types out of ordinary AppShell applications while preserving the authenticated user's existing data permissions.
Design Decision
Keep tool ownership explicit
useAIChat()accepts local and provider tools throughtools. Local tools usedefineAIChatTool(...), validate arguments with the application's Standard Schema-compatible validator, execute in the browser, and return a tool result to the next model turn. Provider tools continue to be passed through to the AI Gateway.This leaves the hook responsible for local orchestration only and keeps its public messages user/assistant text-first.
Reuse application schema libraries
Local tools require runtime validation and JSON Schema generation. AppShell accepts Standard Schema and Standard JSON Schema implementations instead of introducing a schema DSL; Zod 4 supports both directly. This avoids duplicating validation and schema-generation behavior.
Summary
useAIChat()