docs: fix inaccuracies, add translations, and expand channel docs (#1837)
## Config field fixes (cross-verified against Go source) - MaixCam: server_address → host + port - IRC: use_tls → tls, channels_to_join → channels (all 6 languages) - WeCom AI Bot: callback port 18791 → 18790 - credential_encryption: base_url → api_base, add required model field, remove incorrect passphrase-only mode docs - providers.md: agents.defaults.model → model_name (×4), remove non-existent session.backlog_limit - migration guide, troubleshooting: agents.defaults.model → model_name - ANTIGRAVITY_AUTH: fix file path, Go 1.21 → 1.25, model → model_name - spawn-tasks: fix truncated file, add Heartbeat introduction - tools_configuration: add Tavily/SearXNG/GLMSearch, exec allow_remote/ timeout_seconds/custom_allow_patterns, cron allow_command, skills github/search_cache, clawhub timeout/max_zip_size/max_response_size - configuration: fix builtin skills path (build-time embedded, not cwd), HEARTBEAT.md marked auto-generated ## Broken link fixes (15 total) - chat-apps.md: WeCom/Matrix links with wrong relative paths - providers.md: migration link with extra docs/ prefix - hardware-compatibility.md: README links with wrong depth (all 5 langs) - chat-apps.md: WhatsApp dead links → anchor links (zh/ja) ## Getting-started accuracy - README (all 6 langs): add picoclaw.io as recommended download, add missing picoclaw model CLI command - docker.md: clarify first-run trigger condition (all 6 langs) - configuration.md: fix builtin skills path description (all 6 langs) ## QQ channel - Add quick setup via q.qq.com/qqbot/openclaw (one-click bot creation) - Add manual setup as fallback (all 6 languages) ## Feishu channel - Update setup flow: WebSocket/SDK mode, no webhook URL needed - Preserve Lark international domain note (all 6 languages) ## chat-apps.md - Add Feishu, Slack, IRC, OneBot detail sections (all 6 languages) - Add MaixCam section to ja/fr/pt-br/vi - Fix all channel doc links to point to correct language version ## New translations (25 files, 5 docs × 5 languages) debug.md, credential_encryption.md, hardware-compatibility.md, ANTIGRAVITY_AUTH.md, ANTIGRAVITY_USAGE.md → zh/ja/fr/pt-br/vi ## Channel docs (6 languages each, 60 new files) telegram, discord, qq, feishu, maixcam, dingtalk, line, slack, onebot, wecom/wecom_aibot, wecom/wecom_app, wecom/wecom_bot Co-authored-by: BeaconCat <BeaconCat@users.noreply.github.com>
This commit is contained in:
1 parent
0fe058254c
commit
403ceb39be
142 files changed
+11104
-367
No files matched your search
@@ -0,0 +1,809 @@
|
||||
> 返回 [README](../../README.zh.md)
|
||||
|
||||
# Antigravity 认证与集成指南
|
||||
|
||||
## 概述
|
||||
|
||||
**Antigravity**(Google Cloud Code Assist)是由 Google 支持的 AI 模型提供商,通过 Google 的云基础设施提供对 Claude Opus 4.6 和 Gemini 等模型的访问。本文档提供了关于认证工作原理、如何获取模型以及如何在 PicoClaw 中实现新提供商的完整指南。
|
||||
|
||||
---
|
||||
|
||||
## 目录
|
||||
|
||||
1. [认证流程](#认证流程)
|
||||
2. [OAuth 实现细节](#oauth-实现细节)
|
||||
3. [令牌管理](#令牌管理)
|
||||
4. [模型列表获取](#模型列表获取)
|
||||
5. [用量追踪](#用量追踪)
|
||||
6. [提供商插件结构](#提供商插件结构)
|
||||
7. [集成要求](#集成要求)
|
||||
8. [API 端点](#api-端点)
|
||||
9. [配置](#配置)
|
||||
10. [在 PicoClaw 中创建新提供商](#在-picoclaw-中创建新提供商)
|
||||
|
||||
---
|
||||
|
||||
## 认证流程
|
||||
|
||||
### 1. 带 PKCE 的 OAuth 2.0
|
||||
|
||||
Antigravity 使用 **OAuth 2.0 with PKCE(Proof Key for Code Exchange)** 进行安全认证:
|
||||
|
||||
```
|
||||
┌─────────────┐ ┌─────────────────┐
|
||||
│ Client │ ───(1) Generate PKCE Pair────────> │ │
|
||||
│ │ ───(2) Open Auth URL─────────────> │ Google OAuth │
|
||||
│ │ │ Server │
|
||||
│ │ <──(3) Redirect with Code───────── │ │
|
||||
│ │ └─────────────────┘
|
||||
│ │ ───(4) Exchange Code for Tokens──> │ Token URL │
|
||||
│ │ │ │
|
||||
│ │ <──(5) Access + Refresh Tokens──── │ │
|
||||
└─────────────┘ └─────────────────┘
|
||||
```
|
||||
|
||||
### 2. 详细步骤
|
||||
|
||||
#### 步骤 1:生成 PKCE 参数
|
||||
```typescript
|
||||
function generatePkce(): { verifier: string; challenge: string } {
|
||||
const verifier = randomBytes(32).toString("hex");
|
||||
const challenge = createHash("sha256").update(verifier).digest("base64url");
|
||||
return { verifier, challenge };
|
||||
}
|
||||
```
|
||||
|
||||
#### 步骤 2:构建授权 URL
|
||||
```typescript
|
||||
const AUTH_URL = "https://accounts.google.com/o/oauth2/v2/auth";
|
||||
const REDIRECT_URI = "http://localhost:51121/oauth-callback";
|
||||
|
||||
function buildAuthUrl(params: { challenge: string; state: string }): string {
|
||||
const url = new URL(AUTH_URL);
|
||||
url.searchParams.set("client_id", CLIENT_ID);
|
||||
url.searchParams.set("response_type", "code");
|
||||
url.searchParams.set("redirect_uri", REDIRECT_URI);
|
||||
url.searchParams.set("scope", SCOPES.join(" "));
|
||||
url.searchParams.set("code_challenge", params.challenge);
|
||||
url.searchParams.set("code_challenge_method", "S256");
|
||||
url.searchParams.set("state", params.state);
|
||||
url.searchParams.set("access_type", "offline");
|
||||
url.searchParams.set("prompt", "consent");
|
||||
return url.toString();
|
||||
}
|
||||
```
|
||||
|
||||
**所需权限范围:**
|
||||
```typescript
|
||||
const SCOPES = [
|
||||
"https://www.googleapis.com/auth/cloud-platform",
|
||||
"https://www.googleapis.com/auth/userinfo.email",
|
||||
"https://www.googleapis.com/auth/userinfo.profile",
|
||||
"https://www.googleapis.com/auth/cclog",
|
||||
"https://www.googleapis.com/auth/experimentsandconfigs",
|
||||
];
|
||||
```
|
||||
|
||||
#### 步骤 3:处理 OAuth 回调
|
||||
|
||||
**自动模式(本地开发):**
|
||||
- 在端口 51121 上启动本地 HTTP 服务器
|
||||
- 等待来自 Google 的重定向
|
||||
- 从查询参数中提取授权码
|
||||
|
||||
**手动模式(远程/无头环境):**
|
||||
- 向用户显示授权 URL
|
||||
- 用户在浏览器中完成认证
|
||||
- 用户将完整的重定向 URL 粘贴回终端
|
||||
- 从粘贴的 URL 中解析授权码
|
||||
|
||||
#### 步骤 4:用授权码交换令牌
|
||||
```typescript
|
||||
const TOKEN_URL = "https://oauth2.googleapis.com/token";
|
||||
|
||||
async function exchangeCode(params: {
|
||||
code: string;
|
||||
verifier: string;
|
||||
}): Promise<{ access: string; refresh: string; expires: number }> {
|
||||
const response = await fetch(TOKEN_URL, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
||||
body: new URLSearchParams({
|
||||
client_id: CLIENT_ID,
|
||||
client_secret: CLIENT_SECRET,
|
||||
code: params.code,
|
||||
grant_type: "authorization_code",
|
||||
redirect_uri: REDIRECT_URI,
|
||||
code_verifier: params.verifier,
|
||||
}),
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
return {
|
||||
access: data.access_token,
|
||||
refresh: data.refresh_token,
|
||||
expires: Date.now() + data.expires_in * 1000 - 5 * 60 * 1000, // 5 min buffer
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
#### 步骤 5:获取额外的用户数据
|
||||
|
||||
**用户邮箱:**
|
||||
```typescript
|
||||
async function fetchUserEmail(accessToken: string): Promise<string | undefined> {
|
||||
const response = await fetch(
|
||||
"https://www.googleapis.com/oauth2/v1/userinfo?alt=json",
|
||||
{ headers: { Authorization: `Bearer ${accessToken}` } }
|
||||
);
|
||||
const data = await response.json();
|
||||
return data.email;
|
||||
}
|
||||
```
|
||||
|
||||
**项目 ID(API 调用必需):**
|
||||
```typescript
|
||||
async function fetchProjectId(accessToken: string): Promise<string> {
|
||||
const headers = {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
"User-Agent": "google-api-nodejs-client/9.15.1",
|
||||
"X-Goog-Api-Client": "google-cloud-sdk vscode_cloudshelleditor/0.1",
|
||||
"Client-Metadata": JSON.stringify({
|
||||
ideType: "IDE_UNSPECIFIED",
|
||||
platform: "PLATFORM_UNSPECIFIED",
|
||||
pluginType: "GEMINI",
|
||||
}),
|
||||
};
|
||||
|
||||
const response = await fetch(
|
||||
"https://cloudcode-pa.googleapis.com/v1internal:loadCodeAssist",
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body: JSON.stringify({
|
||||
metadata: {
|
||||
ideType: "IDE_UNSPECIFIED",
|
||||
platform: "PLATFORM_UNSPECIFIED",
|
||||
pluginType: "GEMINI",
|
||||
},
|
||||
}),
|
||||
}
|
||||
);
|
||||
|
||||
const data = await response.json();
|
||||
return data.cloudaicompanionProject || "rising-fact-p41fc"; // 默认回退值
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## OAuth 实现细节
|
||||
|
||||
### 客户端凭据
|
||||
|
||||
**重要:** 这些凭据在源代码中以 base64 编码存储,用于与 pi-ai 同步:
|
||||
|
||||
```typescript
|
||||
const decode = (s: string) => Buffer.from(s, "base64").toString();
|
||||
|
||||
const CLIENT_ID = decode(
|
||||
"MTA3MTAwNjA2MDU5MS10bWhzc2luMmgyMWxjcmUyMzV2dG9sb2poNGc0MDNlcC5hcHBzLmdvb2dsZXVzZXJjb250ZW50LmNvbQ=="
|
||||
);
|
||||
const CLIENT_SECRET = decode("R09DU1BYLUs1OEZXUjQ4NkxkTEoxbUxCOHNYQzR6NnFEQWY=");
|
||||
```
|
||||
|
||||
### OAuth 流程模式
|
||||
|
||||
1. **自动流程**(有浏览器的本地机器):
|
||||
- 自动打开浏览器
|
||||
- 本地回调服务器捕获重定向
|
||||
- 初始认证后无需用户交互
|
||||
|
||||
2. **手动流程**(远程/无头/WSL2 环境):
|
||||
- 显示 URL 供手动复制粘贴
|
||||
- 用户在外部浏览器中完成认证
|
||||
- 用户将完整的重定向 URL 粘贴回来
|
||||
|
||||
```typescript
|
||||
function shouldUseManualOAuthFlow(isRemote: boolean): boolean {
|
||||
return isRemote || isWSL2Sync();
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 令牌管理
|
||||
|
||||
### 认证配置文件结构
|
||||
|
||||
```typescript
|
||||
type OAuthCredential = {
|
||||
type: "oauth";
|
||||
provider: "google-antigravity";
|
||||
access: string; // 访问令牌
|
||||
refresh: string; // 刷新令牌
|
||||
expires: number; // 过期时间戳(毫秒,自 epoch 起)
|
||||
email?: string; // 用户邮箱
|
||||
projectId?: string; // Google Cloud 项目 ID
|
||||
};
|
||||
```
|
||||
|
||||
### 令牌刷新
|
||||
|
||||
凭据包含一个刷新令牌,可在当前访问令牌过期时用于获取新的访问令牌。过期时间设置了 5 分钟的缓冲区以防止竞态条件。
|
||||
|
||||
---
|
||||
|
||||
## 模型列表获取
|
||||
|
||||
### 获取可用模型
|
||||
|
||||
```typescript
|
||||
const BASE_URL = "https://cloudcode-pa.googleapis.com";
|
||||
|
||||
async function fetchAvailableModels(
|
||||
accessToken: string,
|
||||
projectId: string
|
||||
): Promise<Model[]> {
|
||||
const headers = {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
"User-Agent": "antigravity",
|
||||
"X-Goog-Api-Client": "google-cloud-sdk vscode_cloudshelleditor/0.1",
|
||||
};
|
||||
|
||||
const response = await fetch(
|
||||
`${BASE_URL}/v1internal:fetchAvailableModels`,
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body: JSON.stringify({ project: projectId }),
|
||||
}
|
||||
);
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
// 返回带有配额信息的模型
|
||||
return Object.entries(data.models).map(([modelId, modelInfo]) => ({
|
||||
id: modelId,
|
||||
displayName: modelInfo.displayName,
|
||||
quotaInfo: {
|
||||
remainingFraction: modelInfo.quotaInfo?.remainingFraction,
|
||||
resetTime: modelInfo.quotaInfo?.resetTime,
|
||||
isExhausted: modelInfo.quotaInfo?.isExhausted,
|
||||
},
|
||||
}));
|
||||
}
|
||||
```
|
||||
|
||||
### 响应格式
|
||||
|
||||
```typescript
|
||||
type FetchAvailableModelsResponse = {
|
||||
models?: Record<string, {
|
||||
displayName?: string;
|
||||
quotaInfo?: {
|
||||
remainingFraction?: number | string;
|
||||
resetTime?: string; // ISO 8601 时间戳
|
||||
isExhausted?: boolean;
|
||||
};
|
||||
}>;
|
||||
};
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 用量追踪
|
||||
|
||||
### 获取用量数据
|
||||
|
||||
```typescript
|
||||
export async function fetchAntigravityUsage(
|
||||
token: string,
|
||||
timeoutMs: number
|
||||
): Promise<ProviderUsageSnapshot> {
|
||||
// 1. 获取额度和计划信息
|
||||
const loadCodeAssistRes = await fetch(
|
||||
`${BASE_URL}/v1internal:loadCodeAssist`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
metadata: {
|
||||
ideType: "ANTIGRAVITY",
|
||||
platform: "PLATFORM_UNSPECIFIED",
|
||||
pluginType: "GEMINI",
|
||||
},
|
||||
}),
|
||||
}
|
||||
);
|
||||
|
||||
// 提取额度信息
|
||||
const { availablePromptCredits, planInfo, currentTier } = data;
|
||||
|
||||
// 2. 获取模型配额
|
||||
const modelsRes = await fetch(
|
||||
`${BASE_URL}/v1internal:fetchAvailableModels`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
body: JSON.stringify({ project: projectId }),
|
||||
}
|
||||
);
|
||||
|
||||
// 构建用量窗口
|
||||
return {
|
||||
provider: "google-antigravity",
|
||||
displayName: "Google Antigravity",
|
||||
windows: [
|
||||
{ label: "Credits", usedPercent: calculateUsedPercent(available, monthly) },
|
||||
// 各模型配额...
|
||||
],
|
||||
plan: currentTier?.name || planType,
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
### 用量响应结构
|
||||
|
||||
```typescript
|
||||
type ProviderUsageSnapshot = {
|
||||
provider: "google-antigravity";
|
||||
displayName: string;
|
||||
windows: UsageWindow[];
|
||||
plan?: string;
|
||||
error?: string;
|
||||
};
|
||||
|
||||
type UsageWindow = {
|
||||
label: string; // "Credits" 或模型 ID
|
||||
usedPercent: number; // 0-100
|
||||
resetAt?: number; // 配额重置的时间戳
|
||||
};
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 提供商插件结构
|
||||
|
||||
### 插件定义
|
||||
|
||||
```typescript
|
||||
const antigravityPlugin = {
|
||||
id: "google-antigravity-auth",
|
||||
name: "Google Antigravity Auth",
|
||||
description: "OAuth flow for Google Antigravity (Cloud Code Assist)",
|
||||
configSchema: emptyPluginConfigSchema(),
|
||||
|
||||
register(api: PicoClawPluginApi) {
|
||||
api.registerProvider({
|
||||
id: "google-antigravity",
|
||||
label: "Google Antigravity",
|
||||
docsPath: "/providers/models",
|
||||
aliases: ["antigravity"],
|
||||
|
||||
auth: [
|
||||
{
|
||||
id: "oauth",
|
||||
label: "Google OAuth",
|
||||
hint: "PKCE + localhost callback",
|
||||
kind: "oauth",
|
||||
run: async (ctx: ProviderAuthContext) => {
|
||||
// OAuth 实现在此处
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### ProviderAuthContext
|
||||
|
||||
```typescript
|
||||
type ProviderAuthContext = {
|
||||
config: PicoClawConfig;
|
||||
agentDir?: string;
|
||||
workspaceDir?: string;
|
||||
prompter: WizardPrompter; // UI 提示/通知
|
||||
runtime: RuntimeEnv; // 日志等
|
||||
isRemote: boolean; // 是否在远程运行
|
||||
openUrl: (url: string) => Promise<void>; // 浏览器打开器
|
||||
oauth: {
|
||||
createVpsAwareHandlers: Function;
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
### ProviderAuthResult
|
||||
|
||||
```typescript
|
||||
type ProviderAuthResult = {
|
||||
profiles: Array<{
|
||||
profileId: string;
|
||||
credential: AuthProfileCredential;
|
||||
}>;
|
||||
configPatch?: Partial<PicoClawConfig>;
|
||||
defaultModel?: string;
|
||||
notes?: string[];
|
||||
};
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 集成要求
|
||||
|
||||
### 1. 所需环境/依赖
|
||||
|
||||
- Go ≥ 1.25
|
||||
- PicoClaw 代码库(`pkg/providers/` 和 `pkg/auth/`)
|
||||
- `crypto` 和 `net/http` 标准库包
|
||||
|
||||
### 2. API 调用所需的请求头
|
||||
|
||||
```typescript
|
||||
const REQUIRED_HEADERS = {
|
||||
"Authorization": `Bearer ${accessToken}`,
|
||||
"Content-Type": "application/json",
|
||||
"User-Agent": "antigravity", // 或 "google-api-nodejs-client/9.15.1"
|
||||
"X-Goog-Api-Client": "google-cloud-sdk vscode_cloudshelleditor/0.1",
|
||||
};
|
||||
|
||||
// 对于 loadCodeAssist 调用,还需包含:
|
||||
const CLIENT_METADATA = {
|
||||
ideType: "ANTIGRAVITY", // 或 "IDE_UNSPECIFIED"
|
||||
platform: "PLATFORM_UNSPECIFIED",
|
||||
pluginType: "GEMINI",
|
||||
};
|
||||
```
|
||||
|
||||
### 3. 模型 Schema 清理
|
||||
|
||||
Antigravity 使用兼容 Gemini 的模型,因此工具 schema 必须进行清理:
|
||||
|
||||
```typescript
|
||||
const GOOGLE_SCHEMA_UNSUPPORTED_KEYWORDS = new Set([
|
||||
"patternProperties",
|
||||
"additionalProperties",
|
||||
"$schema",
|
||||
"$id",
|
||||
"$ref",
|
||||
"$defs",
|
||||
"definitions",
|
||||
"examples",
|
||||
"minLength",
|
||||
"maxLength",
|
||||
"minimum",
|
||||
"maximum",
|
||||
"multipleOf",
|
||||
"pattern",
|
||||
"format",
|
||||
"minItems",
|
||||
"maxItems",
|
||||
"uniqueItems",
|
||||
"minProperties",
|
||||
"maxProperties",
|
||||
]);
|
||||
|
||||
// 发送前清理 schema
|
||||
function cleanToolSchemaForGemini(schema: Record<string, unknown>): unknown {
|
||||
// 移除不支持的关键字
|
||||
// 确保顶层有 type: "object"
|
||||
// 展平 anyOf/oneOf 联合类型
|
||||
}
|
||||
```
|
||||
|
||||
### 4. 思维块处理(Claude 模型)
|
||||
|
||||
对于 Antigravity 的 Claude 模型,思维块需要特殊处理:
|
||||
|
||||
```typescript
|
||||
const ANTIGRAVITY_SIGNATURE_RE = /^[A-Za-z0-9+/]+={0,2}$/;
|
||||
|
||||
export function sanitizeAntigravityThinkingBlocks(
|
||||
messages: AgentMessage[]
|
||||
): AgentMessage[] {
|
||||
// 验证思维签名
|
||||
// 规范化签名字段
|
||||
// 丢弃未签名的思维块
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## API 端点
|
||||
|
||||
### 认证端点
|
||||
|
||||
| 端点 | 方法 | 用途 |
|
||||
|------|------|------|
|
||||
| `https://accounts.google.com/o/oauth2/v2/auth` | GET | OAuth 授权 |
|
||||
| `https://oauth2.googleapis.com/token` | POST | 令牌交换 |
|
||||
| `https://www.googleapis.com/oauth2/v1/userinfo` | GET | 用户信息(邮箱) |
|
||||
|
||||
### Cloud Code Assist 端点
|
||||
|
||||
| 端点 | 方法 | 用途 |
|
||||
|------|------|------|
|
||||
| `https://cloudcode-pa.googleapis.com/v1internal:loadCodeAssist` | POST | 加载项目信息、额度、计划 |
|
||||
| `https://cloudcode-pa.googleapis.com/v1internal:fetchAvailableModels` | POST | 列出可用模型及配额 |
|
||||
| `https://cloudcode-pa.googleapis.com/v1internal:streamGenerateContent?alt=sse` | POST | 聊天流式端点 |
|
||||
|
||||
**API 请求格式(聊天):**
|
||||
`v1internal:streamGenerateContent` 端点期望一个包装标准 Gemini 请求的信封格式:
|
||||
|
||||
```json
|
||||
{
|
||||
"project": "your-project-id",
|
||||
"model": "model-id",
|
||||
"request": {
|
||||
"contents": [...],
|
||||
"systemInstruction": {...},
|
||||
"generationConfig": {...},
|
||||
"tools": [...]
|
||||
},
|
||||
"requestType": "agent",
|
||||
"userAgent": "antigravity",
|
||||
"requestId": "agent-timestamp-random"
|
||||
}
|
||||
```
|
||||
|
||||
**API 响应格式(SSE):**
|
||||
每条 SSE 消息(`data: {...}`)被包装在 `response` 字段中:
|
||||
|
||||
```json
|
||||
{
|
||||
"response": {
|
||||
"candidates": [...],
|
||||
"usageMetadata": {...},
|
||||
"modelVersion": "...",
|
||||
"responseId": "..."
|
||||
},
|
||||
"traceId": "...",
|
||||
"metadata": {}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 配置
|
||||
|
||||
### config.json 配置
|
||||
|
||||
```json
|
||||
{
|
||||
"model_list": [
|
||||
{
|
||||
"model_name": "gemini-flash",
|
||||
"model": "antigravity/gemini-3-flash",
|
||||
"auth_method": "oauth"
|
||||
}
|
||||
],
|
||||
"agents": {
|
||||
"defaults": {
|
||||
"model_name": "gemini-flash"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 认证配置文件存储
|
||||
|
||||
认证配置文件存储在 `~/.picoclaw/auth.json` 中:
|
||||
|
||||
```json
|
||||
{
|
||||
"credentials": {
|
||||
"google-antigravity": {
|
||||
"access_token": "ya29...",
|
||||
"refresh_token": "1//...",
|
||||
"expires_at": "2026-01-01T00:00:00Z",
|
||||
"provider": "google-antigravity",
|
||||
"auth_method": "oauth",
|
||||
"email": "user@example.com",
|
||||
"project_id": "my-project-id"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 在 PicoClaw 中创建新提供商
|
||||
|
||||
PicoClaw 提供商以 Go 包的形式实现,位于 `pkg/providers/` 下。要添加新提供商:
|
||||
|
||||
### 分步实现
|
||||
|
||||
#### 1. 创建提供商文件
|
||||
|
||||
在 `pkg/providers/` 中创建新的 Go 文件:
|
||||
|
||||
```
|
||||
pkg/providers/
|
||||
└── your_provider.go
|
||||
```
|
||||
|
||||
#### 2. 实现 Provider 接口
|
||||
|
||||
你的提供商必须实现 `pkg/providers/types.go` 中定义的 `Provider` 接口:
|
||||
|
||||
```go
|
||||
package providers
|
||||
|
||||
type YourProvider struct {
|
||||
apiKey string
|
||||
apiBase string
|
||||
}
|
||||
|
||||
func NewYourProvider(apiKey, apiBase, proxy string) *YourProvider {
|
||||
if apiBase == "" {
|
||||
apiBase = "https://api.your-provider.com/v1"
|
||||
}
|
||||
return &YourProvider{apiKey: apiKey, apiBase: apiBase}
|
||||
}
|
||||
|
||||
func (p *YourProvider) Chat(ctx context.Context, messages []Message, tools []Tool, cb StreamCallback) error {
|
||||
// 实现带流式传输的聊天补全
|
||||
}
|
||||
```
|
||||
|
||||
#### 3. 在工厂中注册
|
||||
|
||||
将你的提供商添加到 `pkg/providers/factory.go` 中的协议分支:
|
||||
|
||||
```go
|
||||
case "your-provider":
|
||||
return NewYourProvider(sel.apiKey, sel.apiBase, sel.proxy), nil
|
||||
```
|
||||
|
||||
#### 4. 添加默认配置(可选)
|
||||
|
||||
在 `pkg/config/defaults.go` 中添加默认条目:
|
||||
|
||||
```go
|
||||
{
|
||||
ModelName: "your-model",
|
||||
Model: "your-provider/model-name",
|
||||
APIKey: "",
|
||||
},
|
||||
```
|
||||
|
||||
#### 5. 添加认证支持(可选)
|
||||
|
||||
如果你的提供商需要 OAuth 或特殊认证,在 `cmd/picoclaw/internal/auth/helpers.go` 中添加分支:
|
||||
|
||||
```go
|
||||
case "your-provider":
|
||||
authLoginYourProvider()
|
||||
```
|
||||
|
||||
#### 6. 通过 `config.json` 配置
|
||||
|
||||
```json
|
||||
{
|
||||
"model_list": [
|
||||
{
|
||||
"model_name": "your-model",
|
||||
"model": "your-provider/model-name",
|
||||
"api_key": "your-api-key",
|
||||
"api_base": "https://api.your-provider.com/v1"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 测试你的实现
|
||||
|
||||
### CLI 命令
|
||||
|
||||
```bash
|
||||
# 使用提供商进行认证
|
||||
picoclaw auth login --provider your-provider
|
||||
|
||||
# 列出模型(用于 Antigravity)
|
||||
picoclaw auth models
|
||||
|
||||
# 启动网关
|
||||
picoclaw gateway
|
||||
|
||||
# 使用指定模型运行代理
|
||||
picoclaw agent -m "Hello" --model your-model
|
||||
```
|
||||
|
||||
### 测试用环境变量
|
||||
|
||||
```bash
|
||||
# 覆盖默认模型
|
||||
export PICOCLAW_AGENTS_DEFAULTS_MODEL=your-model
|
||||
|
||||
# 覆盖提供商设置
|
||||
export PICOCLAW_MODEL_LIST='[{"model_name":"your-model","model":"your-provider/model-name","api_key":"..."}]'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 参考资料
|
||||
|
||||
- **源文件:**
|
||||
- `pkg/providers/antigravity_provider.go` - Antigravity 提供商实现
|
||||
- `pkg/auth/oauth.go` - OAuth 流程实现
|
||||
- `pkg/auth/store.go` - 认证凭据存储(`~/.picoclaw/auth.json`)
|
||||
- `pkg/providers/factory.go` - 提供商工厂和协议路由
|
||||
- `pkg/providers/types.go` - 提供商接口定义
|
||||
- `cmd/picoclaw/internal/auth/helpers.go` - 认证 CLI 命令
|
||||
|
||||
- **文档:**
|
||||
- `docs/ANTIGRAVITY_USAGE.md` - Antigravity 使用指南
|
||||
- `docs/migration/model-list-migration.md` - 迁移指南
|
||||
|
||||
---
|
||||
|
||||
## 注意事项
|
||||
|
||||
1. **Google Cloud 项目:** Antigravity 要求在你的 Google Cloud 项目上启用 Gemini for Google Cloud
|
||||
2. **配额:** 使用 Google Cloud 项目配额(非独立计费)
|
||||
3. **模型访问:** 可用模型取决于你的 Google Cloud 项目配置
|
||||
4. **思维块:** 通过 Antigravity 使用的 Claude 模型需要对带签名的思维块进行特殊处理
|
||||
5. **Schema 清理:** 工具 schema 必须清理以移除不支持的 JSON Schema 关键字
|
||||
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
## 常见错误处理
|
||||
|
||||
### 1. 速率限制(HTTP 429)
|
||||
|
||||
当项目/模型配额耗尽时,Antigravity 会返回 429 错误。错误响应通常在 `details` 字段中包含 `quotaResetDelay`。
|
||||
|
||||
**429 错误示例:**
|
||||
```json
|
||||
{
|
||||
"error": {
|
||||
"code": 429,
|
||||
"message": "You have exhausted your capacity on this model. Your quota will reset after 4h30m28s.",
|
||||
"status": "RESOURCE_EXHAUSTED",
|
||||
"details": [
|
||||
{
|
||||
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
|
||||
"metadata": {
|
||||
"quotaResetDelay": "4h30m28.060903746s"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 2. 空响应(受限模型)
|
||||
|
||||
某些模型可能出现在可用模型列表中,但返回空响应(200 OK 但 SSE 流为空)。这通常发生在当前项目没有权限使用的预览版或受限模型上。
|
||||
|
||||
**处理方式:** 将空响应视为错误,通知用户该模型可能对其项目受限或无效。
|
||||
|
||||
---
|
||||
|
||||
## 故障排除
|
||||
|
||||
### "Token expired"(令牌已过期)
|
||||
- 刷新 OAuth 令牌:`picoclaw auth login --provider antigravity`
|
||||
|
||||
### "Gemini for Google Cloud is not enabled"(Gemini for Google Cloud 未启用)
|
||||
- 在 Google Cloud Console 中启用该 API
|
||||
|
||||
### "Project not found"(项目未找到)
|
||||
- 确保你的 Google Cloud 项目已启用必要的 API
|
||||
- 检查认证过程中项目 ID 是否正确获取
|
||||
|
||||
### 模型未出现在列表中
|
||||
- 验证 OAuth 认证是否成功完成
|
||||
- 检查认证配置文件存储:`~/.picoclaw/auth.json`
|
||||
- 重新运行 `picoclaw auth login --provider antigravity`
|
||||
@@ -0,0 +1,72 @@
|
||||
> 返回 [README](../../README.zh.md)
|
||||
|
||||
# 在 PicoClaw 中使用 Antigravity 提供商
|
||||
|
||||
本指南介绍如何在 PicoClaw 中设置和使用 **Antigravity**(Google Cloud Code Assist)提供商。
|
||||
|
||||
## 前提条件
|
||||
|
||||
1. 一个 Google 账户。
|
||||
2. 已启用 Google Cloud Code Assist(通常通过"Gemini for Google Cloud"引导流程获取)。
|
||||
|
||||
## 1. 身份验证
|
||||
|
||||
要使用 Antigravity 进行身份验证,请运行以下命令:
|
||||
|
||||
```bash
|
||||
picoclaw auth login --provider antigravity
|
||||
```
|
||||
|
||||
### 手动验证(无界面/VPS 环境)
|
||||
如果你在服务器(Coolify/Docker)上运行且无法访问 `localhost`,请按照以下步骤操作:
|
||||
1. 运行上述命令。
|
||||
2. 复制提供的 URL 并在本地浏览器中打开。
|
||||
3. 完成登录。
|
||||
4. 浏览器将重定向到 `localhost:51121` URL(页面将无法加载)。
|
||||
5. **从浏览器地址栏复制该最终 URL**。
|
||||
6. **将其粘贴回 PicoClaw 正在等待的终端中**。
|
||||
|
||||
PicoClaw 将自动提取授权码并完成流程。
|
||||
|
||||
## 2. 管理模型
|
||||
|
||||
### 列出可用模型
|
||||
查看你的项目可以访问哪些模型并检查其配额:
|
||||
|
||||
```bash
|
||||
picoclaw auth models
|
||||
```
|
||||
|
||||
### 切换模型
|
||||
你可以在 `~/.picoclaw/config.json` 中更改默认模型,或通过 CLI 覆盖:
|
||||
|
||||
```bash
|
||||
# 为单个命令覆盖
|
||||
picoclaw agent -m "Hello" --model claude-opus-4-6-thinking
|
||||
```
|
||||
|
||||
## 3. 实际使用(Coolify/Docker)
|
||||
|
||||
如果你通过 Coolify 或 Docker 部署,请按照以下步骤进行测试:
|
||||
|
||||
1. **环境变量**:
|
||||
* `PICOCLAW_AGENTS_DEFAULTS_MODEL=gemini-flash`
|
||||
2. **身份验证持久化**:
|
||||
如果你已在本地登录,可以将凭据复制到服务器:
|
||||
```bash
|
||||
scp ~/.picoclaw/auth.json user@your-server:~/.picoclaw/
|
||||
```
|
||||
*或者*,如果你有终端访问权限,可以在服务器上运行一次 `auth login` 命令。
|
||||
|
||||
## 4. 故障排除
|
||||
|
||||
* **空响应**:如果模型返回空回复,可能是该模型在你的项目中受到限制。请尝试 `gemini-3-flash` 或 `claude-opus-4-6-thinking`。
|
||||
* **429 速率限制**:Antigravity 有严格的配额限制。如果触发限制,PicoClaw 将在错误消息中显示"重置时间"。
|
||||
* **404 未找到**:确保你使用的是 `picoclaw auth models` 列表中的模型 ID。请使用短 ID(例如 `gemini-3-flash`),而非完整路径。
|
||||
|
||||
## 5. 可用模型总结
|
||||
|
||||
根据测试,以下模型最为可靠:
|
||||
* `gemini-3-flash`(快速,高可用性)
|
||||
* `gemini-2.5-flash-lite`(轻量级)
|
||||
* `claude-opus-4-6-thinking`(强大,包含推理能力)
|
||||
+62
-29
@@ -14,7 +14,7 @@ PicoClaw 支持多种聊天平台,使您的 Agent 能够连接到任何地方
|
||||
| -------------------- | ----------- | ----------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
|
||||
| **Telegram** | ⭐ 简单 | 推荐,支持语音转文字,长轮询无需公网 | [查看文档](../channels/telegram/README.zh.md) |
|
||||
| **Discord** | ⭐ 简单 | Socket Mode,支持群组/私信,Bot 生态成熟 | [查看文档](../channels/discord/README.zh.md) |
|
||||
| **WhatsApp** | ⭐ 简单 | 原生 (QR 扫码) 或 Bridge URL | [查看文档](../channels/whatsapp/README.zh.md) |
|
||||
| **WhatsApp** | ⭐ 简单 | 原生 (QR 扫码) 或 Bridge URL | [查看文档](#whatsapp) |
|
||||
| **Slack** | ⭐ 简单 | **Socket Mode** (无需公网 IP),企业级支持 | [查看文档](../channels/slack/README.zh.md) |
|
||||
| **Matrix** | ⭐⭐ 中等 | 联邦协议,支持自建 homeserver 与公开服务器 | [查看文档](../channels/matrix/README.zh.md) |
|
||||
| **QQ** | ⭐⭐ 中等 | 官方机器人 API,适合国内社群 | [查看文档](../channels/qq/README.zh.md) |
|
||||
@@ -207,12 +207,13 @@ picoclaw gateway
|
||||
<details>
|
||||
<summary><b>QQ</b></summary>
|
||||
|
||||
**1. 创建 Bot**
|
||||
**快速设置(推荐)**
|
||||
|
||||
- 前往 [QQ 开放平台](https://q.qq.com/#)
|
||||
- 创建应用 → 获取 **AppID** 和 **AppSecret**
|
||||
QQ 开放平台提供了一键创建 OpenClaw 兼容机器人的页面:
|
||||
|
||||
**2. 配置**
|
||||
1. 打开 [QQ 机器人快速创建](https://q.qq.com/qqbot/openclaw/index.html),扫码登录
|
||||
2. 机器人自动创建 — 复制 **App ID** 和 **App Secret**
|
||||
3. 配置 PicoClaw:
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -227,13 +228,20 @@ picoclaw gateway
|
||||
}
|
||||
```
|
||||
|
||||
> `allow_from` 留空表示允许所有用户,或指定 QQ 号限制访问。
|
||||
4. 运行 `picoclaw gateway`,打开 QQ 与机器人聊天
|
||||
|
||||
**3. 运行**
|
||||
> App Secret 仅显示一次,请立即保存 — 再次查看将强制重置。
|
||||
>
|
||||
> 通过快速创建页面创建的机器人初始仅限创建者使用,不支持群聊。如需启用群聊访问,请在 [QQ 开放平台](https://q.qq.com/) 配置沙箱模式。
|
||||
|
||||
```bash
|
||||
picoclaw gateway
|
||||
```
|
||||
**手动设置**
|
||||
|
||||
如果你更喜欢手动创建机器人:
|
||||
|
||||
* 登录 [QQ 开放平台](https://q.qq.com/) 注册成为开发者
|
||||
* 创建 QQ 机器人 — 自定义头像和名称
|
||||
* 从机器人设置中复制 **App ID** 和 **App Secret**
|
||||
* 按上述方式配置并运行 `picoclaw gateway`
|
||||
|
||||
</details>
|
||||
|
||||
@@ -242,9 +250,10 @@ picoclaw gateway
|
||||
|
||||
**1. 创建 Slack App**
|
||||
|
||||
* 前往 [Slack API](https://api.slack.com/apps) 创建应用
|
||||
* 启用 **Socket Mode**
|
||||
* 获取 **Bot Token** 和 **App-Level Token**
|
||||
* 前往 [Slack API](https://api.slack.com/apps) 创建新应用
|
||||
* 在 **OAuth & Permissions** 中添加 Bot 权限范围:`chat:write`、`app_mentions:read`、`im:history`、`im:read`、`im:write`
|
||||
* 将应用安装到你的工作区
|
||||
* 复制 **Bot Token**(`xoxb-...`)和 **App-Level Token**(`xapp-...`,启用 Socket Mode 后获取)
|
||||
|
||||
**2. 配置**
|
||||
|
||||
@@ -253,8 +262,8 @@ picoclaw gateway
|
||||
"channels": {
|
||||
"slack": {
|
||||
"enabled": true,
|
||||
"bot_token": "xoxb-YOUR_BOT_TOKEN",
|
||||
"app_token": "xapp-YOUR_APP_TOKEN",
|
||||
"bot_token": "xoxb-YOUR-BOT-TOKEN",
|
||||
"app_token": "xapp-YOUR-APP-TOKEN",
|
||||
"allow_from": []
|
||||
}
|
||||
}
|
||||
@@ -280,21 +289,26 @@ picoclaw gateway
|
||||
"irc": {
|
||||
"enabled": true,
|
||||
"server": "irc.libera.chat:6697",
|
||||
"tls": true,
|
||||
"nick": "picoclaw-bot",
|
||||
"use_tls": true,
|
||||
"channels_to_join": ["#your-channel"],
|
||||
"channels": ["#your-channel"],
|
||||
"password": "",
|
||||
"allow_from": []
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
可选:`nickserv_password` 用于 NickServ 认证,`sasl_user`/`sasl_password` 用于 SASL 认证。
|
||||
|
||||
**2. 运行**
|
||||
|
||||
```bash
|
||||
picoclaw gateway
|
||||
```
|
||||
|
||||
Bot 将连接到 IRC 服务器并加入指定的频道。
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
@@ -382,11 +396,14 @@ picoclaw gateway
|
||||
<details>
|
||||
<summary><b>飞书 (Feishu)</b></summary>
|
||||
|
||||
PicoClaw 通过 WebSocket/SDK 模式连接飞书 — 无需公网 Webhook URL 或回调服务器。
|
||||
|
||||
**1. 创建应用**
|
||||
|
||||
* 前往 [飞书开放平台](https://open.feishu.cn/)
|
||||
* 创建企业自建应用
|
||||
* 获取 **App ID** 和 **App Secret**
|
||||
* 前往 [飞书开放平台](https://open.feishu.cn/) 创建应用
|
||||
* 在应用设置中启用 **机器人** 能力
|
||||
* 创建版本并发布应用(应用必须发布后才能生效)
|
||||
* 复制 **App ID**(以 `cli_` 开头)和 **App Secret**
|
||||
|
||||
**2. 配置**
|
||||
|
||||
@@ -396,21 +413,25 @@ picoclaw gateway
|
||||
"feishu": {
|
||||
"enabled": true,
|
||||
"app_id": "cli_xxx",
|
||||
"app_secret": "xxx",
|
||||
"encrypt_key": "",
|
||||
"verification_token": "",
|
||||
"app_secret": "YOUR_APP_SECRET",
|
||||
"allow_from": []
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**3. 运行**
|
||||
可选:`encrypt_key` 和 `verification_token` 用于事件加密(生产环境推荐)。
|
||||
|
||||
**3. 运行并聊天**
|
||||
|
||||
```bash
|
||||
picoclaw gateway
|
||||
```
|
||||
|
||||
打开飞书,搜索你的机器人名称即可开始聊天。也可以将机器人添加到群组 — 使用 `group_trigger.mention_only: true` 设置为仅在 @提及时回复。
|
||||
|
||||
完整选项请参考 [飞书渠道配置指南](../channels/feishu/README.zh.md)。
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
@@ -496,7 +517,7 @@ picoclaw gateway
|
||||
**1. 创建 AI Bot**
|
||||
|
||||
* 企业微信管理后台 → 应用管理 → AI Bot
|
||||
* 在 AI Bot 设置中配置回调 URL:`http://your-server:18791/webhook/wecom-aibot`
|
||||
* 在 AI Bot 设置中配置回调 URL:`http://your-server:18790/webhook/wecom-aibot`
|
||||
* 复制 **Token** 并点击"随机生成" **EncodingAESKey**
|
||||
|
||||
**2. 配置**
|
||||
@@ -528,24 +549,36 @@ picoclaw gateway
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>OneBot</b></summary>
|
||||
<summary><b>OneBot(通过 OneBot 协议连接 QQ)</b></summary>
|
||||
|
||||
**1. 配置**
|
||||
OneBot 是 QQ 机器人的开放协议。PicoClaw 通过 WebSocket 连接任何 OneBot v11 兼容实现(如 [Lagrange](https://github.com/LagrangeDev/Lagrange.Core)、[NapCat](https://github.com/NapNeko/NapCatQQ))。
|
||||
|
||||
兼容 NapCat / Go-CQHTTP 等 OneBot 实现。
|
||||
**1. 设置 OneBot 实现**
|
||||
|
||||
安装并运行 OneBot v11 兼容的 QQ 机器人框架,启用其 WebSocket 服务器。
|
||||
|
||||
**2. 配置**
|
||||
|
||||
```json
|
||||
{
|
||||
"channels": {
|
||||
"onebot": {
|
||||
"enabled": true,
|
||||
"ws_url": "ws://127.0.0.1:8080",
|
||||
"access_token": "",
|
||||
"allow_from": []
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**2. 运行**
|
||||
| 字段 | 说明 |
|
||||
|------|------|
|
||||
| `ws_url` | OneBot 实现的 WebSocket URL |
|
||||
| `access_token` | 认证用的访问令牌(如果在 OneBot 中配置了的话) |
|
||||
| `reconnect_interval` | 重连间隔(秒)(默认:5) |
|
||||
|
||||
**3. 运行**
|
||||
|
||||
```bash
|
||||
picoclaw gateway
|
||||
|
||||
@@ -57,7 +57,7 @@ PicoClaw 将数据存储在您配置的工作区中(默认:`~/.picoclaw/work
|
||||
|
||||
1. `~/.picoclaw/workspace/skills`(工作区)
|
||||
2. `~/.picoclaw/skills`(全局)
|
||||
3. `<current-working-directory>/skills`(内置)
|
||||
3. `<构建时嵌入路径>/skills`(内置)
|
||||
|
||||
在高级/测试场景下,可通过以下环境变量覆盖内置技能目录:
|
||||
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
> 返回 [README](../../README.zh.md)
|
||||
|
||||
# 凭据加密
|
||||
|
||||
PicoClaw 支持对 `model_list` 配置条目中的 `api_key` 值进行加密。
|
||||
加密后的密钥以 `enc://<base64>` 字符串形式存储,并在启动时自动解密。
|
||||
|
||||
---
|
||||
|
||||
## 快速开始
|
||||
|
||||
**1. 设置密码短语**
|
||||
|
||||
```bash
|
||||
export PICOCLAW_KEY_PASSPHRASE="your-passphrase"
|
||||
```
|
||||
|
||||
**2. 加密 API 密钥**
|
||||
|
||||
运行 `picoclaw onboard` — 它会提示你输入密码短语并生成 SSH 密钥,
|
||||
然后在下一次 `SaveConfig` 调用时自动重新加密配置中所有明文 `api_key` 条目。生成的 `enc://` 值如下所示:
|
||||
|
||||
```
|
||||
enc://AAAA...base64...
|
||||
```
|
||||
|
||||
**3. 将输出粘贴到你的配置中**
|
||||
|
||||
```json
|
||||
{
|
||||
"model_list": [
|
||||
{
|
||||
"model_name": "gpt-4o",
|
||||
"model": "openai/gpt-4o",
|
||||
"api_key": "enc://AAAA...base64...",
|
||||
"api_base": "https://api.openai.com/v1"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 支持的 `api_key` 格式
|
||||
|
||||
| 格式 | 示例 | 行为 |
|
||||
|------|------|------|
|
||||
| 明文 | `sk-abc123` | 直接使用 |
|
||||
| 文件引用 | `file://openai.key` | 从配置文件所在目录读取内容 |
|
||||
| 加密 | `enc://<base64>` | 启动时使用 `PICOCLAW_KEY_PASSPHRASE` 解密 |
|
||||
| 空值 | `""` | 原样传递(用于 `auth_method: oauth`) |
|
||||
|
||||
---
|
||||
|
||||
## 加密设计
|
||||
|
||||
### 密钥派生
|
||||
|
||||
加密使用 **HKDF-SHA256**,并以 SSH 私钥作为第二因子。
|
||||
|
||||
```
|
||||
sshHash = SHA256(ssh_private_key_file_bytes)
|
||||
ikm = HMAC-SHA256(key=sshHash, message=passphrase)
|
||||
aes_key = HKDF-SHA256(ikm, salt, info="picoclaw-credential-v1", 32 bytes)
|
||||
```
|
||||
|
||||
### 加密
|
||||
|
||||
```
|
||||
AES-256-GCM(key=aes_key, nonce=random[12], plaintext=api_key)
|
||||
```
|
||||
|
||||
### 传输格式
|
||||
|
||||
```
|
||||
enc://<base64( salt[16] + nonce[12] + ciphertext )>
|
||||
```
|
||||
|
||||
| 字段 | 大小 | 描述 |
|
||||
|------|------|------|
|
||||
| `salt` | 16 字节 | 每次加密随机生成;输入 HKDF |
|
||||
| `nonce` | 12 字节 | 每次加密随机生成;AES-GCM IV |
|
||||
| `ciphertext` | 可变 | AES-256-GCM 密文 + 16 字节认证标签 |
|
||||
|
||||
GCM 认证标签会自动附加到密文之后。任何篡改都会导致解密失败并报错,而不是返回损坏的明文。
|
||||
|
||||
### 性能
|
||||
|
||||
| 操作 | 耗时 (ARM Cortex-A) |
|
||||
|------|---------------------|
|
||||
| 密钥派生 (HKDF) | < 1 ms |
|
||||
| AES-256-GCM 解密 | < 1 ms |
|
||||
| **启动总开销** | **每个密钥 < 2 ms** |
|
||||
|
||||
---
|
||||
|
||||
## 使用 SSH 密钥的双因子安全
|
||||
|
||||
当提供 SSH 私钥时,破解加密需要**同时具备**:
|
||||
|
||||
1. **密码短语** (`PICOCLAW_KEY_PASSPHRASE`)
|
||||
2. **SSH 私钥文件**
|
||||
|
||||
这意味着仅泄露配置文件不足以恢复 API 密钥,即使密码短语较弱也是如此。SSH 密钥贡献 256 位熵(Ed25519),与密码短语强度无关。
|
||||
|
||||
### 威胁模型
|
||||
|
||||
| 攻击者拥有 | 能否解密? |
|
||||
|------------|-----------|
|
||||
| 仅配置文件 | 否 — 需要密码短语 + SSH 密钥 |
|
||||
| 仅 SSH 密钥 | 否 — 需要密码短语 |
|
||||
| 仅密码短语 | 否 — 需要 SSH 密钥 |
|
||||
| 配置文件 + SSH 密钥 + 密码短语 | 是 — 完全泄露 |
|
||||
|
||||
---
|
||||
|
||||
## 环境变量
|
||||
|
||||
| 变量 | 是否必需 | 描述 |
|
||||
|------|----------|------|
|
||||
| `PICOCLAW_KEY_PASSPHRASE` | 是(用于 `enc://`) | 用于密钥派生的密码短语 |
|
||||
| `PICOCLAW_SSH_KEY_PATH` | 否 | SSH 私钥路径。如未设置,自动从 `~/.ssh/picoclaw_ed25519.key` 检测 |
|
||||
|
||||
### SSH 密钥自动检测
|
||||
|
||||
如果未设置 `PICOCLAW_SSH_KEY_PATH`,PicoClaw 会查找专用密钥:
|
||||
|
||||
```
|
||||
~/.ssh/picoclaw_ed25519.key
|
||||
```
|
||||
|
||||
此专用文件避免与用户现有的 SSH 密钥冲突。
|
||||
运行 `picoclaw onboard` 可自动生成该密钥。
|
||||
|
||||
`os.UserHomeDir()` 用于跨平台主目录解析(在 Windows 上读取 `USERPROFILE`,在 Unix/macOS 上读取 `HOME`)。
|
||||
|
||||
> **注意:** SSH 密钥文件是凭据加密的必要条件。如果未找到密钥且未设置 `PICOCLAW_SSH_KEY_PATH`,加密/解密将失败。运行 `picoclaw onboard` 可自动生成密钥。
|
||||
|
||||
---
|
||||
|
||||
## 迁移
|
||||
|
||||
由于唯一的密钥材料是 `PICOCLAW_KEY_PASSPHRASE` 和 SSH 私钥文件,迁移非常简单:
|
||||
|
||||
1. 将配置文件复制到新机器。
|
||||
2. 将 `PICOCLAW_KEY_PASSPHRASE` 设置为相同的值。
|
||||
3. 将 SSH 私钥文件复制到相同路径(或将 `PICOCLAW_SSH_KEY_PATH` 设置为新位置)。
|
||||
|
||||
无需重新加密。
|
||||
|
||||
---
|
||||
|
||||
## 安全注意事项
|
||||
|
||||
- **密码短语和 SSH 密钥都是必需的。** SSH 密钥作为第二因子 — 没有它,加密/解密将失败。如果密钥不存在,运行 `picoclaw onboard` 生成。
|
||||
- **SSH 密钥在运行时为只读。** PicoClaw 不会写入或修改 SSH 密钥文件。
|
||||
- **仍然支持明文密钥。** 不使用 `enc://` 的现有配置不受影响。
|
||||
- **`enc://` 格式通过版本控制**,通过 HKDF `info` 字段(`picoclaw-credential-v1`)实现,允许未来升级算法而不破坏现有加密值。
|
||||
@@ -0,0 +1,36 @@
|
||||
# 调试 PicoClaw
|
||||
|
||||
> 返回 [README](../../README.zh.md)
|
||||
|
||||
PicoClaw 在处理每一个请求时,都会在后台执行多个复杂的交互操作——从消息路由和复杂度评估,到工具执行和模型故障适配。能够准确地看到正在发生什么至关重要,这不仅有助于排查潜在问题,也有助于真正理解代理的运作方式。
|
||||
|
||||
## 以调试模式启动 PicoClaw
|
||||
|
||||
要获取代理运行的详细信息(LLM 请求、工具调用、消息路由),可以使用调试标志启动 PicoClaw 网关:
|
||||
|
||||
```bash
|
||||
picoclaw gateway --debug
|
||||
# or
|
||||
picoclaw gateway -d
|
||||
```
|
||||
|
||||
在此模式下,系统会对日志进行详细格式化,并显示系统提示词和工具执行结果的预览。
|
||||
|
||||
## 禁用日志截断(完整日志)
|
||||
|
||||
默认情况下,PicoClaw 会在调试日志中截断过长的字符串(例如*系统提示词*或大型 JSON 输出结果),以保持控制台的可读性。
|
||||
|
||||
如果你需要检查某个命令的完整输出,或发送给 LLM 模型的确切载荷,可以使用 `--no-truncate` 标志。
|
||||
|
||||
**注意:** 此标志*仅*在与 `--debug` 模式组合使用时有效。
|
||||
|
||||
```bash
|
||||
picoclaw gateway --debug --no-truncate
|
||||
|
||||
```
|
||||
|
||||
当此标志激活时,全局截断功能将被禁用。这在以下场景中非常有用:
|
||||
|
||||
* 验证发送给提供商的消息的确切语法。
|
||||
* 读取 `exec`、`web_fetch` 或 `read_file` 等工具的完整输出。
|
||||
* 调试保存在内存中的会话历史。
|
||||
@@ -12,6 +12,7 @@ git clone https://github.com/sipeed/picoclaw.git
|
||||
cd picoclaw
|
||||
|
||||
# 2. 首次运行 — 自动生成 docker/data/config.json 后退出
|
||||
# (仅在 config.json 和 workspace/ 都不存在时触发)
|
||||
docker compose -f docker/docker-compose.yml --profile gateway up
|
||||
# 容器打印 "First-run setup complete." 后自动停止
|
||||
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
> 返回 [README](../../README.zh.md)
|
||||
|
||||
# 🖥️ PicoClaw 硬件兼容性列表
|
||||
|
||||
PicoClaw 几乎可以在任何 Linux 设备上运行。本页面记录了已验证的芯片、产品和开发板。
|
||||
|
||||
**你的硬件不在列表中?** 提交 PR 来添加它!欢迎硬件厂商贡献和联合推广。
|
||||
|
||||
---
|
||||
|
||||
## 1. 已验证的芯片支持
|
||||
|
||||
### x86
|
||||
|
||||
| 厂商 | 芯片 | 备注 |
|
||||
|------|------|------|
|
||||
| Intel | Any x86 CPU (i386+) | 所有桌面/服务器/笔记本处理器 |
|
||||
| AMD | Any x86 CPU | 所有桌面/服务器/笔记本处理器 |
|
||||
|
||||
### ARM
|
||||
|
||||
| 子架构 | 典型芯片 | 备注 |
|
||||
|--------|----------|------|
|
||||
| ARMv6 | [BCM2835](https://www.raspberrypi.com/documentation/computers/processors.html#bcm2835) (Raspberry Pi 1/Zero) | 单核 ARM1176JZF-S |
|
||||
| ARMv7 | [Allwinner V3s](https://linux-sunxi.org/V3s) | 单核 Cortex-A7,用于 LicheePi Zero |
|
||||
| ARM64 | [Allwinner H618](https://linux-sunxi.org/H618) | 四核 Cortex-A53,用于 Orange Pi Zero 3 |
|
||||
| ARM64 | [BCM2711](https://www.raspberrypi.com/documentation/computers/processors.html#bcm2711) (Raspberry Pi 4) | 四核 Cortex-A72 |
|
||||
| ARM64 | [BCM2712](https://www.raspberrypi.com/documentation/computers/processors.html#bcm2712) (Raspberry Pi 5) | 四核 Cortex-A76 |
|
||||
| ARM64 | [AX630C](https://www.axera-tech.com/) (爱芯元智) | 双核 Cortex-A53 + NPU,用于 NanoKVM-Pro / MaixCAM2 |
|
||||
|
||||
### RISC-V (riscv64)
|
||||
|
||||
| 厂商 | 芯片 | 核心 | 备注 |
|
||||
|------|------|------|------|
|
||||
| [SOPHGO (算能)](https://www.sophgo.com/) | SG2002 | C906 @ 1GHz | 256MB DDR3 片上内存,用于 LicheeRV-Nano / NanoKVM / MaixCAM |
|
||||
| [Allwinner (全志)](https://www.allwinnertech.com/) | V861 | Dual C907 | 128MB DDR3L 片上内存,1 TOPS NPU,4K AI 摄像头 SiP |
|
||||
| [Allwinner (全志)](https://www.allwinnertech.com/) | V881 | C907 | RISC-V AI 摄像头系列 |
|
||||
| [Arterytek (匠芯创)](https://www.arterytek.com/) | D213 | RISC-V | 用于 HaaS506-LD1 工业 RTU |
|
||||
| [SpacemiT (进迭)](https://www.spacemit.com/) | K1 | 8x X60 @ 1.8GHz | 用于 Milk-V Jupiter, BananaPi BPI-F3 |
|
||||
| [SpacemiT (进迭)](https://www.spacemit.com/) | K3 | 8x X100 @ 2.5GHz | 符合 RVA23 规范,1024 位 RVV,FP8 AI 推理 |
|
||||
| [Zhihe (知合)](https://www.zhihe-tech.com/) | A210 | High-perf RISC-V | 8 核,16MB L3 缓存,桌面级 |
|
||||
| [Canaan (嘉楠)](https://www.canaan-creative.com/) | K230 | Dual C908 @ 1.6GHz | 6 TOPS KPU,用于 CanMV-K230 |
|
||||
|
||||
### MIPS
|
||||
|
||||
| 厂商 | 芯片 | 备注 |
|
||||
|------|------|------|
|
||||
| MediaTek | [MT7620](https://www.mediatek.com/products/home-networking/mt7620) | MIPS24KEc @ 580MHz,用于许多 OpenWrt 路由器(如小米路由器 3G) |
|
||||
|
||||
### LoongArch (loong64)
|
||||
|
||||
| 厂商 | 芯片 | 备注 |
|
||||
|------|------|------|
|
||||
| [Loongson (龙芯)](https://www.loongson.cn/) | 3A5000 | 四核 LA464 @ 2.5GHz,桌面/工作站 |
|
||||
| [Loongson (龙芯)](https://www.loongson.cn/) | 3A6000 | 四核 4C/8T @ 2.5GHz,IPC 可与 Intel 第十代相媲美 |
|
||||
| [Loongson (龙芯)](https://www.loongson.cn/) | 2K1000LA | 双核 @ 1GHz,工业/物联网应用 |
|
||||
|
||||
---
|
||||
|
||||
## 2. 已验证的产品(按发布日期排列)
|
||||
|
||||
已通过 PicoClaw 测试的消费产品、路由器和工业设备。
|
||||
|
||||
| 年份 | 产品 | 架构 | SoC | 内存 | 类别 |
|
||||
|------|------|------|-----|------|------|
|
||||
| 2009 | Nokia N900 | ARM (A8) | OMAP3430 | 256MB | 智能手机 |
|
||||
| 2012 | Samsung Galaxy Note 10.1 (N8000) | ARM (A9) | Exynos 4412 | 2GB | 平板电脑 |
|
||||
| 2016 | Xiaomi Router 3G (小米路由器3G) | MIPS | MT7620 | 256MB | 路由器 (OpenWrt) |
|
||||
| 2018 | Phicomm N1 (斐讯N1) | ARM64 (A53) | S905D | 2GB | 电视盒子 / 家庭服务器 |
|
||||
| 2019 | Xiaomi AI Speaker (小爱音箱) | ARM64 (A53) | — | 256MB | 智能音箱 |
|
||||
| 2024 | [NanoKVM](https://wiki.sipeed.com/hardware/en/kvm/NanoKVM/introduction.html) | RISC-V | SG2002 | 256MB | IP-KVM |
|
||||
| 2025 | HaaS506-LD1 | RISC-V | D213 | 128MB | 工业 RTU |
|
||||
| 2025 | [NanoKVM-Pro](https://wiki.sipeed.com/hardware/en/kvm/NanoKVM_Pro/introduction.html) | ARM64 (A53) | AX630C | 1GB | 专业 IP-KVM |
|
||||
| 2026 | [MaixCAM2](https://wiki.sipeed.com/hardware/en/maixcam/index.html) | ARM64 (A53) | AX630C | 1/4GB | 4K AI 摄像头 |
|
||||
|
||||
---
|
||||
|
||||
## 3. 已验证的开发板(按发布日期排列)
|
||||
|
||||
| 年份 | 开发板 | 架构 | SoC | 内存 | 购买链接 |
|
||||
|------|--------|------|-----|------|----------|
|
||||
| 2012 | [Raspberry Pi 1 Model B](https://www.raspberrypi.com/products/) | ARMv6 | BCM2835 | 512MB | — |
|
||||
| 2015 | [Raspberry Pi 2 Model B](https://www.raspberrypi.com/products/raspberry-pi-2-model-b/) | ARMv7 (A7) | BCM2836 | 1GB | — |
|
||||
| 2015 | [Raspberry Pi Zero](https://www.raspberrypi.com/products/raspberry-pi-zero/) | ARMv6 | BCM2835 | 512MB | — |
|
||||
| 2016 | [Raspberry Pi 3 Model B](https://www.raspberrypi.com/products/raspberry-pi-3-model-b/) | ARM64 (A53) | BCM2837 | 1GB | — |
|
||||
| 2017 | [LicheePi Zero](https://wiki.sipeed.com/hardware/en/lichee/Zero/Zero.html) | ARMv7 (A7) | Allwinner V3s | 64MB | [Sipeed](https://sipeed.com/) |
|
||||
| 2019 | [Raspberry Pi 4 Model B](https://www.raspberrypi.com/products/raspberry-pi-4-model-b/) | ARM64 (A72) | BCM2711 | 1~8GB | [RPi](https://www.raspberrypi.com/) |
|
||||
| 2023 | [Raspberry Pi 5](https://www.raspberrypi.com/products/raspberry-pi-5/) | ARM64 (A76) | BCM2712 | 2~8GB | [RPi](https://www.raspberrypi.com/) |
|
||||
| 2024 | [LicheeRV-Nano](https://wiki.sipeed.com/hardware/en/lichee/RV_Nano/1_intro.html) | RISC-V | SG2002 | 256MB | [AliExpress](https://www.aliexpress.com/item/1005006519668532.html) |
|
||||
| 2024 | [MaixCAM-Pro](https://wiki.sipeed.com/hardware/en/maixcam/index.html) | RISC-V | SG2002 | 256MB | [Sipeed](https://sipeed.com/) |
|
||||
| 2024 | [Milk-V Duo 64M](https://milkv.io/docs/duo/getting-started/duo) | RISC-V | CV1800B | 64MB | [Milk-V](https://milkv.io/) |
|
||||
| 2024 | [CanMV-K230](https://developer.canaan-creative.com/k230_canmv/en/main/) | RISC-V | K230 | 512MB | [Canaan](https://www.canaan-creative.com/) |
|
||||
|
||||
---
|
||||
|
||||
## 4. 同样适用于
|
||||
|
||||
### Android 手机(通过 Termux)
|
||||
|
||||
任何 ARM64 Android 手机(2015 年以后),1GB 以上内存。安装 [Termux](https://github.com/termux/termux-app),使用 `proot` 运行 PicoClaw。
|
||||
|
||||
> 参见 [README:在旧 Android 手机上运行](../../README.zh.md#-run-on-old-android-phones) 获取设置说明。
|
||||
|
||||
### 桌面 / 服务器 / 云
|
||||
|
||||
| 平台 | 备注 |
|
||||
|------|------|
|
||||
| x86_64 Linux | 原生二进制文件,无依赖 |
|
||||
| x86_64 Windows | 原生二进制文件 |
|
||||
| macOS (Intel / Apple Silicon) | 原生二进制文件 |
|
||||
| Docker (any platform) | `docker compose` 一行命令,参见 [Docker 指南](docker.md) |
|
||||
| OpenWrt routers | MIPS/ARM 构建,需要 >32MB 可用内存 |
|
||||
| FreeBSD / NetBSD | 提供 x86_64 和 arm64 构建 |
|
||||
|
||||
---
|
||||
|
||||
## 5. 最低要求
|
||||
|
||||
| 资源 | 最低要求 | 推荐配置 |
|
||||
|------|----------|----------|
|
||||
| 内存 | 10MB 可用 | 32MB 以上可用 |
|
||||
| 存储 | 20MB(二进制文件) | 50MB 以上(含工作区) |
|
||||
| CPU | 任意(单核 0.6GHz 以上) | — |
|
||||
| 操作系统 | Linux (kernel 3.x+) | Linux 5.x+ |
|
||||
| 网络 | 必需(用于 LLM API 调用) | 以太网或 WiFi |
|
||||
|
||||
---
|
||||
|
||||
## 6. 如何测试与贡献
|
||||
|
||||
```bash
|
||||
# 1. 下载适合你架构的版本
|
||||
wget https://github.com/sipeed/picoclaw/releases/latest/download/picoclaw_Linux_arm64.tar.gz
|
||||
tar xzf picoclaw_Linux_arm64.tar.gz
|
||||
|
||||
# 2. 初始化
|
||||
./picoclaw onboard
|
||||
|
||||
# 3. 测试
|
||||
./picoclaw agent -m "Hello, what board am I running on?"
|
||||
```
|
||||
|
||||
可用构建版本:`linux-amd64`, `linux-arm64`, `linux-arm`, `linux-riscv64`, `linux-loong64`, `linux-mipsle`
|
||||
|
||||
### 添加你的硬件
|
||||
|
||||
1. Fork 本仓库
|
||||
2. 将你的芯片/产品/开发板添加到相应的表格中
|
||||
3. 包含:名称、架构、SoC、内存、年份,以及可用的链接
|
||||
4. 提交 PR
|
||||
|
||||
硬件厂商:想要添加官方支持或联合推广?请提交 issue 或通过 [Discord](https://discord.gg/V4sAZ9XWpN) 联系我们。
|
||||
@@ -93,7 +93,7 @@
|
||||
],
|
||||
"agents": {
|
||||
"defaults": {
|
||||
"model": "gpt-5.4"
|
||||
"model_name": "gpt-5.4"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -266,7 +266,7 @@ PicoClaw 在发送请求前仅去除外层 `litellm/` 前缀,因此 `litellm/l
|
||||
],
|
||||
"agents": {
|
||||
"defaults": {
|
||||
"model": "glm-4.7"
|
||||
"model_name": "glm-4.7"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -298,7 +298,7 @@ PicoClaw 按协议族路由 Provider:
|
||||
"agents": {
|
||||
"defaults": {
|
||||
"workspace": "~/.picoclaw/workspace",
|
||||
"model": "glm-4.7",
|
||||
"model_name": "glm-4.7",
|
||||
"max_tokens": 8192,
|
||||
"temperature": 0.7,
|
||||
"max_tool_iterations": 20
|
||||
@@ -328,12 +328,11 @@ picoclaw agent -m "你好"
|
||||
{
|
||||
"agents": {
|
||||
"defaults": {
|
||||
"model": "anthropic/claude-opus-4-5"
|
||||
"model_name": "anthropic/claude-opus-4-5"
|
||||
}
|
||||
},
|
||||
"session": {
|
||||
"dm_scope": "per-channel-peer",
|
||||
"backlog_limit": 20
|
||||
"dm_scope": "per-channel-peer"
|
||||
},
|
||||
"providers": {
|
||||
"openrouter": {
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
|
||||
> 返回 [README](../../README.zh.md)
|
||||
|
||||
### 使用 Spawn 的异步任务
|
||||
PicoClaw 通过 `spawn` 工具支持**异步任务执行**。主要由 **Heartbeat(心跳)** 系统使用,在不阻塞主 Agent 循环的情况下运行耗时任务。
|
||||
|
||||
对于耗时较长的任务(网络搜索、API 调用),使用 `spawn` 工具创建一个 **子 Agent (subagent)**:
|
||||
## Heartbeat
|
||||
|
||||
心跳系统会定期检查 `workspace/HEARTBEAT.md` 中的计划任务。首次运行时会自动生成默认模板,你可以自定义它来定义快速任务(内联处理)和长任务(通过 `spawn` 委派)。
|
||||
|
||||
**`HEARTBEAT.md` 示例:**
|
||||
|
||||
```markdown
|
||||
# Periodic Tasks
|
||||
|
||||
## Quick Tasks (respond directly)
|
||||
|
||||
- Report current time
|
||||
|
||||
@@ -43,11 +43,12 @@ Web 工具用于网页搜索和抓取。
|
||||
|
||||
### Brave
|
||||
|
||||
| 配置项 | 类型 | 默认值 | 描述 |
|
||||
|---------------|--------|--------|--------------------|
|
||||
| `enabled` | bool | false | 启用 Brave 搜索 |
|
||||
| `api_key` | string | - | Brave Search API 密钥 |
|
||||
| `max_results` | int | 5 | 最大结果数 |
|
||||
| 配置项 | 类型 | 默认值 | 描述 |
|
||||
|---------------|----------|--------|------------------------------------------------|
|
||||
| `enabled` | bool | false | 启用 Brave 搜索 |
|
||||
| `api_key` | string | - | Brave Search API 密钥 |
|
||||
| `api_keys` | string[] | - | 多个 API 密钥轮换(优先于 `api_key`) |
|
||||
| `max_results` | int | 5 | 最大结果数 |
|
||||
|
||||
### DuckDuckGo
|
||||
|
||||
@@ -58,11 +59,46 @@ Web 工具用于网页搜索和抓取。
|
||||
|
||||
### Perplexity
|
||||
|
||||
| 配置项 | 类型 | 默认值 | 描述 |
|
||||
|---------------|--------|--------|-----------------------|
|
||||
| `enabled` | bool | false | 启用 Perplexity 搜索 |
|
||||
| `api_key` | string | - | Perplexity API 密钥 |
|
||||
| `max_results` | int | 5 | 最大结果数 |
|
||||
| 配置项 | 类型 | 默认值 | 描述 |
|
||||
|---------------|----------|--------|------------------------------------------------|
|
||||
| `enabled` | bool | false | 启用 Perplexity 搜索 |
|
||||
| `api_key` | string | - | Perplexity API 密钥 |
|
||||
| `api_keys` | string[] | - | 多个 API 密钥轮换(优先于 `api_key`) |
|
||||
| `max_results` | int | 5 | 最大结果数 |
|
||||
|
||||
### Tavily
|
||||
|
||||
| 配置项 | 类型 | 默认值 | 描述 |
|
||||
|---------------|--------|--------|-----------------------------------|
|
||||
| `enabled` | bool | false | 启用 Tavily 搜索 |
|
||||
| `api_key` | string | - | Tavily API 密钥 |
|
||||
| `base_url` | string | - | 自定义 Tavily API 基础 URL |
|
||||
| `max_results` | int | 0 | 最大结果数(0 = 默认) |
|
||||
|
||||
### SearXNG
|
||||
|
||||
| 配置项 | 类型 | 默认值 | 描述 |
|
||||
|---------------|--------|--------------------------|-----------------------|
|
||||
| `enabled` | bool | false | 启用 SearXNG 搜索 |
|
||||
| `base_url` | string | `http://localhost:8888` | SearXNG 实例 URL |
|
||||
| `max_results` | int | 5 | 最大结果数 |
|
||||
|
||||
### GLM Search
|
||||
|
||||
| 配置项 | 类型 | 默认值 | 描述 |
|
||||
|-----------------|--------|------------------------------------------------------|-----------------------|
|
||||
| `enabled` | bool | false | 启用 GLM 搜索 |
|
||||
| `api_key` | string | - | GLM API 密钥 |
|
||||
| `base_url` | string | `https://open.bigmodel.cn/api/paas/v4/web_search` | GLM Search API URL |
|
||||
| `search_engine` | string | `search_std` | 搜索引擎类型 |
|
||||
| `max_results` | int | 5 | 最大结果数 |
|
||||
|
||||
### 其他 Web 设置
|
||||
|
||||
| 配置项 | 类型 | 默认值 | 描述 |
|
||||
|--------------------------|----------|--------|-------------------------------------------------|
|
||||
| `prefer_native` | bool | true | 优先使用 provider 原生搜索而非配置的搜索引擎 |
|
||||
| `private_host_whitelist` | string[] | `[]` | 允许 Web 抓取的私有/内部主机白名单 |
|
||||
|
||||
## Exec 工具
|
||||
|
||||
@@ -154,6 +190,7 @@ Cron 工具用于调度周期性任务。
|
||||
| 配置项 | 类型 | 默认值 | 描述 |
|
||||
|------------------------|------|--------|-------------------------------------|
|
||||
| `exec_timeout_minutes` | int | 5 | 执行超时时间(分钟),0 表示无限制 |
|
||||
| `allow_command` | bool | false | 允许 cron 任务执行 shell 命令 |
|
||||
|
||||
## MCP 工具
|
||||
|
||||
@@ -320,9 +357,27 @@ Skills 工具配置通过 ClawHub 等注册表进行技能发现和安装。
|
||||
| `registries.clawhub.enabled` | bool | true | 启用 ClawHub 注册表 |
|
||||
| `registries.clawhub.base_url` | string | `https://clawhub.ai` | ClawHub 基础 URL |
|
||||
| `registries.clawhub.auth_token` | string | `""` | 可选的 Bearer 令牌,用于更高速率限制 |
|
||||
| `registries.clawhub.search_path` | string | `/api/v1/search` | 搜索 API 路径 |
|
||||
| `registries.clawhub.skills_path` | string | `/api/v1/skills` | Skills API 路径 |
|
||||
| `registries.clawhub.download_path` | string | `/api/v1/download` | 下载 API 路径 |
|
||||
| `registries.clawhub.search_path` | string | `""` | 搜索 API 路径 |
|
||||
| `registries.clawhub.skills_path` | string | `""` | Skills API 路径 |
|
||||
| `registries.clawhub.download_path` | string | `""` | 下载 API 路径 |
|
||||
| `registries.clawhub.timeout` | int | 0 | 请求超时时间(秒),0 = 默认 |
|
||||
| `registries.clawhub.max_zip_size` | int | 0 | 技能 zip 最大大小(字节),0 = 默认 |
|
||||
| `registries.clawhub.max_response_size` | int | 0 | API 响应最大大小(字节),0 = 默认 |
|
||||
|
||||
### GitHub 集成
|
||||
|
||||
| 配置项 | 类型 | 默认值 | 描述 |
|
||||
|------------------|--------|--------|-------------------------------|
|
||||
| `github.proxy` | string | `""` | GitHub API 请求的 HTTP 代理 |
|
||||
| `github.token` | string | `""` | GitHub 个人访问令牌 |
|
||||
|
||||
### 搜索设置
|
||||
|
||||
| 配置项 | 类型 | 默认值 | 描述 |
|
||||
|----------------------------|------|--------|--------------------------|
|
||||
| `max_concurrent_searches` | int | 2 | 最大并发技能搜索请求数 |
|
||||
| `search_cache.max_size` | int | 50 | 最大缓存搜索结果数 |
|
||||
| `search_cache.ttl_seconds` | int | 300 | 缓存 TTL(秒) |
|
||||
|
||||
### 配置示例
|
||||
|
||||
@@ -334,11 +389,17 @@ Skills 工具配置通过 ClawHub 等注册表进行技能发现和安装。
|
||||
"clawhub": {
|
||||
"enabled": true,
|
||||
"base_url": "https://clawhub.ai",
|
||||
"auth_token": "",
|
||||
"search_path": "/api/v1/search",
|
||||
"skills_path": "/api/v1/skills",
|
||||
"download_path": "/api/v1/download"
|
||||
"auth_token": ""
|
||||
}
|
||||
},
|
||||
"github": {
|
||||
"proxy": "",
|
||||
"token": ""
|
||||
},
|
||||
"max_concurrent_searches": 2,
|
||||
"search_cache": {
|
||||
"max_size": 50,
|
||||
"ttl_seconds": 300
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
**修复方法:** 在 `~/.picoclaw/config.json`(或你的配置路径)中:
|
||||
|
||||
1. **agents.defaults.model** 必须匹配 `model_list` 中的某个 `model_name`(例如 `"openrouter-free"`)。
|
||||
1. **agents.defaults.model_name** 必须匹配 `model_list` 中的某个 `model_name`(例如 `"openrouter-free"`)。
|
||||
2. 该条目的 **model** 必须是有效的 OpenRouter 模型 ID,例如:
|
||||
- `"openrouter/free"` – 自动免费层
|
||||
- `"google/gemini-2.0-flash-exp:free"`
|
||||
@@ -28,7 +28,7 @@
|
||||
{
|
||||
"agents": {
|
||||
"defaults": {
|
||||
"model": "openrouter-free"
|
||||
"model_name": "openrouter-free"
|
||||
}
|
||||
},
|
||||
"model_list": [
|
||||
|
||||
Reference in new issue
Block a user