Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ IMAGE ?= ghcr.io/russellluo/picoclaw
TAG ?= 2025.3.25
LOCAL_IMAGE ?= picoclaw:local

.DEFAULT_GOAL := build
.DEFAULT_GOAL := build-all

.PHONY: help fmt test build build-csgclaw build-csgclaw-cli build-all run onboard clean package package-all release tag push publish boxlite-setup

Expand Down
57 changes: 56 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,66 @@ go build ./cmd/csgclaw
## Quick Start

```bash
csgclaw onboard --base-url <url> --api-key <key> --model-id <model>
csgclaw onboard --base-url <url> --api-key <key> --models <model[,model...]> [--reasoning-effort <effort>]
csgclaw serve
```

Open the printed URL (e.g. `http://127.0.0.1:18080/`) in your browser to enter the IM workspace.
For a fresh config, `onboard` creates a single `default` provider and sets `models.default` to `default.<first-model>`.

## Model Provider Examples

### Remote LLM API

```toml
[server]
listen_addr = "0.0.0.0:18080"
advertise_base_url = "http://127.0.0.1:18080"
access_token = "your_access_token"

[models]
default = "remote.gpt-5.4"

[models.providers.remote]
base_url = "https://api.openai.com/v1"
api_key = "sk-your-api-key"
models = ["gpt-5.4"]

[bootstrap]
manager_image = "ghcr.io/russellluo/picoclaw:2026.4.8.1"
```

### Local Codex via CLIProxyAPI

```toml
[server]
listen_addr = "0.0.0.0:18080"
advertise_base_url = "http://127.0.0.1:18080"
access_token = "your_access_token"

[models]
default = "codex.gpt-5.4"

[models.providers.codex]
base_url = "http://127.0.0.1:8317/v1"
api_key = "local"
models = ["gpt-5.4"]

[bootstrap]
manager_image = "ghcr.io/russellluo/picoclaw:2026.4.8.1"
```

### Worker Override Example

```json
{
"id": "u-reviewer",
"name": "reviewer",
"description": "code review worker",
"profile": "codex.gpt-5.4",
"role": "worker"
}
```

## Features

Expand Down
57 changes: 56 additions & 1 deletion README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,66 @@ go build ./cmd/csgclaw
## 快速开始

```bash
csgclaw onboard --base-url <url> --api-key <key> --model-id <model>
csgclaw onboard --base-url <url> --api-key <key> --models <model[,model...]> [--reasoning-effort <effort>]
csgclaw serve
```

执行后 CLI 会打印访问地址(例如 `http://127.0.0.1:18080/`),在浏览器中打开即可进入 IM 工作区。
对于全新配置,`onboard` 会创建一个名为 `default` 的 provider,并把 `models.default` 设为 `default.<第一个模型>`。

## Model Provider 配置示例

### 远程 LLM API

```toml
[server]
listen_addr = "0.0.0.0:18080"
advertise_base_url = "http://127.0.0.1:18080"
access_token = "your_access_token"

[models]
default = "remote.gpt-5.4"

[models.providers.remote]
base_url = "https://api.openai.com/v1"
api_key = "sk-your-api-key"
models = ["gpt-5.4"]

[bootstrap]
manager_image = "ghcr.io/russellluo/picoclaw:2026.4.8.1"
```

### 通过 CLIProxyAPI 接入本地 Codex

```toml
[server]
listen_addr = "0.0.0.0:18080"
advertise_base_url = "http://127.0.0.1:18080"
access_token = "your_access_token"

[models]
default = "codex.gpt-5.4"

[models.providers.codex]
base_url = "http://127.0.0.1:8317/v1"
api_key = "local"
models = ["gpt-5.4"]

[bootstrap]
manager_image = "ghcr.io/russellluo/picoclaw:2026.4.8.1"
```

### Worker 覆盖示例

```json
{
"id": "u-reviewer",
"name": "reviewer",
"description": "code review worker",
"profile": "codex.gpt-5.4",
"role": "worker"
}
```

## 功能特性

