Add Chrome Built-in AI (Prompt API / Gemini Nano) as a zero-download local provider in the AI Harness

未关闭
#1,215 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
68/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
活跃
技术栈
playwright, react, typescript
领域
ai, frontend

调研方向

Start with src/lib/ai/providers.ts, src/lib/ai/types.ts, and src/lib/ai/local-adapter.ts, then inspect the provider settings panels in src/components/studio/views/ai-harness-settings*.tsx. Implement and test capability detection plus provider integration in src/lib/ai/tools.ts and src/lib/ai/provider-errors.ts, using Playwright to mock the Prompt API. Done means an available built-in provider appears only for supported browsers, structured output and errors work through the existing adapter interface, and unit and E2E coverage passes.

由索引模型根据 Issue 内容生成。

描述

ai-agent enhancement feature priority: low

Summary

The AI Harness supports OpenRouter, Ollama, and in-browser models (transformers.js). There is a fourth local-first option that fits the product's "zero backend, minimal download" philosophy: the Chrome Built-in AI Prompt API (Gemini Nano). It ships with the browser — no weights to download, no remote calls, no Ollama install — and supports constrained/structured output, which is ideal for the harness's tool-calling and claim-extraction flows.

Evidence

  • Provider surface: src/lib/ai/providers.ts + src/lib/ai/local-adapter.ts (Ollama + in-browser models) + src/lib/ai/types.ts (provider abstraction to extend).
  • The Settings/AI Harness panels (src/components/studio/views/ai-harness-settings*.tsx) already model per-provider capability gating — the pattern to copy for capability detection.
  • No references to LanguageModel / window.ai / Prompt API exist in src/ today.

Impact

  • New feature with zero infrastructure: instant local AI for Chrome/Edge users without the ~25 MB model download of the semantic path or an Ollama install.
  • Fits privacy posture: on-device inference, opt-in, nothing leaves the device — consistent with ADR 045's threat model.
  • Structured output: responseConstraint gives JSON that always parses — a better primitive for client-side tool calls (src/lib/ai/tools.ts) than prompt-engineering.

Proposed approach

  1. Capability-detect self.LanguageModel.availability() (and LanguageModelParams); expose as a new provider in the harness only when available.
  2. Implement behind the existing provider adapter interface; reuse url-guard.ts-style defensive coding for the (absent) network path.
  3. Keep it clearly labeled "Chrome/Edge only" in the provider picker; follow the repo's capability-ladder UX: Prompt API → WebGPU in-browser model → Ollama → OpenRouter.
  4. E2E: mock the Prompt API in Playwright; unit tests for availability detection and error mapping via provider-errors.ts.

References

主要语言
TypeScript
星标
3
派生
2
平均合并
11 小时 49 分钟
30 天内合并 PR
102

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

d-oit/do-knowledge-studio 的其他 Issue

查看 d-oit/do-knowledge-studio 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。