Skip to content

Commit 14de80d

Browse files
authored
Merge pull request #128 from yinwm/feat/better-version
feat: add git commit hash to version and improve documentation
2 parents 82fea61 + b5a8eff commit 14de80d

File tree

7 files changed

+289
-435
lines changed

7 files changed

+289
-435
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ coverage.html
3434

3535
# Ralph workspace
3636
ralph/
37-
.ralph/
37+
.ralph/
38+
tasks/

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ MAIN_GO=$(CMD_DIR)/main.go
88

99
# Version
1010
VERSION?=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
11+
GIT_COMMIT=$(shell git rev-parse --short=8 HEAD 2>/dev/null || echo "dev")
1112
BUILD_TIME=$(shell date +%FT%T%z)
1213
GO_VERSION=$(shell $(GO) version | awk '{print $$3}')
13-
LDFLAGS=-ldflags "-X main.version=$(VERSION) -X main.buildTime=$(BUILD_TIME) -X main.goVersion=$(GO_VERSION)"
14+
LDFLAGS=-ldflags "-X main.version=$(VERSION) -X main.gitCommit=$(GIT_COMMIT) -X main.buildTime=$(BUILD_TIME) -X main.goVersion=$(GO_VERSION)"
1415

1516
# Go variables
1617
GO?=go

README.ja.md