Expand Down
4 changes: 2 additions & 2 deletions cli/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (c cmd) runCreate(ctx context.Context, run *command.Context, args []string,
id := fs.String("id", "", "agent id")
name := fs.String("name", "", "agent name")
description := fs.String("description", "", "agent description")
modelID := fs.String("model-id", "", "agent model identifier")
profile := fs.String("profile", "", "agent llm profile")
if err := fs.Parse(args); err != nil {
return err
}
Expand All @@ -101,7 +101,7 @@ func (c cmd) runCreate(ctx context.Context, run *command.Context, args []string,
ID: *id,
Name: *name,
Description: *description,
ModelID: *modelID,
Profile: *profile,
})
if err != nil {
return err
Expand Down
34 changes: 22 additions & 12 deletions cli/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ func TestExecuteAgentListUsesHTTPClient(t *testing.T) {
if req.URL.String() != "http://example.test/api/v1/agents" {
t.Fatalf("url = %q, want %q", req.URL.String(), "http://example.test/api/v1/agents")
}
return jsonResponse(http.StatusOK, `[{"id":"u-alice","name":"alice","role":"worker","status":"running","created_at":"2026-04-01T12:00:00Z"}]`), nil
return jsonResponse(http.StatusOK, `[{"id":"u-alice","name":"alice","role":"worker","status":"running","created_at":"2026-04-01T12:00:00Z","profile":"codex-main"}]`), nil
}),
}

if err := app.Execute(context.Background(), []string{"--endpoint", "http://example.test", "agent", "list"}); err != nil {
t.Fatalf("Execute() error = %v", err)
}
assertTableHasRow(t, stdout.String(), "u-alice", "alice", "worker", "running")
assertTableHasRow(t, stdout.String(), "u-alice", "alice", "worker", "running", "codex-main")
}

func TestExecuteBotListUsesDefaultChannel(t *testing.T) {
Expand Down Expand Up @@ -253,8 +253,8 @@ func TestExecuteMessageSendsToFeishuChannel(t *testing.T) {
func TestRenderAgentsTableAlignsLongColumns(t *testing.T) {
var buf bytes.Buffer
agents := []agent.Agent{
{ID: "u-manager", Name: "manager", Role: "manager", Status: "running"},
{ID: "u-dev", Name: "dev", Role: "worker", Status: "running"},
{ID: "u-manager", Name: "manager", Role: "manager", Status: "running", Profile: "codex-main"},
{ID: "u-dev", Name: "dev", Role: "worker", Status: "running", Profile: "claude-main"},
{ID: "u-alex", Name: "alex", Role: "worker", Status: "running"},
}

Expand All @@ -267,7 +267,7 @@ func TestRenderAgentsTableAlignsLongColumns(t *testing.T) {
t.Fatalf("line count = %d, want 4; output=%q", len(lines), buf.String())
}

re := regexp.MustCompile(`^(\S+)(\s{2,})(\S+)(\s{2,})(\S+)(\s{2,})(\S+)$`)
re := regexp.MustCompile(`^(\S+)(\s{2,})(\S+)(\s{2,})(\S+)(\s{2,})(\S+)(\s{2,})(\S+)$`)
if re.FindStringSubmatchIndex(lines[0]) == nil {
t.Fatalf("header not aligned: %q", lines[0])
}
Expand All @@ -282,6 +282,16 @@ func TestRenderAgentsTableAlignsLongColumns(t *testing.T) {
}
}

func TestRenderAgentsTableUsesDashForMissingProfile(t *testing.T) {
var buf bytes.Buffer

if err := renderAgentsTable(&buf, []agent.Agent{{ID: "u-alice", Name: "alice", Role: "worker", Status: "running"}}); err != nil {
t.Fatalf("renderAgentsTable() error = %v", err)
}

assertTableHasRow(t, buf.String(), "u-alice", "alice", "worker", "running", "-")
}

func TestExecuteAgentCreateUsesHTTPClient(t *testing.T) {
var stdout bytes.Buffer
app := &App{
Expand All @@ -308,19 +318,19 @@ func TestExecuteAgentCreateUsesHTTPClient(t *testing.T) {
if payload["description"] != "worker" {
t.Fatalf("payload[description] = %#v, want %q", payload["description"], "worker")
}
if payload["model_id"] != "gpt-test" {
t.Fatalf("payload[model_id] = %#v, want %q", payload["model_id"], "gpt-test")
if payload["profile"] != "cliproxy-codex" {
t.Fatalf("payload[profile] = %#v, want %q", payload["profile"], "cliproxy-codex")
}

return jsonResponse(http.StatusCreated, `{"id":"u-alice","name":"alice","role":"worker","status":"running","created_at":"2026-04-01T12:00:00Z"}`), nil
return jsonResponse(http.StatusCreated, `{"id":"u-alice","name":"alice","role":"worker","status":"running","created_at":"2026-04-01T12:00:00Z","profile":"codex-main"}`), nil
}),
}

err := app.Execute(context.Background(), []string{"--endpoint", "http://example.test", "--token", "secret-token", "agent", "create", "--name", "alice", "--description", "worker", "--model-id", "gpt-test"})
err := app.Execute(context.Background(), []string{"--endpoint", "http://example.test", "--token", "secret-token", "agent", "create", "--name", "alice", "--description", "worker", "--profile", "cliproxy-codex"})
if err != nil {
t.Fatalf("Execute() error = %v", err)
}
assertTableHasRow(t, stdout.String(), "u-alice", "alice", "worker", "running")
assertTableHasRow(t, stdout.String(), "u-alice", "alice", "worker", "running", "codex-main")
}

func TestExecuteAgentDeleteUsesHTTPClient(t *testing.T) {
Expand Down Expand Up @@ -357,14 +367,14 @@ func TestExecuteAgentStatusByIDUsesHTTPClient(t *testing.T) {
if req.URL.String() != "http://example.test/api/v1/agents/u-alice" {
t.Fatalf("url = %q, want %q", req.URL.String(), "http://example.test/api/v1/agents/u-alice")
}
return jsonResponse(http.StatusOK, `{"id":"u-alice","name":"alice","role":"worker","status":"running","created_at":"2026-04-01T12:00:00Z"}`), nil
return jsonResponse(http.StatusOK, `{"id":"u-alice","name":"alice","role":"worker","status":"running","created_at":"2026-04-01T12:00:00Z","profile":"codex-main"}`), nil
}),
}

if err := app.Execute(context.Background(), []string{"--endpoint", "http://example.test", "agent", "status", "u-alice"}); err != nil {
t.Fatalf("Execute() error = %v", err)
}
assertTableHasRow(t, stdout.String(), "u-alice", "alice", "worker", "running")
assertTableHasRow(t, stdout.String(), "u-alice", "alice", "worker", "running", "codex-main")
}

func TestExecuteAgentLogsUsesHTTPClient(t *testing.T) {
Expand Down
12 changes: 10 additions & 2 deletions cli/command/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,21 @@ func RenderMessages(output string, w io.Writer, messages []apitypes.Message) err

func RenderAgentsTable(w io.Writer, agents []agent.Agent) error {
tw := NewTableWriter(w)
fmt.Fprintln(tw, "ID\tNAME\tROLE\tSTATUS")
fmt.Fprintln(tw, "ID\tNAME\tROLE\tSTATUS\tPROFILE")
for _, a := range agents {
fmt.Fprintf(tw, "%s\t%s\t%s\t%s\n", a.ID, a.Name, a.Role, a.Status)
fmt.Fprintf(tw, "%s\t%s\t%s\t%s\t%s\n", a.ID, a.Name, a.Role, a.Status, displayAgentProfile(a.Profile))
}
return tw.Flush()
}

func displayAgentProfile(profile string) string {
profile = strings.TrimSpace(profile)
if profile == "" {
return "-"
}
return profile
}

func RenderBotsTable(w io.Writer, bots []apitypes.Bot) error {
tw := NewTableWriter(w)
fmt.Fprintln(tw, "ID\tNAME\tROLE\tCHANNEL\tAGENT\tUSER")
Expand Down
13 changes: 11 additions & 2 deletions cli/http_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io"
"net/http"
"net/url"
"strings"
"text/tabwriter"

"csgclaw/cli/command"
Expand Down Expand Up @@ -88,9 +89,9 @@ func writeJSON(w io.Writer, v any) error {

func renderAgentsTable(w io.Writer, agents []agent.Agent) error {
tw := newTableWriter(w)
fmt.Fprintln(tw, "ID\tNAME\tROLE\tSTATUS")
fmt.Fprintln(tw, "ID\tNAME\tROLE\tSTATUS\tPROFILE")
for _, a := range agents {
fmt.Fprintf(tw, "%s\t%s\t%s\t%s\n", a.ID, a.Name, a.Role, a.Status)
fmt.Fprintf(tw, "%s\t%s\t%s\t%s\t%s\n", a.ID, a.Name, a.Role, a.Status, displayAgentProfile(a.Profile))
}
return tw.Flush()
}
Expand All @@ -99,6 +100,14 @@ func renderBotsTable(w io.Writer, bots []apitypes.Bot) error {
return command.RenderBotsTable(w, bots)
}

func displayAgentProfile(profile string) string {
profile = strings.TrimSpace(profile)
if profile == "" {
return "-"
}
return profile
}

func renderRoomsTable(w io.Writer, rooms []apitypes.Room) error {
return command.RenderRoomsTable(w, rooms)
}
Expand Down
Loading