Lines changed: 163 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ picoclaw onboard
186186
"providers": {
187187
"openrouter": {
188188
"api_key": "xxx",
189-
"api_base": "https://open.bigmodel.cn/api/paas/v4"
189+
"api_base": "https://openrouter.ai/api/v1"
190190
}
191191
},
192192
"tools": {
@@ -223,12 +223,14 @@ picoclaw agent -m "What is 2+2?"
223223

224224
## 💬 チャットアプリ
225225

226-
Telegram で PicoClaw と会話できます
226+
Telegram、Discord、QQ、DingTalk で PicoClaw と会話できます
227227

228228
| チャネル | セットアップ |
229229
|---------|------------|
230230
| **Telegram** | 簡単(トークンのみ) |
231231
| **Discord** | 簡単(Bot トークン + Intents) |
232+
| **QQ** | 簡単(AppID + AppSecret) |
233+
| **DingTalk** | 普通(アプリ認証情報) |
232234

233235
<details>
234236
<summary><b>Telegram</b>(推奨)</summary>
@@ -307,6 +309,73 @@ picoclaw gateway
307309

308310
</details>
309311

312+
<details>
313+
<summary><b>QQ</b></summary>
314+
315+
**1. Bot を作成**
316+
317+
- [QQ オープンプラットフォーム](https://connect.qq.com/) にアクセス
318+
- アプリケーションを作成 → **AppID****AppSecret** を取得
319+
320+
**2. 設定**
321+
322+
```json
323+
{
324+
"channels": {
325+
"qq": {
326+
"enabled": true,
327+
"app_id": "YOUR_APP_ID",
328+
"app_secret": "YOUR_APP_SECRET",
329+
"allow_from": []
330+
}
331+
}
332+
}
333+
```
334+
335+
> `allow_from` を空にすると全ユーザーを許可、QQ番号を指定してアクセス制限可能。
336+
337+
**3. 起動**
338+
339+
```bash
340+
picoclaw gateway
341+
```
342+
343+
</details>
344+
345+
<details>
346+
<summary><b>DingTalk</b></summary>
347+
348+
**1. Bot を作成**
349+
350+
- [オープンプラットフォーム](https://open.dingtalk.com/) にアクセス
351+
- 内部アプリを作成
352+
- Client ID と Client Secret をコピー
353+
354+
**2. 設定**
355+
356+
```json
357+
{
358+
"channels": {
359+
"dingtalk": {
360+
"enabled": true,
361+
"client_id": "YOUR_CLIENT_ID",
362+
"client_secret": "YOUR_CLIENT_SECRET",
363+
"allow_from": []
364+
}
365+
}
366+
}
367+
```
368+
369+
> `allow_from` を空にすると全ユーザーを許可、ユーザーIDを指定してアクセス制限可能。
370+
371+
**3. 起動**
372+
373+
```bash
374+
picoclaw gateway
375+
```
376+
377+
</details>
378+
310379
## ⚙️ 設定
311380

312381
設定ファイル: `~/.picoclaw/config.json`
@@ -330,6 +399,98 @@ PicoClaw は設定されたワークスペース(デフォルト: `~/.picoclaw
330399
└── USER.md # ユーザー設定
331400
```
332401

402+
### 🔒 セキュリティサンドボックス
403+
404+
PicoClaw はデフォルトでサンドボックス環境で実行されます。エージェントは設定されたワークスペース内のファイルにのみアクセスし、コマンドを実行できます。
405+
406+
#### デフォルト設定
407+
408+
```json
409+
{
410+
"agents": {
411+
"defaults": {
412+
"workspace": "~/.picoclaw/workspace",
413+
"restrict_to_workspace": true
414+
}
415+
}
416+
}
417+
```
418+
419+
| オプション | デフォルト | 説明 |
420+
|-----------|-----------|------|
421+
| `workspace` | `~/.picoclaw/workspace` | エージェントの作業ディレクトリ |
422+
| `restrict_to_workspace` | `true` | ファイル/コマンドアクセスをワークスペースに制限 |
423+
424+
#### 保護対象ツール
425+
426+
`restrict_to_workspace: true` の場合、以下のツールがサンドボックス化されます:
427+
428+
| ツール | 機能 | 制限 |
429+
|-------|------|------|
430+
| `read_file` | ファイル読み込み | ワークスペース内のファイルのみ |
431+
| `write_file` | ファイル書き込み | ワークスペース内のファイルのみ |
432+
| `list_dir` | ディレクトリ一覧 | ワークスペース内のディレクトリのみ |
433+
| `edit_file` | ファイル編集 | ワークスペース内のファイルのみ |
434+
| `append_file` | ファイル追記 | ワークスペース内のファイルのみ |
435+
| `exec` | コマンド実行 | コマンドパスはワークスペース内である必要あり |
436+
437+
#### exec ツールの追加保護
438+
439+
`restrict_to_workspace: false` でも、`exec` ツールは以下の危険なコマンドをブロックします:
440+
441+
- `rm -rf`, `del /f`, `rmdir /s` — 一括削除
442+
- `format`, `mkfs`, `diskpart` — ディスクフォーマット
443+
- `dd if=` — ディスクイメージング
444+
- `/dev/sd[a-z]` への書き込み — 直接ディスク書き込み
445+
- `shutdown`, `reboot`, `poweroff` — システムシャットダウン
446+
- フォークボム `:(){ :|:& };:`
447+
448+
#### エラー例
449+
450+
```
451+
[ERROR] tool: Tool execution failed
452+
{tool=exec, error=Command blocked by safety guard (path outside working dir)}
453+
```
454+
455+
```
456+
[ERROR] tool: Tool execution failed
457+
{tool=exec, error=Command blocked by safety guard (dangerous pattern detected)}
458+
```
459+
460+
#### 制限の無効化(セキュリティリスク)
461+
462+
エージェントにワークスペース外のパスへのアクセスが必要な場合:
463+
464+
**方法1: 設定ファイル**
465+
```json
466+
{
467+
"agents": {
468+
"defaults": {
469+
"restrict_to_workspace": false
470+
}
471+
}
472+
}
473+
```
474+
475+
**方法2: 環境変数**
476+
```bash
477+
export PICOCLAW_AGENTS_DEFAULTS_RESTRICT_TO_WORKSPACE=false
478+
```
479+
480+
> ⚠️ **警告**: この制限を無効にすると、エージェントはシステム上の任意のパスにアクセスできるようになります。制御された環境でのみ慎重に使用してください。
481+
482+
#### セキュリティ境界の一貫性
483+
484+
`restrict_to_workspace` 設定は、すべての実行パスで一貫して適用されます:
485+
486+
| 実行パス | セキュリティ境界 |
487+
|---------|-----------------|
488+
| メインエージェント | `restrict_to_workspace`|
489+
| サブエージェント / Spawn | 同じ制限を継承 ✅ |
490+
| ハートビートタスク | 同じ制限を継承 ✅ |
491+
492+
すべてのパスで同じワークスペース制限が適用されます — サブエージェントやスケジュールタスクを通じてセキュリティ境界をバイパスする方法はありません。
493+
333494
### ハートビート(定期タスク)
334495

335496
PicoClaw は自動的に定期タスクを実行できます。ワークスペースに `HEARTBEAT.md` ファイルを作成します:

README.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,98 @@ PicoClaw stores data in your configured workspace (default: `~/.picoclaw/workspa
425425
└── USER.md # User preferences
426426
```
427427

428+
### 🔒 Security Sandbox
429+
430+
PicoClaw runs in a sandboxed environment by default. The agent can only access files and execute commands within the configured workspace.
431+
432+
#### Default Configuration
433+
434+
```json
435+
{
436+
"agents": {
437+
"defaults": {
438+
"workspace": "~/.picoclaw/workspace",
439+
"restrict_to_workspace": true
440+
}
441+
}
442+
}
443+
```
444+
445+
| Option | Default | Description |
446+
|--------|---------|-------------|
447+
| `workspace` | `~/.picoclaw/workspace` | Working directory for the agent |
448+
| `restrict_to_workspace` | `true` | Restrict file/command access to workspace |
449+
450+
#### Protected Tools
451+
452+
When `restrict_to_workspace: true`, the following tools are sandboxed:
453+
454+
| Tool | Function | Restriction |
455+
|------|----------|-------------|
456+
| `read_file` | Read files | Only files within workspace |
457+
| `write_file` | Write files | Only files within workspace |
458+
| `list_dir` | List directories | Only directories within workspace |
459+
| `edit_file` | Edit files | Only files within workspace |
460+
| `append_file` | Append to files | Only files within workspace |
461+
| `exec` | Execute commands | Command paths must be within workspace |
462+
463+
#### Additional Exec Protection
464+
465+
Even with `restrict_to_workspace: false`, the `exec` tool blocks these dangerous commands:
466+
467+
- `rm -rf`, `del /f`, `rmdir /s` — Bulk deletion
468+
- `format`, `mkfs`, `diskpart` — Disk formatting
469+
- `dd if=` — Disk imaging
470+
- Writing to `/dev/sd[a-z]` — Direct disk writes
471+
- `shutdown`, `reboot`, `poweroff` — System shutdown
472+
- Fork bomb `:(){ :|:& };:`
473+
474+
#### Error Examples
475+
476+
```
477+
[ERROR] tool: Tool execution failed
478+
{tool=exec, error=Command blocked by safety guard (path outside working dir)}
479+
```
480+
481+
```
482+
[ERROR] tool: Tool execution failed
483+
{tool=exec, error=Command blocked by safety guard (dangerous pattern detected)}
484+
```
485+
486+
#### Disabling Restrictions (Security Risk)
487+
488+
If you need the agent to access paths outside the workspace:
489+
490+
**Method 1: Config file**
491+
```json
492+
{
493+
"agents": {
494+
"defaults": {
495+
"restrict_to_workspace": false
496+
}
497+
}
498+
}
499+
```
500+
501+
**Method 2: Environment variable**
502+
```bash
503+
export PICOCLAW_AGENTS_DEFAULTS_RESTRICT_TO_WORKSPACE=false
504+
```
505+
506+
> ⚠️ **Warning**: Disabling this restriction allows the agent to access any path on your system. Use with caution in controlled environments only.
507+
508+
#### Security Boundary Consistency
509+
510+
The `restrict_to_workspace` setting applies consistently across all execution paths:
511+
512+
| Execution Path | Security Boundary |
513+
|----------------|-------------------|
514+
| Main Agent | `restrict_to_workspace`|
515+
| Subagent / Spawn | Inherits same restriction ✅ |
516+
| Heartbeat tasks | Inherits same restriction ✅ |
517+
518+
All paths share the same workspace restriction — there's no way to bypass the security boundary through subagents or scheduled tasks.
519+
428520
### Heartbeat (Periodic Tasks)
429521

430522
PicoClaw can perform periodic tasks automatically. Create a `HEARTBEAT.md` file in your workspace:

0 commit comments

Comments
 (0)